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