A Discrete-Event Network Simulator
API
ap-wifi-mac.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006, 2009 INRIA
4  * Copyright (c) 2009 MIRKO BANCHI
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Mirko Banchi <mk.banchi@gmail.com>
21  */
22 
23 #include "ns3/log.h"
24 #include "ns3/packet.h"
25 #include "ns3/simulator.h"
26 #include "ns3/pointer.h"
27 #include "ns3/string.h"
28 #include "ns3/random-variable-stream.h"
29 #include "ap-wifi-mac.h"
30 #include "channel-access-manager.h"
31 #include "mac-tx-middle.h"
32 #include "mac-rx-middle.h"
33 #include "mgt-headers.h"
34 #include "msdu-aggregator.h"
35 #include "amsdu-subframe-header.h"
36 #include "wifi-phy.h"
37 #include "wifi-net-device.h"
38 #include "wifi-mac-queue.h"
39 #include "ns3/ht-configuration.h"
40 #include "ns3/he-configuration.h"
41 #include "qos-txop.h"
42 
43 namespace ns3 {
44 
45 NS_LOG_COMPONENT_DEFINE ("ApWifiMac");
46 
47 NS_OBJECT_ENSURE_REGISTERED (ApWifiMac);
48 
49 TypeId
51 {
52  static TypeId tid = TypeId ("ns3::ApWifiMac")
53  .SetParent<WifiMac> ()
54  .SetGroupName ("Wifi")
55  .AddConstructor<ApWifiMac> ()
56  .AddAttribute ("BeaconInterval",
57  "Delay between two beacons",
58  TimeValue (MicroSeconds (102400)),
61  MakeTimeChecker ())
62  .AddAttribute ("BeaconJitter",
63  "A uniform random variable to cause the initial beacon starting time (after simulation time 0) "
64  "to be distributed between 0 and the BeaconInterval.",
65  StringValue ("ns3::UniformRandomVariable"),
67  MakePointerChecker<UniformRandomVariable> ())
68  .AddAttribute ("EnableBeaconJitter",
69  "If beacons are enabled, whether to jitter the initial send event.",
70  BooleanValue (true),
73  .AddAttribute ("BeaconGeneration",
74  "Whether or not beacons are generated.",
75  BooleanValue (true),
78  .AddAttribute ("EnableNonErpProtection", "Whether or not protection mechanism should be used when non-ERP STAs are present within the BSS."
79  "This parameter is only used when ERP is supported by the AP.",
80  BooleanValue (true),
83  .AddAttribute ("BsrLifetime",
84  "Lifetime of Buffer Status Reports received from stations.",
85  TimeValue (MilliSeconds (20)),
87  MakeTimeChecker ())
88  .AddTraceSource ("AssociatedSta",
89  "A station associated with this access point.",
91  "ns3::ApWifiMac::AssociationCallback")
92  .AddTraceSource ("DeAssociatedSta",
93  "A station lost association with this access point.",
95  "ns3::ApWifiMac::AssociationCallback")
96  ;
97  return tid;
98 }
99 
101  : m_enableBeaconGeneration (false),
102  m_numNonErpStations (0),
103  m_numNonHtStations (0),
104  m_shortSlotTimeEnabled (false),
105  m_shortPreambleEnabled (false)
106 {
107  NS_LOG_FUNCTION (this);
108  m_beaconTxop = CreateObject<Txop> (CreateObject<WifiMacQueue> (AC_BEACON));
109  m_beaconTxop->SetWifiMac (this);
110  m_beaconTxop->SetAifsn (1);
111  m_beaconTxop->SetMinCw (0);
112  m_beaconTxop->SetMaxCw (0);
115 
116  //Let the lower layers know that we are acting as an AP.
118 }
119 
121 {
122  NS_LOG_FUNCTION (this);
123  m_staList.clear ();
124 }
125 
126 void
128 {
129  NS_LOG_FUNCTION (this);
130  m_beaconTxop->Dispose ();
131  m_beaconTxop = 0;
132  m_enableBeaconGeneration = false;
135 }
136 
137 void
139 {
140  NS_LOG_FUNCTION (this << address);
141  //As an AP, our MAC address is also the BSSID. Hence we are
142  //overriding this function and setting both in our parent class.
145 }
146 
149 {
150  if (ac == AC_BEACON)
151  {
152  return m_beaconTxop->GetWifiMacQueue ();
153  }
154  return WifiMac::GetTxopQueue (ac);
155 }
156 
157 void
159 {
160  NS_LOG_FUNCTION (this << enable);
161  if (!enable)
162  {
164  }
165  else if (enable && !m_enableBeaconGeneration)
166  {
168  }
169  m_enableBeaconGeneration = enable;
170 }
171 
172 Time
174 {
175  NS_LOG_FUNCTION (this);
176  return m_beaconInterval;
177 }
178 
179 void
181 {
182  NS_LOG_FUNCTION (this << &linkUp);
184 
185  //The approach taken here is that, from the point of view of an AP,
186  //the link is always up, so we immediately invoke the callback if
187  //one is set
188  linkUp ();
189 }
190 
191 void
193 {
194  NS_LOG_FUNCTION (this << interval);
195  if ((interval.GetMicroSeconds () % 1024) != 0)
196  {
197  NS_FATAL_ERROR ("beacon interval should be multiple of 1024us (802.11 time unit), see IEEE Std. 802.11-2012");
198  }
199  if (interval.GetMicroSeconds () > (1024 * 65535))
200  {
201  NS_FATAL_ERROR ("beacon interval should be smaller then or equal to 65535 * 1024us (802.11 time unit)");
202  }
203  m_beaconInterval = interval;
204 }
205 
206 int64_t
207 ApWifiMac::AssignStreams (int64_t stream)
208 {
209  NS_LOG_FUNCTION (this << stream);
210  m_beaconJitter->SetStream (stream);
211  return 1;
212 }
213 
214 void
216 {
217  NS_LOG_FUNCTION (this);
219  {
220  for (const auto& sta : m_staList)
221  {
223  {
224  m_shortSlotTimeEnabled = false;
225  return;
226  }
227  }
228  m_shortSlotTimeEnabled = true;
229  }
230  else
231  {
232  m_shortSlotTimeEnabled = false;
233  }
234 }
235 
236 void
238 {
239  NS_LOG_FUNCTION (this);
240  if (GetErpSupported () && GetWifiPhy ()->GetShortPhyPreambleSupported ())
241  {
242  for (const auto& sta : m_staList)
243  {
244  if (!GetWifiRemoteStationManager ()->GetErpOfdmSupported (sta.second) ||
245  !GetWifiRemoteStationManager ()->GetShortPreambleSupported (sta.second))
246  {
247  m_shortPreambleEnabled = false;
248  return;
249  }
250  }
251  m_shortPreambleEnabled = true;
252  }
253  else
254  {
255  m_shortPreambleEnabled = false;
256  }
257 }
258 
259 void
261  Mac48Address to)
262 {
263  NS_LOG_FUNCTION (this << packet << from << to);
264  //If we are not a QoS AP then we definitely want to use AC_BE to
265  //transmit the packet. A TID of zero will map to AC_BE (through \c
266  //QosUtilsMapTidToAc()), so we use that as our default here.
267  uint8_t tid = 0;
268 
269  //If we are a QoS AP then we attempt to get a TID for this packet
270  if (GetQosSupported ())
271  {
272  tid = QosUtilsGetTidForPacket (packet);
273  //Any value greater than 7 is invalid and likely indicates that
274  //the packet had no QoS tag, so we revert to zero, which'll
275  //mean that AC_BE is used.
276  if (tid > 7)
277  {
278  tid = 0;
279  }
280  }
281 
282  ForwardDown (packet, from, to, tid);
283 }
284 
285 void
287  Mac48Address to, uint8_t tid)
288 {
289  NS_LOG_FUNCTION (this << packet << from << to << +tid);
290  WifiMacHeader hdr;
291 
292  //For now, an AP that supports QoS does not support non-QoS
293  //associations, and vice versa. In future the AP model should
294  //support simultaneously associated QoS and non-QoS STAs, at which
295  //point there will need to be per-association QoS state maintained
296  //by the association state machine, and consulted here.
297  if (GetQosSupported ())
298  {
301  hdr.SetQosNoEosp ();
302  hdr.SetQosNoAmsdu ();
303  //Transmission of multiple frames in the same Polled TXOP is not supported for now
304  hdr.SetQosTxopLimit (0);
305  //Fill in the QoS control field in the MAC header
306  hdr.SetQosTid (tid);
307  }
308  else
309  {
310  hdr.SetType (WIFI_MAC_DATA);
311  }
312 
313  if (GetQosSupported ())
314  {
315  hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT control field is not yet implemented (set it to 1 when implemented)
316  }
317  hdr.SetAddr1 (to);
318  hdr.SetAddr2 (GetAddress ());
319  hdr.SetAddr3 (from);
320  hdr.SetDsFrom ();
321  hdr.SetDsNotTo ();
322 
323  if (GetQosSupported ())
324  {
325  //Sanity check that the TID is valid
326  NS_ASSERT (tid < 8);
327  GetQosTxop (tid)->Queue (packet, hdr);
328  }
329  else
330  {
331  GetTxop ()->Queue (packet, hdr);
332  }
333 }
334 
335 bool
337 {
338  return (to.IsGroup () || GetWifiRemoteStationManager ()->IsAssociated (to));
339 }
340 
341 void
343 {
344  NS_LOG_FUNCTION (this << packet << to << from);
345  if (CanForwardPacketsTo (to))
346  {
347  ForwardDown (packet, from, to);
348  }
349  else
350  {
351  NotifyTxDrop (packet);
352  }
353 }
354 
355 void
357 {
358  NS_LOG_FUNCTION (this << packet << to);
359  //We're sending this packet with a from address that is our own. We
360  //get that address from the lower MAC and make use of the
361  //from-spoofing Enqueue() method to avoid duplicated code.
362  Enqueue (packet, to, GetAddress ());
363 }
364 
365 bool
367 {
368  NS_LOG_FUNCTION (this);
369  return true;
370 }
371 
374 {
375  NS_LOG_FUNCTION (this);
376  SupportedRates rates;
377  //Send the set of supported rates and make sure that we indicate
378  //the Basic Rate set in this set of supported rates.
379  for (const auto & mode : GetWifiPhy ()->GetModeList ())
380  {
381  uint64_t modeDataRate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ());
382  NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
383  rates.AddSupportedRate (modeDataRate);
384  //Add rates that are part of the BSSBasicRateSet (manufacturer dependent!)
385  //here we choose to add the mandatory rates to the BSSBasicRateSet,
386  //except for 802.11b where we assume that only the non HR-DSSS rates are part of the BSSBasicRateSet
387  if (mode.IsMandatory () && (mode.GetModulationClass () != WIFI_MOD_CLASS_HR_DSSS))
388  {
389  NS_LOG_DEBUG ("Adding basic mode " << mode.GetUniqueName ());
391  }
392  }
393  //set the basic rates
394  for (uint8_t j = 0; j < GetWifiRemoteStationManager ()->GetNBasicModes (); j++)
395  {
397  uint64_t modeDataRate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ());
398  NS_LOG_DEBUG ("Setting basic rate " << mode.GetUniqueName ());
399  rates.SetBasicRate (modeDataRate);
400  }
401  //If it is a HT AP, then add the BSSMembershipSelectorSet
402  //The standard says that the BSSMembershipSelectorSet
403  //must have its MSB set to 1 (must be treated as a Basic Rate)
404  //Also the standard mentioned that at least 1 element should be included in the SupportedRates the rest can be in the ExtendedSupportedRates
405  if (GetHtSupported ())
406  {
407  for (const auto & selector : GetWifiPhy ()->GetBssMembershipSelectorList ())
408  {
409  rates.AddBssMembershipSelectorRate (selector);
410  }
411  }
412  return rates;
413 }
414 
417 {
418  NS_LOG_FUNCTION (this);
419  DsssParameterSet dsssParameters;
420  if (GetDsssSupported ())
421  {
422  dsssParameters.SetDsssSupported (1);
423  dsssParameters.SetCurrentChannel (GetWifiPhy ()->GetChannelNumber ());
424  }
425  return dsssParameters;
426 }
427 
430 {
431  NS_LOG_FUNCTION (this);
432  CapabilityInformation capabilities;
435  capabilities.SetEss ();
436  return capabilities;
437 }
438 
441 {
442  NS_LOG_FUNCTION (this);
443  ErpInformation information;
444  information.SetErpSupported (1);
445  if (GetErpSupported ())
446  {
447  information.SetNonErpPresent (m_numNonErpStations > 0);
448  information.SetUseProtection (GetUseNonErpProtection ());
450  {
451  information.SetBarkerPreambleMode (0);
452  }
453  else
454  {
455  information.SetBarkerPreambleMode (1);
456  }
457  }
458  return information;
459 }
460 
463 {
464  NS_LOG_FUNCTION (this);
465  EdcaParameterSet edcaParameters;
466  if (GetQosSupported ())
467  {
468  edcaParameters.SetQosSupported (1);
469  Ptr<QosTxop> edca;
470  Time txopLimit;
471 
472  edca = GetQosTxop (AC_BE);
473  txopLimit = edca->GetTxopLimit ();
474  edcaParameters.SetBeAci (0);
475  edcaParameters.SetBeCWmin (edca->GetMinCw ());
476  edcaParameters.SetBeCWmax (edca->GetMaxCw ());
477  edcaParameters.SetBeAifsn (edca->GetAifsn ());
478  edcaParameters.SetBeTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
479 
480  edca = GetQosTxop (AC_BK);
481  txopLimit = edca->GetTxopLimit ();
482  edcaParameters.SetBkAci (1);
483  edcaParameters.SetBkCWmin (edca->GetMinCw ());
484  edcaParameters.SetBkCWmax (edca->GetMaxCw ());
485  edcaParameters.SetBkAifsn (edca->GetAifsn ());
486  edcaParameters.SetBkTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
487 
488  edca = GetQosTxop (AC_VI);
489  txopLimit = edca->GetTxopLimit ();
490  edcaParameters.SetViAci (2);
491  edcaParameters.SetViCWmin (edca->GetMinCw ());
492  edcaParameters.SetViCWmax (edca->GetMaxCw ());
493  edcaParameters.SetViAifsn (edca->GetAifsn ());
494  edcaParameters.SetViTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
495 
496  edca = GetQosTxop (AC_VO);
497  txopLimit = edca->GetTxopLimit ();
498  edcaParameters.SetVoAci (3);
499  edcaParameters.SetVoCWmin (edca->GetMinCw ());
500  edcaParameters.SetVoCWmax (edca->GetMaxCw ());
501  edcaParameters.SetVoAifsn (edca->GetAifsn ());
502  edcaParameters.SetVoTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
503 
504  edcaParameters.SetQosInfo (0);
505  }
506  return edcaParameters;
507 }
508 
511 {
512  NS_LOG_FUNCTION (this);
513  MuEdcaParameterSet muEdcaParameters;
514  if (GetHeSupported ())
515  {
516  Ptr<HeConfiguration> heConfiguration = GetHeConfiguration ();
517  NS_ASSERT (heConfiguration != 0);
518 
519  muEdcaParameters.SetQosInfo (0);
520 
521  UintegerValue uintegerValue;
522  TimeValue timeValue;
523 
524  heConfiguration->GetAttribute ("MuBeAifsn", uintegerValue);
525  muEdcaParameters.SetMuAifsn (AC_BE, uintegerValue.Get ());
526  heConfiguration->GetAttribute ("MuBeCwMin", uintegerValue);
527  muEdcaParameters.SetMuCwMin (AC_BE, uintegerValue.Get ());
528  heConfiguration->GetAttribute ("MuBeCwMax", uintegerValue);
529  muEdcaParameters.SetMuCwMax (AC_BE, uintegerValue.Get ());
530  heConfiguration->GetAttribute ("BeMuEdcaTimer", timeValue);
531  muEdcaParameters.SetMuEdcaTimer (AC_BE, timeValue.Get ());
532 
533  heConfiguration->GetAttribute ("MuBkAifsn", uintegerValue);
534  muEdcaParameters.SetMuAifsn (AC_BK, uintegerValue.Get ());
535  heConfiguration->GetAttribute ("MuBkCwMin", uintegerValue);
536  muEdcaParameters.SetMuCwMin (AC_BK, uintegerValue.Get ());
537  heConfiguration->GetAttribute ("MuBkCwMax", uintegerValue);
538  muEdcaParameters.SetMuCwMax (AC_BK, uintegerValue.Get ());
539  heConfiguration->GetAttribute ("BkMuEdcaTimer", timeValue);
540  muEdcaParameters.SetMuEdcaTimer (AC_BK, timeValue.Get ());
541 
542  heConfiguration->GetAttribute ("MuViAifsn", uintegerValue);
543  muEdcaParameters.SetMuAifsn (AC_VI, uintegerValue.Get ());
544  heConfiguration->GetAttribute ("MuViCwMin", uintegerValue);
545  muEdcaParameters.SetMuCwMin (AC_VI, uintegerValue.Get ());
546  heConfiguration->GetAttribute ("MuViCwMax", uintegerValue);
547  muEdcaParameters.SetMuCwMax (AC_VI, uintegerValue.Get ());
548  heConfiguration->GetAttribute ("ViMuEdcaTimer", timeValue);
549  muEdcaParameters.SetMuEdcaTimer (AC_VI, timeValue.Get ());
550 
551  heConfiguration->GetAttribute ("MuVoAifsn", uintegerValue);
552  muEdcaParameters.SetMuAifsn (AC_VO, uintegerValue.Get ());
553  heConfiguration->GetAttribute ("MuVoCwMin", uintegerValue);
554  muEdcaParameters.SetMuCwMin (AC_VO, uintegerValue.Get ());
555  heConfiguration->GetAttribute ("MuVoCwMax", uintegerValue);
556  muEdcaParameters.SetMuCwMax (AC_VO, uintegerValue.Get ());
557  heConfiguration->GetAttribute ("VoMuEdcaTimer", timeValue);
558  muEdcaParameters.SetMuEdcaTimer (AC_VO, timeValue.Get ());
559  }
560  return muEdcaParameters;
561 }
562 
565 {
566  NS_LOG_FUNCTION (this);
567  HtOperation operation;
568  if (GetHtSupported ())
569  {
570  operation.SetHtSupported (1);
571  operation.SetPrimaryChannel (GetWifiPhy ()->GetPrimaryChannelNumber (20));
572  operation.SetRifsMode (false);
573  operation.SetNonGfHtStasPresent (true);
574  if (GetWifiPhy ()->GetChannelWidth () > 20)
575  {
576  operation.SetSecondaryChannelOffset (1);
577  operation.SetStaChannelWidth (1);
578  }
579  if (m_numNonHtStations == 0)
580  {
581  operation.SetHtProtection (NO_PROTECTION);
582  }
583  else
584  {
586  }
587  uint64_t maxSupportedRate = 0; //in bit/s
588  for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT))
589  {
590  uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
591  NS_ASSERT (nss > 0 && nss < 5);
592  uint64_t dataRate = mcs.GetDataRate (GetWifiPhy ()->GetChannelWidth (), GetHtConfiguration ()->GetShortGuardIntervalSupported () ? 400 : 800, nss);
593  if (dataRate > maxSupportedRate)
594  {
595  maxSupportedRate = dataRate;
596  NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate);
597  }
598  }
599  uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedTxSpatialStreams ();
600  auto mcsList = GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT);
601  uint8_t nMcs = mcsList.size ();
602  for (const auto& sta : m_staList)
603  {
604  if (GetWifiRemoteStationManager ()->GetHtSupported (sta.second))
605  {
606  uint64_t maxSupportedRateByHtSta = 0; //in bit/s
607  auto itMcs = mcsList.begin ();
608  for (uint8_t j = 0; j < (std::min (nMcs, GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second))); j++)
609  {
610  WifiMode mcs = *itMcs++;
611  uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
612  NS_ASSERT (nss > 0 && nss < 5);
613  uint64_t dataRate = mcs.GetDataRate (GetWifiRemoteStationManager ()->GetChannelWidthSupported (sta.second),
614  GetWifiRemoteStationManager ()->GetShortGuardIntervalSupported (sta.second) ? 400 : 800, nss);
615  if (dataRate > maxSupportedRateByHtSta)
616  {
617  maxSupportedRateByHtSta = dataRate;
618  }
619  }
620  if (maxSupportedRateByHtSta < maxSupportedRate)
621  {
622  maxSupportedRate = maxSupportedRateByHtSta;
623  }
624  if (GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second) < nMcs)
625  {
626  nMcs = GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second);
627  }
628  if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream)
629  {
630  maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second);
631  }
632  }
633  }
634  operation.SetRxHighestSupportedDataRate (static_cast<uint16_t> (maxSupportedRate / 1e6)); //in Mbit/s
635  operation.SetTxMcsSetDefined (nMcs > 0);
636  operation.SetTxMaxNSpatialStreams (maxSpatialStream);
637  //To be filled in once supported
638  operation.SetObssNonHtStasPresent (0);
639  operation.SetDualBeacon (0);
640  operation.SetDualCtsProtection (0);
641  operation.SetStbcBeacon (0);
642  operation.SetLSigTxopProtectionFullSupport (0);
643  operation.SetPcoActive (0);
644  operation.SetPhase (0);
645  operation.SetRxMcsBitmask (0);
646  operation.SetTxRxMcsSetUnequal (0);
647  operation.SetTxUnequalModulation (0);
648  }
649  return operation;
650 }
651 
654 {
655  NS_LOG_FUNCTION (this);
656  VhtOperation operation;
657  if (GetVhtSupported ())
658  {
659  operation.SetVhtSupported (1);
660  const uint16_t bssBandwidth = GetWifiPhy ()->GetChannelWidth ();
661  // Set to 0 for 20 MHz or 40 MHz BSS bandwidth.
662  // Set to 1 for 80 MHz, 160 MHz or 80+80 MHz BSS bandwidth.
663  operation.SetChannelWidth ((bssBandwidth > 40) ? 1 : 0);
664  // For 20, 40, or 80 MHz BSS bandwidth, indicates the channel center frequency
665  // index for the 20, 40, or 80 MHz channel on which the VHT BSS operates.
666  // For 160 MHz BSS bandwidth and the Channel Width subfield equal to 1,
667  // indicates the channel center frequency index of the 80 MHz channel
668  // segment that contains the primary channel.
669  operation.SetChannelCenterFrequencySegment0 ((bssBandwidth == 160) ?
670  GetWifiPhy ()->GetOperatingChannel ().GetPrimaryChannelNumber (80, WIFI_STANDARD_80211ac) :
671  GetWifiPhy ()->GetChannelNumber ());
672  // For a 20, 40, or 80 MHz BSS bandwidth, this subfield is set to 0.
673  // For a 160 MHz BSS bandwidth and the Channel Width subfield equal to 1,
674  // indicates the channel center frequency index of the 160 MHz channel on
675  // which the VHT BSS operates.
676  operation.SetChannelCenterFrequencySegment1 ((bssBandwidth == 160) ? GetWifiPhy ()->GetChannelNumber () : 0);
677  uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams ();
678  for (const auto& sta : m_staList)
679  {
680  if (GetWifiRemoteStationManager ()->GetVhtSupported (sta.second))
681  {
682  if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream)
683  {
684  maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second);
685  }
686  }
687  }
688  for (uint8_t nss = 1; nss <= maxSpatialStream; nss++)
689  {
690  uint8_t maxMcs = 9; //TBD: hardcode to 9 for now since we assume all MCS values are supported
691  operation.SetMaxVhtMcsPerNss (nss, maxMcs);
692  }
693  }
694  return operation;
695 }
696 
699 {
700  NS_LOG_FUNCTION (this);
701  HeOperation operation;
702  if (GetHeSupported ())
703  {
704  operation.SetHeSupported (1);
705  uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams ();
706  for (const auto& sta : m_staList)
707  {
708  if (GetWifiRemoteStationManager ()->GetHeSupported (sta.second))
709  {
710  if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream)
711  {
712  maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second);
713  }
714  }
715  }
716  for (uint8_t nss = 1; nss <= maxSpatialStream; nss++)
717  {
718  operation.SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported
719  }
720  operation.SetBssColor (GetHeConfiguration ()->GetBssColor ());
721  }
722  return operation;
723 }
724 
725 void
727 {
728  NS_LOG_FUNCTION (this << to);
729  WifiMacHeader hdr;
731  hdr.SetAddr1 (to);
732  hdr.SetAddr2 (GetAddress ());
733  hdr.SetAddr3 (GetAddress ());
734  hdr.SetDsNotFrom ();
735  hdr.SetDsNotTo ();
736  Ptr<Packet> packet = Create<Packet> ();
738  probe.SetSsid (GetSsid ());
740  probe.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
741  probe.SetCapabilities (GetCapabilities ());
744  if (GetDsssSupported ())
745  {
747  }
748  if (GetErpSupported ())
749  {
751  }
752  if (GetQosSupported ())
753  {
755  }
756  if (GetHtSupported ())
757  {
760  probe.SetHtOperation (GetHtOperation ());
761  }
762  if (GetVhtSupported ())
763  {
765  probe.SetVhtOperation (GetVhtOperation ());
766  }
767  if (GetHeSupported ())
768  {
770  probe.SetHeOperation (GetHeOperation ());
772  }
773  packet->AddHeader (probe);
774 
775  if (!GetQosSupported ())
776  {
777  GetTxop ()->Queue (packet, hdr);
778  }
779  // "A QoS STA that transmits a Management frame determines access category used
780  // for medium access in transmission of the Management frame as follows
781  // (If dot11QMFActivated is false or not present)
782  // — If the Management frame is individually addressed to a non-QoS STA, category
783  // AC_BE should be selected.
784  // — If category AC_BE was not selected by the previous step, category AC_VO
785  // shall be selected." (Sec. 10.2.3.2 of 802.11-2020)
786  else if (!GetWifiRemoteStationManager ()->GetQosSupported (to))
787  {
788  GetBEQueue ()->Queue (packet, hdr);
789  }
790  else
791  {
792  GetVOQueue ()->Queue (packet, hdr);
793  }
794 }
795 
796 void
797 ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc)
798 {
799  NS_LOG_FUNCTION (this << to << success << isReassoc);
800  WifiMacHeader hdr;
802  hdr.SetAddr1 (to);
803  hdr.SetAddr2 (GetAddress ());
804  hdr.SetAddr3 (GetAddress ());
805  hdr.SetDsNotFrom ();
806  hdr.SetDsNotTo ();
807  Ptr<Packet> packet = Create<Packet> ();
809  StatusCode code;
810  if (success)
811  {
812  code.SetSuccess ();
813  uint16_t aid = 0;
814  bool found = false;
815  if (isReassoc)
816  {
817  for (const auto& sta : m_staList)
818  {
819  if (sta.second == to)
820  {
821  aid = sta.first;
822  found = true;
823  break;
824  }
825  }
826  }
827  if (!found)
828  {
829  aid = GetNextAssociationId ();
830  m_staList.insert (std::make_pair (aid, to));
831  m_assocLogger (aid, to);
833  if (GetWifiRemoteStationManager ()->GetDsssSupported (to) && !GetWifiRemoteStationManager ()->GetErpOfdmSupported (to))
834  {
836  }
838  {
840  }
843  }
844  assoc.SetAssociationId (aid);
845  }
846  else
847  {
848  code.SetFailure ();
849  }
851  assoc.SetStatusCode (code);
852  assoc.SetCapabilities (GetCapabilities ());
853  if (GetErpSupported ())
854  {
856  }
857  if (GetQosSupported ())
858  {
860  }
861  if (GetHtSupported ())
862  {
865  assoc.SetHtOperation (GetHtOperation ());
866  }
867  if (GetVhtSupported ())
868  {
870  assoc.SetVhtOperation (GetVhtOperation ());
871  }
872  if (GetHeSupported ())
873  {
875  assoc.SetHeOperation (GetHeOperation ());
877  }
878  packet->AddHeader (assoc);
879 
880  if (!GetQosSupported ())
881  {
882  GetTxop ()->Queue (packet, hdr);
883  }
884  // "A QoS STA that transmits a Management frame determines access category used
885  // for medium access in transmission of the Management frame as follows
886  // (If dot11QMFActivated is false or not present)
887  // — If the Management frame is individually addressed to a non-QoS STA, category
888  // AC_BE should be selected.
889  // — If category AC_BE was not selected by the previous step, category AC_VO
890  // shall be selected." (Sec. 10.2.3.2 of 802.11-2020)
891  else if (!GetWifiRemoteStationManager ()->GetQosSupported (to))
892  {
893  GetBEQueue ()->Queue (packet, hdr);
894  }
895  else
896  {
897  GetVOQueue ()->Queue (packet, hdr);
898  }
899 }
900 
901 void
903 {
904  NS_LOG_FUNCTION (this);
905  WifiMacHeader hdr;
908  hdr.SetAddr2 (GetAddress ());
909  hdr.SetAddr3 (GetAddress ());
910  hdr.SetDsNotFrom ();
911  hdr.SetDsNotTo ();
912  Ptr<Packet> packet = Create<Packet> ();
913  MgtBeaconHeader beacon;
914  beacon.SetSsid (GetSsid ());
916  beacon.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
917  beacon.SetCapabilities (GetCapabilities ());
920  if (GetDsssSupported ())
921  {
923  }
924  if (GetErpSupported ())
925  {
927  }
928  if (GetQosSupported ())
929  {
931  }
932  if (GetHtSupported ())
933  {
936  beacon.SetHtOperation (GetHtOperation ());
937  }
938  if (GetVhtSupported ())
939  {
941  beacon.SetVhtOperation (GetVhtOperation ());
942  }
943  if (GetHeSupported ())
944  {
946  beacon.SetHeOperation (GetHeOperation ());
948  }
949  packet->AddHeader (beacon);
950 
951  //The beacon has it's own special queue, so we load it in there
952  m_beaconTxop->Queue (packet, hdr);
954 
955  //If a STA that does not support Short Slot Time associates,
956  //the AP shall use long slot time beginning at the first Beacon
957  //subsequent to the association of the long slot time STA.
958  if (GetErpSupported ())
959  {
961  {
962  //Enable short slot time
963  GetWifiPhy ()->SetSlot (MicroSeconds (9));
964  }
965  else
966  {
967  //Disable short slot time
968  GetWifiPhy ()->SetSlot (MicroSeconds (20));
969  }
970  }
971 }
972 
973 void
975 {
976  NS_LOG_FUNCTION (this << *mpdu);
977  const WifiMacHeader& hdr = mpdu->GetHeader ();
978  if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
979  && GetWifiRemoteStationManager ()->IsWaitAssocTxOk (hdr.GetAddr1 ()))
980  {
981  NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
983  }
984 }
985 
986 void
988 {
989  NS_LOG_FUNCTION (this << +timeoutReason << *mpdu);
990  const WifiMacHeader& hdr = mpdu->GetHeader ();
991 
992  if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
993  && GetWifiRemoteStationManager ()->IsWaitAssocTxOk (hdr.GetAddr1 ()))
994  {
995  NS_LOG_DEBUG ("association failed with sta=" << hdr.GetAddr1 ());
997  }
998 }
999 
1000 void
1002 {
1003  NS_LOG_FUNCTION (this << *mpdu);
1004  const WifiMacHeader* hdr = &mpdu->GetHeader ();
1005  Ptr<const Packet> packet = mpdu->GetPacket ();
1006  Mac48Address from = hdr->GetAddr2 ();
1007  if (hdr->IsData ())
1008  {
1009  Mac48Address bssid = hdr->GetAddr1 ();
1010  if (!hdr->IsFromDs ()
1011  && hdr->IsToDs ()
1012  && bssid == GetAddress ()
1013  && GetWifiRemoteStationManager ()->IsAssociated (from))
1014  {
1015  Mac48Address to = hdr->GetAddr3 ();
1016  if (to == GetAddress ())
1017  {
1018  NS_LOG_DEBUG ("frame for me from=" << from);
1019  if (hdr->IsQosData ())
1020  {
1021  if (hdr->IsQosAmsdu ())
1022  {
1023  NS_LOG_DEBUG ("Received A-MSDU from=" << from << ", size=" << packet->GetSize ());
1025  packet = 0;
1026  }
1027  else
1028  {
1029  ForwardUp (packet, from, bssid);
1030  }
1031  }
1032  else if (hdr->HasData ())
1033  {
1034  ForwardUp (packet, from, bssid);
1035  }
1036  }
1037  else if (to.IsGroup ()
1038  || GetWifiRemoteStationManager ()->IsAssociated (to))
1039  {
1040  NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to);
1041  Ptr<Packet> copy = packet->Copy ();
1042 
1043  //If the frame we are forwarding is of type QoS Data,
1044  //then we need to preserve the UP in the QoS control
1045  //header...
1046  if (hdr->IsQosData ())
1047  {
1048  ForwardDown (copy, from, to, hdr->GetQosTid ());
1049  }
1050  else
1051  {
1052  ForwardDown (copy, from, to);
1053  }
1054  ForwardUp (packet, from, to);
1055  }
1056  else
1057  {
1058  ForwardUp (packet, from, to);
1059  }
1060  }
1061  else if (hdr->IsFromDs ()
1062  && hdr->IsToDs ())
1063  {
1064  //this is an AP-to-AP frame
1065  //we ignore for now.
1066  NotifyRxDrop (packet);
1067  }
1068  else
1069  {
1070  //we can ignore these frames since
1071  //they are not targeted at the AP
1072  NotifyRxDrop (packet);
1073  }
1074  return;
1075  }
1076  else if (hdr->IsMgt ())
1077  {
1078  if (hdr->IsProbeReq ()
1079  && (hdr->GetAddr1 ().IsGroup () || hdr->GetAddr1 () == GetAddress ()))
1080  {
1081  // In the case where the Address 1 field contains a group address, the
1082  // Address 3 field also is validated to verify that the group addressed
1083  // frame originated from a STA in the BSS of which the receiving STA is
1084  // a member (Section 9.3.3.1 of 802.11-2020)
1085  if (hdr->GetAddr1 ().IsGroup ()
1086  && !hdr->GetAddr3 ().IsBroadcast () && hdr->GetAddr3 () != GetAddress ())
1087  {
1088  // not addressed to us
1089  return;
1090  }
1091  MgtProbeRequestHeader probeRequestHeader;
1092  packet->PeekHeader (probeRequestHeader);
1093  Ssid ssid = probeRequestHeader.GetSsid ();
1094  if (ssid == GetSsid () || ssid.IsBroadcast ())
1095  {
1096  NS_LOG_DEBUG ("Probe request received from " << from << ": send probe response");
1097  SendProbeResp (from);
1098  }
1099  return;
1100  }
1101  else if (hdr->GetAddr1 () == GetAddress ())
1102  {
1103  if (hdr->IsAssocReq ())
1104  {
1105  NS_LOG_DEBUG ("Association request received from " << from);
1106  //first, verify that the the station's supported
1107  //rate set is compatible with our Basic Rate set
1108  MgtAssocRequestHeader assocReq;
1109  packet->PeekHeader (assocReq);
1110  CapabilityInformation capabilities = assocReq.GetCapabilities ();
1112  SupportedRates rates = assocReq.GetSupportedRates ();
1113  bool problem = false;
1114  if (rates.GetNRates () == 0)
1115  {
1116  problem = true;
1117  }
1118  if (GetHtSupported ())
1119  {
1120  //check whether the HT STA supports all MCSs in Basic MCS Set
1121  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
1122  if (htcapabilities.IsSupportedMcs (0))
1123  {
1124  for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1125  {
1127  if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1128  {
1129  problem = true;
1130  break;
1131  }
1132  }
1133  }
1134  }
1135  if (GetVhtSupported ())
1136  {
1137  //check whether the VHT STA supports all MCSs in Basic MCS Set
1138  VhtCapabilities vhtcapabilities = assocReq.GetVhtCapabilities ();
1139  if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
1140  {
1141  for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1142  {
1144  if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1145  {
1146  problem = true;
1147  break;
1148  }
1149  }
1150  }
1151  }
1152  if (GetHeSupported ())
1153  {
1154  //check whether the HE STA supports all MCSs in Basic MCS Set
1155  HeCapabilities hecapabilities = assocReq.GetHeCapabilities ();
1156  if (hecapabilities.GetSupportedMcsAndNss () != 0)
1157  {
1158  for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1159  {
1161  if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1162  {
1163  problem = true;
1164  break;
1165  }
1166  }
1167  }
1168  }
1169  if (problem)
1170  {
1171  NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send association response with an error status");
1172  SendAssocResp (hdr->GetAddr2 (), false, false);
1173  }
1174  else
1175  {
1176  NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1177  //record all its supported modes in its associated WifiRemoteStation
1178  for (const auto & mode : GetWifiPhy ()->GetModeList ())
1179  {
1180  if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
1181  {
1183  }
1184  }
1185  if (GetErpSupported () && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ())
1186  {
1188  }
1189  if (GetHtSupported ())
1190  {
1191  HtCapabilities htCapabilities = assocReq.GetHtCapabilities ();
1192  if (htCapabilities.IsSupportedMcs (0))
1193  {
1194  GetWifiRemoteStationManager ()->AddStationHtCapabilities (from, htCapabilities);
1195  }
1196  }
1197  if (GetVhtSupported ())
1198  {
1199  VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilities ();
1200  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1201  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1202  {
1203  GetWifiRemoteStationManager ()->AddStationVhtCapabilities (from, vhtCapabilities);
1204  for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT))
1205  {
1206  if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1207  {
1209  //here should add a control to add basic MCS when it is implemented
1210  }
1211  }
1212  }
1213  }
1214  if (GetHtSupported ())
1215  {
1216  ExtendedCapabilities extendedCapabilities = assocReq.GetExtendedCapabilities ();
1217  //TODO: to be completed
1218  }
1219  if (GetHeSupported ())
1220  {
1221  HeCapabilities heCapabilities = assocReq.GetHeCapabilities ();
1222  if (heCapabilities.GetSupportedMcsAndNss () != 0)
1223  {
1224  GetWifiRemoteStationManager ()->AddStationHeCapabilities (from, heCapabilities);
1225  for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
1226  {
1227  if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1228  {
1230  //here should add a control to add basic MCS when it is implemented
1231  }
1232  }
1233  }
1234  }
1236  NS_LOG_DEBUG ("Send association response with success status");
1237  SendAssocResp (hdr->GetAddr2 (), true, false);
1238  }
1239  return;
1240  }
1241  else if (hdr->IsReassocReq ())
1242  {
1243  NS_LOG_DEBUG ("Reassociation request received from " << from);
1244  //first, verify that the the station's supported
1245  //rate set is compatible with our Basic Rate set
1246  MgtReassocRequestHeader reassocReq;
1247  packet->PeekHeader (reassocReq);
1248  CapabilityInformation capabilities = reassocReq.GetCapabilities ();
1250  SupportedRates rates = reassocReq.GetSupportedRates ();
1251  bool problem = false;
1252  if (rates.GetNRates () == 0)
1253  {
1254  problem = true;
1255  }
1256  if (GetHtSupported ())
1257  {
1258  //check whether the HT STA supports all MCSs in Basic MCS Set
1259  HtCapabilities htcapabilities = reassocReq.GetHtCapabilities ();
1260  if (htcapabilities.IsSupportedMcs (0))
1261  {
1262  for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1263  {
1265  if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1266  {
1267  problem = true;
1268  break;
1269  }
1270  }
1271  }
1272  }
1273  if (GetVhtSupported ())
1274  {
1275  //check whether the VHT STA supports all MCSs in Basic MCS Set
1276  VhtCapabilities vhtcapabilities = reassocReq.GetVhtCapabilities ();
1277  if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
1278  {
1279  for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1280  {
1282  if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1283  {
1284  problem = true;
1285  break;
1286  }
1287  }
1288  }
1289  }
1290  if (GetHeSupported ())
1291  {
1292  //check whether the HE STA supports all MCSs in Basic MCS Set
1293  HeCapabilities hecapabilities = reassocReq.GetHeCapabilities ();
1294  if (hecapabilities.GetSupportedMcsAndNss () != 0)
1295  {
1296  for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1297  {
1299  if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1300  {
1301  problem = true;
1302  break;
1303  }
1304  }
1305  }
1306  }
1307  if (problem)
1308  {
1309  NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send reassociation response with an error status");
1310  SendAssocResp (hdr->GetAddr2 (), false, true);
1311  }
1312  else
1313  {
1314  NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1315  //update all its supported modes in its associated WifiRemoteStation
1316  for (const auto & mode : GetWifiPhy ()->GetModeList ())
1317  {
1318  if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
1319  {
1321  }
1322  }
1323  if (GetErpSupported () && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ())
1324  {
1326  }
1327  if (GetHtSupported ())
1328  {
1329  HtCapabilities htCapabilities = reassocReq.GetHtCapabilities ();
1330  if (htCapabilities.IsSupportedMcs (0))
1331  {
1332  GetWifiRemoteStationManager ()->AddStationHtCapabilities (from, htCapabilities);
1333  }
1334  }
1335  if (GetVhtSupported ())
1336  {
1337  VhtCapabilities vhtCapabilities = reassocReq.GetVhtCapabilities ();
1338  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1339  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1340  {
1341  GetWifiRemoteStationManager ()->AddStationVhtCapabilities (from, vhtCapabilities);
1342  for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT))
1343  {
1344  if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1345  {
1347  //here should add a control to add basic MCS when it is implemented
1348  }
1349  }
1350  }
1351  }
1352  if (GetHtSupported ())
1353  {
1354  ExtendedCapabilities extendedCapabilities = reassocReq.GetExtendedCapabilities ();
1355  //TODO: to be completed
1356  }
1357  if (GetHeSupported ())
1358  {
1359  HeCapabilities heCapabilities = reassocReq.GetHeCapabilities ();
1360  if (heCapabilities.GetSupportedMcsAndNss () != 0)
1361  {
1362  GetWifiRemoteStationManager ()->AddStationHeCapabilities (from, heCapabilities);
1363  for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
1364  {
1365  if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1366  {
1368  //here should add a control to add basic MCS when it is implemented
1369  }
1370  }
1371  }
1372  }
1374  NS_LOG_DEBUG ("Send reassociation response with success status");
1375  SendAssocResp (hdr->GetAddr2 (), true, true);
1376  }
1377  return;
1378  }
1379  else if (hdr->IsDisassociation ())
1380  {
1381  NS_LOG_DEBUG ("Disassociation received from " << from);
1383  for (auto it = m_staList.begin (); it != m_staList.end (); ++it)
1384  {
1385  if (it->second == from)
1386  {
1387  m_staList.erase (it);
1388  m_deAssocLogger (it->first, it->second);
1389  if (GetWifiRemoteStationManager ()->GetDsssSupported (from) && !GetWifiRemoteStationManager ()->GetErpOfdmSupported (from))
1390  {
1392  }
1394  {
1396  }
1399  break;
1400  }
1401  }
1402  return;
1403  }
1404  }
1405  }
1406 
1407  //Invoke the receive handler of our parent class to deal with any
1408  //other frames. Specifically, this will handle Block Ack-related
1409  //Management Action frames.
1410  WifiMac::Receive (Create<WifiMacQueueItem> (packet, *hdr));
1411 }
1412 
1413 void
1415 {
1416  NS_LOG_FUNCTION (this << *mpdu);
1417  for (auto& i : *PeekPointer (mpdu))
1418  {
1419  if (i.second.GetDestinationAddr () == GetAddress ())
1420  {
1421  ForwardUp (i.first, i.second.GetSourceAddr (),
1422  i.second.GetDestinationAddr ());
1423  }
1424  else
1425  {
1426  Mac48Address from = i.second.GetSourceAddr ();
1427  Mac48Address to = i.second.GetDestinationAddr ();
1428  NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
1429  ForwardDown (i.first->Copy (), from, to, mpdu->GetHeader ().GetQosTid ());
1430  }
1431  }
1432 }
1433 
1434 void
1436 {
1437  NS_LOG_FUNCTION (this);
1439  m_beaconEvent.Cancel ();
1441  {
1443  {
1444  Time jitter = MicroSeconds (static_cast<int64_t> (m_beaconJitter->GetValue (0, 1) * (GetBeaconInterval ().GetMicroSeconds ())));
1445  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time " << jitter);
1447  }
1448  else
1449  {
1450  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time 0");
1452  }
1453  }
1459 }
1460 
1461 bool
1463 {
1464  bool useProtection = (m_numNonErpStations > 0) && m_enableNonErpProtection;
1466  return useProtection;
1467 }
1468 
1469 uint16_t
1471 {
1472  //Return the first free AID value between 1 and 2007
1473  for (uint16_t nextAid = 1; nextAid <= 2007; nextAid++)
1474  {
1475  if (m_staList.find (nextAid) == m_staList.end ())
1476  {
1477  return nextAid;
1478  }
1479  }
1480  NS_FATAL_ERROR ("No free association ID available!");
1481  return 0;
1482 }
1483 
1484 const std::map<uint16_t, Mac48Address>&
1486 {
1487  return m_staList;
1488 }
1489 
1490 uint16_t
1492 {
1494 }
1495 
1496 uint8_t
1498 {
1499  auto it = m_bufferStatus.find (WifiAddressTidPair (address, tid));
1500  if (it == m_bufferStatus.end ()
1501  || it->second.timestamp + m_bsrLifetime < Simulator::Now ())
1502  {
1503  return 255;
1504  }
1505  return it->second.value;
1506 }
1507 
1508 void
1510 {
1511  if (size == 255)
1512  {
1513  // no point in storing an unspecified size
1514  m_bufferStatus.erase (WifiAddressTidPair (address, tid));
1515  }
1516  else
1517  {
1519  }
1520 }
1521 
1522 uint8_t
1524 {
1525  uint8_t maxSize = 0;
1526  bool found = false;
1527 
1528  for (uint8_t tid = 0; tid < 8; tid++)
1529  {
1530  uint8_t size = GetBufferStatus (tid, address);
1531  if (size != 255)
1532  {
1533  maxSize = std::max (maxSize, size);
1534  found = true;
1535  }
1536  }
1537 
1538  if (found)
1539  {
1540  return maxSize;
1541  }
1542  return 255;
1543 }
1544 
1545 } //namespace ns3
#define min(a, b)
Definition: 80211b.c:42
#define max(a, b)
Definition: 80211b.c:43
Wi-Fi AP state machine.
Definition: ap-wifi-mac.h:51
void UpdateShortPreambleEnabled(void)
Update whether short preamble should be enabled or not in the BSS.
Definition: ap-wifi-mac.cc:237
bool m_shortPreambleEnabled
Flag whether short preamble is enabled in the BSS.
Definition: ap-wifi-mac.h:314
Ptr< Txop > m_beaconTxop
Dedicated Txop for beacons.
Definition: ap-wifi-mac.h:304
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
Definition: ap-wifi-mac.cc:158
void SendProbeResp(Mac48Address to)
Forward a probe response packet to the DCF.
Definition: ap-wifi-mac.cc:726
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
Definition: ap-wifi-mac.cc:373
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:192
HeOperation GetHeOperation(void) const
Return the HE operation of the current AP.
Definition: ap-wifi-mac.cc:698
uint16_t GetAssociationId(Mac48Address addr) const
void SetAddress(Mac48Address address) override
Definition: ap-wifi-mac.cc:138
uint16_t m_numNonHtStations
Number of non-HT stations currently associated to the AP.
Definition: ap-wifi-mac.h:312
Ptr< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
Definition: ap-wifi-mac.h:308
void TxOk(Ptr< const WifiMacQueueItem > mpdu)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:974
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
Definition: ap-wifi-mac.cc:336
virtual ~ApWifiMac()
Definition: ap-wifi-mac.cc:120
bool m_enableNonErpProtection
Flag whether protection mechanism is used or not when non-ERP STAs are present within the BSS.
Definition: ap-wifi-mac.h:315
bool m_shortSlotTimeEnabled
Flag whether short slot time is enabled within the BSS.
Definition: ap-wifi-mac.h:313
void Receive(Ptr< WifiMacQueueItem > mpdu) override
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
ErpInformation GetErpInformation(void) const
Return the ERP information of the current AP.
Definition: ap-wifi-mac.cc:440
HtOperation GetHtOperation(void) const
Return the HT operation of the current AP.
Definition: ap-wifi-mac.cc:564
bool SupportsSendFrom(void) const override
Definition: ap-wifi-mac.cc:366
std::map< uint16_t, Mac48Address > m_staList
Map of all stations currently associated to the AP with their association ID.
Definition: ap-wifi-mac.h:310
DsssParameterSet GetDsssParameterSet(void) const
Return the DSSS Parameter Set that we support.
Definition: ap-wifi-mac.cc:416
void UpdateShortSlotTimeEnabled(void)
Update whether short slot time should be enabled or not in the BSS.
Definition: ap-wifi-mac.cc:215
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current AP.
Definition: ap-wifi-mac.cc:429
void SendOneBeacon(void)
Forward a beacon packet to the beacon special DCF.
Definition: ap-wifi-mac.cc:902
TracedCallback< uint16_t, Mac48Address > m_deAssocLogger
deassociation logger
Definition: ap-wifi-mac.h:335
bool m_enableBeaconGeneration
Flag whether beacons are being generated.
Definition: ap-wifi-mac.h:305
Time m_beaconInterval
Beacon interval.
Definition: ap-wifi-mac.h:306
void TxFailed(WifiMacDropReason timeoutReason, Ptr< const WifiMacQueueItem > mpdu)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:987
void DeaggregateAmsduAndForward(Ptr< WifiMacQueueItem > mpdu) override
This method is called to de-aggregate an A-MSDU and forward the constituent packets up the stack.
bool m_enableBeaconJitter
Flag whether the first beacon should be generated at random time.
Definition: ap-wifi-mac.h:309
void DoInitialize(void) override
Initialize() implementation.
MuEdcaParameterSet GetMuEdcaParameterSet(void) const
Return the MU EDCA Parameter Set of the current AP.
Definition: ap-wifi-mac.cc:510
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set of the current AP.
Definition: ap-wifi-mac.cc:462
TracedCallback< uint16_t, Mac48Address > m_assocLogger
association logger
Definition: ap-wifi-mac.h:334
bool GetUseNonErpProtection(void) const
Return whether protection for non-ERP stations is used in the BSS.
EventId m_beaconEvent
Event to generate one beacon.
Definition: ap-wifi-mac.h:307
const std::map< uint16_t, Mac48Address > & GetStaList(void) const
Get a const reference to the map of associated stations.
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
Definition: ap-wifi-mac.cc:356
uint8_t GetMaxBufferStatus(Mac48Address address) const
Return the maximum among the values of the Queue Size subfield of the last QoS Data or QoS Null frame...
static TypeId GetTypeId(void)
Get the type ID.
Definition: ap-wifi-mac.cc:50
Time m_bsrLifetime
Lifetime of Buffer Status Reports.
Definition: ap-wifi-mac.h:316
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: ap-wifi-mac.cc:207
uint16_t GetNextAssociationId(void)
uint8_t GetBufferStatus(uint8_t tid, Mac48Address address) const
Return the value of the Queue Size subfield of the last QoS Data or QoS Null frame received from the ...
void SetLinkUpCallback(Callback< void > linkUp) override
Definition: ap-wifi-mac.cc:180
uint16_t m_numNonErpStations
Number of non-ERP stations currently associated to the AP.
Definition: ap-wifi-mac.h:311
VhtOperation GetVhtOperation(void) const
Return the VHT operation of the current AP.
Definition: ap-wifi-mac.cc:653
void DoDispose(void) override
Destructor implementation.
Definition: ap-wifi-mac.cc:127
void SetBufferStatus(uint8_t tid, Mac48Address address, uint8_t size)
Store the value of the Queue Size subfield of the last QoS Data or QoS Null frame received from the s...
void SendAssocResp(Mac48Address to, bool success, bool isReassoc)
Forward an association or a reassociation response packet to the DCF.
Definition: ap-wifi-mac.cc:797
std::unordered_map< WifiAddressTidPair, bsrType, WifiAddressTidHash > m_bufferStatus
Per (MAC address, TID) buffer status reports.
Definition: ap-wifi-mac.h:324
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet down to DCF/EDCAF (enqueue the packet).
Definition: ap-wifi-mac.cc:260
Ptr< WifiMacQueue > GetTxopQueue(AcIndex ac) const override
Get the wifi MAC queue of the (Qos)Txop associated with the given AC, if such (Qos)Txop is installed,...
Definition: ap-wifi-mac.cc:148
Time GetBeaconInterval(void) const
Definition: ap-wifi-mac.cc:173
AttributeValue implementation for Boolean.
Definition: boolean.h:37
bool IsShortPreamble(void) const
Check if the short preamble bit in the capability information field is set to 1.
bool IsShortSlotTime(void) const
Check if the short slot time in the capability information field is set to 1.
void SetShortSlotTime(bool shortSlotTime)
Set the short slot time bit in the capability information field.
void SetShortPreamble(bool shortPreamble)
Set the short preamble bit in the capability information field.
void SetEss(void)
Set the Extended Service Set (ESS) bit in the capability information field.
The DSSS Parameter Set.
void SetCurrentChannel(uint8_t currentChannel)
Set the Current Channel field in the DsssParameterSet information element.
void SetDsssSupported(uint8_t dsssSupported)
Set DSSS supported.
The EDCA Parameter Set.
void SetViTxopLimit(uint16_t txop)
Set the AC_VI TXOP Limit field in the EdcaParameterSet information element.
void SetViAifsn(uint8_t aifsn)
Set the AC_VI AIFSN field in the EdcaParameterSet information element.
void SetVoAci(uint8_t aci)
Set the AC_VO ACI field in the EdcaParameterSet information element.
void SetVoCWmax(uint32_t cwMax)
Set the AC_VO CWmax field in the EdcaParameterSet information element.
void SetViCWmin(uint32_t cwMin)
Set the AC_VI CWmin field in the EdcaParameterSet information element.
void SetVoTxopLimit(uint16_t txop)
Set the AC_VO TXOP Limit field in the EdcaParameterSet information element.
void SetVoAifsn(uint8_t aifsn)
Set the AC_VO AIFSN field in the EdcaParameterSet information element.
void SetQosInfo(uint8_t qosInfo)
Set the QoS Info field in the EdcaParameterSet information element.
void SetBkCWmin(uint32_t cwMin)
Set the AC_BK CWmin field in the EdcaParameterSet information element.
void SetViAci(uint8_t aci)
Set the AC_VI ACI field in the EdcaParameterSet information element.
void SetViCWmax(uint32_t cwMax)
Set the AC_VI CWmax field in the EdcaParameterSet information element.
void SetVoCWmin(uint32_t cwMin)
Set the AC_VO CWmin field in the EdcaParameterSet information element.
void SetBeTxopLimit(uint16_t txop)
Set the AC_BE TXOP Limit field in the EdcaParameterSet information element.
void SetBeCWmax(uint32_t cwMax)
Set the AC_BE CWmax field in the EdcaParameterSet information element.
void SetBeAci(uint8_t aci)
Set the AC_BE ACI field in the EdcaParameterSet information element.
void SetBkCWmax(uint32_t cwMax)
Set the AC_BK CWmax field in the EdcaParameterSet information element.
void SetBkTxopLimit(uint16_t txop)
Set the AC_BK TXOP Limit field in the EdcaParameterSet information element.
void SetBkAifsn(uint8_t aifsn)
Set the AC_BK AIFSN field in the EdcaParameterSet information element.
void SetBeCWmin(uint32_t cwMin)
Set the AC_BE CWmin field in the EdcaParameterSet information element.
void SetBkAci(uint8_t aci)
Set the AC_BK ACI field in the EdcaParameterSet information element.
void SetQosSupported(uint8_t qosSupported)
Set QOS supported function.
void SetBeAifsn(uint8_t aifsn)
Set the AC_BE AIFSN field in the EdcaParameterSet information element.
The ErpInformation Information Element.
void SetErpSupported(uint8_t erpSupported)
Set the ERP supported field.
void SetBarkerPreambleMode(uint8_t barkerPreambleMode)
Set the Barker_Preamble_Mode field in the ErpInformation information element.
void SetUseProtection(uint8_t useProtection)
Set the Use_Protection field in the ErpInformation information element.
void SetNonErpPresent(uint8_t nonErpPresent)
Set the Non_Erp_Present field in the ErpInformation information element.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
The Extended Capabilities Information Element.
The IEEE 802.11ax HE Capabilities.
bool IsSupportedTxMcs(uint8_t mcs) const
Is RX MCS supported.
uint16_t GetSupportedMcsAndNss() const
Return the MCS and NSS field in the HE Capabilities information element.
The HE Operation Information Element.
Definition: he-operation.h:36
void SetBssColor(uint8_t bssColor)
Set the BSS color.
void SetMaxHeMcsPerNss(uint8_t nss, uint8_t maxHeMcs)
Set the Basic HE-MCS and NSS field in the HE Operation information element by specifying the tuple (n...
Definition: he-operation.cc:97
void SetHeSupported(uint8_t heSupported)
Set the HE supported information element.
Definition: he-operation.cc:53
The HT Capabilities Information Element.
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
The HT Operation Information Element.
Definition: ht-operation.h:51
void SetObssNonHtStasPresent(uint8_t obssNonHtStasPresent)
Set the OBSS non HT STAs present.
void SetRifsMode(uint8_t rifsMode)
Set the RIFS mode.
Definition: ht-operation.cc:99
void SetSecondaryChannelOffset(uint8_t secondaryChannelOffset)
Set the secondary channel offset.
Definition: ht-operation.cc:87
void SetPcoActive(uint8_t pcoActive)
Set the PCO active.
void SetTxUnequalModulation(uint8_t txUnequalModulation)
Set the transmit unequal modulation.
void SetHtProtection(uint8_t htProtection)
Set the HT protection.
void SetTxMaxNSpatialStreams(uint8_t maxTxSpatialStreams)
Set the transmit maximum number spatial streams.
void SetTxRxMcsSetUnequal(uint8_t txRxMcsSetUnequal)
Set the transmit / receive MCS set unequal.
void SetDualBeacon(uint8_t dualBeacon)
Set the dual beacon.
void SetNonGfHtStasPresent(uint8_t nonGfHtStasPresent)
Set the non GF HT STAs present.
void SetTxMcsSetDefined(uint8_t txMcsSetDefined)
Set the transmit MCS set defined.
void SetLSigTxopProtectionFullSupport(uint8_t lSigTxopProtectionFullSupport)
Set the LSIG TXOP protection full support.
void SetStaChannelWidth(uint8_t staChannelWidth)
Set the STA channel width.
Definition: ht-operation.cc:93
void SetRxHighestSupportedDataRate(uint16_t maxSupportedRate)
Set the receive highest supported data rate.
void SetRxMcsBitmask(uint8_t index)
Set the receive MCS bitmask.
void SetPrimaryChannel(uint8_t ctrl)
Set the Primary Channel field in the HT Operation information element.
Definition: ht-operation.cc:81
void SetDualCtsProtection(uint8_t dualCtsProtection)
Set the dual CTS protection.
void SetPhase(uint8_t pcoPhase)
Set the PCO phase.
void SetHtSupported(uint8_t htSupported)
Set the HT Supported.
Definition: ht-operation.cc:67
void SetStbcBeacon(uint8_t stbcBeacon)
Set the STBC beacon.
an EUI-48 address
Definition: mac48-address.h:44
static Mac48Address GetBroadcast(void)
bool IsGroup(void) const
bool IsBroadcast(void) const
Implement the header for management frames of type association request.
Definition: mgt-headers.h:50
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:602
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:554
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:566
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:578
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:590
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:614
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:320
void SetErpInformation(ErpInformation erpInformation)
Set the ERP information.
void SetVhtCapabilities(VhtCapabilities vhtCapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:986
void SetHtCapabilities(HtCapabilities htCapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:962
void SetHtOperation(HtOperation htOperation)
Set the HT operation.
Definition: mgt-headers.cc:974
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:938
void SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
void SetStatusCode(StatusCode code)
Set the status code.
Definition: mgt-headers.cc:926
void SetAssociationId(uint16_t aid)
Set the association ID.
void SetMuEdcaParameterSet(MuEdcaParameterSet muEdcaParameterSet)
Set the MU EDCA Parameter Set.
void SetEdcaParameterSet(EdcaParameterSet edcaParameterSet)
Set the EDCA Parameter Set.
void SetHeOperation(HeOperation heOperation)
Set the HE operation.
void SetExtendedCapabilities(ExtendedCapabilities extendedCapabilities)
Set the extended capabilities.
Definition: mgt-headers.cc:950
void SetVhtOperation(VhtOperation vhtOperation)
Set the VHT operation.
Definition: mgt-headers.cc:998
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:932
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:862
Implement the header for management frames of type probe request.
Definition: mgt-headers.h:529
Ssid GetSsid(void) const
Return the Service Set Identifier (SSID).
Definition: mgt-headers.cc:46
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:633
void SetVhtCapabilities(VhtCapabilities vhtCapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:268
void SetErpInformation(ErpInformation erpInformation)
Set the ERP information.
Definition: mgt-headers.cc:346
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:220
void SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:292
void SetExtendedCapabilities(ExtendedCapabilities extendedCapabilities)
Set the extended capabilities.
Definition: mgt-headers.cc:232
void SetVhtOperation(VhtOperation vhtOperation)
Set the VHT operation.
Definition: mgt-headers.cc:280
void SetHtCapabilities(HtCapabilities htCapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:244
void SetHtOperation(HtOperation htOperation)
Set the HT operation.
Definition: mgt-headers.cc:256
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:316
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:328
void SetDsssParameterSet(DsssParameterSet dsssParameterSet)
Set the DSSS Parameter Set.
Definition: mgt-headers.cc:334
void SetBeaconIntervalUs(uint64_t us)
Set the beacon interval in microseconds unit.
Definition: mgt-headers.cc:322
void SetEdcaParameterSet(EdcaParameterSet edcaParameterSet)
Set the EDCA Parameter Set.
Definition: mgt-headers.cc:358
void SetHeOperation(HeOperation heOperation)
Set the HE operation.
Definition: mgt-headers.cc:304
void SetMuEdcaParameterSet(MuEdcaParameterSet muEdcaParameterSet)
Set the MU EDCA Parameter Set.
Definition: mgt-headers.cc:364
Implement the header for management frames of type reassociation request.
Definition: mgt-headers.h:182
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:801
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:789
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:777
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:765
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:741
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:753
The MU EDCA Parameter Set.
void SetMuCwMin(uint8_t aci, uint16_t cwMin)
Set the ECWmin subfield of the ECWmin/ECWmax field in the MU AC Parameter Record field corresponding ...
void SetMuEdcaTimer(uint8_t aci, Time timer)
Set the MU EDCA Timer field in the MU AC Parameter Record field corresponding to the given AC Index (...
void SetMuAifsn(uint8_t aci, uint8_t aifsn)
Set the AIFSN subfield of the ACI/AIFSN field in the MU AC Parameter Record field corresponding to th...
void SetQosInfo(uint8_t qosInfo)
Set the QoS Info field in the MuEdcaParameterSet information element.
void SetMuCwMax(uint8_t aci, uint16_t cwMax)
Set the ECWmax subfield of the ECWmin/ECWmax field in the MU AC Parameter Record field corresponding ...
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:364
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Definition: object.cc:183
void Dispose(void)
Dispose of this Object.
Definition: object.cc:214
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:856
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
uint32_t GetMinCw(void) const override
Return the minimum contention window size from the EDCA Parameter Set or the MU EDCA Parameter Set,...
Definition: qos-txop.cc:211
uint8_t GetAifsn(void) const override
Return the number of slots that make up an AIFS according to the EDCA Parameter Set or the MU EDCA Pa...
Definition: qos-txop.cc:233
uint32_t GetMaxCw(void) const override
Return the maximum contention window size from the EDCA Parameter Set or the MU EDCA Parameter Set,...
Definition: qos-txop.cc:222
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:587
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
Status code for association response.
Definition: status-code.h:32
void SetFailure(void)
Set success bit to 1 (failure).
Definition: status-code.cc:36
void SetSuccess(void)
Set success bit to 0 (success).
Definition: status-code.cc:30
Hold variables of type string.
Definition: string.h:41
The Supported Rates Information Element.
void SetBasicRate(uint64_t bs)
Set the given rate to basic rates.
void AddBssMembershipSelectorRate(uint64_t bs)
Add a special value to the supported rate set, corresponding to a BSS membership selector.
uint8_t GetNRates(void) const
Return the number of supported rates.
void AddSupportedRate(uint64_t bs)
Add the given rate to the supported rates.
bool IsSupportedRate(uint64_t bs) const
Check if the given rate is supported.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:387
AttributeValue implementation for Time.
Definition: nstime.h:1308
Time Get(void) const
Definition: time.cc:519
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:173
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Definition: txop.cc:154
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: txop.cc:280
virtual void SetWifiMac(const Ptr< WifiMac > mac)
Set the wifi MAC this Txop is associated to.
Definition: txop.cc:136
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Definition: txop.cc:129
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:247
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:161
void SetChannelAccessManager(const Ptr< ChannelAccessManager > manager)
Set ChannelAccessManager this Txop is associated to.
Definition: txop.cc:122
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:294
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Hold an unsigned integer type.
Definition: uinteger.h:44
uint64_t Get(void) const
Definition: uinteger.cc:35
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
The IEEE 802.11ac VHT Capabilities.
bool IsSupportedTxMcs(uint8_t mcs) const
Returns true if transmit MCS is supported.
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
uint32_t GetVhtCapabilitiesInfo() const
Return the VHT Capabilities Info field in the VHT Capabilities information element.
The VHT Operation Information Element.
Definition: vht-operation.h:36
void SetVhtSupported(uint8_t vhtSupported)
Set the VHT supported information element.
void SetMaxVhtMcsPerNss(uint8_t nss, uint8_t maxVhtMcs)
Set the Basic VHT-MCS and NSS field in the VHT Operation information element by specifying the tuple ...
void SetChannelWidth(uint8_t channelWidth)
Set the Channel Width field in the VHT Operation information element.
void SetChannelCenterFrequencySegment1(uint8_t channelCenterFrequencySegment1)
Set the Channel Center Frequency Segment 1 field in the VHT Operation information element.
void SetChannelCenterFrequencySegment0(uint8_t channelCenterFrequencySegment0)
Set the Channel Center Frequency Segment 0 field in the VHT Operation information element.
Implements the IEEE 802.11 MAC header.
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.
bool HasData(void) const
Return true if the header type is DATA and is not DATA_NULL.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
bool IsFromDs(void) const
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
bool IsDisassociation(void) const
Return true if the header is a Disassociation header.
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
bool IsProbeReq(void) const
Return true if the header is a Probe Request header.
bool IsMgt(void) const
Return true if the Type is Management.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
void SetNoOrder(void)
Unset order bit in the frame control field.
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
bool IsData(void) const
Return true if the Type is DATA.
void SetDsFrom(void)
Set the From DS bit in the Frame Control field.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
bool IsToDs(void) const
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:85
Ptr< HtConfiguration > GetHtConfiguration(void) const
Definition: wifi-mac.cc:1047
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities of the device.
Definition: wifi-mac.cc:1175
bool GetShortSlotTimeSupported(void) const
Definition: wifi-mac.cc:872
Ptr< HeConfiguration > GetHeConfiguration(void) const
Definition: wifi-mac.cc:1059
bool GetVhtSupported() const
Return whether the device supports VHT.
Definition: wifi-mac.cc:1075
bool GetQosSupported() const
Return whether the device supports QoS.
Definition: wifi-mac.cc:822
virtual void SetAddress(Mac48Address address)
Definition: wifi-mac.cc:396
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
Definition: wifi-mac.cc:1325
Ssid GetSsid(void) const
Definition: wifi-mac.cc:416
void DoInitialize() override
Initialize() implementation.
Definition: wifi-mac.cc:320
Mac48Address GetAddress(void) const
Definition: wifi-mac.cc:403
Ptr< QosTxop > GetBEQueue(void) const
Accessor for the AC_BE channel access function.
Definition: wifi-mac.cc:485
bool GetHtSupported() const
Return whether the device supports HT.
Definition: wifi-mac.cc:1065
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Definition: wifi-mac.cc:371
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
Definition: wifi-mac.cc:757
Ptr< QosTxop > GetVOQueue(void) const
Accessor for the AC_VO channel access function.
Definition: wifi-mac.cc:473
Ptr< ChannelAccessManager > m_channelAccessManager
channel access manager
Definition: wifi-mac.h:521
bool GetHeSupported() const
Return whether the device supports HE.
Definition: wifi-mac.cc:1085
virtual void Receive(Ptr< WifiMacQueueItem > mpdu)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
Definition: wifi-mac.cc:923
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
Definition: wifi-mac.h:520
Ptr< WifiPhy > GetWifiPhy(void) const
Definition: wifi-mac.cc:776
virtual Ptr< WifiMacQueue > GetTxopQueue(AcIndex ac) const
Get the wifi MAC queue of the (Qos)Txop associated with the given AC, if such (Qos)Txop is installed,...
Definition: wifi-mac.cc:497
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:543
virtual void SetLinkUpCallback(Callback< void > linkUp)
Definition: wifi-mac.cc:891
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
Definition: wifi-mac.cc:916
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
Definition: wifi-mac.cc:1242
bool GetErpSupported() const
Return whether the device supports ERP.
Definition: wifi-mac.cc:828
bool GetDsssSupported() const
Return whether the device supports DSSS.
Definition: wifi-mac.cc:852
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
Definition: wifi-mac.cc:1186
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
Definition: wifi-mac.cc:452
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:525
void DoDispose() override
Destructor implementation.
Definition: wifi-mac.cc:336
void SetBssid(Mac48Address bssid)
Definition: wifi-mac.cc:422
Ptr< Txop > GetTxop(void) const
Accessor for the Txop object.
Definition: wifi-mac.cc:446
represent a single transmission mode
Definition: wifi-mode.h:48
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:155
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:140
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:114
std::list< WifiMode > GetMcsList(void) const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
Definition: wifi-phy.cc:1767
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1138
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1120
void SetSlot(Time slot)
Set the slot duration for this PHY.
Definition: wifi-phy.cc:682
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:918
uint8_t GetNumberOfSupportedStreams(Mac48Address address) const
Return the number of spatial streams supported by the station.
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
uint16_t GetAssociationId(Mac48Address remoteAddress) const
Get the AID of a remote station.
uint8_t GetNBasicMcs(void) const
Return the number of basic MCS index.
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
uint8_t GetNBasicModes(void) const
Return the number of basic modes we support.
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtCapabilities)
Records VHT capabilities of the remote station.
void SetShortPreambleEnabled(bool enable)
Enable or disable short PHY preambles.
void RecordWaitAssocTxOk(Mac48Address address)
Records that we are waiting for an ACK for the association response we sent.
void RecordGotAssocTxOk(Mac48Address address)
Records that we got an ACK for the association response we sent.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
void AddSupportedMode(Mac48Address address, WifiMode mode)
Invoked in a STA or AP to store the set of modes supported by a destination which is also supported l...
WifiMode GetBasicMcs(uint8_t i) const
Return the MCS at the given list index.
uint8_t GetNMcsSupported(Mac48Address address) const
Return the number of MCS supported by the station.
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
void AddSupportedPhyPreamble(Mac48Address address, bool isShortPreambleSupported)
Record whether the short PHY preamble is supported by the station.
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
void SetAssociationId(Mac48Address remoteAddress, uint16_t aid)
Record the AID of a remote station.
void AddSupportedErpSlotTime(Mac48Address address, bool isShortSlotTimeSupported)
Record whether the short ERP slot time is supported by the station.
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
Records HT capabilities of the remote station.
void RecordGotAssocTxFailed(Mac48Address address)
Records that we missed an ACK for the association response we sent.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: boolean.h:85
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: pointer.h:227
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: nstime.h:1309
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Definition: abort.h:77
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#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 MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1260
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1252
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
WifiMacDropReason
The reason why an MPDU was dropped.
Definition: wifi-mac.h:66
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a QoS tag is attached to the packet, returns a value < 8.
Definition: qos-utils.cc:152
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:71
@ WIFI_STANDARD_80211ac
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ AC_BE
Best Effort.
Definition: qos-utils.h:73
@ AC_VO
Voice.
Definition: qos-utils.h:79
@ AC_VI
Video.
Definition: qos-utils.h:77
@ AC_BK
Background.
Definition: qos-utils.h:75
@ AC_BEACON
Beacon queue.
Definition: qos-utils.h:83
address
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ AP
Definition: wifi-mac.h:54
@ NO_PROTECTION
Definition: ht-operation.h:37
@ MIXED_MODE_PROTECTION
Definition: ht-operation.h:40
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:522
@ WIFI_MAC_MGT_BEACON
@ WIFI_MAC_MGT_ASSOCIATION_RESPONSE
@ WIFI_MAC_MGT_PROBE_RESPONSE
@ WIFI_MAC_DATA
@ WIFI_MAC_MGT_REASSOCIATION_RESPONSE
@ WIFI_MAC_QOSDATA
std::pair< Mac48Address, uint8_t > WifiAddressTidPair
(MAC address, TID) pair
Definition: qos-utils.h:32
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1648
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:415
ssid
Definition: third.py:100