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 "sta-wifi-mac.h"
24 #include "ns3/log.h"
25 #include "ns3/simulator.h"
26 #include "ns3/string.h"
27 #include "ns3/pointer.h"
28 #include "ns3/boolean.h"
29 #include "ns3/trace-source-accessor.h"
30 #include "qos-tag.h"
31 #include "mac-low.h"
32 #include "dcf-manager.h"
33 #include "mac-rx-middle.h"
34 #include "mac-tx-middle.h"
35 #include "wifi-mac-header.h"
36 #include "msdu-aggregator.h"
37 #include "amsdu-subframe-header.h"
38 #include "mgt-headers.h"
39 #include "ht-capabilities.h"
40 #include "ht-operations.h"
41 #include "vht-capabilities.h"
42 
43 /*
44  * The state machine for this STA is:
45  -------------- -----------
46  | Associated | <-------------------- -------> | Refused |
47  -------------- \ / -----------
48  \ \ /
49  \ ----------------- -----------------------------
50  \-> | Beacon Missed | --> | Wait Association Response |
51  ----------------- -----------------------------
52  \ ^
53  \ |
54  \ -----------------------
55  \-> | Wait Probe Response |
56  -----------------------
57  */
58 
59 namespace ns3 {
60 
61 NS_LOG_COMPONENT_DEFINE ("StaWifiMac");
62 
63 NS_OBJECT_ENSURE_REGISTERED (StaWifiMac);
64 
65 TypeId
67 {
68  static TypeId tid = TypeId ("ns3::StaWifiMac")
70  .SetGroupName ("Wifi")
71  .AddConstructor<StaWifiMac> ()
72  .AddAttribute ("ProbeRequestTimeout", "The interval between two consecutive probe request attempts.",
73  TimeValue (Seconds (0.05)),
75  MakeTimeChecker ())
76  .AddAttribute ("AssocRequestTimeout", "The interval between two consecutive assoc request attempts.",
77  TimeValue (Seconds (0.5)),
79  MakeTimeChecker ())
80  .AddAttribute ("MaxMissedBeacons",
81  "Number of beacons which much be consecutively missed before "
82  "we attempt to restart association.",
83  UintegerValue (10),
85  MakeUintegerChecker<uint32_t> ())
86  .AddAttribute ("ActiveProbing",
87  "If true, we send probe requests. If false, we don't."
88  "NOTE: if more than one STA in your simulation is using active probing, "
89  "you should enable it at a different simulation time for each STA, "
90  "otherwise all the STAs will start sending probes at the same time resulting in collisions. "
91  "See bug 1060 for more info.",
92  BooleanValue (false),
95  .AddTraceSource ("Assoc", "Associated with an access point.",
97  "ns3::Mac48Address::TracedCallback")
98  .AddTraceSource ("DeAssoc", "Association with an access point lost.",
100  "ns3::Mac48Address::TracedCallback")
101  ;
102  return tid;
103 }
104 
106  : m_state (BEACON_MISSED),
107  m_probeRequestEvent (),
108  m_assocRequestEvent (),
109  m_beaconWatchdogEnd (Seconds (0.0))
110 {
111  NS_LOG_FUNCTION (this);
112 
113  //Let the lower layers know that we are acting as a non-AP STA in
114  //an infrastructure BSS.
116 }
117 
119 {
120  NS_LOG_FUNCTION (this);
121 }
122 
123 void
125 {
126  NS_LOG_FUNCTION (this << missed);
127  m_maxMissedBeacons = missed;
128 }
129 
130 void
132 {
133  NS_LOG_FUNCTION (this << timeout);
135 }
136 
137 void
139 {
140  NS_LOG_FUNCTION (this << timeout);
142 }
143 
144 void
146 {
147  NS_LOG_FUNCTION (this);
149 }
150 
151 void
153 {
154  NS_LOG_FUNCTION (this << enable);
155  if (enable)
156  {
158  }
159  else
160  {
162  }
163  m_activeProbing = enable;
164 }
165 
167 {
168  return m_activeProbing;
169 }
170 
171 void
173 {
174  NS_LOG_FUNCTION (this);
175  WifiMacHeader hdr;
176  hdr.SetProbeReq ();
178  hdr.SetAddr2 (GetAddress ());
180  hdr.SetDsNotFrom ();
181  hdr.SetDsNotTo ();
182  Ptr<Packet> packet = Create<Packet> ();
183  MgtProbeRequestHeader probe;
184  probe.SetSsid (GetSsid ());
185  probe.SetSupportedRates (GetSupportedRates ());
187  {
188  probe.SetHtCapabilities (GetHtCapabilities ());
189  hdr.SetNoOrder ();
190  }
191  if (m_vhtSupported)
192  {
193  probe.SetVhtCapabilities (GetVhtCapabilities ());
194  }
195  packet->AddHeader (probe);
196 
197  //The standard is not clear on the correct queue for management
198  //frames if we are a QoS AP. The approach taken here is to always
199  //use the DCF for these regardless of whether we have a QoS
200  //association or not.
201  m_dca->Queue (packet, hdr);
202 
204  {
206  }
209 }
210 
211 void
213 {
214  NS_LOG_FUNCTION (this << GetBssid ());
215  WifiMacHeader hdr;
216  hdr.SetAssocReq ();
217  hdr.SetAddr1 (GetBssid ());
218  hdr.SetAddr2 (GetAddress ());
219  hdr.SetAddr3 (GetBssid ());
220  hdr.SetDsNotFrom ();
221  hdr.SetDsNotTo ();
222  Ptr<Packet> packet = Create<Packet> ();
223  MgtAssocRequestHeader assoc;
224  assoc.SetSsid (GetSsid ());
225  assoc.SetSupportedRates (GetSupportedRates ());
226  assoc.SetCapabilities (GetCapabilities ());
228  {
229  assoc.SetHtCapabilities (GetHtCapabilities ());
230  hdr.SetNoOrder ();
231  }
232  if (m_vhtSupported)
233  {
234  assoc.SetVhtCapabilities (GetVhtCapabilities ());
235  }
236  packet->AddHeader (assoc);
237 
238  //The standard is not clear on the correct queue for management
239  //frames if we are a QoS AP. The approach taken here is to always
240  //use the DCF for these regardless of whether we have a QoS
241  //association or not.
242  m_dca->Queue (packet, hdr);
243 
245  {
247  }
250 }
251 
252 void
254 {
255  NS_LOG_FUNCTION (this);
256  switch (m_state)
257  {
258  case ASSOCIATED:
259  return;
260  break;
261  case WAIT_PROBE_RESP:
262  /* we have sent a probe request earlier so we
263  do not need to re-send a probe request immediately.
264  We just need to wait until probe-request-timeout
265  or until we get a probe response
266  */
267  break;
268  case BEACON_MISSED:
269  /* we were associated but we missed a bunch of beacons
270  * so we should assume we are not associated anymore.
271  * We try to initiate a probe request now.
272  */
273  m_linkDown ();
274  if (m_activeProbing)
275  {
277  SendProbeRequest ();
278  }
279  break;
280  case WAIT_ASSOC_RESP:
281  /* we have sent an assoc request so we do not need to
282  re-send an assoc request right now. We just need to
283  wait until either assoc-request-timeout or until
284  we get an assoc response.
285  */
286  break;
287  case REFUSED:
288  /* we have sent an assoc request and received a negative
289  assoc resp. We wait until someone restarts an
290  association with a given ssid.
291  */
292  break;
293  }
294 }
295 
296 void
298 {
299  NS_LOG_FUNCTION (this);
302 }
303 
304 void
306 {
307  NS_LOG_FUNCTION (this);
309  SendProbeRequest ();
310 }
311 
312 void
314 {
315  NS_LOG_FUNCTION (this);
317  {
319  {
321  }
324  return;
325  }
326  NS_LOG_DEBUG ("beacon missed");
329 }
330 
331 void
333 {
334  NS_LOG_FUNCTION (this << delay);
338  {
339  NS_LOG_DEBUG ("really restart watchdog.");
341  }
342 }
343 
344 bool
346 {
347  return m_state == ASSOCIATED;
348 }
349 
350 bool
352 {
353  return m_state == WAIT_ASSOC_RESP;
354 }
355 
356 void
358 {
359  NS_LOG_FUNCTION (this << packet << to);
360  if (!IsAssociated ())
361  {
362  NotifyTxDrop (packet);
364  return;
365  }
366  WifiMacHeader hdr;
367 
368  //If we are not a QoS AP then we definitely want to use AC_BE to
369  //transmit the packet. A TID of zero will map to AC_BE (through \c
370  //QosUtilsMapTidToAc()), so we use that as our default here.
371  uint8_t tid = 0;
372 
373  //For now, an AP that supports QoS does not support non-QoS
374  //associations, and vice versa. In future the AP model should
375  //support simultaneously associated QoS and non-QoS STAs, at which
376  //point there will need to be per-association QoS state maintained
377  //by the association state machine, and consulted here.
378  if (m_qosSupported)
379  {
382  hdr.SetQosNoEosp ();
383  hdr.SetQosNoAmsdu ();
384  //Transmission of multiple frames in the same TXOP is not
385  //supported for now
386  hdr.SetQosTxopLimit (0);
387 
388  //Fill in the QoS control field in the MAC header
389  tid = QosUtilsGetTidForPacket (packet);
390  //Any value greater than 7 is invalid and likely indicates that
391  //the packet had no QoS tag, so we revert to zero, which'll
392  //mean that AC_BE is used.
393  if (tid > 7)
394  {
395  tid = 0;
396  }
397  hdr.SetQosTid (tid);
398  }
399  else
400  {
401  hdr.SetTypeData ();
402  }
404  {
405  hdr.SetNoOrder ();
406  }
407 
408  hdr.SetAddr1 (GetBssid ());
409  hdr.SetAddr2 (m_low->GetAddress ());
410  hdr.SetAddr3 (to);
411  hdr.SetDsNotFrom ();
412  hdr.SetDsTo ();
413 
414  if (m_qosSupported)
415  {
416  //Sanity check that the TID is valid
417  NS_ASSERT (tid < 8);
418  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
419  }
420  else
421  {
422  m_dca->Queue (packet, hdr);
423  }
424 }
425 
426 void
428 {
429  NS_LOG_FUNCTION (this << packet << hdr);
430  NS_ASSERT (!hdr->IsCtl ());
431  if (hdr->GetAddr3 () == GetAddress ())
432  {
433  NS_LOG_LOGIC ("packet sent by us.");
434  return;
435  }
436  else if (hdr->GetAddr1 () != GetAddress ()
437  && !hdr->GetAddr1 ().IsGroup ())
438  {
439  NS_LOG_LOGIC ("packet is not for us");
440  NotifyRxDrop (packet);
441  return;
442  }
443  else if (hdr->IsData ())
444  {
445  if (!IsAssociated ())
446  {
447  NS_LOG_LOGIC ("Received data frame while not associated: ignore");
448  NotifyRxDrop (packet);
449  return;
450  }
451  if (!(hdr->IsFromDs () && !hdr->IsToDs ()))
452  {
453  NS_LOG_LOGIC ("Received data frame not from the DS: ignore");
454  NotifyRxDrop (packet);
455  return;
456  }
457  if (hdr->GetAddr2 () != GetBssid ())
458  {
459  NS_LOG_LOGIC ("Received data frame not from the BSS we are associated with: ignore");
460  NotifyRxDrop (packet);
461  return;
462  }
463  if (hdr->IsQosData ())
464  {
465  if (hdr->IsQosAmsdu ())
466  {
467  NS_ASSERT (hdr->GetAddr3 () == GetBssid ());
468  DeaggregateAmsduAndForward (packet, hdr);
469  packet = 0;
470  }
471  else
472  {
473  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
474  }
475  }
476  else
477  {
478  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
479  }
480  return;
481  }
482  else if (hdr->IsProbeReq ()
483  || hdr->IsAssocReq ())
484  {
485  //This is a frame aimed at an AP, so we can safely ignore it.
486  NotifyRxDrop (packet);
487  return;
488  }
489  else if (hdr->IsBeacon ())
490  {
491  MgtBeaconHeader beacon;
492  packet->RemoveHeader (beacon);
493  CapabilityInformation capabilities = beacon.GetCapabilities ();
494  bool goodBeacon = false;
495  if (GetSsid ().IsBroadcast ()
496  || beacon.GetSsid ().IsEqual (GetSsid ()))
497  {
498  goodBeacon = true;
499  }
500  SupportedRates rates = beacon.GetSupportedRates ();
501  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
502  {
503  uint32_t selector = m_phy->GetBssMembershipSelector (i);
504  if (!rates.IsSupportedRate (selector))
505  {
506  goodBeacon = false;
507  }
508  }
509  if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ())
510  {
511  goodBeacon = false;
512  }
513  if (goodBeacon)
514  {
516  RestartBeaconWatchdog (delay);
517  SetBssid (hdr->GetAddr3 ());
518  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
519  if (m_erpSupported)
520  {
521  ErpInformation erpInformation = beacon.GetErpInformation ();
522  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
523  if (erpInformation.GetUseProtection() == true)
524  {
526  }
527  else
528  {
530  }
531  if (capabilities.IsShortSlotTime () == true)
532  {
533  //enable short slot time
534  SetSlot (MicroSeconds (9));
535  }
536  else
537  {
538  //disable short slot time
539  SetSlot (MicroSeconds (20));
540  }
541  }
542  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
544  }
545  if (goodBeacon && m_state == BEACON_MISSED)
546  {
549  }
550  return;
551  }
552  else if (hdr->IsProbeResp ())
553  {
554  if (m_state == WAIT_PROBE_RESP)
555  {
556  MgtProbeResponseHeader probeResp;
557  packet->RemoveHeader (probeResp);
558  CapabilityInformation capabilities = probeResp.GetCapabilities ();
559  if (!probeResp.GetSsid ().IsEqual (GetSsid ()))
560  {
561  //not a probe resp for our ssid.
562  return;
563  }
564  SupportedRates rates = probeResp.GetSupportedRates ();
565  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
566  {
567  uint32_t selector = m_phy->GetBssMembershipSelector (i);
568  if (!rates.IsSupportedRate (selector))
569  {
570  return;
571  }
572  }
573  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
574  {
575  WifiMode mode = m_phy->GetMode (i);
576  uint8_t nss = 1; // Assume 1 spatial stream
577  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, nss)))
578  {
579  m_stationManager->AddSupportedMode (hdr->GetAddr2 (), mode);
580  if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, nss)))
581  {
583  }
584  }
585  }
586 
587  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
588  if (m_erpSupported)
589  {
590  bool isErpAllowed = false;
591  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
592  {
593  WifiMode mode = m_phy->GetMode (i);
594  if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM && rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1)))
595  {
596  isErpAllowed = true;
597  break;
598  }
599  }
600  if (!isErpAllowed)
601  {
602  //disable short slot time and set cwMin to 31
603  SetSlot (MicroSeconds (20));
604  ConfigureContentionWindow (31, 1023);
605  }
606  else
607  {
608  ErpInformation erpInformation = probeResp.GetErpInformation ();
609  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
611  {
612  //enable short slot time
613  SetSlot (MicroSeconds (9));
614  }
615  else
616  {
617  //disable short slot time
618  SetSlot (MicroSeconds (20));
619  }
620  }
621  }
622  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
624  SetBssid (hdr->GetAddr3 ());
625  Time delay = MicroSeconds (probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons);
626  RestartBeaconWatchdog (delay);
628  {
630  }
633  }
634  return;
635  }
636  else if (hdr->IsAssocResp ())
637  {
638  if (m_state == WAIT_ASSOC_RESP)
639  {
640  MgtAssocResponseHeader assocResp;
641  packet->RemoveHeader (assocResp);
643  {
645  }
646  if (assocResp.GetStatusCode ().IsSuccess ())
647  {
649  NS_LOG_DEBUG ("assoc completed");
650  CapabilityInformation capabilities = assocResp.GetCapabilities ();
651  SupportedRates rates = assocResp.GetSupportedRates ();
652  bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
653  if (m_erpSupported)
654  {
655  bool isErpAllowed = false;
656  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
657  {
658  WifiMode mode = m_phy->GetMode (i);
659  if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM && rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1)))
660  {
661  isErpAllowed = true;
662  break;
663  }
664  }
665  if (!isErpAllowed)
666  {
667  //disable short slot time and set cwMin to 31
668  SetSlot (MicroSeconds (20));
669  ConfigureContentionWindow (31, 1023);
670  }
671  else
672  {
673  ErpInformation erpInformation = assocResp.GetErpInformation ();
674  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
676  {
677  //enable short slot time
678  SetSlot (MicroSeconds (9));
679  }
680  else
681  {
682  //disable short slot time
683  SetSlot (MicroSeconds (20));
684  }
685  }
686  }
687  m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
689  if (m_htSupported)
690  {
691  HtCapabilities htcapabilities = assocResp.GetHtCapabilities ();
692  HtOperations htOperations = assocResp.GetHtOperations ();
693  m_stationManager->AddStationHtCapabilities (hdr->GetAddr2 (), htcapabilities);
694  }
695  if (m_vhtSupported)
696  {
697  VhtCapabilities vhtcapabilities = assocResp.GetVhtCapabilities ();
698  m_stationManager->AddStationVhtCapabilities (hdr->GetAddr2 (), vhtcapabilities);
699  }
700 
701  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
702  {
703  WifiMode mode = m_phy->GetMode (i);
704  uint8_t nss = 1; // Assume 1 spatial stream
705  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, nss)))
706  {
707  m_stationManager->AddSupportedMode (hdr->GetAddr2 (), mode);
708  if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, nss)))
709  {
711  }
712  }
713  }
714  if (m_htSupported)
715  {
716  HtCapabilities htcapabilities = assocResp.GetHtCapabilities ();
717  for (uint32_t i = 0; i < m_phy->GetNMcs (); i++)
718  {
719  WifiMode mcs = m_phy->GetMcs (i);
720  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
721  {
722  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
723  //here should add a control to add basic MCS when it is implemented
724  }
725  }
726  }
727  if (m_vhtSupported)
728  {
729  VhtCapabilities vhtcapabilities = assocResp.GetVhtCapabilities ();
730  for (uint32_t i = 0; i < m_phy->GetNMcs (); i++)
731  {
732  WifiMode mcs = m_phy->GetMcs (i);
733  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
734  {
735  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
736  //here should add a control to add basic MCS when it is implemented
737  }
738  }
739  }
740  if (!m_linkUp.IsNull ())
741  {
742  m_linkUp ();
743  }
744  }
745  else
746  {
747  NS_LOG_DEBUG ("assoc refused");
748  SetState (REFUSED);
749  }
750  }
751  return;
752  }
753 
754  //Invoke the receive handler of our parent class to deal with any
755  //other frames. Specifically, this will handle Block Ack-related
756  //Management Action frames.
757  RegularWifiMac::Receive (packet, hdr);
758 }
759 
762 {
763  SupportedRates rates;
764  uint8_t nss = 1; // Number of spatial streams is 1 for non-MIMO modes
766  {
767  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
768  {
770  }
771  }
772  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
773  {
774  WifiMode mode = m_phy->GetMode (i);
775  uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth (), false, nss);
776  NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
777  rates.AddSupportedRate (modeDataRate);
778  }
779  return rates;
780 }
781 
784 {
785  CapabilityInformation capabilities;
788  return capabilities;
789 }
790 
791 void
793 {
794  if (value == ASSOCIATED
795  && m_state != ASSOCIATED)
796  {
797  m_assocLogger (GetBssid ());
798  }
799  else if (value != ASSOCIATED
800  && m_state == ASSOCIATED)
801  {
803  }
804  m_state = value;
805 }
806 
807 } //namespace ns3
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:232
bool IsWaitAssocResp(void) const
Return whether we are waiting for an association response from an AP.
bool IsBeacon(void) const
Return true if the header is a Beacon header.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:268
The HT Operations Information ElementThis class knows how to serialise and deserialise the HT Operati...
Definition: ht-operations.h:54
TracedCallback< Mac48Address > m_deAssocLogger
Definition: sta-wifi-mac.h:192
void AddSupportedRate(uint32_t bs)
Add the given rate to the supported rates.
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates...
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
bool IsSupportedTxMcs(uint8_t mcs) const
Time m_assocRequestTimeout
Definition: sta-wifi-mac.h:183
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:183
bool GetShortSlotTimeEnabled(void) const
Return whether the device uses short slot time.
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...
Implement the header for management frames of type association request.
Definition: mgt-headers.h:44
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetQosAckPolicy(enum QosAckPolicy policy)
Set the QoS ACK policy in the QoS control field.
ERP-OFDM PHY (19.5)
Definition: wifi-mode.h:58
AttributeValue implementation for Boolean.
Definition: boolean.h:34
void SendAssociationRequest(void)
Forward an association request packet to the DCF.
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:578
Ssid GetSsid(void) const
Return the Service Set Identifier (SSID).
Definition: mgt-headers.cc:171
HtOperations GetHtOperations(void) const
Return the HT operations.
Definition: mgt-headers.cc:602
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
void SetProbeReq(void)
Set Type/Subtype values for a probe request header.
virtual uint32_t GetNModes(void) const =0
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
uint64_t GetBeaconIntervalUs(void) const
Return the beacon interval in microseconds unit.
Definition: mgt-headers.cc:177
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:81
Time m_probeRequestTimeout
Definition: sta-wifi-mac.h:182
void SetProbeRequestTimeout(Time timeout)
EdcaQueues m_edca
This is a map from Access Category index to the corresponding channel access function.
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
enum WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:386
virtual uint8_t GetNMcs(void) const =0
The WifiPhy::GetNMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of t...
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1258
#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
Callback< void > m_linkUp
Callback when a link is up.
void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
The HT Capabilities Information ElementThis class knows how to serialise and deserialise the HT Capab...
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:393
void SetSlot(Time slotTime)
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:284
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:65
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:614
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...
TracedCallback< Mac48Address > m_assocLogger
Definition: sta-wifi-mac.h:191
virtual bool GetShortPlcpPreambleSupported(void) const =0
EventId m_assocRequestEvent
Definition: sta-wifi-mac.h:185
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
VHT PHY (Clause 22)
Definition: wifi-mode.h:64
Ptr< WifiPhy > m_phy
Wifi PHY.
bool IsCtl(void) const
Return true if the Type is Control.
ns3::Time timeout
bool IsEqual(const Ssid &o) const
Check if the two SSIDs are equal.
Definition: ssid.cc:73
virtual Ssid GetSsid(void) const
The Supported Rates Information ElementThis class knows how to serialise and deserialise the Supporte...
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capability of the device.
bool IsProbeResp(void) const
Return true if the header is a Probe Response header.
Capability information.
void SetAssocRequestTimeout(Time timeout)
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...
virtual WifiMode GetMcs(uint8_t mcs) const =0
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
ErpInformation GetErpInformation(void) const
Return the ERP information.
Definition: mgt-headers.cc:626
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a qos tag is attached to the packet, returns a value < 8.
Definition: qos-utils.cc:62
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
virtual void SetBssid(Mac48Address bssid)
void SendProbeRequest(void)
Forward a probe request packet to the DCF.
void ForwardUp(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
virtual uint32_t GetChannelWidth(void) const =0
base class for all MAC-level wifi objects.
void ProbeRequestTimeout(void)
This method is called after the probe request timeout occurred.
bool m_qosSupported
This Boolean is set true iff this WifiMac is to model 802.11e/WMM style Quality of Service...
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1216
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:45
AttributeValue implementation for Time.
Definition: nstime.h:957
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
MacState
The current MAC state of the STA.
Definition: sta-wifi-mac.h:90
Ptr< DcaTxop > m_dca
This holds a pointer to the DCF instance for this WifiMac - used for transmission of frames to non-Qo...
ErpInformation GetErpInformation(void) const
Return the ERP information.
Definition: mgt-headers.cc:261
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
The IEEE 802.11ac VHT Capabilities.
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:266
bool IsProbeReq(void) const
Return true if the header is a Probe Request header.
Hold an unsigned integer type.
Definition: uinteger.h:44
void MissedBeacons(void)
This method is called after we have not received a beacon from the AP.
uint8_t GetBarkerPreambleMode(void) const
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
Records HT capabilities of the remote station.
bool m_vhtSupported
This Boolean is set true iff this WifiMac is to model 802.11ac.
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Definition: qos-utils.cc:28
HT PHY (Clause 20)
Definition: wifi-mode.h:62
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:364
static Mac48Address GetBroadcast(void)
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:627
bool GetActiveProbing(void) const
Return whether active probing is enabled.
void SetState(enum MacState value)
Set the current MAC state.
void SetAssocReq(void)
Set Type/Subtype values for an association request header.
virtual uint32_t GetNBssMembershipSelectors(void) const =0
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
Ptr< MacLow > m_low
MacLow (RTS, CTS, DATA, ACK etc.)
SupportedRates GetSupportedRates(void)
Return the supported rates.
Definition: mgt-headers.cc:554
HtCapabilities GetHtCapabilities(void) const
Return the HT capability of the device.
void SetBasicRate(uint32_t bs)
Set the given rate to basic rates.
Callback< void > m_linkDown
Callback when a link is down.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
bool IsBasicRate(uint32_t bs) const
Check if the given rate is a basic rate.
uint32_t m_maxMissedBeacons
Definition: sta-wifi-mac.h:188
void StartActiveAssociation(void)
Start an active association sequence immediately.
void SetMaxMissedBeacons(uint32_t missed)
EventId m_beaconWatchdog
Definition: sta-wifi-mac.h:186
virtual ~StaWifiMac()
bool IsToDs(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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...
bool IsGroup(void) const
virtual uint32_t GetBssMembershipSelector(uint32_t selector) const =0
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
bool IsSupportedMcs(uint8_t mcs) const
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
static TypeId GetTypeId(void)
Definition: sta-wifi-mac.cc:66
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.
an EUI-48 address
Definition: mac48-address.h:43
uint64_t GetDataRate(uint32_t channelWidth, bool isShortGuardInterval, uint8_t nss) const
Definition: wifi-mode.cc:109
virtual WifiMode GetMode(uint32_t mode) const =0
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
void RestartBeaconWatchdog(Time delay)
Restarts the beacon timer.
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current STA.
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:1379
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:958
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
void SetShortPreamble(bool shortPreamble)
Set the short preamble bit in the capability information field.
Implement the header for management frames of type probe request.
Definition: mgt-headers.h:268
bool m_htSupported
This Boolean is set true iff this WifiMac is to model 802.11n.
void SetActiveProbing(bool enable)
Enable or disable active probing.
Implement the header for management frames of type association response.
Definition: mgt-headers.h:149
virtual Mac48Address GetBssid(void) const
bool IsShortSlotTime(void) const
Check if the short slot time in the capability information field is set to 1.
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
bool IsData(void) const
Return true if the Type is DATA.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS DATA...
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
virtual Mac48Address GetAddress(void) const
void SetTypeData(void)
Set Type/Subtype values for a data packet with no subtype equal to 0.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
bool IsSuccess(void) const
Return whether the status code is success.
Definition: status-code.cc:44
virtual void Enqueue(Ptr< const Packet > packet, Mac48Address to)
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
void SetDsTo(void)
Set the To DS bit in the Frame Control field.
bool IsFromDs(void) const
bool IsSupportedRate(uint32_t bs) const
Check if the given rate is supported.
void SetNoOrder(void)
Unset order bit in the frame control field.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:911
The ErpInformation Information ElementThis class knows how to serialise and deserialise the ErpInform...
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:195
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:41
void SetType(enum WifiMacType type)
Set Type/Subtype values with the correct values depending on the given type.
enum MacState m_state
Definition: sta-wifi-mac.h:181
virtual bool GetShortSlotTimeSupported(void) const
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
Time m_beaconWatchdogEnd
Definition: sta-wifi-mac.h:187
bool m_erpSupported
This Boolean is set true iff this WifiMac is to model 802.11g.
void SetShortSlotTime(bool shortSlotTime)
Set the short slot time bit in the capability information field.
EventId m_probeRequestEvent
Definition: sta-wifi-mac.h:184
void SetShortPreambleEnabled(bool enable)
Enable or disable short PLCP preambles.
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:346
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.
uint8_t GetUseProtection(void) const
bool IsAssociated(void) const
Return whether we are associated with an AP.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
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
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:826
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:484
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:257
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtcapabilities)
Records VHT capabilities of the remote station.
Implements the IEEE 802.11 MAC header.
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
StatusCode GetStatusCode(void)
Return the status code.
Definition: mgt-headers.cc:548
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:590
The Wifi MAC high model for a non-AP STA in a BSS.
Definition: sta-wifi-mac.h:42
bool IsShortPreamble(void) const
Check if the short preamble bit in the capability information field is set to 1.