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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Author: Mirko Banchi <mk.banchi@gmail.com>
21  */
22 #include "sta-wifi-mac.h"
23 
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 
31 #include "qos-tag.h"
32 #include "mac-low.h"
33 #include "dcf-manager.h"
34 #include "mac-rx-middle.h"
35 #include "mac-tx-middle.h"
36 #include "wifi-mac-header.h"
37 #include "msdu-aggregator.h"
38 #include "amsdu-subframe-header.h"
39 #include "mgt-headers.h"
40 #include "ht-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", "If true, we send probe requests. If false, we don't. NOTE: if more than one STA in your simulation is using active probing, you should enable it at a different simulation time for each STA, otherwise all the STAs will start sending probes at the same time resulting in collisions. See bug 1060 for more info.",
86  BooleanValue (false),
89  .AddTraceSource ("Assoc", "Associated with an access point.",
91  "ns3::Mac48Address::TracedCallback")
92  .AddTraceSource ("DeAssoc", "Association with an access point lost.",
94  "ns3::Mac48Address::TracedCallback")
95  ;
96  return tid;
97 }
98 
100  : m_state (BEACON_MISSED),
101  m_probeRequestEvent (),
102  m_assocRequestEvent (),
103  m_beaconWatchdogEnd (Seconds (0.0))
104 {
105  NS_LOG_FUNCTION (this);
106 
107  // Let the lower layers know that we are acting as a non-AP STA in
108  // an infrastructure BSS.
110 }
111 
113 {
114  NS_LOG_FUNCTION (this);
115 }
116 
117 void
119 {
120  NS_LOG_FUNCTION (this << missed);
121  m_maxMissedBeacons = missed;
122 }
123 
124 void
126 {
127  NS_LOG_FUNCTION (this << timeout);
129 }
130 
131 void
133 {
134  NS_LOG_FUNCTION (this << timeout);
136 }
137 
138 void
140 {
141  NS_LOG_FUNCTION (this);
143 }
144 
145 void
147 {
148  NS_LOG_FUNCTION (this << enable);
149  if (enable)
150  {
152  }
153  else
154  {
156  }
157  m_activeProbing = enable;
158 }
159 
161 {
162  return m_activeProbing;
163 }
164 
165 void
167 {
168  NS_LOG_FUNCTION (this);
169  WifiMacHeader hdr;
170  hdr.SetProbeReq ();
172  hdr.SetAddr2 (GetAddress ());
174  hdr.SetDsNotFrom ();
175  hdr.SetDsNotTo ();
176  Ptr<Packet> packet = Create<Packet> ();
177  MgtProbeRequestHeader probe;
178  probe.SetSsid (GetSsid ());
179  probe.SetSupportedRates (GetSupportedRates ());
180  if (m_htSupported)
181  {
182  probe.SetHtCapabilities (GetHtCapabilities());
183  hdr.SetNoOrder();
184  }
185 
186  packet->AddHeader (probe);
187 
188  // The standard is not clear on the correct queue for management
189  // frames if we are a QoS AP. The approach taken here is to always
190  // use the DCF for these regardless of whether we have a QoS
191  // association or not.
192  m_dca->Queue (packet, hdr);
193 
195  {
197  }
200 }
201 
202 void
204 {
205  NS_LOG_FUNCTION (this << GetBssid ());
206  WifiMacHeader hdr;
207  hdr.SetAssocReq ();
208  hdr.SetAddr1 (GetBssid ());
209  hdr.SetAddr2 (GetAddress ());
210  hdr.SetAddr3 (GetBssid ());
211  hdr.SetDsNotFrom ();
212  hdr.SetDsNotTo ();
213  Ptr<Packet> packet = Create<Packet> ();
214  MgtAssocRequestHeader assoc;
215  assoc.SetSsid (GetSsid ());
216  assoc.SetSupportedRates (GetSupportedRates ());
217  if (m_htSupported)
218  {
219  assoc.SetHtCapabilities (GetHtCapabilities());
220  hdr.SetNoOrder();
221  }
222 
223  packet->AddHeader (assoc);
224 
225  // The standard is not clear on the correct queue for management
226  // frames if we are a QoS AP. The approach taken here is to always
227  // use the DCF for these regardless of whether we have a QoS
228  // association or not.
229  m_dca->Queue (packet, hdr);
230 
232  {
234  }
237 }
238 
239 void
241 {
242  NS_LOG_FUNCTION (this);
243  switch (m_state)
244  {
245  case ASSOCIATED:
246  return;
247  break;
248  case WAIT_PROBE_RESP:
249  /* we have sent a probe request earlier so we
250  do not need to re-send a probe request immediately.
251  We just need to wait until probe-request-timeout
252  or until we get a probe response
253  */
254  break;
255  case BEACON_MISSED:
256  /* we were associated but we missed a bunch of beacons
257  * so we should assume we are not associated anymore.
258  * We try to initiate a probe request now.
259  */
260  m_linkDown ();
261  if (m_activeProbing)
262  {
264  SendProbeRequest ();
265  }
266  break;
267  case WAIT_ASSOC_RESP:
268  /* we have sent an assoc request so we do not need to
269  re-send an assoc request right now. We just need to
270  wait until either assoc-request-timeout or until
271  we get an assoc response.
272  */
273  break;
274  case REFUSED:
275  /* we have sent an assoc request and received a negative
276  assoc resp. We wait until someone restarts an
277  association with a given ssid.
278  */
279  break;
280  }
281 }
282 
283 void
285 {
286  NS_LOG_FUNCTION (this);
289 }
290 
291 void
293 {
294  NS_LOG_FUNCTION (this);
296  SendProbeRequest ();
297 }
298 
299 void
301 {
302  NS_LOG_FUNCTION (this);
304  {
306  {
308  }
311  return;
312  }
313  NS_LOG_DEBUG ("beacon missed");
316 }
317 
318 void
320 {
321  NS_LOG_FUNCTION (this << delay);
322  m_beaconWatchdogEnd = std::max (Simulator::Now () + delay, m_beaconWatchdogEnd);
325  {
326  NS_LOG_DEBUG ("really restart watchdog.");
328  }
329 }
330 
331 bool
333 {
334  return m_state == ASSOCIATED;
335 }
336 
337 bool
339 {
340  return m_state == WAIT_ASSOC_RESP;
341 }
342 
343 void
345 {
346  NS_LOG_FUNCTION (this << packet << to);
347  if (!IsAssociated ())
348  {
349  NotifyTxDrop (packet);
351  return;
352  }
353  WifiMacHeader hdr;
354 
355  // If we are not a QoS AP then we definitely want to use AC_BE to
356  // transmit the packet. A TID of zero will map to AC_BE (through \c
357  // QosUtilsMapTidToAc()), so we use that as our default here.
358  uint8_t tid = 0;
359 
360  // For now, an AP that supports QoS does not support non-QoS
361  // associations, and vice versa. In future the AP model should
362  // support simultaneously associated QoS and non-QoS STAs, at which
363  // point there will need to be per-association QoS state maintained
364  // by the association state machine, and consulted here.
365  if (m_qosSupported)
366  {
369  hdr.SetQosNoEosp ();
370  hdr.SetQosNoAmsdu ();
371  // Transmission of multiple frames in the same TXOP is not
372  // supported for now
373  hdr.SetQosTxopLimit (0);
374 
375  // Fill in the QoS control field in the MAC header
376  tid = QosUtilsGetTidForPacket (packet);
377  // Any value greater than 7 is invalid and likely indicates that
378  // the packet had no QoS tag, so we revert to zero, which'll
379  // mean that AC_BE is used.
380  if (tid >= 7)
381  {
382  tid = 0;
383  }
384  hdr.SetQosTid (tid);
385  }
386  else
387  {
388  hdr.SetTypeData ();
389  }
390 if (m_htSupported)
391  {
392  hdr.SetNoOrder();
393  }
394 
395  hdr.SetAddr1 (GetBssid ());
396  hdr.SetAddr2 (m_low->GetAddress ());
397  hdr.SetAddr3 (to);
398  hdr.SetDsNotFrom ();
399  hdr.SetDsTo ();
400 
401  if (m_qosSupported)
402  {
403  // Sanity check that the TID is valid
404  NS_ASSERT (tid < 8);
405  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
406  }
407  else
408  {
409  m_dca->Queue (packet, hdr);
410  }
411 }
412 
413 void
415 {
416  NS_LOG_FUNCTION (this << packet << hdr);
417  NS_ASSERT (!hdr->IsCtl ());
418  if (hdr->GetAddr3 () == GetAddress ())
419  {
420  NS_LOG_LOGIC ("packet sent by us.");
421  return;
422  }
423  else if (hdr->GetAddr1 () != GetAddress ()
424  && !hdr->GetAddr1 ().IsGroup ())
425  {
426  NS_LOG_LOGIC ("packet is not for us");
427  NotifyRxDrop (packet);
428  return;
429  }
430  else if (hdr->IsData ())
431  {
432  if (!IsAssociated ())
433  {
434  NS_LOG_LOGIC ("Received data frame while not associated: ignore");
435  NotifyRxDrop (packet);
436  return;
437  }
438  if (!(hdr->IsFromDs () && !hdr->IsToDs ()))
439  {
440  NS_LOG_LOGIC ("Received data frame not from the DS: ignore");
441  NotifyRxDrop (packet);
442  return;
443  }
444  if (hdr->GetAddr2 () != GetBssid ())
445  {
446  NS_LOG_LOGIC ("Received data frame not from the BSS we are associated with: ignore");
447  NotifyRxDrop (packet);
448  return;
449  }
450 
451  if (hdr->IsQosData ())
452  {
453  if (hdr->IsQosAmsdu ())
454  {
455  NS_ASSERT (hdr->GetAddr3 () == GetBssid ());
456  DeaggregateAmsduAndForward (packet, hdr);
457  packet = 0;
458  }
459  else
460  {
461  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
462  }
463  }
464  else
465  {
466  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
467  }
468  return;
469  }
470  else if (hdr->IsProbeReq ()
471  || hdr->IsAssocReq ())
472  {
473  // This is a frame aimed at an AP, so we can safely ignore it.
474  NotifyRxDrop (packet);
475  return;
476  }
477  else if (hdr->IsBeacon ())
478  {
479  MgtBeaconHeader beacon;
480  packet->RemoveHeader (beacon);
481  bool goodBeacon = false;
482  if (GetSsid ().IsBroadcast ()
483  || beacon.GetSsid ().IsEqual (GetSsid ()))
484  {
485  goodBeacon = true;
486  }
487  SupportedRates rates = beacon.GetSupportedRates ();
488  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
489  {
490  uint32_t selector = m_phy->GetBssMembershipSelector (i);
491  if (!rates.IsSupportedRate (selector))
492  {
493  goodBeacon = false;
494  }
495  }
496  if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ())
497  {
498  goodBeacon = false;
499  }
500  if (goodBeacon)
501  {
503  RestartBeaconWatchdog (delay);
504  SetBssid (hdr->GetAddr3 ());
505  }
506  if (goodBeacon && m_state == BEACON_MISSED)
507  {
510  }
511  return;
512  }
513  else if (hdr->IsProbeResp ())
514  {
515  if (m_state == WAIT_PROBE_RESP)
516  {
517  MgtProbeResponseHeader probeResp;
518  packet->RemoveHeader (probeResp);
519  if (!probeResp.GetSsid ().IsEqual (GetSsid ()))
520  {
521  //not a probe resp for our ssid.
522  return;
523  }
524  SupportedRates rates = probeResp.GetSupportedRates ();
525  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
526  {
527  uint32_t selector = m_phy->GetBssMembershipSelector (i);
528  if (!rates.IsSupportedRate (selector))
529  {
530  return;
531  }
532  }
533  SetBssid (hdr->GetAddr3 ());
534  Time delay = MicroSeconds (probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons);
535  RestartBeaconWatchdog (delay);
537  {
539  }
542  }
543  return;
544  }
545  else if (hdr->IsAssocResp ())
546  {
547  if (m_state == WAIT_ASSOC_RESP)
548  {
549  MgtAssocResponseHeader assocResp;
550  packet->RemoveHeader (assocResp);
552  {
554  }
555  if (assocResp.GetStatusCode ().IsSuccess ())
556  {
558  NS_LOG_DEBUG ("assoc completed");
559  SupportedRates rates = assocResp.GetSupportedRates ();
560  if (m_htSupported)
561  {
562  HtCapabilities htcapabilities = assocResp.GetHtCapabilities ();
563  m_stationManager->AddStationHtCapabilities (hdr->GetAddr2 (),htcapabilities);
564  }
565 
566  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
567  {
568  WifiMode mode = m_phy->GetMode (i);
569  if (rates.IsSupportedRate (mode.GetDataRate ()))
570  {
571  m_stationManager->AddSupportedMode (hdr->GetAddr2 (), mode);
572  if (rates.IsBasicRate (mode.GetDataRate ()))
573  {
575  }
576  }
577  }
578  if(m_htSupported)
579  {
580  HtCapabilities htcapabilities = assocResp.GetHtCapabilities ();
581  for (uint32_t i = 0; i < m_phy->GetNMcs(); i++)
582  {
583  uint8_t mcs=m_phy->GetMcs(i);
584  if (htcapabilities.IsSupportedMcs (mcs))
585  {
586  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
587  //here should add a control to add basic MCS when it is implemented
588  }
589  }
590  }
591  if (!m_linkUp.IsNull ())
592  {
593  m_linkUp ();
594  }
595  }
596  else
597  {
598  NS_LOG_DEBUG ("assoc refused");
599  SetState (REFUSED);
600  }
601  }
602  return;
603  }
604 
605  // Invoke the receive handler of our parent class to deal with any
606  // other frames. Specifically, this will handle Block Ack-related
607  // Management Action frames.
608  RegularWifiMac::Receive (packet, hdr);
609 }
610 
613 {
614  SupportedRates rates;
615  if(m_htSupported)
616  {
617  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors(); i++)
618  {
620  }
621  }
622  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
623  {
624  WifiMode mode = m_phy->GetMode (i);
625  rates.AddSupportedRate (mode.GetDataRate ());
626  }
627  return rates;
628 }
631 {
632  HtCapabilities capabilities;
633  capabilities.SetHtSupported(1);
634  capabilities.SetLdpc (m_phy->GetLdpc());
636  capabilities.SetGreenfield (m_phy->GetGreenfield());
637 for (uint8_t i =0 ; i < m_phy->GetNMcs();i++)
638  {
639  capabilities.SetRxMcsBitmask(m_phy->GetMcs(i));
640  }
641  return capabilities;
642 }
643 void
645 {
646  if (value == ASSOCIATED
647  && m_state != ASSOCIATED)
648  {
649  m_assocLogger (GetBssid ());
650  }
651  else if (value != ASSOCIATED
652  && m_state == ASSOCIATED)
653  {
655  }
656  m_state = value;
657 }
658 
659 } // 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
TracedCallback< Mac48Address > m_deAssocLogger
Definition: sta-wifi-mac.h:193
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
Time m_assocRequestTimeout
Definition: sta-wifi-mac.h:184
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:150
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:40
#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:140
#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 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:145
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:183
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.
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:1078
#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:271
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:275
virtual bool GetLdpc(void) const =0
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:65
virtual uint8_t GetMcs(uint8_t mcs) const =0
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
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:192
EventId m_assocRequestEvent
Definition: sta-wifi-mac.h:186
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
Ptr< WifiPhy > m_phy
Wifi PHY.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:819
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:69
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:93
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...
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a qos tag is attached to the packet, returns a value < 8.
Definition: qos-utils.cc:60
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 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.
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...
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)
AttributeValue implementation for Time.
Definition: nstime.h:928
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...
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:257
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 AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
Records HT capabilities of the remote station.
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Definition: qos-utils.cc:27
static Mac48Address GetBroadcast(void)
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:599
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:389
void SetBasicRate(uint32_t bs)
Set the given rate to basic rates.
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.
uint32_t m_maxMissedBeacons
Definition: sta-wifi-mac.h:189
void StartActiveAssociation(void)
Start an active association sequence immediately.
void SetMaxMissedBeacons(uint32_t missed)
EventId m_beaconWatchdog
Definition: sta-wifi-mac.h:187
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
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:980
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:929
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:180
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:116
virtual Mac48Address GetBssid(void) const
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
void AddSupportedMcs(Mac48Address address, uint8_t mcs)
Record the MCS index supported by the station.
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:866
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:42
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:882
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:39
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:182
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
Time m_beaconWatchdogEnd
Definition: sta-wifi-mac.h:188
EventId m_probeRequestEvent
Definition: sta-wifi-mac.h:185
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:239
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
a unique identifier for an interface.
Definition: type-id.h:57
uint64_t GetDataRate(void) const
Definition: wifi-mode.cc:79
TypeId SetParent(TypeId tid)
Definition: type-id.cc:638
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:321
virtual bool GetGreenfield(void) const =0
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:253
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:384
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:410
The Wifi MAC high model for a non-AP STA in a BSS.
Definition: sta-wifi-mac.h:43