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
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::MultiUserScheduler::NotifyAccessGranted
TxFormat NotifyAccessGranted(Ptr< QosTxop > edca, Time availableTime, bool initialFrame)
Notify the Multi-user Scheduler that the given AC of the AP gained channel access.
Definition: multi-user-scheduler.cc:127
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::Object::NotifyNewAggregate
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
Definition: object.cc:325
ns3::MultiUserScheduler::DL_MU_TX
@ DL_MU_TX
Definition: multi-user-scheduler.h:66
ns3::MultiUserScheduler::ComputeUlMuInfo
virtual UlMuInfo ComputeUlMuInfo(void)=0
Prepare the information required to solicit an UL MU transmission.
ns3::WIFI_MAC_QOSDATA_NULL
@ WIFI_MAC_QOSDATA_NULL
Definition: wifi-mac-header.h:74
ns3::MultiUserScheduler::UlMuInfo
Information to be provided in case of UL MU transmission.
Definition: multi-user-scheduler.h:79
ns3::MultiUserScheduler::m_edca
Ptr< QosTxop > m_edca
the AC that gained channel access
Definition: multi-user-scheduler.h:137
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
ns3::MultiUserScheduler::GetDlMuInfo
DlMuInfo & GetDlMuInfo(void)
Get the information required to perform a DL MU transmission.
Definition: multi-user-scheduler.cc:161
ns3::MultiUserScheduler::m_dlInfo
DlMuInfo m_dlInfo
information required to perform a DL MU transmission
Definition: multi-user-scheduler.h:172
ns3::MultiUserScheduler::MultiUserScheduler
MultiUserScheduler()
Definition: multi-user-scheduler.cc:47
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WifiMacHeader::GetSerializedSize
uint32_t GetSerializedSize(void) const override
Definition: wifi-mac-header.cc:1155
ns3::MultiUserScheduler::DlMuInfo::txParams
WifiTxParameters txParams
the transmission parameters
Definition: multi-user-scheduler.h:74
ns3::WifiMacHeader::SetDsTo
void SetDsTo(void)
Set the To DS bit in the Frame Control field.
Definition: wifi-mac-header.cc:96
ns3::WIFI_MAC_FCS_LENGTH
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects of the IEEE 802.11 MAC FCS field.
Definition: wifi-mac-trailer.h:31
multi-user-scheduler.h
ns3::MultiUserScheduler::DlMuInfo::psduMap
WifiPsduMap psduMap
the DL MU PPDU to transmit
Definition: multi-user-scheduler.h:73
ns3::MultiUserScheduler::NotifyNewAggregate
void NotifyNewAggregate(void) override
Notify all Objects aggregated to this one of a new Object being aggregated.
Definition: multi-user-scheduler.cc:71
ns3::MultiUserScheduler::DoDispose
void DoDispose(void) override
Destructor implementation.
Definition: multi-user-scheduler.cc:57
ns3::WifiMacHeader::SetDsNotFrom
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
Definition: wifi-mac-header.cc:90
ns3::MultiUserScheduler::m_initialFrame
bool m_initialFrame
true if a TXOP is being started
Definition: multi-user-scheduler.h:139
ns3::MultiUserScheduler::SelectTxFormat
virtual TxFormat SelectTxFormat(void)=0
Select the format of the next transmission.
third.mac
mac
Definition: third.py:99
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::MultiUserScheduler::UlMuInfo::trigger
Ptr< WifiMacQueueItem > trigger
the Trigger frame used to solicit TB PPDUs
Definition: multi-user-scheduler.h:80
ns3::MultiUserScheduler::ComputeDlMuInfo
virtual DlMuInfo ComputeDlMuInfo(void)=0
Compute the information required to perform a DL MU transmission.
ns3::WifiMacHeader
Implements the IEEE 802.11 MAC header.
Definition: wifi-mac-header.h:85
ns3::MultiUserScheduler::~MultiUserScheduler
virtual ~MultiUserScheduler()
Definition: multi-user-scheduler.cc:51
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::MultiUserScheduler::GetUlMuInfo
UlMuInfo & GetUlMuInfo(void)
Get the information required to solicit an UL MU transmission.
Definition: multi-user-scheduler.cc:178
ns3::MultiUserScheduler::m_availableTime
Time m_availableTime
the time available for frame exchange
Definition: multi-user-scheduler.h:138
ns3::MultiUserScheduler::DlMuInfo
Information to be provided in case of DL MU transmission.
Definition: multi-user-scheduler.h:72
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::MultiUserScheduler::m_heFem
Ptr< HeFrameExchangeManager > m_heFem
HE Frame Exchange Manager.
Definition: multi-user-scheduler.h:136
ns3::MultiUserScheduler::UL_MU_TX
@ UL_MU_TX
Definition: multi-user-scheduler.h:67
ns3::WifiTxParameters::Clear
void Clear(void)
Reset the TX parameters.
Definition: wifi-tx-parameters.cc:67
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::MultiUserScheduler::SetWifiMac
void SetWifiMac(Ptr< ApWifiMac > mac)
Set the wifi MAC.
Definition: multi-user-scheduler.cc:106
NS_ABORT_MSG_IF
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
ns3::MultiUserScheduler::m_apMac
Ptr< ApWifiMac > m_apMac
the AP wifi MAC
Definition: multi-user-scheduler.h:135
ns3::MultiUserScheduler::GetWifiRemoteStationManager
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
Get the station manager attached to the AP.
Definition: multi-user-scheduler.cc:121
ns3::MultiUserScheduler::UlMuInfo::txParams
WifiTxParameters txParams
the transmission parameters for the Trigger Frame
Definition: multi-user-scheduler.h:82
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition: log-macros-enabled.h:209
he-frame-exchange-manager.h
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::MultiUserScheduler::NO_TX
@ NO_TX
Definition: multi-user-scheduler.h:64
ns3::MultiUserScheduler::GetLastTxFormat
TxFormat GetLastTxFormat(void) const
Get the format of the last transmission, as determined by the last call to NotifyAccessGranted that d...
Definition: multi-user-scheduler.cc:155
ns3::MultiUserScheduler::m_sizeOf8QosNull
uint32_t m_sizeOf8QosNull
size in bytes of 8 QoS Null frames
Definition: multi-user-scheduler.h:140
ns3::WifiMacHeader::SetType
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
Definition: wifi-mac-header.cc:132
he-configuration.h
ns3::MultiUserScheduler::TxFormat
TxFormat
Enumeration of the possible transmission formats.
Definition: multi-user-scheduler.h:63
ns3::MultiUserScheduler::DoInitialize
void DoInitialize(void) override
Initialize() implementation.
Definition: multi-user-scheduler.cc:88
ns3::Object::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
ns3::MpduAggregator::GetSizeIfAggregated
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...
Definition: mpdu-aggregator.cc:113
ns3::MultiUserScheduler::m_lastTxFormat
TxFormat m_lastTxFormat
the format of last transmission
Definition: multi-user-scheduler.h:171
ns3::MultiUserScheduler::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: multi-user-scheduler.cc:38
ns3::MultiUserScheduler::m_ulInfo
UlMuInfo m_ulInfo
information required to solicit an UL MU transmission
Definition: multi-user-scheduler.h:173