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 
355  if (GetQosSupported ())
356  {
357  hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT 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 a HT 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 ())
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 ())
763  {
764  probe.SetExtendedCapabilities (GetExtendedCapabilities ());
765  probe.SetHtCapabilities (GetHtCapabilities ());
766  probe.SetHtOperation (GetHtOperation ());
767  }
768  if (GetVhtSupported ())
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 ())
841  {
842  assoc.SetExtendedCapabilities (GetExtendedCapabilities ());
843  assoc.SetHtCapabilities (GetHtCapabilities ());
844  assoc.SetHtOperation (GetHtOperation ());
845  }
846  if (GetVhtSupported ())
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 ())
901  {
902  beacon.SetExtendedCapabilities (GetExtendedCapabilities ());
903  beacon.SetHtCapabilities (GetHtCapabilities ());
904  beacon.SetHtOperation (GetHtOperation ());
905  }
906  if (GetVhtSupported ())
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 << *mpdu);
1024  const WifiMacHeader* hdr = &mpdu->GetHeader ();
1025  Ptr<const Packet> packet = mpdu->GetPacket ();
1026  Mac48Address from = hdr->GetAddr2 ();
1027  if (hdr->IsData ())
1028  {
1029  Mac48Address bssid = hdr->GetAddr1 ();
1030  if (!hdr->IsFromDs ()
1031  && hdr->IsToDs ()
1032  && bssid == GetAddress ()
1033  && m_stationManager->IsAssociated (from))
1034  {
1035  Mac48Address to = hdr->GetAddr3 ();
1036  if (to == GetAddress ())
1037  {
1038  NS_LOG_DEBUG ("frame for me from=" << from);
1039  if (hdr->IsQosData ())
1040  {
1041  if (hdr->IsQosAmsdu ())
1042  {
1043  NS_LOG_DEBUG ("Received A-MSDU from=" << from << ", size=" << packet->GetSize ());
1045  packet = 0;
1046  }
1047  else
1048  {
1049  ForwardUp (packet, from, bssid);
1050  }
1051  }
1052  else if (hdr->HasData ())
1053  {
1054  ForwardUp (packet, from, bssid);
1055  }
1056  }
1057  else if (to.IsGroup ()
1058  || m_stationManager->IsAssociated (to))
1059  {
1060  NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to);
1061  Ptr<Packet> copy = packet->Copy ();
1062 
1063  //If the frame we are forwarding is of type QoS Data,
1064  //then we need to preserve the UP in the QoS control
1065  //header...
1066  if (hdr->IsQosData ())
1067  {
1068  ForwardDown (copy, from, to, hdr->GetQosTid ());
1069  }
1070  else
1071  {
1072  ForwardDown (copy, from, to);
1073  }
1074  ForwardUp (packet, from, to);
1075  }
1076  else
1077  {
1078  ForwardUp (packet, from, to);
1079  }
1080  }
1081  else if (hdr->IsFromDs ()
1082  && hdr->IsToDs ())
1083  {
1084  //this is an AP-to-AP frame
1085  //we ignore for now.
1086  NotifyRxDrop (packet);
1087  }
1088  else
1089  {
1090  //we can ignore these frames since
1091  //they are not targeted at the AP
1092  NotifyRxDrop (packet);
1093  }
1094  return;
1095  }
1096  else if (hdr->IsMgt ())
1097  {
1098  if (hdr->IsProbeReq ())
1099  {
1100  NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ());
1101  MgtProbeRequestHeader probeRequestHeader;
1102  packet->PeekHeader (probeRequestHeader);
1103  Ssid ssid = probeRequestHeader.GetSsid ();
1104  if (ssid == GetSsid () || ssid.IsBroadcast ())
1105  {
1106  NS_LOG_DEBUG ("Probe request received from " << from << ": send probe response");
1107  SendProbeResp (from);
1108  }
1109  return;
1110  }
1111  else if (hdr->GetAddr1 () == GetAddress ())
1112  {
1113  if (hdr->IsAssocReq ())
1114  {
1115  NS_LOG_DEBUG ("Association request received from " << from);
1116  //first, verify that the the station's supported
1117  //rate set is compatible with our Basic Rate set
1118  MgtAssocRequestHeader assocReq;
1119  packet->PeekHeader (assocReq);
1120  CapabilityInformation capabilities = assocReq.GetCapabilities ();
1121  m_stationManager->AddSupportedPhyPreamble (from, capabilities.IsShortPreamble ());
1122  SupportedRates rates = assocReq.GetSupportedRates ();
1123  bool problem = false;
1124  bool isHtStation = false;
1125  bool isOfdmStation = false;
1126  bool isErpStation = false;
1127  bool isDsssStation = false;
1128  for (uint8_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
1129  {
1131  if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1132  {
1134  {
1135  isDsssStation = false;
1136  }
1137  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1138  {
1139  isErpStation = false;
1140  }
1141  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1142  {
1143  isOfdmStation = false;
1144  }
1145  if (isDsssStation == false && isErpStation == false && isOfdmStation == false)
1146  {
1147  problem = true;
1148  break;
1149  }
1150  }
1151  else
1152  {
1154  {
1155  isDsssStation = true;
1156  }
1157  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1158  {
1159  isErpStation = true;
1160  }
1161  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1162  {
1163  isOfdmStation = true;
1164  }
1165  }
1166  }
1167  m_stationManager->AddSupportedErpSlotTime (from, capabilities.IsShortSlotTime () && isErpStation);
1168  if (GetHtSupported ())
1169  {
1170  //check whether the HT STA supports all MCSs in Basic MCS Set
1171  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
1172  if (htcapabilities.IsSupportedMcs (0))
1173  {
1174  isHtStation = true;
1175  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1176  {
1178  if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1179  {
1180  problem = true;
1181  break;
1182  }
1183  }
1184  }
1185  }
1186  if (GetVhtSupported ())
1187  {
1188  //check whether the VHT STA supports all MCSs in Basic MCS Set
1189  VhtCapabilities vhtcapabilities = assocReq.GetVhtCapabilities ();
1190  if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
1191  {
1192  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1193  {
1195  if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1196  {
1197  problem = true;
1198  break;
1199  }
1200  }
1201  }
1202  }
1203  if (GetHeSupported ())
1204  {
1205  //check whether the HE STA supports all MCSs in Basic MCS Set
1206  HeCapabilities hecapabilities = assocReq.GetHeCapabilities ();
1207  if (hecapabilities.GetSupportedMcsAndNss () != 0)
1208  {
1209  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1210  {
1212  if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1213  {
1214  problem = true;
1215  break;
1216  }
1217  }
1218  }
1219  }
1220  if (problem)
1221  {
1222  NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send association response with an error status");
1223  SendAssocResp (hdr->GetAddr2 (), false, false);
1224  }
1225  else
1226  {
1227  NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1228  //record all its supported modes in its associated WifiRemoteStation
1229  for (uint8_t j = 0; j < m_phy->GetNModes (); j++)
1230  {
1231  WifiMode mode = m_phy->GetMode (j);
1232  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1233  {
1234  m_stationManager->AddSupportedMode (from, mode);
1235  }
1236  }
1237  if (GetPcfSupported () && capabilities.IsCfPollable ())
1238  {
1239  m_cfPollingList.push_back (from);
1240  if (m_itCfPollingList == m_cfPollingList.end ())
1241  {
1243  }
1244  }
1245  if (GetHtSupported ())
1246  {
1247  HtCapabilities htCapabilities = assocReq.GetHtCapabilities ();
1248  if (htCapabilities.IsSupportedMcs (0))
1249  {
1250  m_stationManager->AddStationHtCapabilities (from, htCapabilities);
1251  }
1252  }
1253  if (GetVhtSupported ())
1254  {
1255  VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilities ();
1256  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1257  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1258  {
1259  m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities);
1260  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1261  {
1262  WifiMode mcs = m_phy->GetMcs (i);
1263  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1264  {
1265  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1266  //here should add a control to add basic MCS when it is implemented
1267  }
1268  }
1269  }
1270  }
1271  if (GetHtSupported ())
1272  {
1273  ExtendedCapabilities extendedCapabilities = assocReq.GetExtendedCapabilities ();
1274  //TODO: to be completed
1275  }
1276  if (GetHeSupported ())
1277  {
1278  HeCapabilities heCapabilities = assocReq.GetHeCapabilities ();
1279  if (heCapabilities.GetSupportedMcsAndNss () != 0)
1280  {
1281  m_stationManager->AddStationHeCapabilities (from, heCapabilities);
1282  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1283  {
1284  WifiMode mcs = m_phy->GetMcs (i);
1285  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1286  {
1287  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1288  //here should add a control to add basic MCS when it is implemented
1289  }
1290  }
1291  }
1292  }
1294  if (!isHtStation)
1295  {
1296  m_nonHtStations.push_back (hdr->GetAddr2 ());
1297  m_nonHtStations.unique ();
1298  }
1299  if (!isErpStation && isDsssStation)
1300  {
1301  m_nonErpStations.push_back (hdr->GetAddr2 ());
1302  m_nonErpStations.unique ();
1303  }
1304  NS_LOG_DEBUG ("Send association response with success status");
1305  SendAssocResp (hdr->GetAddr2 (), true, false);
1306  }
1307  return;
1308  }
1309  else if (hdr->IsReassocReq ())
1310  {
1311  NS_LOG_DEBUG ("Reassociation request received from " << from);
1312  //first, verify that the the station's supported
1313  //rate set is compatible with our Basic Rate set
1314  MgtReassocRequestHeader reassocReq;
1315  packet->PeekHeader (reassocReq);
1316  CapabilityInformation capabilities = reassocReq.GetCapabilities ();
1317  m_stationManager->AddSupportedPhyPreamble (from, capabilities.IsShortPreamble ());
1318  SupportedRates rates = reassocReq.GetSupportedRates ();
1319  bool problem = false;
1320  bool isHtStation = false;
1321  bool isOfdmStation = false;
1322  bool isErpStation = false;
1323  bool isDsssStation = false;
1324  for (uint8_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
1325  {
1327  if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1328  {
1330  {
1331  isDsssStation = false;
1332  }
1333  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1334  {
1335  isErpStation = false;
1336  }
1337  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1338  {
1339  isOfdmStation = false;
1340  }
1341  if (isDsssStation == false && isErpStation == false && isOfdmStation == false)
1342  {
1343  problem = true;
1344  break;
1345  }
1346  }
1347  else
1348  {
1350  {
1351  isDsssStation = true;
1352  }
1353  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1354  {
1355  isErpStation = true;
1356  }
1357  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1358  {
1359  isOfdmStation = true;
1360  }
1361  }
1362  }
1363  m_stationManager->AddSupportedErpSlotTime (from, capabilities.IsShortSlotTime () && isErpStation);
1364  if (GetHtSupported ())
1365  {
1366  //check whether the HT STA supports all MCSs in Basic MCS Set
1367  HtCapabilities htcapabilities = reassocReq.GetHtCapabilities ();
1368  if (htcapabilities.IsSupportedMcs (0))
1369  {
1370  isHtStation = true;
1371  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1372  {
1374  if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1375  {
1376  problem = true;
1377  break;
1378  }
1379  }
1380  }
1381  }
1382  if (GetVhtSupported ())
1383  {
1384  //check whether the VHT STA supports all MCSs in Basic MCS Set
1385  VhtCapabilities vhtcapabilities = reassocReq.GetVhtCapabilities ();
1386  if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
1387  {
1388  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1389  {
1391  if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1392  {
1393  problem = true;
1394  break;
1395  }
1396  }
1397  }
1398  }
1399  if (GetHeSupported ())
1400  {
1401  //check whether the HE STA supports all MCSs in Basic MCS Set
1402  HeCapabilities hecapabilities = reassocReq.GetHeCapabilities ();
1403  if (hecapabilities.GetSupportedMcsAndNss () != 0)
1404  {
1405  for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1406  {
1408  if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1409  {
1410  problem = true;
1411  break;
1412  }
1413  }
1414  }
1415  }
1416  if (problem)
1417  {
1418  NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send reassociation response with an error status");
1419  SendAssocResp (hdr->GetAddr2 (), false, true);
1420  }
1421  else
1422  {
1423  NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1424  //update all its supported modes in its associated WifiRemoteStation
1425  for (uint8_t j = 0; j < m_phy->GetNModes (); j++)
1426  {
1427  WifiMode mode = m_phy->GetMode (j);
1428  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1429  {
1430  m_stationManager->AddSupportedMode (from, mode);
1431  }
1432  }
1433  if (GetHtSupported ())
1434  {
1435  HtCapabilities htCapabilities = reassocReq.GetHtCapabilities ();
1436  if (htCapabilities.IsSupportedMcs (0))
1437  {
1438  m_stationManager->AddStationHtCapabilities (from, htCapabilities);
1439  }
1440  }
1441  if (GetVhtSupported ())
1442  {
1443  VhtCapabilities vhtCapabilities = reassocReq.GetVhtCapabilities ();
1444  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1445  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1446  {
1447  m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities);
1448  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1449  {
1450  WifiMode mcs = m_phy->GetMcs (i);
1451  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1452  {
1453  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1454  //here should add a control to add basic MCS when it is implemented
1455  }
1456  }
1457  }
1458  }
1459  if (GetHtSupported ())
1460  {
1461  ExtendedCapabilities extendedCapabilities = reassocReq.GetExtendedCapabilities ();
1462  //TODO: to be completed
1463  }
1464  if (GetHeSupported ())
1465  {
1466  HeCapabilities heCapabilities = reassocReq.GetHeCapabilities ();
1467  if (heCapabilities.GetSupportedMcsAndNss () != 0)
1468  {
1469  m_stationManager->AddStationHeCapabilities (from, heCapabilities);
1470  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1471  {
1472  WifiMode mcs = m_phy->GetMcs (i);
1473  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1474  {
1475  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1476  //here should add a control to add basic MCS when it is implemented
1477  }
1478  }
1479  }
1480  }
1482  if (!isHtStation)
1483  {
1484  m_nonHtStations.push_back (hdr->GetAddr2 ());
1485  m_nonHtStations.unique ();
1486  }
1487  if (!isErpStation && isDsssStation)
1488  {
1489  m_nonErpStations.push_back (hdr->GetAddr2 ());
1490  m_nonErpStations.unique ();
1491  }
1492  NS_LOG_DEBUG ("Send reassociation response with success status");
1493  SendAssocResp (hdr->GetAddr2 (), true, true);
1494  }
1495  return;
1496  }
1497  else if (hdr->IsDisassociation ())
1498  {
1499  NS_LOG_DEBUG ("Disassociation received from " << from);
1501  for (std::map<uint16_t, Mac48Address>::const_iterator j = m_staList.begin (); j != m_staList.end (); j++)
1502  {
1503  if (j->second == from)
1504  {
1505  m_staList.erase (j);
1506  break;
1507  }
1508  }
1509  for (std::list<Mac48Address>::const_iterator j = m_nonErpStations.begin (); j != m_nonErpStations.end (); j++)
1510  {
1511  if ((*j) == from)
1512  {
1513  m_nonErpStations.erase (j);
1514  break;
1515  }
1516  }
1517  for (std::list<Mac48Address>::const_iterator j = m_nonHtStations.begin (); j != m_nonHtStations.end (); j++)
1518  {
1519  if ((*j) == from)
1520  {
1521  m_nonHtStations.erase (j);
1522  break;
1523  }
1524  }
1525  for (std::list<Mac48Address>::const_iterator j = m_cfPollingList.begin (); j != m_cfPollingList.end (); ++j)
1526  {
1527  if ((*j) == from)
1528  {
1529  m_cfPollingList.erase (j);
1530  break;
1531  }
1532  }
1533  return;
1534  }
1535  }
1536  }
1537 
1538  //Invoke the receive handler of our parent class to deal with any
1539  //other frames. Specifically, this will handle Block Ack-related
1540  //Management Action frames.
1541  RegularWifiMac::Receive (Create<WifiMacQueueItem> (packet, *hdr));
1542 }
1543 
1544 void
1546 {
1547  NS_LOG_FUNCTION (this << *mpdu);
1548  for (auto& i : *PeekPointer (mpdu))
1549  {
1550  if (i.second.GetDestinationAddr () == GetAddress ())
1551  {
1552  ForwardUp (i.first, i.second.GetSourceAddr (),
1553  i.second.GetDestinationAddr ());
1554  }
1555  else
1556  {
1557  Mac48Address from = i.second.GetSourceAddr ();
1558  Mac48Address to = i.second.GetDestinationAddr ();
1559  NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
1560  ForwardDown (i.first->Copy (), from, to, mpdu->GetHeader ().GetQosTid ());
1561  }
1562  }
1563 }
1564 
1565 void
1567 {
1568  NS_LOG_FUNCTION (this);
1570  m_beaconEvent.Cancel ();
1572  {
1574  {
1575  Time jitter = MicroSeconds (static_cast<int64_t> (m_beaconJitter->GetValue (0, 1) * (GetBeaconInterval ().GetMicroSeconds ())));
1576  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time " << jitter);
1578  }
1579  else
1580  {
1581  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time 0");
1583  }
1584  }
1586 }
1587 
1588 bool
1590 {
1591  bool useProtection = !m_nonErpStations.empty () && m_enableNonErpProtection;
1592  m_stationManager->SetUseNonErpProtection (useProtection);
1593  return useProtection;
1594 }
1595 
1596 bool
1598 {
1599  bool rifsMode = false;
1600  if (GetHtSupported () && !GetVhtSupported ()) //RIFS mode is no longer allowed with 802.11ac or higher
1601  {
1602  if (m_nonHtStations.empty () || !m_disableRifs)
1603  {
1604  rifsMode = true;
1605  }
1606  }
1607  if (GetHtSupported () && GetHtConfiguration ()->GetRifsSupported () && rifsMode)
1608  {
1610  }
1611  else
1612  {
1614  }
1615  return rifsMode;
1616 }
1617 
1618 uint16_t
1620 {
1621  //Return the first free AID value between 1 and 2007
1622  for (uint16_t nextAid = 1; nextAid <= 2007; nextAid++)
1623  {
1624  if (m_staList.find (nextAid) == m_staList.end ())
1625  {
1626  return nextAid;
1627  }
1628  }
1629  NS_FATAL_ERROR ("No free association ID available!");
1630  return 0;
1631 }
1632 
1633 void
1635 {
1636  NS_LOG_FUNCTION (this);
1638  if (m_itCfPollingList == m_cfPollingList.end ())
1639  {
1641  }
1642 }
1643 
1644 } //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: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:302
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:782
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:306
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.
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet down to DCF/EDCAF (enqueue the packet).
Definition: ap-wifi-mac.cc:302
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:3932
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:308
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: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: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:1445
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:119
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:37
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:566
CfParameterSet GetCfParameterSet(void) const
Return the CF parameter set of the current AP.
Definition: ap-wifi-mac.cc:551
#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.
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 SetSlot(Time slotTime)
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
void Enqueue(Ptr< Packet > packet, Mac48Address to)
Definition: ap-wifi-mac.cc:392
#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:162
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:854
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
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: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.
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.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:449
bool m_enableBeaconGeneration
Flag whether beacons are being generated.
Definition: ap-wifi-mac.h:297
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:1388
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:3926
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: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:227
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:590
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1390
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:1126
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:466
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:246
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:661
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:231
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:307
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:252
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:298
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.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1610
Ptr< Txop > m_beaconTxop
Dedicated Txop for beacons.
Definition: ap-wifi-mac.h:296
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:305
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: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: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: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:185
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:212
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...
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...
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:718
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:133
Ssid GetSsid(void) const
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:1579
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:1127
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1540
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:453
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:514
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:3914
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:3920
uint8_t GetBssMembershipSelector(uint8_t selector) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1451
EventId m_cfpEvent
Event to generate one PCF frame.
Definition: ap-wifi-mac.h:299
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.
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:866
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: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:265
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: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:126
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< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
Definition: ap-wifi-mac.h:300
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:303
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:115
void IncrementPollingListIterator(void)
Increment the PCF polling list iterator to indicate that the next polling station can be polled...
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: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:1080
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:301
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: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:37
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: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:304
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:316
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:1421
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:922
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:847
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: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:1439
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 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:302
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.