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> ();
100 
101  //Let the lower layers know that we are acting as an AP.
103 }
104 
106 {
107  NS_LOG_FUNCTION (this);
108  m_staList.clear ();
109  m_addressIdMap.clear ();
110  m_nonErpStations.clear ();
111  m_nonHtStations.clear ();
112 }
113 
114 void
116 {
117  NS_LOG_FUNCTION (this);
118  m_beaconTxop->Dispose ();
119  m_beaconTxop = 0;
120  m_enableBeaconGeneration = false;
123 }
124 
125 void
127 {
128  NS_LOG_FUNCTION (this << address);
129  //As an AP, our MAC address is also the BSSID. Hence we are
130  //overriding this function and setting both in our parent class.
133 }
134 
135 void
137 {
138  NS_LOG_FUNCTION (this << enable);
139  if (!enable)
140  {
142  }
143  else if (enable && !m_enableBeaconGeneration)
144  {
146  }
147  m_enableBeaconGeneration = enable;
148 }
149 
150 Time
152 {
153  NS_LOG_FUNCTION (this);
154  return m_beaconInterval;
155 }
156 
157 void
159 {
160  NS_LOG_FUNCTION (this << stationManager);
161  m_beaconTxop->SetWifiRemoteStationManager (stationManager);
163 }
164 
165 void
167 {
168  NS_LOG_FUNCTION (this << &linkUp);
170 
171  //The approach taken here is that, from the point of view of an AP,
172  //the link is always up, so we immediately invoke the callback if
173  //one is set
174  linkUp ();
175 }
176 
177 void
179 {
180  NS_LOG_FUNCTION (this << interval);
181  if ((interval.GetMicroSeconds () % 1024) != 0)
182  {
183  NS_FATAL_ERROR ("beacon interval should be multiple of 1024us (802.11 time unit), see IEEE Std. 802.11-2012");
184  }
185  if (interval.GetMicroSeconds () > (1024 * 65535))
186  {
187  NS_FATAL_ERROR ("beacon interval should be smaller then or equal to 65535 * 1024us (802.11 time unit)");
188  }
189  m_beaconInterval = interval;
190 }
191 
192 int64_t
193 ApWifiMac::AssignStreams (int64_t stream)
194 {
195  NS_LOG_FUNCTION (this << stream);
196  m_beaconJitter->SetStream (stream);
197  return 1;
198 }
199 
200 bool
202 {
203  if (m_nonErpStations.size () != 0)
204  {
205  return false;
206  }
208  {
209  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
210  {
212  {
213  return false;
214  }
215  }
216  return true;
217  }
218  return false;
219 }
220 
221 bool
223 {
225  {
226  for (std::list<Mac48Address>::const_iterator i = m_nonErpStations.begin (); i != m_nonErpStations.end (); i++)
227  {
229  {
230  return false;
231  }
232  }
233  return true;
234  }
235  return false;
236 }
237 
238 uint16_t
240 {
241  uint16_t channelWidth = m_phy->GetChannelWidth ();
242  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
243  {
244  if (m_stationManager->GetVhtSupported (i->second))
245  {
246  if (m_stationManager->GetChannelWidthSupported (i->second) < channelWidth)
247  {
248  channelWidth = m_stationManager->GetChannelWidthSupported (i->second);
249  }
250  }
251  }
252  return channelWidth;
253 }
254 
255 void
257  Mac48Address to)
258 {
259  NS_LOG_FUNCTION (this << packet << from << to);
260  //If we are not a QoS AP then we definitely want to use AC_BE to
261  //transmit the packet. A TID of zero will map to AC_BE (through \c
262  //QosUtilsMapTidToAc()), so we use that as our default here.
263  uint8_t tid = 0;
264 
265  //If we are a QoS AP then we attempt to get a TID for this packet
266  if (GetQosSupported ())
267  {
268  tid = QosUtilsGetTidForPacket (packet);
269  //Any value greater than 7 is invalid and likely indicates that
270  //the packet had no QoS tag, so we revert to zero, which'll
271  //mean that AC_BE is used.
272  if (tid > 7)
273  {
274  tid = 0;
275  }
276  }
277 
278  ForwardDown (packet, from, to, tid);
279 }
280 
281 void
283  Mac48Address to, uint8_t tid)
284 {
285  NS_LOG_FUNCTION (this << packet << from << to << +tid);
286  WifiMacHeader hdr;
287 
288  //For now, an AP that supports QoS does not support non-QoS
289  //associations, and vice versa. In future the AP model should
290  //support simultaneously associated QoS and non-QoS STAs, at which
291  //point there will need to be per-association QoS state maintained
292  //by the association state machine, and consulted here.
293  if (GetQosSupported ())
294  {
297  hdr.SetQosNoEosp ();
298  hdr.SetQosNoAmsdu ();
299  //Transmission of multiple frames in the same Polled TXOP is not supported for now
300  hdr.SetQosTxopLimit (0);
301  //Fill in the QoS control field in the MAC header
302  hdr.SetQosTid (tid);
303  }
304  else
305  {
306  hdr.SetType (WIFI_MAC_DATA);
307  }
308 
309  if (GetQosSupported ())
310  {
311  hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT control field is not yet implemented (set it to 1 when implemented)
312  }
313  hdr.SetAddr1 (to);
314  hdr.SetAddr2 (GetAddress ());
315  hdr.SetAddr3 (from);
316  hdr.SetDsFrom ();
317  hdr.SetDsNotTo ();
318 
319  if (GetQosSupported ())
320  {
321  //Sanity check that the TID is valid
322  NS_ASSERT (tid < 8);
323  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
324  }
325  else
326  {
327  m_txop->Queue (packet, hdr);
328  }
329 }
330 
331 void
333 {
334  NS_LOG_FUNCTION (this << packet << to << from);
335  if (to.IsGroup () || m_stationManager->IsAssociated (to))
336  {
337  ForwardDown (packet, from, to);
338  }
339  else
340  {
341  NotifyTxDrop (packet);
342  }
343 }
344 
345 void
347 {
348  NS_LOG_FUNCTION (this << packet << to);
349  //We're sending this packet with a from address that is our own. We
350  //get that address from the lower MAC and make use of the
351  //from-spoofing Enqueue() method to avoid duplicated code.
352  Enqueue (packet, to, GetAddress ());
353 }
354 
355 bool
357 {
358  NS_LOG_FUNCTION (this);
359  return true;
360 }
361 
364 {
365  NS_LOG_FUNCTION (this);
366  SupportedRates rates;
367  //Send the set of supported rates and make sure that we indicate
368  //the Basic Rate set in this set of supported rates.
369  for (const auto & mode : m_phy->GetModeList ())
370  {
371  uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ());
372  NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
373  rates.AddSupportedRate (modeDataRate);
374  //Add rates that are part of the BSSBasicRateSet (manufacturer dependent!)
375  //here we choose to add the mandatory rates to the BSSBasicRateSet,
376  //except for 802.11b where we assume that only the non HR-DSSS rates are part of the BSSBasicRateSet
377  if (mode.IsMandatory () && (mode.GetModulationClass () != WIFI_MOD_CLASS_HR_DSSS))
378  {
379  NS_LOG_DEBUG ("Adding basic mode " << mode.GetUniqueName ());
381  }
382  }
383  //set the basic rates
384  for (uint8_t j = 0; j < m_stationManager->GetNBasicModes (); j++)
385  {
387  uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ());
388  NS_LOG_DEBUG ("Setting basic rate " << mode.GetUniqueName ());
389  rates.SetBasicRate (modeDataRate);
390  }
391  //If it is a HT AP, then add the BSSMembershipSelectorSet
392  //The standard says that the BSSMembershipSelectorSet
393  //must have its MSB set to 1 (must be treated as a Basic Rate)
394  //Also the standard mentioned that at least 1 element should be included in the SupportedRates the rest can be in the ExtendedSupportedRates
395  if (GetHtSupported ())
396  {
397  for (const auto & selector : m_phy->GetBssMembershipSelectorList ())
398  {
399  rates.AddBssMembershipSelectorRate (selector);
400  }
401  }
402  return rates;
403 }
404 
407 {
408  NS_LOG_FUNCTION (this);
409  DsssParameterSet dsssParameters;
410  if (GetDsssSupported ())
411  {
412  dsssParameters.SetDsssSupported (1);
413  dsssParameters.SetCurrentChannel (m_phy->GetChannelNumber ());
414  }
415  return dsssParameters;
416 }
417 
420 {
421  NS_LOG_FUNCTION (this);
422  CapabilityInformation capabilities;
423  capabilities.SetShortPreamble (GetShortPreambleEnabled ());
424  capabilities.SetShortSlotTime (GetShortSlotTimeEnabled ());
425  capabilities.SetEss ();
426  return capabilities;
427 }
428 
431 {
432  NS_LOG_FUNCTION (this);
433  ErpInformation information;
434  information.SetErpSupported (1);
435  if (GetErpSupported ())
436  {
437  information.SetNonErpPresent (!m_nonErpStations.empty ());
438  information.SetUseProtection (GetUseNonErpProtection ());
440  {
441  information.SetBarkerPreambleMode (0);
442  }
443  else
444  {
445  information.SetBarkerPreambleMode (1);
446  }
447  }
448  return information;
449 }
450 
453 {
454  NS_LOG_FUNCTION (this);
455  EdcaParameterSet edcaParameters;
456  if (GetQosSupported ())
457  {
458  edcaParameters.SetQosSupported (1);
459  Ptr<QosTxop> edca;
460  Time txopLimit;
461 
462  edca = m_edca.find (AC_BE)->second;
463  txopLimit = edca->GetTxopLimit ();
464  edcaParameters.SetBeAci (0);
465  edcaParameters.SetBeCWmin (edca->GetMinCw ());
466  edcaParameters.SetBeCWmax (edca->GetMaxCw ());
467  edcaParameters.SetBeAifsn (edca->GetAifsn ());
468  edcaParameters.SetBeTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
469 
470  edca = m_edca.find (AC_BK)->second;
471  txopLimit = edca->GetTxopLimit ();
472  edcaParameters.SetBkAci (1);
473  edcaParameters.SetBkCWmin (edca->GetMinCw ());
474  edcaParameters.SetBkCWmax (edca->GetMaxCw ());
475  edcaParameters.SetBkAifsn (edca->GetAifsn ());
476  edcaParameters.SetBkTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
477 
478  edca = m_edca.find (AC_VI)->second;
479  txopLimit = edca->GetTxopLimit ();
480  edcaParameters.SetViAci (2);
481  edcaParameters.SetViCWmin (edca->GetMinCw ());
482  edcaParameters.SetViCWmax (edca->GetMaxCw ());
483  edcaParameters.SetViAifsn (edca->GetAifsn ());
484  edcaParameters.SetViTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
485 
486  edca = m_edca.find (AC_VO)->second;
487  txopLimit = edca->GetTxopLimit ();
488  edcaParameters.SetVoAci (3);
489  edcaParameters.SetVoCWmin (edca->GetMinCw ());
490  edcaParameters.SetVoCWmax (edca->GetMaxCw ());
491  edcaParameters.SetVoAifsn (edca->GetAifsn ());
492  edcaParameters.SetVoTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
493 
494  edcaParameters.SetQosInfo (0);
495  }
496  return edcaParameters;
497 }
498 
501 {
502  NS_LOG_FUNCTION (this);
503  HtOperation operation;
504  if (GetHtSupported ())
505  {
506  operation.SetHtSupported (1);
507  operation.SetPrimaryChannel (m_phy->GetChannelNumber ());
508  operation.SetRifsMode (false);
509  operation.SetNonGfHtStasPresent (true);
510  if (m_phy->GetChannelWidth () > 20)
511  {
512  operation.SetSecondaryChannelOffset (1);
513  operation.SetStaChannelWidth (1);
514  }
515  if (m_nonHtStations.empty ())
516  {
517  operation.SetHtProtection (NO_PROTECTION);
518  }
519  else
520  {
522  }
523  uint64_t maxSupportedRate = 0; //in bit/s
524  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HT))
525  {
526  uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
527  NS_ASSERT (nss > 0 && nss < 5);
528  uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), GetHtConfiguration ()->GetShortGuardIntervalSupported () ? 400 : 800, nss);
529  if (dataRate > maxSupportedRate)
530  {
531  maxSupportedRate = dataRate;
532  NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate);
533  }
534  }
535  uint8_t maxSpatialStream = m_phy->GetMaxSupportedTxSpatialStreams ();
536  auto mcsList = m_phy->GetMcsList (WIFI_MOD_CLASS_HT);
537  uint8_t nMcs = mcsList.size ();
538  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
539  {
540  if (m_stationManager->GetHtSupported (i->second))
541  {
542  uint64_t maxSupportedRateByHtSta = 0; //in bit/s
543  auto itMcs = mcsList.begin ();
544  for (uint8_t j = 0; j < (std::min (nMcs, m_stationManager->GetNMcsSupported (i->second))); j++)
545  {
546  WifiMode mcs = *itMcs++;
547  uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
548  NS_ASSERT (nss > 0 && nss < 5);
549  uint64_t dataRate = mcs.GetDataRate (m_stationManager->GetChannelWidthSupported (i->second), m_stationManager->GetShortGuardIntervalSupported (i->second) ? 400 : 800, nss);
550  if (dataRate > maxSupportedRateByHtSta)
551  {
552  maxSupportedRateByHtSta = dataRate;
553  }
554  }
555  if (maxSupportedRateByHtSta < maxSupportedRate)
556  {
557  maxSupportedRate = maxSupportedRateByHtSta;
558  }
559  if (m_stationManager->GetNMcsSupported (i->second) < nMcs)
560  {
561  nMcs = m_stationManager->GetNMcsSupported (i->second);
562  }
563  if (m_stationManager->GetNumberOfSupportedStreams (i->second) < maxSpatialStream)
564  {
565  maxSpatialStream = m_stationManager->GetNumberOfSupportedStreams (i->second);
566  }
567  }
568  }
569  operation.SetRxHighestSupportedDataRate (static_cast<uint16_t> (maxSupportedRate / 1e6)); //in Mbit/s
570  operation.SetTxMcsSetDefined (nMcs > 0);
571  operation.SetTxMaxNSpatialStreams (maxSpatialStream);
572  //To be filled in once supported
573  operation.SetObssNonHtStasPresent (0);
574  operation.SetDualBeacon (0);
575  operation.SetDualCtsProtection (0);
576  operation.SetStbcBeacon (0);
577  operation.SetLSigTxopProtectionFullSupport (0);
578  operation.SetPcoActive (0);
579  operation.SetPhase (0);
580  operation.SetRxMcsBitmask (0);
581  operation.SetTxRxMcsSetUnequal (0);
582  operation.SetTxUnequalModulation (0);
583  }
584  return operation;
585 }
586 
589 {
590  NS_LOG_FUNCTION (this);
591  VhtOperation operation;
592  if (GetVhtSupported ())
593  {
594  operation.SetVhtSupported (1);
595  uint16_t channelWidth = GetVhtOperationalChannelWidth ();
596  if (channelWidth == 160)
597  {
598  operation.SetChannelWidth (2);
599  }
600  else if (channelWidth == 80)
601  {
602  operation.SetChannelWidth (1);
603  }
604  else
605  {
606  operation.SetChannelWidth (0);
607  }
608  uint8_t maxSpatialStream = m_phy->GetMaxSupportedRxSpatialStreams ();
609  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
610  {
611  if (m_stationManager->GetVhtSupported (i->second))
612  {
613  if (m_stationManager->GetNumberOfSupportedStreams (i->second) < maxSpatialStream)
614  {
615  maxSpatialStream = m_stationManager->GetNumberOfSupportedStreams (i->second);
616  }
617  }
618  }
619  for (uint8_t nss = 1; nss <= maxSpatialStream; nss++)
620  {
621  uint8_t maxMcs = 9; //TBD: hardcode to 9 for now since we assume all MCS values are supported
622  operation.SetMaxVhtMcsPerNss (nss, maxMcs);
623  }
624  }
625  return operation;
626 }
627 
630 {
631  NS_LOG_FUNCTION (this);
632  HeOperation operation;
633  if (GetHeSupported ())
634  {
635  operation.SetHeSupported (1);
636  uint8_t maxSpatialStream = m_phy->GetMaxSupportedRxSpatialStreams ();
637  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
638  {
639  if (m_stationManager->GetHeSupported (i->second))
640  {
641  if (m_stationManager->GetNumberOfSupportedStreams (i->second) < maxSpatialStream)
642  {
643  maxSpatialStream = m_stationManager->GetNumberOfSupportedStreams (i->second);
644  }
645  }
646  }
647  for (uint8_t nss = 1; nss <= maxSpatialStream; nss++)
648  {
649  operation.SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported
650  }
651  operation.SetBssColor (GetHeConfiguration ()->GetBssColor ());
652  }
653  return operation;
654 }
655 
656 void
658 {
659  NS_LOG_FUNCTION (this << to);
660  WifiMacHeader hdr;
662  hdr.SetAddr1 (to);
663  hdr.SetAddr2 (GetAddress ());
664  hdr.SetAddr3 (GetAddress ());
665  hdr.SetDsNotFrom ();
666  hdr.SetDsNotTo ();
667  Ptr<Packet> packet = Create<Packet> ();
669  probe.SetSsid (GetSsid ());
670  probe.SetSupportedRates (GetSupportedRates ());
671  probe.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
672  probe.SetCapabilities (GetCapabilities ());
675  if (GetDsssSupported ())
676  {
677  probe.SetDsssParameterSet (GetDsssParameterSet ());
678  }
679  if (GetErpSupported ())
680  {
681  probe.SetErpInformation (GetErpInformation ());
682  }
683  if (GetQosSupported ())
684  {
685  probe.SetEdcaParameterSet (GetEdcaParameterSet ());
686  }
687  if (GetHtSupported ())
688  {
689  probe.SetExtendedCapabilities (GetExtendedCapabilities ());
690  probe.SetHtCapabilities (GetHtCapabilities ());
691  probe.SetHtOperation (GetHtOperation ());
692  }
693  if (GetVhtSupported ())
694  {
695  probe.SetVhtCapabilities (GetVhtCapabilities ());
696  probe.SetVhtOperation (GetVhtOperation ());
697  }
698  if (GetHeSupported ())
699  {
700  probe.SetHeCapabilities (GetHeCapabilities ());
701  probe.SetHeOperation (GetHeOperation ());
702  }
703  packet->AddHeader (probe);
704 
705  //The standard is not clear on the correct queue for management
706  //frames if we are a QoS AP. The approach taken here is to always
707  //use the DCF for these regardless of whether we have a QoS
708  //association or not.
709  m_txop->Queue (packet, hdr);
710 }
711 
712 void
713 ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc)
714 {
715  NS_LOG_FUNCTION (this << to << success << isReassoc);
716  WifiMacHeader hdr;
718  hdr.SetAddr1 (to);
719  hdr.SetAddr2 (GetAddress ());
720  hdr.SetAddr3 (GetAddress ());
721  hdr.SetDsNotFrom ();
722  hdr.SetDsNotTo ();
723  Ptr<Packet> packet = Create<Packet> ();
725  StatusCode code;
726  if (success)
727  {
728  code.SetSuccess ();
729  uint16_t aid = 0;
730  bool found = false;
731  if (isReassoc)
732  {
733  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); ++i)
734  {
735  if (i->second == to)
736  {
737  aid = i->first;
738  found = true;
739  break;
740  }
741  }
742  }
743  if (!found)
744  {
745  aid = GetNextAssociationId ();
746  m_staList.insert (std::make_pair (aid, to));
747  m_addressIdMap.insert (std::make_pair (to, aid));
748  }
749  assoc.SetAssociationId (aid);
750  }
751  else
752  {
753  code.SetFailure ();
754  }
755  assoc.SetSupportedRates (GetSupportedRates ());
756  assoc.SetStatusCode (code);
757  assoc.SetCapabilities (GetCapabilities ());
758  if (GetErpSupported ())
759  {
760  assoc.SetErpInformation (GetErpInformation ());
761  }
762  if (GetQosSupported ())
763  {
764  assoc.SetEdcaParameterSet (GetEdcaParameterSet ());
765  }
766  if (GetHtSupported ())
767  {
768  assoc.SetExtendedCapabilities (GetExtendedCapabilities ());
769  assoc.SetHtCapabilities (GetHtCapabilities ());
770  assoc.SetHtOperation (GetHtOperation ());
771  }
772  if (GetVhtSupported ())
773  {
774  assoc.SetVhtCapabilities (GetVhtCapabilities ());
775  assoc.SetVhtOperation (GetVhtOperation ());
776  }
777  if (GetHeSupported ())
778  {
779  assoc.SetHeCapabilities (GetHeCapabilities ());
780  assoc.SetHeOperation (GetHeOperation ());
781  }
782  packet->AddHeader (assoc);
783 
784  //The standard is not clear on the correct queue for management
785  //frames if we are a QoS AP. The approach taken here is to always
786  //use the DCF for these regardless of whether we have a QoS
787  //association or not.
788  m_txop->Queue (packet, hdr);
789 }
790 
791 void
793 {
794  NS_LOG_FUNCTION (this);
795  WifiMacHeader hdr;
798  hdr.SetAddr2 (GetAddress ());
799  hdr.SetAddr3 (GetAddress ());
800  hdr.SetDsNotFrom ();
801  hdr.SetDsNotTo ();
802  Ptr<Packet> packet = Create<Packet> ();
803  MgtBeaconHeader beacon;
804  beacon.SetSsid (GetSsid ());
805  beacon.SetSupportedRates (GetSupportedRates ());
806  beacon.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
807  beacon.SetCapabilities (GetCapabilities ());
810  if (GetDsssSupported ())
811  {
812  beacon.SetDsssParameterSet (GetDsssParameterSet ());
813  }
814  if (GetErpSupported ())
815  {
816  beacon.SetErpInformation (GetErpInformation ());
817  }
818  if (GetQosSupported ())
819  {
820  beacon.SetEdcaParameterSet (GetEdcaParameterSet ());
821  }
822  if (GetHtSupported ())
823  {
824  beacon.SetExtendedCapabilities (GetExtendedCapabilities ());
825  beacon.SetHtCapabilities (GetHtCapabilities ());
826  beacon.SetHtOperation (GetHtOperation ());
827  }
828  if (GetVhtSupported ())
829  {
830  beacon.SetVhtCapabilities (GetVhtCapabilities ());
831  beacon.SetVhtOperation (GetVhtOperation ());
832  }
833  if (GetHeSupported ())
834  {
835  beacon.SetHeCapabilities (GetHeCapabilities ());
836  beacon.SetHeOperation (GetHeOperation ());
837  }
838  packet->AddHeader (beacon);
839 
840  //The beacon has it's own special queue, so we load it in there
841  m_beaconTxop->Queue (packet, hdr);
843 
844  //If a STA that does not support Short Slot Time associates,
845  //the AP shall use long slot time beginning at the first Beacon
846  //subsequent to the association of the long slot time STA.
847  if (GetErpSupported ())
848  {
849  if (GetShortSlotTimeEnabled () == true)
850  {
851  //Enable short slot time
852  m_phy->SetSlot (MicroSeconds (9));
853  }
854  else
855  {
856  //Disable short slot time
857  m_phy->SetSlot (MicroSeconds (20));
858  }
859  }
860 }
861 
862 void
864 {
865  NS_LOG_FUNCTION (this << *mpdu);
866  const WifiMacHeader& hdr = mpdu->GetHeader ();
867  if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
869  {
870  NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
872  }
873 }
874 
875 void
876 ApWifiMac::TxFailed (uint8_t timeoutReason, Ptr<const WifiMacQueueItem> mpdu, const WifiTxVector& txVector)
877 {
878  NS_LOG_FUNCTION (this << +timeoutReason << *mpdu << txVector);
879  const WifiMacHeader& hdr = mpdu->GetHeader ();
880 
881  if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
883  {
884  NS_LOG_DEBUG ("association failed with sta=" << hdr.GetAddr1 ());
886  }
887 }
888 
889 void
891 {
892  NS_LOG_FUNCTION (this << *mpdu);
893  const WifiMacHeader* hdr = &mpdu->GetHeader ();
894  Ptr<const Packet> packet = mpdu->GetPacket ();
895  Mac48Address from = hdr->GetAddr2 ();
896  if (hdr->IsData ())
897  {
898  Mac48Address bssid = hdr->GetAddr1 ();
899  if (!hdr->IsFromDs ()
900  && hdr->IsToDs ()
901  && bssid == GetAddress ()
902  && m_stationManager->IsAssociated (from))
903  {
904  Mac48Address to = hdr->GetAddr3 ();
905  if (to == GetAddress ())
906  {
907  NS_LOG_DEBUG ("frame for me from=" << from);
908  if (hdr->IsQosData ())
909  {
910  if (hdr->IsQosAmsdu ())
911  {
912  NS_LOG_DEBUG ("Received A-MSDU from=" << from << ", size=" << packet->GetSize ());
914  packet = 0;
915  }
916  else
917  {
918  ForwardUp (packet, from, bssid);
919  }
920  }
921  else if (hdr->HasData ())
922  {
923  ForwardUp (packet, from, bssid);
924  }
925  }
926  else if (to.IsGroup ()
928  {
929  NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to);
930  Ptr<Packet> copy = packet->Copy ();
931 
932  //If the frame we are forwarding is of type QoS Data,
933  //then we need to preserve the UP in the QoS control
934  //header...
935  if (hdr->IsQosData ())
936  {
937  ForwardDown (copy, from, to, hdr->GetQosTid ());
938  }
939  else
940  {
941  ForwardDown (copy, from, to);
942  }
943  ForwardUp (packet, from, to);
944  }
945  else
946  {
947  ForwardUp (packet, from, to);
948  }
949  }
950  else if (hdr->IsFromDs ()
951  && hdr->IsToDs ())
952  {
953  //this is an AP-to-AP frame
954  //we ignore for now.
955  NotifyRxDrop (packet);
956  }
957  else
958  {
959  //we can ignore these frames since
960  //they are not targeted at the AP
961  NotifyRxDrop (packet);
962  }
963  return;
964  }
965  else if (hdr->IsMgt ())
966  {
967  if (hdr->IsProbeReq ())
968  {
969  NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ());
970  MgtProbeRequestHeader probeRequestHeader;
971  packet->PeekHeader (probeRequestHeader);
972  Ssid ssid = probeRequestHeader.GetSsid ();
973  if (ssid == GetSsid () || ssid.IsBroadcast ())
974  {
975  NS_LOG_DEBUG ("Probe request received from " << from << ": send probe response");
976  SendProbeResp (from);
977  }
978  return;
979  }
980  else if (hdr->GetAddr1 () == GetAddress ())
981  {
982  if (hdr->IsAssocReq ())
983  {
984  NS_LOG_DEBUG ("Association request received from " << from);
985  //first, verify that the the station's supported
986  //rate set is compatible with our Basic Rate set
987  MgtAssocRequestHeader assocReq;
988  packet->PeekHeader (assocReq);
989  CapabilityInformation capabilities = assocReq.GetCapabilities ();
991  SupportedRates rates = assocReq.GetSupportedRates ();
992  bool problem = false;
993  bool isHtStation = false;
994  bool isOfdmStation = false;
995  bool isErpStation = false;
996  bool isDsssStation = false;
997  for (uint8_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
998  {
1000  if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1001  {
1003  {
1004  isDsssStation = false;
1005  }
1006  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1007  {
1008  isErpStation = false;
1009  }
1010  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1011  {
1012  isOfdmStation = false;
1013  }
1014  if (isDsssStation == false && isErpStation == false && isOfdmStation == false)
1015  {
1016  problem = true;
1017  break;
1018  }
1019  }
1020  else
1021  {
1023  {
1024  isDsssStation = true;
1025  }
1026  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1027  {
1028  isErpStation = true;
1029  }
1030  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1031  {
1032  isOfdmStation = true;
1033  }
1034  }
1035  }
1036  m_stationManager->AddSupportedErpSlotTime (from, capabilities.IsShortSlotTime () && isErpStation);
1037  if (GetHtSupported ())
1038  {
1039  //check whether the HT STA supports all MCSs in Basic MCS Set
1040  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
1041  if (htcapabilities.IsSupportedMcs (0))
1042  {
1043  isHtStation = true;
1044  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1045  {
1047  if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1048  {
1049  problem = true;
1050  break;
1051  }
1052  }
1053  }
1054  }
1055  if (GetVhtSupported ())
1056  {
1057  //check whether the VHT STA supports all MCSs in Basic MCS Set
1058  VhtCapabilities vhtcapabilities = assocReq.GetVhtCapabilities ();
1059  if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
1060  {
1061  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1062  {
1064  if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1065  {
1066  problem = true;
1067  break;
1068  }
1069  }
1070  }
1071  }
1072  if (GetHeSupported ())
1073  {
1074  //check whether the HE STA supports all MCSs in Basic MCS Set
1075  HeCapabilities hecapabilities = assocReq.GetHeCapabilities ();
1076  if (hecapabilities.GetSupportedMcsAndNss () != 0)
1077  {
1078  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1079  {
1081  if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1082  {
1083  problem = true;
1084  break;
1085  }
1086  }
1087  }
1088  }
1089  if (problem)
1090  {
1091  NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send association response with an error status");
1092  SendAssocResp (hdr->GetAddr2 (), false, false);
1093  }
1094  else
1095  {
1096  NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1097  //record all its supported modes in its associated WifiRemoteStation
1098  for (const auto & mode : m_phy->GetModeList ())
1099  {
1100  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1101  {
1102  m_stationManager->AddSupportedMode (from, mode);
1103  }
1104  }
1105  if (GetHtSupported ())
1106  {
1107  HtCapabilities htCapabilities = assocReq.GetHtCapabilities ();
1108  if (htCapabilities.IsSupportedMcs (0))
1109  {
1110  m_stationManager->AddStationHtCapabilities (from, htCapabilities);
1111  }
1112  }
1113  if (GetVhtSupported ())
1114  {
1115  VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilities ();
1116  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1117  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1118  {
1119  m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities);
1120  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_VHT))
1121  {
1122  if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1123  {
1124  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1125  //here should add a control to add basic MCS when it is implemented
1126  }
1127  }
1128  }
1129  }
1130  if (GetHtSupported ())
1131  {
1132  ExtendedCapabilities extendedCapabilities = assocReq.GetExtendedCapabilities ();
1133  //TODO: to be completed
1134  }
1135  if (GetHeSupported ())
1136  {
1137  HeCapabilities heCapabilities = assocReq.GetHeCapabilities ();
1138  if (heCapabilities.GetSupportedMcsAndNss () != 0)
1139  {
1140  m_stationManager->AddStationHeCapabilities (from, heCapabilities);
1141  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HE))
1142  {
1143  if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1144  {
1145  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1146  //here should add a control to add basic MCS when it is implemented
1147  }
1148  }
1149  }
1150  }
1152  if (!isHtStation)
1153  {
1154  m_nonHtStations.push_back (hdr->GetAddr2 ());
1155  m_nonHtStations.unique ();
1156  }
1157  if (!isErpStation && isDsssStation)
1158  {
1159  m_nonErpStations.push_back (hdr->GetAddr2 ());
1160  m_nonErpStations.unique ();
1161  }
1162  NS_LOG_DEBUG ("Send association response with success status");
1163  SendAssocResp (hdr->GetAddr2 (), true, false);
1164  }
1165  return;
1166  }
1167  else if (hdr->IsReassocReq ())
1168  {
1169  NS_LOG_DEBUG ("Reassociation request received from " << from);
1170  //first, verify that the the station's supported
1171  //rate set is compatible with our Basic Rate set
1172  MgtReassocRequestHeader reassocReq;
1173  packet->PeekHeader (reassocReq);
1174  CapabilityInformation capabilities = reassocReq.GetCapabilities ();
1175  m_stationManager->AddSupportedPhyPreamble (from, capabilities.IsShortPreamble ());
1176  SupportedRates rates = reassocReq.GetSupportedRates ();
1177  bool problem = false;
1178  bool isHtStation = false;
1179  bool isOfdmStation = false;
1180  bool isErpStation = false;
1181  bool isDsssStation = false;
1182  for (uint8_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
1183  {
1185  if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1186  {
1188  {
1189  isDsssStation = false;
1190  }
1191  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1192  {
1193  isErpStation = false;
1194  }
1195  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1196  {
1197  isOfdmStation = false;
1198  }
1199  if (isDsssStation == false && isErpStation == false && isOfdmStation == false)
1200  {
1201  problem = true;
1202  break;
1203  }
1204  }
1205  else
1206  {
1208  {
1209  isDsssStation = true;
1210  }
1211  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1212  {
1213  isErpStation = true;
1214  }
1215  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1216  {
1217  isOfdmStation = true;
1218  }
1219  }
1220  }
1221  m_stationManager->AddSupportedErpSlotTime (from, capabilities.IsShortSlotTime () && isErpStation);
1222  if (GetHtSupported ())
1223  {
1224  //check whether the HT STA supports all MCSs in Basic MCS Set
1225  HtCapabilities htcapabilities = reassocReq.GetHtCapabilities ();
1226  if (htcapabilities.IsSupportedMcs (0))
1227  {
1228  isHtStation = true;
1229  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1230  {
1232  if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1233  {
1234  problem = true;
1235  break;
1236  }
1237  }
1238  }
1239  }
1240  if (GetVhtSupported ())
1241  {
1242  //check whether the VHT STA supports all MCSs in Basic MCS Set
1243  VhtCapabilities vhtcapabilities = reassocReq.GetVhtCapabilities ();
1244  if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
1245  {
1246  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1247  {
1249  if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1250  {
1251  problem = true;
1252  break;
1253  }
1254  }
1255  }
1256  }
1257  if (GetHeSupported ())
1258  {
1259  //check whether the HE STA supports all MCSs in Basic MCS Set
1260  HeCapabilities hecapabilities = reassocReq.GetHeCapabilities ();
1261  if (hecapabilities.GetSupportedMcsAndNss () != 0)
1262  {
1263  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1264  {
1266  if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1267  {
1268  problem = true;
1269  break;
1270  }
1271  }
1272  }
1273  }
1274  if (problem)
1275  {
1276  NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send reassociation response with an error status");
1277  SendAssocResp (hdr->GetAddr2 (), false, true);
1278  }
1279  else
1280  {
1281  NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1282  //update all its supported modes in its associated WifiRemoteStation
1283  for (const auto & mode : m_phy->GetModeList ())
1284  {
1285  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1286  {
1287  m_stationManager->AddSupportedMode (from, mode);
1288  }
1289  }
1290  if (GetHtSupported ())
1291  {
1292  HtCapabilities htCapabilities = reassocReq.GetHtCapabilities ();
1293  if (htCapabilities.IsSupportedMcs (0))
1294  {
1295  m_stationManager->AddStationHtCapabilities (from, htCapabilities);
1296  }
1297  }
1298  if (GetVhtSupported ())
1299  {
1300  VhtCapabilities vhtCapabilities = reassocReq.GetVhtCapabilities ();
1301  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1302  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1303  {
1304  m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities);
1305  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_VHT))
1306  {
1307  if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1308  {
1309  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1310  //here should add a control to add basic MCS when it is implemented
1311  }
1312  }
1313  }
1314  }
1315  if (GetHtSupported ())
1316  {
1317  ExtendedCapabilities extendedCapabilities = reassocReq.GetExtendedCapabilities ();
1318  //TODO: to be completed
1319  }
1320  if (GetHeSupported ())
1321  {
1322  HeCapabilities heCapabilities = reassocReq.GetHeCapabilities ();
1323  if (heCapabilities.GetSupportedMcsAndNss () != 0)
1324  {
1325  m_stationManager->AddStationHeCapabilities (from, heCapabilities);
1326  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HE))
1327  {
1328  if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1329  {
1330  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1331  //here should add a control to add basic MCS when it is implemented
1332  }
1333  }
1334  }
1335  }
1337  if (!isHtStation)
1338  {
1339  m_nonHtStations.push_back (hdr->GetAddr2 ());
1340  m_nonHtStations.unique ();
1341  }
1342  if (!isErpStation && isDsssStation)
1343  {
1344  m_nonErpStations.push_back (hdr->GetAddr2 ());
1345  m_nonErpStations.unique ();
1346  }
1347  NS_LOG_DEBUG ("Send reassociation response with success status");
1348  SendAssocResp (hdr->GetAddr2 (), true, true);
1349  }
1350  return;
1351  }
1352  else if (hdr->IsDisassociation ())
1353  {
1354  NS_LOG_DEBUG ("Disassociation received from " << from);
1356  for (std::map<uint16_t, Mac48Address>::const_iterator j = m_staList.begin (); j != m_staList.end (); j++)
1357  {
1358  if (j->second == from)
1359  {
1360  m_staList.erase (j);
1361  m_addressIdMap.erase (from);
1362  break;
1363  }
1364  }
1365  for (std::list<Mac48Address>::const_iterator j = m_nonErpStations.begin (); j != m_nonErpStations.end (); j++)
1366  {
1367  if ((*j) == from)
1368  {
1369  m_nonErpStations.erase (j);
1370  break;
1371  }
1372  }
1373  for (std::list<Mac48Address>::const_iterator j = m_nonHtStations.begin (); j != m_nonHtStations.end (); j++)
1374  {
1375  if ((*j) == from)
1376  {
1377  m_nonHtStations.erase (j);
1378  break;
1379  }
1380  }
1381  return;
1382  }
1383  }
1384  }
1385 
1386  //Invoke the receive handler of our parent class to deal with any
1387  //other frames. Specifically, this will handle Block Ack-related
1388  //Management Action frames.
1389  RegularWifiMac::Receive (Create<WifiMacQueueItem> (packet, *hdr));
1390 }
1391 
1392 void
1394 {
1395  NS_LOG_FUNCTION (this << *mpdu);
1396  for (auto& i : *PeekPointer (mpdu))
1397  {
1398  if (i.second.GetDestinationAddr () == GetAddress ())
1399  {
1400  ForwardUp (i.first, i.second.GetSourceAddr (),
1401  i.second.GetDestinationAddr ());
1402  }
1403  else
1404  {
1405  Mac48Address from = i.second.GetSourceAddr ();
1406  Mac48Address to = i.second.GetDestinationAddr ();
1407  NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
1408  ForwardDown (i.first->Copy (), from, to, mpdu->GetHeader ().GetQosTid ());
1409  }
1410  }
1411 }
1412 
1413 void
1415 {
1416  NS_LOG_FUNCTION (this);
1418  m_beaconEvent.Cancel ();
1420  {
1422  {
1423  Time jitter = MicroSeconds (static_cast<int64_t> (m_beaconJitter->GetValue (0, 1) * (GetBeaconInterval ().GetMicroSeconds ())));
1424  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time " << jitter);
1426  }
1427  else
1428  {
1429  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time 0");
1431  }
1432  }
1434  NS_ABORT_IF (!TraceConnectWithoutContext ("MpduResponseTimeout", MakeCallback (&ApWifiMac::TxFailed, this)));
1436 }
1437 
1438 bool
1440 {
1441  bool useProtection = !m_nonErpStations.empty () && m_enableNonErpProtection;
1442  m_stationManager->SetUseNonErpProtection (useProtection);
1443  return useProtection;
1444 }
1445 
1446 uint16_t
1448 {
1449  //Return the first free AID value between 1 and 2007
1450  for (uint16_t nextAid = 1; nextAid <= 2007; nextAid++)
1451  {
1452  if (m_staList.find (nextAid) == m_staList.end ())
1453  {
1454  return nextAid;
1455  }
1456  }
1457  NS_FATAL_ERROR ("No free association ID available!");
1458  return 0;
1459 }
1460 
1461 const std::map<uint16_t, Mac48Address>&
1463 {
1464  return m_staList;
1465 }
1466 
1467 uint16_t
1469 {
1470  auto it = m_addressIdMap.find (addr);
1471 
1472  if (it == m_addressIdMap.end ())
1473  {
1474  return SU_STA_ID;
1475  }
1476  return it->second;
1477 }
1478 
1479 uint8_t
1481 {
1482  auto it = m_bufferStatus.find (WifiAddressTidPair (address, tid));
1483  if (it == m_bufferStatus.end ()
1484  || it->second.timestamp + m_bsrLifetime < Simulator::Now ())
1485  {
1486  return 255;
1487  }
1488  return it->second.value;
1489 }
1490 
1491 void
1493 {
1494  if (size == 255)
1495  {
1496  // no point in storing an unspecified size
1497  m_bufferStatus.erase (WifiAddressTidPair (address, tid));
1498  }
1499  else
1500  {
1502  }
1503 }
1504 
1505 uint8_t
1507 {
1508  uint8_t maxSize = 0;
1509  bool found = false;
1510 
1511  for (uint8_t tid = 0; tid < 8; tid++)
1512  {
1513  uint8_t size = GetBufferStatus (tid, address);
1514  if (size != 255)
1515  {
1516  maxSize = std::max (maxSize, size);
1517  found = true;
1518  }
1519  }
1520 
1521  if (found)
1522  {
1523  return maxSize;
1524  }
1525  return 255;
1526 }
1527 
1528 } //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:786
std::pair< Mac48Address, uint8_t > WifiAddressTidPair
(MAC address, TID) pair
Definition: qos-utils.h:32
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:311
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:178
Ptr< HeConfiguration > GetHeConfiguration(void) const
Definition: wifi-mac.cc:198
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:738
Implement the header for management frames of type association request.
Definition: mgt-headers.h:48
#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:256
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates...
Definition: ap-wifi-mac.cc:363
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 ...
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
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:452
uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: txop.cc:268
#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:629
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:193
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:2000
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:916
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.
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:774
WifiMode GetBasicMcs(uint8_t i) const
Return the MCS at the given list index.
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:121
uint16_t GetAssociationId(Mac48Address addr) const
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:346
#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:151
const std::map< uint16_t, Mac48Address > & GetStaList(void) const
Get a const reference to the map of associated stations.
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:239
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:2049
uint8_t GetNBasicMcs(void) const
Return the number of basic MCS index.
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:726
void SetVoCWmin(uint32_t cwMin)
Set the AC_VO CWmin field in the EdcaParameterSet information element.
uint32_t GetMinCw(void) const
Return the minimum contention window size.
Definition: txop.cc:256
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.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:47
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:551
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:152
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
bool m_enableBeaconGeneration
Flag whether beacons are being generated.
Definition: ap-wifi-mac.h:306
void SendAssocResp(Mac48Address to, bool success, bool isReassoc)
Forward an association or a reassociation response packet to the DCF.
Definition: ap-wifi-mac.cc:713
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
Definition: ap-wifi-mac.cc:158
HR/DSSS (Clause 16)
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1233
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.
void SetHtProtection(uint8_t htProtection)
Set the HT protection.
base class for all MAC-level wifi objects.
void SetSuccess(void)
Set success bit to 0 (success).
Definition: status-code.cc:30
Ptr< HtConfiguration > GetHtConfiguration(void) const
Definition: wifi-mac.cc:184
const WifiMacHeader & GetHeader(void) const
Get the header stored in this item.
bool GetErpSupported() const
Return whether the device supports ERP.
Video.
Definition: qos-utils.h:65
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:575
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:419
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:103
Time m_bsrLifetime
Lifetime of Buffer Status Reports.
Definition: ap-wifi-mac.h:317
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:588
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:201
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:599
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:316
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:126
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:222
void SetVhtSupported(uint8_t vhtSupported)
Set the VHT supported information element.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
Best Effort.
Definition: qos-utils.h:61
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:308
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:305
std::list< uint8_t > GetBssMembershipSelectorList(void) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1427
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.
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:159
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:122
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
void TxFailed(uint8_t timeoutReason, Ptr< const WifiMacQueueItem > mpdu, const WifiTxVector &txVector)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:876
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
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:316
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:587
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:293
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
void SetLinkUpCallback(Callback< void > linkUp)
void SetLinkUpCallback(Callback< void > linkUp)
Definition: ap-wifi-mac.cc:166
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...
Background.
Definition: qos-utils.h:63
void TxOk(Ptr< const WifiMacQueueItem > mpdu)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:863
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:262
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:539
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:771
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:1199
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:406
HtOperation GetHtOperation(void) const
Return the HT operation of the current AP.
Definition: ap-wifi-mac.cc:500
Implement the header for management frames of type probe request.
Definition: mgt-headers.h:513
ErpInformation GetErpInformation(void) const
Return the ERP information of the current AP.
Definition: ap-wifi-mac.cc:430
Mac48Address GetAddress(void) const
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:317
void SendProbeResp(Mac48Address to)
Forward a probe response packet to the DCF.
Definition: ap-wifi-mac.cc:657
uint8_t GetNBasicModes(void) const
Return the number of basic modes we support.
Voice.
Definition: qos-utils.h:67
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.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Definition: abort.h:77
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.
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:792
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:157
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:169
bool GetHtSupported() const
Return whether the device supports HT.
void DoDispose(void)
Destructor implementation.
Definition: ap-wifi-mac.cc:115
void SetAddress(Mac48Address address)
Definition: ap-wifi-mac.cc:126
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:762
#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:309
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:307
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:321
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:314
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:890
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:105
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:310
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:241
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:563
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:617
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
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:315
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:137
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:288
bool SupportsSendFrom(void) const
Definition: ap-wifi-mac.cc:356
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:1403
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
#define SU_STA_ID
Definition: wifi-mode.h:32
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:833
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:100
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:179
bool IsToDs(void) const
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:750
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1421
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
std::unordered_map< Mac48Address, uint16_t, WifiAddressHash > m_addressIdMap
Definition: ap-wifi-mac.h:313
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:136
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.
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: txop.cc:274
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.