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