A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
multi-user-scheduler.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
9#ifndef MULTI_USER_SCHEDULER_H
10#define MULTI_USER_SCHEDULER_H
11
12#include "he-ru.h"
13
14#include "ns3/ap-wifi-mac.h"
15#include "ns3/ctrl-headers.h"
16#include "ns3/object.h"
17#include "ns3/wifi-remote-station-manager.h"
18#include "ns3/wifi-tx-parameters.h"
19
20#include <functional>
21#include <unordered_map>
22#include <vector>
23
24namespace ns3
25{
26
27class HeFrameExchangeManager;
28
29typedef std::unordered_map<uint16_t /* staId */, Ptr<WifiPsdu> /* PSDU */> WifiPsduMap;
30
31/**
32 * @ingroup wifi
33 *
34 * MultiUserScheduler is an abstract base class defining the API that APs
35 * supporting at least VHT can use to determine the format of their next transmission.
36 * VHT APs can only transmit DL MU PPDUs by using MU-MIMO, while HE APs can
37 * transmit both DL MU PPDUs and UL MU PPDUs by using OFDMA in addition to MU-MIMO.
38 *
39 * However, given that DL MU-MIMO is not yet supported, a MultiUserScheduler can
40 * only be aggregated to HE APs.
41 */
43{
44 public:
45 /**
46 * @brief Get the type ID.
47 * @return the object TypeId
48 */
49 static TypeId GetTypeId();
51 ~MultiUserScheduler() override;
52
53 /// Enumeration of the possible transmission formats
61
62 /// Information to be provided in case of DL MU transmission
63 struct DlMuInfo
64 {
65 WifiPsduMap psduMap; //!< the DL MU PPDU to transmit
66 WifiTxParameters txParams; //!< the transmission parameters
67 };
68
69 /// Information to be provided in case of UL MU transmission
70 struct UlMuInfo
71 {
72 CtrlTriggerHeader trigger; //!< the Trigger Frame used to solicit TB PPDUs
73 WifiMacHeader macHdr; //!< the MAC header for the Trigger Frame
74 WifiTxParameters txParams; //!< the transmission parameters for the Trigger Frame
75 };
76
77 /**
78 * Notify the Multi-user Scheduler that the given AC of the AP gained channel
79 * access. The Multi-user Scheduler determines the format of the next transmission.
80 *
81 * @param edca the EDCAF which has been granted the opportunity to transmit
82 * @param availableTime the amount of time allowed for the frame exchange. Pass
83 * Time::Min() in case the TXOP limit is null
84 * @param initialFrame true if the frame being transmitted is the initial frame
85 * of the TXOP. This is used to determine whether the TXOP
86 * limit can be exceeded
87 * @param allowedWidth the allowed width for the next transmission
88 * @param linkId the ID of the link over which channel access was gained
89 * @return the format of the next transmission
90 */
92 Time availableTime,
93 bool initialFrame,
94 MHz_u allowedWidth,
95 uint8_t linkId);
96
97 /**
98 * Get the information required to perform a DL MU transmission on the given link. Note
99 * that this method can only be called if GetTxFormat returns DL_MU_TX on the given link.
100 *
101 * @param linkId the ID of the given link
102 * @return the information required to perform a DL MU transmission
103 */
104 DlMuInfo& GetDlMuInfo(uint8_t linkId);
105
106 /**
107 * Get the information required to solicit an UL MU transmission on the given link. Note
108 * that this method can only be called if GetTxFormat returns UL_MU_TX on the given link.
109 *
110 * @param linkId the ID of the given link
111 * @return the information required to solicit an UL MU transmission
112 */
113 UlMuInfo& GetUlMuInfo(uint8_t linkId);
114
115 /**
116 * This method is called when a protection mechanism for an MU transmission is completed and
117 * gives the MU scheduler the opportunity to modify the MU PPDU or the TX parameters before
118 * the actual MU transmission.
119 *
120 * @param linkId ID of the link on which protection was completed
121 * @param psduMap the PSDU map to be transmitted
122 * @param txParams the TX parameters for the MU transmission
123 */
124 void NotifyProtectionCompleted(uint8_t linkId,
125 WifiPsduMap& psduMap,
126 WifiTxParameters& txParams);
127
128 /**
129 * When the TXOP limit is zero and the TXOP continues a SIFS after receiving a response to a
130 * BSRP TF, the Duration/ID field of the BSRP TF should be extended to reserve the medium
131 * for the frame exchange following the BSRP TF. This method is intended to return the estimated
132 * duration of the frame exchange following the BSRP TF (including the SIFS after the responses
133 * to the BSRP TF). Specifically, the base class method simply returns the default duration of
134 * TB PPDUs solicited via a Basic Trigger Frame. Subclasses can override this method to return
135 * a more accurate estimate of the time required by the following frame exchange.
136 *
137 * This method should only be called when the MU scheduler has determined that a BSRP TF has
138 * to be sent on the given link.
139 *
140 * @param linkId the ID of the given link
141 * @return the estimated duration of the frame exchange following the BSRP TF
142 */
143 virtual Time GetExtraTimeForBsrpTfDurationId(uint8_t linkId) const;
144
145 /**
146 * Set the duration of the interval between two consecutive requests for channel
147 * access made by the MultiUserScheduler.
148 *
149 * @param interval the duration of the interval between two consecutive requests
150 * for channel access
151 */
152 void SetAccessReqInterval(Time interval);
153
154 /**
155 * @return the duration of the interval between two consecutive requests for channel access
156 */
158
159 protected:
160 /**
161 * Get the station manager attached to the AP on the given link.
162 *
163 * @param linkId the ID of the given link
164 * @return the station manager attached to the AP on the given link
165 */
167
168 /**
169 * Get the HE Frame Exchange Manager attached to the AP on the given link.
170 *
171 * @param linkId the ID of the given link
172 * @return the HE Frame Exchange Manager attached to the AP on the given link
173 */
174 Ptr<HeFrameExchangeManager> GetHeFem(uint8_t linkId) const;
175
176 /**
177 * Get an MPDU containing the given Trigger Frame.
178 *
179 * @param trigger the given Trigger Frame
180 * @param linkId the ID of the link on which the Trigger Frame has to be sent
181 * @return an MPDU containing the given Trigger Frame
182 */
183 Ptr<WifiMpdu> GetTriggerFrame(const CtrlTriggerHeader& trigger, uint8_t linkId) const;
184
185 /**
186 * Update the given Trigger Frame after protection is completed on the given link.
187 *
188 * @param linkId the ID of the given link
189 * @param trigger the given Trigger Frame
190 * @param txParams the TX parameters for the UL MU transmission
191 */
192 virtual void UpdateTriggerFrameAfterProtection(uint8_t linkId,
193 CtrlTriggerHeader& trigger,
194 WifiTxParameters& txParams) const {};
195
196 /**
197 * Update the given PSDU map after protection is completed on the given link.
198 *
199 * @param linkId the ID of the given link
200 * @param psduMap the given PSDU map
201 * @param txParams the TX parameters for the DL MU transmission
202 */
203 virtual void UpdateDlMuAfterProtection(uint8_t linkId,
204 WifiPsduMap& psduMap,
205 WifiTxParameters& txParams) const {};
206
207 /**
208 * Remove the User Info fields for which the given predicate is true from the given Trigger
209 * Frame.
210 *
211 * @param linkId the ID of the link on which the Trigger Frame has to be sent
212 * @param trigger the given Trigger Frame
213 * @param txParams the TX parameters for the UL MU transmission
214 * @param predicate the given predicate (input parameters are link ID and device link address)
215 */
216 void RemoveRecipientsFromTf(uint8_t linkId,
217 CtrlTriggerHeader& trigger,
218 WifiTxParameters& txParams,
219 std::function<bool(uint8_t, Mac48Address)> predicate) const;
220
221 /**
222 * Remove PSDUs for which the given predicate is true from the given PSDU map. Entries in the
223 * TXVECTOR corresponding to such PSDUs are also removed.
224 *
225 * @param linkId the ID of the link on which the PSDU map has to be sent
226 * @param psduMap the given PSDU map
227 * @param txParams the TX parameters for the DL MU transmission
228 * @param predicate the given predicate (input parameters are link ID and device link address)
229 */
230 void RemoveRecipientsFromDlMu(uint8_t linkId,
231 WifiPsduMap& psduMap,
232 WifiTxParameters& txParams,
233 std::function<bool(uint8_t, Mac48Address)> predicate) const;
234
235 /**
236 * Get the format of the last transmission on the given link, as determined by
237 * the last call to NotifyAccessGranted that did not return NO_TX.
238 *
239 * @param linkId the ID of the given link
240 * @return the format of the last transmission on the given link
241 */
242 TxFormat GetLastTxFormat(uint8_t linkId) const;
243
244 /**
245 * Get the maximum size in bytes among the A-MPDUs containing QoS Null frames
246 * and solicited by the given (BSRP) Trigger Frame. For each station addressed
247 * by the Trigger Frame, the expected response is an A-MPDU containing as many
248 * QoS Null frames as the number of TIDs for which a BlockAck agreement has
249 * been established between the station and the AP.
250 *
251 * @param trigger the given Trigger Frame
252 * @return the maximum size in bytes among the A-MPDUs containing QoS Null frames
253 * and solicited by the given Trigger Frame
254 */
256
257 void DoDispose() override;
258 void NotifyNewAggregate() override;
259 void DoInitialize() override;
260
261 Ptr<ApWifiMac> m_apMac; //!< the AP wifi MAC
262 Ptr<QosTxop> m_edca; //!< the AC that gained channel access
263 Time m_availableTime; //!< the time available for frame exchange
264 bool m_initialFrame; //!< true if a TXOP is being started
265 MHz_u m_allowedWidth; //!< the allowed width for the current transmission
266 uint8_t m_linkId; //!< the ID of the link over which channel access has been granted
267 Time m_defaultTbPpduDuration; //!< the default duration of TB PPDUs solicited by Basic TFs
268
269 const std::function<bool(uint8_t, Mac48Address)>
270 m_isUnprotectedEmlsrClient; //!< predicate returning true if the device with the given
271 //!< (link) address is an EMLSR client that is not protected on
272 //!< the given link
273
274 private:
275 /**
276 * Set the wifi MAC. Note that it must be the MAC of an HE AP.
277 *
278 * @param mac the AP wifi MAC
279 */
280 void SetWifiMac(Ptr<ApWifiMac> mac);
281
282 /**
283 * Perform actions required on expiration of the channel access request timer associated with
284 * the given link, such as requesting channel access (if not requested already) and restarting
285 * the channel access request timer.
286 *
287 * @param linkId the ID of the given link
288 */
289 void AccessReqTimeout(uint8_t linkId);
290
291 /**
292 * Select the format of the next transmission.
293 *
294 * @return the format of the next transmission
295 */
297
298 /**
299 * Compute the information required to perform a DL MU transmission.
300 *
301 * @return the information required to perform a DL MU transmission
302 */
304
305 /**
306 * Prepare the information required to solicit an UL MU transmission.
307 *
308 * @return the information required to solicit an UL MU transmission
309 */
311
312 /**
313 * Ensure that the Trigger Frame returned in case of UL MU transmission is
314 * correct. Currently, this method sets the CS Required, the AP Tx Power and
315 * the UL Target Receive Power subfields.
316 */
317 void CheckTriggerFrame();
318
319 /**
320 * Type for the information about the last transmission
321 */
323 {
324 TxFormat lastTxFormat{NO_TX}; ///< the format of last transmission
325 DlMuInfo dlInfo; ///< information required to perform a DL MU transmission
326 UlMuInfo ulInfo; ///< information required to solicit an UL MU transmission
327 };
328
329 std::map<uint8_t, LastTxInfo> m_lastTxInfo; ///< Information about the last transmission
330 std::vector<EventId>
331 m_accessReqTimers; ///< the per-link timer controlling additional channel access requests
332 Time m_accessReqInterval; ///< duration of the interval between channel access requests
333 AcIndex m_accessReqAc; ///< AC we request channel access for
334 bool m_restartTimerUponAccess; ///< whether the channel access timer has to be restarted
335 ///< upon channel access
336};
337
338} // namespace ns3
339
340#endif /* MULTI_USER_SCHEDULER_H */
Headers for Trigger frames.
an EUI-48 address
MultiUserScheduler is an abstract base class defining the API that APs supporting at least VHT can us...
bool m_initialFrame
true if a TXOP is being started
void NotifyNewAggregate() override
Notify all Objects aggregated to this one of a new Object being aggregated.
void DoInitialize() override
Initialize() implementation.
Ptr< ApWifiMac > m_apMac
the AP wifi MAC
std::vector< EventId > m_accessReqTimers
the per-link timer controlling additional channel access requests
void CheckTriggerFrame()
Ensure that the Trigger Frame returned in case of UL MU transmission is correct.
static TypeId GetTypeId()
Get the type ID.
Time m_availableTime
the time available for frame exchange
void RemoveRecipientsFromTf(uint8_t linkId, CtrlTriggerHeader &trigger, WifiTxParameters &txParams, std::function< bool(uint8_t, Mac48Address)> predicate) const
Remove the User Info fields for which the given predicate is true from the given Trigger Frame.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId) const
Get the station manager attached to the AP on the given link.
UlMuInfo & GetUlMuInfo(uint8_t linkId)
Get the information required to solicit an UL MU transmission on the given link.
uint8_t m_linkId
the ID of the link over which channel access has been granted
virtual TxFormat SelectTxFormat()=0
Select the format of the next transmission.
void SetAccessReqInterval(Time interval)
Set the duration of the interval between two consecutive requests for channel access made by the Mult...
uint32_t GetMaxSizeOfQosNullAmpdu(const CtrlTriggerHeader &trigger) const
Get the maximum size in bytes among the A-MPDUs containing QoS Null frames and solicited by the given...
virtual void UpdateTriggerFrameAfterProtection(uint8_t linkId, CtrlTriggerHeader &trigger, WifiTxParameters &txParams) const
Update the given Trigger Frame after protection is completed on the given link.
bool m_restartTimerUponAccess
whether the channel access timer has to be restarted upon channel access
const std::function< bool(uint8_t, Mac48Address)> m_isUnprotectedEmlsrClient
predicate returning true if the device with the given (link) address is an EMLSR client that is not p...
virtual DlMuInfo ComputeDlMuInfo()=0
Compute the information required to perform a DL MU transmission.
Ptr< QosTxop > m_edca
the AC that gained channel access
void NotifyProtectionCompleted(uint8_t linkId, WifiPsduMap &psduMap, WifiTxParameters &txParams)
This method is called when a protection mechanism for an MU transmission is completed and gives the M...
virtual UlMuInfo ComputeUlMuInfo()=0
Prepare the information required to solicit an UL MU transmission.
Time m_defaultTbPpduDuration
the default duration of TB PPDUs solicited by Basic TFs
TxFormat GetLastTxFormat(uint8_t linkId) const
Get the format of the last transmission on the given link, as determined by the last call to NotifyAc...
void DoDispose() override
Destructor implementation.
Ptr< WifiMpdu > GetTriggerFrame(const CtrlTriggerHeader &trigger, uint8_t linkId) const
Get an MPDU containing the given Trigger Frame.
AcIndex m_accessReqAc
AC we request channel access for.
DlMuInfo & GetDlMuInfo(uint8_t linkId)
Get the information required to perform a DL MU transmission on the given link.
MHz_u m_allowedWidth
the allowed width for the current transmission
Ptr< HeFrameExchangeManager > GetHeFem(uint8_t linkId) const
Get the HE Frame Exchange Manager attached to the AP on the given link.
Time m_accessReqInterval
duration of the interval between channel access requests
TxFormat NotifyAccessGranted(Ptr< QosTxop > edca, Time availableTime, bool initialFrame, MHz_u allowedWidth, uint8_t linkId)
Notify the Multi-user Scheduler that the given AC of the AP gained channel access.
void SetWifiMac(Ptr< ApWifiMac > mac)
Set the wifi MAC.
virtual Time GetExtraTimeForBsrpTfDurationId(uint8_t linkId) const
When the TXOP limit is zero and the TXOP continues a SIFS after receiving a response to a BSRP TF,...
TxFormat
Enumeration of the possible transmission formats.
virtual void UpdateDlMuAfterProtection(uint8_t linkId, WifiPsduMap &psduMap, WifiTxParameters &txParams) const
Update the given PSDU map after protection is completed on the given link.
std::map< uint8_t, LastTxInfo > m_lastTxInfo
Information about the last transmission.
void RemoveRecipientsFromDlMu(uint8_t linkId, WifiPsduMap &psduMap, WifiTxParameters &txParams, std::function< bool(uint8_t, Mac48Address)> predicate) const
Remove PSDUs for which the given predicate is true from the given PSDU map.
void AccessReqTimeout(uint8_t linkId)
Perform actions required on expiration of the channel access request timer associated with the given ...
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
Implements the IEEE 802.11 MAC header.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition qos-utils.h:62
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< WifiPsdu > > WifiPsduMap
Map of PSDUs indexed by STA-ID.
Information to be provided in case of DL MU transmission.
WifiTxParameters txParams
the transmission parameters
WifiPsduMap psduMap
the DL MU PPDU to transmit
Type for the information about the last transmission.
TxFormat lastTxFormat
the format of last transmission
UlMuInfo ulInfo
information required to solicit an UL MU transmission
DlMuInfo dlInfo
information required to perform a DL MU transmission
Information to be provided in case of UL MU transmission.
WifiTxParameters txParams
the transmission parameters for the Trigger Frame
CtrlTriggerHeader trigger
the Trigger Frame used to solicit TB PPDUs
WifiMacHeader macHdr
the MAC header for the Trigger Frame