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 "mac-low.h"
29 #include "mgt-headers.h"
30 #include "snr-tag.h"
31 #include "wifi-net-device.h"
32 #include "ht-configuration.h"
33 #include "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")
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_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 void
117 {
118  NS_LOG_FUNCTION (this << enable);
119  m_activeProbing = enable;
121  {
122  NS_LOG_DEBUG ("STA is still scanning, reset scanning process");
123  StartScanning ();
124  }
125 }
126 
127 bool
129 {
130  return m_activeProbing;
131 }
132 
133 void
135 {
136  NS_LOG_FUNCTION (this << phy);
139 }
140 
141 void
143 {
144  NS_LOG_FUNCTION (this << stationManager);
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 ());
163  probe.SetSupportedRates (GetSupportedRates ());
164  if (GetHtSupported () || GetVhtSupported () || GetHeSupported ())
165  {
166  probe.SetExtendedCapabilities (GetExtendedCapabilities ());
167  probe.SetHtCapabilities (GetHtCapabilities ());
168  }
169  if (GetVhtSupported () || GetHeSupported ())
170  {
171  probe.SetVhtCapabilities (GetVhtCapabilities ());
172  }
173  if (GetHeSupported ())
174  {
175  probe.SetHeCapabilities (GetHeCapabilities ());
176  }
177  packet->AddHeader (probe);
178 
179  //The standard is not clear on the correct queue for management
180  //frames if we are a QoS AP. The approach taken here is to always
181  //use the non-QoS for these regardless of whether we have a QoS
182  //association or not.
183  m_txop->Queue (packet, hdr);
184 }
185 
186 void
188 {
189  NS_LOG_FUNCTION (this << GetBssid () << isReassoc);
190  WifiMacHeader hdr;
192  hdr.SetAddr1 (GetBssid ());
193  hdr.SetAddr2 (GetAddress ());
194  hdr.SetAddr3 (GetBssid ());
195  hdr.SetDsNotFrom ();
196  hdr.SetDsNotTo ();
197  Ptr<Packet> packet = Create<Packet> ();
198  if (!isReassoc)
199  {
200  MgtAssocRequestHeader assoc;
201  assoc.SetSsid (GetSsid ());
203  assoc.SetCapabilities (GetCapabilities ());
204  assoc.SetListenInterval (0);
205  if (GetHtSupported () || GetVhtSupported () || GetHeSupported ())
206  {
209  }
210  if (GetVhtSupported () || GetHeSupported ())
211  {
213  }
214  if (GetHeSupported ())
215  {
217  }
218  packet->AddHeader (assoc);
219  }
220  else
221  {
222  MgtReassocRequestHeader reassoc;
223  reassoc.SetCurrentApAddress (GetBssid ());
224  reassoc.SetSsid (GetSsid ());
226  reassoc.SetCapabilities (GetCapabilities ());
227  reassoc.SetListenInterval (0);
228  if (GetHtSupported () || GetVhtSupported () || GetHeSupported ())
229  {
232  }
233  if (GetVhtSupported () || GetHeSupported ())
234  {
236  }
237  if (GetHeSupported ())
238  {
240  }
241  packet->AddHeader (reassoc);
242  }
243 
244  //The standard is not clear on the correct queue for management
245  //frames if we are a QoS AP. The approach taken here is to always
246  //use the non-QoS for these regardless of whether we have a QoS
247  //association or not.
248  m_txop->Queue (packet, hdr);
249 
251  {
253  }
256 }
257 
258 void
260 {
261  NS_LOG_FUNCTION (this);
264 }
265 
266 void
268 {
269  NS_LOG_FUNCTION (this);
270  switch (m_state)
271  {
272  case ASSOCIATED:
273  return;
274  break;
275  case WAIT_PROBE_RESP:
276  /* we have sent a probe request earlier so we
277  do not need to re-send a probe request immediately.
278  We just need to wait until probe-request-timeout
279  or until we get a probe response
280  */
281  break;
282  case WAIT_BEACON:
283  /* we have initiated passive scanning, continue to wait
284  and gather beacons
285  */
286  break;
287  case UNASSOCIATED:
288  /* we were associated but we missed a bunch of beacons
289  * so we should assume we are not associated anymore.
290  * We try to initiate a scan now.
291  */
292  m_linkDown ();
293  StartScanning ();
294  break;
295  case WAIT_ASSOC_RESP:
296  /* we have sent an association request so we do not need to
297  re-send an association request right now. We just need to
298  wait until either assoc-request-timeout or until
299  we get an association response.
300  */
301  break;
302  case REFUSED:
303  /* we have sent an association request and received a negative
304  association response. We wait until someone restarts an
305  association with a given ssid.
306  */
307  break;
308  }
309 }
310 
311 void
313 {
314  NS_LOG_FUNCTION (this);
315  m_candidateAps.clear ();
317  {
319  }
321  {
323  }
324  if (GetActiveProbing ())
325  {
327  SendProbeRequest ();
330  this);
331  }
332  else
333  {
337  this);
338  }
339 }
340 
341 void
343 {
344  NS_LOG_FUNCTION (this);
345  if (!m_candidateAps.empty ())
346  {
347  ApInfo bestAp = m_candidateAps.front();
348  m_candidateAps.erase(m_candidateAps.begin ());
349  NS_LOG_DEBUG ("Attempting to associate with BSSID " << bestAp.m_bssid);
350  Time beaconInterval;
351  if (bestAp.m_activeProbing)
352  {
353  UpdateApInfoFromProbeResp (bestAp.m_probeResp, bestAp.m_apAddr, bestAp.m_bssid);
354  beaconInterval = MicroSeconds (bestAp.m_probeResp.GetBeaconIntervalUs ());
355  }
356  else
357  {
358  UpdateApInfoFromBeacon (bestAp.m_beacon, bestAp.m_apAddr, bestAp.m_bssid);
359  beaconInterval = MicroSeconds (bestAp.m_beacon.GetBeaconIntervalUs ());
360  }
361 
362  Time delay = beaconInterval * m_maxMissedBeacons;
363  RestartBeaconWatchdog (delay);
365  SendAssociationRequest (false);
366  }
367  else
368  {
369  NS_LOG_DEBUG ("Exhausted list of candidate AP; restart scanning");
370  StartScanning ();
371  }
372 }
373 
374 void
376 {
377  NS_LOG_FUNCTION (this);
379  SendAssociationRequest (false);
380 }
381 
382 void
384 {
385  NS_LOG_FUNCTION (this);
387  {
389  {
391  }
394  return;
395  }
396  NS_LOG_DEBUG ("beacon missed");
399 }
400 
401 void
403 {
404  NS_LOG_FUNCTION (this << delay);
408  {
409  NS_LOG_DEBUG ("really restart watchdog.");
411  }
412 }
413 
414 bool
416 {
417  return m_state == ASSOCIATED;
418 }
419 
420 bool
422 {
423  return m_state == WAIT_ASSOC_RESP;
424 }
425 
426 void
428 {
429  NS_LOG_FUNCTION (this << packet << to);
430  if (!IsAssociated ())
431  {
432  NotifyTxDrop (packet);
434  return;
435  }
436  WifiMacHeader hdr;
437 
438  //If we are not a QoS AP then we definitely want to use AC_BE to
439  //transmit the packet. A TID of zero will map to AC_BE (through \c
440  //QosUtilsMapTidToAc()), so we use that as our default here.
441  uint8_t tid = 0;
442 
443  //For now, an AP that supports QoS does not support non-QoS
444  //associations, and vice versa. In future the AP model should
445  //support simultaneously associated QoS and non-QoS STAs, at which
446  //point there will need to be per-association QoS state maintained
447  //by the association state machine, and consulted here.
448  if (GetQosSupported ())
449  {
452  hdr.SetQosNoEosp ();
453  hdr.SetQosNoAmsdu ();
454  //Transmission of multiple frames in the same TXOP is not
455  //supported for now
456  hdr.SetQosTxopLimit (0);
457 
458  //Fill in the QoS control field in the MAC header
459  tid = QosUtilsGetTidForPacket (packet);
460  //Any value greater than 7 is invalid and likely indicates that
461  //the packet had no QoS tag, so we revert to zero, which'll
462  //mean that AC_BE is used.
463  if (tid > 7)
464  {
465  tid = 0;
466  }
467  hdr.SetQosTid (tid);
468  }
469  else
470  {
471  hdr.SetType (WIFI_MAC_DATA);
472  }
474  {
475  hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT/VHT/HE control field is not yet implemented (set it to 1 when implemented)
476  }
477 
478  hdr.SetAddr1 (GetBssid ());
479  hdr.SetAddr2 (m_low->GetAddress ());
480  hdr.SetAddr3 (to);
481  hdr.SetDsNotFrom ();
482  hdr.SetDsTo ();
483 
484  if (GetQosSupported ())
485  {
486  //Sanity check that the TID is valid
487  NS_ASSERT (tid < 8);
488  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
489  }
490  else
491  {
492  m_txop->Queue (packet, hdr);
493  }
494 }
495 
496 void
498 {
499  NS_LOG_FUNCTION (this << packet << hdr);
500  NS_ASSERT (!hdr->IsCtl ());
501  if (hdr->GetAddr3 () == GetAddress ())
502  {
503  NS_LOG_LOGIC ("packet sent by us.");
504  return;
505  }
506  else if (hdr->GetAddr1 () != GetAddress ()
507  && !hdr->GetAddr1 ().IsGroup ())
508  {
509  NS_LOG_LOGIC ("packet is not for us");
510  NotifyRxDrop (packet);
511  return;
512  }
513  else if ((hdr->GetAddr1 () == GetAddress ()) && (hdr->GetAddr2 () == GetBssid ()) && hdr->IsCfPoll ())
514  {
516  }
517  if (hdr->IsData ())
518  {
519  if (!IsAssociated ())
520  {
521  NS_LOG_LOGIC ("Received data frame while not associated: ignore");
522  NotifyRxDrop (packet);
523  return;
524  }
525  if (!(hdr->IsFromDs () && !hdr->IsToDs ()))
526  {
527  NS_LOG_LOGIC ("Received data frame not from the DS: ignore");
528  NotifyRxDrop (packet);
529  return;
530  }
531  if (hdr->GetAddr2 () != GetBssid ())
532  {
533  NS_LOG_LOGIC ("Received data frame not from the BSS we are associated with: ignore");
534  NotifyRxDrop (packet);
535  return;
536  }
537  if (hdr->IsQosData ())
538  {
539  if (hdr->IsQosAmsdu ())
540  {
541  NS_ASSERT (hdr->GetAddr3 () == GetBssid ());
542  DeaggregateAmsduAndForward (packet, hdr);
543  packet = 0;
544  }
545  else
546  {
547  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
548  }
549  }
550  else if (hdr->HasData ())
551  {
552  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
553  }
554  return;
555  }
556  else if (hdr->IsProbeReq ()
557  || hdr->IsAssocReq ()
558  || hdr->IsReassocReq ())
559  {
560  //This is a frame aimed at an AP, so we can safely ignore it.
561  NotifyRxDrop (packet);
562  return;
563  }
564  else if (hdr->IsBeacon ())
565  {
566  NS_LOG_DEBUG ("Beacon received");
567  MgtBeaconHeader beacon;
568  packet->RemoveHeader (beacon);
569  CapabilityInformation capabilities = beacon.GetCapabilities ();
570  NS_ASSERT (capabilities.IsEss ());
571  bool goodBeacon = false;
572  if (GetSsid ().IsBroadcast ()
573  || beacon.GetSsid ().IsEqual (GetSsid ()))
574  {
575  NS_LOG_LOGIC ("Beacon is for our SSID");
576  goodBeacon = true;
577  }
578  CfParameterSet cfParameterSet = beacon.GetCfParameterSet ();
579  if (cfParameterSet.GetCFPCount () == 0)
580  {
581  //see section 9.3.2.2 802.11-1999
582  if (GetPcfSupported ())
583  {
584  m_low->DoNavStartNow (MicroSeconds (cfParameterSet.GetCFPMaxDurationUs ()));
585  }
586  else
587  {
588  m_low->DoNavStartNow (MicroSeconds (cfParameterSet.GetCFPDurRemainingUs ()));
589  }
590  }
591  SupportedRates rates = beacon.GetSupportedRates ();
592  bool bssMembershipSelectorMatch = false;
593  for (uint8_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
594  {
595  uint8_t selector = m_phy->GetBssMembershipSelector (i);
596  if (rates.IsBssMembershipSelectorRate (selector))
597  {
598  NS_LOG_LOGIC ("Beacon is matched to our BSS membership selector");
599  bssMembershipSelectorMatch = true;
600  }
601  }
602  if (m_phy->GetNBssMembershipSelectors () > 0 && bssMembershipSelectorMatch == false)
603  {
604  NS_LOG_LOGIC ("No match for BSS membership selector");
605  goodBeacon = false;
606  }
607  if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ())
608  {
609  NS_LOG_LOGIC ("Beacon is not for us");
610  goodBeacon = false;
611  }
612  if (goodBeacon && m_state == ASSOCIATED)
613  {
616  RestartBeaconWatchdog (delay);
617  UpdateApInfoFromBeacon (beacon, hdr->GetAddr2 (), hdr->GetAddr3 ());
618  }
619  if (goodBeacon && m_state == WAIT_BEACON)
620  {
621  NS_LOG_DEBUG ("Beacon received while scanning from " << hdr->GetAddr2 ());
622  SnrTag snrTag;
623  bool removed = packet->RemovePacketTag (snrTag);
624  NS_ASSERT (removed);
625  ApInfo apInfo;
626  apInfo.m_apAddr = hdr->GetAddr2 ();
627  apInfo.m_bssid = hdr->GetAddr3 ();
628  apInfo.m_activeProbing = false;
629  apInfo.m_snr = snrTag.Get ();
630  apInfo.m_beacon = beacon;
631  UpdateCandidateApList (apInfo);
632  }
633  return;
634  }
635  else if (hdr->IsProbeResp ())
636  {
637  if (m_state == WAIT_PROBE_RESP)
638  {
639  NS_LOG_DEBUG ("Probe response received while scanning from " << hdr->GetAddr2 ());
640  MgtProbeResponseHeader probeResp;
641  packet->RemoveHeader (probeResp);
642  if (!probeResp.GetSsid ().IsEqual (GetSsid ()))
643  {
644  NS_LOG_DEBUG ("Probe response is not for our SSID");
645  return;
646  }
647  SnrTag snrTag;
648  bool removed = packet->RemovePacketTag (snrTag);
649  NS_ASSERT (removed);
650  ApInfo apInfo;
651  apInfo.m_apAddr = hdr->GetAddr2 ();
652  apInfo.m_bssid = hdr->GetAddr3 ();
653  apInfo.m_activeProbing = true;
654  apInfo.m_snr = snrTag.Get ();
655  apInfo.m_probeResp = probeResp;
656  UpdateCandidateApList (apInfo);
657  }
658  return;
659  }
660  else if (hdr->IsAssocResp () || hdr->IsReassocResp ())
661  {
662  if (m_state == WAIT_ASSOC_RESP)
663  {
664  MgtAssocResponseHeader assocResp;
665  packet->RemoveHeader (assocResp);
667  {
669  }
670  if (assocResp.GetStatusCode ().IsSuccess ())
671  {
673  if (hdr->IsReassocResp ())
674  {
675  NS_LOG_DEBUG ("reassociation done");
676  }
677  else
678  {
679  NS_LOG_DEBUG ("association completed");
680  }
681  UpdateApInfoFromAssocResp (assocResp, hdr->GetAddr2 ());
682  if (!m_linkUp.IsNull ())
683  {
684  m_linkUp ();
685  }
686  }
687  else
688  {
689  NS_LOG_DEBUG ("association refused");
690  if (m_candidateAps.empty ())
691  {
692  SetState (REFUSED);
693  }
694  else
695  {
696  ScanningTimeout ();
697  }
698  }
699  }
700  return;
701  }
702 
703  //Invoke the receive handler of our parent class to deal with any
704  //other frames. Specifically, this will handle Block Ack-related
705  //Management Action frames.
706  RegularWifiMac::Receive (packet, hdr);
707 }
708 
709 void
711 {
712  NS_LOG_FUNCTION (this << newApInfo.m_bssid << newApInfo.m_apAddr << newApInfo.m_snr << newApInfo.m_activeProbing << newApInfo.m_beacon << newApInfo.m_probeResp);
713  // Remove duplicate ApInfo entry
714  for (std::vector<ApInfo>::iterator i = m_candidateAps.begin(); i != m_candidateAps.end(); ++i)
715  {
716  if (newApInfo.m_bssid == (*i).m_bssid)
717  {
718  m_candidateAps.erase(i);
719  break;
720  }
721  }
722  // Insert before the entry with lower SNR
723  for (std::vector<ApInfo>::iterator i = m_candidateAps.begin(); i != m_candidateAps.end(); ++i)
724  {
725  if (newApInfo.m_snr > (*i).m_snr)
726  {
727  m_candidateAps.insert (i, newApInfo);
728  return;
729  }
730  }
731  // If new ApInfo is the lowest, insert at back
732  m_candidateAps.push_back(newApInfo);
733 }
734 
735 void
737 {
738  NS_LOG_FUNCTION (this << beacon << apAddr << bssid);
739  SetBssid (bssid);
740  CapabilityInformation capabilities = beacon.GetCapabilities ();
741  SupportedRates rates = beacon.GetSupportedRates ();
742  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
743  {
744  WifiMode mode = m_phy->GetMode (i);
745  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
746  {
747  m_stationManager->AddSupportedMode (apAddr, mode);
748  }
749  }
750  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
751  if (GetErpSupported ())
752  {
753  ErpInformation erpInformation = beacon.GetErpInformation ();
754  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
755  if (erpInformation.GetUseProtection () != 0)
756  {
758  }
759  else
760  {
762  }
763  if (capabilities.IsShortSlotTime () == true)
764  {
765  //enable short slot time
766  SetSlot (MicroSeconds (9));
767  }
768  else
769  {
770  //disable short slot time
771  SetSlot (MicroSeconds (20));
772  }
773  }
774  if (GetQosSupported ())
775  {
776  bool qosSupported = false;
777  EdcaParameterSet edcaParameters = beacon.GetEdcaParameterSet ();
778  if (edcaParameters.IsQosSupported ())
779  {
780  qosSupported = true;
781  //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.
782  SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTxopLimit ()));
783  SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTxopLimit ()));
784  SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ()));
785  SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ()));
786  }
787  m_stationManager->SetQosSupport (apAddr, qosSupported);
788  }
789  if (GetHtSupported ())
790  {
791  HtCapabilities htCapabilities = beacon.GetHtCapabilities ();
792  if (!htCapabilities.IsSupportedMcs (0))
793  {
795  }
796  else
797  {
798  m_stationManager->AddStationHtCapabilities (apAddr, htCapabilities);
799  HtOperation htOperation = beacon.GetHtOperation ();
800  if (htOperation.GetNonGfHtStasPresent ())
801  {
803  }
804  else
805  {
807  }
808  if (!GetVhtSupported () && GetHtConfiguration ()->GetRifsSupported () && htOperation.GetRifsMode ())
809  {
811  }
812  else
813  {
815  }
816  }
817  }
818  if (GetVhtSupported ())
819  {
820  VhtCapabilities vhtCapabilities = beacon.GetVhtCapabilities ();
821  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
822  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
823  {
824  m_stationManager->AddStationVhtCapabilities (apAddr, vhtCapabilities);
825  VhtOperation vhtOperation = beacon.GetVhtOperation ();
826  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
827  {
828  WifiMode mcs = m_phy->GetMcs (i);
829  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
830  {
831  m_stationManager->AddSupportedMcs (apAddr, mcs);
832  }
833  }
834  }
835  }
836  if (GetHtSupported () || GetVhtSupported ())
837  {
838  ExtendedCapabilities extendedCapabilities = beacon.GetExtendedCapabilities ();
839  //TODO: to be completed
840  }
841  if (GetHeSupported ())
842  {
843  HeCapabilities heCapabilities = beacon.GetHeCapabilities ();
844  //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer
845  m_stationManager->AddStationHeCapabilities (apAddr, heCapabilities);
846  HeOperation heOperation = beacon.GetHeOperation ();
847  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
848  {
849  WifiMode mcs = m_phy->GetMcs (i);
850  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
851  {
852  m_stationManager->AddSupportedMcs (apAddr, mcs);
853  }
854  }
855  }
856  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
858 }
859 
860 void
862 {
863  NS_LOG_FUNCTION (this << probeResp << apAddr << bssid);
864  CapabilityInformation capabilities = probeResp.GetCapabilities ();
865  SupportedRates rates = probeResp.GetSupportedRates ();
866  for (uint8_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
867  {
868  uint8_t selector = m_phy->GetBssMembershipSelector (i);
869  if (!rates.IsBssMembershipSelectorRate (selector))
870  {
871  NS_LOG_DEBUG ("Supported rates do not fit with the BSS membership selector");
872  return;
873  }
874  }
875  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
876  {
877  WifiMode mode = m_phy->GetMode (i);
878  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
879  {
880  m_stationManager->AddSupportedMode (apAddr, mode);
881  if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
882  {
884  }
885  }
886  }
887 
888  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
889  if (GetErpSupported ())
890  {
891  bool isErpAllowed = false;
892  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
893  {
894  WifiMode mode = m_phy->GetMode (i);
896  {
897  isErpAllowed = true;
898  break;
899  }
900  }
901  if (!isErpAllowed)
902  {
903  //disable short slot time and set cwMin to 31
904  SetSlot (MicroSeconds (20));
905  ConfigureContentionWindow (31, 1023);
906  }
907  else
908  {
909  ErpInformation erpInformation = probeResp.GetErpInformation ();
910  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
912  {
913  //enable short slot time
914  SetSlot (MicroSeconds (9));
915  }
916  else
917  {
918  //disable short slot time
919  SetSlot (MicroSeconds (20));
920  }
921  ConfigureContentionWindow (15, 1023);
922  }
923  }
924  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
926  SetBssid (bssid);
927 }
928 
929 void
931 {
932  NS_LOG_FUNCTION (this << assocResp << apAddr);
933  CapabilityInformation capabilities = assocResp.GetCapabilities ();
934  SupportedRates rates = assocResp.GetSupportedRates ();
935  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
936  if (GetErpSupported ())
937  {
938  bool isErpAllowed = false;
939  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
940  {
941  WifiMode mode = m_phy->GetMode (i);
943  {
944  isErpAllowed = true;
945  break;
946  }
947  }
948  if (!isErpAllowed)
949  {
950  //disable short slot time and set cwMin to 31
951  SetSlot (MicroSeconds (20));
952  ConfigureContentionWindow (31, 1023);
953  }
954  else
955  {
956  ErpInformation erpInformation = assocResp.GetErpInformation ();
957  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
959  {
960  //enable short slot time
961  SetSlot (MicroSeconds (9));
962  }
963  else
964  {
965  //disable short slot time
966  SetSlot (MicroSeconds (20));
967  }
968  ConfigureContentionWindow (15, 1023);
969  }
970  }
971  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
973  if (GetQosSupported ())
974  {
975  bool qosSupported = false;
976  EdcaParameterSet edcaParameters = assocResp.GetEdcaParameterSet ();
977  if (edcaParameters.IsQosSupported ())
978  {
979  qosSupported = true;
980  //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.
981  SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTxopLimit ()));
982  SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTxopLimit ()));
983  SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ()));
984  SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ()));
985  }
986  m_stationManager->SetQosSupport (apAddr, qosSupported);
987  }
988  if (GetHtSupported ())
989  {
990  HtCapabilities htCapabilities = assocResp.GetHtCapabilities ();
991  if (!htCapabilities.IsSupportedMcs (0))
992  {
994  }
995  else
996  {
997  m_stationManager->AddStationHtCapabilities (apAddr, htCapabilities);
998  HtOperation htOperation = assocResp.GetHtOperation ();
999  if (htOperation.GetNonGfHtStasPresent ())
1000  {
1002  }
1003  else
1004  {
1006  }
1007  if (!GetVhtSupported () && GetHtConfiguration ()->GetRifsSupported () && htOperation.GetRifsMode ())
1008  {
1010  }
1011  else
1012  {
1014  }
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  m_stationManager->AddStationVhtCapabilities (apAddr, vhtCapabilities);
1024  VhtOperation vhtOperation = assocResp.GetVhtOperation ();
1025  }
1026  }
1027  if (GetHeSupported ())
1028  {
1029  HeCapabilities hecapabilities = assocResp.GetHeCapabilities ();
1030  //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer
1031  m_stationManager->AddStationHeCapabilities (apAddr, hecapabilities);
1032  HeOperation heOperation = assocResp.GetHeOperation ();
1033  GetHeConfiguration ()->SetAttribute ("BssColor", UintegerValue (heOperation.GetBssColor ()));
1034  }
1035  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
1036  {
1037  WifiMode mode = m_phy->GetMode (i);
1038  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1039  {
1040  m_stationManager->AddSupportedMode (apAddr, mode);
1041  if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1042  {
1044  }
1045  }
1046  }
1047  if (GetHtSupported ())
1048  {
1049  HtCapabilities htCapabilities = assocResp.GetHtCapabilities ();
1050  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1051  {
1052  WifiMode mcs = m_phy->GetMcs (i);
1053  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1054  {
1055  m_stationManager->AddSupportedMcs (apAddr, mcs);
1056  //here should add a control to add basic MCS when it is implemented
1057  }
1058  }
1059  }
1060  if (GetVhtSupported ())
1061  {
1062  VhtCapabilities vhtcapabilities = assocResp.GetVhtCapabilities ();
1063  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1064  {
1065  WifiMode mcs = m_phy->GetMcs (i);
1066  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtcapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
1067  {
1068  m_stationManager->AddSupportedMcs (apAddr, mcs);
1069  //here should add a control to add basic MCS when it is implemented
1070  }
1071  }
1072  }
1073  if (GetHtSupported () || GetVhtSupported ())
1074  {
1075  ExtendedCapabilities extendedCapabilities = assocResp.GetExtendedCapabilities ();
1076  //TODO: to be completed
1077  }
1078  if (GetHeSupported ())
1079  {
1080  HeCapabilities heCapabilities = assocResp.GetHeCapabilities ();
1081  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1082  {
1083  WifiMode mcs = m_phy->GetMcs (i);
1084  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
1085  {
1086  m_stationManager->AddSupportedMcs (apAddr, mcs);
1087  //here should add a control to add basic MCS when it is implemented
1088  }
1089  }
1090  }
1091 }
1092 
1095 {
1096  SupportedRates rates;
1097  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
1098  {
1099  WifiMode mode = m_phy->GetMode (i);
1100  uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ());
1101  NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
1102  rates.AddSupportedRate (modeDataRate);
1103  }
1104  if (GetHtSupported () || GetVhtSupported () || GetHeSupported ())
1105  {
1106  for (uint8_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
1107  {
1109  }
1110  }
1111  return rates;
1112 }
1113 
1116 {
1117  CapabilityInformation capabilities;
1120  if (GetPcfSupported ())
1121  {
1122  capabilities.SetCfPollable ();
1123  }
1124  return capabilities;
1125 }
1126 
1127 void
1129 {
1130  if (value == ASSOCIATED
1131  && m_state != ASSOCIATED)
1132  {
1133  m_assocLogger (GetBssid ());
1134  }
1135  else if (value != ASSOCIATED
1136  && m_state == ASSOCIATED)
1137  {
1139  }
1140  m_state = value;
1141 }
1142 
1143 void
1144 StaWifiMac::SetEdcaParameters (AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
1145 {
1146  Ptr<QosTxop> edca = m_edca.find (ac)->second;
1147  edca->SetMinCw (cwMin);
1148  edca->SetMaxCw (cwMax);
1149  edca->SetAifsn (aifsn);
1150  edca->SetTxopLimit (txopLimit);
1151 }
1152 
1153 void
1155 {
1156  NS_LOG_FUNCTION (this);
1157  if (IsAssociated ())
1158  {
1159  NS_LOG_DEBUG ("PHY capabilities changed: send reassociation request");
1161  SendAssociationRequest (true);
1162  }
1163 }
1164 
1165 } //namespace ns3
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:202
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:729
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void SetWifiPhy(const Ptr< WifiPhy > phy)
bool IsSuccess(void) const
Return whether the status code is success.
Definition: status-code.cc:42
bool m_activeProbing
Flag whether active probing is used or not.
Definition: sta-wifi-mac.h:49
TracedCallback< Mac48Address > m_deAssocLogger
deassoc logger
Definition: sta-wifi-mac.h:331
double m_snr
SNR.
Definition: sta-wifi-mac.h:48
Ptr< HeConfiguration > GetHeConfiguration(void) const
Definition: wifi-mac.cc:493
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void SendCfFrame(WifiMacType frameType, Mac48Address addr)
Sends CF frame to sta with address addr.
Definition: txop.cc:786
Time m_assocRequestTimeout
assoc request timeout
Definition: sta-wifi-mac.h:316
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
Handle a received packet.
Implement the header for management frames of type association request.
Definition: mgt-headers.h:49
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
bool GetActiveProbing(void) const
Return whether active probing is enabled.
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:554
bool IsBssMembershipSelectorRate(uint64_t bs) const
Check if the given rate is a BSS membership selector value.
void DoInitialize(void)
Initialize() implementation.
ERP-OFDM PHY (19.5)
Definition: wifi-mode.h:54
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...
WifiMode GetMcs(uint8_t mcs) const
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
Definition: wifi-phy.cc:4090
#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.
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:950
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
Definition: sta-wifi-mac.h:324
void AssocRequestTimeout(void)
This method is called after the association timeout occurred.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: boolean.h:84
Time m_probeRequestTimeout
probe request timeout
Definition: sta-wifi-mac.h:315
EdcaQueues m_edca
This is a map from Access Category index to the corresponding channel access function.
uint8_t GetNBssMembershipSelectors(void) const
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
Definition: wifi-phy.cc:1414
void StartScanning(void)
Start the scanning process which trigger active or passive scanning based on the active probing flag...
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:37
#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)
bool GetRifsSupported(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
void SetListenInterval(uint16_t interval)
Set the listen interval.
Definition: mgt-headers.cc:735
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
The HT Capabilities Information ElementThis class knows how to serialise and deserialise the HT Capab...
void SetHtCapabilities(HtCapabilities htcapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:578
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:536
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:723
bool GetPcfSupported() const
Return whether the device supports PCF.
uint32_t GetBeCWmin(void) const
Return the AC_BE CWmin field in the EdcaParameterSet information element.
VhtOperation GetVhtOperation(void) const
Return the VHT operation.
void SetSlot(Time slotTime)
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:264
The HT Operation Information ElementThis class knows how to serialise and deserialise the HT Operatio...
Definition: ht-operation.h:52
Mac48Address m_bssid
BSSID.
Definition: sta-wifi-mac.h:46
virtual void DeaggregateAmsduAndForward(Ptr< Packet > aggregatedPacket, const WifiMacHeader *hdr)
This method can be called to de-aggregate an A-MSDU and forward the constituent packets up the stack...
void SetPcfSupported(bool enable)
Enable or disable PCF capability support.
HtOperation GetHtOperation(void) const
Return the HT operation.
Definition: mgt-headers.cc:268
TracedCallback< Mac48Address > m_assocLogger
assoc logger
Definition: sta-wifi-mac.h:330
bool IsBasicRate(uint64_t bs) const
Check if the given rate is a basic rate.
EventId m_assocRequestEvent
assoc request event
Definition: sta-wifi-mac.h:319
VHT PHY (Clause 22)
Definition: wifi-mode.h:60
Ptr< WifiPhy > m_phy
Wifi PHY.
uint8_t GetCFPCount(void) const
Return the CFP Count in DTIM frames unit.
Time m_waitBeaconTimeout
wait beacon timeout
Definition: sta-wifi-mac.h:314
bool IsCfPoll(void) const
Return true if the Type/Subtype is one of the possible CF-Poll headers.
void SetHeCapabilities(HeCapabilities hecapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:602
Video.
Definition: qos-utils.h:45
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.
Voice.
Definition: qos-utils.h:47
Best Effort.
Definition: qos-utils.h:41
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
bool GetShortSlotTimeSupported(void) const
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
virtual void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
Set up WifiRemoteStationManager associated with this StaWifiMac.
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:542
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a qos tag is attached to the packet, returns a value < 8.
Definition: qos-utils.cc:58
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
phy
Definition: third.py:86
The Wifi MAC high model for a STA or AP in a BSS.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
uint8_t GetNonGfHtStasPresent(void) const
Return the non GF HT STAs present.
bool GetShortPlcpPreambleSupported(void) const
Return whether short PLCP preamble is supported.
Definition: wifi-phy.cc:713
MacState
The current MAC state of the STA.
Definition: sta-wifi-mac.h:158
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1357
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
void SetBssid(Mac48Address bssid)
uint8_t GetNMcs(void) const
The WifiPhy::GetNMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of t...
Definition: wifi-phy.cc:4084
void SetListenInterval(uint16_t interval)
Set the listen interval.
Definition: mgt-headers.cc:548
uint64_t GetCFPMaxDurationUs(void) const
Return the CFP MaxDuration in microseconds.
void SendProbeRequest(void)
Forward a probe request packet to the DCF.
Background.
Definition: qos-utils.h:43
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current STA.
void ForwardUp(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set.
Definition: mgt-headers.cc:382
void UpdateApInfoFromBeacon(MgtBeaconHeader beacon, Mac48Address apAddr, Mac48Address bssid)
Update associated AP&#39;s information from beacon.
Ptr< HtConfiguration > GetHtConfiguration(void) const
Definition: wifi-mac.cc:479
void SetVhtCapabilities(VhtCapabilities vhtcapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:777
bool GetErpSupported() const
Return whether the device supports ERP.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1389
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
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.
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
#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:370
AttributeValue implementation for Time.
Definition: nstime.h:1124
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
bool GetVhtSupported() const
Return whether the device supports VHT.
bool IsBeacon(void) const
Return true if the header is a Beacon header.
void SetHtCapabilities(HtCapabilities htcapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:765
The IEEE 802.11ac VHT Capabilities.
CfParameterSet GetCfParameterSet(void) const
Return the CF parameter set.
Definition: mgt-headers.cc:328
MacState m_state
MAC state.
Definition: sta-wifi-mac.h:313
void SetExtendedCapabilities(ExtendedCapabilities extendedcapabilities)
Set the Extended Capabilities.
Definition: mgt-headers.cc:566
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:246
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:220
uint8_t GetBkAifsn(void) const
Return the AC_BK AIFSN field in the EdcaParameterSet information element.
bool IsFromDs(void) const
The CF Parameter SetThis class knows how to serialise and deserialise the CF Parameter Set...
HtOperation GetHtOperation(void) const
Return the HT operation.
Definition: mgt-headers.cc:986
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
Records HT capabilities of the remote station.
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:32
HT PHY (Clause 20)
Definition: wifi-mode.h:58
static Mac48Address GetBroadcast(void)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:244
Mac48Address GetBssid(void) const
void ScanningTimeout(void)
This method is called after wait beacon timeout or wait probe request timeout has occurred...
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities hecapabilities)
Records HE capabilities of the remote station.
void SetCapabilitiesChangedCallback(Callback< void > callback)
Definition: wifi-phy.cc:473
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:494
Ptr< MacLow > m_low
MacLow (RTS, CTS, DATA, ACK etc.)
uint64_t GetBeaconIntervalUs(void) const
Return the beacon interval in microseconds unit.
Definition: mgt-headers.cc:214
SupportedRates GetSupportedRates(void)
Return the supported rates.
Definition: mgt-headers.cc:926
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 SetCfPollable(void)
Set the CF-Pollable bit in the capability information field.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
void SendCfPollResponse(void)
Forward a CF-Poll response packet to the CFP queue.
uint32_t m_maxMissedBeacons
maximum missed beacons
Definition: sta-wifi-mac.h:322
bool GetShortSlotTimeEnabled(void) const
Return whether the device uses short slot time.
EventId m_beaconWatchdog
beacon watchdog
Definition: sta-wifi-mac.h:320
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
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:256
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...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
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:42
void AddBssMembershipSelectorRate(uint64_t bs)
Add a special value to the supported rate set, corresponding to a BSS membership selector.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
uint8_t GetBeAifsn(void) const
Return the AC_BE AIFSN field in the EdcaParameterSet information element.
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 SetVhtCapabilities(VhtCapabilities vhtcapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:590
Ssid GetSsid(void) const
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...
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:1125
bool IsGroup(void) const
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:193
Ssid GetSsid(void) const
Return the Service Set Identifier (SSID).
Definition: mgt-headers.cc:208
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 SetHeCapabilities(HeCapabilities hecapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:789
EventId m_waitBeaconEvent
wait beacon event
Definition: sta-wifi-mac.h:317
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
uint8_t GetRifsMode(void) const
Return the RIFS mode.
uint32_t GetVoCWmax(void) const
Return the AC_VO CWmax field in the EdcaParameterSet information element.
uint64_t GetCFPDurRemainingUs(void) const
Return the CFP DurRemaining in microseconds.
Implement the header for management frames of type probe request.
Definition: mgt-headers.h:508
void SetActiveProbing(bool enable)
Enable or disable active probing.
Mac48Address GetAddress(void) const
uint8_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:4072
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:318
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:962
void UpdateApInfoFromAssocResp(MgtAssocResponseHeader assocResp, Mac48Address apAddr)
Update AP&#39;s information from association response.
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.
WifiMode GetMode(uint8_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:4078
uint8_t GetBssMembershipSelector(uint8_t selector) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1420
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.
virtual void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:308
bool IsSupportedRxMcs(uint8_t mcs) const
Get the is receive MCS supported.
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:185
void SetCurrentApAddress(Mac48Address currentApAddr)
Set the address of the current access point.
Definition: mgt-headers.cc:819
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:198
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:276
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:870
HeOperation GetHeOperation(void) const
Return the HE operation.
Definition: mgt-headers.cc:316
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:272
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:974
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
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:65
void Enqueue(Ptr< const Packet > packet, Mac48Address to)
void SetUseGreenfieldProtection(bool enable)
Enable or disable protection for stations that do not support HT greenfield format.
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:292
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:998
uint8_t GetBssColor(void) const
Get the BSS color.
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:1078
The ErpInformation Information ElementThis class knows how to serialise and deserialise the ErpInform...
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:40
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:269
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:232
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:321
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:741
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:323
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:318
void SetShortPreambleEnabled(bool enable)
Enable or disable short PLCP preambles.
The HE Operation Information ElementThis class knows how to serialise and deserialise the HE Operatio...
Definition: he-operation.h:37
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:612
Ptr< WifiRemoteStationManager > m_stationManager
Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.)
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
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.
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:472
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
void SetExtendedCapabilities(ExtendedCapabilities extendedcapabilities)
Set the Extended Capabilities.
Definition: mgt-headers.cc:753
a unique identifier for an interface.
Definition: type-id.h:58
virtual void SetWifiPhy(const Ptr< WifiPhy > phy)
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:915
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.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:38
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:841
Introspection did not find any typical Config paths.
Definition: snr-tag.h:34
HE PHY (Clause 26)
Definition: wifi-mode.h:62
void SetRifsPermitted(bool allow)
Permit or prohibit RIFS.
bool IsShortSlotTime(void) const
Check if the short slot time in the capability information field is set to 1.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:150
void 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.
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtcapabilities)
Records VHT capabilities of the remote station.
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:920
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:280
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
bool HasData(void) const
Return true if the header type is DATA and is not DATA_NULL.
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
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:304
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:332
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.