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.
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 (); // explicitly set to 0 for the time being since HT/VHT/HE control field is not yet implemented (set it to 1 when implemented)
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  //Send the set of supported rates and make sure that we indicate
407  //the Basic Rate set in this set of supported rates.
408  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
409  {
410  WifiMode mode = m_phy->GetMode (i);
411  uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ());
412  NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
413  rates.AddSupportedRate (modeDataRate);
414  //Add rates that are part of the BSSBasicRateSet (manufacturer dependent!)
415  //here we choose to add the mandatory rates to the BSSBasicRateSet,
416  //except for 802.11b where we assume that only the non HR-DSSS rates are part of the BSSBasicRateSet
417  if (mode.IsMandatory () && (mode.GetModulationClass () != WIFI_MOD_CLASS_HR_DSSS))
418  {
419  NS_LOG_DEBUG ("Adding basic mode " << mode.GetUniqueName ());
421  }
422  }
423  //set the basic rates
424  for (uint8_t j = 0; j < m_stationManager->GetNBasicModes (); j++)
425  {
427  uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ());
428  NS_LOG_DEBUG ("Setting basic rate " << mode.GetUniqueName ());
429  rates.SetBasicRate (modeDataRate);
430  }
431  //If it is an HT-AP or VHT-AP or HE-AP, then add the BSSMembershipSelectorSet
432  //The standard says that the BSSMembershipSelectorSet
433  //must have its MSB set to 1 (must be treated as a Basic Rate)
434  //Also the standard mentioned that at least 1 element should be included in the SupportedRates the rest can be in the ExtendedSupportedRates
435  if (GetHtSupported () || GetVhtSupported () || GetHeSupported ())
436  {
437  for (uint8_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
438  {
440  }
441  }
442  return rates;
443 }
444 
447 {
448  NS_LOG_FUNCTION (this);
449  DsssParameterSet dsssParameters;
450  if (GetDsssSupported ())
451  {
452  dsssParameters.SetDsssSupported (1);
453  dsssParameters.SetCurrentChannel (m_phy->GetChannelNumber ());
454  }
455  return dsssParameters;
456 }
457 
460 {
461  NS_LOG_FUNCTION (this);
462  CapabilityInformation capabilities;
463  capabilities.SetShortPreamble (GetShortPreambleEnabled ());
464  capabilities.SetShortSlotTime (GetShortSlotTimeEnabled ());
465  capabilities.SetEss ();
466  if (GetPcfSupported ())
467  {
468  capabilities.SetCfPollable ();
469  }
470  return capabilities;
471 }
472 
475 {
476  NS_LOG_FUNCTION (this);
477  ErpInformation information;
478  information.SetErpSupported (1);
479  if (GetErpSupported ())
480  {
481  information.SetNonErpPresent (!m_nonErpStations.empty ());
482  information.SetUseProtection (GetUseNonErpProtection ());
484  {
485  information.SetBarkerPreambleMode (0);
486  }
487  else
488  {
489  information.SetBarkerPreambleMode (1);
490  }
491  }
492  return information;
493 }
494 
497 {
498  NS_LOG_FUNCTION (this);
499  EdcaParameterSet edcaParameters;
500  if (GetQosSupported ())
501  {
502  edcaParameters.SetQosSupported (1);
503  Ptr<QosTxop> edca;
504  Time txopLimit;
505 
506  edca = m_edca.find (AC_BE)->second;
507  txopLimit = edca->GetTxopLimit ();
508  edcaParameters.SetBeAci (0);
509  edcaParameters.SetBeCWmin (edca->GetMinCw ());
510  edcaParameters.SetBeCWmax (edca->GetMaxCw ());
511  edcaParameters.SetBeAifsn (edca->GetAifsn ());
512  edcaParameters.SetBeTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
513 
514  edca = m_edca.find (AC_BK)->second;
515  txopLimit = edca->GetTxopLimit ();
516  edcaParameters.SetBkAci (1);
517  edcaParameters.SetBkCWmin (edca->GetMinCw ());
518  edcaParameters.SetBkCWmax (edca->GetMaxCw ());
519  edcaParameters.SetBkAifsn (edca->GetAifsn ());
520  edcaParameters.SetBkTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
521 
522  edca = m_edca.find (AC_VI)->second;
523  txopLimit = edca->GetTxopLimit ();
524  edcaParameters.SetViAci (2);
525  edcaParameters.SetViCWmin (edca->GetMinCw ());
526  edcaParameters.SetViCWmax (edca->GetMaxCw ());
527  edcaParameters.SetViAifsn (edca->GetAifsn ());
528  edcaParameters.SetViTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
529 
530  edca = m_edca.find (AC_VO)->second;
531  txopLimit = edca->GetTxopLimit ();
532  edcaParameters.SetVoAci (3);
533  edcaParameters.SetVoCWmin (edca->GetMinCw ());
534  edcaParameters.SetVoCWmax (edca->GetMaxCw ());
535  edcaParameters.SetVoAifsn (edca->GetAifsn ());
536  edcaParameters.SetVoTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
537 
538  edcaParameters.SetQosInfo (0);
539  }
540  return edcaParameters;
541 }
542 
545 {
546  CfParameterSet cfParameterSet;
547  if (GetPcfSupported () && !m_cfPollingList.empty ())
548  {
549  cfParameterSet.SetPcfSupported (1);
550  cfParameterSet.SetCFPCount (0);
551  cfParameterSet.SetCFPPeriod (1);
552  cfParameterSet.SetCFPMaxDurationUs (GetCfpMaxDuration ().GetMicroSeconds ());
553  cfParameterSet.SetCFPDurRemainingUs (GetCfpMaxDuration ().GetMicroSeconds ());
554  }
555  return cfParameterSet;
556 }
557 
560 {
561  NS_LOG_FUNCTION (this);
562  HtOperation operation;
563  if (GetHtSupported ())
564  {
565  operation.SetHtSupported (1);
566  operation.SetPrimaryChannel (m_phy->GetChannelNumber ());
567  operation.SetRifsMode (GetRifsMode ());
569  if (m_phy->GetChannelWidth () > 20)
570  {
571  operation.SetSecondaryChannelOffset (1);
572  operation.SetStaChannelWidth (1);
573  }
574  if (m_nonHtStations.empty ())
575  {
576  operation.SetHtProtection (NO_PROTECTION);
577  }
578  else
579  {
581  }
582  uint64_t maxSupportedRate = 0; //in bit/s
583  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
584  {
585  WifiMode mcs = m_phy->GetMcs (i);
587  {
588  continue;
589  }
590  uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
591  NS_ASSERT (nss > 0 && nss < 5);
592  uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), m_phy->GetShortGuardInterval () ? 400 : 800, nss);
593  if (dataRate > maxSupportedRate)
594  {
595  maxSupportedRate = dataRate;
596  NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate);
597  }
598  }
599  uint8_t maxSpatialStream = m_phy->GetMaxSupportedTxSpatialStreams ();
600  uint8_t nMcs = m_phy->GetNMcs ();
601  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
602  {
603  if (m_stationManager->GetHtSupported (i->second))
604  {
605  uint64_t maxSupportedRateByHtSta = 0; //in bit/s
606  for (uint8_t j = 0; j < (std::min (nMcs, m_stationManager->GetNMcsSupported (i->second))); j++)
607  {
608  WifiMode mcs = m_phy->GetMcs (j);
610  {
611  continue;
612  }
613  uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
614  NS_ASSERT (nss > 0 && nss < 5);
615  uint64_t dataRate = mcs.GetDataRate (m_stationManager->GetChannelWidthSupported (i->second), m_stationManager->GetShortGuardInterval (i->second) ? 400 : 800, nss);
616  if (dataRate > maxSupportedRateByHtSta)
617  {
618  maxSupportedRateByHtSta = dataRate;
619  }
620  }
621  if (maxSupportedRateByHtSta < maxSupportedRate)
622  {
623  maxSupportedRate = maxSupportedRateByHtSta;
624  }
625  if (m_stationManager->GetNMcsSupported (i->second) < nMcs)
626  {
627  nMcs = m_stationManager->GetNMcsSupported (i->second);
628  }
629  if (m_stationManager->GetNumberOfSupportedStreams (i->second) < maxSpatialStream)
630  {
631  maxSpatialStream = m_stationManager->GetNumberOfSupportedStreams (i->second);
632  }
633  }
634  }
635  operation.SetRxHighestSupportedDataRate (static_cast<uint16_t> (maxSupportedRate / 1e6)); //in Mbit/s
636  operation.SetTxMcsSetDefined (nMcs > 0);
637  operation.SetTxMaxNSpatialStreams (maxSpatialStream);
638  //To be filled in once supported
639  operation.SetObssNonHtStasPresent (0);
640  operation.SetDualBeacon (0);
641  operation.SetDualCtsProtection (0);
642  operation.SetStbcBeacon (0);
643  operation.SetLSigTxopProtectionFullSupport (0);
644  operation.SetPcoActive (0);
645  operation.SetPhase (0);
646  operation.SetRxMcsBitmask (0);
647  operation.SetTxRxMcsSetUnequal (0);
648  operation.SetTxUnequalModulation (0);
649  }
650  return operation;
651 }
652 
655 {
656  NS_LOG_FUNCTION (this);
657  VhtOperation operation;
658  if (GetVhtSupported ())
659  {
660  operation.SetVhtSupported (1);
661  uint16_t channelWidth = GetVhtOperationalChannelWidth ();
662  if (channelWidth == 160)
663  {
664  operation.SetChannelWidth (2);
665  }
666  else if (channelWidth == 80)
667  {
668  operation.SetChannelWidth (1);
669  }
670  else
671  {
672  operation.SetChannelWidth (0);
673  }
674  for (uint8_t nss = 1; nss <= 8; nss++)
675  {
676  uint8_t maxMcs;
677  if (nss <= m_phy->GetMaxSupportedRxSpatialStreams ())
678  {
679  maxMcs = 9; //TBD: hardcode to 9 for now since we assume all MCS values are supported
680  }
681  else
682  {
683  maxMcs = 0;
684  }
685  operation.SetMaxVhtMcsPerNss (nss, maxMcs);
686  }
687  }
688  return operation;
689 }
690 
693 {
694  NS_LOG_FUNCTION (this);
695  HeOperation operation;
696  if (GetHeSupported ())
697  {
698  operation.SetHeSupported (1);
699  for (uint8_t nss = 1; nss <= m_phy->GetMaxSupportedRxSpatialStreams (); nss++)
700  {
701  operation.SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported
702  }
703  }
704  return operation;
705 }
706 
707 void
709 {
710  NS_LOG_FUNCTION (this << to);
711  WifiMacHeader hdr;
713  hdr.SetAddr1 (to);
714  hdr.SetAddr2 (GetAddress ());
715  hdr.SetAddr3 (GetAddress ());
716  hdr.SetDsNotFrom ();
717  hdr.SetDsNotTo ();
718  Ptr<Packet> packet = Create<Packet> ();
720  probe.SetSsid (GetSsid ());
721  probe.SetSupportedRates (GetSupportedRates ());
722  probe.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
723  probe.SetCapabilities (GetCapabilities ());
726  if (GetDsssSupported ())
727  {
728  probe.SetDsssParameterSet (GetDsssParameterSet ());
729  }
730  if (GetErpSupported ())
731  {
732  probe.SetErpInformation (GetErpInformation ());
733  }
734  if (GetQosSupported ())
735  {
736  probe.SetEdcaParameterSet (GetEdcaParameterSet ());
737  }
738  if (GetHtSupported () || GetVhtSupported () || GetHeSupported ())
739  {
740  probe.SetExtendedCapabilities (GetExtendedCapabilities ());
741  probe.SetHtCapabilities (GetHtCapabilities ());
742  probe.SetHtOperation (GetHtOperation ());
743  }
744  if (GetVhtSupported () || GetHeSupported ())
745  {
746  probe.SetVhtCapabilities (GetVhtCapabilities ());
747  probe.SetVhtOperation (GetVhtOperation ());
748  }
749  if (GetHeSupported ())
750  {
751  probe.SetHeCapabilities (GetHeCapabilities ());
752  probe.SetHeOperation (GetHeOperation ());
753  }
754  packet->AddHeader (probe);
755 
756  //The standard is not clear on the correct queue for management
757  //frames if we are a QoS AP. The approach taken here is to always
758  //use the DCF for these regardless of whether we have a QoS
759  //association or not.
760  m_txop->Queue (packet, hdr);
761 }
762 
763 void
764 ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc)
765 {
766  NS_LOG_FUNCTION (this << to << success << isReassoc);
767  WifiMacHeader hdr;
769  hdr.SetAddr1 (to);
770  hdr.SetAddr2 (GetAddress ());
771  hdr.SetAddr3 (GetAddress ());
772  hdr.SetDsNotFrom ();
773  hdr.SetDsNotTo ();
774  Ptr<Packet> packet = Create<Packet> ();
776  StatusCode code;
777  if (success)
778  {
779  code.SetSuccess ();
780  uint16_t aid = 0;
781  bool found = false;
782  if (isReassoc)
783  {
784  for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); ++i)
785  {
786  if (i->second == to)
787  {
788  aid = i->first;
789  found = true;
790  break;
791  }
792  }
793  }
794  if (!found)
795  {
796  aid = GetNextAssociationId ();
797  m_staList.insert (std::make_pair (aid, to));
798  }
799  assoc.SetAssociationId (aid);
800  }
801  else
802  {
803  code.SetFailure ();
804  }
805  assoc.SetSupportedRates (GetSupportedRates ());
806  assoc.SetStatusCode (code);
807  assoc.SetCapabilities (GetCapabilities ());
808  if (GetErpSupported ())
809  {
810  assoc.SetErpInformation (GetErpInformation ());
811  }
812  if (GetQosSupported ())
813  {
814  assoc.SetEdcaParameterSet (GetEdcaParameterSet ());
815  }
816  if (GetHtSupported () || GetVhtSupported () || GetHeSupported ())
817  {
818  assoc.SetExtendedCapabilities (GetExtendedCapabilities ());
819  assoc.SetHtCapabilities (GetHtCapabilities ());
820  assoc.SetHtOperation (GetHtOperation ());
821  }
822  if (GetVhtSupported () || GetHeSupported ())
823  {
824  assoc.SetVhtCapabilities (GetVhtCapabilities ());
825  assoc.SetVhtOperation (GetVhtOperation ());
826  }
827  if (GetHeSupported ())
828  {
829  assoc.SetHeCapabilities (GetHeCapabilities ());
830  assoc.SetHeOperation (GetHeOperation ());
831  }
832  packet->AddHeader (assoc);
833 
834  //The standard is not clear on the correct queue for management
835  //frames if we are a QoS AP. The approach taken here is to always
836  //use the DCF for these regardless of whether we have a QoS
837  //association or not.
838  m_txop->Queue (packet, hdr);
839 }
840 
841 void
843 {
844  NS_LOG_FUNCTION (this);
845  WifiMacHeader hdr;
848  hdr.SetAddr2 (GetAddress ());
849  hdr.SetAddr3 (GetAddress ());
850  hdr.SetDsNotFrom ();
851  hdr.SetDsNotTo ();
852  Ptr<Packet> packet = Create<Packet> ();
853  MgtBeaconHeader beacon;
854  beacon.SetSsid (GetSsid ());
855  beacon.SetSupportedRates (GetSupportedRates ());
856  beacon.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
857  beacon.SetCapabilities (GetCapabilities ());
860  if (GetPcfSupported ())
861  {
862  beacon.SetCfParameterSet (GetCfParameterSet ());
863  }
864  if (GetDsssSupported ())
865  {
866  beacon.SetDsssParameterSet (GetDsssParameterSet ());
867  }
868  if (GetErpSupported ())
869  {
870  beacon.SetErpInformation (GetErpInformation ());
871  }
872  if (GetQosSupported ())
873  {
874  beacon.SetEdcaParameterSet (GetEdcaParameterSet ());
875  }
876  if (GetHtSupported () || GetVhtSupported ())
877  {
878  beacon.SetExtendedCapabilities (GetExtendedCapabilities ());
879  beacon.SetHtCapabilities (GetHtCapabilities ());
880  beacon.SetHtOperation (GetHtOperation ());
881  }
882  if (GetVhtSupported () || GetHeSupported ())
883  {
884  beacon.SetVhtCapabilities (GetVhtCapabilities ());
885  beacon.SetVhtOperation (GetVhtOperation ());
886  }
887  if (GetHeSupported ())
888  {
889  beacon.SetHeCapabilities (GetHeCapabilities ());
890  beacon.SetHeOperation (GetHeOperation ());
891  }
892  packet->AddHeader (beacon);
893 
894  //The beacon has it's own special queue, so we load it in there
895  m_beaconTxop->Queue (packet, hdr);
897 
898  //If a STA that does not support Short Slot Time associates,
899  //the AP shall use long slot time beginning at the first Beacon
900  //subsequent to the association of the long slot time STA.
901  if (GetErpSupported ())
902  {
903  if (GetShortSlotTimeEnabled () == true)
904  {
905  //Enable short slot time
906  SetSlot (MicroSeconds (9));
907  }
908  else
909  {
910  //Disable short slot time
911  SetSlot (MicroSeconds (20));
912  }
913  }
914 }
915 
916 void
918 {
919  if (!GetPcfSupported ())
920  {
921  return;
922  }
923  if (m_txop->CanStartNextPolling ())
924  {
925  SendCfPoll ();
926  }
927  else if (m_low->IsCfPeriod ())
928  {
929  SendCfEnd ();
930  }
931 }
932 
933 void
935 {
936  NS_LOG_FUNCTION (this);
939 }
940 
941 void
943 {
944  NS_LOG_FUNCTION (this);
947 }
948 
949 void
951 {
952  NS_LOG_FUNCTION (this);
953  RegularWifiMac::TxOk (hdr);
954  if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
956  {
957  NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
959  }
960  else if (hdr.IsBeacon () && GetPcfSupported ())
961  {
962  if (!m_cfPollingList.empty ())
963  {
964  SendCfPoll ();
965  }
966  else
967  {
968  SendCfEnd ();
969  }
970  }
971  else if (hdr.IsCfPoll ())
972  {
974  }
975 }
976 
977 void
979 {
980  NS_LOG_FUNCTION (this);
982 
983  if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
985  {
986  NS_LOG_DEBUG ("association failed with sta=" << hdr.GetAddr1 ());
988  }
989  else if (hdr.IsCfPoll ())
990  {
992  SendNextCfFrame ();
993  }
994 }
995 
996 void
998 {
999  NS_LOG_FUNCTION (this << packet << hdr);
1000  Mac48Address from = hdr->GetAddr2 ();
1001  if (hdr->IsData ())
1002  {
1003  Mac48Address bssid = hdr->GetAddr1 ();
1004  if (!hdr->IsFromDs ()
1005  && hdr->IsToDs ()
1006  && bssid == GetAddress ()
1007  && m_stationManager->IsAssociated (from))
1008  {
1009  Mac48Address to = hdr->GetAddr3 ();
1010  if (to == GetAddress ())
1011  {
1012  NS_LOG_DEBUG ("frame for me from=" << from);
1013  if (hdr->IsQosData ())
1014  {
1015  if (hdr->IsQosAmsdu ())
1016  {
1017  NS_LOG_DEBUG ("Received A-MSDU from=" << from << ", size=" << packet->GetSize ());
1018  DeaggregateAmsduAndForward (packet, hdr);
1019  packet = 0;
1020  }
1021  else
1022  {
1023  ForwardUp (packet, from, bssid);
1024  }
1025  }
1026  else if (hdr->HasData ())
1027  {
1028  ForwardUp (packet, from, bssid);
1029  }
1030  }
1031  else if (to.IsGroup ()
1032  || m_stationManager->IsAssociated (to))
1033  {
1034  NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to);
1035  Ptr<Packet> copy = packet->Copy ();
1036 
1037  //If the frame we are forwarding is of type QoS Data,
1038  //then we need to preserve the UP in the QoS control
1039  //header...
1040  if (hdr->IsQosData ())
1041  {
1042  ForwardDown (packet, from, to, hdr->GetQosTid ());
1043  }
1044  else
1045  {
1046  ForwardDown (packet, from, to);
1047  }
1048  ForwardUp (copy, from, to);
1049  }
1050  else
1051  {
1052  ForwardUp (packet, from, to);
1053  }
1054  }
1055  else if (hdr->IsFromDs ()
1056  && hdr->IsToDs ())
1057  {
1058  //this is an AP-to-AP frame
1059  //we ignore for now.
1060  NotifyRxDrop (packet);
1061  }
1062  else
1063  {
1064  //we can ignore these frames since
1065  //they are not targeted at the AP
1066  NotifyRxDrop (packet);
1067  }
1068  return;
1069  }
1070  else if (hdr->IsMgt ())
1071  {
1072  if (hdr->IsProbeReq ())
1073  {
1074  NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ());
1075  NS_LOG_DEBUG ("Probe request received from " << from << ": send probe response");
1076  SendProbeResp (from);
1077  return;
1078  }
1079  else if (hdr->GetAddr1 () == GetAddress ())
1080  {
1081  if (hdr->IsAssocReq ())
1082  {
1083  NS_LOG_DEBUG ("Association request received from " << from);
1084  //first, verify that the the station's supported
1085  //rate set is compatible with our Basic Rate set
1086  MgtAssocRequestHeader assocReq;
1087  packet->RemoveHeader (assocReq);
1088  CapabilityInformation capabilities = assocReq.GetCapabilities ();
1090  SupportedRates rates = assocReq.GetSupportedRates ();
1091  bool problem = false;
1092  bool isHtStation = false;
1093  bool isOfdmStation = false;
1094  bool isErpStation = false;
1095  bool isDsssStation = false;
1096  for (uint8_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
1097  {
1099  if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1100  {
1102  {
1103  isDsssStation = false;
1104  }
1105  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1106  {
1107  isErpStation = false;
1108  }
1109  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1110  {
1111  isOfdmStation = false;
1112  }
1113  if (isDsssStation == false && isErpStation == false && isOfdmStation == false)
1114  {
1115  problem = true;
1116  break;
1117  }
1118  }
1119  else
1120  {
1122  {
1123  isDsssStation = true;
1124  }
1125  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1126  {
1127  isErpStation = true;
1128  }
1129  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1130  {
1131  isOfdmStation = true;
1132  }
1133  }
1134  }
1135  m_stationManager->AddSupportedErpSlotTime (from, capabilities.IsShortSlotTime () && isErpStation);
1136  if (GetHtSupported ())
1137  {
1138  //check whether the HT STA supports all MCSs in Basic MCS Set
1139  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
1140  if (htcapabilities.IsSupportedMcs (0))
1141  {
1142  isHtStation = true;
1143  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1144  {
1146  if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1147  {
1148  problem = true;
1149  break;
1150  }
1151  }
1152  }
1153  }
1154  if (GetVhtSupported ())
1155  {
1156  //check whether the VHT STA supports all MCSs in Basic MCS Set
1157  VhtCapabilities vhtcapabilities = assocReq.GetVhtCapabilities ();
1158  if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
1159  {
1160  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1161  {
1163  if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1164  {
1165  problem = true;
1166  break;
1167  }
1168  }
1169  }
1170  }
1171  if (GetHeSupported ())
1172  {
1173  //check whether the HE STA supports all MCSs in Basic MCS Set
1174  HeCapabilities hecapabilities = assocReq.GetHeCapabilities ();
1175  if (hecapabilities.GetSupportedMcsAndNss () != 0)
1176  {
1177  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1178  {
1180  if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1181  {
1182  problem = true;
1183  break;
1184  }
1185  }
1186  }
1187  }
1188  if (problem)
1189  {
1190  NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send association response with an error status");
1191  SendAssocResp (hdr->GetAddr2 (), false, false);
1192  }
1193  else
1194  {
1195  NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1196  //record all its supported modes in its associated WifiRemoteStation
1197  for (uint8_t j = 0; j < m_phy->GetNModes (); j++)
1198  {
1199  WifiMode mode = m_phy->GetMode (j);
1200  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1201  {
1202  m_stationManager->AddSupportedMode (from, mode);
1203  }
1204  }
1205  if (GetPcfSupported () && capabilities.IsCfPollable ())
1206  {
1207  m_cfPollingList.push_back (from);
1208  if (m_itCfPollingList == m_cfPollingList.end ())
1209  {
1211  }
1212  }
1213  if (GetHtSupported ())
1214  {
1215  HtCapabilities htCapabilities = assocReq.GetHtCapabilities ();
1216  if (htCapabilities.IsSupportedMcs (0))
1217  {
1218  m_stationManager->AddStationHtCapabilities (from, htCapabilities);
1219  }
1220  }
1221  if (GetVhtSupported ())
1222  {
1223  VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilities ();
1224  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1225  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1226  {
1227  m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities);
1228  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1229  {
1230  WifiMode mcs = m_phy->GetMcs (i);
1231  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1232  {
1233  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1234  //here should add a control to add basic MCS when it is implemented
1235  }
1236  }
1237  }
1238  }
1239  if (GetHtSupported () || GetVhtSupported ())
1240  {
1241  ExtendedCapabilities extendedCapabilities = assocReq.GetExtendedCapabilities ();
1242  //TODO: to be completed
1243  }
1244  if (GetHeSupported ())
1245  {
1246  HeCapabilities heCapabilities = assocReq.GetHeCapabilities ();
1247  //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer
1248  m_stationManager->AddStationHeCapabilities (from, heCapabilities);
1249  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1250  {
1251  WifiMode mcs = m_phy->GetMcs (i);
1252  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1253  {
1254  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1255  //here should add a control to add basic MCS when it is implemented
1256  }
1257  }
1258  }
1260  if (!isHtStation)
1261  {
1262  m_nonHtStations.push_back (hdr->GetAddr2 ());
1263  m_nonHtStations.unique ();
1264  }
1265  if (!isErpStation && isDsssStation)
1266  {
1267  m_nonErpStations.push_back (hdr->GetAddr2 ());
1268  m_nonErpStations.unique ();
1269  }
1270  NS_LOG_DEBUG ("Send association response with success status");
1271  SendAssocResp (hdr->GetAddr2 (), true, false);
1272  }
1273  return;
1274  }
1275  else if (hdr->IsReassocReq ())
1276  {
1277  NS_LOG_DEBUG ("Reassociation request received from " << from);
1278  //first, verify that the the station's supported
1279  //rate set is compatible with our Basic Rate set
1280  MgtReassocRequestHeader reassocReq;
1281  packet->RemoveHeader (reassocReq);
1282  CapabilityInformation capabilities = reassocReq.GetCapabilities ();
1284  SupportedRates rates = reassocReq.GetSupportedRates ();
1285  bool problem = false;
1286  bool isHtStation = false;
1287  bool isOfdmStation = false;
1288  bool isErpStation = false;
1289  bool isDsssStation = false;
1290  for (uint8_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
1291  {
1293  if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1294  {
1296  {
1297  isDsssStation = false;
1298  }
1299  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1300  {
1301  isErpStation = false;
1302  }
1303  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1304  {
1305  isOfdmStation = false;
1306  }
1307  if (isDsssStation == false && isErpStation == false && isOfdmStation == false)
1308  {
1309  problem = true;
1310  break;
1311  }
1312  }
1313  else
1314  {
1316  {
1317  isDsssStation = true;
1318  }
1319  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1320  {
1321  isErpStation = true;
1322  }
1323  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1324  {
1325  isOfdmStation = true;
1326  }
1327  }
1328  }
1329  m_stationManager->AddSupportedErpSlotTime (from, capabilities.IsShortSlotTime () && isErpStation);
1330  if (GetHtSupported ())
1331  {
1332  //check whether the HT STA supports all MCSs in Basic MCS Set
1333  HtCapabilities htcapabilities = reassocReq.GetHtCapabilities ();
1334  if (htcapabilities.IsSupportedMcs (0))
1335  {
1336  isHtStation = true;
1337  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1338  {
1340  if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1341  {
1342  problem = true;
1343  break;
1344  }
1345  }
1346  }
1347  }
1348  if (GetVhtSupported ())
1349  {
1350  //check whether the VHT STA supports all MCSs in Basic MCS Set
1351  VhtCapabilities vhtcapabilities = reassocReq.GetVhtCapabilities ();
1352  if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
1353  {
1354  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1355  {
1357  if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1358  {
1359  problem = true;
1360  break;
1361  }
1362  }
1363  }
1364  }
1365  if (GetHeSupported ())
1366  {
1367  //check whether the HE STA supports all MCSs in Basic MCS Set
1368  HeCapabilities hecapabilities = reassocReq.GetHeCapabilities ();
1369  if (hecapabilities.GetSupportedMcsAndNss () != 0)
1370  {
1371  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1372  {
1374  if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1375  {
1376  problem = true;
1377  break;
1378  }
1379  }
1380  }
1381  }
1382  if (problem)
1383  {
1384  NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send reassociation response with an error status");
1385  SendAssocResp (hdr->GetAddr2 (), false, true);
1386  }
1387  else
1388  {
1389  NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1390  //update all its supported modes in its associated WifiRemoteStation
1391  for (uint8_t j = 0; j < m_phy->GetNModes (); j++)
1392  {
1393  WifiMode mode = m_phy->GetMode (j);
1394  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1395  {
1396  m_stationManager->AddSupportedMode (from, mode);
1397  }
1398  }
1399  if (GetHtSupported ())
1400  {
1401  HtCapabilities htCapabilities = reassocReq.GetHtCapabilities ();
1402  if (htCapabilities.IsSupportedMcs (0))
1403  {
1404  m_stationManager->AddStationHtCapabilities (from, htCapabilities);
1405  }
1406  }
1407  if (GetVhtSupported ())
1408  {
1409  VhtCapabilities vhtCapabilities = reassocReq.GetVhtCapabilities ();
1410  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1411  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1412  {
1413  m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities);
1414  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1415  {
1416  WifiMode mcs = m_phy->GetMcs (i);
1417  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1418  {
1419  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1420  //here should add a control to add basic MCS when it is implemented
1421  }
1422  }
1423  }
1424  }
1425  if (GetHtSupported () || GetVhtSupported ())
1426  {
1427  ExtendedCapabilities extendedCapabilities = reassocReq.GetExtendedCapabilities ();
1428  //TODO: to be completed
1429  }
1430  if (GetHeSupported ())
1431  {
1432  HeCapabilities heCapabilities = reassocReq.GetHeCapabilities ();
1433  //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer
1434  m_stationManager->AddStationHeCapabilities (from, heCapabilities);
1435  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1436  {
1437  WifiMode mcs = m_phy->GetMcs (i);
1438  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1439  {
1440  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1441  //here should add a control to add basic MCS when it is implemented
1442  }
1443  }
1444  }
1446  if (!isHtStation)
1447  {
1448  m_nonHtStations.push_back (hdr->GetAddr2 ());
1449  m_nonHtStations.unique ();
1450  }
1451  if (!isErpStation && isDsssStation)
1452  {
1453  m_nonErpStations.push_back (hdr->GetAddr2 ());
1454  m_nonErpStations.unique ();
1455  }
1456  NS_LOG_DEBUG ("Send reassociation response with success status");
1457  SendAssocResp (hdr->GetAddr2 (), true, true);
1458  }
1459  return;
1460  }
1461  else if (hdr->IsDisassociation ())
1462  {
1463  NS_LOG_DEBUG ("Disassociation received from " << from);
1465  for (std::map<uint16_t, Mac48Address>::const_iterator j = m_staList.begin (); j != m_staList.end (); j++)
1466  {
1467  if (j->second == from)
1468  {
1469  m_staList.erase (j);
1470  break;
1471  }
1472  }
1473  for (std::list<Mac48Address>::const_iterator j = m_nonErpStations.begin (); j != m_nonErpStations.end (); j++)
1474  {
1475  if ((*j) == from)
1476  {
1477  m_nonErpStations.erase (j);
1478  break;
1479  }
1480  }
1481  for (std::list<Mac48Address>::const_iterator j = m_nonHtStations.begin (); j != m_nonHtStations.end (); j++)
1482  {
1483  if ((*j) == from)
1484  {
1485  m_nonHtStations.erase (j);
1486  break;
1487  }
1488  }
1489  for (std::list<Mac48Address>::const_iterator j = m_cfPollingList.begin (); j != m_cfPollingList.end (); ++j)
1490  {
1491  if ((*j) == from)
1492  {
1493  m_cfPollingList.erase (j);
1494  break;
1495  }
1496  }
1497  return;
1498  }
1499  }
1500  }
1501 
1502  //Invoke the receive handler of our parent class to deal with any
1503  //other frames. Specifically, this will handle Block Ack-related
1504  //Management Action frames.
1505  RegularWifiMac::Receive (packet, hdr);
1506 }
1507 
1508 void
1510 {
1511  NS_LOG_FUNCTION (this << aggregatedPacket << hdr);
1513  for (MsduAggregator::DeaggregatedMsdusCI i = packets.begin ();
1514  i != packets.end (); ++i)
1515  {
1516  if ((*i).second.GetDestinationAddr () == GetAddress ())
1517  {
1518  ForwardUp ((*i).first, (*i).second.GetSourceAddr (),
1519  (*i).second.GetDestinationAddr ());
1520  }
1521  else
1522  {
1523  Mac48Address from = (*i).second.GetSourceAddr ();
1524  Mac48Address to = (*i).second.GetDestinationAddr ();
1525  NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
1526  ForwardDown ((*i).first, from, to, hdr->GetQosTid ());
1527  }
1528  }
1529 }
1530 
1531 void
1533 {
1534  NS_LOG_FUNCTION (this);
1536  m_beaconEvent.Cancel ();
1538  {
1540  {
1541  Time jitter = MicroSeconds (static_cast<int64_t> (m_beaconJitter->GetValue (0, 1) * (GetBeaconInterval ().GetMicroSeconds ())));
1542  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time " << jitter);
1544  }
1545  else
1546  {
1547  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time 0");
1549  }
1550  }
1552 }
1553 
1554 bool
1556 {
1557  bool useProtection = !m_nonErpStations.empty () && m_enableNonErpProtection;
1558  m_stationManager->SetUseNonErpProtection (useProtection);
1559  return useProtection;
1560 }
1561 
1562 bool
1564 {
1565  bool rifsMode = false;
1566  if (GetHtSupported () && !GetVhtSupported ()) //RIFS mode is forbidden for VHT
1567  {
1568  if (m_nonHtStations.empty () || !m_disableRifs)
1569  {
1570  rifsMode = true;
1571  }
1572  }
1573  if (GetRifsSupported () && rifsMode)
1574  {
1576  }
1577  else
1578  {
1580  }
1581  return rifsMode;
1582 }
1583 
1584 uint16_t
1586 {
1587  //Return the first free AID value between 1 and 2007
1588  for (uint16_t nextAid = 1; nextAid <= 2007; nextAid++)
1589  {
1590  if (m_staList.find (nextAid) == m_staList.end ())
1591  {
1592  return nextAid;
1593  }
1594  }
1595  NS_FATAL_ERROR ("No free association ID available!");
1596  return 0;
1597 }
1598 
1599 void
1601 {
1602  NS_LOG_FUNCTION (this);
1604  if (m_itCfPollingList == m_cfPollingList.end ())
1605  {
1607  }
1608 }
1609 
1610 } //namespace ns3
void SetRxHighestSupportedDataRate(uint16_t maxsupportedrate)
Set the receive highest supported data rate.
uint8_t GetNMcsSupported(Mac48Address address) const
Return the number of MCS supported by the station.
void DoInitialize(void)
Initialize() implementation.
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
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:807
void SendCfEnd(void)
Send a CF-End packet.
Definition: ap-wifi-mac.cc:942
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:335
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:194
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:102
void SendCfFrame(WifiMacType frameType, Mac48Address addr)
Sends CF frame to sta with address addr.
Definition: txop.cc:732
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:759
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.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
bool GetRifsMode(void) const
Return whether RIFS is allowed in the BSS.
ERP-OFDM PHY (19.5)
Definition: wifi-mode.h:54
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.
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 SetMaxVhtMcsPerNss(uint8_t nss, uint8_t maxVhtMcs)
Set the Basic VHT-MCS and NSS field in the VHT Operation information element by specifying the tuple ...
Ptr< Txop > m_txop
This holds a pointer to the TXOP instance for this WifiMac - used for transmission of frames to non-Q...
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set of the current AP.
Definition: ap-wifi-mac.cc:496
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:3523
uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: txop.cc:284
#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
bool GetShortPreambleSupported(Mac48Address address) const
Return whether the station supports short PLCP 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:831
HeOperation GetHeOperation(void) const
Return the HE operation of the current AP.
Definition: ap-wifi-mac.cc:692
Hold variables of type string.
Definition: string.h:41
#define min(a, b)
Definition: 80211b.c:42
bool GetShortGuardInterval(void) const
Return whether short guard interval is supported.
Definition: wifi-phy.cc:617
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
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: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.
bool IsCfPollable(void) const
Check if the CF-Pollable bit in the capability information field is set to 1.
uint8_t GetNBssMembershipSelectors(void) const
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
Definition: wifi-phy.cc:1320
void SetChannelAccessManager(const Ptr< ChannelAccessManager > manager)
Set ChannelAccessManager this Txop is associated to.
Definition: txop.cc:109
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
Get the is transmit MCS 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: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.
CfParameterSet GetCfParameterSet(void) const
Return the CF parameter set of the current AP.
Definition: ap-wifi-mac.cc:544
void SetCFPDurRemainingUs(uint64_t cfpdurremaining)
Set the CFP MaxDuration in microseconds.
bool GetRifsSupported(void) const
#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...
void SetVoAifsn(uint8_t aifsn)
Set the AC_VO AIFSN field in the EdcaParameterSet information element.
bool GetPcfSupported() const
Return whether the device supports PCF.
std::list< std::pair< Ptr< Packet >, AmsduSubframeHeader > >::const_iterator DeaggregatedMsdusCI
DeaggregatedMsdusCI typedef.
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:795
WifiMode GetBasicMcs(uint8_t i) const
Return the MCS at the given list index.
void SetSlot(Time slotTime)
static DeaggregatedMsdus Deaggregate(Ptr< Packet > aggregatedPacket)
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:242
The HT Operation Information ElementThis class knows how to serialise and deserialise the HT Operatio...
Definition: ht-operation.h:52
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
void SetPhase(uint8_t pcophase)
Set the PCO phase.
Time GetBeaconInterval(void) const
Definition: ap-wifi-mac.cc:159
virtual void SetPcfSupported(bool enable)
Enable or disable PCF capability support.
VHT PHY (Clause 22)
Definition: wifi-mode.h:60
bool CanStartNextPolling(void) const
Check if the next PCF transmission can fit in the remaining CFP duration.
Definition: txop.cc:804
Ptr< WifiPhy > m_phy
Wifi PHY.
uint16_t GetVhtOperationalChannelWidth(void) const
Determine the VHT operational channel width (in MHz).
Definition: ap-wifi-mac.cc:278
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)
bool IsCfPoll(void) const
Return true if the Type/Subtype is one of the possible CF-Poll headers.
uint8_t GetNBasicMcs(void) const
Return the number of basic MCS index.
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:747
void SetVoCWmin(uint32_t cwMin)
Set the AC_VO CWmin field in the EdcaParameterSet information element.
Video.
Definition: qos-utils.h:44
uint32_t GetMinCw(void) const
Return the minimum contention window size.
Definition: txop.cc:272
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
bool GetGreenfieldSupported(Mac48Address address) const
Return whether the station supports Greenfield or not.
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
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
bool GetShortSlotTimeSupported(void) const
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:572
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...
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:57
void SetStaChannelWidth(uint8_t stachannelwidth)
Set the STA channel width.
Definition: ht-operation.cc:93
bool IsMandatory(void) const
Definition: wifi-mode.cc:471
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
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 m_enableBeaconGeneration
Flag whether beacons are being generated.
Definition: ap-wifi-mac.h:330
bool GetShortPlcpPreambleSupported(void) const
Return whether short PLCP preamble is supported.
Definition: wifi-phy.cc:644
void SendAssocResp(Mac48Address to, bool success, bool isReassoc)
Forward an association or a reassociation response packet to the DCF.
Definition: ap-wifi-mac.cc:764
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
Definition: ap-wifi-mac.cc:173
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1263
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.
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
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:3517
void SetViAifsn(uint8_t aifsn)
Set the AC_VI AIFSN field in the EdcaParameterSet information element.
uint8_t GetNumberOfSupportedStreams(Mac48Address address) const
Return the number of spatial streams supported by the station.
Background.
Definition: qos-utils.h:42
void SetDualBeacon(uint8_t dualbeacon)
Set the dual beacon.
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.
void SetSuccess(void)
Set success bit to 0 (success).
Definition: status-code.cc:30
void SetCfpMaxDuration(Time duration)
Definition: mac-low.cc:352
bool GetVhtSupported(Mac48Address address) const
Return whether the station supports VHT or not.
bool GetErpSupported() const
Return whether the device supports ERP.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:220
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:596
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1381
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:370
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 SetEss(void)
Set the Extended Service Set (ESS) bit in the capability information field.
AttributeValue implementation for Time.
Definition: nstime.h:1076
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.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
bool GetVhtSupported() const
Return whether the device supports VHT.
bool IsBeacon(void) const
Return true if the header is a Beacon header.
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:45
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current AP.
Definition: ap-wifi-mac.cc:459
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:224
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.
VhtOperation GetVhtOperation(void) const
Return the VHT operation of the current AP.
Definition: ap-wifi-mac.cc:654
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.
virtual bool IsCfPeriod(void) const
This function indicates whether it is the CF period.
Definition: mac-low.cc:2969
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:224
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:620
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
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:31
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
void SetAddress(Mac48Address address)
bool GetShortPreambleEnabled(void) const
Determine whether short preamble should be enabled or not in the BSS.
Definition: ap-wifi-mac.cc:245
HT PHY (Clause 20)
Definition: wifi-mode.h:58
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.)
void SetViTxopLimit(uint16_t txop)
Set the AC_VI TXOP Limit field in the EdcaParameterSet information element.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
Ptr< Txop > m_beaconTxop
Dedicated Txop for beacons.
Definition: ap-wifi-mac.h:329
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
void SetRxMcsBitmask(uint8_t index)
Set the receive MCS bitmask.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities hecapabilities)
Records HE capabilities of the remote station.
bool IsAssociated(Mac48Address address) const
Return whether the station associated.
void SetPcfSupported(uint8_t pcfSupported)
Set PCF supported function.
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
void SetCurrentChannel(uint8_t currentChannel)
Set the Current Channel field in the DsssParameterSet information element.
std::list< Mac48Address > m_cfPollingList
List of all PCF stations currently associated to the AP.
Definition: ap-wifi-mac.h:338
void SendNextCfFrame(void)
Determine what is the next PCF frame and trigger its transmission.
Definition: ap-wifi-mac.cc:917
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:500
Ptr< MacLow > m_low
MacLow (RTS, CTS, DATA, ACK etc.)
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:463
Time GetCfpMaxDuration(void) const
Definition: mac-low.cc:438
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
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...
Definition: ap-wifi-mac.cc:997
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...
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
void SetCfPollable(void)
Set the CF-Pollable bit in the capability information field.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:363
Status code for association response.
Definition: status-code.h:31
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:334
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:608
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
void SetLinkUpCallback(Callback< void > linkUp)
void SetLinkUpCallback(Callback< void > linkUp)
Definition: ap-wifi-mac.cc:182
virtual void DoDispose()
Destructor implementation.
std::list< std::pair< Ptr< Packet >, AmsduSubframeHeader > > DeaggregatedMsdus
DeaggregatedMsdus typedef.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetCfpMaxDuration(Time duration)
Definition: ap-wifi-mac.cc:205
bool IsData(void) const
Return true if the Type is DATA.
address
Definition: first.py:37
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.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
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:278
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.
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:560
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.
void SetTxRxMcsSetUnequal(uint8_t txrxmcssetunequal)
Set the transmit / receive MCS set unequal.
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 transmit MCS supported.
bool IsShortPreamble(void) const
Check if the short preamble bit in the capability information field is set to 1.
void SetDsssSupported(uint8_t DsssSupported)
Set DSSS supported.
void SetMacLow(const Ptr< MacLow > low)
Set MacLow associated with this Txop.
Definition: txop.cc:123
Ssid GetSsid(void) const
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:1570
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:1077
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1415
void SetBeAci(uint8_t aci)
Set the AC_BE ACI field in the EdcaParameterSet information element.
bool IsGroup(void) const
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
void SetBkAci(uint8_t aci)
Set the AC_BK ACI field in the EdcaParameterSet information element.
DsssParameterSet GetDsssParameterSet(void) const
Return the DSSS Parameter Set that we support.
Definition: ap-wifi-mac.cc:446
void SetDualCtsProtection(uint8_t dualctsprotection)
Set the dual CTS protection.
HtOperation GetHtOperation(void) const
Return the HT operation of the current AP.
Definition: ap-wifi-mac.cc:559
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
ErpInformation GetErpInformation(void) const
Return the ERP information of the current AP.
Definition: ap-wifi-mac.cc:474
Mac48Address GetAddress(void) const
uint8_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3505
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:318
void SendProbeResp(Mac48Address to)
Forward a probe response packet to the DCF.
Definition: ap-wifi-mac.cc:708
uint8_t GetNBasicModes(void) const
Return the number of basic modes we support.
The DSSS Parameter SetThis class knows how to serialise and deserialise the DSSS Parameter Set...
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
WifiMode GetMode(uint8_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3511
void SetPcoActive(uint8_t pcoactive)
Set the PCO active.
uint8_t GetBssMembershipSelector(uint8_t selector) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1326
EventId m_cfpEvent
Event to generate one PCF frame.
Definition: ap-wifi-mac.h:332
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.
virtual void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:296
void TxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:978
bool IsMgt(void) const
Return true if the Type is Management.
bool GetHtSupported(Mac48Address address) const
Return whether the station supports HT or not.
void SetNonGfHtStasPresent(uint8_t nongfhtstaspresent)
Set the non GF HT STAs present.
void SendOneBeacon(void)
Forward a beacon packet to the beacon special DCF.
Definition: ap-wifi-mac.cc:842
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
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:187
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:262
bool GetHtSupported() const
Return whether the device supports HT.
void DoDispose(void)
Destructor implementation.
Definition: ap-wifi-mac.cc:122
void SetAddress(Mac48Address address)
Definition: ap-wifi-mac.cc:134
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:783
#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
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
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
void SetVoTxopLimit(uint16_t txop)
Set the AC_VO TXOP Limit field in the EdcaParameterSet information element.
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
virtual ~ApWifiMac()
Definition: ap-wifi-mac.cc:112
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:934
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:1030
The ErpInformation Information ElementThis class knows how to serialise and deserialise the ErpInform...
Time GetCfpMaxDuration(void) const
Definition: ap-wifi-mac.cc:166
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 IsNonGfHtStasPresent(void) const
Determine whether non-Greenfield HT stations are present or not.
Definition: ap-wifi-mac.cc:262
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:950
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:584
bool GetShortGuardInterval(Mac48Address address) const
Return whether the station supports HT/VHT short guard interval.
Time GetBeaconInterval(void) const
Definition: mac-low.cc:432
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 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.)
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 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
void SetTxOkCallback(TxOk callback)
Definition: txop.cc:137
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:337
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:478
bool SupportsSendFrom(void) const
Definition: ap-wifi-mac.cc:395
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:1296
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: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.
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.
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:156
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
uint16_t GetChannelWidthSupported(Mac48Address address) const
Return the channel width supported by the station.
Implement the header for management frames of type reassociation request.
Definition: mgt-headers.h:180
bool IsToDs(void) const
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:771
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1314
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
bool HasData(void) const
Return true if the header type is DATA and is not DATA_NULL.
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
Definition: ap-wifi-mac.cc:144
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
void SetChannelWidth(uint8_t channelWidth)
Set the Channel Width field in the VHT Operation information element.
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
virtual void TxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: txop.cc:290
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS ACK policy in the QoS control field.