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