This documentation is not the Latest Release.
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  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Mirko Banchi <mk.banchi@gmail.com>
21  */
22 
23 #include "ap-wifi-mac.h"
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 #include "qos-tag.h"
31 #include "wifi-phy.h"
32 #include "dcf-manager.h"
33 #include "mac-rx-middle.h"
34 #include "mac-tx-middle.h"
35 #include "mgt-headers.h"
36 #include "mac-low.h"
37 #include "amsdu-subframe-header.h"
38 #include "msdu-aggregator.h"
39 
40 namespace ns3 {
41 
42 NS_LOG_COMPONENT_DEFINE ("ApWifiMac");
43 
44 NS_OBJECT_ENSURE_REGISTERED (ApWifiMac);
45 
46 TypeId
48 {
49  static TypeId tid = TypeId ("ns3::ApWifiMac")
51  .SetGroupName ("Wifi")
52  .AddConstructor<ApWifiMac> ()
53  .AddAttribute ("BeaconInterval", "Delay between two beacons",
54  TimeValue (MicroSeconds (102400)),
57  MakeTimeChecker ())
58  .AddAttribute ("BeaconJitter", "A uniform random variable to cause the initial beacon starting time (after simulation time 0) "
59  "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 
249  {
250  hdr.SetNoOrder ();
251  }
252  hdr.SetAddr1 (to);
253  hdr.SetAddr2 (GetAddress ());
254  hdr.SetAddr3 (from);
255  hdr.SetDsFrom ();
256  hdr.SetDsNotTo ();
257 
258  if (m_qosSupported)
259  {
260  //Sanity check that the TID is valid
261  NS_ASSERT (tid < 8);
262  m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr);
263  }
264  else
265  {
266  m_dca->Queue (packet, hdr);
267  }
268 }
269 
270 void
272 {
273  NS_LOG_FUNCTION (this << packet << to << from);
274  if (to.IsBroadcast () || m_stationManager->IsAssociated (to))
275  {
276  ForwardDown (packet, from, to);
277  }
278 }
279 
280 void
282 {
283  NS_LOG_FUNCTION (this << packet << to);
284  //We're sending this packet with a from address that is our own. We
285  //get that address from the lower MAC and make use of the
286  //from-spoofing Enqueue() method to avoid duplicated code.
287  Enqueue (packet, to, m_low->GetAddress ());
288 }
289 
290 bool
292 {
293  NS_LOG_FUNCTION (this);
294  return true;
295 }
296 
299 {
300  NS_LOG_FUNCTION (this);
301  SupportedRates rates;
302  //If it is an HT-AP then add the BSSMembershipSelectorSet
303  //which only includes 127 for HT now. The standard says that the BSSMembershipSelectorSet
304  //must have its MSB set to 1 (must be treated as a Basic Rate)
305  //Also the standard mentioned that at leat 1 element should be included in the SupportedRates the rest can be in the ExtendedSupportedRates
307  {
308  for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
309  {
311  }
312  }
313  //Send the set of supported rates and make sure that we indicate
314  //the Basic Rate set in this set of supported rates.
315  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
316  {
317  WifiMode mode = m_phy->GetMode (i);
318  rates.AddSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1));
319  //Add rates that are part of the BSSBasicRateSet (manufacturer dependent!)
320  //here we choose to add the mandatory rates to the BSSBasicRateSet,
321  //exept for 802.11b where we assume that only the non HR-DSSS rates are part of the BSSBasicRateSet
322  if (mode.IsMandatory () && (mode.GetModulationClass () != WIFI_MOD_CLASS_HR_DSSS))
323  {
325  }
326  }
327  //set the basic rates
328  for (uint32_t j = 0; j < m_stationManager->GetNBasicModes (); j++)
329  {
331  rates.SetBasicRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1));
332  }
333 
334  return rates;
335 }
336 
339 {
340  CapabilityInformation capabilities;
341  capabilities.SetShortPreamble (m_phy->GetShortPlcpPreamble ());
342  return capabilities;
343 }
344 
347 {
348  HtCapabilities capabilities;
349  capabilities.SetHtSupported (1);
350  if (m_htSupported)
351  {
352  capabilities.SetLdpc (m_phy->GetLdpc ());
353  capabilities.SetSupportedChannelWidth (m_phy->GetChannelWidth () == 40);
355  capabilities.SetShortGuardInterval40 (m_phy->GetChannelWidth () == 40 && m_phy->GetGuardInterval ());
356  capabilities.SetGreenfield (m_phy->GetGreenfield ());
357  capabilities.SetMaxAmsduLength (1); //hardcoded for now (TBD)
358  capabilities.SetLSigProtectionSupport (!m_phy->GetGreenfield ());
359  capabilities.SetMaxAmpduLength (3); //hardcoded for now (TBD)
360  uint64_t maxSupportedRate = 0; //in bit/s
361  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
362  {
363  WifiMode mcs = m_phy->GetMcs (i);
364  capabilities.SetRxMcsBitmask (mcs.GetMcsValue ());
365  if ((mcs.GetModulationClass () == WIFI_MOD_CLASS_HT)
366  && (mcs.GetDataRate (m_phy->GetChannelWidth (), m_phy->GetGuardInterval (), 1) > maxSupportedRate))
367  {
368  maxSupportedRate = mcs.GetDataRate (m_phy->GetChannelWidth (), m_phy->GetGuardInterval (), 1);
369  }
370  }
371  capabilities.SetRxHighestSupportedDataRate (maxSupportedRate / 1e6); //in Mbit/s
372  capabilities.SetTxMcsSetDefined (m_phy->GetNMcs () > 0);
374  }
375  return capabilities;
376 }
377 
380 {
381  VhtCapabilities capabilities;
382  capabilities.SetVhtSupported (1);
383  if (m_vhtSupported)
384  {
385  if (m_phy->GetChannelWidth () == 160)
386  {
387  capabilities.SetSupportedChannelWidthSet (1);
388  }
389  else
390  {
391  capabilities.SetSupportedChannelWidthSet (0);
392  }
393  capabilities.SetMaxMpduLength (2); //hardcoded for now (TBD)
394  capabilities.SetRxLdpc (m_phy->GetLdpc ());
397  capabilities.SetMaxAmpduLengthExponent (7); //hardcoded for now (TBD)
398  uint8_t maxMcs = 0;
399  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
400  {
401  WifiMode mcs = m_phy->GetMcs (i);
402  if ((mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT)
403  && (mcs.GetMcsValue () > maxMcs))
404  {
405  maxMcs = mcs.GetMcsValue ();
406  }
407  }
408  capabilities.SetRxMcsMap (maxMcs, 1); //Only 1 SS is currently supported
409  capabilities.SetTxMcsMap (maxMcs, 1); //Only 1 SS is currently supported
410  }
411  return capabilities;
412 }
413 
414 void
416 {
417  NS_LOG_FUNCTION (this << to);
418  WifiMacHeader hdr;
419  hdr.SetProbeResp ();
420  hdr.SetAddr1 (to);
421  hdr.SetAddr2 (GetAddress ());
422  hdr.SetAddr3 (GetAddress ());
423  hdr.SetDsNotFrom ();
424  hdr.SetDsNotTo ();
425  Ptr<Packet> packet = Create<Packet> ();
427  probe.SetSsid (GetSsid ());
428  probe.SetSupportedRates (GetSupportedRates ());
429  probe.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
430  probe.SetCapabilities (GetCapabilities ());
432  {
433  probe.SetHtCapabilities (GetHtCapabilities ());
434  hdr.SetNoOrder ();
435  }
436  if (m_vhtSupported)
437  {
438  probe.SetVhtCapabilities (GetVhtCapabilities ());
439  }
440  packet->AddHeader (probe);
441 
442  //The standard is not clear on the correct queue for management
443  //frames if we are a QoS AP. The approach taken here is to always
444  //use the DCF for these regardless of whether we have a QoS
445  //association or not.
446  m_dca->Queue (packet, hdr);
447 }
448 
449 void
451 {
452  NS_LOG_FUNCTION (this << to << success);
453  WifiMacHeader hdr;
454  hdr.SetAssocResp ();
455  hdr.SetAddr1 (to);
456  hdr.SetAddr2 (GetAddress ());
457  hdr.SetAddr3 (GetAddress ());
458  hdr.SetDsNotFrom ();
459  hdr.SetDsNotTo ();
460  Ptr<Packet> packet = Create<Packet> ();
462  StatusCode code;
463  if (success)
464  {
465  code.SetSuccess ();
466  }
467  else
468  {
469  code.SetFailure ();
470  }
471  assoc.SetSupportedRates (GetSupportedRates ());
472  assoc.SetStatusCode (code);
473  assoc.SetCapabilities (GetCapabilities ());
475  {
476  assoc.SetHtCapabilities (GetHtCapabilities ());
477  hdr.SetNoOrder ();
478  }
479  if (m_vhtSupported)
480  {
481  assoc.SetVhtCapabilities (GetVhtCapabilities ());
482  }
483  packet->AddHeader (assoc);
484 
485  //The standard is not clear on the correct queue for management
486  //frames if we are a QoS AP. The approach taken here is to always
487  //use the DCF for these regardless of whether we have a QoS
488  //association or not.
489  m_dca->Queue (packet, hdr);
490 }
491 
492 void
494 {
495  NS_LOG_FUNCTION (this);
496  WifiMacHeader hdr;
497  hdr.SetBeacon ();
499  hdr.SetAddr2 (GetAddress ());
500  hdr.SetAddr3 (GetAddress ());
501  hdr.SetDsNotFrom ();
502  hdr.SetDsNotTo ();
503  Ptr<Packet> packet = Create<Packet> ();
504  MgtBeaconHeader beacon;
505  beacon.SetSsid (GetSsid ());
506  beacon.SetSupportedRates (GetSupportedRates ());
507  beacon.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
508  beacon.SetCapabilities (GetCapabilities ());
510  {
511  beacon.SetHtCapabilities (GetHtCapabilities ());
512  hdr.SetNoOrder ();
513  }
514  if (m_vhtSupported)
515  {
516  beacon.SetVhtCapabilities (GetVhtCapabilities ());
517  }
518  packet->AddHeader (beacon);
519 
520  //The beacon has it's own special queue, so we load it in there
521  m_beaconDca->Queue (packet, hdr);
523 }
524 
525 void
527 {
528  NS_LOG_FUNCTION (this);
529  RegularWifiMac::TxOk (hdr);
530 
531  if (hdr.IsAssocResp ()
533  {
534  NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
536  }
537 }
538 
539 void
541 {
542  NS_LOG_FUNCTION (this);
544 
545  if (hdr.IsAssocResp ()
547  {
548  NS_LOG_DEBUG ("assoc failed with sta=" << hdr.GetAddr1 ());
550  }
551 }
552 
553 void
555 {
556  NS_LOG_FUNCTION (this << packet << hdr);
557 
558  Mac48Address from = hdr->GetAddr2 ();
559 
560  if (hdr->IsData ())
561  {
562  Mac48Address bssid = hdr->GetAddr1 ();
563  if (!hdr->IsFromDs ()
564  && hdr->IsToDs ()
565  && bssid == GetAddress ()
566  && m_stationManager->IsAssociated (from))
567  {
568  Mac48Address to = hdr->GetAddr3 ();
569  if (to == GetAddress ())
570  {
571  NS_LOG_DEBUG ("frame for me from=" << from);
572  if (hdr->IsQosData ())
573  {
574  if (hdr->IsQosAmsdu ())
575  {
576  NS_LOG_DEBUG ("Received A-MSDU from=" << from << ", size=" << packet->GetSize ());
577  DeaggregateAmsduAndForward (packet, hdr);
578  packet = 0;
579  }
580  else
581  {
582  ForwardUp (packet, from, bssid);
583  }
584  }
585  else
586  {
587  ForwardUp (packet, from, bssid);
588  }
589  }
590  else if (to.IsGroup ()
592  {
593  NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to);
594  Ptr<Packet> copy = packet->Copy ();
595 
596  //If the frame we are forwarding is of type QoS Data,
597  //then we need to preserve the UP in the QoS control
598  //header...
599  if (hdr->IsQosData ())
600  {
601  ForwardDown (packet, from, to, hdr->GetQosTid ());
602  }
603  else
604  {
605  ForwardDown (packet, from, to);
606  }
607  ForwardUp (copy, from, to);
608  }
609  else
610  {
611  ForwardUp (packet, from, to);
612  }
613  }
614  else if (hdr->IsFromDs ()
615  && hdr->IsToDs ())
616  {
617  //this is an AP-to-AP frame
618  //we ignore for now.
619  NotifyRxDrop (packet);
620  }
621  else
622  {
623  //we can ignore these frames since
624  //they are not targeted at the AP
625  NotifyRxDrop (packet);
626  }
627  return;
628  }
629  else if (hdr->IsMgt ())
630  {
631  if (hdr->IsProbeReq ())
632  {
633  NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ());
634  SendProbeResp (from);
635  return;
636  }
637  else if (hdr->GetAddr1 () == GetAddress ())
638  {
639  if (hdr->IsAssocReq ())
640  {
641  //first, verify that the the station's supported
642  //rate set is compatible with our Basic Rate set
643  MgtAssocRequestHeader assocReq;
644  packet->RemoveHeader (assocReq);
645  CapabilityInformation capabilities = assocReq.GetCapabilities ();
647  SupportedRates rates = assocReq.GetSupportedRates ();
648  bool problem = false;
649  for (uint32_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
650  {
652  if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1)))
653  {
654  problem = true;
655  break;
656  }
657  }
658  if (m_htSupported)
659  {
660  //check that the STA supports all MCSs in Basic MCS Set
661  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
662  for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
663  {
665  if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
666  {
667  problem = true;
668  break;
669  }
670  }
671  }
672  if (m_vhtSupported)
673  {
674  //check that the STA supports all MCSs in Basic MCS Set
675  VhtCapabilities vhtcapabilities = assocReq.GetVhtCapabilities ();
676  for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
677  {
679  if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
680  {
681  problem = true;
682  break;
683  }
684  }
685  }
686  if (problem)
687  {
688  //One of the Basic Rate set mode is not
689  //supported by the station. So, we return an assoc
690  //response with an error status.
691  SendAssocResp (hdr->GetAddr2 (), false);
692  }
693  else
694  {
695  //station supports all rates in Basic Rate Set.
696  //record all its supported modes in its associated WifiRemoteStation
697  for (uint32_t j = 0; j < m_phy->GetNModes (); j++)
698  {
699  WifiMode mode = m_phy->GetMode (j);
700  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1)))
701  {
702  m_stationManager->AddSupportedMode (from, mode);
703  }
704  }
705  if (m_htSupported)
706  {
707  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
708  m_stationManager->AddStationHtCapabilities (from,htcapabilities);
709  for (uint32_t j = 0; j < m_phy->GetNMcs (); j++)
710  {
711  WifiMode mcs = m_phy->GetMcs (j);
712  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
713  {
714  m_stationManager->AddSupportedMcs (from, mcs);
715  }
716  }
717  }
718  if (m_vhtSupported)
719  {
720  VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilities ();
721  m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities);
722  for (uint32_t i = 0; i < m_phy->GetNMcs (); i++)
723  {
724  WifiMode mcs = m_phy->GetMcs (i);
725  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
726  {
727  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
728  //here should add a control to add basic MCS when it is implemented
729  }
730  }
731  }
733  // send assoc response with success status.
734  SendAssocResp (hdr->GetAddr2 (), true);
735  }
736  return;
737  }
738  else if (hdr->IsDisassociation ())
739  {
741  return;
742  }
743  }
744  }
745 
746  //Invoke the receive handler of our parent class to deal with any
747  //other frames. Specifically, this will handle Block Ack-related
748  //Management Action frames.
749  RegularWifiMac::Receive (packet, hdr);
750 }
751 
752 void
754  const WifiMacHeader *hdr)
755 {
756  NS_LOG_FUNCTION (this << aggregatedPacket << hdr);
758  MsduAggregator::Deaggregate (aggregatedPacket);
759 
760  for (MsduAggregator::DeaggregatedMsdusCI i = packets.begin ();
761  i != packets.end (); ++i)
762  {
763  if ((*i).second.GetDestinationAddr () == GetAddress ())
764  {
765  ForwardUp ((*i).first, (*i).second.GetSourceAddr (),
766  (*i).second.GetDestinationAddr ());
767  }
768  else
769  {
770  Mac48Address from = (*i).second.GetSourceAddr ();
771  Mac48Address to = (*i).second.GetDestinationAddr ();
772  NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
773  ForwardDown ((*i).first, from, to, hdr->GetQosTid ());
774  }
775  }
776 }
777 
778 void
780 {
781  NS_LOG_FUNCTION (this);
782  m_beaconDca->Initialize ();
785  {
787  {
788  int64_t jitter = m_beaconJitter->GetValue (0, m_beaconInterval.GetMicroSeconds ());
789  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time " << jitter << " microseconds");
791  }
792  else
793  {
794  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time 0");
796  }
797  }
799 }
800 
801 } //namespace ns3
virtual void DoInitialize(void)
Initialize() implementation.
Definition: ap-wifi-mac.cc:779
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:266
virtual uint32_t GetNumberOfTransmitAntennas(void) const =0
void SetTxMcsSetDefined(uint8_t txmcssetdefined)
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:168
void SetShortGuardIntervalFor80Mhz(uint8_t shortguardinterval)
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
bool IsSupportedTxMcs(uint8_t mcs) const
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
Implement the header for management frames of type association request.
Definition: mgt-headers.h:42
#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:346
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)
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capability of the current AP.
Definition: ap-wifi-mac.cc:379
Hold variables of type string.
Definition: string.h:41
void SetTxMcsMap(uint16_t map)
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
void SetMaxMpduLength(uint8_t length)
EdcaQueues m_edca
This is a map from Access Category index to the corresponding channel access function.
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
enum WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:375
virtual uint8_t GetNMcs(void) const =0
The WifiPhy::GetNMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of t...
#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:786
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:283
virtual bool GetLdpc(void) const =0
void SendAssocResp(Mac48Address to, bool success)
Forward an association response packet to the DCF.
Definition: ap-wifi-mac.cc:450
virtual bool SupportsSendFrom(void) const
Definition: ap-wifi-mac.cc:291
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
VHT PHY (Clause 22)
Definition: wifi-mode.h:62
void SetVhtSupported(uint8_t vhtsupported)
Ptr< WifiPhy > m_phy
Wifi PHY.
void SetRxLdpc(uint8_t rxldpc)
Ptr< DcaTxop > m_beaconDca
Dedicated DcaTxop for beacons.
Definition: ap-wifi-mac.h:225
HR/DSSS PHY (Clause 18)
Definition: wifi-mode.h:50
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:97
bool IsMandatory(void) const
Definition: wifi-mode.cc:346
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
Capability information.
virtual void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
void SetShortGuardIntervalFor160Mhz(uint8_t shortguardinterval)
virtual WifiMode GetMcs(uint8_t mcs) const =0
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a qos tag is attached to the packet, returns a value < 8.
Definition: qos-utils.cc:62
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:227
virtual void Enqueue(Ptr< const Packet > packet, Mac48Address to)
Definition: ap-wifi-mac.cc:281
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:421
virtual void SetBssid(Mac48Address bssid)
void SetLSigProtectionSupport(uint8_t lsigprotection)
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 uint32_t GetChannelWidth(void) const =0
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:32
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:220
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1216
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:349
void SetShortGuardInterval20(uint8_t shortguardinterval)
void SetBeacon(void)
Set Type/Subtype values for a beacon header.
AttributeValue implementation for Time.
Definition: nstime.h:957
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...
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:385
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
The IEEE 802.11ac VHT Capabilities.
static TypeId GetTypeId(void)
Definition: ap-wifi-mac.cc:47
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.
void SetMaxAmsduLength(uint8_t maxamsdulength)
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.
bool m_vhtSupported
This Boolean is set true iff this WifiMac is to model 802.11ac.
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Definition: qos-utils.cc:28
virtual void SetAddress(Mac48Address address)
HT PHY (Clause 20)
Definition: wifi-mode.h:60
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:353
static Mac48Address GetBroadcast(void)
void SetMaxAmpduLength(uint8_t maxampdulength)
bool IsSupportedMcs(uint8_t mcs)
EventId m_beaconEvent
Event to generate one beacon.
Definition: ap-wifi-mac.h:228
virtual bool GetGuardInterval(void) const =0
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:624
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.
void SetSupportedChannelWidthSet(uint8_t channelwidthset)
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:554
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:753
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
void SetRxHighestSupportedDataRate(uint16_t maxsupportedrate)
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:33
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:225
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.
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:409
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)
Get the next random value, as a double in the specified range .
an EUI-48 address
Definition: mac48-address.h:43
WifiMode GetBasicMcs(uint32_t i) const
Return the MCS at the given list index.
uint64_t GetDataRate(uint32_t channelWidth, bool isShortGuardInterval, uint8_t nss) const
Definition: wifi-mode.cc:100
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:1379
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:958
bool GetBeaconGeneration(void) const
Return whether the AP is generating beacons.
Definition: ap-wifi-mac.cc:134
void SetShortPreamble(bool shortPreamble)
Set the short preamble bit in the capability information field.
Wi-Fi AP state machineHandle association, dis-association and authentication, of STAs within an infra...
Definition: ap-wifi-mac.h:43
void AddSupportedPlcpPreamble(Mac48Address address, bool isShortPreambleSupported)
Record whether the short PLCP preamble is supported by the station.
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:147
void SendProbeResp(Mac48Address to)
Forward a probe response packet to the DCF.
Definition: ap-wifi-mac.cc:415
virtual bool GetShortPlcpPreamble(void) const =0
void SetAssocResp(void)
Set Type/Subtype values for an association response header.
void SetRxMcsMap(uint16_t map)
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates...
Definition: ap-wifi-mac.cc:298
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:540
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:493
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
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:229
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current AP.
Definition: ap-wifi-mac.cc:338
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
Time m_beaconInterval
Interval between beacons.
Definition: ap-wifi-mac.h:226
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:911
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:230
Time GetBeaconInterval(void) const
Definition: ap-wifi-mac.cc:141
void SetTxMaxNSpatialStreams(uint8_t maxtxspatialstreams)
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:526
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:318
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:38
void SetShortGuardInterval40(uint8_t shortguardinterval)
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:397
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:826
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:429
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:255
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtcapabilities)
Records VHT capabilities of the remote station.
Implements the IEEE 802.11 MAC header.
void SetSupportedChannelWidth(uint8_t supportedchannelwidth)
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
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.
bool IsShortPreamble(void) const
Check if the short preamble bit in the capability information field is set to 1.
void SetMaxAmpduLengthExponent(uint8_t exponent)