A Discrete-Event Network Simulator
API
sta-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 "qos-txop.h"
27 #include "sta-wifi-mac.h"
28 #include "wifi-phy.h"
29 #include "mgt-headers.h"
30 #include "snr-tag.h"
31 #include "wifi-net-device.h"
32 #include "ns3/ht-configuration.h"
33 #include "ns3/he-configuration.h"
34 
35 namespace ns3 {
36 
37 NS_LOG_COMPONENT_DEFINE ("StaWifiMac");
38 
39 NS_OBJECT_ENSURE_REGISTERED (StaWifiMac);
40 
41 TypeId
43 {
44  static TypeId tid = TypeId ("ns3::StaWifiMac")
45  .SetParent<WifiMac> ()
46  .SetGroupName ("Wifi")
47  .AddConstructor<StaWifiMac> ()
48  .AddAttribute ("ProbeRequestTimeout", "The duration to actively probe the channel.",
49  TimeValue (Seconds (0.05)),
51  MakeTimeChecker ())
52  .AddAttribute ("WaitBeaconTimeout", "The duration to dwell on a channel while passively scanning for beacon",
53  TimeValue (MilliSeconds (120)),
55  MakeTimeChecker ())
56  .AddAttribute ("AssocRequestTimeout", "The interval between two consecutive association request attempts.",
57  TimeValue (Seconds (0.5)),
59  MakeTimeChecker ())
60  .AddAttribute ("MaxMissedBeacons",
61  "Number of beacons which much be consecutively missed before "
62  "we attempt to restart association.",
63  UintegerValue (10),
65  MakeUintegerChecker<uint32_t> ())
66  .AddAttribute ("ActiveProbing",
67  "If true, we send probe requests. If false, we don't."
68  "NOTE: if more than one STA in your simulation is using active probing, "
69  "you should enable it at a different simulation time for each STA, "
70  "otherwise all the STAs will start sending probes at the same time resulting in collisions. "
71  "See bug 1060 for more info.",
72  BooleanValue (false),
75  .AddTraceSource ("Assoc", "Associated with an access point.",
77  "ns3::Mac48Address::TracedCallback")
78  .AddTraceSource ("DeAssoc", "Association with an access point lost.",
80  "ns3::Mac48Address::TracedCallback")
81  .AddTraceSource ("BeaconArrival",
82  "Time of beacons arrival from associated AP",
84  "ns3::Time::TracedCallback")
85  ;
86  return tid;
87 }
88 
90  : m_state (UNASSOCIATED),
91  m_aid (0),
92  m_waitBeaconEvent (),
93  m_probeRequestEvent (),
94  m_assocRequestEvent (),
95  m_beaconWatchdogEnd (Seconds (0))
96 {
97  NS_LOG_FUNCTION (this);
98 
99  //Let the lower layers know that we are acting as a non-AP STA in
100  //an infrastructure BSS.
102 }
103 
104 void
106 {
107  NS_LOG_FUNCTION (this);
108  StartScanning ();
109 }
110 
112 {
113  NS_LOG_FUNCTION (this);
114 }
115 
116 uint16_t
118 {
119  NS_ASSERT_MSG (IsAssociated (), "This station is not associated to any AP");
120  return m_aid;
121 }
122 
123 void
125 {
126  NS_LOG_FUNCTION (this << enable);
127  m_activeProbing = enable;
129  {
130  NS_LOG_DEBUG ("STA is still scanning, reset scanning process");
131  StartScanning ();
132  }
133 }
134 
135 bool
137 {
138  return m_activeProbing;
139 }
140 
141 void
143 {
144  NS_LOG_FUNCTION (this << phy);
147 }
148 
149 void
151 {
152  NS_LOG_FUNCTION (this);
153  WifiMacHeader hdr;
156  hdr.SetAddr2 (GetAddress ());
158  hdr.SetDsNotFrom ();
159  hdr.SetDsNotTo ();
160  Ptr<Packet> packet = Create<Packet> ();
161  MgtProbeRequestHeader probe;
162  probe.SetSsid (GetSsid ());
164  if (GetHtSupported ())
165  {
168  }
169  if (GetVhtSupported ())
170  {
172  }
173  if (GetHeSupported ())
174  {
176  }
177  packet->AddHeader (probe);
178 
179  if (!GetQosSupported ())
180  {
181  GetTxop ()->Queue (packet, hdr);
182  }
183  // "A QoS STA that transmits a Management frame determines access category used
184  // for medium access in transmission of the Management frame as follows
185  // (If dot11QMFActivated is false or not present)
186  // — If the Management frame is individually addressed to a non-QoS STA, category
187  // AC_BE should be selected.
188  // — If category AC_BE was not selected by the previous step, category AC_VO
189  // shall be selected." (Sec. 10.2.3.2 of 802.11-2020)
190  else
191  {
192  GetVOQueue ()->Queue (packet, hdr);
193  }
194 }
195 
196 void
198 {
199  NS_LOG_FUNCTION (this << GetBssid () << isReassoc);
200  WifiMacHeader hdr;
202  hdr.SetAddr1 (GetBssid ());
203  hdr.SetAddr2 (GetAddress ());
204  hdr.SetAddr3 (GetBssid ());
205  hdr.SetDsNotFrom ();
206  hdr.SetDsNotTo ();
207  Ptr<Packet> packet = Create<Packet> ();
208  if (!isReassoc)
209  {
210  MgtAssocRequestHeader assoc;
211  assoc.SetSsid (GetSsid ());
213  assoc.SetCapabilities (GetCapabilities ());
214  assoc.SetListenInterval (0);
215  if (GetHtSupported ())
216  {
219  }
220  if (GetVhtSupported ())
221  {
223  }
224  if (GetHeSupported ())
225  {
227  }
228  packet->AddHeader (assoc);
229  }
230  else
231  {
232  MgtReassocRequestHeader reassoc;
233  reassoc.SetCurrentApAddress (GetBssid ());
234  reassoc.SetSsid (GetSsid ());
236  reassoc.SetCapabilities (GetCapabilities ());
237  reassoc.SetListenInterval (0);
238  if (GetHtSupported ())
239  {
242  }
243  if (GetVhtSupported ())
244  {
246  }
247  if (GetHeSupported ())
248  {
250  }
251  packet->AddHeader (reassoc);
252  }
253 
254  if (!GetQosSupported ())
255  {
256  GetTxop ()->Queue (packet, hdr);
257  }
258  // "A QoS STA that transmits a Management frame determines access category used
259  // for medium access in transmission of the Management frame as follows
260  // (If dot11QMFActivated is false or not present)
261  // — If the Management frame is individually addressed to a non-QoS STA, category
262  // AC_BE should be selected.
263  // — If category AC_BE was not selected by the previous step, category AC_VO
264  // shall be selected." (Sec. 10.2.3.2 of 802.11-2020)
266  {
267  GetBEQueue ()->Queue (packet, hdr);
268  }
269  else
270  {
271  GetVOQueue ()->Queue (packet, hdr);
272  }
273 
275  {
277  }
280 }
281 
282 void
284 {
285  NS_LOG_FUNCTION (this);
286  switch (m_state)
287  {
288  case ASSOCIATED:
289  return;
290  break;
291  case WAIT_PROBE_RESP:
292  /* we have sent a probe request earlier so we
293  do not need to re-send a probe request immediately.
294  We just need to wait until probe-request-timeout
295  or until we get a probe response
296  */
297  break;
298  case WAIT_BEACON:
299  /* we have initiated passive scanning, continue to wait
300  and gather beacons
301  */
302  break;
303  case UNASSOCIATED:
304  /* we were associated but we missed a bunch of beacons
305  * so we should assume we are not associated anymore.
306  * We try to initiate a scan now.
307  */
308  m_linkDown ();
309  StartScanning ();
310  break;
311  case WAIT_ASSOC_RESP:
312  /* we have sent an association request so we do not need to
313  re-send an association request right now. We just need to
314  wait until either assoc-request-timeout or until
315  we get an association response.
316  */
317  break;
318  case REFUSED:
319  /* we have sent an association request and received a negative
320  association response. We wait until someone restarts an
321  association with a given SSID.
322  */
323  break;
324  }
325 }
326 
327 void
329 {
330  NS_LOG_FUNCTION (this);
331  m_candidateAps.clear ();
333  {
335  }
337  {
339  }
340  if (GetActiveProbing ())
341  {
343  SendProbeRequest ();
346  this);
347  }
348  else
349  {
353  this);
354  }
355 }
356 
357 void
359 {
360  NS_LOG_FUNCTION (this);
361  if (!m_candidateAps.empty ())
362  {
363  ApInfo bestAp = m_candidateAps.front();
364  m_candidateAps.erase(m_candidateAps.begin ());
365  NS_LOG_DEBUG ("Attempting to associate with BSSID " << bestAp.m_bssid);
366  Time beaconInterval;
367  if (bestAp.m_activeProbing)
368  {
369  UpdateApInfoFromProbeResp (bestAp.m_probeResp, bestAp.m_apAddr, bestAp.m_bssid);
370  beaconInterval = MicroSeconds (bestAp.m_probeResp.GetBeaconIntervalUs ());
371  }
372  else
373  {
374  UpdateApInfoFromBeacon (bestAp.m_beacon, bestAp.m_apAddr, bestAp.m_bssid);
375  beaconInterval = MicroSeconds (bestAp.m_beacon.GetBeaconIntervalUs ());
376  }
377 
378  Time delay = beaconInterval * m_maxMissedBeacons;
379  RestartBeaconWatchdog (delay);
381  SendAssociationRequest (false);
382  }
383  else
384  {
385  NS_LOG_DEBUG ("Exhausted list of candidate AP; restart scanning");
386  StartScanning ();
387  }
388 }
389 
390 void
392 {
393  NS_LOG_FUNCTION (this);
395  SendAssociationRequest (false);
396 }
397 
398 void
400 {
401  NS_LOG_FUNCTION (this);
403  {
405  {
407  }
410  return;
411  }
412  NS_LOG_DEBUG ("beacon missed");
413  // We need to switch to the UNASSOCIATED state. However, if we are receiving
414  // a frame, wait until the RX is completed (otherwise, crashes may occur if
415  // we are receiving a MU frame because its reception requires the STA-ID)
416  Time delay = Seconds (0);
417  if (GetWifiPhy ()->IsStateRx ())
418  {
419  delay = GetWifiPhy ()->GetDelayUntilIdle ();
420  }
422 }
423 
424 void
426 {
427  NS_LOG_FUNCTION (this);
428  NS_LOG_DEBUG ("Set state to UNASSOCIATED and start scanning");
431 }
432 
433 void
435 {
436  NS_LOG_FUNCTION (this << delay);
440  {
441  NS_LOG_DEBUG ("really restart watchdog.");
443  }
444 }
445 
446 bool
448 {
449  return m_state == ASSOCIATED;
450 }
451 
452 bool
454 {
455  return m_state == WAIT_ASSOC_RESP;
456 }
457 
458 bool
460 {
461  return (IsAssociated ());
462 }
463 
464 void
466 {
467  NS_LOG_FUNCTION (this << packet << to);
468  if (!CanForwardPacketsTo (to))
469  {
470  NotifyTxDrop (packet);
472  return;
473  }
474  WifiMacHeader hdr;
475 
476  //If we are not a QoS AP then we definitely want to use AC_BE to
477  //transmit the packet. A TID of zero will map to AC_BE (through \c
478  //QosUtilsMapTidToAc()), so we use that as our default here.
479  uint8_t tid = 0;
480 
481  //For now, an AP that supports QoS does not support non-QoS
482  //associations, and vice versa. In future the AP model should
483  //support simultaneously associated QoS and non-QoS STAs, at which
484  //point there will need to be per-association QoS state maintained
485  //by the association state machine, and consulted here.
486  if (GetQosSupported ())
487  {
490  hdr.SetQosNoEosp ();
491  hdr.SetQosNoAmsdu ();
492  //Transmission of multiple frames in the same TXOP is not
493  //supported for now
494  hdr.SetQosTxopLimit (0);
495 
496  //Fill in the QoS control field in the MAC header
497  tid = QosUtilsGetTidForPacket (packet);
498  //Any value greater than 7 is invalid and likely indicates that
499  //the packet had no QoS tag, so we revert to zero, which'll
500  //mean that AC_BE is used.
501  if (tid > 7)
502  {
503  tid = 0;
504  }
505  hdr.SetQosTid (tid);
506  }
507  else
508  {
509  hdr.SetType (WIFI_MAC_DATA);
510  }
511  if (GetQosSupported ())
512  {
513  hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT control field is not yet implemented (set it to 1 when implemented)
514  }
515 
516  hdr.SetAddr1 (GetBssid ());
517  hdr.SetAddr2 (GetAddress ());
518  hdr.SetAddr3 (to);
519  hdr.SetDsNotFrom ();
520  hdr.SetDsTo ();
521 
522  if (GetQosSupported ())
523  {
524  //Sanity check that the TID is valid
525  NS_ASSERT (tid < 8);
526  GetQosTxop (tid)->Queue (packet, hdr);
527  }
528  else
529  {
530  GetTxop ()->Queue (packet, hdr);
531  }
532 }
533 
534 void
536 {
537  NS_LOG_FUNCTION (this << *mpdu);
538  const WifiMacHeader* hdr = &mpdu->GetHeader ();
539  Ptr<const Packet> packet = mpdu->GetPacket ();
540  NS_ASSERT (!hdr->IsCtl ());
541  if (hdr->GetAddr3 () == GetAddress ())
542  {
543  NS_LOG_LOGIC ("packet sent by us.");
544  return;
545  }
546  else if (hdr->GetAddr1 () != GetAddress ()
547  && !hdr->GetAddr1 ().IsGroup ())
548  {
549  NS_LOG_LOGIC ("packet is not for us");
550  NotifyRxDrop (packet);
551  return;
552  }
553  if (hdr->IsData ())
554  {
555  if (!IsAssociated ())
556  {
557  NS_LOG_LOGIC ("Received data frame while not associated: ignore");
558  NotifyRxDrop (packet);
559  return;
560  }
561  if (!(hdr->IsFromDs () && !hdr->IsToDs ()))
562  {
563  NS_LOG_LOGIC ("Received data frame not from the DS: ignore");
564  NotifyRxDrop (packet);
565  return;
566  }
567  if (hdr->GetAddr2 () != GetBssid ())
568  {
569  NS_LOG_LOGIC ("Received data frame not from the BSS we are associated with: ignore");
570  NotifyRxDrop (packet);
571  return;
572  }
573  if (hdr->IsQosData ())
574  {
575  if (hdr->IsQosAmsdu ())
576  {
577  NS_ASSERT (hdr->GetAddr3 () == GetBssid ());
579  packet = 0;
580  }
581  else
582  {
583  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
584  }
585  }
586  else if (hdr->HasData ())
587  {
588  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
589  }
590  return;
591  }
592  else if (hdr->IsProbeReq ()
593  || hdr->IsAssocReq ()
594  || hdr->IsReassocReq ())
595  {
596  //This is a frame aimed at an AP, so we can safely ignore it.
597  NotifyRxDrop (packet);
598  return;
599  }
600  else if (hdr->IsBeacon ())
601  {
602  NS_LOG_DEBUG ("Beacon received");
603  MgtBeaconHeader beacon;
604  Ptr<Packet> copy = packet->Copy ();
605  copy->RemoveHeader (beacon);
606  CapabilityInformation capabilities = beacon.GetCapabilities ();
607  NS_ASSERT (capabilities.IsEss ());
608  bool goodBeacon = false;
609  if (GetSsid ().IsBroadcast ()
610  || beacon.GetSsid ().IsEqual (GetSsid ()))
611  {
612  NS_LOG_LOGIC ("Beacon is for our SSID");
613  goodBeacon = true;
614  }
615  SupportedRates rates = beacon.GetSupportedRates ();
616  bool bssMembershipSelectorMatch = false;
617  auto selectorList = GetWifiPhy ()->GetBssMembershipSelectorList ();
618  for (const auto & selector : selectorList)
619  {
620  if (rates.IsBssMembershipSelectorRate (selector))
621  {
622  NS_LOG_LOGIC ("Beacon is matched to our BSS membership selector");
623  bssMembershipSelectorMatch = true;
624  }
625  }
626  if (selectorList.size () > 0 && bssMembershipSelectorMatch == false)
627  {
628  NS_LOG_LOGIC ("No match for BSS membership selector");
629  goodBeacon = false;
630  }
631  if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ())
632  {
633  NS_LOG_LOGIC ("Beacon is not for us");
634  goodBeacon = false;
635  }
636  if (goodBeacon && m_state == ASSOCIATED)
637  {
640  RestartBeaconWatchdog (delay);
641  UpdateApInfoFromBeacon (beacon, hdr->GetAddr2 (), hdr->GetAddr3 ());
642  }
643  if (goodBeacon && m_state == WAIT_BEACON)
644  {
645  NS_LOG_DEBUG ("Beacon received while scanning from " << hdr->GetAddr2 ());
646  SnrTag snrTag;
647  bool removed = copy->RemovePacketTag (snrTag);
648  NS_ASSERT (removed);
649  ApInfo apInfo;
650  apInfo.m_apAddr = hdr->GetAddr2 ();
651  apInfo.m_bssid = hdr->GetAddr3 ();
652  apInfo.m_activeProbing = false;
653  apInfo.m_snr = snrTag.Get ();
654  apInfo.m_beacon = beacon;
655  UpdateCandidateApList (apInfo);
656  }
657  return;
658  }
659  else if (hdr->IsProbeResp ())
660  {
661  if (m_state == WAIT_PROBE_RESP)
662  {
663  NS_LOG_DEBUG ("Probe response received while scanning from " << hdr->GetAddr2 ());
664  MgtProbeResponseHeader probeResp;
665  Ptr<Packet> copy = packet->Copy ();
666  copy->RemoveHeader (probeResp);
667  if (!probeResp.GetSsid ().IsEqual (GetSsid ()))
668  {
669  NS_LOG_DEBUG ("Probe response is not for our SSID");
670  return;
671  }
672  SnrTag snrTag;
673  bool removed = copy->RemovePacketTag (snrTag);
674  NS_ASSERT (removed);
675  ApInfo apInfo;
676  apInfo.m_apAddr = hdr->GetAddr2 ();
677  apInfo.m_bssid = hdr->GetAddr3 ();
678  apInfo.m_activeProbing = true;
679  apInfo.m_snr = snrTag.Get ();
680  apInfo.m_probeResp = probeResp;
681  UpdateCandidateApList (apInfo);
682  }
683  return;
684  }
685  else if (hdr->IsAssocResp () || hdr->IsReassocResp ())
686  {
687  if (m_state == WAIT_ASSOC_RESP)
688  {
689  MgtAssocResponseHeader assocResp;
690  packet->PeekHeader (assocResp);
692  {
694  }
695  if (assocResp.GetStatusCode ().IsSuccess ())
696  {
698  m_aid = assocResp.GetAssociationId ();
699  if (hdr->IsReassocResp ())
700  {
701  NS_LOG_DEBUG ("reassociation done");
702  }
703  else
704  {
705  NS_LOG_DEBUG ("association completed");
706  }
707  UpdateApInfoFromAssocResp (assocResp, hdr->GetAddr2 ());
708  if (!m_linkUp.IsNull ())
709  {
710  m_linkUp ();
711  }
712  }
713  else
714  {
715  NS_LOG_DEBUG ("association refused");
716  if (m_candidateAps.empty ())
717  {
718  SetState (REFUSED);
719  }
720  else
721  {
722  ScanningTimeout ();
723  }
724  }
725  }
726  return;
727  }
728 
729  //Invoke the receive handler of our parent class to deal with any
730  //other frames. Specifically, this will handle Block Ack-related
731  //Management Action frames.
732  WifiMac::Receive (Create<WifiMacQueueItem> (packet, *hdr));
733 }
734 
735 void
737 {
738  NS_LOG_FUNCTION (this << newApInfo.m_bssid << newApInfo.m_apAddr << newApInfo.m_snr << newApInfo.m_activeProbing << newApInfo.m_beacon << newApInfo.m_probeResp);
739  // Remove duplicate ApInfo entry
740  for (std::vector<ApInfo>::iterator i = m_candidateAps.begin(); i != m_candidateAps.end(); ++i)
741  {
742  if (newApInfo.m_bssid == (*i).m_bssid)
743  {
744  m_candidateAps.erase(i);
745  break;
746  }
747  }
748  // Insert before the entry with lower SNR
749  for (std::vector<ApInfo>::iterator i = m_candidateAps.begin(); i != m_candidateAps.end(); ++i)
750  {
751  if (newApInfo.m_snr > (*i).m_snr)
752  {
753  m_candidateAps.insert (i, newApInfo);
754  return;
755  }
756  }
757  // If new ApInfo is the lowest, insert at back
758  m_candidateAps.push_back(newApInfo);
759 }
760 
761 void
763 {
764  NS_LOG_FUNCTION (this << beacon << apAddr << bssid);
765  SetBssid (bssid);
766  CapabilityInformation capabilities = beacon.GetCapabilities ();
767  SupportedRates rates = beacon.GetSupportedRates ();
768  for (const auto & mode : GetWifiPhy ()->GetModeList ())
769  {
770  if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
771  {
773  }
774  }
775  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
776  if (GetErpSupported ())
777  {
778  ErpInformation erpInformation = beacon.GetErpInformation ();
779  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
780  if (erpInformation.GetUseProtection () != 0)
781  {
783  }
784  else
785  {
787  }
788  if (capabilities.IsShortSlotTime () == true)
789  {
790  //enable short slot time
791  GetWifiPhy ()->SetSlot (MicroSeconds (9));
792  }
793  else
794  {
795  //disable short slot time
796  GetWifiPhy ()->SetSlot (MicroSeconds (20));
797  }
798  }
799  if (GetQosSupported ())
800  {
801  bool qosSupported = false;
802  EdcaParameterSet edcaParameters = beacon.GetEdcaParameterSet ();
803  if (edcaParameters.IsQosSupported ())
804  {
805  qosSupported = true;
806  //The value of the TXOP Limit field is specified as an unsigned integer, with the least significant octet transmitted first, in units of 32 μs.
807  SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTxopLimit ()));
808  SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTxopLimit ()));
809  SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ()));
810  SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ()));
811  }
812  GetWifiRemoteStationManager ()->SetQosSupport (apAddr, qosSupported);
813  }
814  if (GetHtSupported ())
815  {
816  HtCapabilities htCapabilities = beacon.GetHtCapabilities ();
817  if (!htCapabilities.IsSupportedMcs (0))
818  {
820  }
821  else
822  {
823  GetWifiRemoteStationManager ()->AddStationHtCapabilities (apAddr, htCapabilities);
824  }
825  }
826  if (GetVhtSupported ())
827  {
828  VhtCapabilities vhtCapabilities = beacon.GetVhtCapabilities ();
829  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
830  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
831  {
832  GetWifiRemoteStationManager ()->AddStationVhtCapabilities (apAddr, vhtCapabilities);
833  VhtOperation vhtOperation = beacon.GetVhtOperation ();
834  for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT))
835  {
836  if (vhtCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
837  {
839  }
840  }
841  }
842  }
843  if (GetHtSupported ())
844  {
845  ExtendedCapabilities extendedCapabilities = beacon.GetExtendedCapabilities ();
846  //TODO: to be completed
847  }
848  if (GetHeSupported ())
849  {
850  HeCapabilities heCapabilities = beacon.GetHeCapabilities ();
851  if (heCapabilities.GetSupportedMcsAndNss () != 0)
852  {
853  GetWifiRemoteStationManager ()->AddStationHeCapabilities (apAddr, heCapabilities);
854  HeOperation heOperation = beacon.GetHeOperation ();
855  for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
856  {
857  if (heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
858  {
860  }
861  }
862  }
863 
864  MuEdcaParameterSet muEdcaParameters = beacon.GetMuEdcaParameterSet ();
865  if (muEdcaParameters.IsPresent ())
866  {
867  SetMuEdcaParameters (AC_BE, muEdcaParameters.GetMuCwMin (AC_BE), muEdcaParameters.GetMuCwMax (AC_BE),
868  muEdcaParameters.GetMuAifsn (AC_BE), muEdcaParameters.GetMuEdcaTimer (AC_BE));
869  SetMuEdcaParameters (AC_BK, muEdcaParameters.GetMuCwMin (AC_BK), muEdcaParameters.GetMuCwMax (AC_BK),
870  muEdcaParameters.GetMuAifsn (AC_BK), muEdcaParameters.GetMuEdcaTimer (AC_BK));
871  SetMuEdcaParameters (AC_VI, muEdcaParameters.GetMuCwMin (AC_VI), muEdcaParameters.GetMuCwMax (AC_VI),
872  muEdcaParameters.GetMuAifsn (AC_VI), muEdcaParameters.GetMuEdcaTimer (AC_VI));
873  SetMuEdcaParameters (AC_VO, muEdcaParameters.GetMuCwMin (AC_VO), muEdcaParameters.GetMuCwMax (AC_VO),
874  muEdcaParameters.GetMuAifsn (AC_VO), muEdcaParameters.GetMuEdcaTimer (AC_VO));
875  }
876  }
877  GetWifiRemoteStationManager ()->SetShortPreambleEnabled (isShortPreambleEnabled);
879 }
880 
881 void
883 {
884  NS_LOG_FUNCTION (this << probeResp << apAddr << bssid);
885  CapabilityInformation capabilities = probeResp.GetCapabilities ();
886  SupportedRates rates = probeResp.GetSupportedRates ();
887  for (const auto & selector : GetWifiPhy ()->GetBssMembershipSelectorList ())
888  {
889  if (!rates.IsBssMembershipSelectorRate (selector))
890  {
891  NS_LOG_DEBUG ("Supported rates do not fit with the BSS membership selector");
892  return;
893  }
894  }
895  for (const auto & mode : GetWifiPhy ()->GetModeList ())
896  {
897  if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
898  {
900  if (rates.IsBasicRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
901  {
903  }
904  }
905  }
906 
907  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
908  if (GetErpSupported ())
909  {
910  bool isErpAllowed = false;
911  for (const auto & mode : GetWifiPhy ()->GetModeList (WIFI_MOD_CLASS_ERP_OFDM))
912  {
913  if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
914  {
915  isErpAllowed = true;
916  break;
917  }
918  }
919  if (!isErpAllowed)
920  {
921  //disable short slot time and set cwMin to 31
922  GetWifiPhy ()->SetSlot (MicroSeconds (20));
923  ConfigureContentionWindow (31, 1023);
924  }
925  else
926  {
927  ErpInformation erpInformation = probeResp.GetErpInformation ();
928  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
929  if (GetWifiRemoteStationManager ()->GetShortSlotTimeEnabled ())
930  {
931  //enable short slot time
932  GetWifiPhy ()->SetSlot (MicroSeconds (9));
933  }
934  else
935  {
936  //disable short slot time
937  GetWifiPhy ()->SetSlot (MicroSeconds (20));
938  }
939  ConfigureContentionWindow (15, 1023);
940  }
941  }
942  GetWifiRemoteStationManager ()->SetShortPreambleEnabled (isShortPreambleEnabled);
944  SetBssid (bssid);
945 }
946 
947 void
949 {
950  NS_LOG_FUNCTION (this << assocResp << apAddr);
951  CapabilityInformation capabilities = assocResp.GetCapabilities ();
952  SupportedRates rates = assocResp.GetSupportedRates ();
953  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
954  if (GetErpSupported ())
955  {
956  bool isErpAllowed = false;
957  for (const auto & mode : GetWifiPhy ()->GetModeList (WIFI_MOD_CLASS_ERP_OFDM))
958  {
959  if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
960  {
961  isErpAllowed = true;
962  break;
963  }
964  }
965  if (!isErpAllowed)
966  {
967  //disable short slot time and set cwMin to 31
968  GetWifiPhy ()->SetSlot (MicroSeconds (20));
969  ConfigureContentionWindow (31, 1023);
970  }
971  else
972  {
973  ErpInformation erpInformation = assocResp.GetErpInformation ();
974  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
975  if (GetWifiRemoteStationManager ()->GetShortSlotTimeEnabled ())
976  {
977  //enable short slot time
978  GetWifiPhy ()->SetSlot (MicroSeconds (9));
979  }
980  else
981  {
982  //disable short slot time
983  GetWifiPhy ()->SetSlot (MicroSeconds (20));
984  }
985  ConfigureContentionWindow (15, 1023);
986  }
987  }
988  GetWifiRemoteStationManager ()->SetShortPreambleEnabled (isShortPreambleEnabled);
990  if (GetQosSupported ())
991  {
992  bool qosSupported = false;
993  EdcaParameterSet edcaParameters = assocResp.GetEdcaParameterSet ();
994  if (edcaParameters.IsQosSupported ())
995  {
996  qosSupported = true;
997  //The value of the TXOP Limit field is specified as an unsigned integer, with the least significant octet transmitted first, in units of 32 μs.
998  SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTxopLimit ()));
999  SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTxopLimit ()));
1000  SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ()));
1001  SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ()));
1002  }
1003  GetWifiRemoteStationManager ()->SetQosSupport (apAddr, qosSupported);
1004  }
1005  if (GetHtSupported ())
1006  {
1007  HtCapabilities htCapabilities = assocResp.GetHtCapabilities ();
1008  if (!htCapabilities.IsSupportedMcs (0))
1009  {
1011  }
1012  else
1013  {
1014  GetWifiRemoteStationManager ()->AddStationHtCapabilities (apAddr, htCapabilities);
1015  }
1016  }
1017  if (GetVhtSupported ())
1018  {
1019  VhtCapabilities vhtCapabilities = assocResp.GetVhtCapabilities ();
1020  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1021  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1022  {
1023  GetWifiRemoteStationManager ()->AddStationVhtCapabilities (apAddr, vhtCapabilities);
1024  VhtOperation vhtOperation = assocResp.GetVhtOperation ();
1025  }
1026  }
1027  if (GetHeSupported ())
1028  {
1029  HeCapabilities hecapabilities = assocResp.GetHeCapabilities ();
1030  if (hecapabilities.GetSupportedMcsAndNss () != 0)
1031  {
1032  GetWifiRemoteStationManager ()->AddStationHeCapabilities (apAddr, hecapabilities);
1033  HeOperation heOperation = assocResp.GetHeOperation ();
1034  GetHeConfiguration ()->SetAttribute ("BssColor", UintegerValue (heOperation.GetBssColor ()));
1035  }
1036 
1037  MuEdcaParameterSet muEdcaParameters = assocResp.GetMuEdcaParameterSet ();
1038  if (muEdcaParameters.IsPresent ())
1039  {
1040  SetMuEdcaParameters (AC_BE, muEdcaParameters.GetMuCwMin (AC_BE), muEdcaParameters.GetMuCwMax (AC_BE),
1041  muEdcaParameters.GetMuAifsn (AC_BE), muEdcaParameters.GetMuEdcaTimer (AC_BE));
1042  SetMuEdcaParameters (AC_BK, muEdcaParameters.GetMuCwMin (AC_BK), muEdcaParameters.GetMuCwMax (AC_BK),
1043  muEdcaParameters.GetMuAifsn (AC_BK), muEdcaParameters.GetMuEdcaTimer (AC_BK));
1044  SetMuEdcaParameters (AC_VI, muEdcaParameters.GetMuCwMin (AC_VI), muEdcaParameters.GetMuCwMax (AC_VI),
1045  muEdcaParameters.GetMuAifsn (AC_VI), muEdcaParameters.GetMuEdcaTimer (AC_VI));
1046  SetMuEdcaParameters (AC_VO, muEdcaParameters.GetMuCwMin (AC_VO), muEdcaParameters.GetMuCwMax (AC_VO),
1047  muEdcaParameters.GetMuAifsn (AC_VO), muEdcaParameters.GetMuEdcaTimer (AC_VO));
1048  }
1049  }
1050  for (const auto & mode : GetWifiPhy ()->GetModeList ())
1051  {
1052  if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
1053  {
1054  GetWifiRemoteStationManager ()->AddSupportedMode (apAddr, mode);
1055  if (rates.IsBasicRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
1056  {
1058  }
1059  }
1060  }
1061  if (GetHtSupported ())
1062  {
1063  HtCapabilities htCapabilities = assocResp.GetHtCapabilities ();
1064  for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT))
1065  {
1066  if (htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1067  {
1068  GetWifiRemoteStationManager ()->AddSupportedMcs (apAddr, mcs);
1069  //here should add a control to add basic MCS when it is implemented
1070  }
1071  }
1072  }
1073  if (GetVhtSupported ())
1074  {
1075  VhtCapabilities vhtcapabilities = assocResp.GetVhtCapabilities ();
1076  for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT))
1077  {
1078  if (vhtcapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
1079  {
1080  GetWifiRemoteStationManager ()->AddSupportedMcs (apAddr, mcs);
1081  //here should add a control to add basic MCS when it is implemented
1082  }
1083  }
1084  }
1085  if (GetHtSupported ())
1086  {
1087  ExtendedCapabilities extendedCapabilities = assocResp.GetExtendedCapabilities ();
1088  //TODO: to be completed
1089  }
1090  if (GetHeSupported ())
1091  {
1092  HeCapabilities heCapabilities = assocResp.GetHeCapabilities ();
1093  for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
1094  {
1095  if (heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
1096  {
1097  GetWifiRemoteStationManager ()->AddSupportedMcs (apAddr, mcs);
1098  //here should add a control to add basic MCS when it is implemented
1099  }
1100  }
1101  }
1102 }
1103 
1106 {
1107  SupportedRates rates;
1108  for (const auto & mode : GetWifiPhy ()->GetModeList ())
1109  {
1110  uint64_t modeDataRate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ());
1111  NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
1112  rates.AddSupportedRate (modeDataRate);
1113  }
1114  if (GetHtSupported ())
1115  {
1116  for (const auto & selector : GetWifiPhy ()->GetBssMembershipSelectorList ())
1117  {
1118  rates.AddBssMembershipSelectorRate (selector);
1119  }
1120  }
1121  return rates;
1122 }
1123 
1126 {
1127  CapabilityInformation capabilities;
1128  capabilities.SetShortPreamble (GetWifiPhy ()->GetShortPhyPreambleSupported () || GetErpSupported ());
1130  return capabilities;
1131 }
1132 
1133 void
1135 {
1136  if (value == ASSOCIATED
1137  && m_state != ASSOCIATED)
1138  {
1139  m_assocLogger (GetBssid ());
1140  }
1141  else if (value != ASSOCIATED
1142  && m_state == ASSOCIATED)
1143  {
1145  }
1146  m_state = value;
1147 }
1148 
1149 void
1150 StaWifiMac::SetEdcaParameters (AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
1151 {
1152  Ptr<QosTxop> edca = GetQosTxop (ac);
1153  edca->SetMinCw (cwMin);
1154  edca->SetMaxCw (cwMax);
1155  edca->SetAifsn (aifsn);
1156  edca->SetTxopLimit (txopLimit);
1157 }
1158 
1159 void
1160 StaWifiMac::SetMuEdcaParameters (AcIndex ac, uint16_t cwMin, uint16_t cwMax, uint8_t aifsn, Time muEdcaTimer)
1161 {
1162  Ptr<QosTxop> edca = GetQosTxop (ac);
1163  edca->SetMuCwMin (cwMin);
1164  edca->SetMuCwMax (cwMax);
1165  edca->SetMuAifsn (aifsn);
1166  edca->SetMuEdcaTimer (muEdcaTimer);
1167 }
1168 
1169 void
1171 {
1172  NS_LOG_FUNCTION (this);
1173  if (IsAssociated ())
1174  {
1175  NS_LOG_DEBUG ("PHY capabilities changed: send reassociation request");
1177  SendAssociationRequest (true);
1178  }
1179 }
1180 
1181 void
1183 {
1184  NS_LOG_FUNCTION (this);
1185 
1187 
1188  if (IsInitialized ())
1189  {
1190  Disassociated ();
1191  }
1192 }
1193 
1194 } //namespace ns3
#define max(a, b)
Definition: 80211b.c:43
AttributeValue implementation for Boolean.
Definition: boolean.h:37
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1386
bool IsShortPreamble(void) const
Check if the short preamble bit in the capability information field is set to 1.
bool IsShortSlotTime(void) const
Check if the short slot time in the capability information field is set to 1.
void SetShortSlotTime(bool shortSlotTime)
Set the short slot time bit in the capability information field.
void SetShortPreamble(bool shortPreamble)
Set the short preamble bit in the capability information field.
bool IsEss(void) const
Check if the Extended Service Set (ESS) bit in the capability information field is set to 1.
The EDCA Parameter Set.
uint16_t GetBeTxopLimit(void) const
Return the AC_BE TXOP Limit field in the EdcaParameterSet information element.
uint32_t GetBeCWmin(void) const
Return the AC_BE CWmin field in the EdcaParameterSet information element.
uint8_t GetVoAifsn(void) const
Return the AC_VO AIFSN field in the EdcaParameterSet information element.
uint8_t GetBeAifsn(void) const
Return the AC_BE AIFSN field in the EdcaParameterSet information element.
uint16_t GetVoTxopLimit(void) const
Return the AC_VO TXOP Limit field in the EdcaParameterSet information element.
uint32_t GetVoCWmax(void) const
Return the AC_VO CWmax field in the EdcaParameterSet information element.
uint32_t GetViCWmin(void) const
Return the AC_VI CWmin field in the EdcaParameterSet information element.
uint8_t GetBkAifsn(void) const
Return the AC_BK AIFSN field in the EdcaParameterSet information element.
uint8_t IsQosSupported(void) const
Is QOS supported function.
uint32_t GetViCWmax(void) const
Return the AC_VI CWmax field in the EdcaParameterSet information element.
uint8_t GetViAifsn(void) const
Return the AC_VI AIFSN field in the EdcaParameterSet information element.
uint32_t GetBeCWmax(void) const
Return the AC_BE CWmax field in the EdcaParameterSet information element.
uint32_t GetBkCWmax(void) const
Return the AC_BK CWmax field in the EdcaParameterSet information element.
uint16_t GetViTxopLimit(void) const
Return the AC_VI TXOP Limit field in the EdcaParameterSet information element.
uint32_t GetBkCWmin(void) const
Return the AC_BK CWmin field in the EdcaParameterSet information element.
uint32_t GetVoCWmin(void) const
Return the AC_VO CWmin field in the EdcaParameterSet information element.
uint16_t GetBkTxopLimit(void) const
Return the AC_BK TXOP Limit field in the EdcaParameterSet information element.
The ErpInformation Information Element.
uint8_t GetBarkerPreambleMode(void) const
Return the Barker_Preamble_Mode field in the ErpInformation information element.
uint8_t GetUseProtection(void) const
Return the Use_Protection field in the ErpInformation information element.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:71
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:65
The Extended Capabilities Information Element.
The IEEE 802.11ax HE Capabilities.
bool IsSupportedRxMcs(uint8_t mcs) const
Is RX MCS supported.
uint16_t GetSupportedMcsAndNss() const
Return the MCS and NSS field in the HE Capabilities information element.
The HE Operation Information Element.
Definition: he-operation.h:36
uint8_t GetBssColor(void) const
Get the BSS color.
The HT Capabilities Information Element.
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
an EUI-48 address
Definition: mac48-address.h:44
static Mac48Address GetBroadcast(void)
bool IsGroup(void) const
Implement the header for management frames of type association request.
Definition: mgt-headers.h:50
void SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:596
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:536
void SetHtCapabilities(HtCapabilities htCapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:572
void SetExtendedCapabilities(ExtendedCapabilities extendedCapabilities)
Set the Extended Capabilities.
Definition: mgt-headers.cc:560
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:530
void SetListenInterval(uint16_t interval)
Set the listen interval.
Definition: mgt-headers.cc:542
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:548
void SetVhtCapabilities(VhtCapabilities vhtCapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:584
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:320
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:968
MuEdcaParameterSet GetMuEdcaParameterSet(void) const
Return the MU EDCA Parameter Set.
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:956
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set.
VhtOperation GetVhtOperation(void) const
Return the VHT operation.
SupportedRates GetSupportedRates(void)
Return the supported rates.
Definition: mgt-headers.cc:920
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:992
StatusCode GetStatusCode(void)
Return the status code.
Definition: mgt-headers.cc:914
HeOperation GetHeOperation(void) const
Return the HE operation.
ErpInformation GetErpInformation(void) const
Return the ERP information.
uint16_t GetAssociationId(void) const
Return the association ID.
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:944
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:862
Implement the header for management frames of type probe request.
Definition: mgt-headers.h:529
void SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:94
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:40
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:52
void SetVhtCapabilities(VhtCapabilities vhtCapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:82
void SetHtCapabilities(HtCapabilities htCapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:70
void SetExtendedCapabilities(ExtendedCapabilities extendedCapabilities)
Set the extended capabilities.
Definition: mgt-headers.cc:58
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:633
VhtOperation GetVhtOperation(void) const
Return the VHT operation.
Definition: mgt-headers.cc:286
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:298
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:274
HeOperation GetHeOperation(void) const
Return the HE operation.
Definition: mgt-headers.cc:310
MuEdcaParameterSet GetMuEdcaParameterSet(void) const
Return the MU EDCA Parameter Set.
Definition: mgt-headers.cc:376
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:226
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set.
Definition: mgt-headers.cc:370
Ssid GetSsid(void) const
Return the Service Set Identifier (SSID).
Definition: mgt-headers.cc:202
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:214
ErpInformation GetErpInformation(void) const
Return the ERP information.
Definition: mgt-headers.cc:352
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:250
uint64_t GetBeaconIntervalUs(void) const
Return the beacon interval in microseconds unit.
Definition: mgt-headers.cc:208
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:238
Implement the header for management frames of type reassociation request.
Definition: mgt-headers.h:182
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:723
void SetHtCapabilities(HtCapabilities htCapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:759
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:735
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:717
void SetExtendedCapabilities(ExtendedCapabilities extendedCapabilities)
Set the Extended Capabilities.
Definition: mgt-headers.cc:747
void SetListenInterval(uint16_t interval)
Set the listen interval.
Definition: mgt-headers.cc:729
void SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:783
void SetVhtCapabilities(VhtCapabilities vhtCapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:771
void SetCurrentApAddress(Mac48Address currentApAddr)
Set the address of the current access point.
Definition: mgt-headers.cc:813
The MU EDCA Parameter Set.
uint16_t GetMuCwMin(uint8_t aci) const
Get the CWmin value encoded by the ECWmin subfield of the ECWmin/ECWmax field in the MU AC Parameter ...
uint8_t GetMuAifsn(uint8_t aci) const
Get the AIFSN subfield of the ACI/AIFSN field in the MU AC Parameter Record field corresponding to th...
bool IsPresent(void) const
Return true if a valid MU EDCA Parameter Set is present in this object.
uint16_t GetMuCwMax(uint8_t aci) const
Get the CWmax value encoded by the ECWmax subfield of the ECWmin/ECWmax field in the MU AC Parameter ...
Time GetMuEdcaTimer(uint8_t aci) const
Get the MU EDCA Timer value encoded in the MU AC Parameter Record field corresponding to the given AC...
bool IsInitialized(void) const
Check if the object has been initialized.
Definition: object.cc:208
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:963
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
void SetMuCwMax(uint16_t cwMax)
Set the maximum contention window size to use while the MU EDCA Timer is running.
Definition: qos-txop.cc:165
void SetMuEdcaTimer(Time timer)
Set the MU EDCA Timer.
Definition: qos-txop.cc:179
void SetMuAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS while the MU EDCA Timer is running.
Definition: qos-txop.cc:172
void SetMuCwMin(uint16_t cwMin)
Set the minimum contention window size to use while the MU EDCA Timer is running.
Definition: qos-txop.cc:158
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:204
Introspection did not find any typical Config paths.
Definition: snr-tag.h:35
double Get(void) const
Return the SNR value.
Definition: snr-tag.cc:89
bool IsEqual(const Ssid &o) const
Check if the two SSIDs are equal.
Definition: ssid.cc:55
The Wifi MAC high model for a non-AP STA in a BSS.
Definition: sta-wifi-mac.h:107
Time m_waitBeaconTimeout
wait beacon timeout
Definition: sta-wifi-mac.h:326
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current STA.
void ScanningTimeout(void)
This method is called after wait beacon timeout or wait probe request timeout has occurred.
bool m_activeProbing
active probing
Definition: sta-wifi-mac.h:335
virtual ~StaWifiMac()
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
void SetEdcaParameters(AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
Set the EDCA parameters.
void SetState(MacState value)
Set the current MAC state.
Time m_beaconWatchdogEnd
beacon watchdog end
Definition: sta-wifi-mac.h:333
void UpdateApInfoFromProbeResp(MgtProbeResponseHeader probeResp, Mac48Address apAddr, Mac48Address bssid)
Update AP's information from probe response.
TracedCallback< Mac48Address > m_deAssocLogger
disassociation logger
Definition: sta-wifi-mac.h:343
void NotifyChannelSwitching(void) override
Notify that channel has been switched.
void SendProbeRequest(void)
Forward a probe request packet to the DCF.
void UpdateApInfoFromBeacon(MgtBeaconHeader beacon, Mac48Address apAddr, Mac48Address bssid)
Update associated AP's information from beacon.
MacState
The current MAC state of the STA.
Definition: sta-wifi-mac.h:161
EventId m_beaconWatchdog
beacon watchdog
Definition: sta-wifi-mac.h:332
uint16_t GetAssociationId(void) const
Return the association ID.
void UpdateCandidateApList(ApInfo newApInfo)
Update list of candidate AP to associate.
void UpdateApInfoFromAssocResp(MgtAssocResponseHeader assocResp, Mac48Address apAddr)
Update AP's information from association response.
bool IsWaitAssocResp(void) const
Return whether we are waiting for an association response from an AP.
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
void TryToEnsureAssociated(void)
Try to ensure that we are associated with an AP by taking an appropriate action depending on the curr...
bool IsAssociated(void) const
Return whether we are associated with an AP.
void Disassociated(void)
Take actions after disassociation.
uint32_t m_maxMissedBeacons
maximum missed beacons
Definition: sta-wifi-mac.h:334
EventId m_waitBeaconEvent
wait beacon event
Definition: sta-wifi-mac.h:329
TracedCallback< Mac48Address > m_assocLogger
association logger
Definition: sta-wifi-mac.h:342
void AssocRequestTimeout(void)
This method is called after the association timeout occurred.
void Receive(Ptr< WifiMacQueueItem > mpdu) override
Handle a received packet.
void RestartBeaconWatchdog(Time delay)
Restarts the beacon timer.
void MissedBeacons(void)
This method is called after we have not received a beacon from the AP.
EventId m_probeRequestEvent
probe request event
Definition: sta-wifi-mac.h:330
static TypeId GetTypeId(void)
Get the type ID.
Definition: sta-wifi-mac.cc:42
void StartScanning(void)
Start the scanning process which trigger active or passive scanning based on the active probing flag.
uint16_t m_aid
Association AID.
Definition: sta-wifi-mac.h:325
MacState m_state
MAC state.
Definition: sta-wifi-mac.h:324
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
void SetMuEdcaParameters(AcIndex ac, uint16_t cwMin, uint16_t cwMax, uint8_t aifsn, Time muEdcaTimer)
Set the MU EDCA parameters.
void SetWifiPhy(const Ptr< WifiPhy > phy) override
void PhyCapabilitiesChanged(void)
Indicate that PHY capabilities have changed.
TracedCallback< Time > m_beaconArrival
beacon arrival logger
Definition: sta-wifi-mac.h:344
Time m_assocRequestTimeout
association request timeout
Definition: sta-wifi-mac.h:328
void DoInitialize(void) override
Initialize() implementation.
Time m_probeRequestTimeout
probe request timeout
Definition: sta-wifi-mac.h:327
void SetActiveProbing(bool enable)
Enable or disable active probing.
std::vector< ApInfo > m_candidateAps
list of candidate APs to associate to
Definition: sta-wifi-mac.h:336
EventId m_assocRequestEvent
association request event
Definition: sta-wifi-mac.h:331
bool GetActiveProbing(void) const
Return whether active probing is enabled.
void SendAssociationRequest(bool isReassoc)
Forward an association or reassociation request packet to the DCF.
bool IsSuccess(void) const
Return whether the status code is success.
Definition: status-code.cc:42
The Supported Rates Information Element.
void AddBssMembershipSelectorRate(uint64_t bs)
Add a special value to the supported rate set, corresponding to a BSS membership selector.
bool IsBasicRate(uint64_t bs) const
Check if the given rate is a basic rate.
bool IsBssMembershipSelectorRate(uint64_t bs) const
Check if the given rate is a BSS membership selector value.
void AddSupportedRate(uint64_t bs)
Add the given rate to the supported rates.
bool IsSupportedRate(uint64_t bs) const
Check if the given rate is supported.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
AttributeValue implementation for Time.
Definition: nstime.h:1308
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:173
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:254
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:247
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:161
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:294
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Hold an unsigned integer type.
Definition: uinteger.h:44
The IEEE 802.11ac VHT Capabilities.
bool IsSupportedRxMcs(uint8_t mcs) const
Returns true if receive MCS is supported.
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
The VHT Operation Information Element.
Definition: vht-operation.h:36
Implements the IEEE 802.11 MAC header.
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
bool IsCtl(void) const
Return true if the Type is Control.
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.
bool HasData(void) const
Return true if the header type is DATA and is not DATA_NULL.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
bool IsFromDs(void) const
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
void SetDsTo(void)
Set the To DS bit in the Frame Control field.
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
bool IsProbeResp(void) const
Return true if the header is a Probe Response header.
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
bool IsProbeReq(void) const
Return true if the header is a Probe Request header.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
void SetNoOrder(void)
Unset order bit in the frame control field.
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
bool IsData(void) const
Return true if the Type is DATA.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
bool IsToDs(void) const
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
bool IsBeacon(void) const
Return true if the header is a Beacon header.
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:85
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities of the device.
Definition: wifi-mac.cc:1175
bool GetShortSlotTimeSupported(void) const
Definition: wifi-mac.cc:872
Ptr< HeConfiguration > GetHeConfiguration(void) const
Definition: wifi-mac.cc:1059
Callback< void > m_linkDown
Callback when a link is down.
Definition: wifi-mac.h:526
bool GetVhtSupported() const
Return whether the device supports VHT.
Definition: wifi-mac.cc:1075
bool GetQosSupported() const
Return whether the device supports QoS.
Definition: wifi-mac.cc:822
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
Definition: wifi-mac.cc:1325
Ssid GetSsid(void) const
Definition: wifi-mac.cc:416
Mac48Address GetAddress(void) const
Definition: wifi-mac.cc:403
Ptr< QosTxop > GetBEQueue(void) const
Accessor for the AC_BE channel access function.
Definition: wifi-mac.cc:485
bool GetHtSupported() const
Return whether the device supports HT.
Definition: wifi-mac.cc:1065
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Definition: wifi-mac.cc:371
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
Definition: wifi-mac.cc:757
Ptr< QosTxop > GetVOQueue(void) const
Accessor for the AC_VO channel access function.
Definition: wifi-mac.cc:473
Mac48Address GetBssid(void) const
Definition: wifi-mac.cc:433
bool GetHeSupported() const
Return whether the device supports HE.
Definition: wifi-mac.cc:1085
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...
Definition: wifi-mac.cc:923
virtual void NotifyChannelSwitching(void)
Notify that channel has been switched.
Definition: wifi-mac.cc:504
Ptr< WifiPhy > GetWifiPhy(void) const
Definition: wifi-mac.cc:776
virtual void SetWifiPhy(Ptr< WifiPhy > phy)
Definition: wifi-mac.cc:763
virtual void DeaggregateAmsduAndForward(Ptr< WifiMacQueueItem > mpdu)
This method can be called to de-aggregate an A-MSDU and forward the constituent packets up the stack.
Definition: wifi-mac.cc:1036
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:543
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
Definition: wifi-mac.cc:916
virtual void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
Definition: wifi-mac.cc:572
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
Definition: wifi-mac.cc:1242
bool GetErpSupported() const
Return whether the device supports ERP.
Definition: wifi-mac.cc:828
Callback< void > m_linkUp
Callback when a link is up.
Definition: wifi-mac.h:525
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
Definition: wifi-mac.cc:1186
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
Definition: wifi-mac.cc:452
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:525
void SetBssid(Mac48Address bssid)
Definition: wifi-mac.cc:422
Ptr< Txop > GetTxop(void) const
Accessor for the Txop object.
Definition: wifi-mac.cc:446
std::list< uint8_t > GetBssMembershipSelectorList(void) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1144
void SetSlot(Time slot)
Set the slot duration for this PHY.
Definition: wifi-phy.cc:682
Time GetDelayUntilIdle(void)
Definition: wifi-phy.cc:1851
void SetCapabilitiesChangedCallback(Callback< void > callback)
Definition: wifi-phy.cc:414
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
void RemoveAllSupportedMcs(Mac48Address address)
Invoked in a STA or AP to delete all of the supported MCS by a destination.
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtCapabilities)
Records VHT capabilities of the remote station.
void SetShortPreambleEnabled(bool enable)
Enable or disable short PHY preambles.
void SetQosSupport(Mac48Address from, bool qosSupported)
Records QoS support of the remote station.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
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 AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
Records HT capabilities of the remote station.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
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
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:1309
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: uinteger.h:45
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1260
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1252
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a QoS tag is attached to the packet, returns a value < 8.
Definition: qos-utils.cc:152
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:71
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ WIFI_MOD_CLASS_ERP_OFDM
ERP-OFDM (18.4)
@ AC_BE
Best Effort.
Definition: qos-utils.h:73
@ AC_VO
Voice.
Definition: qos-utils.h:79
@ AC_VI
Video.
Definition: qos-utils.h:77
@ AC_BK
Background.
Definition: qos-utils.h:75
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ STA
Definition: wifi-mac.h:53
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:522
@ WIFI_MAC_MGT_PROBE_REQUEST
@ WIFI_MAC_MGT_ASSOCIATION_REQUEST
@ WIFI_MAC_MGT_REASSOCIATION_REQUEST
@ WIFI_MAC_DATA
@ WIFI_MAC_QOSDATA
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:1648
phy
Definition: third.py:93
Struct to hold information regarding observed AP through active/passive scanning.
Definition: sta-wifi-mac.h:45
double m_snr
SNR in linear scale.
Definition: sta-wifi-mac.h:48
Mac48Address m_bssid
BSSID.
Definition: sta-wifi-mac.h:46
MgtProbeResponseHeader m_probeResp
Probe Response header.
Definition: sta-wifi-mac.h:51
Mac48Address m_apAddr
AP MAC address.
Definition: sta-wifi-mac.h:47
MgtBeaconHeader m_beacon
Beacon header.
Definition: sta-wifi-mac.h:50
bool m_activeProbing
Flag whether active probing is used or not.
Definition: sta-wifi-mac.h:49