A Discrete-Event Network Simulator
API
multi-user-scheduler.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Stefano Avallone <stavallo@unina.it>
19  */
20 
21 #include "ns3/log.h"
22 #include "ns3/abort.h"
23 #include "multi-user-scheduler.h"
24 #include "ns3/qos-txop.h"
25 #include "he-configuration.h"
27 #include "ns3/wifi-protection.h"
28 #include "ns3/wifi-acknowledgment.h"
29 #include "ns3/wifi-mac-trailer.h"
30 
31 namespace ns3 {
32 
33 NS_LOG_COMPONENT_DEFINE ("MultiUserScheduler");
34 
35 NS_OBJECT_ENSURE_REGISTERED (MultiUserScheduler);
36 
37 TypeId
39 {
40  static TypeId tid = TypeId ("ns3::MultiUserScheduler")
41  .SetParent<Object> ()
42  .SetGroupName ("Wifi")
43  ;
44  return tid;
45 }
46 
48 {
49 }
50 
52 {
54 }
55 
56 void
58 {
59  NS_LOG_FUNCTION (this);
60  m_apMac = 0;
61  m_heFem = 0;
62  m_edca = 0;
63  m_dlInfo.psduMap.clear ();
67 }
68 
69 void
71 {
72  NS_LOG_FUNCTION (this);
73  if (m_apMac == 0)
74  {
75  Ptr<ApWifiMac> apMac = this->GetObject<ApWifiMac> ();
76  //verify that it's a valid AP mac and that
77  //the AP mac was not set before
78  if (apMac != 0)
79  {
80  this->SetWifiMac (apMac);
81  }
82  }
84 }
85 
86 void
88 {
89  // compute the size in bytes of 8 QoS Null frames. It can be used by subclasses
90  // when responding to a BSRP Trigger Frame
91  WifiMacHeader header;
93  header.SetDsTo ();
94  header.SetDsNotFrom ();
95  uint32_t headerSize = header.GetSerializedSize ();
96 
97  m_sizeOf8QosNull = 0;
98  for (uint8_t i = 0; i < 8; i++)
99  {
101  }
102 }
103 
104 void
106 {
107  NS_LOG_FUNCTION (this << mac);
108  m_apMac = mac;
109 
110  // When VHT DL MU-MIMO will be supported, we will have to lower this requirement
111  // and allow a Multi-user scheduler to be installed on a VHT AP.
112  NS_ABORT_MSG_IF (m_apMac == 0 || m_apMac->GetHeConfiguration () == 0,
113  "MultiUserScheduler can only be installed on HE APs");
114 
115  m_heFem = DynamicCast<HeFrameExchangeManager> (m_apMac->GetFrameExchangeManager ());
116  m_heFem->SetMultiUserScheduler (this);
117 }
118 
121 {
122  return m_apMac->GetWifiRemoteStationManager ();
123 }
124 
126 MultiUserScheduler::NotifyAccessGranted (Ptr<QosTxop> edca, Time availableTime, bool initialFrame)
127 {
128  NS_LOG_FUNCTION (this << edca << availableTime << initialFrame);
129 
130  m_edca = edca;
131  m_availableTime = availableTime;
132  m_initialFrame = initialFrame;
133 
134  TxFormat txFormat = SelectTxFormat ();
135 
136  if (txFormat == DL_MU_TX)
137  {
139  }
140  else if (txFormat == UL_MU_TX)
141  {
142  NS_ABORT_MSG_IF (m_heFem == 0, "UL MU PPDUs are only supported by HE APs");
145  }
146 
147  if (txFormat != NO_TX)
148  {
149  m_lastTxFormat = txFormat;
150  }
151  return txFormat;
152 }
153 
156 {
157  return m_lastTxFormat;
158 }
159 
162 {
163  NS_ABORT_MSG_IF (m_lastTxFormat != DL_MU_TX, "Next transmission is not DL MU");
164 
165 #ifdef NS3_BUILD_PROFILE_DEBUG
166  // check that all the addressed stations support HE
167  for (auto& psdu : m_dlInfo.psduMap)
168  {
169  NS_ABORT_MSG_IF (!GetWifiRemoteStationManager ()->GetHeSupported (psdu.second->GetAddr1 ()),
170  "Station " << psdu.second->GetAddr1 () << " does not support HE");
171  }
172 #endif
173 
174  return m_dlInfo;
175 }
176 
179 {
180  NS_ABORT_MSG_IF (m_lastTxFormat != UL_MU_TX, "Next transmission is not UL MU");
181 
182  return m_ulInfo;
183 }
184 
185 void
187 {
188  NS_LOG_FUNCTION (this);
189 
190  // Set the CS Required subfield to true, unless the UL Length subfield is less
191  // than or equal to 76 (see Section 26.5.2.5 of 802.11ax-2021)
193 
194  m_heFem->SetTargetRssi (m_ulInfo.trigger);
195 }
196 
197 } //namespace ns3
void SetCsRequired(bool cs)
Set the CS Required subfield of the Common Info field.
uint16_t GetUlLength(void) const
Get the UL Length subfield of the Common Info field.
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...
virtual TxFormat SelectTxFormat(void)=0
Select the format of the next transmission.
bool m_initialFrame
true if a TXOP is being started
void DoInitialize(void) override
Initialize() implementation.
UlMuInfo m_ulInfo
information required to solicit an UL MU transmission
TxFormat m_lastTxFormat
the format of last transmission
Ptr< ApWifiMac > m_apMac
the AP wifi MAC
Time m_availableTime
the time available for frame exchange
void DoDispose(void) override
Destructor implementation.
TxFormat GetLastTxFormat(void) const
Get the format of the last transmission, as determined by the last call to NotifyAccessGranted that d...
virtual UlMuInfo ComputeUlMuInfo(void)=0
Prepare the information required to solicit an UL MU transmission.
DlMuInfo m_dlInfo
information required to perform a DL MU transmission
void NotifyNewAggregate(void) override
Notify all Objects aggregated to this one of a new Object being aggregated.
Ptr< HeFrameExchangeManager > m_heFem
HE Frame Exchange Manager.
virtual DlMuInfo ComputeDlMuInfo(void)=0
Compute the information required to perform a DL MU transmission.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
Get the station manager attached to the AP.
Ptr< QosTxop > m_edca
the AC that gained channel access
uint32_t m_sizeOf8QosNull
size in bytes of 8 QoS Null frames
UlMuInfo & GetUlMuInfo(void)
Get the information required to solicit an UL MU transmission.
DlMuInfo & GetDlMuInfo(void)
Get the information required to perform a DL MU transmission.
void CheckTriggerFrame(void)
Ensure that the Trigger Frame returned in case of UL MU transmission is correct.
static TypeId GetTypeId(void)
Get the type ID.
void SetWifiMac(Ptr< ApWifiMac > mac)
Set the wifi MAC.
TxFormat
Enumeration of the possible transmission formats.
TxFormat NotifyAccessGranted(Ptr< QosTxop > edca, Time availableTime, bool initialFrame)
Notify the Multi-user Scheduler that the given AC of the AP gained channel access.
A base class which provides memory management and object aggregation.
Definition: object.h:88
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
Definition: object.cc:325
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Implements the IEEE 802.11 MAC header.
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
void SetDsTo(void)
Set the To DS bit in the Frame Control field.
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
uint32_t GetSerializedSize(void) const override
void Clear(void)
Reset the TX parameters.
#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:205
#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
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.
@ WIFI_MAC_QOSDATA_NULL
mac
Definition: third.py:99
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