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 "ap-wifi-mac.h"
24 #include "ns3/log.h"
25 #include "ns3/simulator.h"
26 #include "ns3/string.h"
27 #include "ns3/pointer.h"
28 #include "mac-low.h"
29 #include "mac-tx-middle.h"
30 
31 namespace ns3 {
32 
33 NS_LOG_COMPONENT_DEFINE ("ApWifiMac");
34 
35 NS_OBJECT_ENSURE_REGISTERED (ApWifiMac);
36 
37 TypeId
39 {
40  static TypeId tid = TypeId ("ns3::ApWifiMac")
42  .SetGroupName ("Wifi")
43  .AddConstructor<ApWifiMac> ()
44  .AddAttribute ("BeaconInterval",
45  "Delay between two beacons",
46  TimeValue (MicroSeconds (102400)),
49  MakeTimeChecker ())
50  .AddAttribute ("BeaconJitter",
51  "A uniform random variable to cause the initial beacon starting time (after simulation time 0) "
52  "to be distributed between 0 and the BeaconInterval.",
53  StringValue ("ns3::UniformRandomVariable"),
55  MakePointerChecker<UniformRandomVariable> ())
56  .AddAttribute ("EnableBeaconJitter",
57  "If beacons are enabled, whether to jitter the initial send event.",
58  BooleanValue (true),
61  .AddAttribute ("BeaconGeneration",
62  "Whether or not beacons are generated.",
63  BooleanValue (true),
67  .AddAttribute ("EnableNonErpProtection", "Whether or not protection mechanism should be used when non-ERP STAs are present within the BSS."
68  "This parameter is only used when ERP is supported by the AP.",
69  BooleanValue (true),
72  .AddAttribute ("RifsMode", "If non-HT STAs are detected, whether to force RIFS to be disabled within the BSS."
73  "This parameter is only used when HT is supported by the AP.",
74  BooleanValue (true),
77  ;
78  return tid;
79 }
80 
82  : m_enableBeaconGeneration (false)
83 {
84  NS_LOG_FUNCTION (this);
85  m_beaconDca = CreateObject<DcaTxop> ();
86  m_beaconDca->SetAifsn (1);
87  m_beaconDca->SetMinCw (0);
88  m_beaconDca->SetMaxCw (0);
89  m_beaconDca->SetLow (m_low);
90  m_beaconDca->SetManager (m_dcfManager);
91  m_beaconDca->SetTxMiddle (m_txMiddle);
92 
93  //Let the lower layers know that we are acting as an AP.
95 }
96 
98 {
99  NS_LOG_FUNCTION (this);
100  m_staList.clear ();
101  m_nonErpStations.clear ();
102  m_nonHtStations.clear ();
103 }
104 
105 void
107 {
108  NS_LOG_FUNCTION (this);
109  m_beaconDca->Dispose ();
110  m_beaconDca = 0;
111  m_enableBeaconGeneration = false;
114 }
115 
116 void
118 {
119  NS_LOG_FUNCTION (this << address);
120  //As an AP, our MAC address is also the BSSID. Hence we are
121  //overriding this function and setting both in our parent class.
122  RegularWifiMac::SetAddress (address);
123  RegularWifiMac::SetBssid (address);
124 }
125 
126 void
128 {
129  NS_LOG_FUNCTION (this << enable);
130  if (!enable)
131  {
133  }
134  else if (enable && !m_enableBeaconGeneration)
135  {
137  }
138  m_enableBeaconGeneration = enable;
139 }
140 
141 bool
143 {
144  NS_LOG_FUNCTION (this);
146 }
147 
148 Time
150 {
151  NS_LOG_FUNCTION (this);
152  return m_beaconInterval;
153 }
154 
155 void
157 {
158  NS_LOG_FUNCTION (this << stationManager);
159  m_beaconDca->SetWifiRemoteStationManager (stationManager);
161 }
162 
163 void
165 {
166  NS_LOG_FUNCTION (this << &linkUp);
168 
169  //The approach taken here is that, from the point of view of an AP,
170  //the link is always up, so we immediately invoke the callback if
171  //one is set
172  linkUp ();
173 }
174 
175 void
177 {
178  NS_LOG_FUNCTION (this << interval);
179  if ((interval.GetMicroSeconds () % 1024) != 0)
180  {
181  NS_LOG_WARN ("beacon interval should be multiple of 1024us (802.11 time unit), see IEEE Std. 802.11-2012");
182  }
183  m_beaconInterval = interval;
184 }
185 
186 void
188 {
189  NS_LOG_FUNCTION (this);
190  SendOneBeacon ();
191 }
192 
193 int64_t
194 ApWifiMac::AssignStreams (int64_t stream)
195 {
196  NS_LOG_FUNCTION (this << stream);
197  m_beaconJitter->SetStream (stream);
198  return 1;
199 }
200 
201 bool
203 {
204  if (m_nonErpStations.size () != 0)
205  {
206  return false;
207  }
208  if (m_erpSupported == true && GetShortSlotTimeSupported () == true)
209  {
210  for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
211  {
212  if (m_stationManager->GetShortSlotTimeSupported (*i) == false)
213  {
214  return false;
215  }
216  }
217  return true;
218  }
219  return false;
220 }
221 
222 bool
224 {
226  {
227  for (std::list<Mac48Address>::const_iterator i = m_nonErpStations.begin (); i != m_nonErpStations.end (); i++)
228  {
229  if (m_stationManager->GetShortPreambleSupported (*i) == false)
230  {
231  return false;
232  }
233  }
234  return true;
235  }
236  return false;
237 }
238 
239 bool
241 {
242  bool isNonGfHtStasPresent = false;
243  for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
244  {
245  if (m_stationManager->GetGreenfieldSupported (*i) == false)
246  {
247  isNonGfHtStasPresent = true;
248  break;
249  }
250  }
251  m_stationManager->SetUseGreenfieldProtection (isNonGfHtStasPresent);
252  return isNonGfHtStasPresent;
253 }
254 
255 uint8_t
257 {
258  uint8_t channelWidth = m_phy->GetChannelWidth ();
259  for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
260  {
262  {
263  if (m_stationManager->GetChannelWidthSupported (*i) < channelWidth)
264  {
265  channelWidth = m_stationManager->GetChannelWidthSupported (*i);
266  }
267  }
268  }
269  return channelWidth;
270 }
271 
272 void
274  Mac48Address to)
275 {
276  NS_LOG_FUNCTION (this << packet << from << to);
277  //If we are not a QoS AP then we definitely want to use AC_BE to
278  //transmit the packet. A TID of zero will map to AC_BE (through \c
279  //QosUtilsMapTidToAc()), so we use that as our default here.
280  uint8_t tid = 0;
281 
282  //If we are a QoS AP then we attempt to get a TID for this packet
283  if (m_qosSupported)
284  {
285  tid = QosUtilsGetTidForPacket (packet);
286  //Any value greater than 7 is invalid and likely indicates that
287  //the packet had no QoS tag, so we revert to zero, which'll
288  //mean that AC_BE is used.
289  if (tid > 7)
290  {
291  tid = 0;
292  }
293  }
294 
295  ForwardDown (packet, from, to, tid);
296 }
297 
298 void
300  Mac48Address to, uint8_t tid)
301 {
302  NS_LOG_FUNCTION (this << packet << from << to << static_cast<uint32_t> (tid));
303  WifiMacHeader hdr;
304 
305  //For now, an AP that supports QoS does not support non-QoS
306  //associations, and vice versa. In future the AP model should
307  //support simultaneously associated QoS and non-QoS STAs, at which
308  //point there will need to be per-association QoS state maintained
309  //by the association state machine, and consulted here.
310  if (m_qosSupported)
311  {
314  hdr.SetQosNoEosp ();
315  hdr.SetQosNoAmsdu ();
316  //Transmission of multiple frames in the same Polled TXOP is not supported for now
317  hdr.SetQosTxopLimit (0);
318  //Fill in the QoS control field in the MAC header
319  hdr.SetQosTid (tid);
320  }
321  else
322  {
323  hdr.SetTypeData ();
324  }
325 
327  {
328  hdr.SetNoOrder ();
329  }
330  hdr.SetAddr1 (to);
331  hdr.SetAddr2 (GetAddress ());
332  hdr.SetAddr3 (from);
333  hdr.SetDsFrom ();
334  hdr.SetDsNotTo ();
335 
336  if (m_qosSupported)
337  {
338  //Sanity check that the TID is valid
339  NS_ASSERT (tid < 8);
340  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
341  }
342  else
343  {
344  m_dca->Queue (packet, hdr);
345  }
346 }
347 
348 void
350 {
351  NS_LOG_FUNCTION (this << packet << to << from);
352  if (to.IsBroadcast () || m_stationManager->IsAssociated (to))
353  {
354  ForwardDown (packet, from, to);
355  }
356  else
357  {
358  NotifyTxDrop (packet);
359  }
360 }
361 
362 void
364 {
365  NS_LOG_FUNCTION (this << packet << to);
366  //We're sending this packet with a from address that is our own. We
367  //get that address from the lower MAC and make use of the
368  //from-spoofing Enqueue() method to avoid duplicated code.
369  Enqueue (packet, to, m_low->GetAddress ());
370 }
371 
372 bool
374 {
375  NS_LOG_FUNCTION (this);
376  return true;
377 }
378 
381 {
382  NS_LOG_FUNCTION (this);
383  SupportedRates rates;
384  //If it is an HT-AP or VHT-AP or HE-AP, then add the BSSMembershipSelectorSet
385  //The standard says that the BSSMembershipSelectorSet
386  //must have its MSB set to 1 (must be treated as a Basic Rate)
387  //Also the standard mentioned that at least 1 element should be included in the SupportedRates the rest can be in the ExtendedSupportedRates
389  {
390  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
391  {
393  }
394  }
395  //
396  //Send the set of supported rates and make sure that we indicate
397  //the Basic Rate set in this set of supported rates.
398  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
399  {
400  WifiMode mode = m_phy->GetMode (i);
401  uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ());
402  NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
403  rates.AddSupportedRate (modeDataRate);
404  //Add rates that are part of the BSSBasicRateSet (manufacturer dependent!)
405  //here we choose to add the mandatory rates to the BSSBasicRateSet,
406  //except for 802.11b where we assume that only the non HR-DSSS rates are part of the BSSBasicRateSet
407  if (mode.IsMandatory () && (mode.GetModulationClass () != WIFI_MOD_CLASS_HR_DSSS))
408  {
409  NS_LOG_DEBUG ("Adding basic mode " << mode.GetUniqueName ());
411  }
412  }
413  //set the basic rates
414  for (uint32_t j = 0; j < m_stationManager->GetNBasicModes (); j++)
415  {
417  uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ());
418  NS_LOG_DEBUG ("Setting basic rate " << mode.GetUniqueName ());
419  rates.SetBasicRate (modeDataRate);
420  }
421 
422  return rates;
423 }
424 
427 {
428  NS_LOG_FUNCTION (this);
429  DsssParameterSet dsssParameters;
430  if (m_dsssSupported)
431  {
432  dsssParameters.SetDsssSupported (1);
433  dsssParameters.SetCurrentChannel (m_phy->GetChannelNumber ());
434  }
435  return dsssParameters;
436 }
437 
440 {
441  NS_LOG_FUNCTION (this);
442  CapabilityInformation capabilities;
443  capabilities.SetShortPreamble (GetShortPreambleEnabled ());
444  capabilities.SetShortSlotTime (GetShortSlotTimeEnabled ());
445  return capabilities;
446 }
447 
450 {
451  NS_LOG_FUNCTION (this);
452  ErpInformation information;
453  information.SetErpSupported (1);
454  if (m_erpSupported)
455  {
456  information.SetNonErpPresent (!m_nonErpStations.empty ());
457  information.SetUseProtection (GetUseNonErpProtection ());
459  {
460  information.SetBarkerPreambleMode (0);
461  }
462  else
463  {
464  information.SetBarkerPreambleMode (1);
465  }
466  }
467  return information;
468 }
469 
472 {
473  NS_LOG_FUNCTION (this);
474  EdcaParameterSet edcaParameters;
475  if (m_qosSupported)
476  {
477  edcaParameters.SetQosSupported (1);
478  Ptr<EdcaTxopN> edca;
479  Time txopLimit;
480 
481  edca = m_edca.find (AC_BE)->second;
482  txopLimit = edca->GetTxopLimit ();
483  edcaParameters.SetBeAci (0);
484  edcaParameters.SetBeCWmin (edca->GetMinCw ());
485  edcaParameters.SetBeCWmax (edca->GetMaxCw ());
486  edcaParameters.SetBeAifsn (edca->GetAifsn ());
487  edcaParameters.SetBeTXOPLimit (txopLimit.GetMicroSeconds () / 32);
488 
489  edca = m_edca.find (AC_BK)->second;
490  txopLimit = edca->GetTxopLimit ();
491  edcaParameters.SetBkAci (1);
492  edcaParameters.SetBkCWmin (edca->GetMinCw ());
493  edcaParameters.SetBkCWmax (edca->GetMaxCw ());
494  edcaParameters.SetBkAifsn (edca->GetAifsn ());
495  edcaParameters.SetBkTXOPLimit (txopLimit.GetMicroSeconds () / 32);
496 
497  edca = m_edca.find (AC_VI)->second;
498  txopLimit = edca->GetTxopLimit ();
499  edcaParameters.SetViAci (2);
500  edcaParameters.SetViCWmin (edca->GetMinCw ());
501  edcaParameters.SetViCWmax (edca->GetMaxCw ());
502  edcaParameters.SetViAifsn (edca->GetAifsn ());
503  edcaParameters.SetViTXOPLimit (txopLimit.GetMicroSeconds () / 32);
504 
505  edca = m_edca.find (AC_VO)->second;
506  txopLimit = edca->GetTxopLimit ();
507  edcaParameters.SetVoAci (3);
508  edcaParameters.SetVoCWmin (edca->GetMinCw ());
509  edcaParameters.SetVoCWmax (edca->GetMaxCw ());
510  edcaParameters.SetVoAifsn (edca->GetAifsn ());
511  edcaParameters.SetVoTXOPLimit (txopLimit.GetMicroSeconds () / 32);
512  }
513  return edcaParameters;
514 }
515 
518 {
519  NS_LOG_FUNCTION (this);
520  HtOperation operation;
521  if (m_htSupported)
522  {
523  operation.SetHtSupported (1);
524  operation.SetRifsMode (GetRifsMode ());
526  if (m_nonHtStations.empty ())
527  {
528  operation.SetHtProtection (NO_PROTECTION);
529  }
530  else
531  {
533  }
534  }
535  return operation;
536 }
537 
540 {
541  NS_LOG_FUNCTION (this);
542  VhtOperation operation;
543  if (m_vhtSupported)
544  {
545  operation.SetVhtSupported (1);
546  uint8_t channelWidth = GetVhtOperationalChannelWidth ();
547  if (channelWidth == 160)
548  {
549  operation.SetChannelWidth (2);
550  }
551  else if (channelWidth == 80)
552  {
553  operation.SetChannelWidth (1);
554  }
555  else
556  {
557  operation.SetChannelWidth (0);
558  }
559  for (uint8_t nss = 1; nss <= 8; nss++)
560  {
561  uint8_t maxMcs;
562  if (nss <= m_phy->GetMaxSupportedRxSpatialStreams ())
563  {
564  maxMcs = 9; //TBD: hardcode to 9 for now since we assume all MCS values are supported
565  }
566  else
567  {
568  maxMcs = 0;
569  }
570  operation.SetMaxVhtMcsPerNss (nss, maxMcs);
571  }
572 
573  }
574  return operation;
575 }
576 
577 void
579 {
580  NS_LOG_FUNCTION (this << to);
581  WifiMacHeader hdr;
582  hdr.SetProbeResp ();
583  hdr.SetAddr1 (to);
584  hdr.SetAddr2 (GetAddress ());
585  hdr.SetAddr3 (GetAddress ());
586  hdr.SetDsNotFrom ();
587  hdr.SetDsNotTo ();
588  hdr.SetNoOrder ();
589  Ptr<Packet> packet = Create<Packet> ();
591  probe.SetSsid (GetSsid ());
592  probe.SetSupportedRates (GetSupportedRates ());
593  probe.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
594  probe.SetCapabilities (GetCapabilities ());
597  if (m_dsssSupported)
598  {
599  probe.SetDsssParameterSet (GetDsssParameterSet ());
600  }
601  if (m_erpSupported)
602  {
603  probe.SetErpInformation (GetErpInformation ());
604  }
605  if (m_qosSupported)
606  {
607  probe.SetEdcaParameterSet (GetEdcaParameterSet ());
608  }
610  {
611  probe.SetHtCapabilities (GetHtCapabilities ());
612  probe.SetHtOperation (GetHtOperation ());
613  }
615  {
616  probe.SetVhtCapabilities (GetVhtCapabilities ());
617  probe.SetVhtOperation (GetVhtOperation ());
618  }
619  if (m_heSupported)
620  {
621  probe.SetHeCapabilities (GetHeCapabilities ());
622  }
623  packet->AddHeader (probe);
624 
625  //The standard is not clear on the correct queue for management
626  //frames if we are a QoS AP. The approach taken here is to always
627  //use the DCF for these regardless of whether we have a QoS
628  //association or not.
629  m_dca->Queue (packet, hdr);
630 }
631 
632 void
634 {
635  NS_LOG_FUNCTION (this << to << success);
636  WifiMacHeader hdr;
637  hdr.SetAssocResp ();
638  hdr.SetAddr1 (to);
639  hdr.SetAddr2 (GetAddress ());
640  hdr.SetAddr3 (GetAddress ());
641  hdr.SetDsNotFrom ();
642  hdr.SetDsNotTo ();
643  hdr.SetNoOrder ();
644  Ptr<Packet> packet = Create<Packet> ();
646  StatusCode code;
647  if (success)
648  {
649  code.SetSuccess ();
650  m_staList.push_back (to);
651  }
652  else
653  {
654  code.SetFailure ();
655  }
656  assoc.SetSupportedRates (GetSupportedRates ());
657  assoc.SetStatusCode (code);
658  assoc.SetCapabilities (GetCapabilities ());
659  if (m_erpSupported)
660  {
661  assoc.SetErpInformation (GetErpInformation ());
662  }
663  if (m_qosSupported)
664  {
665  assoc.SetEdcaParameterSet (GetEdcaParameterSet ());
666  }
668  {
669  assoc.SetHtCapabilities (GetHtCapabilities ());
670  assoc.SetHtOperation (GetHtOperation ());
671  }
673  {
674  assoc.SetVhtCapabilities (GetVhtCapabilities ());
675  assoc.SetVhtOperation (GetVhtOperation ());
676  }
677  if (m_heSupported)
678  {
679  assoc.SetHeCapabilities (GetHeCapabilities ());
680  }
681  packet->AddHeader (assoc);
682 
683  //The standard is not clear on the correct queue for management
684  //frames if we are a QoS AP. The approach taken here is to always
685  //use the DCF for these regardless of whether we have a QoS
686  //association or not.
687  m_dca->Queue (packet, hdr);
688 }
689 
690 void
692 {
693  NS_LOG_FUNCTION (this);
694  WifiMacHeader hdr;
695  hdr.SetBeacon ();
697  hdr.SetAddr2 (GetAddress ());
698  hdr.SetAddr3 (GetAddress ());
699  hdr.SetDsNotFrom ();
700  hdr.SetDsNotTo ();
701  hdr.SetNoOrder ();
702  Ptr<Packet> packet = Create<Packet> ();
703  MgtBeaconHeader beacon;
704  beacon.SetSsid (GetSsid ());
705  beacon.SetSupportedRates (GetSupportedRates ());
706  beacon.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
707  beacon.SetCapabilities (GetCapabilities ());
710  if (m_dsssSupported)
711  {
712  beacon.SetDsssParameterSet (GetDsssParameterSet ());
713  }
714  if (m_erpSupported)
715  {
716  beacon.SetErpInformation (GetErpInformation ());
717  }
718  if (m_qosSupported)
719  {
720  beacon.SetEdcaParameterSet (GetEdcaParameterSet ());
721  }
723  {
724  beacon.SetHtCapabilities (GetHtCapabilities ());
725  beacon.SetHtOperation (GetHtOperation ());
726  }
728  {
729  beacon.SetVhtCapabilities (GetVhtCapabilities ());
730  beacon.SetVhtOperation (GetVhtOperation ());
731  }
732  if (m_heSupported)
733  {
734  beacon.SetHeCapabilities (GetHeCapabilities ());
735  }
736  packet->AddHeader (beacon);
737 
738  //The beacon has it's own special queue, so we load it in there
739  m_beaconDca->Queue (packet, hdr);
741 
742  //If a STA that does not support Short Slot Time associates,
743  //the AP shall use long slot time beginning at the first Beacon
744  //subsequent to the association of the long slot time STA.
745  if (m_erpSupported)
746  {
747  if (GetShortSlotTimeEnabled () == true)
748  {
749  //Enable short slot time
750  SetSlot (MicroSeconds (9));
751  }
752  else
753  {
754  //Disable short slot time
755  SetSlot (MicroSeconds (20));
756  }
757  }
758 }
759 
760 void
762 {
763  NS_LOG_FUNCTION (this);
764  RegularWifiMac::TxOk (hdr);
765 
766  if (hdr.IsAssocResp ()
768  {
769  NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
771  }
772 }
773 
774 void
776 {
777  NS_LOG_FUNCTION (this);
779 
780  if (hdr.IsAssocResp ()
782  {
783  NS_LOG_DEBUG ("assoc failed with sta=" << hdr.GetAddr1 ());
785  }
786 }
787 
788 void
790 {
791  NS_LOG_FUNCTION (this << packet << hdr);
792 
793  Mac48Address from = hdr->GetAddr2 ();
794 
795  if (hdr->IsData ())
796  {
797  Mac48Address bssid = hdr->GetAddr1 ();
798  if (!hdr->IsFromDs ()
799  && hdr->IsToDs ()
800  && bssid == GetAddress ()
801  && m_stationManager->IsAssociated (from))
802  {
803  Mac48Address to = hdr->GetAddr3 ();
804  if (to == GetAddress ())
805  {
806  NS_LOG_DEBUG ("frame for me from=" << from);
807  if (hdr->IsQosData ())
808  {
809  if (hdr->IsQosAmsdu ())
810  {
811  NS_LOG_DEBUG ("Received A-MSDU from=" << from << ", size=" << packet->GetSize ());
812  DeaggregateAmsduAndForward (packet, hdr);
813  packet = 0;
814  }
815  else
816  {
817  ForwardUp (packet, from, bssid);
818  }
819  }
820  else
821  {
822  ForwardUp (packet, from, bssid);
823  }
824  }
825  else if (to.IsGroup ()
827  {
828  NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to);
829  Ptr<Packet> copy = packet->Copy ();
830 
831  //If the frame we are forwarding is of type QoS Data,
832  //then we need to preserve the UP in the QoS control
833  //header...
834  if (hdr->IsQosData ())
835  {
836  ForwardDown (packet, from, to, hdr->GetQosTid ());
837  }
838  else
839  {
840  ForwardDown (packet, from, to);
841  }
842  ForwardUp (copy, from, to);
843  }
844  else
845  {
846  ForwardUp (packet, from, to);
847  }
848  }
849  else if (hdr->IsFromDs ()
850  && hdr->IsToDs ())
851  {
852  //this is an AP-to-AP frame
853  //we ignore for now.
854  NotifyRxDrop (packet);
855  }
856  else
857  {
858  //we can ignore these frames since
859  //they are not targeted at the AP
860  NotifyRxDrop (packet);
861  }
862  return;
863  }
864  else if (hdr->IsMgt ())
865  {
866  if (hdr->IsProbeReq ())
867  {
868  NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ());
869  SendProbeResp (from);
870  return;
871  }
872  else if (hdr->GetAddr1 () == GetAddress ())
873  {
874  if (hdr->IsAssocReq ())
875  {
876  //first, verify that the the station's supported
877  //rate set is compatible with our Basic Rate set
878  MgtAssocRequestHeader assocReq;
879  packet->RemoveHeader (assocReq);
880  CapabilityInformation capabilities = assocReq.GetCapabilities ();
882  SupportedRates rates = assocReq.GetSupportedRates ();
883  bool problem = false;
884  bool isHtStation = false;
885  bool isOfdmStation = false;
886  bool isErpStation = false;
887  bool isDsssStation = false;
888  for (uint32_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
889  {
891  if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
892  {
894  {
895  isDsssStation = false;
896  }
897  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
898  {
899  isErpStation = false;
900  }
901  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
902  {
903  isOfdmStation = false;
904  }
905  if (isDsssStation == false && isErpStation == false && isOfdmStation == false)
906  {
907  problem = true;
908  break;
909  }
910  }
911  else
912  {
914  {
915  isDsssStation = true;
916  }
917  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
918  {
919  isErpStation = true;
920  }
921  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
922  {
923  isOfdmStation = true;
924  }
925  }
926  }
927  m_stationManager->AddSupportedErpSlotTime (from, capabilities.IsShortSlotTime () && isErpStation);
928  if (m_htSupported)
929  {
930  //check whether the HT STA supports all MCSs in Basic MCS Set
931  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
932  if (htcapabilities.IsSupportedMcs (0))
933  {
934  isHtStation = true;
935  for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
936  {
938  if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
939  {
940  problem = true;
941  break;
942  }
943  }
944  }
945  }
946  if (m_vhtSupported)
947  {
948  //check whether the VHT STA supports all MCSs in Basic MCS Set
949  VhtCapabilities vhtcapabilities = assocReq.GetVhtCapabilities ();
950  if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
951  {
952  for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
953  {
955  if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
956  {
957  problem = true;
958  break;
959  }
960  }
961  }
962  }
963  if (m_heSupported)
964  {
965  //check whether the HE STA supports all MCSs in Basic MCS Set
966  HeCapabilities hecapabilities = assocReq.GetHeCapabilities ();
967  if (hecapabilities.GetSupportedMcsAndNss () != 0)
968  {
969  for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
970  {
972  if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
973  {
974  problem = true;
975  break;
976  }
977  }
978  }
979  }
980  if (problem)
981  {
982  //One of the Basic Rate set mode is not
983  //supported by the station. So, we return an assoc
984  //response with an error status.
985  SendAssocResp (hdr->GetAddr2 (), false);
986  }
987  else
988  {
989  //station supports all rates in Basic Rate Set.
990  //record all its supported modes in its associated WifiRemoteStation
991  for (uint32_t j = 0; j < m_phy->GetNModes (); j++)
992  {
993  WifiMode mode = m_phy->GetMode (j);
994  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
995  {
996  m_stationManager->AddSupportedMode (from, mode);
997  }
998  }
999  if (m_htSupported)
1000  {
1001  HtCapabilities htCapabilities = assocReq.GetHtCapabilities ();
1002  if (htCapabilities.IsSupportedMcs (0))
1003  {
1004  m_stationManager->AddStationHtCapabilities (from, htCapabilities);
1005  for (uint32_t j = 0; j < m_phy->GetNMcs (); j++)
1006  {
1007  WifiMode mcs = m_phy->GetMcs (j);
1008  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1009  {
1010  m_stationManager->AddSupportedMcs (from, mcs);
1011  }
1012  }
1013  }
1014  }
1015  if (m_vhtSupported)
1016  {
1017  VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilities ();
1018  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1019  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1020  {
1021  m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities);
1022  for (uint32_t i = 0; i < m_phy->GetNMcs (); i++)
1023  {
1024  WifiMode mcs = m_phy->GetMcs (i);
1025  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1026  {
1027  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1028  //here should add a control to add basic MCS when it is implemented
1029  }
1030  }
1031  }
1032  }
1033  if (m_heSupported)
1034  {
1035  HeCapabilities heCapabilities = assocReq.GetHeCapabilities ();
1036  //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer
1037  m_stationManager->AddStationHeCapabilities (from, heCapabilities);
1038  for (uint32_t i = 0; i < m_phy->GetNMcs (); i++)
1039  {
1040  WifiMode mcs = m_phy->GetMcs (i);
1041  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1042  {
1043  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1044  //here should add a control to add basic MCS when it is implemented
1045  }
1046  }
1047  }
1049  if (!isHtStation)
1050  {
1051  m_nonHtStations.push_back (hdr->GetAddr2 ());
1052  }
1053  if (!isErpStation && isDsssStation)
1054  {
1055  m_nonErpStations.push_back (hdr->GetAddr2 ());
1056  }
1057  // send assoc response with success status.
1058  SendAssocResp (hdr->GetAddr2 (), true);
1059  }
1060  return;
1061  }
1062  else if (hdr->IsDisassociation ())
1063  {
1065  for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
1066  {
1067  if ((*i) == from)
1068  {
1069  m_staList.erase (i);
1070  break;
1071  }
1072  }
1073  for (std::list<Mac48Address>::const_iterator j = m_nonErpStations.begin (); j != m_nonErpStations.end (); j++)
1074  {
1075  if ((*j) == from)
1076  {
1077  m_nonErpStations.erase (j);
1078  break;
1079  }
1080  }
1081  for (std::list<Mac48Address>::const_iterator j = m_nonHtStations.begin (); j != m_nonHtStations.end (); j++)
1082  {
1083  if ((*j) == from)
1084  {
1085  m_nonHtStations.erase (j);
1086  break;
1087  }
1088  }
1089  return;
1090  }
1091  }
1092  }
1093 
1094  //Invoke the receive handler of our parent class to deal with any
1095  //other frames. Specifically, this will handle Block Ack-related
1096  //Management Action frames.
1097  RegularWifiMac::Receive (packet, hdr);
1098 }
1099 
1100 void
1102  const WifiMacHeader *hdr)
1103 {
1104  NS_LOG_FUNCTION (this << aggregatedPacket << hdr);
1106  MsduAggregator::Deaggregate (aggregatedPacket);
1107 
1108  for (MsduAggregator::DeaggregatedMsdusCI i = packets.begin ();
1109  i != packets.end (); ++i)
1110  {
1111  if ((*i).second.GetDestinationAddr () == GetAddress ())
1112  {
1113  ForwardUp ((*i).first, (*i).second.GetSourceAddr (),
1114  (*i).second.GetDestinationAddr ());
1115  }
1116  else
1117  {
1118  Mac48Address from = (*i).second.GetSourceAddr ();
1119  Mac48Address to = (*i).second.GetDestinationAddr ();
1120  NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
1121  ForwardDown ((*i).first, from, to, hdr->GetQosTid ());
1122  }
1123  }
1124 }
1125 
1126 void
1128 {
1129  NS_LOG_FUNCTION (this);
1130  m_beaconDca->Initialize ();
1131  m_beaconEvent.Cancel ();
1133  {
1135  {
1136  int64_t jitter = m_beaconJitter->GetValue (0, m_beaconInterval.GetMicroSeconds ());
1137  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time " << jitter << " microseconds");
1139  }
1140  else
1141  {
1142  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time 0");
1144  }
1145  }
1147 }
1148 
1149 bool
1151 {
1152  bool useProtection = !m_nonErpStations.empty () && m_enableNonErpProtection;
1153  m_stationManager->SetUseNonErpProtection (useProtection);
1154  return useProtection;
1155 }
1156 
1157 bool
1159 {
1160  bool rifsMode = false;
1161  if (m_htSupported && !m_vhtSupported) //RIFS mode is forbidden for VHT
1162  {
1163  if (m_nonHtStations.empty () || !m_disableRifs)
1164  {
1165  rifsMode = true;
1166  }
1167  }
1168  if (GetRifsSupported () && rifsMode)
1169  {
1171  }
1172  else
1173  {
1175  }
1176  return rifsMode;
1177 }
1178 
1179 } //namespace ns3
void DoInitialize(void)
Initialize() implementation.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:267
Ptr< DcfManager > m_dcfManager
DCF manager (access to channel)
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set of the current AP.
Definition: ap-wifi-mac.cc:471
uint32_t GetVhtCapabilitiesInfo() const
Return the VHT Capabilties 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:1496
uint32_t GetMaxCw(void) const
Return the maximum contention window size.
Definition: dca-txop.cc:201
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:176
void AddSupportedRate(uint32_t bs)
Add the given rate to the supported rates.
void SetErpSupported(uint8_t erpSupported)
Set the ERP supported field.
uint32_t GetNBssMembershipSelectors(void) const
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
Definition: wifi-phy.cc:1351
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 AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
Implement the header for management frames of type association request.
Definition: mgt-headers.h:45
#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 GetGreenfieldSupported(Mac48Address address) const
Return whether the station supports Greenfield or not.
ERP-OFDM PHY (19.5)
Definition: wifi-mode.h:54
AttributeValue implementation for Boolean.
Definition: boolean.h:36
void SetMaxVhtMcsPerNss(uint8_t nss, uint8_t maxVhtMcs)
Set the Basic VHT-MCS and NSS field in the VHT Operation information element by specifying the tuple ...
void SetBkCWmin(uint8_t cwMin)
Set the AC_BK CWmin field in the EdcaParameterSet information element.
void SetType(WifiMacType type)
Set Type/Subtype values with the correct values depending on the given type.
#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:301
Hold variables of type string.
Definition: string.h:41
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:194
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:426
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 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.
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
The VHT Operation Information ElementThis class knows how to serialise and deserialise the VHT Operat...
Definition: vht-operation.h:37
#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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
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:796
std::list< std::pair< Ptr< Packet >, AmsduSubframeHeader > >::const_iterator DeaggregatedMsdusCI
DeaggregatedMsdusCI typedef.
bool IsBroadcast(void) const
void SetSlot(Time slotTime)
static DeaggregatedMsdus Deaggregate(Ptr< Packet > aggregatedPacket)
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:283
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
uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: dca-txop.cc:207
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:3553
void SendAssocResp(Mac48Address to, bool success)
Forward an association response packet to the DCF.
Definition: ap-wifi-mac.cc:633
uint8_t GetVhtOperationalChannelWidth(void) const
Determine the VHT operational channel width (in MHz).
Definition: ap-wifi-mac.cc:256
bool SupportsSendFrom(void) const
Definition: ap-wifi-mac.cc:373
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.
Ptr< DcaTxop > m_beaconDca
Dedicated DcaTxop for beacons.
Definition: ap-wifi-mac.h:291
HR/DSSS PHY (Clause 18)
Definition: wifi-mode.h:48
void SetHtProtection(uint8_t htprotection)
Set the HT protection.
void SetProbeResp(void)
Set Type/Subtype values for a probe response header.
Ssid GetSsid(void) const
Video.
Definition: qos-utils.h:45
The Supported Rates Information ElementThis class knows how to serialise and deserialise the Supporte...
void SetBarkerPreambleMode(uint8_t barkerPreambleMode)
Set the Barker_Preamble_Mode field in the ErpInformation information element.
Voice.
Definition: qos-utils.h:47
Best Effort.
Definition: qos-utils.h:41
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:458
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 capability of the device.
Capability information.
uint32_t GetBssMembershipSelector(uint32_t selector) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1357
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 capability 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:62
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
bool GetUseNonErpProtection(void) const
Return whether protection for non-ERP stations is used in the 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:293
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
Definition: ap-wifi-mac.cc:156
void Enqueue(Ptr< const Packet > packet, Mac48Address to)
Definition: ap-wifi-mac.cc:363
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:538
void SetBssid(Mac48Address bssid)
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:43
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: dca-txop.cc:213
void ForwardUp(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
base class for all MAC-level wifi objects.
void SetSuccess(void)
Set success bit to 0 (success).
Definition: status-code.cc:30
bool m_qosSupported
This Boolean is set true iff this WifiMac is to model 802.11e/WMM style Quality of Service...
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:1375
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:349
void SetBeacon(void)
Set Type/Subtype values for a beacon header.
AttributeValue implementation for Time.
Definition: nstime.h:1055
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
Ptr< DcaTxop > m_dca
This holds a pointer to the DCF instance for this WifiMac - used for transmission of frames to non-Qo...
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:490
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
The IEEE 802.11ac VHT Capabilities.
static TypeId GetTypeId(void)
Get the type ID.
Definition: ap-wifi-mac.cc:38
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:265
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:273
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.
uint64_t GetDataRate(uint8_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:143
WifiMode GetBasicMode(uint32_t i) const
Return a basic mode from the set of basic modes.
bool GetShortPreambleEnabled(void) const
Determine whether short preamble should be enabled or not in the BSS.
Definition: ap-wifi-mac.cc:223
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
Records HT capabilities of the remote station.
bool m_vhtSupported
This Boolean is set true iff this WifiMac is to model 802.11ac.
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:300
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Definition: qos-utils.cc:28
void SetAddress(Mac48Address address)
void SetBeCWmax(uint8_t cwMax)
Set the AC_BE CWmax field in the EdcaParameterSet information element.
HT PHY (Clause 20)
Definition: wifi-mode.h:58
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:465
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:450
static Mac48Address GetBroadcast(void)
void SetBeCWmin(uint8_t cwMin)
Set the AC_BE CWmin field in the EdcaParameterSet information element.
EventId m_beaconEvent
Event to generate one beacon.
Definition: ap-wifi-mac.h:294
uint8_t GetChannelWidthSupported(Mac48Address address) const
Return the channel width supported by the station.
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:529
void SetViCWmin(uint8_t cwMin)
Set the AC_VI CWmin field in the EdcaParameterSet information element.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities hecapabilities)
Records HE capabilities of the remote station.
uint32_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3541
bool IsMgt(void) const
Return true if the Type is Management.
bool m_heSupported
This Boolean is set true iff this WifiMac is to model 802.11ax.
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:517
Ptr< MacLow > m_low
MacLow (RTS, CTS, DATA, ACK etc.)
uint32_t GetNBasicMcs(void) const
Return the number of basic MCS index.
HtCapabilities GetHtCapabilities(void) const
Return the HT capability of the device.
void SetBasicRate(uint32_t bs)
Set the given rate to basic rates.
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:789
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 SetQosTid(uint8_t tid)
Set the TID for the QoS header.
std::list< Mac48Address > m_staList
List of all stations currently associated to the AP.
Definition: ap-wifi-mac.h:297
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:3559
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:275
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 AddBssMembershipSelectorRate(uint32_t bs)
Add a special value to the supported rate set, corresponding to a BSS membership selector.
void SetLinkUpCallback(Callback< void > linkUp)
Definition: ap-wifi-mac.cc:164
virtual void DoDispose()
Destructor implementation.
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:514
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.
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...
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 AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
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.
an EUI-48 address
Definition: mac48-address.h:43
WifiMode GetBasicMcs(uint32_t i) const
Return the MCS at the given list index.
void SetBkAifsn(uint8_t aifsn)
Set the AC_BK AIFSN field in the EdcaParameterSet information element.
bool IsAssociated(Mac48Address address) const
Return whether the station associated.
void SetDsssSupported(uint8_t DsssSupported)
Set DSSS supported.
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:1564
void SetBkTXOPLimit(uint16_t txop)
Set the AC_BK TXOP Limit field in the EdcaParameterSet information element.
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:1056
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:240
bool GetBeaconGeneration(void) const
Return whether the AP is generating beacons.
Definition: ap-wifi-mac.cc:142
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:44
void SetBkAci(uint8_t aci)
Set the AC_BK ACI field in the EdcaParameterSet information element.
void AddSupportedPlcpPreamble(Mac48Address address, bool isShortPreambleSupported)
Record whether the short PLCP preamble is supported by the station.
bool m_htSupported
This Boolean is set true iff this WifiMac is to model 802.11n.
Implement the header for management frames of type association response.
Definition: mgt-headers.h:163
void SendProbeResp(Mac48Address to)
Forward a probe response packet to the DCF.
Definition: ap-wifi-mac.cc:578
uint8_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1304
The DSSS Parameter SetThis class knows how to serialise and deserialise the DSSS Parameter Set...
void SetAssocResp(void)
Set Type/Subtype values for an association response header.
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates...
Definition: ap-wifi-mac.cc:380
bool IsShortSlotTime(void) const
Check if the short slot time in the capability information field is set to 1.
uint32_t GetNBasicModes(void) const
Return the number of basic modes we support.
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.
void TxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:775
void SetNonGfHtStasPresent(uint8_t nongfhtstaspresent)
Set the non GF HT STAs present.
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:691
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS DATA...
void AddSupportedErpSlotTime(Mac48Address address, bool isShortSlotTimeSupported)
Record whether the short ERP slot time is supported by the station.
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:261
void DoDispose(void)
Destructor implementation.
Definition: ap-wifi-mac.cc:106
void SetAddress(Mac48Address address)
Definition: ap-wifi-mac.cc:117
ErpInformation GetErpInformation(void) const
Return the ERP information of the current AP.
Definition: ap-wifi-mac.cc:449
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:269
Mac48Address GetAddress(void) const
void SetTypeData(void)
Set Type/Subtype values for a data packet with no subtype equal to 0.
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:295
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current AP.
Definition: ap-wifi-mac.cc:439
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
Time m_beaconInterval
Interval between beacons.
Definition: ap-wifi-mac.h:292
bool IsSupportedTxMcs(uint8_t mcs) const
Is transmit MCS supported.
void SetVoCWmin(uint8_t cwMin)
Set the AC_VO CWmin 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:298
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:97
bool IsFromDs(void) const
bool IsSupportedRate(uint32_t bs) const
Check if the given rate is supported.
void SetRifsMode(uint8_t rifsmode)
Set the RIFS mode.
Definition: ht-operation.cc:99
void SetDsFrom(void)
Set the From DS bit in the Frame Control field.
void SetNoOrder(void)
Unset order bit in the frame control field.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1009
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:296
Time GetBeaconInterval(void) const
Definition: ap-wifi-mac.cc:149
void SetVoCWmax(uint8_t cwMax)
Set the AC_VO CWmax field in the EdcaParameterSet information element.
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.
tuple address
Definition: first.py:37
bool m_erpSupported
This Boolean is set true iff this WifiMac is to model 802.11g.
void TxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:761
bool GetRifsSupported(void) const
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:487
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 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:412
void SetBkCWmax(uint8_t cwMax)
Set the AC_BK CWmax field in the EdcaParameterSet information element.
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:664
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
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
std::list< Mac48Address > m_nonHtStations
List of all non-HT stations currently associated to the AP.
Definition: ap-wifi-mac.h:299
bool GetShortSlotTimeEnabled(void) const
Determine whether short slot time should be enabled or not in the BSS.
Definition: ap-wifi-mac.cc:202
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:539
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:502
uint32_t GetMinCw(void) const
Return the minimum contention window size.
Definition: dca-txop.cc:195
a unique identifier for an interface.
Definition: type-id.h:58
bool m_dsssSupported
This Boolean is set true iff this WifiMac is to model 802.11b.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
void StartBeaconing(void)
Start beacon transmission immediately.
Definition: ap-wifi-mac.cc:187
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:602
void SetViCWmax(uint8_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:526
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.
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
Definition: ap-wifi-mac.cc:127
void SetChannelWidth(uint8_t channelWidth)
Set the Channel Width field in the VHT Operation information element.
WifiMode GetMode(uint32_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3547
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.