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");
390 }
391 
392 void
394 {
395  NS_LOG_FUNCTION (this << delay);
399  {
400  NS_LOG_DEBUG ("really restart watchdog.");
402  }
403 }
404 
405 bool
407 {
408  return m_state == ASSOCIATED;
409 }
410 
411 bool
413 {
414  return m_state == WAIT_ASSOC_RESP;
415 }
416 
417 void
419 {
420  NS_LOG_FUNCTION (this << packet << to);
421  if (!IsAssociated ())
422  {
423  NotifyTxDrop (packet);
425  return;
426  }
427  WifiMacHeader hdr;
428 
429  //If we are not a QoS AP then we definitely want to use AC_BE to
430  //transmit the packet. A TID of zero will map to AC_BE (through \c
431  //QosUtilsMapTidToAc()), so we use that as our default here.
432  uint8_t tid = 0;
433 
434  //For now, an AP that supports QoS does not support non-QoS
435  //associations, and vice versa. In future the AP model should
436  //support simultaneously associated QoS and non-QoS STAs, at which
437  //point there will need to be per-association QoS state maintained
438  //by the association state machine, and consulted here.
439  if (GetQosSupported ())
440  {
443  hdr.SetQosNoEosp ();
444  hdr.SetQosNoAmsdu ();
445  //Transmission of multiple frames in the same TXOP is not
446  //supported for now
447  hdr.SetQosTxopLimit (0);
448 
449  //Fill in the QoS control field in the MAC header
450  tid = QosUtilsGetTidForPacket (packet);
451  //Any value greater than 7 is invalid and likely indicates that
452  //the packet had no QoS tag, so we revert to zero, which'll
453  //mean that AC_BE is used.
454  if (tid > 7)
455  {
456  tid = 0;
457  }
458  hdr.SetQosTid (tid);
459  }
460  else
461  {
462  hdr.SetType (WIFI_MAC_DATA);
463  }
464  if (GetQosSupported ())
465  {
466  hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT control field is not yet implemented (set it to 1 when implemented)
467  }
468 
469  hdr.SetAddr1 (GetBssid ());
470  hdr.SetAddr2 (GetAddress ());
471  hdr.SetAddr3 (to);
472  hdr.SetDsNotFrom ();
473  hdr.SetDsTo ();
474 
475  if (GetQosSupported ())
476  {
477  //Sanity check that the TID is valid
478  NS_ASSERT (tid < 8);
479  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
480  }
481  else
482  {
483  m_txop->Queue (packet, hdr);
484  }
485 }
486 
487 void
489 {
490  NS_LOG_FUNCTION (this << *mpdu);
491  const WifiMacHeader* hdr = &mpdu->GetHeader ();
492  Ptr<const Packet> packet = mpdu->GetPacket ();
493  NS_ASSERT (!hdr->IsCtl ());
494  if (hdr->GetAddr3 () == GetAddress ())
495  {
496  NS_LOG_LOGIC ("packet sent by us.");
497  return;
498  }
499  else if (hdr->GetAddr1 () != GetAddress ()
500  && !hdr->GetAddr1 ().IsGroup ())
501  {
502  NS_LOG_LOGIC ("packet is not for us");
503  NotifyRxDrop (packet);
504  return;
505  }
506  if (hdr->IsData ())
507  {
508  if (!IsAssociated ())
509  {
510  NS_LOG_LOGIC ("Received data frame while not associated: ignore");
511  NotifyRxDrop (packet);
512  return;
513  }
514  if (!(hdr->IsFromDs () && !hdr->IsToDs ()))
515  {
516  NS_LOG_LOGIC ("Received data frame not from the DS: ignore");
517  NotifyRxDrop (packet);
518  return;
519  }
520  if (hdr->GetAddr2 () != GetBssid ())
521  {
522  NS_LOG_LOGIC ("Received data frame not from the BSS we are associated with: ignore");
523  NotifyRxDrop (packet);
524  return;
525  }
526  if (hdr->IsQosData ())
527  {
528  if (hdr->IsQosAmsdu ())
529  {
530  NS_ASSERT (hdr->GetAddr3 () == GetBssid ());
532  packet = 0;
533  }
534  else
535  {
536  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
537  }
538  }
539  else if (hdr->HasData ())
540  {
541  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
542  }
543  return;
544  }
545  else if (hdr->IsProbeReq ()
546  || hdr->IsAssocReq ()
547  || hdr->IsReassocReq ())
548  {
549  //This is a frame aimed at an AP, so we can safely ignore it.
550  NotifyRxDrop (packet);
551  return;
552  }
553  else if (hdr->IsBeacon ())
554  {
555  NS_LOG_DEBUG ("Beacon received");
556  MgtBeaconHeader beacon;
557  Ptr<Packet> copy = packet->Copy ();
558  copy->RemoveHeader (beacon);
559  CapabilityInformation capabilities = beacon.GetCapabilities ();
560  NS_ASSERT (capabilities.IsEss ());
561  bool goodBeacon = false;
562  if (GetSsid ().IsBroadcast ()
563  || beacon.GetSsid ().IsEqual (GetSsid ()))
564  {
565  NS_LOG_LOGIC ("Beacon is for our SSID");
566  goodBeacon = true;
567  }
568  SupportedRates rates = beacon.GetSupportedRates ();
569  bool bssMembershipSelectorMatch = false;
570  auto selectorList = m_phy->GetBssMembershipSelectorList ();
571  for (const auto & selector : selectorList)
572  {
573  if (rates.IsBssMembershipSelectorRate (selector))
574  {
575  NS_LOG_LOGIC ("Beacon is matched to our BSS membership selector");
576  bssMembershipSelectorMatch = true;
577  }
578  }
579  if (selectorList.size () > 0 && bssMembershipSelectorMatch == false)
580  {
581  NS_LOG_LOGIC ("No match for BSS membership selector");
582  goodBeacon = false;
583  }
584  if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ())
585  {
586  NS_LOG_LOGIC ("Beacon is not for us");
587  goodBeacon = false;
588  }
589  if (goodBeacon && m_state == ASSOCIATED)
590  {
593  RestartBeaconWatchdog (delay);
594  UpdateApInfoFromBeacon (beacon, hdr->GetAddr2 (), hdr->GetAddr3 ());
595  }
596  if (goodBeacon && m_state == WAIT_BEACON)
597  {
598  NS_LOG_DEBUG ("Beacon received while scanning from " << hdr->GetAddr2 ());
599  SnrTag snrTag;
600  bool removed = copy->RemovePacketTag (snrTag);
601  NS_ASSERT (removed);
602  ApInfo apInfo;
603  apInfo.m_apAddr = hdr->GetAddr2 ();
604  apInfo.m_bssid = hdr->GetAddr3 ();
605  apInfo.m_activeProbing = false;
606  apInfo.m_snr = snrTag.Get ();
607  apInfo.m_beacon = beacon;
608  UpdateCandidateApList (apInfo);
609  }
610  return;
611  }
612  else if (hdr->IsProbeResp ())
613  {
614  if (m_state == WAIT_PROBE_RESP)
615  {
616  NS_LOG_DEBUG ("Probe response received while scanning from " << hdr->GetAddr2 ());
617  MgtProbeResponseHeader probeResp;
618  Ptr<Packet> copy = packet->Copy ();
619  copy->RemoveHeader (probeResp);
620  if (!probeResp.GetSsid ().IsEqual (GetSsid ()))
621  {
622  NS_LOG_DEBUG ("Probe response is not for our SSID");
623  return;
624  }
625  SnrTag snrTag;
626  bool removed = copy->RemovePacketTag (snrTag);
627  NS_ASSERT (removed);
628  ApInfo apInfo;
629  apInfo.m_apAddr = hdr->GetAddr2 ();
630  apInfo.m_bssid = hdr->GetAddr3 ();
631  apInfo.m_activeProbing = true;
632  apInfo.m_snr = snrTag.Get ();
633  apInfo.m_probeResp = probeResp;
634  UpdateCandidateApList (apInfo);
635  }
636  return;
637  }
638  else if (hdr->IsAssocResp () || hdr->IsReassocResp ())
639  {
640  if (m_state == WAIT_ASSOC_RESP)
641  {
642  MgtAssocResponseHeader assocResp;
643  packet->PeekHeader (assocResp);
645  {
647  }
648  if (assocResp.GetStatusCode ().IsSuccess ())
649  {
651  m_aid = assocResp.GetAssociationId ();
652  if (hdr->IsReassocResp ())
653  {
654  NS_LOG_DEBUG ("reassociation done");
655  }
656  else
657  {
658  NS_LOG_DEBUG ("association completed");
659  }
660  UpdateApInfoFromAssocResp (assocResp, hdr->GetAddr2 ());
661  if (!m_linkUp.IsNull ())
662  {
663  m_linkUp ();
664  }
665  }
666  else
667  {
668  NS_LOG_DEBUG ("association refused");
669  if (m_candidateAps.empty ())
670  {
671  SetState (REFUSED);
672  }
673  else
674  {
675  ScanningTimeout ();
676  }
677  }
678  }
679  return;
680  }
681 
682  //Invoke the receive handler of our parent class to deal with any
683  //other frames. Specifically, this will handle Block Ack-related
684  //Management Action frames.
685  RegularWifiMac::Receive (Create<WifiMacQueueItem> (packet, *hdr));
686 }
687 
688 void
690 {
691  NS_LOG_FUNCTION (this << newApInfo.m_bssid << newApInfo.m_apAddr << newApInfo.m_snr << newApInfo.m_activeProbing << newApInfo.m_beacon << newApInfo.m_probeResp);
692  // Remove duplicate ApInfo entry
693  for (std::vector<ApInfo>::iterator i = m_candidateAps.begin(); i != m_candidateAps.end(); ++i)
694  {
695  if (newApInfo.m_bssid == (*i).m_bssid)
696  {
697  m_candidateAps.erase(i);
698  break;
699  }
700  }
701  // Insert before the entry with lower SNR
702  for (std::vector<ApInfo>::iterator i = m_candidateAps.begin(); i != m_candidateAps.end(); ++i)
703  {
704  if (newApInfo.m_snr > (*i).m_snr)
705  {
706  m_candidateAps.insert (i, newApInfo);
707  return;
708  }
709  }
710  // If new ApInfo is the lowest, insert at back
711  m_candidateAps.push_back(newApInfo);
712 }
713 
714 void
716 {
717  NS_LOG_FUNCTION (this << beacon << apAddr << bssid);
718  SetBssid (bssid);
719  CapabilityInformation capabilities = beacon.GetCapabilities ();
720  SupportedRates rates = beacon.GetSupportedRates ();
721  for (const auto & mode : m_phy->GetModeList ())
722  {
723  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
724  {
725  m_stationManager->AddSupportedMode (apAddr, mode);
726  }
727  }
728  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
729  if (GetErpSupported ())
730  {
731  ErpInformation erpInformation = beacon.GetErpInformation ();
732  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
733  if (erpInformation.GetUseProtection () != 0)
734  {
736  }
737  else
738  {
740  }
741  if (capabilities.IsShortSlotTime () == true)
742  {
743  //enable short slot time
744  m_phy->SetSlot (MicroSeconds (9));
745  }
746  else
747  {
748  //disable short slot time
749  m_phy->SetSlot (MicroSeconds (20));
750  }
751  }
752  if (GetQosSupported ())
753  {
754  bool qosSupported = false;
755  EdcaParameterSet edcaParameters = beacon.GetEdcaParameterSet ();
756  if (edcaParameters.IsQosSupported ())
757  {
758  qosSupported = true;
759  //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.
760  SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTxopLimit ()));
761  SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTxopLimit ()));
762  SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ()));
763  SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ()));
764  }
765  m_stationManager->SetQosSupport (apAddr, qosSupported);
766  }
767  if (GetHtSupported ())
768  {
769  HtCapabilities htCapabilities = beacon.GetHtCapabilities ();
770  if (!htCapabilities.IsSupportedMcs (0))
771  {
773  }
774  else
775  {
776  m_stationManager->AddStationHtCapabilities (apAddr, htCapabilities);
777  }
778  }
779  if (GetVhtSupported ())
780  {
781  VhtCapabilities vhtCapabilities = beacon.GetVhtCapabilities ();
782  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
783  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
784  {
785  m_stationManager->AddStationVhtCapabilities (apAddr, vhtCapabilities);
786  VhtOperation vhtOperation = beacon.GetVhtOperation ();
787  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_VHT))
788  {
789  if (vhtCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
790  {
791  m_stationManager->AddSupportedMcs (apAddr, mcs);
792  }
793  }
794  }
795  }
796  if (GetHtSupported ())
797  {
798  ExtendedCapabilities extendedCapabilities = beacon.GetExtendedCapabilities ();
799  //TODO: to be completed
800  }
801  if (GetHeSupported ())
802  {
803  HeCapabilities heCapabilities = beacon.GetHeCapabilities ();
804  if (heCapabilities.GetSupportedMcsAndNss () != 0)
805  {
806  m_stationManager->AddStationHeCapabilities (apAddr, heCapabilities);
807  HeOperation heOperation = beacon.GetHeOperation ();
808  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HE))
809  {
810  if (heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
811  {
812  m_stationManager->AddSupportedMcs (apAddr, mcs);
813  }
814  }
815  }
816  }
817  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
819 }
820 
821 void
823 {
824  NS_LOG_FUNCTION (this << probeResp << apAddr << bssid);
825  CapabilityInformation capabilities = probeResp.GetCapabilities ();
826  SupportedRates rates = probeResp.GetSupportedRates ();
827  for (const auto & selector : m_phy->GetBssMembershipSelectorList ())
828  {
829  if (!rates.IsBssMembershipSelectorRate (selector))
830  {
831  NS_LOG_DEBUG ("Supported rates do not fit with the BSS membership selector");
832  return;
833  }
834  }
835  for (const auto & mode : m_phy->GetModeList ())
836  {
837  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
838  {
839  m_stationManager->AddSupportedMode (apAddr, mode);
840  if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
841  {
843  }
844  }
845  }
846 
847  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
848  if (GetErpSupported ())
849  {
850  bool isErpAllowed = false;
851  for (const auto & mode : m_phy->GetModeList (WIFI_MOD_CLASS_ERP_OFDM))
852  {
853  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
854  {
855  isErpAllowed = true;
856  break;
857  }
858  }
859  if (!isErpAllowed)
860  {
861  //disable short slot time and set cwMin to 31
862  m_phy->SetSlot (MicroSeconds (20));
863  ConfigureContentionWindow (31, 1023);
864  }
865  else
866  {
867  ErpInformation erpInformation = probeResp.GetErpInformation ();
868  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
870  {
871  //enable short slot time
872  m_phy->SetSlot (MicroSeconds (9));
873  }
874  else
875  {
876  //disable short slot time
877  m_phy->SetSlot (MicroSeconds (20));
878  }
879  ConfigureContentionWindow (15, 1023);
880  }
881  }
882  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
884  SetBssid (bssid);
885 }
886 
887 void
889 {
890  NS_LOG_FUNCTION (this << assocResp << apAddr);
891  CapabilityInformation capabilities = assocResp.GetCapabilities ();
892  SupportedRates rates = assocResp.GetSupportedRates ();
893  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
894  if (GetErpSupported ())
895  {
896  bool isErpAllowed = false;
897  for (const auto & mode : m_phy->GetModeList (WIFI_MOD_CLASS_ERP_OFDM))
898  {
899  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
900  {
901  isErpAllowed = true;
902  break;
903  }
904  }
905  if (!isErpAllowed)
906  {
907  //disable short slot time and set cwMin to 31
908  m_phy->SetSlot (MicroSeconds (20));
909  ConfigureContentionWindow (31, 1023);
910  }
911  else
912  {
913  ErpInformation erpInformation = assocResp.GetErpInformation ();
914  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
916  {
917  //enable short slot time
918  m_phy->SetSlot (MicroSeconds (9));
919  }
920  else
921  {
922  //disable short slot time
923  m_phy->SetSlot (MicroSeconds (20));
924  }
925  ConfigureContentionWindow (15, 1023);
926  }
927  }
928  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
930  if (GetQosSupported ())
931  {
932  bool qosSupported = false;
933  EdcaParameterSet edcaParameters = assocResp.GetEdcaParameterSet ();
934  if (edcaParameters.IsQosSupported ())
935  {
936  qosSupported = true;
937  //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.
938  SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTxopLimit ()));
939  SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTxopLimit ()));
940  SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ()));
941  SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ()));
942  }
943  m_stationManager->SetQosSupport (apAddr, qosSupported);
944  }
945  if (GetHtSupported ())
946  {
947  HtCapabilities htCapabilities = assocResp.GetHtCapabilities ();
948  if (!htCapabilities.IsSupportedMcs (0))
949  {
951  }
952  else
953  {
954  m_stationManager->AddStationHtCapabilities (apAddr, htCapabilities);
955  }
956  }
957  if (GetVhtSupported ())
958  {
959  VhtCapabilities vhtCapabilities = assocResp.GetVhtCapabilities ();
960  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
961  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
962  {
963  m_stationManager->AddStationVhtCapabilities (apAddr, vhtCapabilities);
964  VhtOperation vhtOperation = assocResp.GetVhtOperation ();
965  }
966  }
967  if (GetHeSupported ())
968  {
969  HeCapabilities hecapabilities = assocResp.GetHeCapabilities ();
970  if (hecapabilities.GetSupportedMcsAndNss () != 0)
971  {
972  m_stationManager->AddStationHeCapabilities (apAddr, hecapabilities);
973  HeOperation heOperation = assocResp.GetHeOperation ();
974  GetHeConfiguration ()->SetAttribute ("BssColor", UintegerValue (heOperation.GetBssColor ()));
975  }
976  }
977  for (const auto & mode : m_phy->GetModeList ())
978  {
979  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
980  {
981  m_stationManager->AddSupportedMode (apAddr, mode);
982  if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
983  {
985  }
986  }
987  }
988  if (GetHtSupported ())
989  {
990  HtCapabilities htCapabilities = assocResp.GetHtCapabilities ();
991  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HT))
992  {
993  if (htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
994  {
995  m_stationManager->AddSupportedMcs (apAddr, mcs);
996  //here should add a control to add basic MCS when it is implemented
997  }
998  }
999  }
1000  if (GetVhtSupported ())
1001  {
1002  VhtCapabilities vhtcapabilities = assocResp.GetVhtCapabilities ();
1003  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_VHT))
1004  {
1005  if (vhtcapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
1006  {
1007  m_stationManager->AddSupportedMcs (apAddr, mcs);
1008  //here should add a control to add basic MCS when it is implemented
1009  }
1010  }
1011  }
1012  if (GetHtSupported ())
1013  {
1014  ExtendedCapabilities extendedCapabilities = assocResp.GetExtendedCapabilities ();
1015  //TODO: to be completed
1016  }
1017  if (GetHeSupported ())
1018  {
1019  HeCapabilities heCapabilities = assocResp.GetHeCapabilities ();
1020  for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HE))
1021  {
1022  if (heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
1023  {
1024  m_stationManager->AddSupportedMcs (apAddr, mcs);
1025  //here should add a control to add basic MCS when it is implemented
1026  }
1027  }
1028  }
1029 }
1030 
1033 {
1034  SupportedRates rates;
1035  for (const auto & mode : m_phy->GetModeList ())
1036  {
1037  uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ());
1038  NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
1039  rates.AddSupportedRate (modeDataRate);
1040  }
1041  if (GetHtSupported ())
1042  {
1043  for (const auto & selector : m_phy->GetBssMembershipSelectorList ())
1044  {
1045  rates.AddBssMembershipSelectorRate (selector);
1046  }
1047  }
1048  return rates;
1049 }
1050 
1053 {
1054  CapabilityInformation capabilities;
1057  return capabilities;
1058 }
1059 
1060 void
1062 {
1063  if (value == ASSOCIATED
1064  && m_state != ASSOCIATED)
1065  {
1066  m_assocLogger (GetBssid ());
1067  }
1068  else if (value != ASSOCIATED
1069  && m_state == ASSOCIATED)
1070  {
1072  }
1073  m_state = value;
1074 }
1075 
1076 void
1077 StaWifiMac::SetEdcaParameters (AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
1078 {
1079  Ptr<QosTxop> edca = m_edca.find (ac)->second;
1080  edca->SetMinCw (cwMin);
1081  edca->SetMaxCw (cwMax);
1082  edca->SetAifsn (aifsn);
1083  edca->SetTxopLimit (txopLimit);
1084 }
1085 
1086 void
1088 {
1089  NS_LOG_FUNCTION (this);
1090  if (IsAssociated ())
1091  {
1092  NS_LOG_DEBUG ("PHY capabilities changed: send reassociation request");
1094  SendAssociationRequest (true);
1095  }
1096 }
1097 
1098 } //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
void SetWifiPhy(const Ptr< WifiPhy > phy)
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.
void DoInitialize(void)
Initialize() implementation.
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:57
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:2000
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:2049
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...
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:65
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
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:79
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.
void Enqueue(Ptr< Packet > packet, Mac48Address to)
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:64
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: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:53
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
Best Effort.
Definition: qos-utils.h:60
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
Mac48Address GetBssid(void) const
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:62
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
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 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
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: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
EventId m_waitBeaconEvent
wait beacon event
Definition: sta-wifi-mac.h:312
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:513
void SetExtendedCapabilities(ExtendedCapabilities extendedCapabilities)
Set the Extended Capabilities.
Definition: mgt-headers.cc:545
void SetActiveProbing(bool enable)
Enable or disable active probing.
Mac48Address GetAddress(void) const
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:317
#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:66
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
void Receive(Ptr< WifiMacQueueItem > mpdu)
Handle a received packet.
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
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.
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:617
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
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: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.
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:833
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:179
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.