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