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  HtCapabilities capabilities;
341  capabilities.SetHtSupported (1);
342  if (m_htSupported)
343  {
344  capabilities.SetLdpc (m_phy->GetLdpc ());
345  capabilities.SetSupportedChannelWidth (m_phy->GetChannelWidth () == 40);
347  capabilities.SetShortGuardInterval40 (m_phy->GetChannelWidth () == 40 && m_phy->GetGuardInterval ());
348  capabilities.SetGreenfield (m_phy->GetGreenfield ());
349  capabilities.SetMaxAmsduLength (1); //hardcoded for now (TBD)
350  capabilities.SetLSigProtectionSupport (!m_phy->GetGreenfield ());
351  capabilities.SetMaxAmpduLength (3); //hardcoded for now (TBD)
352  uint64_t maxSupportedRate = 0; //in bit/s
353  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
354  {
355  WifiMode mcs = m_phy->GetMcs (i);
356  capabilities.SetRxMcsBitmask (mcs.GetMcsValue ());
357  if (mcs.GetDataRate (m_phy->GetGuardInterval (), m_phy->GetGuardInterval (), 1) > maxSupportedRate)
358  {
359  maxSupportedRate = mcs.GetDataRate (m_phy->GetGuardInterval (), m_phy->GetGuardInterval (), 1);
360  }
361  }
362  capabilities.SetRxHighestSupportedDataRate (maxSupportedRate / 1e6); //in Mbit/s
363  capabilities.SetTxMcsSetDefined (m_phy->GetNMcs () > 0);
365  }
366  return capabilities;
367 }
368 
371 {
372  VhtCapabilities capabilities;
373  capabilities.SetVhtSupported (1);
374  if (m_vhtSupported)
375  {
376  if (m_phy->GetChannelWidth () == 160)
377  {
378  capabilities.SetSupportedChannelWidthSet (1);
379  }
380  else
381  {
382  capabilities.SetSupportedChannelWidthSet (0);
383  }
384  capabilities.SetMaxMpduLength (2); //hardcoded for now (TBD)
385  capabilities.SetRxLdpc (m_phy->GetLdpc ());
388  capabilities.SetMaxAmpduLengthExponent (7); //hardcoded for now (TBD)
389  uint8_t maxMcs = 0;
390  for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
391  {
392  WifiMode mcs = m_phy->GetMcs (i);
393  if (mcs.GetMcsValue () > maxMcs)
394  {
395  maxMcs = mcs.GetMcsValue ();
396  }
397  }
398  capabilities.SetRxMcsMap (maxMcs, 1); //Only 1 SS is currently supported
399  capabilities.SetTxMcsMap (maxMcs, 1); //Only 1 SS is currently supported
400  }
401  return capabilities;
402 }
403 
404 void
406 {
407  NS_LOG_FUNCTION (this << to);
408  WifiMacHeader hdr;
409  hdr.SetProbeResp ();
410  hdr.SetAddr1 (to);
411  hdr.SetAddr2 (GetAddress ());
412  hdr.SetAddr3 (GetAddress ());
413  hdr.SetDsNotFrom ();
414  hdr.SetDsNotTo ();
415  Ptr<Packet> packet = Create<Packet> ();
417  probe.SetSsid (GetSsid ());
418  probe.SetSupportedRates (GetSupportedRates ());
419  probe.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
421  {
422  probe.SetHtCapabilities (GetHtCapabilities ());
423  hdr.SetNoOrder ();
424  }
425  if (m_vhtSupported)
426  {
427  probe.SetVhtCapabilities (GetVhtCapabilities ());
428  }
429  packet->AddHeader (probe);
430 
431  //The standard is not clear on the correct queue for management
432  //frames if we are a QoS AP. The approach taken here is to always
433  //use the DCF for these regardless of whether we have a QoS
434  //association or not.
435  m_dca->Queue (packet, hdr);
436 }
437 
438 void
440 {
441  NS_LOG_FUNCTION (this << to << success);
442  WifiMacHeader hdr;
443  hdr.SetAssocResp ();
444  hdr.SetAddr1 (to);
445  hdr.SetAddr2 (GetAddress ());
446  hdr.SetAddr3 (GetAddress ());
447  hdr.SetDsNotFrom ();
448  hdr.SetDsNotTo ();
449  Ptr<Packet> packet = Create<Packet> ();
451  StatusCode code;
452  if (success)
453  {
454  code.SetSuccess ();
455  }
456  else
457  {
458  code.SetFailure ();
459  }
460  assoc.SetSupportedRates (GetSupportedRates ());
461  assoc.SetStatusCode (code);
462 
464  {
465  assoc.SetHtCapabilities (GetHtCapabilities ());
466  hdr.SetNoOrder ();
467  }
468  if (m_vhtSupported)
469  {
470  assoc.SetVhtCapabilities (GetVhtCapabilities ());
471  }
472  packet->AddHeader (assoc);
473 
474  //The standard is not clear on the correct queue for management
475  //frames if we are a QoS AP. The approach taken here is to always
476  //use the DCF for these regardless of whether we have a QoS
477  //association or not.
478  m_dca->Queue (packet, hdr);
479 }
480 
481 void
483 {
484  NS_LOG_FUNCTION (this);
485  WifiMacHeader hdr;
486  hdr.SetBeacon ();
488  hdr.SetAddr2 (GetAddress ());
489  hdr.SetAddr3 (GetAddress ());
490  hdr.SetDsNotFrom ();
491  hdr.SetDsNotTo ();
492  Ptr<Packet> packet = Create<Packet> ();
493  MgtBeaconHeader beacon;
494  beacon.SetSsid (GetSsid ());
495  beacon.SetSupportedRates (GetSupportedRates ());
496  beacon.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
498  {
499  beacon.SetHtCapabilities (GetHtCapabilities ());
500  hdr.SetNoOrder ();
501  }
502  if (m_vhtSupported)
503  {
504  beacon.SetVhtCapabilities (GetVhtCapabilities ());
505  }
506  packet->AddHeader (beacon);
507 
508  //The beacon has it's own special queue, so we load it in there
509  m_beaconDca->Queue (packet, hdr);
511 }
512 
513 void
515 {
516  NS_LOG_FUNCTION (this);
517  RegularWifiMac::TxOk (hdr);
518 
519  if (hdr.IsAssocResp ()
521  {
522  NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
524  }
525 }
526 
527 void
529 {
530  NS_LOG_FUNCTION (this);
532 
533  if (hdr.IsAssocResp ()
535  {
536  NS_LOG_DEBUG ("assoc failed with sta=" << hdr.GetAddr1 ());
538  }
539 }
540 
541 void
543 {
544  NS_LOG_FUNCTION (this << packet << hdr);
545 
546  Mac48Address from = hdr->GetAddr2 ();
547 
548  if (hdr->IsData ())
549  {
550  Mac48Address bssid = hdr->GetAddr1 ();
551  if (!hdr->IsFromDs ()
552  && hdr->IsToDs ()
553  && bssid == GetAddress ()
554  && m_stationManager->IsAssociated (from))
555  {
556  Mac48Address to = hdr->GetAddr3 ();
557  if (to == GetAddress ())
558  {
559  NS_LOG_DEBUG ("frame for me from=" << from);
560  if (hdr->IsQosData ())
561  {
562  if (hdr->IsQosAmsdu ())
563  {
564  NS_LOG_DEBUG ("Received A-MSDU from=" << from << ", size=" << packet->GetSize ());
565  DeaggregateAmsduAndForward (packet, hdr);
566  packet = 0;
567  }
568  else
569  {
570  ForwardUp (packet, from, bssid);
571  }
572  }
573  else
574  {
575  ForwardUp (packet, from, bssid);
576  }
577  }
578  else if (to.IsGroup ()
580  {
581  NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to);
582  Ptr<Packet> copy = packet->Copy ();
583 
584  //If the frame we are forwarding is of type QoS Data,
585  //then we need to preserve the UP in the QoS control
586  //header...
587  if (hdr->IsQosData ())
588  {
589  ForwardDown (packet, from, to, hdr->GetQosTid ());
590  }
591  else
592  {
593  ForwardDown (packet, from, to);
594  }
595  ForwardUp (copy, from, to);
596  }
597  else
598  {
599  ForwardUp (packet, from, to);
600  }
601  }
602  else if (hdr->IsFromDs ()
603  && hdr->IsToDs ())
604  {
605  //this is an AP-to-AP frame
606  //we ignore for now.
607  NotifyRxDrop (packet);
608  }
609  else
610  {
611  //we can ignore these frames since
612  //they are not targeted at the AP
613  NotifyRxDrop (packet);
614  }
615  return;
616  }
617  else if (hdr->IsMgt ())
618  {
619  if (hdr->IsProbeReq ())
620  {
621  NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ());
622  SendProbeResp (from);
623  return;
624  }
625  else if (hdr->GetAddr1 () == GetAddress ())
626  {
627  if (hdr->IsAssocReq ())
628  {
629  //first, verify that the the station's supported
630  //rate set is compatible with our Basic Rate set
631  MgtAssocRequestHeader assocReq;
632  packet->RemoveHeader (assocReq);
633  SupportedRates rates = assocReq.GetSupportedRates ();
634  bool problem = false;
635  for (uint32_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
636  {
638  if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1)))
639  {
640  problem = true;
641  break;
642  }
643  }
644  if (m_htSupported)
645  {
646  //check that the STA supports all MCSs in Basic MCS Set
647  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
648  for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
649  {
651  if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
652  {
653  problem = true;
654  break;
655  }
656  }
657  }
658  if (m_vhtSupported)
659  {
660  //check that the STA supports all MCSs in Basic MCS Set
661  VhtCapabilities vhtcapabilities = assocReq.GetVhtCapabilities ();
662  for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
663  {
665  if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
666  {
667  problem = true;
668  break;
669  }
670  }
671  }
672  if (problem)
673  {
674  //One of the Basic Rate set mode is not
675  //supported by the station. So, we return an assoc
676  //response with an error status.
677  SendAssocResp (hdr->GetAddr2 (), false);
678  }
679  else
680  {
681  //station supports all rates in Basic Rate Set.
682  //record all its supported modes in its associated WifiRemoteStation
683  for (uint32_t j = 0; j < m_phy->GetNModes (); j++)
684  {
685  WifiMode mode = m_phy->GetMode (j);
686  if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1)))
687  {
688  m_stationManager->AddSupportedMode (from, mode);
689  }
690  }
691  if (m_htSupported)
692  {
693  HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
694  m_stationManager->AddStationHtCapabilities (from,htcapabilities);
695  for (uint32_t j = 0; j < m_phy->GetNMcs (); j++)
696  {
697  WifiMode mcs = m_phy->GetMcs (j);
698  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
699  {
700  m_stationManager->AddSupportedMcs (from, mcs);
701  }
702  }
703  }
704  if (m_vhtSupported)
705  {
706  VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilities ();
707  m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities);
708  for (uint32_t i = 0; i < m_phy->GetNMcs (); i++)
709  {
710  WifiMode mcs = m_phy->GetMcs (i);
711  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
712  {
713  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
714  //here should add a control to add basic MCS when it is implemented
715  }
716  }
717  }
719  // send assoc response with success status.
720  SendAssocResp (hdr->GetAddr2 (), true);
721  }
722  return;
723  }
724  else if (hdr->IsDisassociation ())
725  {
727  return;
728  }
729  }
730  }
731 
732  //Invoke the receive handler of our parent class to deal with any
733  //other frames. Specifically, this will handle Block Ack-related
734  //Management Action frames.
735  RegularWifiMac::Receive (packet, hdr);
736 }
737 
738 void
740  const WifiMacHeader *hdr)
741 {
742  NS_LOG_FUNCTION (this << aggregatedPacket << hdr);
744  MsduAggregator::Deaggregate (aggregatedPacket);
745 
746  for (MsduAggregator::DeaggregatedMsdusCI i = packets.begin ();
747  i != packets.end (); ++i)
748  {
749  if ((*i).second.GetDestinationAddr () == GetAddress ())
750  {
751  ForwardUp ((*i).first, (*i).second.GetSourceAddr (),
752  (*i).second.GetDestinationAddr ());
753  }
754  else
755  {
756  Mac48Address from = (*i).second.GetSourceAddr ();
757  Mac48Address to = (*i).second.GetDestinationAddr ();
758  NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
759  ForwardDown ((*i).first, from, to, hdr->GetQosTid ());
760  }
761  }
762 }
763 
764 void
766 {
767  NS_LOG_FUNCTION (this);
768  m_beaconDca->Initialize ();
771  {
773  {
774  int64_t jitter = m_beaconJitter->GetValue (0, m_beaconInterval.GetMicroSeconds ());
775  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time " << jitter << " microseconds");
777  }
778  else
779  {
780  NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time 0");
782  }
783  }
785 }
786 
787 } //namespace ns3
virtual void DoInitialize(void)
Initialize() implementation.
Definition: ap-wifi-mac.cc:765
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:43
#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:338
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:370
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:439
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:218
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.
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:220
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:397
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...
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:221
virtual bool GetGuardInterval(void) const =0
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:625
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:542
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:739
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:213
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:379
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
Wi-Fi AP state machineHandle association, dis-association and authentication, of STAs within an infra...
Definition: ap-wifi-mac.h:42
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:138
void SendProbeResp(Mac48Address to)
Forward a probe response packet to the DCF.
Definition: ap-wifi-mac.cc:405
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:528
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:482
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:222
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
Time m_beaconInterval
Interval between beacons.
Definition: ap-wifi-mac.h:219
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:223
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:514
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:297
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:385
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:396
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.
void SetMaxAmpduLengthExponent(uint8_t exponent)