A Discrete-Event Network Simulator
API
multi-user-scheduler.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Stefano Avallone <stavallo@unina.it>
18 */
19
21
22#include "he-configuration.h"
24
25#include "ns3/abort.h"
26#include "ns3/log.h"
27#include "ns3/qos-txop.h"
28#include "ns3/wifi-acknowledgment.h"
29#include "ns3/wifi-mac-trailer.h"
30#include "ns3/wifi-protection.h"
31
32namespace ns3
33{
34
35NS_LOG_COMPONENT_DEFINE("MultiUserScheduler");
36
37NS_OBJECT_ENSURE_REGISTERED(MultiUserScheduler);
38
39TypeId
41{
42 static TypeId tid =
43 TypeId("ns3::MultiUserScheduler")
45 .SetGroupName("Wifi")
46 .AddAttribute("AccessReqInterval",
47 "Duration of the interval between two consecutive requests for "
48 "channel access made by the MultiUserScheduler. Such requests are "
49 "made independently of the presence of frames in the queues of the "
50 "AP and are intended to allow the AP to coordinate UL MU transmissions "
51 "even without DL traffic. A null duration indicates that such "
52 "requests shall not be made.",
56 .AddAttribute("AccessReqAc",
57 "The Access Category for which the MultiUserScheduler makes requests "
58 "for channel access.",
62 "AC_BE",
64 "AC_VI",
66 "AC_VO",
68 "AC_BK"))
69 .AddAttribute("DelayAccessReqUponAccess",
70 "If enabled, the access request interval is measured starting "
71 "from the last time an EDCA function obtained channel access. "
72 "Otherwise, the access request interval is measured starting "
73 "from the last time the MultiUserScheduler made a request for "
74 "channel access.",
75 BooleanValue(true),
78 return tid;
79}
80
82{
83}
84
86{
88}
89
90void
92{
93 NS_LOG_FUNCTION(this);
94 m_apMac = nullptr;
95 m_heFem = nullptr;
96 m_edca = nullptr;
97 m_dlInfo.psduMap.clear();
102}
103
104void
106{
107 NS_LOG_FUNCTION(this);
108 if (!m_apMac)
109 {
110 Ptr<ApWifiMac> apMac = this->GetObject<ApWifiMac>();
111 // verify that it's a valid AP mac and that
112 // the AP mac was not set before
113 if (apMac)
114 {
115 this->SetWifiMac(apMac);
116 }
117 }
119}
120
121void
123{
124 NS_LOG_FUNCTION(this);
125
127 {
130 }
131}
132
133void
135{
136 NS_LOG_FUNCTION(this << mac);
137 m_apMac = mac;
138
139 // When VHT DL MU-MIMO will be supported, we will have to lower this requirement
140 // and allow a Multi-user scheduler to be installed on a VHT AP.
142 "MultiUserScheduler can only be installed on HE APs");
143
144 m_heFem = DynamicCast<HeFrameExchangeManager>(m_apMac->GetFrameExchangeManager());
145 m_heFem->SetMultiUserScheduler(this);
146}
147
150{
152}
153
154void
156{
157 NS_LOG_FUNCTION(this);
158
159 // request channel access if not requested yet
160 auto edca = m_apMac->GetQosTxop(m_accessReqAc);
161
162 if (edca->GetAccessStatus(SINGLE_LINK_OP_ID) == Txop::NOT_REQUESTED)
163 {
165 }
166
167 // restart timer
170}
171
174 Time availableTime,
175 bool initialFrame,
176 uint16_t allowedWidth)
177{
178 NS_LOG_FUNCTION(this << edca << availableTime << initialFrame << allowedWidth);
179
180 m_edca = edca;
181 m_availableTime = availableTime;
182 m_initialFrame = initialFrame;
183 m_allowedWidth = allowedWidth;
184
186 {
187 // restart access timer
191 }
192
193 TxFormat txFormat = SelectTxFormat();
194
195 if (txFormat == DL_MU_TX)
196 {
198 }
199 else if (txFormat == UL_MU_TX)
200 {
201 NS_ABORT_MSG_IF(!m_heFem, "UL MU PPDUs are only supported by HE APs");
204 }
205
206 if (txFormat != NO_TX)
207 {
208 m_lastTxFormat = txFormat;
209 }
210 return txFormat;
211}
212
215{
216 return m_lastTxFormat;
217}
218
221{
222 NS_ABORT_MSG_IF(m_lastTxFormat != DL_MU_TX, "Next transmission is not DL MU");
223
224#ifdef NS3_BUILD_PROFILE_DEBUG
225 // check that all the addressed stations support HE
226 for (auto& psdu : m_dlInfo.psduMap)
227 {
228 NS_ABORT_MSG_IF(!GetWifiRemoteStationManager()->GetHeSupported(psdu.second->GetAddr1()),
229 "Station " << psdu.second->GetAddr1() << " does not support HE");
230 }
231#endif
232
233 return m_dlInfo;
234}
235
238{
239 NS_ABORT_MSG_IF(m_lastTxFormat != UL_MU_TX, "Next transmission is not UL MU");
240
241 return m_ulInfo;
242}
243
246{
247 NS_LOG_FUNCTION(this);
248
249 Ptr<Packet> packet = Create<Packet>();
250 packet->AddHeader(trigger);
251
253 if (trigger.GetNUserInfoFields() == 1)
254 {
255 auto aid = trigger.begin()->GetAid12();
256 auto aidAddrMapIt = m_apMac->GetStaList().find(aid);
257 NS_ASSERT(aidAddrMapIt != m_apMac->GetStaList().end());
258 receiver = aidAddrMapIt->second;
259 }
260
262 hdr.SetAddr1(receiver);
264 hdr.SetDsNotTo();
265 hdr.SetDsNotFrom();
266
267 return Create<WifiMpdu>(packet, hdr);
268}
269
270void
272{
273 NS_LOG_FUNCTION(this);
274
275 // Set the CS Required subfield to true, unless the UL Length subfield is less
276 // than or equal to 76 (see Section 26.5.2.5 of 802.11ax-2021)
278
279 m_heFem->SetTargetRssi(m_ulInfo.trigger);
280}
281
284{
285 // find the maximum number of TIDs for which a BlockAck agreement has been established
286 // with an STA, among all the STAs solicited by the given Trigger Frame
287 uint8_t maxNTids = 0;
288 for (const auto& userInfo : trigger)
289 {
290 const auto staIt = m_apMac->GetStaList().find(userInfo.GetAid12());
291 NS_ASSERT(staIt != m_apMac->GetStaList().cend());
292 uint8_t staNTids = 0;
293 for (uint8_t tid = 0; tid < 8; tid++)
294 {
295 if (m_heFem->GetBaAgreementEstablished(staIt->second, tid))
296 {
297 staNTids++;
298 }
299 }
300 maxNTids = std::max(maxNTids, staNTids);
301 }
302
303 // compute the size in bytes of maxNTids QoS Null frames
305 header.SetDsTo();
306 header.SetDsNotFrom();
307 uint32_t headerSize = header.GetSerializedSize();
308 uint32_t maxSize = 0;
309
310 for (uint8_t i = 0; i < maxNTids; i++)
311 {
312 maxSize = MpduAggregator::GetSizeIfAggregated(headerSize + WIFI_MAC_FCS_LENGTH, maxSize);
313 }
314
315 return maxSize;
316}
317
318} // namespace ns3
#define max(a, b)
Definition: 80211b.c:43
const std::map< uint16_t, Mac48Address > & GetStaList(uint8_t linkId=SINGLE_LINK_OP_ID) const
Get a const reference to the map of associated stations on the given link.
AttributeValue implementation for Boolean.
Definition: boolean.h:37
void RequestAccess(Ptr< Txop > txop)
Headers for Trigger frames.
Definition: ctrl-headers.h:886
ConstIterator begin() const
Get a const iterator pointing to the first User Info field in the list.
std::size_t GetNUserInfoFields() const
Get the number of User Info fields in this Trigger Frame.
void SetCsRequired(bool cs)
Set the CS Required subfield of the Common Info field.
uint16_t GetUlLength() const
Get the UL Length subfield of the Common Info field.
Hold variables of type enum.
Definition: enum.h:56
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:55
bool IsRunning() const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:76
an EUI-48 address
Definition: mac48-address.h:46
static Mac48Address GetBroadcast()
static uint32_t GetSizeIfAggregated(uint32_t mpduSize, uint32_t ampduSize)
Compute the size of the A-MPDU resulting from the aggregation of an MPDU of size mpduSize and an A-MP...
bool m_initialFrame
true if a TXOP is being started
Ptr< WifiMpdu > GetTriggerFrame(const CtrlTriggerHeader &trigger) const
Get an MPDU containing the given Trigger Frame.
void NotifyNewAggregate() override
Notify all Objects aggregated to this one of a new Object being aggregated.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager() const
Get the station manager attached to the AP.
void DoInitialize() override
Initialize() implementation.
DlMuInfo & GetDlMuInfo()
Get the information required to perform a DL MU transmission.
void AccessReqTimeout()
Perform actions required on expiration of the channel access request timer, such as requesting channe...
UlMuInfo m_ulInfo
information required to solicit an UL MU transmission
TxFormat m_lastTxFormat
the format of last transmission
TxFormat NotifyAccessGranted(Ptr< QosTxop > edca, Time availableTime, bool initialFrame, uint16_t allowedWidth)
Notify the Multi-user Scheduler that the given AC of the AP gained channel access.
Ptr< ApWifiMac > m_apMac
the AP wifi MAC
void CheckTriggerFrame()
Ensure that the Trigger Frame returned in case of UL MU transmission is correct.
static TypeId GetTypeId()
Get the type ID.
uint16_t m_allowedWidth
the allowed width in MHz for the current transmission
UlMuInfo & GetUlMuInfo()
Get the information required to solicit an UL MU transmission.
Time m_availableTime
the time available for frame exchange
EventId m_accessReqTimer
the timer controlling additional channel access requests
virtual TxFormat SelectTxFormat()=0
Select the format of the next transmission.
DlMuInfo m_dlInfo
information required to perform a DL MU transmission
Ptr< HeFrameExchangeManager > m_heFem
HE Frame Exchange Manager.
TxFormat GetLastTxFormat() const
Get the format of the last transmission, as determined by the last call to NotifyAccessGranted that d...
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...
bool m_restartTimerUponAccess
whether the channel access timer has to be restarted upon channel access
virtual DlMuInfo ComputeDlMuInfo()=0
Compute the information required to perform a DL MU transmission.
Ptr< QosTxop > m_edca
the AC that gained channel access
virtual UlMuInfo ComputeUlMuInfo()=0
Prepare the information required to solicit an UL MU transmission.
void DoDispose() override
Destructor implementation.
AcIndex m_accessReqAc
AC we request channel access for.
Time m_accessReqInterval
duration of the interval between channel access requests
void SetWifiMac(Ptr< ApWifiMac > mac)
Set the wifi MAC.
TxFormat
Enumeration of the possible transmission formats.
A base class which provides memory management and object aggregation.
Definition: object.h:89
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
Definition: object.cc:332
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:353
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:268
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:568
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
Definition: nstime.h:350
AttributeValue implementation for Time.
Definition: nstime.h:1425
@ NOT_REQUESTED
Definition: txop.h:100
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
Implements the IEEE 802.11 MAC header.
uint32_t GetSerializedSize() const override
void SetDsNotFrom()
Un-set the From DS bit in the Frame Control field.
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
void SetDsTo()
Set the To DS bit in the Frame Control field.
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
void SetDsNotTo()
Un-set the To DS bit in the Frame Control field.
Ptr< FrameExchangeManager > GetFrameExchangeManager(uint8_t linkId=SINGLE_LINK_OP_ID) const
Get the Frame Exchange Manager associated with the given link.
Definition: wifi-mac.cc:835
Ptr< HeConfiguration > GetHeConfiguration() const
Definition: wifi-mac.cc:1250
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId=0) const
Definition: wifi-mac.cc:881
Mac48Address GetAddress() const
Definition: wifi-mac.cc:442
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
Definition: wifi-mac.cc:489
Ptr< ChannelAccessManager > GetChannelAccessManager(uint8_t linkId=SINGLE_LINK_OP_ID) const
Get the Channel Access Manager associated with the given link.
Definition: wifi-mac.cc:841
void Clear()
Reset the TX parameters.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:86
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:205
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1426
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
@ AC_BE
Best Effort.
Definition: qos-utils.h:76
@ AC_VO
Voice.
Definition: qos-utils.h:82
@ AC_VI
Video.
Definition: qos-utils.h:80
@ AC_BK
Background.
Definition: qos-utils.h:78
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects of the IEEE 802.11 MAC FCS field.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:535
static constexpr uint8_t SINGLE_LINK_OP_ID
Link ID for single link operations (helps tracking places where correct link ID is to be used to supp...
Definition: wifi-utils.h:140
@ WIFI_MAC_CTL_TRIGGER
@ WIFI_MAC_QOSDATA_NULL
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:163
mac
Definition: third.py:85
Information to be provided in case of DL MU transmission.
WifiTxParameters txParams
the transmission parameters
WifiPsduMap psduMap
the DL MU PPDU to transmit
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