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 ();
66  m_ulInfo.trigger = 0;
68 }
69 
70 void
72 {
73  NS_LOG_FUNCTION (this);
74  if (m_apMac == 0)
75  {
76  Ptr<ApWifiMac> apMac = this->GetObject<ApWifiMac> ();
77  //verify that it's a valid AP mac and that
78  //the AP mac was not set before
79  if (apMac != 0)
80  {
81  this->SetWifiMac (apMac);
82  }
83  }
85 }
86 
87 void
89 {
90  // compute the size in bytes of 8 QoS Null frames. It can be used by subclasses
91  // when responding to a BSRP Trigger Frame
92  WifiMacHeader header;
94  header.SetDsTo ();
95  header.SetDsNotFrom ();
96  uint32_t headerSize = header.GetSerializedSize ();
97 
98  m_sizeOf8QosNull = 0;
99  for (uint8_t i = 0; i < 8; i++)
100  {
102  }
103 }
104 
105 void
107 {
108  NS_LOG_FUNCTION (this << mac);
109  m_apMac = mac;
110 
111  // When VHT DL MU-MIMO will be supported, we will have to lower this requirement
112  // and allow a Multi-user scheduler to be installed on a VHT AP.
113  NS_ABORT_MSG_IF (m_apMac == 0 || m_apMac->GetHeConfiguration () == 0,
114  "MultiUserScheduler can only be installed on HE APs");
115 
116  m_heFem = DynamicCast<HeFrameExchangeManager> (m_apMac->GetFrameExchangeManager ());
117  m_heFem->SetMultiUserScheduler (this);
118 }
119 
122 {
123  return m_apMac->GetWifiRemoteStationManager ();
124 }
125 
127 MultiUserScheduler::NotifyAccessGranted (Ptr<QosTxop> edca, Time availableTime, bool initialFrame)
128 {
129  NS_LOG_FUNCTION (this << edca << availableTime << initialFrame);
130 
131  m_edca = edca;
132  m_availableTime = availableTime;
133  m_initialFrame = initialFrame;
134 
135  TxFormat txFormat = SelectTxFormat ();
136 
137  if (txFormat == DL_MU_TX)
138  {
140  }
141  else if (txFormat == UL_MU_TX)
142  {
143  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 } //namespace ns3
TxFormat m_lastTxFormat
the format of last transmission
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#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
uint32_t GetSerializedSize(void) const override
void DoDispose(void) override
Destructor implementation.
bool m_initialFrame
true if a TXOP is being started
void Clear(void)
Reset the TX parameters.
WifiTxParameters txParams
the transmission parameters
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects of the IEEE 802.11 MAC FCS field.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
DlMuInfo m_dlInfo
information required to perform a DL MU transmission
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...
void NotifyNewAggregate(void) override
Notify all Objects aggregated to this one of a new Object being aggregated.
Time m_availableTime
the time available for frame exchange
void SetWifiMac(Ptr< ApWifiMac > mac)
Set the wifi MAC.
virtual TxFormat SelectTxFormat(void)=0
Select the format of the next transmission.
Ptr< ApWifiMac > m_apMac
the AP wifi MAC
mac
Definition: third.py:99
Ptr< HeFrameExchangeManager > m_heFem
HE Frame Exchange Manager.
UlMuInfo & GetUlMuInfo(void)
Get the information required to solicit an UL MU transmission.
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.
Information to be provided in case of UL MU transmission.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< WifiMacQueueItem > trigger
the Trigger frame used to solicit TB PPDUs
WifiPsduMap psduMap
the DL MU PPDU to transmit
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
TxFormat GetLastTxFormat(void) const
Get the format of the last transmission, as determined by the last call to NotifyAccessGranted that d...
void DoInitialize(void) override
Initialize() implementation.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
uint32_t m_sizeOf8QosNull
size in bytes of 8 QoS Null frames
TxFormat
Enumeration of the possible transmission formats.
static TypeId GetTypeId(void)
Get the type ID.
void SetDsTo(void)
Set the To DS bit in the Frame Control field.
TxFormat NotifyAccessGranted(Ptr< QosTxop > edca, Time availableTime, bool initialFrame)
Notify the Multi-user Scheduler that the given AC of the AP gained channel access.
virtual UlMuInfo ComputeUlMuInfo(void)=0
Prepare the information required to solicit an UL MU transmission.
Ptr< QosTxop > m_edca
the AC that gained channel access
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
Definition: object.cc:325
DlMuInfo & GetDlMuInfo(void)
Get the information required to perform a DL MU transmission.
UlMuInfo m_ulInfo
information required to solicit an UL MU transmission
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
Implements the IEEE 802.11 MAC header.
WifiTxParameters txParams
the transmission parameters for the Trigger Frame
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
Information to be provided in case of DL MU transmission.