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