A Discrete-Event Network Simulator
API
ap-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 "ap-wifi-mac.h"
23 
24 #include "ns3/assert.h"
25 #include "ns3/log.h"
26 #include "ns3/simulator.h"
27 #include "ns3/string.h"
28 #include "ns3/pointer.h"
29 #include "ns3/boolean.h"
30 
31 #include "qos-tag.h"
32 #include "wifi-phy.h"
33 #include "dcf-manager.h"
34 #include "mac-rx-middle.h"
35 #include "mac-tx-middle.h"
36 #include "mgt-headers.h"
37 #include "mac-low.h"
38 #include "amsdu-subframe-header.h"
39 #include "msdu-aggregator.h"
40 
41 namespace ns3 {
42 
43 NS_LOG_COMPONENT_DEFINE ("ApWifiMac");
44 
45 NS_OBJECT_ENSURE_REGISTERED (ApWifiMac);
46 
47 TypeId
49 {
50  static TypeId tid = TypeId ("ns3::ApWifiMac")
52  .SetGroupName ("Wifi")
53  .AddConstructor<ApWifiMac> ()
54  .AddAttribute ("BeaconInterval", "Delay between two beacons",
55  TimeValue (MicroSeconds (102400)),
58  MakeTimeChecker ())
59  .AddAttribute ("BeaconJitter", "A uniform random variable to cause the initial beacon starting time (after simulation time 0) to be distributed between 0 and the BeaconInterval.",
60  StringValue ("ns3::UniformRandomVariable"),
62  MakePointerChecker<UniformRandomVariable> ())
63  .AddAttribute ("EnableBeaconJitter", "If beacons are enabled, whether to jitter the initial send event.",
64  BooleanValue (false),
67  .AddAttribute ("BeaconGeneration", "Whether or not beacons are generated.",
68  BooleanValue (true),
72  ;
73  return tid;
74 }
75 
77 {
78  NS_LOG_FUNCTION (this);
79  m_beaconDca = CreateObject<DcaTxop> ();
80  m_beaconDca->SetAifsn (1);
81  m_beaconDca->SetMinCw (0);
82  m_beaconDca->SetMaxCw (0);
83  m_beaconDca->SetLow (m_low);
84  m_beaconDca->SetManager (m_dcfManager);
85  m_beaconDca->SetTxMiddle (m_txMiddle);
86 
87  // Let the lower layers know that we are acting as an AP.
89 
91 }
92 
94 {
95  NS_LOG_FUNCTION (this);
96 }
97 
98 void
100 {
101  NS_LOG_FUNCTION (this);
102  m_beaconDca = 0;
103  m_enableBeaconGeneration = false;
106 }
107 
108 void
110 {
111  NS_LOG_FUNCTION (this << address);
112  // As an AP, our MAC address is also the BSSID. Hence we are
113  // overriding this function and setting both in our parent class.
114  RegularWifiMac::SetAddress (address);
115  RegularWifiMac::SetBssid (address);
116 }
117 
118 void
120 {
121  NS_LOG_FUNCTION (this << enable);
122  if (!enable)
123  {
125  }
126  else if (enable && !m_enableBeaconGeneration)
127  {
129  }
130  m_enableBeaconGeneration = enable;
131 }
132 
133 bool
135 {
136  NS_LOG_FUNCTION (this);
138 }
139 
140 Time
142 {
143  NS_LOG_FUNCTION (this);
144  return m_beaconInterval;
145 }
146 
147 void
149 {
150  NS_LOG_FUNCTION (this << stationManager);
151  m_beaconDca->SetWifiRemoteStationManager (stationManager);
153 }
154 
155 void
157 {
158  NS_LOG_FUNCTION (this << &linkUp);
160 
161  // The approach taken here is that, from the point of view of an AP,
162  // the link is always up, so we immediately invoke the callback if
163  // one is set
164  linkUp ();
165 }
166 
167 void
169 {
170  NS_LOG_FUNCTION (this << interval);
171  if ((interval.GetMicroSeconds () % 1024) != 0)
172  {
173  NS_LOG_WARN ("beacon interval should be multiple of 1024us (802.11 time unit), see IEEE Std. 802.11-2012");
174  }
175  m_beaconInterval = interval;
176 }
177 
178 void
180 {
181  NS_LOG_FUNCTION (this);
182  SendOneBeacon ();
183 }
184 
185 int64_t
186 ApWifiMac::AssignStreams (int64_t stream)
187 {
188  NS_LOG_FUNCTION (this << stream);
189  m_beaconJitter->SetStream (stream);
190  return 1;
191 }
192 
193 void
195  Mac48Address to)
196 {
197  NS_LOG_FUNCTION (this << packet << from << to);
198  // If we are not a QoS AP then we definitely want to use AC_BE to
199  // transmit the packet. A TID of zero will map to AC_BE (through \c
200  // QosUtilsMapTidToAc()), so we use that as our default here.
201  uint8_t tid = 0;
202 
203  // If we are a QoS AP then we attempt to get a TID for this packet
204  if (m_qosSupported)
205  {
206  tid = QosUtilsGetTidForPacket (packet);
207  // Any value greater than 7 is invalid and likely indicates that
208  // the packet had no QoS tag, so we revert to zero, which'll
209  // mean that AC_BE is used.
210  if (tid >= 7)
211  {
212  tid = 0;
213  }
214  }
215 
216  ForwardDown (packet, from, to, tid);
217 }
218 
219 void
221  Mac48Address to, uint8_t tid)
222 {
223  NS_LOG_FUNCTION (this << packet << from << to << static_cast<uint32_t> (tid));
224  WifiMacHeader hdr;
225 
226  // For now, an AP that supports QoS does not support non-QoS
227  // associations, and vice versa. In future the AP model should
228  // support simultaneously associated QoS and non-QoS STAs, at which
229  // point there will need to be per-association QoS state maintained
230  // by the association state machine, and consulted here.
231  if (m_qosSupported)
232  {
235  hdr.SetQosNoEosp ();
236  hdr.SetQosNoAmsdu ();
237  // Transmission of multiple frames in the same TXOP is not
238  // supported for now
239  hdr.SetQosTxopLimit (0);
240  // Fill in the QoS control field in the MAC header
241  hdr.SetQosTid (tid);
242  }
243  else
244  {
245  hdr.SetTypeData ();
246  }
247 
248  if (m_htSupported)
249  hdr.SetNoOrder();
250  hdr.SetAddr1 (to);
251  hdr.SetAddr2 (GetAddress ());
252  hdr.SetAddr3 (from);
253  hdr.SetDsFrom ();
254  hdr.SetDsNotTo ();
255 
256  if (m_qosSupported)
257  {
258  // Sanity check that the TID is valid
259  NS_ASSERT (tid < 8);
260  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
261  }
262  else
263  {
264  m_dca->Queue (packet, hdr);
265  }
266 }
267 
268 void
270 {
271  NS_LOG_FUNCTION (this << packet << to << from);
272  if (to.IsBroadcast () || m_stationManager->IsAssociated (to))
273  {
274  ForwardDown (packet, from, to);
275  }
276 }
277 
278 void
280 {
281  NS_LOG_FUNCTION (this << packet << to);
282  // We're sending this packet with a from address that is our own. We
283  // get that address from the lower MAC and make use of the
284  // from-spoofing Enqueue() method to avoid duplicated code.
285  Enqueue (packet, to, m_low->GetAddress ());
286 }
287 
288 bool
290 {
291  NS_LOG_FUNCTION (this);
292  return true;
293 }
294 
297 {
298  NS_LOG_FUNCTION (this);
299  SupportedRates rates;
300  // If it is an HT-AP then add the BSSMembershipSelectorSet
301  // which only includes 127 for HT now. The standard says that the BSSMembershipSelectorSet
302  // must have its MSB set to 1 (must be treated as a Basic Rate)
303  // Also the standard mentioned that at leat 1 element should be included in the SupportedRates the rest can be in the ExtendedSupportedRates
304  if (m_htSupported)
305  {
306  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors(); i++)
307  {
309  }
310  }
311  // send the set of supported rates and make sure that we indicate
312  // the Basic Rate set in this set of supported rates.
313  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
314  {
315  WifiMode mode = m_phy->GetMode (i);
316  rates.AddSupportedRate (mode.GetDataRate ());
317  // add rates that are part of the BSSBasicRateSet (manufacturer dependent!)
318  // here we choose to add the mandatory rates to the BSSBasicRateSet,
319  // exept for 802.11b where we assume that only the two lowest mandatory rates are part of the BSSBasicRateSet
320  if (mode.IsMandatory() &&
322  {
324  }
325  }
326  // set the basic rates
327  for (uint32_t j = 0; j < m_stationManager->GetNBasicModes (); j++)
328  {
330  rates.SetBasicRate (mode.GetDataRate ());
331  }
332 
333  return rates;
334 }
337 {
338  HtCapabilities capabilities;
339  capabilities.SetHtSupported(1);
340  capabilities.SetLdpc (m_phy->GetLdpc());
342  capabilities.SetGreenfield (m_phy->GetGreenfield());
343  for (uint8_t i =0 ; i < m_phy->GetNMcs();i++)
344  {
345  capabilities.SetRxMcsBitmask(m_phy->GetMcs(i));
346  }
347  return capabilities;
348 }
349 void
351 {
352  NS_LOG_FUNCTION (this << to);
353  WifiMacHeader hdr;
354  hdr.SetProbeResp ();
355  hdr.SetAddr1 (to);
356  hdr.SetAddr2 (GetAddress ());
357  hdr.SetAddr3 (GetAddress ());
358  hdr.SetDsNotFrom ();
359  hdr.SetDsNotTo ();
360  Ptr<Packet> packet = Create<Packet> ();
362  probe.SetSsid (GetSsid ());
363  probe.SetSupportedRates (GetSupportedRates ());
364  probe.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
365 if (m_htSupported)
366  {
367  probe.SetHtCapabilities (GetHtCapabilities());
368  hdr.SetNoOrder();
369  }
370  packet->AddHeader (probe);
371 
372  // The standard is not clear on the correct queue for management
373  // frames if we are a QoS AP. The approach taken here is to always
374  // use the DCF for these regardless of whether we have a QoS
375  // association or not.
376  m_dca->Queue (packet, hdr);
377 }
378 
379 void
381 {
382  NS_LOG_FUNCTION (this << to << success);
383  WifiMacHeader hdr;
384  hdr.SetAssocResp ();
385  hdr.SetAddr1 (to);
386  hdr.SetAddr2 (GetAddress ());
387  hdr.SetAddr3 (GetAddress ());
388  hdr.SetDsNotFrom ();
389  hdr.SetDsNotTo ();
390  Ptr<Packet> packet = Create<Packet> ();
392  StatusCode code;
393  if (success)
394  {
395  code.SetSuccess ();
396  }
397  else
398  {
399  code.SetFailure ();
400  }
401  assoc.SetSupportedRates (GetSupportedRates ());
402  assoc.SetStatusCode (code);
403 
404  if (m_htSupported)
405  {
406  assoc.SetHtCapabilities (GetHtCapabilities());
407  hdr.SetNoOrder();
408  }
409  packet->AddHeader (assoc);
410 
411  // The standard is not clear on the correct queue for management
412  // frames if we are a QoS AP. The approach taken here is to always
413  // use the DCF for these regardless of whether we have a QoS
414  // association or not.
415  m_dca->Queue (packet, hdr);
416 }
417 
418 void
420 {
421  NS_LOG_FUNCTION (this);
422  WifiMacHeader hdr;
423  hdr.SetBeacon ();
425  hdr.SetAddr2 (GetAddress ());
426  hdr.SetAddr3 (GetAddress ());
427  hdr.SetDsNotFrom ();
428  hdr.SetDsNotTo ();
429  Ptr<Packet> packet = Create<Packet> ();
430  MgtBeaconHeader beacon;
431  beacon.SetSsid (GetSsid ());
432  beacon.SetSupportedRates (GetSupportedRates ());
433  beacon.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
434  if (m_htSupported)
435  {
436  beacon.SetHtCapabilities (GetHtCapabilities());
437  hdr.SetNoOrder();
438  }
439  packet->AddHeader (beacon);
440 
441  // The beacon has it's own special queue, so we load it in there
442  m_beaconDca->Queue (packet, hdr);
444 }
445 
446 void
448 {
449  NS_LOG_FUNCTION (this);
450  RegularWifiMac::TxOk (hdr);
451 
452  if (hdr.IsAssocResp ()
454  {
455  NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
457  }
458 }
459 
460 void
462 {
463  NS_LOG_FUNCTION (this);
465 
466  if (hdr.IsAssocResp ()
468  {
469  NS_LOG_DEBUG ("assoc failed with sta=" << hdr.GetAddr1 ());
471  }
472 }
473 
474 void
476 {
477  NS_LOG_FUNCTION (this << packet << hdr);
478 
479  Mac48Address from = hdr->GetAddr2 ();
480 
481  if (hdr->IsData ())
482  {
483  Mac48Address bssid = hdr->GetAddr1 ();
484  if (!hdr->IsFromDs ()
485  && hdr->IsToDs ()
486  && bssid == GetAddress ()
487  && m_stationManager->IsAssociated (from))
488  {
489  Mac48Address to = hdr->GetAddr3 ();
490  if (to == GetAddress ())
491  {
492  NS_LOG_DEBUG ("frame for me from=" << from);
493  if (hdr->IsQosData ())
494  {
495  if (hdr->IsQosAmsdu ())
496  {
497  NS_LOG_DEBUG ("Received A-MSDU from=" << from << ", size=" << packet->GetSize ());
498  DeaggregateAmsduAndForward (packet, hdr);
499  packet = 0;
500  }
501  else
502  {
503  ForwardUp (packet, from, bssid);
504  }
505  }
506  else
507  {
508  ForwardUp (packet, from, bssid);
509  }
510  }
511  else if (to.IsGroup ()
513  {
514  NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to);
515  Ptr<Packet> copy = packet->Copy ();
516 
517  // If the frame we are forwarding is of type QoS Data,
518  // then we need to preserve the UP in the QoS control
519  // header...
520  if (hdr->IsQosData ())
521  {
522  ForwardDown (packet, from, to, hdr->GetQosTid ());
523  }
524  else
525  {
526  ForwardDown (packet, from, to);
527  }
528  ForwardUp (copy, from, to);
529  }
530  else
531  {
532  ForwardUp (packet, from, to);
533  }
534  }
535  else if (hdr->IsFromDs ()
536  && hdr->IsToDs ())
537  {
538  // this is an AP-to-AP frame
539  // we ignore for now.
540  NotifyRxDrop (packet);
541  }
542  else
543  {
544  // we can ignore these frames since
545  // they are not targeted at the AP
546  NotifyRxDrop (packet);
547  }
548  return;
549  }
550  else if (hdr->IsMgt ())
551  {
552  if (hdr->IsProbeReq ())
553  {
554  NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ());
555  SendProbeResp (from);
556  return;
557  }
558  else if (hdr->GetAddr1 () == GetAddress ())
559  {
560  if (hdr->IsAssocReq ())
561  {
562  // first, verify that the the station's supported
563  // rate set is compatible with our Basic Rate set
564  MgtAssocRequestHeader assocReq;
565  packet->RemoveHeader (assocReq);
566  SupportedRates rates = assocReq.GetSupportedRates ();
567  bool problem = false;
568  for (uint32_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
569  {
571  if (!rates.IsSupportedRate (mode.GetDataRate ()))
572  {
573  problem = true;
574  break;
575  }
576  }
577  if (m_htSupported)
578  {//check that the STA supports all MCSs in Basic MCS Set
579  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
580  for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
581  {
582  uint8_t mcs = m_stationManager->GetBasicMcs (i);
583  if (!htcapabilities.IsSupportedMcs (mcs))
584  {
585  problem = true;
586  break;
587  }
588  }
589 
590  }
591  if (problem)
592  {
593  // one of the Basic Rate set mode is not
594  // supported by the station. So, we return an assoc
595  // response with an error status.
596  SendAssocResp (hdr->GetAddr2 (), false);
597  }
598  else
599  {
600  // station supports all rates in Basic Rate Set.
601  // record all its supported modes in its associated WifiRemoteStation
602  for (uint32_t j = 0; j < m_phy->GetNModes (); j++)
603  {
604  WifiMode mode = m_phy->GetMode (j);
605  if (rates.IsSupportedRate (mode.GetDataRate ()))
606  {
607  m_stationManager->AddSupportedMode (from, mode);
608  }
609  }
610  if (m_htSupported)
611  {
612  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
613  m_stationManager->AddStationHtCapabilities (from,htcapabilities);
614  for (uint32_t j = 0; j < m_phy->GetNMcs (); j++)
615  {
616  uint8_t mcs = m_phy->GetMcs (j);
617  if (htcapabilities.IsSupportedMcs (mcs))
618  {
619  m_stationManager->AddSupportedMcs (from, mcs);
620  }
621  }
622  }
624  // send assoc response with success status.
625  SendAssocResp (hdr->GetAddr2 (), true);
626  }
627  return;
628  }
629  else if (hdr->IsDisassociation ())
630  {
632  return;
633  }
634  }
635  }
636 
637  // Invoke the receive handler of our parent class to deal with any
638  // other frames. Specifically, this will handle Block Ack-related
639  // Management Action frames.
640  RegularWifiMac::Receive (packet, hdr);
641 }
642 
643 void
645  const WifiMacHeader *hdr)
646 {
647  NS_LOG_FUNCTION (this << aggregatedPacket << hdr);
649  MsduAggregator::Deaggregate (aggregatedPacket);
650 
651  for (MsduAggregator::DeaggregatedMsdusCI i = packets.begin ();
652  i != packets.end (); ++i)
653  {
654  if ((*i).second.GetDestinationAddr () == GetAddress ())
655  {
656  ForwardUp ((*i).first, (*i).second.GetSourceAddr (),
657  (*i).second.GetDestinationAddr ());
658  }
659  else
660  {
661  Mac48Address from = (*i).second.GetSourceAddr ();
662  Mac48Address to = (*i).second.GetDestinationAddr ();
663  NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
664  ForwardDown ((*i).first, from, to, hdr->GetQosTid ());
665  }
666  }
667 }
668 
669 void
671 {
672  NS_LOG_FUNCTION (this);
673  m_beaconDca->Initialize ();
676  {
678  {
679  int64_t jitter = m_beaconJitter->GetValue (0, m_beaconInterval.GetMicroSeconds ());
680  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress() << " at time " << jitter << " microseconds");
682  }
683  else
684  {
685  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress() << " at time 0");
687  }
688  }
690 }
691 
692 } // namespace ns3
virtual void DoInitialize(void)
Initialize() implementation.
Definition: ap-wifi-mac.cc:670
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:268
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:168
void AddSupportedRate(uint32_t bs)
Add the given rate to the supported rates.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
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 "...
HtCapabilities GetHtCapabilities(void) const
Return the HT capability of the current AP.
Definition: ap-wifi-mac.cc:336
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
void SetQosAckPolicy(enum QosAckPolicy policy)
Set the QoS ACK policy in the QoS control field.
AttributeValue implementation for Boolean.
Definition: boolean.h:34
void SetGreenfield(uint8_t greenfield)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
virtual void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > stationManager)
static WifiMode GetDsssRate1Mbps()
Return a WifiMode for DSSS at 1Mbps.
Definition: wifi-phy.cc:650
Hold variables of type string.
Definition: string.h:41
void SetHtSupported(uint8_t htsupported)
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: ap-wifi-mac.cc:186
void RecordWaitAssocTxOk(Mac48Address address)
Records that we are waiting for an ACK for the association response we sent.
virtual uint32_t GetNModes(void) const =0
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
void SetRxMcsBitmask(uint8_t index)
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
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:115
virtual uint8_t GetNMcs(void) const =0
The WifiPhy::GetNMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of t...
#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
MacTxMiddle * m_txMiddle
TX middle (aggregation etc.)
#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.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:766
std::list< std::pair< Ptr< Packet >, AmsduSubframeHeader > >::const_iterator DeaggregatedMsdusCI
bool IsBroadcast(void) const
static DeaggregatedMsdus Deaggregate(Ptr< Packet > aggregatedPacket)
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:275
virtual bool GetLdpc(void) const =0
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...
void SendAssocResp(Mac48Address to, bool success)
Forward an association response packet to the DCF.
Definition: ap-wifi-mac.cc:380
virtual bool SupportsSendFrom(void) const
Definition: ap-wifi-mac.cc:289
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
Ptr< DcaTxop > m_beaconDca
Dedicated DcaTxop for beacons.
Definition: ap-wifi-mac.h:207
void SetProbeResp(void)
Set Type/Subtype values for a probe response header.
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 IsMandatory(void) const
Definition: wifi-mode.cc:104
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
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
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
bool m_enableBeaconGeneration
Flag if beacons are being generated.
Definition: ap-wifi-mac.h:209
virtual void Enqueue(Ptr< const Packet > packet, Mac48Address to)
Definition: ap-wifi-mac.cc:279
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:301
virtual void SetBssid(Mac48Address bssid)
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
void ForwardUp(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
virtual void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > stationManager)
Definition: ap-wifi-mac.cc:148
base class for all MAC-level wifi objects.
void SetSuccess(void)
Set success bit to 0 (success).
Definition: status-code.cc:31
bool m_qosSupported
This Boolean is set true iff this WifiMac is to model 802.11e/WMM style Quality of Service...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:210
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.
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:342
void SetShortGuardInterval20(uint8_t shortguardinterval)
void SetBeacon(void)
Set Type/Subtype values for a beacon header.
AttributeValue implementation for Time.
Definition: nstime.h:928
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.
static TypeId GetTypeId(void)
Definition: ap-wifi-mac.cc:48
bool IsProbeReq(void) const
Return true if the header is a Probe Request header.
void ForwardDown(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet down to DCF/EDCAF (enqueue the packet).
Definition: ap-wifi-mac.cc:194
void RecordGotAssocTxFailed(Mac48Address address)
Records that we missed an ACK for the association response we sent.
WifiMode GetBasicMode(uint32_t i) const
Return a basic mode from the set of basic modes.
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
virtual void SetAddress(Mac48Address address)
static Mac48Address GetBroadcast(void)
bool IsSupportedMcs(uint8_t mcs)
EventId m_beaconEvent
Event to generate one beacon.
Definition: ap-wifi-mac.h:210
virtual bool GetGuardInterval(void) const =0
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:599
bool IsMgt(void) const
Return true if the Type is Management.
virtual uint32_t GetNBssMembershipSelectors(void) const =0
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
Ptr< MacLow > m_low
MacLow (RTS, CTS, DATA, ACK etc.)
uint32_t GetNBasicMcs(void) const
Return the number of basic MCS index.
void SetBasicRate(uint32_t bs)
Set the given rate to basic rates.
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...
Definition: ap-wifi-mac.cc:475
virtual void DeaggregateAmsduAndForward(Ptr< Packet > aggregatedPacket, const WifiMacHeader *hdr)
This method is called to de-aggregate an A-MSDU and forward the constituent packets up the stack...
Definition: ap-wifi-mac.cc:644
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:122
Status code for association response.
Definition: status-code.h:32
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:166
bool IsWaitAssocTxOk(Mac48Address address) const
Return whether we are waiting for an ACK for the association response we sent.
virtual void SetLinkUpCallback(Callback< void > linkUp)
virtual void SetLinkUpCallback(Callback< void > linkUp)
Definition: ap-wifi-mac.cc:156
virtual void DoDispose()
Destructor implementation.
std::list< std::pair< Ptr< Packet >, AmsduSubframeHeader > > DeaggregatedMsdus
bool IsToDs(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsDisassociation(void) const
Return true if the header is a Disassociation header.
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.
DcfManager * m_dcfManager
DCF manager (access to channel)
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
double GetValue(double min, double max)
Returns a random double from the uniform distribution with the specified range.
an EUI-48 address
Definition: mac48-address.h:43
bool IsAssociated(Mac48Address address) const
Return whether the station associated.
virtual WifiMode GetMode(uint32_t mode) const =0
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:980
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
bool GetBeaconGeneration(void) const
Return whether the AP is generating beacons.
Definition: ap-wifi-mac.cc:134
Wi-Fi AP state machineHandle association, dis-association and authentication, of STAs within an infra...
Definition: ap-wifi-mac.h:40
bool m_htSupported
This Boolean is set true iff this WifiMac is to model 802.11n.
Implement the header for management frames of type association response.
Definition: mgt-headers.h:116
void SendProbeResp(Mac48Address to)
Forward a probe response packet to the DCF.
Definition: ap-wifi-mac.cc:350
void SetAssocResp(void)
Set Type/Subtype values for an association response header.
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates...
Definition: ap-wifi-mac.cc:296
uint32_t GetNBasicModes(void) const
Return the number of basic modes we support.
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
virtual void TxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:461
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.
void SendOneBeacon(void)
Forward a beacon packet to the beacon special DCF.
Definition: ap-wifi-mac.cc:419
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_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:228
uint8_t GetBasicMcs(uint32_t i) const
Return the MCS at the given list index.
virtual void DoDispose(void)
Destructor implementation.
Definition: ap-wifi-mac.cc:99
virtual void SetAddress(Mac48Address address)
Definition: ap-wifi-mac.cc:109
#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.
Ptr< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
Definition: ap-wifi-mac.h:211
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
Time m_beaconInterval
Interval between beacons.
Definition: ap-wifi-mac.h:208
virtual void DoInitialize()
Initialize() implementation.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
virtual ~ApWifiMac()
Definition: ap-wifi-mac.cc:93
void SetLdpc(uint8_t ldpc)
bool IsFromDs(void) const
bool IsSupportedRate(uint32_t bs) const
Check if the given rate is supported.
void SetDsFrom(void)
Set the From DS bit in the Frame Control field.
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 SetType(enum WifiMacType type)
Set Type/Subtype values with the correct values depending on the given type.
bool m_enableBeaconJitter
Flag if the first beacon should be generated at random time.
Definition: ap-wifi-mac.h:212
Time GetBeaconInterval(void) const
Definition: ap-wifi-mac.cc:141
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
virtual void TxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
tuple address
Definition: first.py:37
virtual void TxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:447
static WifiMode GetDsssRate2Mbps()
Return a WifiMode for DSSS at 2Mbps.
Definition: wifi-phy.cc:663
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.
void SetFailure(void)
Set success bit to 1 (failure.
Definition: status-code.cc:36
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:291
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
void StartBeaconing(void)
Start beacon transmission immediately.
Definition: ap-wifi-mac.cc:179
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:321
virtual bool GetGreenfield(void) const =0
void RecordGotAssocTxOk(Mac48Address address)
Records that we got an ACK for the association response we sent.
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:253
Implements the IEEE 802.11 MAC header.
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
Definition: wifi-mode.h:46
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
Definition: ap-wifi-mac.cc:119
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
virtual void TxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.