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 "ns3/ht-configuration.h"
39 #include "ns3/he-configuration.h"
40 
41 namespace ns3 {
42 
43 NS_LOG_COMPONENT_DEFINE ("ApWifiMac");
44 
45 NS_OBJECT_ENSURE_REGISTERED (ApWifiMac);
46 
47 TypeId
49 {
50  static TypeId tid = TypeId ("ns3::ApWifiMac")
52  .SetGroupName ("Wifi")
53  .AddConstructor<ApWifiMac> ()
54  .AddAttribute ("BeaconInterval",
55  "Delay between two beacons",
56  TimeValue (MicroSeconds (102400)),
59  MakeTimeChecker ())
60  .AddAttribute ("BeaconJitter",
61  "A uniform random variable to cause the initial beacon starting time (after simulation time 0) "
62  "to be distributed between 0 and the BeaconInterval.",
63  StringValue ("ns3::UniformRandomVariable"),
65  MakePointerChecker<UniformRandomVariable> ())
66  .AddAttribute ("EnableBeaconJitter",
67  "If beacons are enabled, whether to jitter the initial send event.",
68  BooleanValue (true),
71  .AddAttribute ("BeaconGeneration",
72  "Whether or not beacons are generated.",
73  BooleanValue (true),
76  .AddAttribute ("EnableNonErpProtection", "Whether or not protection mechanism should be used when non-ERP STAs are present within the BSS."
77  "This parameter is only used when ERP is supported by the AP.",
78  BooleanValue (true),
81  .AddAttribute ("BsrLifetime",
82  "Lifetime of Buffer Status Reports received from stations.",
83  TimeValue (MilliSeconds (20)),
85  MakeTimeChecker ())
86  ;
87  return tid;
88 }
89 
91  : m_enableBeaconGeneration (false)
92 {
93  NS_LOG_FUNCTION (this);
94  m_beaconTxop = CreateObject<Txop> ();
101 
102  //Let the lower layers know that we are acting as an AP.
104 
106 }
107 
109 {
110  NS_LOG_FUNCTION (this);
111  m_staList.clear ();
112  m_nonErpStations.clear ();
113  m_nonHtStations.clear ();
114  m_cfPollingList.clear ();
115 }
116 
117 void
119 {
120  NS_LOG_FUNCTION (this);
121  m_beaconTxop->Dispose ();
122  m_beaconTxop = 0;
123  m_enableBeaconGeneration = false;
125  m_cfpEvent.Cancel ();
127 }
128 
129 void
131 {
132  NS_LOG_FUNCTION (this << address);
133  //As an AP, our MAC address is also the BSSID. Hence we are
134  //overriding this function and setting both in our parent class.
137 }
138 
139 void
141 {
142  NS_LOG_FUNCTION (this << enable);
143  if (!enable)
144  {
146  }
147  else if (enable && !m_enableBeaconGeneration)
148  {
150  }
151  m_enableBeaconGeneration = enable;
152 }
153 
154 Time
156 {
157  NS_LOG_FUNCTION (this);
158  return m_beaconInterval;
159 }
160 
161 void
163 {
164  NS_LOG_FUNCTION (this << stationManager);
165  m_beaconTxop->SetWifiRemoteStationManager (stationManager);
168 }
169 
170 void
172 {
173  NS_LOG_FUNCTION (this << &linkUp);
175 
176  //The approach taken here is that, from the point of view of an AP,
177  //the link is always up, so we immediately invoke the callback if
178  //one is set
179  linkUp ();
180 }
181 
182 void
184 {
185  NS_LOG_FUNCTION (this << interval);
186  if ((interval.GetMicroSeconds () % 1024) != 0)
187  {
188  NS_FATAL_ERROR ("beacon interval should be multiple of 1024us (802.11 time unit), see IEEE Std. 802.11-2012");
189  }
190  if (interval.GetMicroSeconds () > (1024 * 65535))
191  {
192  NS_FATAL_ERROR ("beacon interval should be smaller then or equal to 65535 * 1024us (802.11 time unit)");
193  }
194  m_beaconInterval = interval;
195 }
196 
197 int64_t
198 ApWifiMac::AssignStreams (int64_t stream)
199 {
200  NS_LOG_FUNCTION (this << stream);
201  m_beaconJitter->SetStream (stream);
202  return 1;
203 }
204 
205 bool
207 {
208  if (m_nonErpStations.size () != 0)
209  {
210  return false;
211  }
213  {
214  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
215  {
217  {
218  return false;
219  }
220  }
221  return true;
222  }
223  return false;
224 }
225 
226 bool
228 {
230  {
231  for (std::list<Mac48Address>::const_iterator i = m_nonErpStations.begin (); i != m_nonErpStations.end (); i++)
232  {
234  {
235  return false;
236  }
237  }
238  return true;
239  }
240  return false;
241 }
242 
243 uint16_t
245 {
246  uint16_t channelWidth = m_phy->GetChannelWidth ();
247  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
248  {
249  if (m_stationManager->GetVhtSupported (i->second))
250  {
251  if (m_stationManager->GetChannelWidthSupported (i->second) < channelWidth)
252  {
253  channelWidth = m_stationManager->GetChannelWidthSupported (i->second);
254  }
255  }
256  }
257  return channelWidth;
258 }
259 
260 void
262  Mac48Address to)
263 {
264  NS_LOG_FUNCTION (this << packet << from << to);
265  //If we are not a QoS AP then we definitely want to use AC_BE to
266  //transmit the packet. A TID of zero will map to AC_BE (through \c
267  //QosUtilsMapTidToAc()), so we use that as our default here.
268  uint8_t tid = 0;
269 
270  //If we are a QoS AP then we attempt to get a TID for this packet
271  if (GetQosSupported ())
272  {
273  tid = QosUtilsGetTidForPacket (packet);
274  //Any value greater than 7 is invalid and likely indicates that
275  //the packet had no QoS tag, so we revert to zero, which'll
276  //mean that AC_BE is used.
277  if (tid > 7)
278  {
279  tid = 0;
280  }
281  }
282 
283  ForwardDown (packet, from, to, tid);
284 }
285 
286 void
288  Mac48Address to, uint8_t tid)
289 {
290  NS_LOG_FUNCTION (this << packet << from << to << +tid);
291  WifiMacHeader hdr;
292 
293  //For now, an AP that supports QoS does not support non-QoS
294  //associations, and vice versa. In future the AP model should
295  //support simultaneously associated QoS and non-QoS STAs, at which
296  //point there will need to be per-association QoS state maintained
297  //by the association state machine, and consulted here.
298  if (GetQosSupported ())
299  {
302  hdr.SetQosNoEosp ();
303  hdr.SetQosNoAmsdu ();
304  //Transmission of multiple frames in the same Polled TXOP is not supported for now
305  hdr.SetQosTxopLimit (0);
306  //Fill in the QoS control field in the MAC header
307  hdr.SetQosTid (tid);
308  }
309  else
310  {
311  hdr.SetType (WIFI_MAC_DATA);
312  }
313 
314  if (GetQosSupported ())
315  {
316  hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT control field is not yet implemented (set it to 1 when implemented)
317  }
318  hdr.SetAddr1 (to);
319  hdr.SetAddr2 (GetAddress ());
320  hdr.SetAddr3 (from);
321  hdr.SetDsFrom ();
322  hdr.SetDsNotTo ();
323 
324  if (GetQosSupported ())
325  {
326  //Sanity check that the TID is valid
327  NS_ASSERT (tid < 8);
328  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
329  }
330  else
331  {
332  m_txop->Queue (packet, hdr);
333  }
334 }
335 
336 void
338 {
339  NS_LOG_FUNCTION (this << packet << to << from);
340  if (to.IsGroup () || m_stationManager->IsAssociated (to))
341  {
342  ForwardDown (packet, from, to);
343  }
344  else
345  {
346  NotifyTxDrop (packet);
347  }
348 }
349 
350 void
352 {
353  NS_LOG_FUNCTION (this << packet << to);
354  //We're sending this packet with a from address that is our own. We
355  //get that address from the lower MAC and make use of the
356  //from-spoofing Enqueue() method to avoid duplicated code.
357  Enqueue (packet, to, GetAddress ());
358 }
359 
360 bool
362 {
363  NS_LOG_FUNCTION (this);
364  return true;
365 }
366 
369 {
370  NS_LOG_FUNCTION (this);
371  SupportedRates rates;
372  //Send the set of supported rates and make sure that we indicate
373  //the Basic Rate set in this set of supported rates.
374  for (const auto & mode : m_phy->GetModeList ())
375  {
376  uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ());
377  NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
378  rates.AddSupportedRate (modeDataRate);
379  //Add rates that are part of the BSSBasicRateSet (manufacturer dependent!)
380  //here we choose to add the mandatory rates to the BSSBasicRateSet,
381  //except for 802.11b where we assume that only the non HR-DSSS rates are part of the BSSBasicRateSet
382  if (mode.IsMandatory () && (mode.GetModulationClass () != WIFI_MOD_CLASS_HR_DSSS))
383  {
384  NS_LOG_DEBUG ("Adding basic mode " << mode.GetUniqueName ());
386  }
387  }
388  //set the basic rates
389  for (uint8_t j = 0; j < m_stationManager->GetNBasicModes (); j++)
390  {
392  uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ());
393  NS_LOG_DEBUG ("Setting basic rate " << mode.GetUniqueName ());
394  rates.SetBasicRate (modeDataRate);
395  }
396  //If it is a HT AP, then add the BSSMembershipSelectorSet
397  //The standard says that the BSSMembershipSelectorSet
398  //must have its MSB set to 1 (must be treated as a Basic Rate)
399  //Also the standard mentioned that at least 1 element should be included in the SupportedRates the rest can be in the ExtendedSupportedRates
400  if (GetHtSupported ())
401  {
402  for (const auto & selector : m_phy->GetBssMembershipSelectorList ())
403  {
404  rates.AddBssMembershipSelectorRate (selector);
405  }
406  }
407  return rates;
408 }
409 
412 {
413  NS_LOG_FUNCTION (this);
414  DsssParameterSet dsssParameters;
415  if (GetDsssSupported ())
416  {
417  dsssParameters.SetDsssSupported (1);
418  dsssParameters.SetCurrentChannel (m_phy->GetChannelNumber ());
419  }
420  return dsssParameters;
421 }
422 
425 {
426  NS_LOG_FUNCTION (this);
427  CapabilityInformation capabilities;
428  capabilities.SetShortPreamble (GetShortPreambleEnabled ());
429  capabilities.SetShortSlotTime (GetShortSlotTimeEnabled ());
430  capabilities.SetEss ();
431  if (GetPcfSupported ())
432  {
433  capabilities.SetCfPollable ();
434  }
435  return capabilities;
436 }
437 
440 {
441  NS_LOG_FUNCTION (this);
442  ErpInformation information;
443  information.SetErpSupported (1);
444  if (GetErpSupported ())
445  {
446  information.SetNonErpPresent (!m_nonErpStations.empty ());
447  information.SetUseProtection (GetUseNonErpProtection ());
449  {
450  information.SetBarkerPreambleMode (0);
451  }
452  else
453  {
454  information.SetBarkerPreambleMode (1);
455  }
456  }
457  return information;
458 }
459 
462 {
463  NS_LOG_FUNCTION (this);
464  EdcaParameterSet edcaParameters;
465  if (GetQosSupported ())
466  {
467  edcaParameters.SetQosSupported (1);
468  Ptr<QosTxop> edca;
469  Time txopLimit;
470 
471  edca = m_edca.find (AC_BE)->second;
472  txopLimit = edca->GetTxopLimit ();
473  edcaParameters.SetBeAci (0);
474  edcaParameters.SetBeCWmin (edca->GetMinCw ());
475  edcaParameters.SetBeCWmax (edca->GetMaxCw ());
476  edcaParameters.SetBeAifsn (edca->GetAifsn ());
477  edcaParameters.SetBeTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
478 
479  edca = m_edca.find (AC_BK)->second;
480  txopLimit = edca->GetTxopLimit ();
481  edcaParameters.SetBkAci (1);
482  edcaParameters.SetBkCWmin (edca->GetMinCw ());
483  edcaParameters.SetBkCWmax (edca->GetMaxCw ());
484  edcaParameters.SetBkAifsn (edca->GetAifsn ());
485  edcaParameters.SetBkTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
486 
487  edca = m_edca.find (AC_VI)->second;
488  txopLimit = edca->GetTxopLimit ();
489  edcaParameters.SetViAci (2);
490  edcaParameters.SetViCWmin (edca->GetMinCw ());
491  edcaParameters.SetViCWmax (edca->GetMaxCw ());
492  edcaParameters.SetViAifsn (edca->GetAifsn ());
493  edcaParameters.SetViTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
494 
495  edca = m_edca.find (AC_VO)->second;
496  txopLimit = edca->GetTxopLimit ();
497  edcaParameters.SetVoAci (3);
498  edcaParameters.SetVoCWmin (edca->GetMinCw ());
499  edcaParameters.SetVoCWmax (edca->GetMaxCw ());
500  edcaParameters.SetVoAifsn (edca->GetAifsn ());
501  edcaParameters.SetVoTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
502 
503  edcaParameters.SetQosInfo (0);
504  }
505  return edcaParameters;
506 }
507 
510 {
511  NS_LOG_FUNCTION (this);
512  HtOperation operation;
513  if (GetHtSupported ())
514  {
515  operation.SetHtSupported (1);
516  operation.SetPrimaryChannel (m_phy->GetChannelNumber ());
517  operation.SetRifsMode (false);
518  operation.SetNonGfHtStasPresent (true);
519  if (m_phy->GetChannelWidth () > 20)
520  {
521  operation.SetSecondaryChannelOffset (1);
522  operation.SetStaChannelWidth (1);
523  }
524  if (m_nonHtStations.empty ())
525  {
526  operation.SetHtProtection (NO_PROTECTION);
527  }
528  else
529  {
531  }
532  uint64_t maxSupportedRate = 0; //in bit/s
533  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HT))
534  {
535  uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
536  NS_ASSERT (nss > 0 && nss < 5);
537  uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), GetHtConfiguration ()->GetShortGuardIntervalSupported () ? 400 : 800, nss);
538  if (dataRate > maxSupportedRate)
539  {
540  maxSupportedRate = dataRate;
541  NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate);
542  }
543  }
544  uint8_t maxSpatialStream = m_phy->GetMaxSupportedTxSpatialStreams ();
545  auto mcsList = m_phy->GetMcsList (WIFI_MOD_CLASS_HT);
546  uint8_t nMcs = mcsList.size ();
547  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
548  {
549  if (m_stationManager->GetHtSupported (i->second))
550  {
551  uint64_t maxSupportedRateByHtSta = 0; //in bit/s
552  auto itMcs = mcsList.begin ();
553  for (uint8_t j = 0; j < (std::min (nMcs, m_stationManager->GetNMcsSupported (i->second))); j++)
554  {
555  WifiMode mcs = *itMcs++;
556  uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
557  NS_ASSERT (nss > 0 && nss < 5);
558  uint64_t dataRate = mcs.GetDataRate (m_stationManager->GetChannelWidthSupported (i->second), m_stationManager->GetShortGuardIntervalSupported (i->second) ? 400 : 800, nss);
559  if (dataRate > maxSupportedRateByHtSta)
560  {
561  maxSupportedRateByHtSta = dataRate;
562  }
563  }
564  if (maxSupportedRateByHtSta < maxSupportedRate)
565  {
566  maxSupportedRate = maxSupportedRateByHtSta;
567  }
568  if (m_stationManager->GetNMcsSupported (i->second) < nMcs)
569  {
570  nMcs = m_stationManager->GetNMcsSupported (i->second);
571  }
572  if (m_stationManager->GetNumberOfSupportedStreams (i->second) < maxSpatialStream)
573  {
574  maxSpatialStream = m_stationManager->GetNumberOfSupportedStreams (i->second);
575  }
576  }
577  }
578  operation.SetRxHighestSupportedDataRate (static_cast<uint16_t> (maxSupportedRate / 1e6)); //in Mbit/s
579  operation.SetTxMcsSetDefined (nMcs > 0);
580  operation.SetTxMaxNSpatialStreams (maxSpatialStream);
581  //To be filled in once supported
582  operation.SetObssNonHtStasPresent (0);
583  operation.SetDualBeacon (0);
584  operation.SetDualCtsProtection (0);
585  operation.SetStbcBeacon (0);
586  operation.SetLSigTxopProtectionFullSupport (0);
587  operation.SetPcoActive (0);
588  operation.SetPhase (0);
589  operation.SetRxMcsBitmask (0);
590  operation.SetTxRxMcsSetUnequal (0);
591  operation.SetTxUnequalModulation (0);
592  }
593  return operation;
594 }
595 
598 {
599  NS_LOG_FUNCTION (this);
600  VhtOperation operation;
601  if (GetVhtSupported ())
602  {
603  operation.SetVhtSupported (1);
604  uint16_t channelWidth = GetVhtOperationalChannelWidth ();
605  if (channelWidth == 160)
606  {
607  operation.SetChannelWidth (2);
608  }
609  else if (channelWidth == 80)
610  {
611  operation.SetChannelWidth (1);
612  }
613  else
614  {
615  operation.SetChannelWidth (0);
616  }
617  uint8_t maxSpatialStream = m_phy->GetMaxSupportedRxSpatialStreams ();
618  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
619  {
620  if (m_stationManager->GetVhtSupported (i->second))
621  {
622  if (m_stationManager->GetNumberOfSupportedStreams (i->second) < maxSpatialStream)
623  {
624  maxSpatialStream = m_stationManager->GetNumberOfSupportedStreams (i->second);
625  }
626  }
627  }
628  for (uint8_t nss = 1; nss <= maxSpatialStream; nss++)
629  {
630  uint8_t maxMcs = 9; //TBD: hardcode to 9 for now since we assume all MCS values are supported
631  operation.SetMaxVhtMcsPerNss (nss, maxMcs);
632  }
633  }
634  return operation;
635 }
636 
639 {
640  NS_LOG_FUNCTION (this);
641  HeOperation operation;
642  if (GetHeSupported ())
643  {
644  operation.SetHeSupported (1);
645  uint8_t maxSpatialStream = m_phy->GetMaxSupportedRxSpatialStreams ();
646  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
647  {
648  if (m_stationManager->GetHeSupported (i->second))
649  {
650  if (m_stationManager->GetNumberOfSupportedStreams (i->second) < maxSpatialStream)
651  {
652  maxSpatialStream = m_stationManager->GetNumberOfSupportedStreams (i->second);
653  }
654  }
655  }
656  for (uint8_t nss = 1; nss <= maxSpatialStream; nss++)
657  {
658  operation.SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported
659  }
660  UintegerValue bssColor;
661  GetHeConfiguration ()->GetAttribute ("BssColor", bssColor);
662  operation.SetBssColor (bssColor.Get ());
663  }
664  return operation;
665 }
666 
667 void
669 {
670  NS_LOG_FUNCTION (this << to);
671  WifiMacHeader hdr;
673  hdr.SetAddr1 (to);
674  hdr.SetAddr2 (GetAddress ());
675  hdr.SetAddr3 (GetAddress ());
676  hdr.SetDsNotFrom ();
677  hdr.SetDsNotTo ();
678  Ptr<Packet> packet = Create<Packet> ();
680  probe.SetSsid (GetSsid ());
681  probe.SetSupportedRates (GetSupportedRates ());
682  probe.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
683  probe.SetCapabilities (GetCapabilities ());
686  if (GetDsssSupported ())
687  {
688  probe.SetDsssParameterSet (GetDsssParameterSet ());
689  }
690  if (GetErpSupported ())
691  {
692  probe.SetErpInformation (GetErpInformation ());
693  }
694  if (GetQosSupported ())
695  {
696  probe.SetEdcaParameterSet (GetEdcaParameterSet ());
697  }
698  if (GetHtSupported ())
699  {
700  probe.SetExtendedCapabilities (GetExtendedCapabilities ());
701  probe.SetHtCapabilities (GetHtCapabilities ());
702  probe.SetHtOperation (GetHtOperation ());
703  }
704  if (GetVhtSupported ())
705  {
706  probe.SetVhtCapabilities (GetVhtCapabilities ());
707  probe.SetVhtOperation (GetVhtOperation ());
708  }
709  if (GetHeSupported ())
710  {
711  probe.SetHeCapabilities (GetHeCapabilities ());
712  probe.SetHeOperation (GetHeOperation ());
713  }
714  packet->AddHeader (probe);
715 
716  //The standard is not clear on the correct queue for management
717  //frames if we are a QoS AP. The approach taken here is to always
718  //use the DCF for these regardless of whether we have a QoS
719  //association or not.
720  m_txop->Queue (packet, hdr);
721 }
722 
723 void
724 ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc)
725 {
726  NS_LOG_FUNCTION (this << to << success << isReassoc);
727  WifiMacHeader hdr;
729  hdr.SetAddr1 (to);
730  hdr.SetAddr2 (GetAddress ());
731  hdr.SetAddr3 (GetAddress ());
732  hdr.SetDsNotFrom ();
733  hdr.SetDsNotTo ();
734  Ptr<Packet> packet = Create<Packet> ();
736  StatusCode code;
737  if (success)
738  {
739  code.SetSuccess ();
740  uint16_t aid = 0;
741  bool found = false;
742  if (isReassoc)
743  {
744  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); ++i)
745  {
746  if (i->second == to)
747  {
748  aid = i->first;
749  found = true;
750  break;
751  }
752  }
753  }
754  if (!found)
755  {
756  aid = GetNextAssociationId ();
757  m_staList.insert (std::make_pair (aid, to));
758  }
759  assoc.SetAssociationId (aid);
760  }
761  else
762  {
763  code.SetFailure ();
764  }
765  assoc.SetSupportedRates (GetSupportedRates ());
766  assoc.SetStatusCode (code);
767  assoc.SetCapabilities (GetCapabilities ());
768  if (GetErpSupported ())
769  {
770  assoc.SetErpInformation (GetErpInformation ());
771  }
772  if (GetQosSupported ())
773  {
774  assoc.SetEdcaParameterSet (GetEdcaParameterSet ());
775  }
776  if (GetHtSupported ())
777  {
778  assoc.SetExtendedCapabilities (GetExtendedCapabilities ());
779  assoc.SetHtCapabilities (GetHtCapabilities ());
780  assoc.SetHtOperation (GetHtOperation ());
781  }
782  if (GetVhtSupported ())
783  {
784  assoc.SetVhtCapabilities (GetVhtCapabilities ());
785  assoc.SetVhtOperation (GetVhtOperation ());
786  }
787  if (GetHeSupported ())
788  {
789  assoc.SetHeCapabilities (GetHeCapabilities ());
790  assoc.SetHeOperation (GetHeOperation ());
791  }
792  packet->AddHeader (assoc);
793 
794  //The standard is not clear on the correct queue for management
795  //frames if we are a QoS AP. The approach taken here is to always
796  //use the DCF for these regardless of whether we have a QoS
797  //association or not.
798  m_txop->Queue (packet, hdr);
799 }
800 
801 void
803 {
804  NS_LOG_FUNCTION (this);
805  WifiMacHeader hdr;
808  hdr.SetAddr2 (GetAddress ());
809  hdr.SetAddr3 (GetAddress ());
810  hdr.SetDsNotFrom ();
811  hdr.SetDsNotTo ();
812  Ptr<Packet> packet = Create<Packet> ();
813  MgtBeaconHeader beacon;
814  beacon.SetSsid (GetSsid ());
815  beacon.SetSupportedRates (GetSupportedRates ());
816  beacon.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
817  beacon.SetCapabilities (GetCapabilities ());
820  if (GetDsssSupported ())
821  {
822  beacon.SetDsssParameterSet (GetDsssParameterSet ());
823  }
824  if (GetErpSupported ())
825  {
826  beacon.SetErpInformation (GetErpInformation ());
827  }
828  if (GetQosSupported ())
829  {
830  beacon.SetEdcaParameterSet (GetEdcaParameterSet ());
831  }
832  if (GetHtSupported ())
833  {
834  beacon.SetExtendedCapabilities (GetExtendedCapabilities ());
835  beacon.SetHtCapabilities (GetHtCapabilities ());
836  beacon.SetHtOperation (GetHtOperation ());
837  }
838  if (GetVhtSupported ())
839  {
840  beacon.SetVhtCapabilities (GetVhtCapabilities ());
841  beacon.SetVhtOperation (GetVhtOperation ());
842  }
843  if (GetHeSupported ())
844  {
845  beacon.SetHeCapabilities (GetHeCapabilities ());
846  beacon.SetHeOperation (GetHeOperation ());
847  }
848  packet->AddHeader (beacon);
849 
850  //The beacon has it's own special queue, so we load it in there
851  m_beaconTxop->Queue (packet, hdr);
853 
854  //If a STA that does not support Short Slot Time associates,
855  //the AP shall use long slot time beginning at the first Beacon
856  //subsequent to the association of the long slot time STA.
857  if (GetErpSupported ())
858  {
859  if (GetShortSlotTimeEnabled () == true)
860  {
861  //Enable short slot time
862  m_phy->SetSlot (MicroSeconds (9));
863  }
864  else
865  {
866  //Disable short slot time
867  m_phy->SetSlot (MicroSeconds (20));
868  }
869  }
870 }
871 
872 void
874 {
875  NS_LOG_FUNCTION (this);
876  RegularWifiMac::TxOk (hdr);
877  if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
879  {
880  NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
882  }
883 }
884 
885 void
887 {
888  NS_LOG_FUNCTION (this);
890 
891  if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
893  {
894  NS_LOG_DEBUG ("association failed with sta=" << hdr.GetAddr1 ());
896  }
897 }
898 
899 void
901 {
902  NS_LOG_FUNCTION (this << *mpdu);
903  const WifiMacHeader* hdr = &mpdu->GetHeader ();
904  Ptr<const Packet> packet = mpdu->GetPacket ();
905  Mac48Address from = hdr->GetAddr2 ();
906  if (hdr->IsData ())
907  {
908  Mac48Address bssid = hdr->GetAddr1 ();
909  if (!hdr->IsFromDs ()
910  && hdr->IsToDs ()
911  && bssid == GetAddress ()
912  && m_stationManager->IsAssociated (from))
913  {
914  Mac48Address to = hdr->GetAddr3 ();
915  if (to == GetAddress ())
916  {
917  NS_LOG_DEBUG ("frame for me from=" << from);
918  if (hdr->IsQosData ())
919  {
920  if (hdr->IsQosAmsdu ())
921  {
922  NS_LOG_DEBUG ("Received A-MSDU from=" << from << ", size=" << packet->GetSize ());
924  packet = 0;
925  }
926  else
927  {
928  ForwardUp (packet, from, bssid);
929  }
930  }
931  else if (hdr->HasData ())
932  {
933  ForwardUp (packet, from, bssid);
934  }
935  }
936  else if (to.IsGroup ()
938  {
939  NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to);
940  Ptr<Packet> copy = packet->Copy ();
941 
942  //If the frame we are forwarding is of type QoS Data,
943  //then we need to preserve the UP in the QoS control
944  //header...
945  if (hdr->IsQosData ())
946  {
947  ForwardDown (copy, from, to, hdr->GetQosTid ());
948  }
949  else
950  {
951  ForwardDown (copy, from, to);
952  }
953  ForwardUp (packet, from, to);
954  }
955  else
956  {
957  ForwardUp (packet, from, to);
958  }
959  }
960  else if (hdr->IsFromDs ()
961  && hdr->IsToDs ())
962  {
963  //this is an AP-to-AP frame
964  //we ignore for now.
965  NotifyRxDrop (packet);
966  }
967  else
968  {
969  //we can ignore these frames since
970  //they are not targeted at the AP
971  NotifyRxDrop (packet);
972  }
973  return;
974  }
975  else if (hdr->IsMgt ())
976  {
977  if (hdr->IsProbeReq ())
978  {
979  NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ());
980  MgtProbeRequestHeader probeRequestHeader;
981  packet->PeekHeader (probeRequestHeader);
982  Ssid ssid = probeRequestHeader.GetSsid ();
983  if (ssid == GetSsid () || ssid.IsBroadcast ())
984  {
985  NS_LOG_DEBUG ("Probe request received from " << from << ": send probe response");
986  SendProbeResp (from);
987  }
988  return;
989  }
990  else if (hdr->GetAddr1 () == GetAddress ())
991  {
992  if (hdr->IsAssocReq ())
993  {
994  NS_LOG_DEBUG ("Association request received from " << from);
995  //first, verify that the the station's supported
996  //rate set is compatible with our Basic Rate set
997  MgtAssocRequestHeader assocReq;
998  packet->PeekHeader (assocReq);
999  CapabilityInformation capabilities = assocReq.GetCapabilities ();
1000  m_stationManager->AddSupportedPhyPreamble (from, capabilities.IsShortPreamble ());
1001  SupportedRates rates = assocReq.GetSupportedRates ();
1002  bool problem = false;
1003  bool isHtStation = false;
1004  bool isOfdmStation = false;
1005  bool isErpStation = false;
1006  bool isDsssStation = false;
1007  for (uint8_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
1008  {
1010  if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1011  {
1013  {
1014  isDsssStation = false;
1015  }
1016  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1017  {
1018  isErpStation = false;
1019  }
1020  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1021  {
1022  isOfdmStation = false;
1023  }
1024  if (isDsssStation == false && isErpStation == false && isOfdmStation == false)
1025  {
1026  problem = true;
1027  break;
1028  }
1029  }
1030  else
1031  {
1033  {
1034  isDsssStation = true;
1035  }
1036  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1037  {
1038  isErpStation = true;
1039  }
1040  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1041  {
1042  isOfdmStation = true;
1043  }
1044  }
1045  }
1046  m_stationManager->AddSupportedErpSlotTime (from, capabilities.IsShortSlotTime () && isErpStation);
1047  if (GetHtSupported ())
1048  {
1049  //check whether the HT STA supports all MCSs in Basic MCS Set
1050  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
1051  if (htcapabilities.IsSupportedMcs (0))
1052  {
1053  isHtStation = true;
1054  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1055  {
1057  if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1058  {
1059  problem = true;
1060  break;
1061  }
1062  }
1063  }
1064  }
1065  if (GetVhtSupported ())
1066  {
1067  //check whether the VHT STA supports all MCSs in Basic MCS Set
1068  VhtCapabilities vhtcapabilities = assocReq.GetVhtCapabilities ();
1069  if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
1070  {
1071  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1072  {
1074  if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1075  {
1076  problem = true;
1077  break;
1078  }
1079  }
1080  }
1081  }
1082  if (GetHeSupported ())
1083  {
1084  //check whether the HE STA supports all MCSs in Basic MCS Set
1085  HeCapabilities hecapabilities = assocReq.GetHeCapabilities ();
1086  if (hecapabilities.GetSupportedMcsAndNss () != 0)
1087  {
1088  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1089  {
1091  if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1092  {
1093  problem = true;
1094  break;
1095  }
1096  }
1097  }
1098  }
1099  if (problem)
1100  {
1101  NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send association response with an error status");
1102  SendAssocResp (hdr->GetAddr2 (), false, false);
1103  }
1104  else
1105  {
1106  NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1107  //record all its supported modes in its associated WifiRemoteStation
1108  for (const auto & mode : m_phy->GetModeList ())
1109  {
1110  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1111  {
1112  m_stationManager->AddSupportedMode (from, mode);
1113  }
1114  }
1115  if (GetHtSupported ())
1116  {
1117  HtCapabilities htCapabilities = assocReq.GetHtCapabilities ();
1118  if (htCapabilities.IsSupportedMcs (0))
1119  {
1120  m_stationManager->AddStationHtCapabilities (from, htCapabilities);
1121  }
1122  }
1123  if (GetVhtSupported ())
1124  {
1125  VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilities ();
1126  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1127  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1128  {
1129  m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities);
1130  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_VHT))
1131  {
1132  if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1133  {
1134  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1135  //here should add a control to add basic MCS when it is implemented
1136  }
1137  }
1138  }
1139  }
1140  if (GetHtSupported ())
1141  {
1142  ExtendedCapabilities extendedCapabilities = assocReq.GetExtendedCapabilities ();
1143  //TODO: to be completed
1144  }
1145  if (GetHeSupported ())
1146  {
1147  HeCapabilities heCapabilities = assocReq.GetHeCapabilities ();
1148  if (heCapabilities.GetSupportedMcsAndNss () != 0)
1149  {
1150  m_stationManager->AddStationHeCapabilities (from, heCapabilities);
1151  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HE))
1152  {
1153  if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1154  {
1155  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1156  //here should add a control to add basic MCS when it is implemented
1157  }
1158  }
1159  }
1160  }
1162  if (!isHtStation)
1163  {
1164  m_nonHtStations.push_back (hdr->GetAddr2 ());
1165  m_nonHtStations.unique ();
1166  }
1167  if (!isErpStation && isDsssStation)
1168  {
1169  m_nonErpStations.push_back (hdr->GetAddr2 ());
1170  m_nonErpStations.unique ();
1171  }
1172  NS_LOG_DEBUG ("Send association response with success status");
1173  SendAssocResp (hdr->GetAddr2 (), true, false);
1174  }
1175  return;
1176  }
1177  else if (hdr->IsReassocReq ())
1178  {
1179  NS_LOG_DEBUG ("Reassociation request received from " << from);
1180  //first, verify that the the station's supported
1181  //rate set is compatible with our Basic Rate set
1182  MgtReassocRequestHeader reassocReq;
1183  packet->PeekHeader (reassocReq);
1184  CapabilityInformation capabilities = reassocReq.GetCapabilities ();
1185  m_stationManager->AddSupportedPhyPreamble (from, capabilities.IsShortPreamble ());
1186  SupportedRates rates = reassocReq.GetSupportedRates ();
1187  bool problem = false;
1188  bool isHtStation = false;
1189  bool isOfdmStation = false;
1190  bool isErpStation = false;
1191  bool isDsssStation = false;
1192  for (uint8_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
1193  {
1195  if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1196  {
1198  {
1199  isDsssStation = false;
1200  }
1201  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1202  {
1203  isErpStation = false;
1204  }
1205  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1206  {
1207  isOfdmStation = false;
1208  }
1209  if (isDsssStation == false && isErpStation == false && isOfdmStation == false)
1210  {
1211  problem = true;
1212  break;
1213  }
1214  }
1215  else
1216  {
1218  {
1219  isDsssStation = true;
1220  }
1221  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1222  {
1223  isErpStation = true;
1224  }
1225  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1226  {
1227  isOfdmStation = true;
1228  }
1229  }
1230  }
1231  m_stationManager->AddSupportedErpSlotTime (from, capabilities.IsShortSlotTime () && isErpStation);
1232  if (GetHtSupported ())
1233  {
1234  //check whether the HT STA supports all MCSs in Basic MCS Set
1235  HtCapabilities htcapabilities = reassocReq.GetHtCapabilities ();
1236  if (htcapabilities.IsSupportedMcs (0))
1237  {
1238  isHtStation = true;
1239  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1240  {
1242  if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1243  {
1244  problem = true;
1245  break;
1246  }
1247  }
1248  }
1249  }
1250  if (GetVhtSupported ())
1251  {
1252  //check whether the VHT STA supports all MCSs in Basic MCS Set
1253  VhtCapabilities vhtcapabilities = reassocReq.GetVhtCapabilities ();
1254  if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
1255  {
1256  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1257  {
1259  if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1260  {
1261  problem = true;
1262  break;
1263  }
1264  }
1265  }
1266  }
1267  if (GetHeSupported ())
1268  {
1269  //check whether the HE STA supports all MCSs in Basic MCS Set
1270  HeCapabilities hecapabilities = reassocReq.GetHeCapabilities ();
1271  if (hecapabilities.GetSupportedMcsAndNss () != 0)
1272  {
1273  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1274  {
1276  if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1277  {
1278  problem = true;
1279  break;
1280  }
1281  }
1282  }
1283  }
1284  if (problem)
1285  {
1286  NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send reassociation response with an error status");
1287  SendAssocResp (hdr->GetAddr2 (), false, true);
1288  }
1289  else
1290  {
1291  NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1292  //update all its supported modes in its associated WifiRemoteStation
1293  for (const auto & mode : m_phy->GetModeList ())
1294  {
1295  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1296  {
1297  m_stationManager->AddSupportedMode (from, mode);
1298  }
1299  }
1300  if (GetHtSupported ())
1301  {
1302  HtCapabilities htCapabilities = reassocReq.GetHtCapabilities ();
1303  if (htCapabilities.IsSupportedMcs (0))
1304  {
1305  m_stationManager->AddStationHtCapabilities (from, htCapabilities);
1306  }
1307  }
1308  if (GetVhtSupported ())
1309  {
1310  VhtCapabilities vhtCapabilities = reassocReq.GetVhtCapabilities ();
1311  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1312  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1313  {
1314  m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities);
1315  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_VHT))
1316  {
1317  if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1318  {
1319  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1320  //here should add a control to add basic MCS when it is implemented
1321  }
1322  }
1323  }
1324  }
1325  if (GetHtSupported ())
1326  {
1327  ExtendedCapabilities extendedCapabilities = reassocReq.GetExtendedCapabilities ();
1328  //TODO: to be completed
1329  }
1330  if (GetHeSupported ())
1331  {
1332  HeCapabilities heCapabilities = reassocReq.GetHeCapabilities ();
1333  if (heCapabilities.GetSupportedMcsAndNss () != 0)
1334  {
1335  m_stationManager->AddStationHeCapabilities (from, heCapabilities);
1336  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HE))
1337  {
1338  if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1339  {
1340  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1341  //here should add a control to add basic MCS when it is implemented
1342  }
1343  }
1344  }
1345  }
1347  if (!isHtStation)
1348  {
1349  m_nonHtStations.push_back (hdr->GetAddr2 ());
1350  m_nonHtStations.unique ();
1351  }
1352  if (!isErpStation && isDsssStation)
1353  {
1354  m_nonErpStations.push_back (hdr->GetAddr2 ());
1355  m_nonErpStations.unique ();
1356  }
1357  NS_LOG_DEBUG ("Send reassociation response with success status");
1358  SendAssocResp (hdr->GetAddr2 (), true, true);
1359  }
1360  return;
1361  }
1362  else if (hdr->IsDisassociation ())
1363  {
1364  NS_LOG_DEBUG ("Disassociation received from " << from);
1366  for (std::map<uint16_t, Mac48Address>::const_iterator j = m_staList.begin (); j != m_staList.end (); j++)
1367  {
1368  if (j->second == from)
1369  {
1370  m_staList.erase (j);
1371  break;
1372  }
1373  }
1374  for (std::list<Mac48Address>::const_iterator j = m_nonErpStations.begin (); j != m_nonErpStations.end (); j++)
1375  {
1376  if ((*j) == from)
1377  {
1378  m_nonErpStations.erase (j);
1379  break;
1380  }
1381  }
1382  for (std::list<Mac48Address>::const_iterator j = m_nonHtStations.begin (); j != m_nonHtStations.end (); j++)
1383  {
1384  if ((*j) == from)
1385  {
1386  m_nonHtStations.erase (j);
1387  break;
1388  }
1389  }
1390  for (std::list<Mac48Address>::const_iterator j = m_cfPollingList.begin (); j != m_cfPollingList.end (); ++j)
1391  {
1392  if ((*j) == from)
1393  {
1394  m_cfPollingList.erase (j);
1395  break;
1396  }
1397  }
1398  return;
1399  }
1400  }
1401  }
1402 
1403  //Invoke the receive handler of our parent class to deal with any
1404  //other frames. Specifically, this will handle Block Ack-related
1405  //Management Action frames.
1406  RegularWifiMac::Receive (Create<WifiMacQueueItem> (packet, *hdr));
1407 }
1408 
1409 void
1411 {
1412  NS_LOG_FUNCTION (this << *mpdu);
1413  for (auto& i : *PeekPointer (mpdu))
1414  {
1415  if (i.second.GetDestinationAddr () == GetAddress ())
1416  {
1417  ForwardUp (i.first, i.second.GetSourceAddr (),
1418  i.second.GetDestinationAddr ());
1419  }
1420  else
1421  {
1422  Mac48Address from = i.second.GetSourceAddr ();
1423  Mac48Address to = i.second.GetDestinationAddr ();
1424  NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
1425  ForwardDown (i.first->Copy (), from, to, mpdu->GetHeader ().GetQosTid ());
1426  }
1427  }
1428 }
1429 
1430 void
1432 {
1433  NS_LOG_FUNCTION (this);
1435  m_beaconEvent.Cancel ();
1437  {
1439  {
1440  Time jitter = MicroSeconds (static_cast<int64_t> (m_beaconJitter->GetValue (0, 1) * (GetBeaconInterval ().GetMicroSeconds ())));
1441  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time " << jitter);
1443  }
1444  else
1445  {
1446  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time 0");
1448  }
1449  }
1451 }
1452 
1453 bool
1455 {
1456  bool useProtection = !m_nonErpStations.empty () && m_enableNonErpProtection;
1457  m_stationManager->SetUseNonErpProtection (useProtection);
1458  return useProtection;
1459 }
1460 
1461 uint16_t
1463 {
1464  //Return the first free AID value between 1 and 2007
1465  for (uint16_t nextAid = 1; nextAid <= 2007; nextAid++)
1466  {
1467  if (m_staList.find (nextAid) == m_staList.end ())
1468  {
1469  return nextAid;
1470  }
1471  }
1472  NS_FATAL_ERROR ("No free association ID available!");
1473  return 0;
1474 }
1475 
1476 uint8_t
1478 {
1479  auto it = m_bufferStatus.find (WifiAddressTidPair (address, tid));
1480  if (it == m_bufferStatus.end ()
1481  || it->second.timestamp + m_bsrLifetime < Simulator::Now ())
1482  {
1483  return 255;
1484  }
1485  return it->second.value;
1486 }
1487 
1488 void
1490 {
1491  if (size == 255)
1492  {
1493  // no point in storing an unspecified size
1494  m_bufferStatus.erase (WifiAddressTidPair (address, tid));
1495  }
1496  else
1497  {
1499  }
1500 }
1501 
1502 uint8_t
1504 {
1505  uint8_t maxSize = 0;
1506  bool found = false;
1507 
1508  for (uint8_t tid = 0; tid < 8; tid++)
1509  {
1510  uint8_t size = GetBufferStatus (tid, address);
1511  if (size != 255)
1512  {
1513  maxSize = std::max (maxSize, size);
1514  found = true;
1515  }
1516  }
1517 
1518  if (found)
1519  {
1520  return maxSize;
1521  }
1522  return 255;
1523 }
1524 
1525 } //namespace ns3
uint8_t GetNMcsSupported(Mac48Address address) const
Return the number of MCS supported by the station.
void DoInitialize(void)
Initialize() implementation.
void Dispose(void)
Dispose of this Object.
Definition: object.cc:214
void SetPcoActive(uint8_t pcoActive)
Set the PCO active.
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:801
std::pair< Mac48Address, uint8_t > WifiAddressTidPair
(MAC address, TID) pair
Definition: qos-utils.h:31
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:557
bool IsDisassociation(void) const
Return true if the header is a Disassociation header.
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:296
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:183
Ptr< HeConfiguration > GetHeConfiguration(void) const
Definition: wifi-mac.cc:195
void SetErpSupported(uint8_t erpSupported)
Set the ERP supported field.
bool IsBroadcast(void) const
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
bool GetVhtSupported(void) const
Return whether the device has VHT capability support enabled.
void SetStbcBeacon(uint8_t stbcBeacon)
Set the STBC beacon.
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:753
std::list< Mac48Address >::iterator m_itCfPollingList
Iterator to the list of all PCF stations currently associated to the AP.
Definition: ap-wifi-mac.h:300
Implement the header for management frames of type association request.
Definition: mgt-headers.h:49
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetQosSupported(uint8_t qosSupported)
Set QOS supported function.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
AttributeValue implementation for Boolean.
Definition: boolean.h:36
void SetViCWmin(uint32_t cwMin)
Set the AC_VI CWmin field in the EdcaParameterSet information element.
bool GetHeSupported() const
Return whether the device supports HE.
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet down to DCF/EDCAF (enqueue the packet).
Definition: ap-wifi-mac.cc:261
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates...
Definition: ap-wifi-mac.cc:368
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 ...
Ptr< Txop > m_txop
This holds a pointer to the TXOP instance for this WifiMac - used for transmission of frames to non-Q...
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set of the current AP.
Definition: ap-wifi-mac.cc:461
uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: txop.cc:288
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
bool GetShortPreambleSupported(Mac48Address address) const
Return whether the station supports short PHY preamble or not.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
HeOperation GetHeOperation(void) const
Return the HE operation of the current AP.
Definition: ap-wifi-mac.cc:638
Hold variables of type string.
Definition: string.h:41
#define min(a, b)
Definition: 80211b.c:42
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:198
void RecordWaitAssocTxOk(Mac48Address address)
Records that we are waiting for an ACK for the association response we sent.
bool GetQosSupported() const
Return whether the device supports QoS.
bool IsSupportedRate(uint64_t bs) const
Check if the given rate is supported.
uint16_t GetSupportedMcsAndNss() const
Return the MCS and NSS field in the HE Capabilities information element.
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
void SetVoAci(uint8_t aci)
Set the AC_VO ACI field in the EdcaParameterSet information element.
EdcaQueues m_edca
This is a map from Access Category index to the corresponding channel access function.
void SetPhase(uint8_t pcoPhase)
Set the PCO phase.
void SetBasicRate(uint64_t bs)
Set the given rate to basic rates.
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtCapabilities)
Records VHT capabilities of the remote station.
void SetLSigTxopProtectionFullSupport(uint8_t lSigTxopProtectionFullSupport)
Set the LSIG TXOP protection full support.
std::list< WifiMode > GetModeList(void) const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition: wifi-phy.cc:2212
void SetChannelAccessManager(const Ptr< ChannelAccessManager > manager)
Set ChannelAccessManager this Txop is associated to.
Definition: txop.cc:118
void SetRxHighestSupportedDataRate(uint16_t maxSupportedRate)
Set the receive highest supported data rate.
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities of the device.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
bool IsSupportedTxMcs(uint8_t mcs) const
Returns true if transmit MCS is supported.
The Extended Capabilities Information ElementThis class knows how to serialise and deserialise the Ex...
The VHT Operation Information ElementThis class knows how to serialise and deserialise the VHT Operat...
Definition: vht-operation.h:35
bool GetHeSupported(void) const
Return whether the device has HE capability support enabled.
#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
void SetQosInfo(uint8_t qosInfo)
Set the QoS Info field in the EdcaParameterSet information element.
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:411
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
void SetNonGfHtStasPresent(uint8_t nonGfHtStasPresent)
Set the non GF HT STAs present.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1297
void SetSlot(Time slot)
Set the slot duration for this PHY.
Definition: wifi-phy.cc:1007
The HT Capabilities Information ElementThis class knows how to serialise and deserialise the HT Capab...
void SetVoAifsn(uint8_t aifsn)
Set the AC_VO AIFSN field in the EdcaParameterSet information element.
bool GetPcfSupported() const
Return whether the device supports PCF.
void AddSupportedPhyPreamble(Mac48Address address, bool isShortPreambleSupported)
Record whether the short PHY preamble is supported by the station.
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:789
WifiMode GetBasicMcs(uint8_t i) const
Return the MCS at the given list index.
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:118
The HT Operation Information ElementThis class knows how to serialise and deserialise the HT Operatio...
Definition: ht-operation.h:50
void Enqueue(Ptr< Packet > packet, Mac48Address to)
Definition: ap-wifi-mac.cc:351
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
void SetTxMaxNSpatialStreams(uint8_t maxTxSpatialStreams)
Set the transmit maximum number spatial streams.
Time GetBeaconInterval(void) const
Definition: ap-wifi-mac.cc:155
void SetPcfSupported(bool enable)
Enable or disable PCF capability support.
void SetHeSupported(uint8_t heSupported)
Set the HE supported information element.
Definition: he-operation.cc:53
Ptr< WifiPhy > m_phy
Wifi PHY.
uint16_t GetVhtOperationalChannelWidth(void) const
Determine the VHT operational channel width (in MHz).
Definition: ap-wifi-mac.cc:244
Ptr< ChannelAccessManager > m_channelAccessManager
channel access manager
uint16_t GetNextAssociationId(void)
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:2261
uint8_t GetNBasicMcs(void) const
Return the number of basic MCS index.
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:741
void SetVoCWmin(uint32_t cwMin)
Set the AC_VO CWmin field in the EdcaParameterSet information element.
Video.
Definition: qos-utils.h:64
uint32_t GetMinCw(void) const
Return the minimum contention window size.
Definition: txop.cc:276
The Supported Rates Information ElementThis class knows how to serialise and deserialise the Supporte...
void SetBarkerPreambleMode(uint8_t barkerPreambleMode)
Set the Barker_Preamble_Mode field in the ErpInformation information element.
Voice.
Definition: qos-utils.h:66
Best Effort.
Definition: qos-utils.h:60
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:68
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
void SetTxMcsSetDefined(uint8_t txMcsSetDefined)
Set the transmit MCS set defined.
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...
bool GetShortSlotTimeSupported(void) const
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:566
Capability information.
void DeaggregateAmsduAndForward(Ptr< WifiMacQueueItem > mpdu)
This method is called to de-aggregate an A-MSDU and forward the constituent packets up the stack...
void AddSupportedRate(uint64_t bs)
Add the given rate to the supported rates.
void SetDualCtsProtection(uint8_t dualCtsProtection)
Set the dual CTS protection.
bool GetDsssSupported() const
Return whether the device supports DSSS.
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a QoS tag is attached to the packet, returns a value < 8.
Definition: qos-utils.cc:79
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
The Wifi MAC high model for a STA or AP in a BSS.
bool m_enableBeaconGeneration
Flag whether beacons are being generated.
Definition: ap-wifi-mac.h:290
void SendAssocResp(Mac48Address to, bool success, bool isReassoc)
Forward an association or a reassociation response packet to the DCF.
Definition: ap-wifi-mac.cc:724
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
Definition: ap-wifi-mac.cc:162
HR/DSSS (Clause 16)
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1395
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
void SetBssid(Mac48Address bssid)
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 SetViAifsn(uint8_t aifsn)
Set the AC_VI AIFSN field in the EdcaParameterSet information element.
uint8_t GetNumberOfSupportedStreams(Mac48Address address) const
Return the number of spatial streams supported by the station.
Background.
Definition: qos-utils.h:62
void SetHtProtection(uint8_t htProtection)
Set the HT protection.
void SetSuccess(void)
Set success bit to 0 (success).
Definition: status-code.cc:30
Ptr< HtConfiguration > GetHtConfiguration(void) const
Definition: wifi-mac.cc:181
const WifiMacHeader & GetHeader(void) const
Get the header stored in this item.
bool GetErpSupported() const
Return whether the device supports ERP.
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
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:590
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
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...
#define max(a, b)
Definition: 80211b.c:43
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:588
void SetEss(void)
Set the Extended Service Set (ESS) bit in the capability information field.
AttributeValue implementation for Time.
Definition: nstime.h:1353
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
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...
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
bool GetVhtSupported() const
Return whether the device supports VHT.
void SetVoCWmax(uint32_t cwMax)
Set the AC_VO CWmax field in the EdcaParameterSet information element.
bool GetShortSlotTimeSupported(Mac48Address address) const
Return whether the station supports short ERP slot time or not.
The IEEE 802.11ac VHT Capabilities.
static TypeId GetTypeId(void)
Get the type ID.
Definition: ap-wifi-mac.cc:48
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
Records HT capabilities of the remote station.
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current AP.
Definition: ap-wifi-mac.cc:424
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:100
Hold an unsigned integer type.
Definition: uinteger.h:44
Time m_bsrLifetime
Lifetime of Buffer Status Reports.
Definition: ap-wifi-mac.h:302
void SetBeCWmin(uint32_t cwMin)
Set the AC_BE CWmin field in the EdcaParameterSet information element.
VhtOperation GetVhtOperation(void) const
Return the VHT operation of the current AP.
Definition: ap-wifi-mac.cc:597
ssid
Definition: third.py:100
void SetViAci(uint8_t aci)
Set the AC_VI ACI field in the EdcaParameterSet information element.
void RecordGotAssocTxFailed(Mac48Address address)
Records that we missed an ACK for the association response we sent.
bool IsFromDs(void) const
bool GetShortSlotTimeEnabled(void) const
Determine whether short slot time should be enabled or not in the BSS.
Definition: ap-wifi-mac.cc:206
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:614
bool GetHtSupported(void) const
Return whether the device has HT capability support enabled.
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:301
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Definition: qos-utils.cc:53
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
void SetAddress(Mac48Address address)
void SetHtSupported(uint8_t htSupported)
Set the HT Supported.
Definition: ht-operation.cc:67
bool GetShortPreambleEnabled(void) const
Determine whether short preamble should be enabled or not in the BSS.
Definition: ap-wifi-mac.cc:227
void SetVhtSupported(uint8_t vhtSupported)
Set the VHT supported information element.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
static Mac48Address GetBroadcast(void)
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
EventId m_beaconEvent
Event to generate one beacon.
Definition: ap-wifi-mac.h:292
void SetViTxopLimit(uint16_t txop)
Set the AC_VI TXOP Limit field in the EdcaParameterSet information element.
Ptr< Txop > m_beaconTxop
Dedicated Txop for beacons.
Definition: ap-wifi-mac.h:289
std::list< uint8_t > GetBssMembershipSelectorList(void) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1464
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
void SetRxMcsBitmask(uint8_t index)
Set the receive MCS bitmask.
bool IsAssociated(Mac48Address address) const
Return whether the station associated.
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
void SetCurrentChannel(uint8_t currentChannel)
Set the Current Channel field in the DsssParameterSet information element.
std::list< Mac48Address > m_cfPollingList
List of all PCF stations currently associated to the AP.
Definition: ap-wifi-mac.h:299
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:147
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:110
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
void SetCfPollable(void)
Set the CF-Pollable bit in the capability information field.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
uint64_t Get(void) const
Definition: uinteger.cc:35
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:388
Ptr< const Packet > GetPacket(void) const
Get the packet stored in this item.
Status code for association response.
Definition: status-code.h:31
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:328
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:602
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
void SetLinkUpCallback(Callback< void > linkUp)
void SetLinkUpCallback(Callback< void > linkUp)
Definition: ap-wifi-mac.cc:171
void SetTxUnequalModulation(uint8_t txUnequalModulation)
Set the transmit unequal modulation.
virtual void DoDispose()
Destructor implementation.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsData(void) const
Return true if the Type is DATA.
address
Definition: first.py:44
void SetDsssSupported(uint8_t dsssSupported)
Set DSSS supported.
The EDCA Parameter SetThis class knows how to serialise and deserialise the EDCA Parameter Set...
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...
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
uint32_t GetMaxCw(void) const
Return the maximum contention window size.
Definition: txop.cc:282
void AddBssMembershipSelectorRate(uint64_t bs)
Add a special value to the supported rate set, corresponding to a BSS membership selector.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:554
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
void SetUseProtection(uint8_t useProtection)
Set the Use_Protection field in the ErpInformation information element.
bool GetShortPhyPreambleSupported(void) const
Return whether short PHY preamble is supported.
Definition: wifi-phy.cc:770
bool IsProbeReq(void) const
Return true if the header is a Probe Request header.
an EUI-48 address
Definition: mac48-address.h:43
void SetBkAifsn(uint8_t aifsn)
Set the AC_BK AIFSN field in the EdcaParameterSet information element.
bool IsSupportedTxMcs(uint8_t mcs) const
Is RX MCS supported.
bool IsShortPreamble(void) const
Check if the short preamble bit in the capability information field is set to 1.
Ssid GetSsid(void) const
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:1354
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1561
void SetBeAci(uint8_t aci)
Set the AC_BE ACI field in the EdcaParameterSet information element.
void SetRifsMode(uint8_t rifsMode)
Set the RIFS mode.
Definition: ht-operation.cc:99
bool IsGroup(void) const
bool GetShortGuardIntervalSupported(void) const
Return whether the device has SGI support enabled.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
void SetShortPreamble(bool shortPreamble)
Set the short preamble bit in the capability information field.
Wi-Fi AP state machineHandle association, dis-association and authentication, of STAs within an infra...
Definition: ap-wifi-mac.h:48
void SetBkAci(uint8_t aci)
Set the AC_BK ACI field in the EdcaParameterSet information element.
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:35
DsssParameterSet GetDsssParameterSet(void) const
Return the DSSS Parameter Set that we support.
Definition: ap-wifi-mac.cc:411
HtOperation GetHtOperation(void) const
Return the HT operation of the current AP.
Definition: ap-wifi-mac.cc:509
Implement the header for management frames of type probe request.
Definition: mgt-headers.h:514
ErpInformation GetErpInformation(void) const
Return the ERP information of the current AP.
Definition: ap-wifi-mac.cc:439
Mac48Address GetAddress(void) const
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:318
void SendProbeResp(Mac48Address to)
Forward a probe response packet to the DCF.
Definition: ap-wifi-mac.cc:668
uint8_t GetNBasicModes(void) const
Return the number of basic modes we support.
The DSSS Parameter SetThis class knows how to serialise and deserialise the DSSS Parameter Set...
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
EventId m_cfpEvent
Event to generate one PCF frame.
Definition: ap-wifi-mac.h:293
bool GetUseNonErpProtection(void) const
Return whether protection for non-ERP stations is used in the BSS.
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 SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
void TxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:886
bool IsMgt(void) const
Return true if the Type is Management.
void SetObssNonHtStasPresent(uint8_t obssNonHtStasPresent)
Set the OBSS non HT STAs present.
void SetBssColor(uint8_t bssColor)
Set the BSS color.
void SendOneBeacon(void)
Forward a beacon packet to the beacon special DCF.
Definition: ap-wifi-mac.cc:802
void SetTxRxMcsSetUnequal(uint8_t txRxMcsSetUnequal)
Set the transmit / receive MCS set unequal.
void SetBkCWmin(uint32_t cwMin)
Set the AC_BK CWmin field in the EdcaParameterSet information element.
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:177
uint32_t GetVhtCapabilitiesInfo() const
Return the VHT Capabilities Info field in the VHT Capabilities information element.
void AddSupportedErpSlotTime(Mac48Address address, bool isShortSlotTimeSupported)
Record whether the short ERP slot time is supported by the station.
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:189
bool GetHtSupported() const
Return whether the device supports HT.
void DoDispose(void)
Destructor implementation.
Definition: ap-wifi-mac.cc:118
void SetAddress(Mac48Address address)
Definition: ap-wifi-mac.cc:130
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:777
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Definition: txop.cc:125
void SetStaChannelWidth(uint8_t staChannelWidth)
Set the STA channel width.
Definition: ht-operation.cc:93
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
Ptr< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
Definition: ap-wifi-mac.h:294
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
Time m_beaconInterval
Beacon interval.
Definition: ap-wifi-mac.h:291
void SetVoTxopLimit(uint16_t txop)
Set the AC_VO TXOP Limit field in the EdcaParameterSet information element.
std::unordered_map< WifiAddressTidPair, bsrType, WifiAddressTidHash > m_bufferStatus
Definition: ap-wifi-mac.h:306
void SetDualBeacon(uint8_t dualBeacon)
Set the dual beacon.
std::list< Mac48Address > m_nonErpStations
List of all non-ERP stations currently associated to the AP.
Definition: ap-wifi-mac.h:297
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: ap-wifi-mac.cc:900
virtual void DoInitialize()
Initialize() implementation.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
virtual ~ApWifiMac()
Definition: ap-wifi-mac.cc:108
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 ...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:533
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this Txop is associated to.
Definition: txop.cc:132
void SetDsFrom(void)
Set the From DS bit in the Frame Control field.
void SetNoOrder(void)
Unset order bit in the frame control field.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data...
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1305
The ErpInformation Information ElementThis class knows how to serialise and deserialise the ErpInform...
bool m_enableBeaconJitter
Flag whether the first beacon should be generated at random time.
Definition: ap-wifi-mac.h:295
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:261
virtual void TxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
void TxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:873
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:578
bool IsWaitAssocTxOk(Mac48Address address) const
Return whether we are waiting for an ACK for the association response we sent.
void SetShortSlotTime(bool shortSlotTime)
Set the short slot time bit in the capability information field.
void SetShortPreambleEnabled(bool enable)
Enable or disable short PHY preambles.
void SetBeCWmax(uint32_t cwMax)
Set the AC_BE CWmax field in the EdcaParameterSet information element.
The HE Operation Information ElementThis class knows how to serialise and deserialise the HE Operatio...
Definition: he-operation.h:35
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:618
Ptr< WifiRemoteStationManager > m_stationManager
Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.)
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
void SetBeAifsn(uint8_t aifsn)
Set the AC_BE AIFSN field in the EdcaParameterSet information element.
void SetFailure(void)
Set success bit to 1 (failure).
Definition: status-code.cc:36
void SetTxOkCallback(TxOk callback)
Definition: txop.cc:139
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
std::list< Mac48Address > m_nonHtStations
List of all non-HT stations currently associated to the AP.
Definition: ap-wifi-mac.h:298
void SetNonErpPresent(uint8_t nonErpPresent)
Set the Non_Erp_Present field in the ErpInformation information element.
The IEEE 802.11ax HE Capabilities.
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:125
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:308
bool SupportsSendFrom(void) const
Definition: ap-wifi-mac.cc:361
void SetBeTxopLimit(uint16_t txop)
Set the AC_BE TXOP Limit field in the EdcaParameterSet information element.
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1440
a unique identifier for an interface.
Definition: type-id.h:58
void SetPrimaryChannel(uint8_t ctrl)
Set the Primary Channel field in the HT Operation information element.
Definition: ht-operation.cc:81
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:847
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:1642
void SetViCWmax(uint32_t cwMax)
Set the AC_VI CWmax field in the EdcaParameterSet information element.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Definition: object.cc:183
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
bool IsShortSlotTime(void) const
Check if the short slot time in the capability information field is set to 1.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:88
void RecordGotAssocTxOk(Mac48Address address)
Records that we got an ACK for the association response we sent.
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
Implements the IEEE 802.11 MAC header.
uint16_t GetChannelWidthSupported(Mac48Address address) const
Return the channel width supported by the station.
Implement the header for management frames of type reassociation request.
Definition: mgt-headers.h:180
bool IsToDs(void) const
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:765
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1458
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
bool HasData(void) const
Return true if the header type is DATA and is not DATA_NULL.
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
Definition: ap-wifi-mac.cc:140
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
void SetSecondaryChannelOffset(uint8_t secondaryChannelOffset)
Set the secondary channel offset.
Definition: ht-operation.cc:87
void SetChannelWidth(uint8_t channelWidth)
Set the Channel Width field in the VHT Operation information element.
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
virtual void TxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: txop.cc:294
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.