A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("StaWifiMac");
43 
44 
45 /*
46  * The state machine for this STA is:
47  -------------- -----------
48  | Associated | <-------------------- -------> | Refused |
49  -------------- \ / -----------
50  \ \ /
51  \ ----------------- -----------------------------
52  \-> | Beacon Missed | --> | Wait Association Response |
53  ----------------- -----------------------------
54  \ ^
55  \ |
56  \ -----------------------
57  \-> | Wait Probe Response |
58  -----------------------
59  */
60 
61 namespace ns3 {
62 
63 NS_OBJECT_ENSURE_REGISTERED (StaWifiMac)
64  ;
65 
66 TypeId
68 {
69  static TypeId tid = TypeId ("ns3::StaWifiMac")
71  .AddConstructor<StaWifiMac> ()
72  .AddAttribute ("ProbeRequestTimeout", "The interval between two consecutive probe request attempts.",
73  TimeValue (Seconds (0.05)),
74  MakeTimeAccessor (&StaWifiMac::m_probeRequestTimeout),
75  MakeTimeChecker ())
76  .AddAttribute ("AssocRequestTimeout", "The interval between two consecutive assoc request attempts.",
77  TimeValue (Seconds (0.5)),
78  MakeTimeAccessor (&StaWifiMac::m_assocRequestTimeout),
79  MakeTimeChecker ())
80  .AddAttribute ("MaxMissedBeacons",
81  "Number of beacons which much be consecutively missed before "
82  "we attempt to restart association.",
83  UintegerValue (10),
84  MakeUintegerAccessor (&StaWifiMac::m_maxMissedBeacons),
85  MakeUintegerChecker<uint32_t> ())
86  .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.",
87  BooleanValue (false),
88  MakeBooleanAccessor (&StaWifiMac::SetActiveProbing),
89  MakeBooleanChecker ())
90  .AddTraceSource ("Assoc", "Associated with an access point.",
92  .AddTraceSource ("DeAssoc", "Association with an access point lost.",
94  ;
95  return tid;
96 }
97 
99  : m_state (BEACON_MISSED),
100  m_probeRequestEvent (),
101  m_assocRequestEvent (),
102  m_beaconWatchdogEnd (Seconds (0.0))
103 {
104  NS_LOG_FUNCTION (this);
105 
106  // Let the lower layers know that we are acting as a non-AP STA in
107  // an infrastructure BSS.
109 }
110 
112 {
113  NS_LOG_FUNCTION (this);
114 }
115 
116 void
118 {
119  NS_LOG_FUNCTION (this << missed);
120  m_maxMissedBeacons = missed;
121 }
122 
123 void
125 {
126  NS_LOG_FUNCTION (this << timeout);
128 }
129 
130 void
132 {
133  NS_LOG_FUNCTION (this << timeout);
135 }
136 
137 void
139 {
140  NS_LOG_FUNCTION (this);
142 }
143 
144 void
146 {
147  NS_LOG_FUNCTION (this << enable);
148  if (enable)
149  {
151  }
152  else
153  {
155  }
156 }
157 
158 void
160 {
161  NS_LOG_FUNCTION (this);
162  WifiMacHeader hdr;
163  hdr.SetProbeReq ();
165  hdr.SetAddr2 (GetAddress ());
167  hdr.SetDsNotFrom ();
168  hdr.SetDsNotTo ();
169  Ptr<Packet> packet = Create<Packet> ();
170  MgtProbeRequestHeader probe;
171  probe.SetSsid (GetSsid ());
172  probe.SetSupportedRates (GetSupportedRates ());
173  if (m_htSupported)
174  {
175  probe.SetHtCapabilities (GetHtCapabilities());
176  hdr.SetNoOrder();
177  }
178 
179  packet->AddHeader (probe);
180 
181  // The standard is not clear on the correct queue for management
182  // frames if we are a QoS AP. The approach taken here is to always
183  // use the DCF for these regardless of whether we have a QoS
184  // association or not.
185  m_dca->Queue (packet, hdr);
186 
188  {
190  }
193 }
194 
195 void
197 {
198  NS_LOG_FUNCTION (this << GetBssid ());
199  WifiMacHeader hdr;
200  hdr.SetAssocReq ();
201  hdr.SetAddr1 (GetBssid ());
202  hdr.SetAddr2 (GetAddress ());
203  hdr.SetAddr3 (GetBssid ());
204  hdr.SetDsNotFrom ();
205  hdr.SetDsNotTo ();
206  Ptr<Packet> packet = Create<Packet> ();
207  MgtAssocRequestHeader assoc;
208  assoc.SetSsid (GetSsid ());
209  assoc.SetSupportedRates (GetSupportedRates ());
210  if (m_htSupported)
211  {
212  assoc.SetHtCapabilities (GetHtCapabilities());
213  hdr.SetNoOrder();
214  }
215 
216  packet->AddHeader (assoc);
217 
218  // The standard is not clear on the correct queue for management
219  // frames if we are a QoS AP. The approach taken here is to always
220  // use the DCF for these regardless of whether we have a QoS
221  // association or not.
222  m_dca->Queue (packet, hdr);
223 
225  {
227  }
230 }
231 
232 void
234 {
235  NS_LOG_FUNCTION (this);
236  switch (m_state)
237  {
238  case ASSOCIATED:
239  return;
240  break;
241  case WAIT_PROBE_RESP:
242  /* we have sent a probe request earlier so we
243  do not need to re-send a probe request immediately.
244  We just need to wait until probe-request-timeout
245  or until we get a probe response
246  */
247  break;
248  case BEACON_MISSED:
249  /* we were associated but we missed a bunch of beacons
250  * so we should assume we are not associated anymore.
251  * We try to initiate a probe request now.
252  */
253  m_linkDown ();
255  SendProbeRequest ();
256  break;
257  case WAIT_ASSOC_RESP:
258  /* we have sent an assoc request so we do not need to
259  re-send an assoc request right now. We just need to
260  wait until either assoc-request-timeout or until
261  we get an assoc response.
262  */
263  break;
264  case REFUSED:
265  /* we have sent an assoc request and received a negative
266  assoc resp. We wait until someone restarts an
267  association with a given ssid.
268  */
269  break;
270  }
271 }
272 
273 void
275 {
276  NS_LOG_FUNCTION (this);
279 }
280 
281 void
283 {
284  NS_LOG_FUNCTION (this);
286  SendProbeRequest ();
287 }
288 
289 void
291 {
292  NS_LOG_FUNCTION (this);
294  {
296  {
298  }
301  return;
302  }
303  NS_LOG_DEBUG ("beacon missed");
306 }
307 
308 void
310 {
311  NS_LOG_FUNCTION (this << delay);
312  m_beaconWatchdogEnd = std::max (Simulator::Now () + delay, m_beaconWatchdogEnd);
315  {
316  NS_LOG_DEBUG ("really restart watchdog.");
318  }
319 }
320 
321 bool
323 {
324  return m_state == ASSOCIATED;
325 }
326 
327 bool
329 {
330  return m_state == WAIT_ASSOC_RESP;
331 }
332 
333 void
335 {
336  NS_LOG_FUNCTION (this << packet << to);
337  if (!IsAssociated ())
338  {
339  NotifyTxDrop (packet);
341  return;
342  }
343  WifiMacHeader hdr;
344 
345  // If we are not a QoS AP then we definitely want to use AC_BE to
346  // transmit the packet. A TID of zero will map to AC_BE (through \c
347  // QosUtilsMapTidToAc()), so we use that as our default here.
348  uint8_t tid = 0;
349 
350  // For now, an AP that supports QoS does not support non-QoS
351  // associations, and vice versa. In future the AP model should
352  // support simultaneously associated QoS and non-QoS STAs, at which
353  // point there will need to be per-association QoS state maintained
354  // by the association state machine, and consulted here.
355  if (m_qosSupported)
356  {
359  hdr.SetQosNoEosp ();
360  hdr.SetQosNoAmsdu ();
361  // Transmission of multiple frames in the same TXOP is not
362  // supported for now
363  hdr.SetQosTxopLimit (0);
364 
365  // Fill in the QoS control field in the MAC header
366  tid = QosUtilsGetTidForPacket (packet);
367  // Any value greater than 7 is invalid and likely indicates that
368  // the packet had no QoS tag, so we revert to zero, which'll
369  // mean that AC_BE is used.
370  if (tid >= 7)
371  {
372  tid = 0;
373  }
374  hdr.SetQosTid (tid);
375  }
376  else
377  {
378  hdr.SetTypeData ();
379  }
380 if (m_htSupported)
381  {
382  hdr.SetNoOrder();
383  }
384 
385  hdr.SetAddr1 (GetBssid ());
386  hdr.SetAddr2 (m_low->GetAddress ());
387  hdr.SetAddr3 (to);
388  hdr.SetDsNotFrom ();
389  hdr.SetDsTo ();
390 
391  if (m_qosSupported)
392  {
393  // Sanity check that the TID is valid
394  NS_ASSERT (tid < 8);
395  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
396  }
397  else
398  {
399  m_dca->Queue (packet, hdr);
400  }
401 }
402 
403 void
405 {
406  NS_LOG_FUNCTION (this << packet << hdr);
407  NS_ASSERT (!hdr->IsCtl ());
408  if (hdr->GetAddr3 () == GetAddress ())
409  {
410  NS_LOG_LOGIC ("packet sent by us.");
411  return;
412  }
413  else if (hdr->GetAddr1 () != GetAddress ()
414  && !hdr->GetAddr1 ().IsGroup ())
415  {
416  NS_LOG_LOGIC ("packet is not for us");
417  NotifyRxDrop (packet);
418  return;
419  }
420  else if (hdr->IsData ())
421  {
422  if (!IsAssociated ())
423  {
424  NS_LOG_LOGIC ("Received data frame while not associated: ignore");
425  NotifyRxDrop (packet);
426  return;
427  }
428  if (!(hdr->IsFromDs () && !hdr->IsToDs ()))
429  {
430  NS_LOG_LOGIC ("Received data frame not from the DS: ignore");
431  NotifyRxDrop (packet);
432  return;
433  }
434  if (hdr->GetAddr2 () != GetBssid ())
435  {
436  NS_LOG_LOGIC ("Received data frame not from the BSS we are associated with: ignore");
437  NotifyRxDrop (packet);
438  return;
439  }
440 
441  if (hdr->IsQosData ())
442  {
443  if (hdr->IsQosAmsdu ())
444  {
445  NS_ASSERT (hdr->GetAddr3 () == GetBssid ());
446  DeaggregateAmsduAndForward (packet, hdr);
447  packet = 0;
448  }
449  else
450  {
451  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
452  }
453  }
454  else
455  {
456  ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
457  }
458  return;
459  }
460  else if (hdr->IsProbeReq ()
461  || hdr->IsAssocReq ())
462  {
463  // This is a frame aimed at an AP, so we can safely ignore it.
464  NotifyRxDrop (packet);
465  return;
466  }
467  else if (hdr->IsBeacon ())
468  {
469  MgtBeaconHeader beacon;
470  packet->RemoveHeader (beacon);
471  bool goodBeacon = false;
472  if (GetSsid ().IsBroadcast ()
473  || beacon.GetSsid ().IsEqual (GetSsid ()))
474  {
475  goodBeacon = true;
476  }
477  SupportedRates rates = beacon.GetSupportedRates ();
478  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
479  {
480  uint32_t selector = m_phy->GetBssMembershipSelector (i);
481  if (!rates.IsSupportedRate (selector))
482  {
483  goodBeacon = false;
484  }
485  }
486  if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ())
487  {
488  goodBeacon = false;
489  }
490  if (goodBeacon)
491  {
492  Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons);
493  RestartBeaconWatchdog (delay);
494  SetBssid (hdr->GetAddr3 ());
495  }
496  if (goodBeacon && m_state == BEACON_MISSED)
497  {
500  }
501  return;
502  }
503  else if (hdr->IsProbeResp ())
504  {
505  if (m_state == WAIT_PROBE_RESP)
506  {
507  MgtProbeResponseHeader probeResp;
508  packet->RemoveHeader (probeResp);
509  if (!probeResp.GetSsid ().IsEqual (GetSsid ()))
510  {
511  //not a probe resp for our ssid.
512  return;
513  }
514  SupportedRates rates = probeResp.GetSupportedRates ();
515  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
516  {
517  uint32_t selector = m_phy->GetBssMembershipSelector (i);
518  if (!rates.IsSupportedRate (selector))
519  {
520  return;
521  }
522  }
523  SetBssid (hdr->GetAddr3 ());
524  Time delay = MicroSeconds (probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons);
525  RestartBeaconWatchdog (delay);
527  {
529  }
532  }
533  return;
534  }
535  else if (hdr->IsAssocResp ())
536  {
537  if (m_state == WAIT_ASSOC_RESP)
538  {
539  MgtAssocResponseHeader assocResp;
540  packet->RemoveHeader (assocResp);
542  {
544  }
545  if (assocResp.GetStatusCode ().IsSuccess ())
546  {
548  NS_LOG_DEBUG ("assoc completed");
549  SupportedRates rates = assocResp.GetSupportedRates ();
550  if (m_htSupported)
551  {
552  HtCapabilities htcapabilities = assocResp.GetHtCapabilities ();
553  m_stationManager->AddStationHtCapabilities (hdr->GetAddr2 (),htcapabilities);
554  }
555 
556  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
557  {
558  WifiMode mode = m_phy->GetMode (i);
559  if (rates.IsSupportedRate (mode.GetDataRate ()))
560  {
561  m_stationManager->AddSupportedMode (hdr->GetAddr2 (), mode);
562  if (rates.IsBasicRate (mode.GetDataRate ()))
563  {
564  m_stationManager->AddBasicMode (mode);
565  }
566  }
567  }
568  if(m_htSupported)
569  {
570  HtCapabilities htcapabilities = assocResp.GetHtCapabilities ();
571  for (uint32_t i = 0; i < m_phy->GetNMcs(); i++)
572  {
573  uint8_t mcs=m_phy->GetMcs(i);
574  if (htcapabilities.IsSupportedMcs (mcs))
575  {
576  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
577  //here should add a control to add basic MCS when it is implemented
578  }
579  }
580  }
581  if (!m_linkUp.IsNull ())
582  {
583  m_linkUp ();
584  }
585  }
586  else
587  {
588  NS_LOG_DEBUG ("assoc refused");
589  SetState (REFUSED);
590  }
591  }
592  return;
593  }
594 
595  // Invoke the receive handler of our parent class to deal with any
596  // other frames. Specifically, this will handle Block Ack-related
597  // Management Action frames.
598  RegularWifiMac::Receive (packet, hdr);
599 }
600 
603 {
604  SupportedRates rates;
605  if(m_htSupported)
606  {
607  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors(); i++)
608  {
610  }
611  }
612  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
613  {
614  WifiMode mode = m_phy->GetMode (i);
615  rates.AddSupportedRate (mode.GetDataRate ());
616  }
617  return rates;
618 }
621 {
622  HtCapabilities capabilities;
623  capabilities.SetHtSupported(1);
624  capabilities.SetLdpc (m_phy->GetLdpc());
626  capabilities.SetGreenfield (m_phy->GetGreenfield());
627 for (uint8_t i =0 ; i < m_phy->GetNMcs();i++)
628  {
629  capabilities.SetRxMcsBitmask(m_phy->GetMcs(i));
630  }
631  return capabilities;
632 }
633 void
635 {
636  if (value == ASSOCIATED
637  && m_state != ASSOCIATED)
638  {
639  m_assocLogger (GetBssid ());
640  }
641  else if (value != ASSOCIATED
642  && m_state == ASSOCIATED)
643  {
645  }
646  m_state = value;
647 }
648 
649 } // namespace ns3
static Time GetDelayLeft(const EventId &id)
Definition: simulator.cc:189
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
NS_LOG_COMPONENT_DEFINE("StaWifiMac")
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...
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
Time m_assocRequestTimeout
Definition: sta-wifi-mac.h:184
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:151
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)
Definition: log.h:345
void SetQosAckPolicy(enum QosAckPolicy policy)
Set the QoS ACK policy in the QoS control field.
Hold a bool native type.
Definition: boolean.h:38
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:141
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:146
void SetRxMcsBitmask(uint8_t index)
void AssocRequestTimeout(void)
This method is called after the association timeout occurred.
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:1014
#define NS_ASSERT(condition)
Definition: assert.h:64
Callback< void > m_linkUp
Callback when a link is up.
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
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:272
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:270
virtual bool GetLdpc(void) const =0
bool IsRunning(void) const
This method is syntactic sugar for the ns3::Simulator::isExpired method.
Definition: event-id.cc:59
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:191
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:824
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:91
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
MacState
The current MAC state of the STA.
Definition: sta-wifi-mac.h:90
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)
hold objects of type ns3::Time
Definition: nstime.h:961
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
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:252
bool IsProbeReq(void) const
Return true if the header is a Probe Request header.
Hold an unsigned integer type.
Definition: uinteger.h:46
void MissedBeacons(void)
This method is called after we have not received a beacon from the AP.
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
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)
Definition: log.h:368
Ptr< MacLow > m_low
MacLow (RTS, CTS, DATA, ACK etc.)
SupportedRates GetSupportedRates(void)
Return the supported rates.
Definition: mgt-headers.cc:390
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
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 TraceSourceAccessor > MakeTraceSourceAccessor(T a)
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
static TypeId GetTypeId(void)
Definition: sta-wifi-mac.cc:67
an EUI-48 address
Definition: mac48-address.h:41
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:985
void TryToEnsureAssociated(void)
Try to ensure that we are associated with an AP by taking an appropriate action depending on the curr...
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
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.
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)
Definition: log.h:289
virtual Mac48Address GetAddress(void) const
void SetTypeData(void)
Set Type/Subtype values for a data packet with no subtype equal to 0.
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:47
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.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:452
void SetNoOrder(void)
Unset order bit in the frame control field.
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:40
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:53
a unique identifier for an interface.
Definition: type-id.h:49
uint64_t GetDataRate(void) const
Definition: wifi-mode.cc:79
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
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:385
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:411