A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("ApWifiMac");
42 
43 namespace ns3 {
44 
46  ;
47 
48 TypeId
50 {
51  static TypeId tid = TypeId ("ns3::ApWifiMac")
53  .AddConstructor<ApWifiMac> ()
54  .AddAttribute ("BeaconInterval", "Delay between two beacons",
55  TimeValue (MicroSeconds (102400)),
56  MakeTimeAccessor (&ApWifiMac::GetBeaconInterval,
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"),
61  MakePointerAccessor (&ApWifiMac::m_beaconJitter),
62  MakePointerChecker<UniformRandomVariable> ())
63  .AddAttribute ("EnableBeaconJitter", "If beacons are enabled, whether to jitter the initial send event.",
64  BooleanValue (false),
65  MakeBooleanAccessor (&ApWifiMac::m_enableBeaconJitter),
66  MakeBooleanChecker ())
67  .AddAttribute ("BeaconGeneration", "Whether or not beacons are generated.",
68  BooleanValue (true),
69  MakeBooleanAccessor (&ApWifiMac::SetBeaconGeneration,
71  MakeBooleanChecker ())
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 
86  // Let the lower layers know that we are acting as an AP.
88 
90 }
91 
93 {
94  NS_LOG_FUNCTION (this);
95 }
96 
97 void
99 {
100  NS_LOG_FUNCTION (this);
101  m_beaconDca = 0;
102  m_enableBeaconGeneration = false;
105 }
106 
107 void
109 {
110  NS_LOG_FUNCTION (this << address);
111  // As an AP, our MAC address is also the BSSID. Hence we are
112  // overriding this function and setting both in our parent class.
113  RegularWifiMac::SetAddress (address);
114  RegularWifiMac::SetBssid (address);
115 }
116 
117 void
119 {
120  NS_LOG_FUNCTION (this << enable);
121  if (!enable)
122  {
124  }
125  else if (enable && !m_enableBeaconGeneration)
126  {
128  }
129  m_enableBeaconGeneration = enable;
130 }
131 
132 bool
134 {
135  NS_LOG_FUNCTION (this);
137 }
138 
139 Time
141 {
142  NS_LOG_FUNCTION (this);
143  return m_beaconInterval;
144 }
145 
146 void
148 {
149  NS_LOG_FUNCTION (this << stationManager);
150  m_beaconDca->SetWifiRemoteStationManager (stationManager);
152 }
153 
154 void
156 {
157  NS_LOG_FUNCTION (this << &linkUp);
159 
160  // The approach taken here is that, from the point of view of an AP,
161  // the link is always up, so we immediately invoke the callback if
162  // one is set
163  linkUp ();
164 }
165 
166 void
168 {
169  NS_LOG_FUNCTION (this << interval);
170  if ((interval.GetMicroSeconds () % 1024) != 0)
171  {
172  NS_LOG_WARN ("beacon interval should be multiple of 1024us, see IEEE Std. 802.11-2007, section 11.1.1.1");
173  }
174  m_beaconInterval = interval;
175 }
176 
177 void
179 {
180  NS_LOG_FUNCTION (this);
181  SendOneBeacon ();
182 }
183 
184 int64_t
185 ApWifiMac::AssignStreams (int64_t stream)
186 {
187  NS_LOG_FUNCTION (this << stream);
188  m_beaconJitter->SetStream (stream);
189  return 1;
190 }
191 
192 void
194  Mac48Address to)
195 {
196  NS_LOG_FUNCTION (this << packet << from << to);
197  // If we are not a QoS AP then we definitely want to use AC_BE to
198  // transmit the packet. A TID of zero will map to AC_BE (through \c
199  // QosUtilsMapTidToAc()), so we use that as our default here.
200  uint8_t tid = 0;
201 
202  // If we are a QoS AP then we attempt to get a TID for this packet
203  if (m_qosSupported)
204  {
205  tid = QosUtilsGetTidForPacket (packet);
206  // Any value greater than 7 is invalid and likely indicates that
207  // the packet had no QoS tag, so we revert to zero, which'll
208  // mean that AC_BE is used.
209  if (tid >= 7)
210  {
211  tid = 0;
212  }
213  }
214 
215  ForwardDown (packet, from, to, tid);
216 }
217 
218 void
220  Mac48Address to, uint8_t tid)
221 {
222  NS_LOG_FUNCTION (this << packet << from << to << static_cast<uint32_t> (tid));
223  WifiMacHeader hdr;
224 
225  // For now, an AP that supports QoS does not support non-QoS
226  // associations, and vice versa. In future the AP model should
227  // support simultaneously associated QoS and non-QoS STAs, at which
228  // point there will need to be per-association QoS state maintained
229  // by the association state machine, and consulted here.
230  if (m_qosSupported)
231  {
234  hdr.SetQosNoEosp ();
235  hdr.SetQosNoAmsdu ();
236  // Transmission of multiple frames in the same TXOP is not
237  // supported for now
238  hdr.SetQosTxopLimit (0);
239  // Fill in the QoS control field in the MAC header
240  hdr.SetQosTid (tid);
241  }
242  else
243  {
244  hdr.SetTypeData ();
245  }
246 
247  if (m_htSupported)
248  hdr.SetNoOrder();
249  hdr.SetAddr1 (to);
250  hdr.SetAddr2 (GetAddress ());
251  hdr.SetAddr3 (from);
252  hdr.SetDsFrom ();
253  hdr.SetDsNotTo ();
254 
255  if (m_qosSupported)
256  {
257  // Sanity check that the TID is valid
258  NS_ASSERT (tid < 8);
259  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
260  }
261  else
262  {
263  m_dca->Queue (packet, hdr);
264  }
265 }
266 
267 void
269 {
270  NS_LOG_FUNCTION (this << packet << to << from);
271  if (to.IsBroadcast () || m_stationManager->IsAssociated (to))
272  {
273  ForwardDown (packet, from, to);
274  }
275 }
276 
277 void
279 {
280  NS_LOG_FUNCTION (this << packet << to);
281  // We're sending this packet with a from address that is our own. We
282  // get that address from the lower MAC and make use of the
283  // from-spoofing Enqueue() method to avoid duplicated code.
284  Enqueue (packet, to, m_low->GetAddress ());
285 }
286 
287 bool
289 {
290  NS_LOG_FUNCTION (this);
291  return true;
292 }
293 
296 {
297  NS_LOG_FUNCTION (this);
298  SupportedRates rates;
299  // If it is an HT-AP then add the BSSMembershipSelectorSet
300  // which only includes 127 for HT now. The standard says that the BSSMembershipSelectorSet
301  // must have its MSB set to 1 (must be treated as a Basic Rate)
302  // Also the standard mentioned that at leat 1 element should be included in the SupportedRates the rest can be in the ExtendedSupportedRates
303  if (m_htSupported)
304  {
305  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors(); i++)
306  {
308  }
309  }
310  // send the set of supported rates and make sure that we indicate
311  // the Basic Rate set in this set of supported rates.
312  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
313  {
314  WifiMode mode = m_phy->GetMode (i);
315  rates.AddSupportedRate (mode.GetDataRate ());
316  }
317  // set the basic rates
318  for (uint32_t j = 0; j < m_stationManager->GetNBasicModes (); j++)
319  {
320  WifiMode mode = m_stationManager->GetBasicMode (j);
321  rates.SetBasicRate (mode.GetDataRate ());
322  }
323 
324  return rates;
325 }
328 {
329  HtCapabilities capabilities;
330  capabilities.SetHtSupported(1);
331  capabilities.SetLdpc (m_phy->GetLdpc());
333  capabilities.SetGreenfield (m_phy->GetGreenfield());
334  for (uint8_t i =0 ; i < m_phy->GetNMcs();i++)
335  {
336  capabilities.SetRxMcsBitmask(m_phy->GetMcs(i));
337  }
338  return capabilities;
339 }
340 void
342 {
343  NS_LOG_FUNCTION (this << to);
344  WifiMacHeader hdr;
345  hdr.SetProbeResp ();
346  hdr.SetAddr1 (to);
347  hdr.SetAddr2 (GetAddress ());
348  hdr.SetAddr3 (GetAddress ());
349  hdr.SetDsNotFrom ();
350  hdr.SetDsNotTo ();
351  Ptr<Packet> packet = Create<Packet> ();
353  probe.SetSsid (GetSsid ());
354  probe.SetSupportedRates (GetSupportedRates ());
355  probe.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
356 if (m_htSupported)
357  {
358  probe.SetHtCapabilities (GetHtCapabilities());
359  hdr.SetNoOrder();
360  }
361  packet->AddHeader (probe);
362 
363  // The standard is not clear on the correct queue for management
364  // frames if we are a QoS AP. The approach taken here is to always
365  // use the DCF for these regardless of whether we have a QoS
366  // association or not.
367  m_dca->Queue (packet, hdr);
368 }
369 
370 void
372 {
373  NS_LOG_FUNCTION (this << to << success);
374  WifiMacHeader hdr;
375  hdr.SetAssocResp ();
376  hdr.SetAddr1 (to);
377  hdr.SetAddr2 (GetAddress ());
378  hdr.SetAddr3 (GetAddress ());
379  hdr.SetDsNotFrom ();
380  hdr.SetDsNotTo ();
381  Ptr<Packet> packet = Create<Packet> ();
383  StatusCode code;
384  if (success)
385  {
386  code.SetSuccess ();
387  }
388  else
389  {
390  code.SetFailure ();
391  }
392  assoc.SetSupportedRates (GetSupportedRates ());
393  assoc.SetStatusCode (code);
394 
395  if (m_htSupported)
396  {
397  assoc.SetHtCapabilities (GetHtCapabilities());
398  hdr.SetNoOrder();
399  }
400  packet->AddHeader (assoc);
401 
402  // The standard is not clear on the correct queue for management
403  // frames if we are a QoS AP. The approach taken here is to always
404  // use the DCF for these regardless of whether we have a QoS
405  // association or not.
406  m_dca->Queue (packet, hdr);
407 }
408 
409 void
411 {
412  NS_LOG_FUNCTION (this);
413  WifiMacHeader hdr;
414  hdr.SetBeacon ();
416  hdr.SetAddr2 (GetAddress ());
417  hdr.SetAddr3 (GetAddress ());
418  hdr.SetDsNotFrom ();
419  hdr.SetDsNotTo ();
420  Ptr<Packet> packet = Create<Packet> ();
421  MgtBeaconHeader beacon;
422  beacon.SetSsid (GetSsid ());
423  beacon.SetSupportedRates (GetSupportedRates ());
424  beacon.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
425  if (m_htSupported)
426  {
427  beacon.SetHtCapabilities (GetHtCapabilities());
428  hdr.SetNoOrder();
429  }
430  packet->AddHeader (beacon);
431 
432  // The beacon has it's own special queue, so we load it in there
433  m_beaconDca->Queue (packet, hdr);
435 }
436 
437 void
439 {
440  NS_LOG_FUNCTION (this);
441  RegularWifiMac::TxOk (hdr);
442 
443  if (hdr.IsAssocResp ()
444  && m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ()))
445  {
446  NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
447  m_stationManager->RecordGotAssocTxOk (hdr.GetAddr1 ());
448  }
449 }
450 
451 void
453 {
454  NS_LOG_FUNCTION (this);
456 
457  if (hdr.IsAssocResp ()
458  && m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ()))
459  {
460  NS_LOG_DEBUG ("assoc failed with sta=" << hdr.GetAddr1 ());
461  m_stationManager->RecordGotAssocTxFailed (hdr.GetAddr1 ());
462  }
463 }
464 
465 void
467 {
468  NS_LOG_FUNCTION (this << packet << hdr);
469 
470  Mac48Address from = hdr->GetAddr2 ();
471 
472  if (hdr->IsData ())
473  {
474  Mac48Address bssid = hdr->GetAddr1 ();
475  if (!hdr->IsFromDs ()
476  && hdr->IsToDs ()
477  && bssid == GetAddress ()
478  && m_stationManager->IsAssociated (from))
479  {
480  Mac48Address to = hdr->GetAddr3 ();
481  if (to == GetAddress ())
482  {
483  NS_LOG_DEBUG ("frame for me from=" << from);
484  if (hdr->IsQosData ())
485  {
486  if (hdr->IsQosAmsdu ())
487  {
488  NS_LOG_DEBUG ("Received A-MSDU from=" << from << ", size=" << packet->GetSize ());
489  DeaggregateAmsduAndForward (packet, hdr);
490  packet = 0;
491  }
492  else
493  {
494  ForwardUp (packet, from, bssid);
495  }
496  }
497  else
498  {
499  ForwardUp (packet, from, bssid);
500  }
501  }
502  else if (to.IsGroup ()
503  || m_stationManager->IsAssociated (to))
504  {
505  NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to);
506  Ptr<Packet> copy = packet->Copy ();
507 
508  // If the frame we are forwarding is of type QoS Data,
509  // then we need to preserve the UP in the QoS control
510  // header...
511  if (hdr->IsQosData ())
512  {
513  ForwardDown (packet, from, to, hdr->GetQosTid ());
514  }
515  else
516  {
517  ForwardDown (packet, from, to);
518  }
519  ForwardUp (copy, from, to);
520  }
521  else
522  {
523  ForwardUp (packet, from, to);
524  }
525  }
526  else if (hdr->IsFromDs ()
527  && hdr->IsToDs ())
528  {
529  // this is an AP-to-AP frame
530  // we ignore for now.
531  NotifyRxDrop (packet);
532  }
533  else
534  {
535  // we can ignore these frames since
536  // they are not targeted at the AP
537  NotifyRxDrop (packet);
538  }
539  return;
540  }
541  else if (hdr->IsMgt ())
542  {
543  if (hdr->IsProbeReq ())
544  {
545  NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ());
546  SendProbeResp (from);
547  return;
548  }
549  else if (hdr->GetAddr1 () == GetAddress ())
550  {
551  if (hdr->IsAssocReq ())
552  {
553  // first, verify that the the station's supported
554  // rate set is compatible with our Basic Rate set
555  MgtAssocRequestHeader assocReq;
556  packet->RemoveHeader (assocReq);
557  SupportedRates rates = assocReq.GetSupportedRates ();
558  bool problem = false;
559  for (uint32_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
560  {
561  WifiMode mode = m_stationManager->GetBasicMode (i);
562  if (!rates.IsSupportedRate (mode.GetDataRate ()))
563  {
564  problem = true;
565  break;
566  }
567  }
568  if (m_htSupported)
569  {//check that the STA supports all MCSs in Basic MCS Set
570  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
571  for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
572  {
573  uint8_t mcs = m_stationManager->GetBasicMcs (i);
574  if (!htcapabilities.IsSupportedMcs (mcs))
575  {
576  problem = true;
577  break;
578  }
579  }
580 
581  }
582  if (problem)
583  {
584  // one of the Basic Rate set mode is not
585  // supported by the station. So, we return an assoc
586  // response with an error status.
587  SendAssocResp (hdr->GetAddr2 (), false);
588  }
589  else
590  {
591  // station supports all rates in Basic Rate Set.
592  // record all its supported modes in its associated WifiRemoteStation
593  for (uint32_t j = 0; j < m_phy->GetNModes (); j++)
594  {
595  WifiMode mode = m_phy->GetMode (j);
596  if (rates.IsSupportedRate (mode.GetDataRate ()))
597  {
598  m_stationManager->AddSupportedMode (from, mode);
599  }
600  }
601  if (m_htSupported)
602  {
603  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
604  m_stationManager->AddStationHtCapabilities (from,htcapabilities);
605  for (uint32_t j = 0; j < m_phy->GetNMcs (); j++)
606  {
607  uint8_t mcs = m_phy->GetMcs (j);
608  if (htcapabilities.IsSupportedMcs (mcs))
609  {
610  m_stationManager->AddSupportedMcs (from, mcs);
611  }
612  }
613  }
614  m_stationManager->RecordWaitAssocTxOk (from);
615  // send assoc response with success status.
616  SendAssocResp (hdr->GetAddr2 (), true);
617  }
618  return;
619  }
620  else if (hdr->IsDisassociation ())
621  {
622  m_stationManager->RecordDisassociated (from);
623  return;
624  }
625  }
626  }
627 
628  // Invoke the receive handler of our parent class to deal with any
629  // other frames. Specifically, this will handle Block Ack-related
630  // Management Action frames.
631  RegularWifiMac::Receive (packet, hdr);
632 }
633 
634 void
636  const WifiMacHeader *hdr)
637 {
638  NS_LOG_FUNCTION (this << aggregatedPacket << hdr);
640  MsduAggregator::Deaggregate (aggregatedPacket);
641 
642  for (MsduAggregator::DeaggregatedMsdusCI i = packets.begin ();
643  i != packets.end (); ++i)
644  {
645  if ((*i).second.GetDestinationAddr () == GetAddress ())
646  {
647  ForwardUp ((*i).first, (*i).second.GetSourceAddr (),
648  (*i).second.GetDestinationAddr ());
649  }
650  else
651  {
652  Mac48Address from = (*i).second.GetSourceAddr ();
653  Mac48Address to = (*i).second.GetDestinationAddr ();
654  NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
655  ForwardDown ((*i).first, from, to, hdr->GetQosTid ());
656  }
657  }
658 }
659 
660 void
662 {
663  NS_LOG_FUNCTION (this);
664  m_beaconDca->Initialize ();
667  {
669  {
670  int64_t jitter = m_beaconJitter->GetValue (0, m_beaconInterval.GetMicroSeconds ());
671  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress() << " at time " << jitter << " microseconds");
672  m_beaconEvent = Simulator::Schedule (MicroSeconds (jitter), &ApWifiMac::SendOneBeacon, this);
673  }
674  else
675  {
676  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress() << " at time 0");
678  }
679  }
681 }
682 
683 } // namespace ns3
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
Definition: ap-wifi-mac.cc:661
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:167
void AddSupportedRate(uint32_t bs)
Add the given rate to the supported rates.
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
Implement the header for management frames of type association request.
Definition: mgt-headers.h:40
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
HtCapabilities GetHtCapabilities(void) const
Return the HT capability of the current AP.
Definition: ap-wifi-mac.cc:327
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.
Hold a bool native type.
Definition: boolean.h:38
void SetGreenfield(uint8_t greenfield)
virtual void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > stationManager)
hold variables of type string
Definition: string.h:19
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:185
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)
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...
#define NS_ASSERT(condition)
Definition: assert.h:64
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.
uint32_t GetSize(void) const
Definition: packet.h:650
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:270
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:371
virtual bool SupportsSendFrom(void) const
Definition: ap-wifi-mac.cc:288
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
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:91
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
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:278
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:302
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:147
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...
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
Definition: nstime.h:291
void SetShortGuardInterval20(uint8_t shortguardinterval)
void SetBeacon(void)
Set Type/Subtype values for a beacon header.
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.
static TypeId GetTypeId(void)
Definition: ap-wifi-mac.cc:49
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:193
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
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.)
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:466
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:635
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
Ptr< Packet > Copy(void) const
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:167
virtual void SetLinkUpCallback(Callback< void > linkUp)
virtual void SetLinkUpCallback(Callback< void > linkUp)
Definition: ap-wifi-mac.cc:155
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
std::list< std::pair< Ptr< Packet >, AmsduSubframeHeader > > DeaggregatedMsdus
bool IsToDs(void) const
bool IsDisassociation(void) const
Return true if the header is a Disassociation header.
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...
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
DcfManager * m_dcfManager
DCF manager (access to channel)
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:41
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:985
bool GetBeaconGeneration(void) const
Return whether the AP is generating beacons.
Definition: ap-wifi-mac.cc:133
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:341
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:295
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:452
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:410
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)
Definition: log.h:280
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: ap-wifi-mac.cc:98
virtual void SetAddress(Mac48Address address)
Definition: ap-wifi-mac.cc:108
#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.
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()
This method is called only once by Object::Initialize.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
Definition: event-id.cc:47
virtual ~ApWifiMac()
Definition: ap-wifi-mac.cc:92
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 SetDsFrom(void)
Set the From DS bit in the Frame Control field.
void SetNoOrder(void)
Unset order bit in the frame control field.
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:140
NS_LOG_COMPONENT_DEFINE("ApWifiMac")
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:438
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:292
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
void StartBeaconing(void)
Start beacon transmission immediately.
Definition: ap-wifi-mac.cc:178
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.
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
Definition: ap-wifi-mac.cc:118
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.