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 
32 namespace ns3 {
33 
34 NS_LOG_COMPONENT_DEFINE ("StaWifiMac");
35 
36 NS_OBJECT_ENSURE_REGISTERED (StaWifiMac);
37 
38 TypeId
40 {
41  static TypeId tid = TypeId ("ns3::StaWifiMac")
43  .SetGroupName ("Wifi")
44  .AddConstructor<StaWifiMac> ()
45  .AddAttribute ("ProbeRequestTimeout", "The duration to actively probe the channel.",
46  TimeValue (Seconds (0.05)),
48  MakeTimeChecker ())
49  .AddAttribute ("WaitBeaconTimeout", "The duration to dwell on a channel while passively scanning for beacon",
50  TimeValue (MilliSeconds (120)),
52  MakeTimeChecker ())
53  .AddAttribute ("AssocRequestTimeout", "The interval between two consecutive association request attempts.",
54  TimeValue (Seconds (0.5)),
56  MakeTimeChecker ())
57  .AddAttribute ("MaxMissedBeacons",
58  "Number of beacons which much be consecutively missed before "
59  "we attempt to restart association.",
60  UintegerValue (10),
62  MakeUintegerChecker<uint32_t> ())
63  .AddAttribute ("ActiveProbing",
64  "If true, we send probe requests. If false, we don't."
65  "NOTE: if more than one STA in your simulation is using active probing, "
66  "you should enable it at a different simulation time for each STA, "
67  "otherwise all the STAs will start sending probes at the same time resulting in collisions. "
68  "See bug 1060 for more info.",
69  BooleanValue (false),
72  .AddTraceSource ("Assoc", "Associated with an access point.",
74  "ns3::Mac48Address::TracedCallback")
75  .AddTraceSource ("DeAssoc", "Association with an access point lost.",
77  "ns3::Mac48Address::TracedCallback")
78  .AddTraceSource ("BeaconArrival",
79  "Time of beacons arrival from associated AP",
81  "ns3::Time::TracedCallback")
82  ;
83  return tid;
84 }
85 
87  : m_state (UNASSOCIATED),
88  m_waitBeaconEvent (),
89  m_probeRequestEvent (),
90  m_assocRequestEvent (),
91  m_beaconWatchdogEnd (Seconds (0))
92 {
93  NS_LOG_FUNCTION (this);
94 
95  //Let the lower layers know that we are acting as a non-AP STA in
96  //an infrastructure BSS.
98 }
99 
100 void
102 {
103  NS_LOG_FUNCTION (this);
104  StartScanning ();
105 }
106 
108 {
109  NS_LOG_FUNCTION (this);
110 }
111 
112 void
114 {
115  NS_LOG_FUNCTION (this << enable);
116  m_activeProbing = enable;
118  {
119  NS_LOG_DEBUG ("STA is still scanning, reset scanning process");
120  StartScanning ();
121  }
122 }
123 
124 bool
126 {
127  return m_activeProbing;
128 }
129 
130 void
132 {
133  NS_LOG_FUNCTION (this << phy);
136 }
137 
138 void
140 {
141  NS_LOG_FUNCTION (this << stationManager);
144 }
145 
146 void
148 {
149  NS_LOG_FUNCTION (this);
150  WifiMacHeader hdr;
153  hdr.SetAddr2 (GetAddress ());
155  hdr.SetDsNotFrom ();
156  hdr.SetDsNotTo ();
157  Ptr<Packet> packet = Create<Packet> ();
158  MgtProbeRequestHeader probe;
159  probe.SetSsid (GetSsid ());
160  probe.SetSupportedRates (GetSupportedRates ());
161  if (GetHtSupported () || GetVhtSupported () || GetHeSupported ())
162  {
163  probe.SetExtendedCapabilities (GetExtendedCapabilities ());
164  probe.SetHtCapabilities (GetHtCapabilities ());
165  }
166  if (GetVhtSupported () || GetHeSupported ())
167  {
168  probe.SetVhtCapabilities (GetVhtCapabilities ());
169  }
170  if (GetHeSupported ())
171  {
172  probe.SetHeCapabilities (GetHeCapabilities ());
173  }
174  packet->AddHeader (probe);
175 
176  //The standard is not clear on the correct queue for management
177  //frames if we are a QoS AP. The approach taken here is to always
178  //use the non-QoS for these regardless of whether we have a QoS
179  //association or not.
180  m_txop->Queue (packet, hdr);
181 }
182 
183 void
185 {
186  NS_LOG_FUNCTION (this << GetBssid () << isReassoc);
187  WifiMacHeader hdr;
189  hdr.SetAddr1 (GetBssid ());
190  hdr.SetAddr2 (GetAddress ());
191  hdr.SetAddr3 (GetBssid ());
192  hdr.SetDsNotFrom ();
193  hdr.SetDsNotTo ();
194  Ptr<Packet> packet = Create<Packet> ();
195  if (!isReassoc)
196  {
197  MgtAssocRequestHeader assoc;
198  assoc.SetSsid (GetSsid ());
200  assoc.SetCapabilities (GetCapabilities ());
201  assoc.SetListenInterval (0);
202  if (GetHtSupported () || GetVhtSupported () || GetHeSupported ())
203  {
206  }
207  if (GetVhtSupported () || GetHeSupported ())
208  {
210  }
211  if (GetHeSupported ())
212  {
214  }
215  packet->AddHeader (assoc);
216  }
217  else
218  {
219  MgtReassocRequestHeader reassoc;
220  reassoc.SetCurrentApAddress (GetBssid ());
221  reassoc.SetSsid (GetSsid ());
223  reassoc.SetCapabilities (GetCapabilities ());
224  reassoc.SetListenInterval (0);
225  if (GetHtSupported () || GetVhtSupported () || GetHeSupported ())
226  {
229  }
230  if (GetVhtSupported () || GetHeSupported ())
231  {
233  }
234  if (GetHeSupported ())
235  {
237  }
238  packet->AddHeader (reassoc);
239  }
240 
241  //The standard is not clear on the correct queue for management
242  //frames if we are a QoS AP. The approach taken here is to always
243  //use the non-QoS for these regardless of whether we have a QoS
244  //association or not.
245  m_txop->Queue (packet, hdr);
246 
248  {
250  }
253 }
254 
255 void
257 {
258  NS_LOG_FUNCTION (this);
261 }
262 
263 void
265 {
266  NS_LOG_FUNCTION (this);
267  switch (m_state)
268  {
269  case ASSOCIATED:
270  return;
271  break;
272  case WAIT_PROBE_RESP:
273  /* we have sent a probe request earlier so we
274  do not need to re-send a probe request immediately.
275  We just need to wait until probe-request-timeout
276  or until we get a probe response
277  */
278  break;
279  case WAIT_BEACON:
280  /* we have initiated passive scanning, continue to wait
281  and gather beacons
282  */
283  break;
284  case UNASSOCIATED:
285  /* we were associated but we missed a bunch of beacons
286  * so we should assume we are not associated anymore.
287  * We try to initiate a scan now.
288  */
289  m_linkDown ();
290  StartScanning ();
291  break;
292  case WAIT_ASSOC_RESP:
293  /* we have sent an association request so we do not need to
294  re-send an association request right now. We just need to
295  wait until either assoc-request-timeout or until
296  we get an association response.
297  */
298  break;
299  case REFUSED:
300  /* we have sent an association request and received a negative
301  association response. We wait until someone restarts an
302  association with a given ssid.
303  */
304  break;
305  }
306 }
307 
308 void
310 {
311  NS_LOG_FUNCTION (this);
312  m_candidateAps.clear ();
314  {
316  }
318  {
320  }
321  if (GetActiveProbing ())
322  {
324  SendProbeRequest ();
327  this);
328  }
329  else
330  {
334  this);
335  }
336 }
337 
338 void
340 {
341  NS_LOG_FUNCTION (this);
342  if (!m_candidateAps.empty ())
343  {
344  ApInfo bestAp = m_candidateAps.front();
345  m_candidateAps.erase(m_candidateAps.begin ());
346  NS_LOG_DEBUG ("Attempting to associate with BSSID " << bestAp.m_bssid);
347  Time beaconInterval;
348  if (bestAp.m_activeProbing)
349  {
350  UpdateApInfoFromProbeResp (bestAp.m_probeResp, bestAp.m_apAddr, bestAp.m_bssid);
351  beaconInterval = MicroSeconds (bestAp.m_probeResp.GetBeaconIntervalUs ());
352  }
353  else
354  {
355  UpdateApInfoFromBeacon (bestAp.m_beacon, bestAp.m_apAddr, bestAp.m_bssid);
356  beaconInterval = MicroSeconds (bestAp.m_beacon.GetBeaconIntervalUs ());
357  }
358 
359  Time delay = beaconInterval * m_maxMissedBeacons;
360  RestartBeaconWatchdog (delay);
362  SendAssociationRequest (false);
363  }
364  else
365  {
366  NS_LOG_DEBUG ("Exhausted list of candidate AP; restart scanning");
367  StartScanning ();
368  }
369 }
370 
371 void
373 {
374  NS_LOG_FUNCTION (this);
376  SendAssociationRequest (false);
377 }
378 
379 void
381 {
382  NS_LOG_FUNCTION (this);
384  {
386  {
388  }
391  return;
392  }
393  NS_LOG_DEBUG ("beacon missed");
396 }
397 
398 void
400 {
401  NS_LOG_FUNCTION (this << delay);
405  {
406  NS_LOG_DEBUG ("really restart watchdog.");
408  }
409 }
410 
411 bool
413 {
414  return m_state == ASSOCIATED;
415 }
416 
417 bool
419 {
420  return m_state == WAIT_ASSOC_RESP;
421 }
422 
423 void
425 {
426  NS_LOG_FUNCTION (this << packet << to);
427  if (!IsAssociated ())
428  {
429  NotifyTxDrop (packet);
431  return;
432  }
433  WifiMacHeader hdr;
434 
435  //If we are not a QoS AP then we definitely want to use AC_BE to
436  //transmit the packet. A TID of zero will map to AC_BE (through \c
437  //QosUtilsMapTidToAc()), so we use that as our default here.
438  uint8_t tid = 0;
439 
440  //For now, an AP that supports QoS does not support non-QoS
441  //associations, and vice versa. In future the AP model should
442  //support simultaneously associated QoS and non-QoS STAs, at which
443  //point there will need to be per-association QoS state maintained
444  //by the association state machine, and consulted here.
445  if (GetQosSupported ())
446  {
449  hdr.SetQosNoEosp ();
450  hdr.SetQosNoAmsdu ();
451  //Transmission of multiple frames in the same TXOP is not
452  //supported for now
453  hdr.SetQosTxopLimit (0);
454 
455  //Fill in the QoS control field in the MAC header
456  tid = QosUtilsGetTidForPacket (packet);
457  //Any value greater than 7 is invalid and likely indicates that
458  //the packet had no QoS tag, so we revert to zero, which'll
459  //mean that AC_BE is used.
460  if (tid > 7)
461  {
462  tid = 0;
463  }
464  hdr.SetQosTid (tid);
465  }
466  else
467  {
468  hdr.SetType (WIFI_MAC_DATA);
469  }
471  {
472  hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT/VHT/HE control field is not yet implemented (set it to 1 when implemented)
473  }
474 
475  hdr.SetAddr1 (GetBssid ());
476  hdr.SetAddr2 (m_low->GetAddress ());
477  hdr.SetAddr3 (to);
478  hdr.SetDsNotFrom ();
479  hdr.SetDsTo ();
480 
481  if (GetQosSupported ())
482  {
483  //Sanity check that the TID is valid
484  NS_ASSERT (tid < 8);
485  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
486  }
487  else
488  {
489  m_txop->Queue (packet, hdr);
490  }
491 }
492 
493 void
495 {
496  NS_LOG_FUNCTION (this << packet << hdr);
497  NS_ASSERT (!hdr->IsCtl ());
498  if (hdr->GetAddr3 () == GetAddress ())
499  {
500  NS_LOG_LOGIC ("packet sent by us.");
501  return;
502  }
503  else if (hdr->GetAddr1 () != GetAddress ()
504  && !hdr->GetAddr1 ().IsGroup ())
505  {
506  NS_LOG_LOGIC ("packet is not for us");
507  NotifyRxDrop (packet);
508  return;
509  }
510  else if ((hdr->GetAddr1 () == GetAddress ()) && (hdr->GetAddr2 () == GetBssid ()) && hdr->IsCfPoll ())
511  {
513  }
514  if (hdr->IsData ())
515  {
516  if (!IsAssociated ())
517  {
518  NS_LOG_LOGIC ("Received data frame while not associated: ignore");
519  NotifyRxDrop (packet);
520  return;
521  }
522  if (!(hdr->IsFromDs () && !hdr->IsToDs ()))
523  {
524  NS_LOG_LOGIC ("Received data frame not from the DS: ignore");
525  NotifyRxDrop (packet);
526  return;
527  }
528  if (hdr->GetAddr2 () != GetBssid ())
529  {
530  NS_LOG_LOGIC ("Received data frame not from the BSS we are associated with: ignore");
531  NotifyRxDrop (packet);
532  return;
533  }
534  if (hdr->IsQosData ())
535  {
536  if (hdr->IsQosAmsdu ())
537  {
538  NS_ASSERT (hdr->GetAddr3 () == GetBssid ());
539  DeaggregateAmsduAndForward (packet, hdr);
540  packet = 0;
541  }
542  else
543  {
544  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
545  }
546  }
547  else if (hdr->HasData ())
548  {
549  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
550  }
551  return;
552  }
553  else if (hdr->IsProbeReq ()
554  || hdr->IsAssocReq ()
555  || hdr->IsReassocReq ())
556  {
557  //This is a frame aimed at an AP, so we can safely ignore it.
558  NotifyRxDrop (packet);
559  return;
560  }
561  else if (hdr->IsBeacon ())
562  {
563  NS_LOG_DEBUG ("Beacon received");
564  MgtBeaconHeader beacon;
565  packet->RemoveHeader (beacon);
566  CapabilityInformation capabilities = beacon.GetCapabilities ();
567  NS_ASSERT (capabilities.IsEss ());
568  bool goodBeacon = false;
569  if (GetSsid ().IsBroadcast ()
570  || beacon.GetSsid ().IsEqual (GetSsid ()))
571  {
572  NS_LOG_LOGIC ("Beacon is for our SSID");
573  goodBeacon = true;
574  }
575  CfParameterSet cfParameterSet = beacon.GetCfParameterSet ();
576  if (cfParameterSet.GetCFPCount () == 0)
577  {
578  //see section 9.3.2.2 802.11-1999
579  if (GetPcfSupported ())
580  {
581  m_low->DoNavStartNow (MicroSeconds (cfParameterSet.GetCFPMaxDurationUs ()));
582  }
583  else
584  {
585  m_low->DoNavStartNow (MicroSeconds (cfParameterSet.GetCFPDurRemainingUs ()));
586  }
587  }
588  SupportedRates rates = beacon.GetSupportedRates ();
589  bool bssMembershipSelectorMatch = false;
590  for (uint8_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
591  {
592  uint8_t selector = m_phy->GetBssMembershipSelector (i);
593  if (rates.IsBssMembershipSelectorRate (selector))
594  {
595  NS_LOG_LOGIC ("Beacon is matched to our BSS membership selector");
596  bssMembershipSelectorMatch = true;
597  }
598  }
599  if (m_phy->GetNBssMembershipSelectors () > 0 && bssMembershipSelectorMatch == false)
600  {
601  NS_LOG_LOGIC ("No match for BSS membership selector");
602  goodBeacon = false;
603  }
604  if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ())
605  {
606  NS_LOG_LOGIC ("Beacon is not for us");
607  goodBeacon = false;
608  }
609  if (goodBeacon && m_state == ASSOCIATED)
610  {
613  RestartBeaconWatchdog (delay);
614  UpdateApInfoFromBeacon (beacon, hdr->GetAddr2 (), hdr->GetAddr3 ());
615  }
616  if (goodBeacon && m_state == WAIT_BEACON)
617  {
618  NS_LOG_DEBUG ("Beacon received while scanning from " << hdr->GetAddr2 ());
619  SnrTag snrTag;
620  bool removed = packet->RemovePacketTag (snrTag);
621  NS_ASSERT (removed);
622  ApInfo apInfo;
623  apInfo.m_apAddr = hdr->GetAddr2 ();
624  apInfo.m_bssid = hdr->GetAddr3 ();
625  apInfo.m_activeProbing = false;
626  apInfo.m_snr = snrTag.Get ();
627  apInfo.m_beacon = beacon;
628  UpdateCandidateApList (apInfo);
629  }
630  return;
631  }
632  else if (hdr->IsProbeResp ())
633  {
634  if (m_state == WAIT_PROBE_RESP)
635  {
636  NS_LOG_DEBUG ("Probe response received while scanning from " << hdr->GetAddr2 ());
637  MgtProbeResponseHeader probeResp;
638  packet->RemoveHeader (probeResp);
639  if (!probeResp.GetSsid ().IsEqual (GetSsid ()))
640  {
641  NS_LOG_DEBUG ("Probe response is not for our SSID");
642  return;
643  }
644  SnrTag snrTag;
645  bool removed = packet->RemovePacketTag (snrTag);
646  NS_ASSERT (removed);
647  ApInfo apInfo;
648  apInfo.m_apAddr = hdr->GetAddr2 ();
649  apInfo.m_bssid = hdr->GetAddr3 ();
650  apInfo.m_activeProbing = true;
651  apInfo.m_snr = snrTag.Get ();
652  apInfo.m_probeResp = probeResp;
653  UpdateCandidateApList (apInfo);
654  }
655  return;
656  }
657  else if (hdr->IsAssocResp () || hdr->IsReassocResp ())
658  {
659  if (m_state == WAIT_ASSOC_RESP)
660  {
661  MgtAssocResponseHeader assocResp;
662  packet->RemoveHeader (assocResp);
664  {
666  }
667  if (assocResp.GetStatusCode ().IsSuccess ())
668  {
670  if (hdr->IsReassocResp ())
671  {
672  NS_LOG_DEBUG ("reassociation done");
673  }
674  else
675  {
676  NS_LOG_DEBUG ("association completed");
677  }
678  UpdateApInfoFromAssocResp (assocResp, hdr->GetAddr2 ());
679  if (!m_linkUp.IsNull ())
680  {
681  m_linkUp ();
682  }
683  }
684  else
685  {
686  NS_LOG_DEBUG ("association refused");
687  if (m_candidateAps.empty ())
688  {
689  SetState (REFUSED);
690  }
691  else
692  {
693  ScanningTimeout ();
694  }
695  }
696  }
697  return;
698  }
699 
700  //Invoke the receive handler of our parent class to deal with any
701  //other frames. Specifically, this will handle Block Ack-related
702  //Management Action frames.
703  RegularWifiMac::Receive (packet, hdr);
704 }
705 
706 void
708 {
709  NS_LOG_FUNCTION (this << newApInfo.m_bssid << newApInfo.m_apAddr << newApInfo.m_snr << newApInfo.m_activeProbing << newApInfo.m_beacon << newApInfo.m_probeResp);
710  // Remove duplicate ApInfo entry
711  for (std::vector<ApInfo>::iterator i = m_candidateAps.begin(); i != m_candidateAps.end(); ++i)
712  {
713  if (newApInfo.m_bssid == (*i).m_bssid)
714  {
715  m_candidateAps.erase(i);
716  break;
717  }
718  }
719  // Insert before the entry with lower SNR
720  for (std::vector<ApInfo>::iterator i = m_candidateAps.begin(); i != m_candidateAps.end(); ++i)
721  {
722  if (newApInfo.m_snr > (*i).m_snr)
723  {
724  m_candidateAps.insert (i, newApInfo);
725  return;
726  }
727  }
728  // If new ApInfo is the lowest, insert at back
729  m_candidateAps.push_back(newApInfo);
730 }
731 
732 void
734 {
735  NS_LOG_FUNCTION (this << beacon << apAddr << bssid);
736  SetBssid (bssid);
737  CapabilityInformation capabilities = beacon.GetCapabilities ();
738  SupportedRates rates = beacon.GetSupportedRates ();
739  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
740  {
741  WifiMode mode = m_phy->GetMode (i);
742  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
743  {
744  m_stationManager->AddSupportedMode (apAddr, mode);
745  }
746  }
747  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
748  if (GetErpSupported ())
749  {
750  ErpInformation erpInformation = beacon.GetErpInformation ();
751  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
752  if (erpInformation.GetUseProtection () != 0)
753  {
755  }
756  else
757  {
759  }
760  if (capabilities.IsShortSlotTime () == true)
761  {
762  //enable short slot time
763  SetSlot (MicroSeconds (9));
764  }
765  else
766  {
767  //disable short slot time
768  SetSlot (MicroSeconds (20));
769  }
770  }
771  if (GetQosSupported ())
772  {
773  bool qosSupported = false;
774  EdcaParameterSet edcaParameters = beacon.GetEdcaParameterSet ();
775  if (edcaParameters.IsQosSupported ())
776  {
777  qosSupported = true;
778  //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.
779  SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTxopLimit ()));
780  SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTxopLimit ()));
781  SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ()));
782  SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ()));
783  }
784  m_stationManager->SetQosSupport (apAddr, qosSupported);
785  }
786  if (GetHtSupported ())
787  {
788  HtCapabilities htCapabilities = beacon.GetHtCapabilities ();
789  if (!htCapabilities.IsSupportedMcs (0))
790  {
792  }
793  else
794  {
795  m_stationManager->AddStationHtCapabilities (apAddr, htCapabilities);
796  HtOperation htOperation = beacon.GetHtOperation ();
797  if (htOperation.GetNonGfHtStasPresent ())
798  {
800  }
801  else
802  {
804  }
805  if (!GetVhtSupported () && GetRifsSupported () && htOperation.GetRifsMode ())
806  {
808  }
809  else
810  {
812  }
813  }
814  }
815  if (GetVhtSupported ())
816  {
817  VhtCapabilities vhtCapabilities = beacon.GetVhtCapabilities ();
818  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
819  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
820  {
821  m_stationManager->AddStationVhtCapabilities (apAddr, vhtCapabilities);
822  VhtOperation vhtOperation = beacon.GetVhtOperation ();
823  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
824  {
825  WifiMode mcs = m_phy->GetMcs (i);
826  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
827  {
828  m_stationManager->AddSupportedMcs (apAddr, mcs);
829  }
830  }
831  }
832  }
833  if (GetHtSupported () || GetVhtSupported ())
834  {
835  ExtendedCapabilities extendedCapabilities = beacon.GetExtendedCapabilities ();
836  //TODO: to be completed
837  }
838  if (GetHeSupported ())
839  {
840  HeCapabilities heCapabilities = beacon.GetHeCapabilities ();
841  //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer
842  m_stationManager->AddStationHeCapabilities (apAddr, heCapabilities);
843  HeOperation heOperation = beacon.GetHeOperation ();
844  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
845  {
846  WifiMode mcs = m_phy->GetMcs (i);
847  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
848  {
849  m_stationManager->AddSupportedMcs (apAddr, mcs);
850  }
851  }
852  }
853  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
855 }
856 
857 void
859 {
860  NS_LOG_FUNCTION (this << probeResp << apAddr << bssid);
861  CapabilityInformation capabilities = probeResp.GetCapabilities ();
862  SupportedRates rates = probeResp.GetSupportedRates ();
863  for (uint8_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
864  {
865  uint8_t selector = m_phy->GetBssMembershipSelector (i);
866  if (!rates.IsBssMembershipSelectorRate (selector))
867  {
868  NS_LOG_DEBUG ("Supported rates do not fit with the BSS membership selector");
869  return;
870  }
871  }
872  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
873  {
874  WifiMode mode = m_phy->GetMode (i);
875  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
876  {
877  m_stationManager->AddSupportedMode (apAddr, mode);
878  if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
879  {
881  }
882  }
883  }
884 
885  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
886  if (GetErpSupported ())
887  {
888  bool isErpAllowed = false;
889  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
890  {
891  WifiMode mode = m_phy->GetMode (i);
893  {
894  isErpAllowed = true;
895  break;
896  }
897  }
898  if (!isErpAllowed)
899  {
900  //disable short slot time and set cwMin to 31
901  SetSlot (MicroSeconds (20));
902  ConfigureContentionWindow (31, 1023);
903  }
904  else
905  {
906  ErpInformation erpInformation = probeResp.GetErpInformation ();
907  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
909  {
910  //enable short slot time
911  SetSlot (MicroSeconds (9));
912  }
913  else
914  {
915  //disable short slot time
916  SetSlot (MicroSeconds (20));
917  }
918  ConfigureContentionWindow (15, 1023);
919  }
920  }
921  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
923  SetBssid (bssid);
924 }
925 
926 void
928 {
929  NS_LOG_FUNCTION (this << assocResp << apAddr);
930  CapabilityInformation capabilities = assocResp.GetCapabilities ();
931  SupportedRates rates = assocResp.GetSupportedRates ();
932  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
933  if (GetErpSupported ())
934  {
935  bool isErpAllowed = false;
936  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
937  {
938  WifiMode mode = m_phy->GetMode (i);
940  {
941  isErpAllowed = true;
942  break;
943  }
944  }
945  if (!isErpAllowed)
946  {
947  //disable short slot time and set cwMin to 31
948  SetSlot (MicroSeconds (20));
949  ConfigureContentionWindow (31, 1023);
950  }
951  else
952  {
953  ErpInformation erpInformation = assocResp.GetErpInformation ();
954  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
956  {
957  //enable short slot time
958  SetSlot (MicroSeconds (9));
959  }
960  else
961  {
962  //disable short slot time
963  SetSlot (MicroSeconds (20));
964  }
965  ConfigureContentionWindow (15, 1023);
966  }
967  }
968  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
970  if (GetQosSupported ())
971  {
972  bool qosSupported = false;
973  EdcaParameterSet edcaParameters = assocResp.GetEdcaParameterSet ();
974  if (edcaParameters.IsQosSupported ())
975  {
976  qosSupported = true;
977  //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.
978  SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTxopLimit ()));
979  SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTxopLimit ()));
980  SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ()));
981  SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ()));
982  }
983  m_stationManager->SetQosSupport (apAddr, qosSupported);
984  }
985  if (GetHtSupported ())
986  {
987  HtCapabilities htCapabilities = assocResp.GetHtCapabilities ();
988  if (!htCapabilities.IsSupportedMcs (0))
989  {
991  }
992  else
993  {
994  m_stationManager->AddStationHtCapabilities (apAddr, htCapabilities);
995  HtOperation htOperation = assocResp.GetHtOperation ();
996  if (htOperation.GetNonGfHtStasPresent ())
997  {
999  }
1000  else
1001  {
1003  }
1004  if (!GetVhtSupported () && GetRifsSupported () && htOperation.GetRifsMode ())
1005  {
1007  }
1008  else
1009  {
1011  }
1012  }
1013  }
1014  if (GetVhtSupported ())
1015  {
1016  VhtCapabilities vhtCapabilities = assocResp.GetVhtCapabilities ();
1017  //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1018  if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1019  {
1020  m_stationManager->AddStationVhtCapabilities (apAddr, vhtCapabilities);
1021  VhtOperation vhtOperation = assocResp.GetVhtOperation ();
1022  }
1023  }
1024  if (GetHeSupported ())
1025  {
1026  HeCapabilities hecapabilities = assocResp.GetHeCapabilities ();
1027  //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer
1028  m_stationManager->AddStationHeCapabilities (apAddr, hecapabilities);
1029  HeOperation heOperation = assocResp.GetHeOperation ();
1030  }
1031  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
1032  {
1033  WifiMode mode = m_phy->GetMode (i);
1034  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1035  {
1036  m_stationManager->AddSupportedMode (apAddr, mode);
1037  if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1038  {
1040  }
1041  }
1042  }
1043  if (GetHtSupported ())
1044  {
1045  HtCapabilities htCapabilities = assocResp.GetHtCapabilities ();
1046  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1047  {
1048  WifiMode mcs = m_phy->GetMcs (i);
1049  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1050  {
1051  m_stationManager->AddSupportedMcs (apAddr, mcs);
1052  //here should add a control to add basic MCS when it is implemented
1053  }
1054  }
1055  }
1056  if (GetVhtSupported ())
1057  {
1058  VhtCapabilities vhtcapabilities = assocResp.GetVhtCapabilities ();
1059  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1060  {
1061  WifiMode mcs = m_phy->GetMcs (i);
1062  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtcapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
1063  {
1064  m_stationManager->AddSupportedMcs (apAddr, mcs);
1065  //here should add a control to add basic MCS when it is implemented
1066  }
1067  }
1068  }
1069  if (GetHtSupported () || GetVhtSupported ())
1070  {
1071  ExtendedCapabilities extendedCapabilities = assocResp.GetExtendedCapabilities ();
1072  //TODO: to be completed
1073  }
1074  if (GetHeSupported ())
1075  {
1076  HeCapabilities heCapabilities = assocResp.GetHeCapabilities ();
1077  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1078  {
1079  WifiMode mcs = m_phy->GetMcs (i);
1080  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
1081  {
1082  m_stationManager->AddSupportedMcs (apAddr, mcs);
1083  //here should add a control to add basic MCS when it is implemented
1084  }
1085  }
1086  }
1087 }
1088 
1091 {
1092  SupportedRates rates;
1093  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
1094  {
1095  WifiMode mode = m_phy->GetMode (i);
1096  uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ());
1097  NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
1098  rates.AddSupportedRate (modeDataRate);
1099  }
1100  if (GetHtSupported () || GetVhtSupported () || GetHeSupported ())
1101  {
1102  for (uint8_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
1103  {
1105  }
1106  }
1107  return rates;
1108 }
1109 
1112 {
1113  CapabilityInformation capabilities;
1116  if (GetPcfSupported ())
1117  {
1118  capabilities.SetCfPollable ();
1119  }
1120  return capabilities;
1121 }
1122 
1123 void
1125 {
1126  if (value == ASSOCIATED
1127  && m_state != ASSOCIATED)
1128  {
1129  m_assocLogger (GetBssid ());
1130  }
1131  else if (value != ASSOCIATED
1132  && m_state == ASSOCIATED)
1133  {
1135  }
1136  m_state = value;
1137 }
1138 
1139 void
1140 StaWifiMac::SetEdcaParameters (AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
1141 {
1142  Ptr<QosTxop> edca = m_edca.find (ac)->second;
1143  edca->SetMinCw (cwMin);
1144  edca->SetMaxCw (cwMax);
1145  edca->SetAifsn (aifsn);
1146  edca->SetTxopLimit (txopLimit);
1147 }
1148 
1149 void
1151 {
1152  NS_LOG_FUNCTION (this);
1153  if (IsAssociated ())
1154  {
1155  NS_LOG_DEBUG ("PHY capabilities changed: send reassociation request");
1157  SendAssociationRequest (true);
1158  }
1159 }
1160 
1161 } //namespace ns3
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:258
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:729
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void SetWifiPhy(const Ptr< WifiPhy > phy)
bool IsSuccess(void) const
Return whether the status code is success.
Definition: status-code.cc:42
bool m_activeProbing
Flag whether active probing is used or not.
Definition: sta-wifi-mac.h:45
TracedCallback< Mac48Address > m_deAssocLogger
deassoc logger
Definition: sta-wifi-mac.h:320
double m_snr
SNR.
Definition: sta-wifi-mac.h:44
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:732
Time m_assocRequestTimeout
assoc request timeout
Definition: sta-wifi-mac.h:305
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
Handle a received packet.
Implement the header for management frames of type association request.
Definition: mgt-headers.h:49
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
bool GetActiveProbing(void) const
Return whether active probing is enabled.
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:554
bool IsBssMembershipSelectorRate(uint64_t bs) const
Check if the given rate is a BSS membership selector value.
void DoInitialize(void)
Initialize() implementation.
ERP-OFDM PHY (19.5)
Definition: wifi-mode.h:54
AttributeValue implementation for Boolean.
Definition: boolean.h:36
bool GetHeSupported() const
Return whether the device supports HE.
Ptr< Txop > m_txop
This holds a pointer to the TXOP instance for this WifiMac - used for transmission of frames to non-Q...
WifiMode GetMcs(uint8_t mcs) const
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
Definition: wifi-phy.cc:3523
#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 reeive MCS supported.
bool IsCtl(void) const
Return true if the Type is Control.
void SetEdcaParameters(AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
Set the EDCA parameters.
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:950
bool GetQosSupported() const
Return whether the device supports QoS.
uint16_t GetVoTxopLimit(void) const
Return the AC_VO TXOP Limit field in the EdcaParameterSet information element.
bool IsSupportedRate(uint64_t bs) const
Check if the given rate is supported.
void SetState(MacState value)
Set the current MAC state.
std::vector< ApInfo > m_candidateAps
list of candidate APs to associate
Definition: sta-wifi-mac.h:313
void AssocRequestTimeout(void)
This method is called after the association timeout occurred.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: boolean.h:84
Time m_probeRequestTimeout
probe request timeout
Definition: sta-wifi-mac.h:304
EdcaQueues m_edca
This is a map from Access Category index to the corresponding channel access function.
bool DoNavStartNow(Time duration)
Start NAV with the given duration.
Definition: mac-low.cc:1295
uint8_t GetNBssMembershipSelectors(void) const
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
Definition: wifi-phy.cc:1320
void StartScanning(void)
Start the scanning process which trigger active or passive scanning based on the active probing flag...
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities of the device.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
The Extended Capabilities Information ElementThis class knows how to serialise and deserialise the Ex...
The VHT Operation Information ElementThis class knows how to serialise and deserialise the VHT Operat...
Definition: vht-operation.h:37
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
Struct to hold information regarding observed AP through active/passive scanning. ...
Definition: sta-wifi-mac.h:40
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:202
void SetListenInterval(uint16_t interval)
Set the listen interval.
Definition: mgt-headers.cc:735
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1022
The HT Capabilities Information ElementThis class knows how to serialise and deserialise the HT Capab...
void SetHtCapabilities(HtCapabilities htcapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:578
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:536
void UpdateCandidateApList(ApInfo newApInfo)
Update list of candidate AP to associate.
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:723
bool GetPcfSupported() const
Return whether the device supports PCF.
uint32_t GetBeCWmin(void) const
Return the AC_BE CWmin field in the EdcaParameterSet information element.
VhtOperation GetVhtOperation(void) const
Return the VHT operation.
void SetSlot(Time slotTime)
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:242
The HT Operation Information ElementThis class knows how to serialise and deserialise the HT Operatio...
Definition: ht-operation.h:52
Mac48Address m_bssid
BSSID.
Definition: sta-wifi-mac.h:42
virtual void DeaggregateAmsduAndForward(Ptr< Packet > aggregatedPacket, const WifiMacHeader *hdr)
This method can be called to de-aggregate an A-MSDU and forward the constituent packets up the stack...
virtual void SetPcfSupported(bool enable)
Enable or disable PCF capability support.
HtOperation GetHtOperation(void) const
Return the HT operation.
Definition: mgt-headers.cc:268
TracedCallback< Mac48Address > m_assocLogger
assoc logger
Definition: sta-wifi-mac.h:319
bool IsBasicRate(uint64_t bs) const
Check if the given rate is a basic rate.
EventId m_assocRequestEvent
assoc request event
Definition: sta-wifi-mac.h:308
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:303
bool IsCfPoll(void) const
Return true if the Type/Subtype is one of the possible CF-Poll headers.
void SetHeCapabilities(HeCapabilities hecapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:602
Video.
Definition: qos-utils.h:44
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:46
Best Effort.
Definition: qos-utils.h:40
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
bool GetShortSlotTimeSupported(void) const
Capability information.
void AddSupportedRate(uint64_t bs)
Add the given rate to the supported rates.
double Get(void) const
Return the SNR value.
Definition: snr-tag.cc:89
virtual void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
Set up WifiRemoteStationManager associated with this StaWifiMac.
uint32_t GetBeCWmax(void) const
Return the AC_BE CWmax field in the EdcaParameterSet information element.
HeOperation GetHeOperation(void) const
Return the HE operation.
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:542
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a qos tag is attached to the packet, returns a value < 8.
Definition: qos-utils.cc:57
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
phy
Definition: third.py:86
The Wifi MAC high model for a STA or AP in a BSS.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
uint8_t GetNonGfHtStasPresent(void) const
Return the non GF HT STAs present.
bool GetShortPlcpPreambleSupported(void) const
Return whether short PLCP preamble is supported.
Definition: wifi-phy.cc:644
MacState
The current MAC state of the STA.
Definition: sta-wifi-mac.h:141
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1263
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:3517
void SetListenInterval(uint16_t interval)
Set the listen interval.
Definition: mgt-headers.cc:548
uint64_t GetCFPMaxDurationUs(void) const
Return the CFP MaxDuration in microseconds.
void SendProbeRequest(void)
Forward a probe request packet to the DCF.
Background.
Definition: qos-utils.h:42
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current STA.
void ForwardUp(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set.
Definition: mgt-headers.cc:382
void UpdateApInfoFromBeacon(MgtBeaconHeader beacon, Mac48Address apAddr, Mac48Address bssid)
Update associated AP&#39;s information from beacon.
void SetVhtCapabilities(VhtCapabilities vhtcapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:777
bool GetErpSupported() const
Return whether the device supports ERP.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1381
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:370
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:43
ErpInformation GetErpInformation(void) const
Return the ERP information.
Definition: mgt-headers.cc:370
AttributeValue implementation for Time.
Definition: nstime.h:1076
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
bool GetVhtSupported() const
Return whether the device supports VHT.
bool IsBeacon(void) const
Return true if the header is a Beacon header.
void SetHtCapabilities(HtCapabilities htcapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:765
The IEEE 802.11ac VHT Capabilities.
CfParameterSet GetCfParameterSet(void) const
Return the CF parameter set.
Definition: mgt-headers.cc:328
MacState m_state
MAC state.
Definition: sta-wifi-mac.h:302
void SetExtendedCapabilities(ExtendedCapabilities extendedcapabilities)
Set the Extended Capabilities.
Definition: mgt-headers.cc:566
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:224
Hold an unsigned integer type.
Definition: uinteger.h:44
bool IsEss(void) const
Check if the Extended Service Set (ESS) bit in the capability information field is set to 1...
void MissedBeacons(void)
This method is called after we have not received a beacon from the AP.
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:220
uint8_t GetBkAifsn(void) const
Return the AC_BK AIFSN field in the EdcaParameterSet information element.
bool IsFromDs(void) const
The CF Parameter SetThis class knows how to serialise and deserialise the CF Parameter Set...
HtOperation GetHtOperation(void) const
Return the HT operation.
Definition: mgt-headers.cc:986
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
Records HT capabilities of the remote station.
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
MgtProbeResponseHeader m_probeResp
Probe Response header.
Definition: sta-wifi-mac.h:47
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Definition: qos-utils.cc:31
HT PHY (Clause 20)
Definition: wifi-mode.h:58
static Mac48Address GetBroadcast(void)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:244
Mac48Address GetBssid(void) const
void ScanningTimeout(void)
This method is called after wait beacon timeout or wait probe request timeout has occurred...
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities hecapabilities)
Records HE capabilities of the remote station.
void SetCapabilitiesChangedCallback(Callback< void > callback)
Definition: wifi-phy.cc:438
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:500
Ptr< MacLow > m_low
MacLow (RTS, CTS, DATA, ACK etc.)
uint64_t GetBeaconIntervalUs(void) const
Return the beacon interval in microseconds unit.
Definition: mgt-headers.cc:214
SupportedRates GetSupportedRates(void)
Return the supported rates.
Definition: mgt-headers.cc:926
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set.
ErpInformation GetErpInformation(void) const
Return the ERP information.
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
void SetQosSupport(Mac48Address from, bool qosSupported)
Records QoS support of the remote station.
uint32_t GetBkCWmin(void) const
Return the AC_BK CWmin field in the EdcaParameterSet information element.
Callback< void > m_linkDown
Callback when a link is down.
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
void SetCfPollable(void)
Set the CF-Pollable bit in the capability information field.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
void SendCfPollResponse(void)
Forward a CF-Poll response packet to the CFP queue.
uint32_t m_maxMissedBeacons
maximum missed beacons
Definition: sta-wifi-mac.h:311
bool GetShortSlotTimeEnabled(void) const
Return whether the device uses short slot time.
EventId m_beaconWatchdog
beacon watchdog
Definition: sta-wifi-mac.h:309
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
void UpdateApInfoFromProbeResp(MgtProbeResponseHeader probeResp, Mac48Address apAddr, Mac48Address bssid)
Update AP&#39;s information from probe response.
virtual ~StaWifiMac()
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsData(void) const
Return true if the Type is DATA.
uint32_t GetVoCWmin(void) const
Return the AC_VO CWmin field in the EdcaParameterSet information element.
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:256
void PhyCapabilitiesChanged(void)
Indicate that PHY capabilities have changed.
The EDCA Parameter SetThis class knows how to serialise and deserialise the EDCA Parameter Set...
void AddSupportedMode(Mac48Address address, WifiMode mode)
Invoked in a STA or AP to store the set of modes supported by a destination which is also supported l...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
static TypeId GetTypeId(void)
Get the type ID.
Definition: sta-wifi-mac.cc:39
void AddBssMembershipSelectorRate(uint64_t bs)
Add a special value to the supported rate set, corresponding to a BSS membership selector.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
uint8_t GetBeAifsn(void) const
Return the AC_BE AIFSN field in the EdcaParameterSet information element.
bool IsProbeReq(void) const
Return true if the header is a Probe Request header.
an EUI-48 address
Definition: mac48-address.h:43
bool IsShortPreamble(void) const
Check if the short preamble bit in the capability information field is set to 1.
void SetVhtCapabilities(VhtCapabilities vhtcapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:590
Ssid GetSsid(void) const
void RestartBeaconWatchdog(Time delay)
Restarts the beacon timer.
void TryToEnsureAssociated(void)
Try to ensure that we are associated with an AP by taking an appropriate action depending on the curr...
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:1077
bool IsGroup(void) const
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
Ssid GetSsid(void) const
Return the Service Set Identifier (SSID).
Definition: mgt-headers.cc:208
void SetShortPreamble(bool shortPreamble)
Set the short preamble bit in the capability information field.
MgtBeaconHeader m_beacon
Beacon header.
Definition: sta-wifi-mac.h:46
void SetHeCapabilities(HeCapabilities hecapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:789
EventId m_waitBeaconEvent
wait beacon event
Definition: sta-wifi-mac.h:306
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
uint8_t GetRifsMode(void) const
Return the RIFS mode.
uint32_t GetVoCWmax(void) const
Return the AC_VO CWmax field in the EdcaParameterSet information element.
uint64_t GetCFPDurRemainingUs(void) const
Return the CFP DurRemaining in microseconds.
Implement the header for management frames of type probe request.
Definition: mgt-headers.h:508
void SetActiveProbing(bool enable)
Enable or disable active probing.
Mac48Address GetAddress(void) const
uint8_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3505
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:318
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:962
void UpdateApInfoFromAssocResp(MgtAssocResponseHeader assocResp, Mac48Address apAddr)
Update AP&#39;s information from association response.
uint16_t GetBkTxopLimit(void) const
Return the AC_BK TXOP Limit field in the EdcaParameterSet information element.
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
WifiMode GetMode(uint8_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3511
uint8_t GetBssMembershipSelector(uint8_t selector) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1326
uint8_t GetVoAifsn(void) const
Return the AC_VO AIFSN field in the EdcaParameterSet information element.
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
uint16_t GetBeTxopLimit(void) const
Return the AC_BE TXOP Limit field in the EdcaParameterSet information element.
virtual void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:296
bool IsSupportedRxMcs(uint8_t mcs) const
Get the is receive MCS supported.
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:175
void SetCurrentApAddress(Mac48Address currentApAddr)
Set the address of the current access point.
Definition: mgt-headers.cc:819
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:187
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:264
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:859
HeOperation GetHeOperation(void) const
Return the HE operation.
Definition: mgt-headers.cc:316
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:270
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:974
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:65
void Enqueue(Ptr< const Packet > packet, Mac48Address to)
void SetUseGreenfieldProtection(bool enable)
Enable or disable protection for stations that do not support HT greenfield format.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
bool IsEqual(const Ssid &o) const
Check if the two SSIDs are equal.
Definition: ssid.cc:55
void SetDsTo(void)
Set the To DS bit in the Frame Control field.
VhtOperation GetVhtOperation(void) const
Return the VHT operation.
Definition: mgt-headers.cc:292
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:998
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:1030
The ErpInformation Information ElementThis class knows how to serialise and deserialise the ErpInform...
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:40
uint32_t GetViCWmax(void) const
Return the AC_VI CWmax field in the EdcaParameterSet information element.
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:257
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:232
uint32_t GetViCWmin(void) const
Return the AC_VI CWmin field in the EdcaParameterSet information element.
bool IsWaitAssocResp(void) const
Return whether we are waiting for an association response from an AP.
Time m_beaconWatchdogEnd
beacon watchdog end
Definition: sta-wifi-mac.h:310
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:741
uint8_t GetBarkerPreambleMode(void) const
Return the Barker_Preamble_Mode field in the ErpInformation information element.
bool m_activeProbing
active probing
Definition: sta-wifi-mac.h:312
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:307
void SetShortPreambleEnabled(bool enable)
Enable or disable short PLCP preambles.
The HE Operation Information ElementThis class knows how to serialise and deserialise the HE Operatio...
Definition: he-operation.h:37
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:612
Ptr< WifiRemoteStationManager > m_stationManager
Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.)
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
bool IsBroadcast(void) const
Check if the SSID is broadcast.
Definition: ssid.cc:72
The IEEE 802.11ax HE Capabilities.
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:478
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
void SetExtendedCapabilities(ExtendedCapabilities extendedcapabilities)
Set the Extended Capabilities.
Definition: mgt-headers.cc:753
a unique identifier for an interface.
Definition: type-id.h:58
virtual void SetWifiPhy(const Ptr< WifiPhy > phy)
void RemoveAllSupportedMcs(Mac48Address address)
Invoked in a STA or AP to delete all of the supported MCS by a destination.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
uint8_t GetViAifsn(void) const
Return the AC_VI AIFSN field in the EdcaParameterSet information element.
uint8_t IsQosSupported(void) const
Is QOS supported function.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:37
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:841
Introspection did not find any typical Config paths.
Definition: snr-tag.h:34
HE PHY (Clause 26)
Definition: wifi-mode.h:62
void SetRifsPermitted(bool allow)
Permit or prohibit RIFS.
bool IsShortSlotTime(void) const
Check if the short slot time in the capability information field is set to 1.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:156
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
uint8_t GetUseProtection(void) const
Return the Use_Protection field in the ErpInformation information element.
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtcapabilities)
Records VHT capabilities of the remote station.
Implements the IEEE 802.11 MAC header.
Implement the header for management frames of type reassociation request.
Definition: mgt-headers.h:180
bool IsToDs(void) const
StatusCode GetStatusCode(void)
Return the status code.
Definition: mgt-headers.cc:920
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:280
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
bool HasData(void) const
Return true if the header type is DATA and is not DATA_NULL.
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
void SendAssociationRequest(bool isReassoc)
Forward an association or reassociation request packet to the DCF.
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:304
bool IsAssociated(void) const
Return whether we are associated with an AP.
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
TracedCallback< Time > m_beaconArrival
beacon arrival logger
Definition: sta-wifi-mac.h:321
The Wifi MAC high model for a non-AP STA in a BSS.
Definition: sta-wifi-mac.h:102
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS ACK policy in the QoS control field.