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_aid (0),
92  m_waitBeaconEvent (),
93  m_probeRequestEvent (),
94  m_assocRequestEvent (),
95  m_beaconWatchdogEnd (Seconds (0))
96 {
97  NS_LOG_FUNCTION (this);
98 
99  //Let the lower layers know that we are acting as a non-AP STA in
100  //an infrastructure BSS.
102 }
103 
104 void
106 {
107  NS_LOG_FUNCTION (this);
108  StartScanning ();
109 }
110 
112 {
113  NS_LOG_FUNCTION (this);
114 }
115 
116 uint16_t
118 {
119  NS_ASSERT_MSG (IsAssociated (), "This station is not associated to any AP");
120  return m_aid;
121 }
122 
123 void
125 {
126  NS_LOG_FUNCTION (this << enable);
127  m_activeProbing = enable;
129  {
130  NS_LOG_DEBUG ("STA is still scanning, reset scanning process");
131  StartScanning ();
132  }
133 }
134 
135 bool
137 {
138  return m_activeProbing;
139 }
140 
141 void
143 {
144  NS_LOG_FUNCTION (this << phy);
147 }
148 
149 void
151 {
152  NS_LOG_FUNCTION (this << stationManager);
155 }
156 
157 void
159 {
160  NS_LOG_FUNCTION (this);
161  WifiMacHeader hdr;
164  hdr.SetAddr2 (GetAddress ());
166  hdr.SetDsNotFrom ();
167  hdr.SetDsNotTo ();
168  Ptr<Packet> packet = Create<Packet> ();
169  MgtProbeRequestHeader probe;
170  probe.SetSsid (GetSsid ());
171  probe.SetSupportedRates (GetSupportedRates ());
172  if (GetHtSupported ())
173  {
174  probe.SetExtendedCapabilities (GetExtendedCapabilities ());
175  probe.SetHtCapabilities (GetHtCapabilities ());
176  }
177  if (GetVhtSupported ())
178  {
179  probe.SetVhtCapabilities (GetVhtCapabilities ());
180  }
181  if (GetHeSupported ())
182  {
183  probe.SetHeCapabilities (GetHeCapabilities ());
184  }
185  packet->AddHeader (probe);
186 
187  //The standard is not clear on the correct queue for management
188  //frames if we are a QoS AP. The approach taken here is to always
189  //use the non-QoS for these regardless of whether we have a QoS
190  //association or not.
191  m_txop->Queue (packet, hdr);
192 }
193 
194 void
196 {
197  NS_LOG_FUNCTION (this << GetBssid () << isReassoc);
198  WifiMacHeader hdr;
200  hdr.SetAddr1 (GetBssid ());
201  hdr.SetAddr2 (GetAddress ());
202  hdr.SetAddr3 (GetBssid ());
203  hdr.SetDsNotFrom ();
204  hdr.SetDsNotTo ();
205  Ptr<Packet> packet = Create<Packet> ();
206  if (!isReassoc)
207  {
208  MgtAssocRequestHeader assoc;
209  assoc.SetSsid (GetSsid ());
211  assoc.SetCapabilities (GetCapabilities ());
212  assoc.SetListenInterval (0);
213  if (GetHtSupported ())
214  {
217  }
218  if (GetVhtSupported ())
219  {
221  }
222  if (GetHeSupported ())
223  {
225  }
226  packet->AddHeader (assoc);
227  }
228  else
229  {
230  MgtReassocRequestHeader reassoc;
231  reassoc.SetCurrentApAddress (GetBssid ());
232  reassoc.SetSsid (GetSsid ());
234  reassoc.SetCapabilities (GetCapabilities ());
235  reassoc.SetListenInterval (0);
236  if (GetHtSupported ())
237  {
240  }
241  if (GetVhtSupported ())
242  {
244  }
245  if (GetHeSupported ())
246  {
248  }
249  packet->AddHeader (reassoc);
250  }
251 
252  //The standard is not clear on the correct queue for management
253  //frames if we are a QoS AP. The approach taken here is to always
254  //use the non-QoS for these regardless of whether we have a QoS
255  //association or not.
256  m_txop->Queue (packet, hdr);
257 
259  {
261  }
264 }
265 
266 void
268 {
269  NS_LOG_FUNCTION (this);
272 }
273 
274 void
276 {
277  NS_LOG_FUNCTION (this);
278  switch (m_state)
279  {
280  case ASSOCIATED:
281  return;
282  break;
283  case WAIT_PROBE_RESP:
284  /* we have sent a probe request earlier so we
285  do not need to re-send a probe request immediately.
286  We just need to wait until probe-request-timeout
287  or until we get a probe response
288  */
289  break;
290  case WAIT_BEACON:
291  /* we have initiated passive scanning, continue to wait
292  and gather beacons
293  */
294  break;
295  case UNASSOCIATED:
296  /* we were associated but we missed a bunch of beacons
297  * so we should assume we are not associated anymore.
298  * We try to initiate a scan now.
299  */
300  m_linkDown ();
301  StartScanning ();
302  break;
303  case WAIT_ASSOC_RESP:
304  /* we have sent an association request so we do not need to
305  re-send an association request right now. We just need to
306  wait until either assoc-request-timeout or until
307  we get an association response.
308  */
309  break;
310  case REFUSED:
311  /* we have sent an association request and received a negative
312  association response. We wait until someone restarts an
313  association with a given SSID.
314  */
315  break;
316  }
317 }
318 
319 void
321 {
322  NS_LOG_FUNCTION (this);
323  m_candidateAps.clear ();
325  {
327  }
329  {
331  }
332  if (GetActiveProbing ())
333  {
335  SendProbeRequest ();
338  this);
339  }
340  else
341  {
345  this);
346  }
347 }
348 
349 void
351 {
352  NS_LOG_FUNCTION (this);
353  if (!m_candidateAps.empty ())
354  {
355  ApInfo bestAp = m_candidateAps.front();
356  m_candidateAps.erase(m_candidateAps.begin ());
357  NS_LOG_DEBUG ("Attempting to associate with BSSID " << bestAp.m_bssid);
358  Time beaconInterval;
359  if (bestAp.m_activeProbing)
360  {
361  UpdateApInfoFromProbeResp (bestAp.m_probeResp, bestAp.m_apAddr, bestAp.m_bssid);
362  beaconInterval = MicroSeconds (bestAp.m_probeResp.GetBeaconIntervalUs ());
363  }
364  else
365  {
366  UpdateApInfoFromBeacon (bestAp.m_beacon, bestAp.m_apAddr, bestAp.m_bssid);
367  beaconInterval = MicroSeconds (bestAp.m_beacon.GetBeaconIntervalUs ());
368  }
369 
370  Time delay = beaconInterval * m_maxMissedBeacons;
371  RestartBeaconWatchdog (delay);
373  SendAssociationRequest (false);
374  }
375  else
376  {
377  NS_LOG_DEBUG ("Exhausted list of candidate AP; restart scanning");
378  StartScanning ();
379  }
380 }
381 
382 void
384 {
385  NS_LOG_FUNCTION (this);
387  SendAssociationRequest (false);
388 }
389 
390 void
392 {
393  NS_LOG_FUNCTION (this);
395  {
397  {
399  }
402  return;
403  }
404  NS_LOG_DEBUG ("beacon missed");
407 }
408 
409 void
411 {
412  NS_LOG_FUNCTION (this << delay);
416  {
417  NS_LOG_DEBUG ("really restart watchdog.");
419  }
420 }
421 
422 bool
424 {
425  return m_state == ASSOCIATED;
426 }
427 
428 bool
430 {
431  return m_state == WAIT_ASSOC_RESP;
432 }
433 
434 void
436 {
437  NS_LOG_FUNCTION (this << packet << to);
438  if (!IsAssociated ())
439  {
440  NotifyTxDrop (packet);
442  return;
443  }
444  WifiMacHeader hdr;
445 
446  //If we are not a QoS AP then we definitely want to use AC_BE to
447  //transmit the packet. A TID of zero will map to AC_BE (through \c
448  //QosUtilsMapTidToAc()), so we use that as our default here.
449  uint8_t tid = 0;
450 
451  //For now, an AP that supports QoS does not support non-QoS
452  //associations, and vice versa. In future the AP model should
453  //support simultaneously associated QoS and non-QoS STAs, at which
454  //point there will need to be per-association QoS state maintained
455  //by the association state machine, and consulted here.
456  if (GetQosSupported ())
457  {
460  hdr.SetQosNoEosp ();
461  hdr.SetQosNoAmsdu ();
462  //Transmission of multiple frames in the same TXOP is not
463  //supported for now
464  hdr.SetQosTxopLimit (0);
465 
466  //Fill in the QoS control field in the MAC header
467  tid = QosUtilsGetTidForPacket (packet);
468  //Any value greater than 7 is invalid and likely indicates that
469  //the packet had no QoS tag, so we revert to zero, which'll
470  //mean that AC_BE is used.
471  if (tid > 7)
472  {
473  tid = 0;
474  }
475  hdr.SetQosTid (tid);
476  }
477  else
478  {
479  hdr.SetType (WIFI_MAC_DATA);
480  }
481  if (GetQosSupported ())
482  {
483  hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT control field is not yet implemented (set it to 1 when implemented)
484  }
485 
486  hdr.SetAddr1 (GetBssid ());
487  hdr.SetAddr2 (m_low->GetAddress ());
488  hdr.SetAddr3 (to);
489  hdr.SetDsNotFrom ();
490  hdr.SetDsTo ();
491 
492  if (GetQosSupported ())
493  {
494  //Sanity check that the TID is valid
495  NS_ASSERT (tid < 8);
496  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
497  }
498  else
499  {
500  m_txop->Queue (packet, hdr);
501  }
502 }
503 
504 void
506 {
507  NS_LOG_FUNCTION (this << *mpdu);
508  const WifiMacHeader* hdr = &mpdu->GetHeader ();
509  Ptr<const Packet> packet = mpdu->GetPacket ();
510  NS_ASSERT (!hdr->IsCtl ());
511  if (hdr->GetAddr3 () == GetAddress ())
512  {
513  NS_LOG_LOGIC ("packet sent by us.");
514  return;
515  }
516  else if (hdr->GetAddr1 () != GetAddress ()
517  && !hdr->GetAddr1 ().IsGroup ())
518  {
519  NS_LOG_LOGIC ("packet is not for us");
520  NotifyRxDrop (packet);
521  return;
522  }
523  else if ((hdr->GetAddr1 () == GetAddress ()) && (hdr->GetAddr2 () == GetBssid ()) && hdr->IsCfPoll ())
524  {
526  }
527  if (hdr->IsData ())
528  {
529  if (!IsAssociated ())
530  {
531  NS_LOG_LOGIC ("Received data frame while not associated: ignore");
532  NotifyRxDrop (packet);
533  return;
534  }
535  if (!(hdr->IsFromDs () && !hdr->IsToDs ()))
536  {
537  NS_LOG_LOGIC ("Received data frame not from the DS: ignore");
538  NotifyRxDrop (packet);
539  return;
540  }
541  if (hdr->GetAddr2 () != GetBssid ())
542  {
543  NS_LOG_LOGIC ("Received data frame not from the BSS we are associated with: ignore");
544  NotifyRxDrop (packet);
545  return;
546  }
547  if (hdr->IsQosData ())
548  {
549  if (hdr->IsQosAmsdu ())
550  {
551  NS_ASSERT (hdr->GetAddr3 () == GetBssid ());
553  packet = 0;
554  }
555  else
556  {
557  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
558  }
559  }
560  else if (hdr->HasData ())
561  {
562  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
563  }
564  return;
565  }
566  else if (hdr->IsProbeReq ()
567  || hdr->IsAssocReq ()
568  || hdr->IsReassocReq ())
569  {
570  //This is a frame aimed at an AP, so we can safely ignore it.
571  NotifyRxDrop (packet);
572  return;
573  }
574  else if (hdr->IsBeacon ())
575  {
576  NS_LOG_DEBUG ("Beacon received");
577  MgtBeaconHeader beacon;
578  Ptr<Packet> copy = packet->Copy ();
579  copy->RemoveHeader (beacon);
580  CapabilityInformation capabilities = beacon.GetCapabilities ();
581  NS_ASSERT (capabilities.IsEss ());
582  bool goodBeacon = false;
583  if (GetSsid ().IsBroadcast ()
584  || beacon.GetSsid ().IsEqual (GetSsid ()))
585  {
586  NS_LOG_LOGIC ("Beacon is for our SSID");
587  goodBeacon = true;
588  }
589  CfParameterSet cfParameterSet = beacon.GetCfParameterSet ();
590  if (cfParameterSet.GetCFPCount () == 0)
591  {
592  //see section 9.3.2.2 802.11-1999
593  if (GetPcfSupported ())
594  {
595  m_low->DoNavStartNow (MicroSeconds (cfParameterSet.GetCFPMaxDurationUs ()));
596  }
597  else
598  {
599  m_low->DoNavStartNow (MicroSeconds (cfParameterSet.GetCFPDurRemainingUs ()));
600  }
601  }
602  SupportedRates rates = beacon.GetSupportedRates ();
603  bool bssMembershipSelectorMatch = false;
604  for (uint8_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
605  {
606  uint8_t selector = m_phy->GetBssMembershipSelector (i);
607  if (rates.IsBssMembershipSelectorRate (selector))
608  {
609  NS_LOG_LOGIC ("Beacon is matched to our BSS membership selector");
610  bssMembershipSelectorMatch = true;
611  }
612  }
613  if (m_phy->GetNBssMembershipSelectors () > 0 && bssMembershipSelectorMatch == false)
614  {
615  NS_LOG_LOGIC ("No match for BSS membership selector");
616  goodBeacon = false;
617  }
618  if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ())
619  {
620  NS_LOG_LOGIC ("Beacon is not for us");
621  goodBeacon = false;
622  }
623  if (goodBeacon && m_state == ASSOCIATED)
624  {
627  RestartBeaconWatchdog (delay);
628  UpdateApInfoFromBeacon (beacon, hdr->GetAddr2 (), hdr->GetAddr3 ());
629  }
630  if (goodBeacon && m_state == WAIT_BEACON)
631  {
632  NS_LOG_DEBUG ("Beacon received while scanning from " << hdr->GetAddr2 ());
633  SnrTag snrTag;
634  bool removed = copy->RemovePacketTag (snrTag);
635  NS_ASSERT (removed);
636  ApInfo apInfo;
637  apInfo.m_apAddr = hdr->GetAddr2 ();
638  apInfo.m_bssid = hdr->GetAddr3 ();
639  apInfo.m_activeProbing = false;
640  apInfo.m_snr = snrTag.Get ();
641  apInfo.m_beacon = beacon;
642  UpdateCandidateApList (apInfo);
643  }
644  return;
645  }
646  else if (hdr->IsProbeResp ())
647  {
648  if (m_state == WAIT_PROBE_RESP)
649  {
650  NS_LOG_DEBUG ("Probe response received while scanning from " << hdr->GetAddr2 ());
651  MgtProbeResponseHeader probeResp;
652  Ptr<Packet> copy = packet->Copy ();
653  copy->RemoveHeader (probeResp);
654  if (!probeResp.GetSsid ().IsEqual (GetSsid ()))
655  {
656  NS_LOG_DEBUG ("Probe response is not for our SSID");
657  return;
658  }
659  SnrTag snrTag;
660  bool removed = copy->RemovePacketTag (snrTag);
661  NS_ASSERT (removed);
662  ApInfo apInfo;
663  apInfo.m_apAddr = hdr->GetAddr2 ();
664  apInfo.m_bssid = hdr->GetAddr3 ();
665  apInfo.m_activeProbing = true;
666  apInfo.m_snr = snrTag.Get ();
667  apInfo.m_probeResp = probeResp;
668  UpdateCandidateApList (apInfo);
669  }
670  return;
671  }
672  else if (hdr->IsAssocResp () || hdr->IsReassocResp ())
673  {
674  if (m_state == WAIT_ASSOC_RESP)
675  {
676  MgtAssocResponseHeader assocResp;
677  packet->PeekHeader (assocResp);
679  {
681  }
682  if (assocResp.GetStatusCode ().IsSuccess ())
683  {
685  m_aid = assocResp.GetAssociationId ();
686  if (hdr->IsReassocResp ())
687  {
688  NS_LOG_DEBUG ("reassociation done");
689  }
690  else
691  {
692  NS_LOG_DEBUG ("association completed");
693  }
694  UpdateApInfoFromAssocResp (assocResp, hdr->GetAddr2 ());
695  if (!m_linkUp.IsNull ())
696  {
697  m_linkUp ();
698  }
699  }
700  else
701  {
702  NS_LOG_DEBUG ("association refused");
703  if (m_candidateAps.empty ())
704  {
705  SetState (REFUSED);
706  }
707  else
708  {
709  ScanningTimeout ();
710  }
711  }
712  }
713  return;
714  }
715 
716  //Invoke the receive handler of our parent class to deal with any
717  //other frames. Specifically, this will handle Block Ack-related
718  //Management Action frames.
719  RegularWifiMac::Receive (Create<WifiMacQueueItem> (packet, *hdr));
720 }
721 
722 void
724 {
725  NS_LOG_FUNCTION (this << newApInfo.m_bssid << newApInfo.m_apAddr << newApInfo.m_snr << newApInfo.m_activeProbing << newApInfo.m_beacon << newApInfo.m_probeResp);
726  // Remove duplicate ApInfo entry
727  for (std::vector<ApInfo>::iterator i = m_candidateAps.begin(); i != m_candidateAps.end(); ++i)
728  {
729  if (newApInfo.m_bssid == (*i).m_bssid)
730  {
731  m_candidateAps.erase(i);
732  break;
733  }
734  }
735  // Insert before the entry with lower SNR
736  for (std::vector<ApInfo>::iterator i = m_candidateAps.begin(); i != m_candidateAps.end(); ++i)
737  {
738  if (newApInfo.m_snr > (*i).m_snr)
739  {
740  m_candidateAps.insert (i, newApInfo);
741  return;
742  }
743  }
744  // If new ApInfo is the lowest, insert at back
745  m_candidateAps.push_back(newApInfo);
746 }
747 
748 void
750 {
751  NS_LOG_FUNCTION (this << beacon << apAddr << bssid);
752  SetBssid (bssid);
753  CapabilityInformation capabilities = beacon.GetCapabilities ();
754  SupportedRates rates = beacon.GetSupportedRates ();
755  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
756  {
757  WifiMode mode = m_phy->GetMode (i);
758  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
759  {
760  m_stationManager->AddSupportedMode (apAddr, mode);
761  }
762  }
763  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
764  if (GetErpSupported ())
765  {
766  ErpInformation erpInformation = beacon.GetErpInformation ();
767  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
768  if (erpInformation.GetUseProtection () != 0)
769  {
771  }
772  else
773  {
775  }
776  if (capabilities.IsShortSlotTime () == true)
777  {
778  //enable short slot time
779  SetSlot (MicroSeconds (9));
780  }
781  else
782  {
783  //disable short slot time
784  SetSlot (MicroSeconds (20));
785  }
786  }
787  if (GetQosSupported ())
788  {
789  bool qosSupported = false;
790  EdcaParameterSet edcaParameters = beacon.GetEdcaParameterSet ();
791  if (edcaParameters.IsQosSupported ())
792  {
793  qosSupported = true;
794  //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.
795  SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTxopLimit ()));
796  SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTxopLimit ()));
797  SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ()));
798  SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ()));
799  }
800  m_stationManager->SetQosSupport (apAddr, qosSupported);
801  }
802  if (GetHtSupported ())
803  {
804  HtCapabilities htCapabilities = beacon.GetHtCapabilities ();
805  if (!htCapabilities.IsSupportedMcs (0))
806  {
808  }
809  else
810  {
811  m_stationManager->AddStationHtCapabilities (apAddr, htCapabilities);
812  HtOperation htOperation = beacon.GetHtOperation ();
813  if (htOperation.GetNonGfHtStasPresent ())
814  {
816  }
817  else
818  {
820  }
821  if (!GetVhtSupported () && GetHtConfiguration ()->GetRifsSupported () && htOperation.GetRifsMode ())
822  {
824  }
825  else
826  {
828  }
829  }
830  }
831  if (GetVhtSupported ())
832  {
833  VhtCapabilities vhtCapabilities = beacon.GetVhtCapabilities ();
834  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
835  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
836  {
837  m_stationManager->AddStationVhtCapabilities (apAddr, vhtCapabilities);
838  VhtOperation vhtOperation = beacon.GetVhtOperation ();
839  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
840  {
841  WifiMode mcs = m_phy->GetMcs (i);
842  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
843  {
844  m_stationManager->AddSupportedMcs (apAddr, mcs);
845  }
846  }
847  }
848  }
849  if (GetHtSupported ())
850  {
851  ExtendedCapabilities extendedCapabilities = beacon.GetExtendedCapabilities ();
852  //TODO: to be completed
853  }
854  if (GetHeSupported ())
855  {
856  HeCapabilities heCapabilities = beacon.GetHeCapabilities ();
857  if (heCapabilities.GetSupportedMcsAndNss () != 0)
858  {
859  m_stationManager->AddStationHeCapabilities (apAddr, heCapabilities);
860  HeOperation heOperation = beacon.GetHeOperation ();
861  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
862  {
863  WifiMode mcs = m_phy->GetMcs (i);
864  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
865  {
866  m_stationManager->AddSupportedMcs (apAddr, mcs);
867  }
868  }
869  }
870  }
871  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
873 }
874 
875 void
877 {
878  NS_LOG_FUNCTION (this << probeResp << apAddr << bssid);
879  CapabilityInformation capabilities = probeResp.GetCapabilities ();
880  SupportedRates rates = probeResp.GetSupportedRates ();
881  for (uint8_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
882  {
883  uint8_t selector = m_phy->GetBssMembershipSelector (i);
884  if (!rates.IsBssMembershipSelectorRate (selector))
885  {
886  NS_LOG_DEBUG ("Supported rates do not fit with the BSS membership selector");
887  return;
888  }
889  }
890  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
891  {
892  WifiMode mode = m_phy->GetMode (i);
893  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
894  {
895  m_stationManager->AddSupportedMode (apAddr, mode);
896  if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
897  {
899  }
900  }
901  }
902 
903  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
904  if (GetErpSupported ())
905  {
906  bool isErpAllowed = false;
907  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
908  {
909  WifiMode mode = m_phy->GetMode (i);
911  {
912  isErpAllowed = true;
913  break;
914  }
915  }
916  if (!isErpAllowed)
917  {
918  //disable short slot time and set cwMin to 31
919  SetSlot (MicroSeconds (20));
920  ConfigureContentionWindow (31, 1023);
921  }
922  else
923  {
924  ErpInformation erpInformation = probeResp.GetErpInformation ();
925  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
927  {
928  //enable short slot time
929  SetSlot (MicroSeconds (9));
930  }
931  else
932  {
933  //disable short slot time
934  SetSlot (MicroSeconds (20));
935  }
936  ConfigureContentionWindow (15, 1023);
937  }
938  }
939  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
941  SetBssid (bssid);
942 }
943 
944 void
946 {
947  NS_LOG_FUNCTION (this << assocResp << apAddr);
948  CapabilityInformation capabilities = assocResp.GetCapabilities ();
949  SupportedRates rates = assocResp.GetSupportedRates ();
950  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
951  if (GetErpSupported ())
952  {
953  bool isErpAllowed = false;
954  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
955  {
956  WifiMode mode = m_phy->GetMode (i);
958  {
959  isErpAllowed = true;
960  break;
961  }
962  }
963  if (!isErpAllowed)
964  {
965  //disable short slot time and set cwMin to 31
966  SetSlot (MicroSeconds (20));
967  ConfigureContentionWindow (31, 1023);
968  }
969  else
970  {
971  ErpInformation erpInformation = assocResp.GetErpInformation ();
972  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
974  {
975  //enable short slot time
976  SetSlot (MicroSeconds (9));
977  }
978  else
979  {
980  //disable short slot time
981  SetSlot (MicroSeconds (20));
982  }
983  ConfigureContentionWindow (15, 1023);
984  }
985  }
986  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
988  if (GetQosSupported ())
989  {
990  bool qosSupported = false;
991  EdcaParameterSet edcaParameters = assocResp.GetEdcaParameterSet ();
992  if (edcaParameters.IsQosSupported ())
993  {
994  qosSupported = true;
995  //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.
996  SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTxopLimit ()));
997  SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTxopLimit ()));
998  SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ()));
999  SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ()));
1000  }
1001  m_stationManager->SetQosSupport (apAddr, qosSupported);
1002  }
1003  if (GetHtSupported ())
1004  {
1005  HtCapabilities htCapabilities = assocResp.GetHtCapabilities ();
1006  if (!htCapabilities.IsSupportedMcs (0))
1007  {
1009  }
1010  else
1011  {
1012  m_stationManager->AddStationHtCapabilities (apAddr, htCapabilities);
1013  HtOperation htOperation = assocResp.GetHtOperation ();
1014  if (htOperation.GetNonGfHtStasPresent ())
1015  {
1017  }
1018  else
1019  {
1021  }
1022  if (!GetVhtSupported () && GetHtConfiguration ()->GetRifsSupported () && htOperation.GetRifsMode ())
1023  {
1025  }
1026  else
1027  {
1029  }
1030  }
1031  }
1032  if (GetVhtSupported ())
1033  {
1034  VhtCapabilities vhtCapabilities = assocResp.GetVhtCapabilities ();
1035  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1036  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1037  {
1038  m_stationManager->AddStationVhtCapabilities (apAddr, vhtCapabilities);
1039  VhtOperation vhtOperation = assocResp.GetVhtOperation ();
1040  }
1041  }
1042  if (GetHeSupported ())
1043  {
1044  HeCapabilities hecapabilities = assocResp.GetHeCapabilities ();
1045  if (hecapabilities.GetSupportedMcsAndNss () != 0)
1046  {
1047  m_stationManager->AddStationHeCapabilities (apAddr, hecapabilities);
1048  HeOperation heOperation = assocResp.GetHeOperation ();
1049  GetHeConfiguration ()->SetAttribute ("BssColor", UintegerValue (heOperation.GetBssColor ()));
1050  }
1051  }
1052  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
1053  {
1054  WifiMode mode = m_phy->GetMode (i);
1055  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1056  {
1057  m_stationManager->AddSupportedMode (apAddr, mode);
1058  if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1059  {
1061  }
1062  }
1063  }
1064  if (GetHtSupported ())
1065  {
1066  HtCapabilities htCapabilities = assocResp.GetHtCapabilities ();
1067  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1068  {
1069  WifiMode mcs = m_phy->GetMcs (i);
1070  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1071  {
1072  m_stationManager->AddSupportedMcs (apAddr, mcs);
1073  //here should add a control to add basic MCS when it is implemented
1074  }
1075  }
1076  }
1077  if (GetVhtSupported ())
1078  {
1079  VhtCapabilities vhtcapabilities = assocResp.GetVhtCapabilities ();
1080  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1081  {
1082  WifiMode mcs = m_phy->GetMcs (i);
1083  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtcapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
1084  {
1085  m_stationManager->AddSupportedMcs (apAddr, mcs);
1086  //here should add a control to add basic MCS when it is implemented
1087  }
1088  }
1089  }
1090  if (GetHtSupported ())
1091  {
1092  ExtendedCapabilities extendedCapabilities = assocResp.GetExtendedCapabilities ();
1093  //TODO: to be completed
1094  }
1095  if (GetHeSupported ())
1096  {
1097  HeCapabilities heCapabilities = assocResp.GetHeCapabilities ();
1098  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1099  {
1100  WifiMode mcs = m_phy->GetMcs (i);
1101  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
1102  {
1103  m_stationManager->AddSupportedMcs (apAddr, mcs);
1104  //here should add a control to add basic MCS when it is implemented
1105  }
1106  }
1107  }
1108 }
1109 
1112 {
1113  SupportedRates rates;
1114  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
1115  {
1116  WifiMode mode = m_phy->GetMode (i);
1117  uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ());
1118  NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
1119  rates.AddSupportedRate (modeDataRate);
1120  }
1121  if (GetHtSupported ())
1122  {
1123  for (uint8_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
1124  {
1126  }
1127  }
1128  return rates;
1129 }
1130 
1133 {
1134  CapabilityInformation capabilities;
1137  if (GetPcfSupported ())
1138  {
1139  capabilities.SetCfPollable ();
1140  }
1141  return capabilities;
1142 }
1143 
1144 void
1146 {
1147  if (value == ASSOCIATED
1148  && m_state != ASSOCIATED)
1149  {
1150  m_assocLogger (GetBssid ());
1151  }
1152  else if (value != ASSOCIATED
1153  && m_state == ASSOCIATED)
1154  {
1156  }
1157  m_state = value;
1158 }
1159 
1160 void
1161 StaWifiMac::SetEdcaParameters (AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
1162 {
1163  Ptr<QosTxop> edca = m_edca.find (ac)->second;
1164  edca->SetMinCw (cwMin);
1165  edca->SetMaxCw (cwMax);
1166  edca->SetAifsn (aifsn);
1167  edca->SetTxopLimit (txopLimit);
1168 }
1169 
1170 void
1172 {
1173  NS_LOG_FUNCTION (this);
1174  if (IsAssociated ())
1175  {
1176  NS_LOG_DEBUG ("PHY capabilities changed: send reassociation request");
1178  SendAssociationRequest (true);
1179  }
1180 }
1181 
1182 } //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:723
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:337
double m_snr
SNR in linear scale.
Definition: sta-wifi-mac.h:48
Ptr< HeConfiguration > GetHeConfiguration(void) const
Definition: wifi-mac.cc:483
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:783
Time m_assocRequestTimeout
association request timeout
Definition: sta-wifi-mac.h:322
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: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 SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:783
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:548
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:3994
#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.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
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:944
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:330
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:321
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.
uint8_t GetNBssMembershipSelectors(void) const
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
Definition: wifi-phy.cc:1449
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: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)
bool GetRifsSupported(void) const
#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:729
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 SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:530
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:717
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:259
The HT Operation Information ElementThis class knows how to serialise and deserialise the HT Operatio...
Definition: ht-operation.h:50
Mac48Address m_bssid
BSSID.
Definition: sta-wifi-mac.h:46
void SetPcfSupported(bool enable)
Enable or disable PCF capability support.
HtOperation GetHtOperation(void) const
Return the HT operation.
Definition: mgt-headers.cc:262
TracedCallback< Mac48Address > m_assocLogger
association logger
Definition: sta-wifi-mac.h:336
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:325
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:320
bool IsCfPoll(void) const
Return true if the Type/Subtype is one of the possible CF-Poll headers.
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.
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
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:536
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:93
The Wifi MAC high model for a STA or AP in a BSS.
uint8_t GetNonGfHtStasPresent(void) const
Return the non GF HT STAs present.
MacState
The current MAC state of the STA.
Definition: sta-wifi-mac.h:164
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1392
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:3988
void SetListenInterval(uint16_t interval)
Set the listen interval.
Definition: mgt-headers.cc:542
uint64_t GetCFPMaxDurationUs(void) const
Return the maximum CFP duration 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.
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set.
Definition: mgt-headers.cc:376
void UpdateApInfoFromBeacon(MgtBeaconHeader beacon, Mac48Address apAddr, Mac48Address bssid)
Update associated AP&#39;s information from beacon.
void Enqueue(Ptr< Packet > packet, Mac48Address to)
Ptr< HtConfiguration > GetHtConfiguration(void) const
Definition: wifi-mac.cc:469
bool GetErpSupported() const
Return whether the device supports ERP.
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:364
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.
The IEEE 802.11ac VHT Capabilities.
CfParameterSet GetCfParameterSet(void) const
Return the CF parameter set.
Definition: mgt-headers.cc:322
MacState m_state
MAC state.
Definition: sta-wifi-mac.h:318
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
Records HT capabilities of the remote station.
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:241
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
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:980
void SetVhtCapabilities(VhtCapabilities vhtCapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:584
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
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
HT PHY (Clause 20)
Definition: wifi-mode.h:58
static Mac48Address GetBroadcast(void)
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:238
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:771
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
void SetCapabilitiesChangedCallback(Callback< void > callback)
Definition: wifi-phy.cc:482
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:463
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:208
SupportedRates GetSupportedRates(void)
Return the supported rates.
Definition: mgt-headers.cc:920
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:328
bool GetShortSlotTimeEnabled(void) const
Return whether the device uses short slot time.
EventId m_beaconWatchdog
beacon watchdog
Definition: sta-wifi-mac.h:326
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: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...
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...
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:722
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:747
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: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:323
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 remaining CFP duration in microseconds.
Implement the header for management frames of type probe request.
Definition: mgt-headers.h:514
void SetExtendedCapabilities(ExtendedCapabilities extendedCapabilities)
Set the Extended Capabilities.
Definition: mgt-headers.cc:560
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:3976
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:956
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:3982
uint8_t GetBssMembershipSelector(uint8_t selector) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1455
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:186
void SetCurrentApAddress(Mac48Address currentApAddr)
Set the address of the current access point.
Definition: mgt-headers.cc:813
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:199
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:277
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: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:968
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
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 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:286
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:992
void SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:596
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:449
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:1078
The ErpInformation Information ElementThis class knows how to serialise and deserialise the ErpInform...
uint16_t m_aid
Association AID.
Definition: sta-wifi-mac.h:319
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:572
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:270
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:327
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:735
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:329
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:324
void SetShortPreambleEnabled(bool enable)
Enable or disable short PHY preambles.
The HE Operation Information ElementThis class knows how to serialise and deserialise the HE Operatio...
Definition: he-operation.h:35
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:618
Ptr< WifiRemoteStationManager > m_stationManager
Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.)
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1386
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
bool IsBroadcast(void) const
Check if the SSID is broadcast.
Definition: ssid.cc:72
The IEEE 802.11ax HE Capabilities.
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:441
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:317
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.
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:847
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
HE PHY (Clause 26)
Definition: wifi-mode.h:62
void SetRifsPermitted(bool allow)
Permit or prohibit RIFS.
bool IsShortSlotTime(void) const
Check if the short slot time in the capability information field is set to 1.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:119
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
uint8_t GetUseProtection(void) const
Return the Use_Protection field in the ErpInformation information element.
Implements the IEEE 802.11 MAC header.
Implement the header for management frames of type reassociation request.
Definition: mgt-headers.h:180
bool IsToDs(void) const
StatusCode GetStatusCode(void)
Return the status code.
Definition: mgt-headers.cc:914
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:759
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:338
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.