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 "vht-capabilities.h"
41 
42 /*
43  * The state machine for this STA is:
44  -------------- -----------
45  | Associated | <-------------------- -------> | Refused |
46  -------------- \ / -----------
47  \ \ /
48  \ ----------------- -----------------------------
49  \-> | Beacon Missed | --> | Wait Association Response |
50  ----------------- -----------------------------
51  \ ^
52  \ |
53  \ -----------------------
54  \-> | Wait Probe Response |
55  -----------------------
56  */
57 
58 namespace ns3 {
59 
60 NS_LOG_COMPONENT_DEFINE ("StaWifiMac");
61 
62 NS_OBJECT_ENSURE_REGISTERED (StaWifiMac);
63 
64 TypeId
66 {
67  static TypeId tid = TypeId ("ns3::StaWifiMac")
69  .SetGroupName ("Wifi")
70  .AddConstructor<StaWifiMac> ()
71  .AddAttribute ("ProbeRequestTimeout", "The interval between two consecutive probe request attempts.",
72  TimeValue (Seconds (0.05)),
74  MakeTimeChecker ())
75  .AddAttribute ("AssocRequestTimeout", "The interval between two consecutive assoc request attempts.",
76  TimeValue (Seconds (0.5)),
78  MakeTimeChecker ())
79  .AddAttribute ("MaxMissedBeacons",
80  "Number of beacons which much be consecutively missed before "
81  "we attempt to restart association.",
82  UintegerValue (10),
84  MakeUintegerChecker<uint32_t> ())
85  .AddAttribute ("ActiveProbing",
86  "If true, we send probe requests. If false, we don't."
87  "NOTE: if more than one STA in your simulation is using active probing, "
88  "you should enable it at a different simulation time for each STA, "
89  "otherwise all the STAs will start sending probes at the same time resulting in collisions. "
90  "See bug 1060 for more info.",
91  BooleanValue (false),
94  .AddTraceSource ("Assoc", "Associated with an access point.",
96  "ns3::Mac48Address::TracedCallback")
97  .AddTraceSource ("DeAssoc", "Association with an access point lost.",
99  "ns3::Mac48Address::TracedCallback")
100  ;
101  return tid;
102 }
103 
105  : m_state (BEACON_MISSED),
106  m_probeRequestEvent (),
107  m_assocRequestEvent (),
108  m_beaconWatchdogEnd (Seconds (0.0))
109 {
110  NS_LOG_FUNCTION (this);
111 
112  //Let the lower layers know that we are acting as a non-AP STA in
113  //an infrastructure BSS.
115 }
116 
118 {
119  NS_LOG_FUNCTION (this);
120 }
121 
122 void
124 {
125  NS_LOG_FUNCTION (this << missed);
126  m_maxMissedBeacons = missed;
127 }
128 
129 void
131 {
132  NS_LOG_FUNCTION (this << timeout);
134 }
135 
136 void
138 {
139  NS_LOG_FUNCTION (this << timeout);
141 }
142 
143 void
145 {
146  NS_LOG_FUNCTION (this);
148 }
149 
150 void
152 {
153  NS_LOG_FUNCTION (this << enable);
154  if (enable)
155  {
157  }
158  else
159  {
161  }
162  m_activeProbing = enable;
163 }
164 
166 {
167  return m_activeProbing;
168 }
169 
170 void
172 {
173  NS_LOG_FUNCTION (this);
174  WifiMacHeader hdr;
175  hdr.SetProbeReq ();
177  hdr.SetAddr2 (GetAddress ());
179  hdr.SetDsNotFrom ();
180  hdr.SetDsNotTo ();
181  Ptr<Packet> packet = Create<Packet> ();
182  MgtProbeRequestHeader probe;
183  probe.SetSsid (GetSsid ());
184  probe.SetSupportedRates (GetSupportedRates ());
186  {
187  probe.SetHtCapabilities (GetHtCapabilities ());
188  hdr.SetNoOrder ();
189  }
190  if (m_vhtSupported)
191  {
192  probe.SetVhtCapabilities (GetVhtCapabilities ());
193  }
194  packet->AddHeader (probe);
195 
196  //The standard is not clear on the correct queue for management
197  //frames if we are a QoS AP. The approach taken here is to always
198  //use the DCF for these regardless of whether we have a QoS
199  //association or not.
200  m_dca->Queue (packet, hdr);
201 
203  {
205  }
208 }
209 
210 void
212 {
213  NS_LOG_FUNCTION (this << GetBssid ());
214  WifiMacHeader hdr;
215  hdr.SetAssocReq ();
216  hdr.SetAddr1 (GetBssid ());
217  hdr.SetAddr2 (GetAddress ());
218  hdr.SetAddr3 (GetBssid ());
219  hdr.SetDsNotFrom ();
220  hdr.SetDsNotTo ();
221  Ptr<Packet> packet = Create<Packet> ();
222  MgtAssocRequestHeader assoc;
223  assoc.SetSsid (GetSsid ());
224  assoc.SetSupportedRates (GetSupportedRates ());
226  {
227  assoc.SetHtCapabilities (GetHtCapabilities ());
228  hdr.SetNoOrder ();
229  }
230  if (m_vhtSupported)
231  {
232  assoc.SetVhtCapabilities (GetVhtCapabilities ());
233  }
234  packet->AddHeader (assoc);
235 
236  //The standard is not clear on the correct queue for management
237  //frames if we are a QoS AP. The approach taken here is to always
238  //use the DCF for these regardless of whether we have a QoS
239  //association or not.
240  m_dca->Queue (packet, hdr);
241 
243  {
245  }
248 }
249 
250 void
252 {
253  NS_LOG_FUNCTION (this);
254  switch (m_state)
255  {
256  case ASSOCIATED:
257  return;
258  break;
259  case WAIT_PROBE_RESP:
260  /* we have sent a probe request earlier so we
261  do not need to re-send a probe request immediately.
262  We just need to wait until probe-request-timeout
263  or until we get a probe response
264  */
265  break;
266  case BEACON_MISSED:
267  /* we were associated but we missed a bunch of beacons
268  * so we should assume we are not associated anymore.
269  * We try to initiate a probe request now.
270  */
271  m_linkDown ();
272  if (m_activeProbing)
273  {
275  SendProbeRequest ();
276  }
277  break;
278  case WAIT_ASSOC_RESP:
279  /* we have sent an assoc request so we do not need to
280  re-send an assoc request right now. We just need to
281  wait until either assoc-request-timeout or until
282  we get an assoc response.
283  */
284  break;
285  case REFUSED:
286  /* we have sent an assoc request and received a negative
287  assoc resp. We wait until someone restarts an
288  association with a given ssid.
289  */
290  break;
291  }
292 }
293 
294 void
296 {
297  NS_LOG_FUNCTION (this);
300 }
301 
302 void
304 {
305  NS_LOG_FUNCTION (this);
307  SendProbeRequest ();
308 }
309 
310 void
312 {
313  NS_LOG_FUNCTION (this);
315  {
317  {
319  }
322  return;
323  }
324  NS_LOG_DEBUG ("beacon missed");
327 }
328 
329 void
331 {
332  NS_LOG_FUNCTION (this << delay);
333  m_beaconWatchdogEnd = std::max (Simulator::Now () + delay, m_beaconWatchdogEnd);
336  {
337  NS_LOG_DEBUG ("really restart watchdog.");
339  }
340 }
341 
342 bool
344 {
345  return m_state == ASSOCIATED;
346 }
347 
348 bool
350 {
351  return m_state == WAIT_ASSOC_RESP;
352 }
353 
354 void
356 {
357  NS_LOG_FUNCTION (this << packet << to);
358  if (!IsAssociated ())
359  {
360  NotifyTxDrop (packet);
362  return;
363  }
364  WifiMacHeader hdr;
365 
366  //If we are not a QoS AP then we definitely want to use AC_BE to
367  //transmit the packet. A TID of zero will map to AC_BE (through \c
368  //QosUtilsMapTidToAc()), so we use that as our default here.
369  uint8_t tid = 0;
370 
371  //For now, an AP that supports QoS does not support non-QoS
372  //associations, and vice versa. In future the AP model should
373  //support simultaneously associated QoS and non-QoS STAs, at which
374  //point there will need to be per-association QoS state maintained
375  //by the association state machine, and consulted here.
376  if (m_qosSupported)
377  {
380  hdr.SetQosNoEosp ();
381  hdr.SetQosNoAmsdu ();
382  //Transmission of multiple frames in the same TXOP is not
383  //supported for now
384  hdr.SetQosTxopLimit (0);
385 
386  //Fill in the QoS control field in the MAC header
387  tid = QosUtilsGetTidForPacket (packet);
388  //Any value greater than 7 is invalid and likely indicates that
389  //the packet had no QoS tag, so we revert to zero, which'll
390  //mean that AC_BE is used.
391  if (tid > 7)
392  {
393  tid = 0;
394  }
395  hdr.SetQosTid (tid);
396  }
397  else
398  {
399  hdr.SetTypeData ();
400  }
402  {
403  hdr.SetNoOrder ();
404  }
405 
406  hdr.SetAddr1 (GetBssid ());
407  hdr.SetAddr2 (m_low->GetAddress ());
408  hdr.SetAddr3 (to);
409  hdr.SetDsNotFrom ();
410  hdr.SetDsTo ();
411 
412  if (m_qosSupported)
413  {
414  //Sanity check that the TID is valid
415  NS_ASSERT (tid < 8);
416  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
417  }
418  else
419  {
420  m_dca->Queue (packet, hdr);
421  }
422 }
423 
424 void
426 {
427  NS_LOG_FUNCTION (this << packet << hdr);
428  NS_ASSERT (!hdr->IsCtl ());
429  if (hdr->GetAddr3 () == GetAddress ())
430  {
431  NS_LOG_LOGIC ("packet sent by us.");
432  return;
433  }
434  else if (hdr->GetAddr1 () != GetAddress ()
435  && !hdr->GetAddr1 ().IsGroup ())
436  {
437  NS_LOG_LOGIC ("packet is not for us");
438  NotifyRxDrop (packet);
439  return;
440  }
441  else if (hdr->IsData ())
442  {
443  if (!IsAssociated ())
444  {
445  NS_LOG_LOGIC ("Received data frame while not associated: ignore");
446  NotifyRxDrop (packet);
447  return;
448  }
449  if (!(hdr->IsFromDs () && !hdr->IsToDs ()))
450  {
451  NS_LOG_LOGIC ("Received data frame not from the DS: ignore");
452  NotifyRxDrop (packet);
453  return;
454  }
455  if (hdr->GetAddr2 () != GetBssid ())
456  {
457  NS_LOG_LOGIC ("Received data frame not from the BSS we are associated with: ignore");
458  NotifyRxDrop (packet);
459  return;
460  }
461  if (hdr->IsQosData ())
462  {
463  if (hdr->IsQosAmsdu ())
464  {
465  NS_ASSERT (hdr->GetAddr3 () == GetBssid ());
466  DeaggregateAmsduAndForward (packet, hdr);
467  packet = 0;
468  }
469  else
470  {
471  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
472  }
473  }
474  else
475  {
476  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
477  }
478  return;
479  }
480  else if (hdr->IsProbeReq ()
481  || hdr->IsAssocReq ())
482  {
483  //This is a frame aimed at an AP, so we can safely ignore it.
484  NotifyRxDrop (packet);
485  return;
486  }
487  else if (hdr->IsBeacon ())
488  {
489  MgtBeaconHeader beacon;
490  packet->RemoveHeader (beacon);
491  bool goodBeacon = false;
492  if (GetSsid ().IsBroadcast ()
493  || beacon.GetSsid ().IsEqual (GetSsid ()))
494  {
495  goodBeacon = true;
496  }
497  SupportedRates rates = beacon.GetSupportedRates ();
498  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
499  {
500  uint32_t selector = m_phy->GetBssMembershipSelector (i);
501  if (!rates.IsSupportedRate (selector))
502  {
503  goodBeacon = false;
504  }
505  }
506  if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ())
507  {
508  goodBeacon = false;
509  }
510  if (goodBeacon)
511  {
513  RestartBeaconWatchdog (delay);
514  SetBssid (hdr->GetAddr3 ());
515  }
516  if (goodBeacon && m_state == BEACON_MISSED)
517  {
520  }
521  return;
522  }
523  else if (hdr->IsProbeResp ())
524  {
525  if (m_state == WAIT_PROBE_RESP)
526  {
527  MgtProbeResponseHeader probeResp;
528  packet->RemoveHeader (probeResp);
529  if (!probeResp.GetSsid ().IsEqual (GetSsid ()))
530  {
531  //not a probe resp for our ssid.
532  return;
533  }
534  SupportedRates rates = probeResp.GetSupportedRates ();
535  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
536  {
537  uint32_t selector = m_phy->GetBssMembershipSelector (i);
538  if (!rates.IsSupportedRate (selector))
539  {
540  return;
541  }
542  }
543  SetBssid (hdr->GetAddr3 ());
544  Time delay = MicroSeconds (probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons);
545  RestartBeaconWatchdog (delay);
547  {
549  }
552  }
553  return;
554  }
555  else if (hdr->IsAssocResp ())
556  {
557  if (m_state == WAIT_ASSOC_RESP)
558  {
559  MgtAssocResponseHeader assocResp;
560  packet->RemoveHeader (assocResp);
562  {
564  }
565  if (assocResp.GetStatusCode ().IsSuccess ())
566  {
568  NS_LOG_DEBUG ("assoc completed");
569  SupportedRates rates = assocResp.GetSupportedRates ();
570  if (m_htSupported)
571  {
572  HtCapabilities htcapabilities = assocResp.GetHtCapabilities ();
573  m_stationManager->AddStationHtCapabilities (hdr->GetAddr2 (),htcapabilities);
574  }
575  if (m_vhtSupported)
576  {
577  VhtCapabilities vhtcapabilities = assocResp.GetVhtCapabilities ();
578  m_stationManager->AddStationVhtCapabilities (hdr->GetAddr2 (), vhtcapabilities);
579  }
580 
581  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
582  {
583  WifiMode mode = m_phy->GetMode (i);
584  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1)))
585  {
586  m_stationManager->AddSupportedMode (hdr->GetAddr2 (), mode);
587  if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1)))
588  {
590  }
591  }
592  }
593  if (m_htSupported)
594  {
595  HtCapabilities htcapabilities = assocResp.GetHtCapabilities ();
596  for (uint32_t i = 0; i < m_phy->GetNMcs (); i++)
597  {
598  WifiMode mcs = m_phy->GetMcs (i);
599  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
600  {
601  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
602  //here should add a control to add basic MCS when it is implemented
603  }
604  }
605  }
606  if (m_vhtSupported)
607  {
608  VhtCapabilities vhtcapabilities = assocResp.GetVhtCapabilities ();
609  for (uint32_t i = 0; i < m_phy->GetNMcs (); i++)
610  {
611  WifiMode mcs = m_phy->GetMcs (i);
612  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
613  {
614  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
615  //here should add a control to add basic MCS when it is implemented
616  }
617  }
618  }
619  if (!m_linkUp.IsNull ())
620  {
621  m_linkUp ();
622  }
623  }
624  else
625  {
626  NS_LOG_DEBUG ("assoc refused");
627  SetState (REFUSED);
628  }
629  }
630  return;
631  }
632 
633  //Invoke the receive handler of our parent class to deal with any
634  //other frames. Specifically, this will handle Block Ack-related
635  //Management Action frames.
636  RegularWifiMac::Receive (packet, hdr);
637 }
638 
641 {
642  SupportedRates rates;
644  {
645  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
646  {
648  }
649  }
650  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
651  {
652  WifiMode mode = m_phy->GetMode (i);
653  rates.AddSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1));
654  }
655  return rates;
656 }
657 
660 {
661  HtCapabilities capabilities;
662  capabilities.SetHtSupported (1);
663  if (m_htSupported)
664  {
665  capabilities.SetLdpc (m_phy->GetLdpc ());
666  capabilities.SetSupportedChannelWidth (m_phy->GetChannelWidth () == 40);
668  capabilities.SetShortGuardInterval40 (m_phy->GetChannelWidth () == 40 && m_phy->GetGuardInterval ());
669  capabilities.SetGreenfield (m_phy->GetGreenfield ());
670  capabilities.SetMaxAmsduLength (1); //hardcoded for now (TBD)
671  capabilities.SetLSigProtectionSupport (!m_phy->GetGreenfield ());
672  capabilities.SetMaxAmpduLength (3); //hardcoded for now (TBD)
673  uint64_t maxSupportedRate = 0; //in bit/s
674  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
675  {
676  WifiMode mcs = m_phy->GetMcs (i);
677  capabilities.SetRxMcsBitmask (mcs.GetMcsValue ());
678  if (mcs.GetDataRate (m_phy->GetGuardInterval (), m_phy->GetGuardInterval (), 1) > maxSupportedRate)
679  {
680  maxSupportedRate = mcs.GetDataRate (m_phy->GetGuardInterval (), m_phy->GetGuardInterval (), 1);
681  }
682  }
683  capabilities.SetRxHighestSupportedDataRate (maxSupportedRate / 1e6); //in Mbit/s
684  capabilities.SetTxMcsSetDefined (m_phy->GetNMcs () > 0);
686  }
687  return capabilities;
688 }
689 
692 {
693  VhtCapabilities capabilities;
694  capabilities.SetVhtSupported (1);
695  if (m_vhtSupported)
696  {
697  if (m_phy->GetChannelWidth () == 160)
698  {
699  capabilities.SetSupportedChannelWidthSet (1);
700  }
701  else
702  {
703  capabilities.SetSupportedChannelWidthSet (0);
704  }
705  capabilities.SetMaxMpduLength (2); //hardcoded for now (TBD)
706  capabilities.SetRxLdpc (m_phy->GetLdpc ());
709  capabilities.SetMaxAmpduLengthExponent (7); //hardcoded for now (TBD)
710  uint8_t maxMcs = 0;
711  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
712  {
713  WifiMode mcs = m_phy->GetMcs (i);
714  if (mcs.GetMcsValue () > maxMcs)
715  {
716  maxMcs = mcs.GetMcsValue ();
717  }
718  }
719  capabilities.SetRxMcsMap (maxMcs, 1); //Only 1 SS is currently supported
720  capabilities.SetTxMcsMap (maxMcs, 1); //Only 1 SS is currently supported
721  }
722  return capabilities;
723 }
724 
725 void
727 {
728  if (value == ASSOCIATED
729  && m_state != ASSOCIATED)
730  {
731  m_assocLogger (GetBssid ());
732  }
733  else if (value != ASSOCIATED
734  && m_state == ASSOCIATED)
735  {
737  }
738  m_state = value;
739 }
740 
741 } //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:266
virtual uint32_t GetNumberOfTransmitAntennas(void) const =0
void SetTxMcsSetDefined(uint8_t txmcssetdefined)
TracedCallback< Mac48Address > m_deAssocLogger
Definition: sta-wifi-mac.h:197
void SetShortGuardIntervalFor80Mhz(uint8_t shortguardinterval)
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:188
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
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:43
#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.
AttributeValue implementation for Boolean.
Definition: boolean.h:34
void SendAssociationRequest(void)
Forward an association request packet to the DCF.
void SetGreenfield(uint8_t greenfield)
Ssid GetSsid(void) const
Return the Service Set Identifier (SSID).
Definition: mgt-headers.cc:171
#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.
void SetTxMcsMap(uint16_t map)
void SetHtSupported(uint8_t htsupported)
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 SetRxMcsBitmask(uint8_t index)
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:187
void SetProbeRequestTimeout(Time timeout)
void SetMaxMpduLength(uint8_t length)
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:375
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.
#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:349
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:283
virtual bool GetLdpc(void) const =0
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:528
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:196
EventId m_assocRequestEvent
Definition: sta-wifi-mac.h:190
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
VHT PHY (Clause 22)
Definition: wifi-mode.h:62
void SetVhtSupported(uint8_t vhtsupported)
Ptr< WifiPhy > m_phy
Wifi PHY.
void SetRxLdpc(uint8_t rxldpc)
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:97
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
bool IsProbeResp(void) const
Return true if the header is a Probe Response header.
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...
void SetShortGuardIntervalFor160Mhz(uint8_t shortguardinterval)
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...
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
virtual void SetBssid(Mac48Address bssid)
void SetLSigProtectionSupport(uint8_t lsigprotection)
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.
void SetShortGuardInterval20(uint8_t shortguardinterval)
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capability of the current AP.
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:89
Ptr< DcaTxop > m_dca
This holds a pointer to the DCF instance for this WifiMac - used for transmission of frames to non-Qo...
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:265
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.
void SetMaxAmsduLength(uint8_t maxamsdulength)
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:60
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:353
static Mac48Address GetBroadcast(void)
void SetMaxAmpduLength(uint8_t maxampdulength)
bool IsSupportedMcs(uint8_t mcs)
virtual bool GetGuardInterval(void) const =0
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:625
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:498
void SetBasicRate(uint32_t bs)
Set the given rate to basic rates.
void SetSupportedChannelWidthSet(uint8_t channelwidthset)
HtCapabilities GetHtCapabilities(void) const
Return the HT capability of the current AP.
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.
void SetRxHighestSupportedDataRate(uint16_t maxsupportedrate)
uint32_t m_maxMissedBeacons
Definition: sta-wifi-mac.h:193
void StartActiveAssociation(void)
Start an active association sequence immediately.
void SetMaxMissedBeacons(uint32_t missed)
EventId m_beaconWatchdog
Definition: sta-wifi-mac.h:191
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
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
static TypeId GetTypeId(void)
Definition: sta-wifi-mac.cc:65
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
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:100
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.
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
Implement the header for management frames of type probe request.
Definition: mgt-headers.h:218
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:138
virtual Mac48Address GetBssid(void) const
void SetRxMcsMap(uint16_t map)
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.
void SetLdpc(uint8_t ldpc)
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
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:186
void SetTxMaxNSpatialStreams(uint8_t maxtxspatialstreams)
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
Time m_beaconWatchdogEnd
Definition: sta-wifi-mac.h:192
EventId m_probeRequestEvent
Definition: sta-wifi-mac.h:189
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:297
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 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
void SetShortGuardInterval40(uint8_t shortguardinterval)
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:396
virtual bool GetGreenfield(void) const =0
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:255
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtcapabilities)
Records VHT capabilities of the remote station.
Implements the IEEE 802.11 MAC header.
void SetSupportedChannelWidth(uint8_t supportedchannelwidth)
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
StatusCode GetStatusCode(void)
Return the status code.
Definition: mgt-headers.cc:492
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:534
The Wifi MAC high model for a non-AP STA in a BSS.
Definition: sta-wifi-mac.h:41
void SetMaxAmpduLengthExponent(uint8_t exponent)