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 "ns3/log.h"
24#include "ns3/packet.h"
25#include "ns3/simulator.h"
26#include "ns3/pointer.h"
27#include "ns3/string.h"
28#include "ns3/random-variable-stream.h"
29#include "ap-wifi-mac.h"
31#include "mac-tx-middle.h"
32#include "mac-rx-middle.h"
33#include "mgt-headers.h"
34#include "msdu-aggregator.h"
36#include "wifi-phy.h"
37#include "wifi-net-device.h"
38#include "wifi-mac-queue.h"
39#include "ns3/ht-configuration.h"
40#include "ns3/he-configuration.h"
41#include "qos-txop.h"
42
43namespace ns3 {
44
45NS_LOG_COMPONENT_DEFINE ("ApWifiMac");
46
48
49TypeId
51{
52 static TypeId tid = TypeId ("ns3::ApWifiMac")
54 .SetGroupName ("Wifi")
55 .AddConstructor<ApWifiMac> ()
56 .AddAttribute ("BeaconInterval",
57 "Delay between two beacons",
58 TimeValue (MicroSeconds (102400)),
62 .AddAttribute ("BeaconJitter",
63 "A uniform random variable to cause the initial beacon starting time (after simulation time 0) "
64 "to be distributed between 0 and the BeaconInterval.",
65 StringValue ("ns3::UniformRandomVariable"),
67 MakePointerChecker<UniformRandomVariable> ())
68 .AddAttribute ("EnableBeaconJitter",
69 "If beacons are enabled, whether to jitter the initial send event.",
70 BooleanValue (true),
73 .AddAttribute ("BeaconGeneration",
74 "Whether or not beacons are generated.",
75 BooleanValue (true),
78 .AddAttribute ("EnableNonErpProtection", "Whether or not protection mechanism should be used when non-ERP STAs are present within the BSS."
79 "This parameter is only used when ERP is supported by the AP.",
80 BooleanValue (true),
83 .AddAttribute ("BsrLifetime",
84 "Lifetime of Buffer Status Reports received from stations.",
88 .AddTraceSource ("AssociatedSta",
89 "A station associated with this access point.",
91 "ns3::ApWifiMac::AssociationCallback")
92 .AddTraceSource ("DeAssociatedSta",
93 "A station lost association with this access point.",
95 "ns3::ApWifiMac::AssociationCallback")
96 ;
97 return tid;
98}
99
101 : m_enableBeaconGeneration (false),
102 m_numNonErpStations (0),
103 m_numNonHtStations (0),
104 m_shortSlotTimeEnabled (false),
105 m_shortPreambleEnabled (false)
106{
107 NS_LOG_FUNCTION (this);
108 m_beaconTxop = CreateObject<Txop> (CreateObject<WifiMacQueue> (AC_BEACON));
109 m_beaconTxop->SetWifiMac (this);
115
116 //Let the lower layers know that we are acting as an AP.
118}
119
121{
122 NS_LOG_FUNCTION (this);
123 m_staList.clear ();
124}
125
126void
128{
129 NS_LOG_FUNCTION (this);
131 m_beaconTxop = 0;
135}
136
137void
139{
140 NS_LOG_FUNCTION (this << address);
141 //As an AP, our MAC address is also the BSSID. Hence we are
142 //overriding this function and setting both in our parent class.
145}
146
149{
150 if (ac == AC_BEACON)
151 {
152 return m_beaconTxop->GetWifiMacQueue ();
153 }
154 return WifiMac::GetTxopQueue (ac);
155}
156
157void
159{
160 NS_LOG_FUNCTION (this << enable);
161 if (!enable)
162 {
164 }
165 else if (enable && !m_enableBeaconGeneration)
166 {
168 }
170}
171
172Time
174{
175 NS_LOG_FUNCTION (this);
176 return m_beaconInterval;
177}
178
179void
181{
182 NS_LOG_FUNCTION (this << &linkUp);
184
185 //The approach taken here is that, from the point of view of an AP,
186 //the link is always up, so we immediately invoke the callback if
187 //one is set
188 linkUp ();
189}
190
191void
193{
194 NS_LOG_FUNCTION (this << interval);
195 if ((interval.GetMicroSeconds () % 1024) != 0)
196 {
197 NS_FATAL_ERROR ("beacon interval should be multiple of 1024us (802.11 time unit), see IEEE Std. 802.11-2012");
198 }
199 if (interval.GetMicroSeconds () > (1024 * 65535))
200 {
201 NS_FATAL_ERROR ("beacon interval should be smaller then or equal to 65535 * 1024us (802.11 time unit)");
202 }
203 m_beaconInterval = interval;
204}
205
206int64_t
208{
209 NS_LOG_FUNCTION (this << stream);
210 m_beaconJitter->SetStream (stream);
211 return 1;
212}
213
214void
216{
217 NS_LOG_FUNCTION (this);
219 {
220 for (const auto& sta : m_staList)
221 {
223 {
225 return;
226 }
227 }
229 }
230 else
231 {
233 }
234}
235
236void
238{
239 NS_LOG_FUNCTION (this);
240 if (GetErpSupported () && GetWifiPhy ()->GetShortPhyPreambleSupported ())
241 {
242 for (const auto& sta : m_staList)
243 {
244 if (!GetWifiRemoteStationManager ()->GetErpOfdmSupported (sta.second) ||
245 !GetWifiRemoteStationManager ()->GetShortPreambleSupported (sta.second))
246 {
248 return;
249 }
250 }
252 }
253 else
254 {
256 }
257}
258
259uint16_t
261{
262 uint16_t channelWidth = GetWifiPhy ()->GetChannelWidth ();
263 for (const auto& sta : m_staList)
264 {
265 if (GetWifiRemoteStationManager ()->GetVhtSupported (sta.second))
266 {
267 if (GetWifiRemoteStationManager ()->GetChannelWidthSupported (sta.second) < channelWidth)
268 {
269 channelWidth = GetWifiRemoteStationManager ()->GetChannelWidthSupported (sta.second);
270 }
271 }
272 }
273 return channelWidth;
274}
275
276void
278 Mac48Address to)
279{
280 NS_LOG_FUNCTION (this << packet << from << to);
281 //If we are not a QoS AP then we definitely want to use AC_BE to
282 //transmit the packet. A TID of zero will map to AC_BE (through \c
283 //QosUtilsMapTidToAc()), so we use that as our default here.
284 uint8_t tid = 0;
285
286 //If we are a QoS AP then we attempt to get a TID for this packet
287 if (GetQosSupported ())
288 {
289 tid = QosUtilsGetTidForPacket (packet);
290 //Any value greater than 7 is invalid and likely indicates that
291 //the packet had no QoS tag, so we revert to zero, which'll
292 //mean that AC_BE is used.
293 if (tid > 7)
294 {
295 tid = 0;
296 }
297 }
298
299 ForwardDown (packet, from, to, tid);
300}
301
302void
304 Mac48Address to, uint8_t tid)
305{
306 NS_LOG_FUNCTION (this << packet << from << to << +tid);
307 WifiMacHeader hdr;
308
309 //For now, an AP that supports QoS does not support non-QoS
310 //associations, and vice versa. In future the AP model should
311 //support simultaneously associated QoS and non-QoS STAs, at which
312 //point there will need to be per-association QoS state maintained
313 //by the association state machine, and consulted here.
314 if (GetQosSupported ())
315 {
318 hdr.SetQosNoEosp ();
319 hdr.SetQosNoAmsdu ();
320 //Transmission of multiple frames in the same Polled TXOP is not supported for now
321 hdr.SetQosTxopLimit (0);
322 //Fill in the QoS control field in the MAC header
323 hdr.SetQosTid (tid);
324 }
325 else
326 {
328 }
329
330 if (GetQosSupported ())
331 {
332 hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT control field is not yet implemented (set it to 1 when implemented)
333 }
334 hdr.SetAddr1 (to);
335 hdr.SetAddr2 (GetAddress ());
336 hdr.SetAddr3 (from);
337 hdr.SetDsFrom ();
338 hdr.SetDsNotTo ();
339
340 if (GetQosSupported ())
341 {
342 //Sanity check that the TID is valid
343 NS_ASSERT (tid < 8);
344 GetQosTxop (tid)->Queue (packet, hdr);
345 }
346 else
347 {
348 GetTxop ()->Queue (packet, hdr);
349 }
350}
351
352bool
354{
355 return (to.IsGroup () || GetWifiRemoteStationManager ()->IsAssociated (to));
356}
357
358void
360{
361 NS_LOG_FUNCTION (this << packet << to << from);
362 if (CanForwardPacketsTo (to))
363 {
364 ForwardDown (packet, from, to);
365 }
366 else
367 {
368 NotifyTxDrop (packet);
369 }
370}
371
372void
374{
375 NS_LOG_FUNCTION (this << packet << to);
376 //We're sending this packet with a from address that is our own. We
377 //get that address from the lower MAC and make use of the
378 //from-spoofing Enqueue() method to avoid duplicated code.
379 Enqueue (packet, to, GetAddress ());
380}
381
382bool
384{
385 NS_LOG_FUNCTION (this);
386 return true;
387}
388
391{
392 NS_LOG_FUNCTION (this);
393 SupportedRates rates;
394 //Send the set of supported rates and make sure that we indicate
395 //the Basic Rate set in this set of supported rates.
396 for (const auto & mode : GetWifiPhy ()->GetModeList ())
397 {
398 uint64_t modeDataRate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ());
399 NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
400 rates.AddSupportedRate (modeDataRate);
401 //Add rates that are part of the BSSBasicRateSet (manufacturer dependent!)
402 //here we choose to add the mandatory rates to the BSSBasicRateSet,
403 //except for 802.11b where we assume that only the non HR-DSSS rates are part of the BSSBasicRateSet
404 if (mode.IsMandatory () && (mode.GetModulationClass () != WIFI_MOD_CLASS_HR_DSSS))
405 {
406 NS_LOG_DEBUG ("Adding basic mode " << mode.GetUniqueName ());
408 }
409 }
410 //set the basic rates
411 for (uint8_t j = 0; j < GetWifiRemoteStationManager ()->GetNBasicModes (); j++)
412 {
414 uint64_t modeDataRate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ());
415 NS_LOG_DEBUG ("Setting basic rate " << mode.GetUniqueName ());
416 rates.SetBasicRate (modeDataRate);
417 }
418 //If it is a HT AP, then add the BSSMembershipSelectorSet
419 //The standard says that the BSSMembershipSelectorSet
420 //must have its MSB set to 1 (must be treated as a Basic Rate)
421 //Also the standard mentioned that at least 1 element should be included in the SupportedRates the rest can be in the ExtendedSupportedRates
422 if (GetHtSupported ())
423 {
424 for (const auto & selector : GetWifiPhy ()->GetBssMembershipSelectorList ())
425 {
426 rates.AddBssMembershipSelectorRate (selector);
427 }
428 }
429 return rates;
430}
431
434{
435 NS_LOG_FUNCTION (this);
436 DsssParameterSet dsssParameters;
437 if (GetDsssSupported ())
438 {
439 dsssParameters.SetDsssSupported (1);
440 dsssParameters.SetCurrentChannel (GetWifiPhy ()->GetChannelNumber ());
441 }
442 return dsssParameters;
443}
444
447{
448 NS_LOG_FUNCTION (this);
449 CapabilityInformation capabilities;
452 capabilities.SetEss ();
453 return capabilities;
454}
455
458{
459 NS_LOG_FUNCTION (this);
460 ErpInformation information;
461 information.SetErpSupported (1);
462 if (GetErpSupported ())
463 {
464 information.SetNonErpPresent (m_numNonErpStations > 0);
467 {
468 information.SetBarkerPreambleMode (0);
469 }
470 else
471 {
472 information.SetBarkerPreambleMode (1);
473 }
474 }
475 return information;
476}
477
480{
481 NS_LOG_FUNCTION (this);
482 EdcaParameterSet edcaParameters;
483 if (GetQosSupported ())
484 {
485 edcaParameters.SetQosSupported (1);
486 Ptr<QosTxop> edca;
487 Time txopLimit;
488
489 edca = GetQosTxop (AC_BE);
490 txopLimit = edca->GetTxopLimit ();
491 edcaParameters.SetBeAci (0);
492 edcaParameters.SetBeCWmin (edca->GetMinCw ());
493 edcaParameters.SetBeCWmax (edca->GetMaxCw ());
494 edcaParameters.SetBeAifsn (edca->GetAifsn ());
495 edcaParameters.SetBeTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
496
497 edca = GetQosTxop (AC_BK);
498 txopLimit = edca->GetTxopLimit ();
499 edcaParameters.SetBkAci (1);
500 edcaParameters.SetBkCWmin (edca->GetMinCw ());
501 edcaParameters.SetBkCWmax (edca->GetMaxCw ());
502 edcaParameters.SetBkAifsn (edca->GetAifsn ());
503 edcaParameters.SetBkTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
504
505 edca = GetQosTxop (AC_VI);
506 txopLimit = edca->GetTxopLimit ();
507 edcaParameters.SetViAci (2);
508 edcaParameters.SetViCWmin (edca->GetMinCw ());
509 edcaParameters.SetViCWmax (edca->GetMaxCw ());
510 edcaParameters.SetViAifsn (edca->GetAifsn ());
511 edcaParameters.SetViTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
512
513 edca = GetQosTxop (AC_VO);
514 txopLimit = edca->GetTxopLimit ();
515 edcaParameters.SetVoAci (3);
516 edcaParameters.SetVoCWmin (edca->GetMinCw ());
517 edcaParameters.SetVoCWmax (edca->GetMaxCw ());
518 edcaParameters.SetVoAifsn (edca->GetAifsn ());
519 edcaParameters.SetVoTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
520
521 edcaParameters.SetQosInfo (0);
522 }
523 return edcaParameters;
524}
525
528{
529 NS_LOG_FUNCTION (this);
530 MuEdcaParameterSet muEdcaParameters;
531 if (GetHeSupported ())
532 {
533 Ptr<HeConfiguration> heConfiguration = GetHeConfiguration ();
534 NS_ASSERT (heConfiguration != 0);
535
536 muEdcaParameters.SetQosInfo (0);
537
538 UintegerValue uintegerValue;
539 TimeValue timeValue;
540
541 heConfiguration->GetAttribute ("MuBeAifsn", uintegerValue);
542 muEdcaParameters.SetMuAifsn (AC_BE, uintegerValue.Get ());
543 heConfiguration->GetAttribute ("MuBeCwMin", uintegerValue);
544 muEdcaParameters.SetMuCwMin (AC_BE, uintegerValue.Get ());
545 heConfiguration->GetAttribute ("MuBeCwMax", uintegerValue);
546 muEdcaParameters.SetMuCwMax (AC_BE, uintegerValue.Get ());
547 heConfiguration->GetAttribute ("BeMuEdcaTimer", timeValue);
548 muEdcaParameters.SetMuEdcaTimer (AC_BE, timeValue.Get ());
549
550 heConfiguration->GetAttribute ("MuBkAifsn", uintegerValue);
551 muEdcaParameters.SetMuAifsn (AC_BK, uintegerValue.Get ());
552 heConfiguration->GetAttribute ("MuBkCwMin", uintegerValue);
553 muEdcaParameters.SetMuCwMin (AC_BK, uintegerValue.Get ());
554 heConfiguration->GetAttribute ("MuBkCwMax", uintegerValue);
555 muEdcaParameters.SetMuCwMax (AC_BK, uintegerValue.Get ());
556 heConfiguration->GetAttribute ("BkMuEdcaTimer", timeValue);
557 muEdcaParameters.SetMuEdcaTimer (AC_BK, timeValue.Get ());
558
559 heConfiguration->GetAttribute ("MuViAifsn", uintegerValue);
560 muEdcaParameters.SetMuAifsn (AC_VI, uintegerValue.Get ());
561 heConfiguration->GetAttribute ("MuViCwMin", uintegerValue);
562 muEdcaParameters.SetMuCwMin (AC_VI, uintegerValue.Get ());
563 heConfiguration->GetAttribute ("MuViCwMax", uintegerValue);
564 muEdcaParameters.SetMuCwMax (AC_VI, uintegerValue.Get ());
565 heConfiguration->GetAttribute ("ViMuEdcaTimer", timeValue);
566 muEdcaParameters.SetMuEdcaTimer (AC_VI, timeValue.Get ());
567
568 heConfiguration->GetAttribute ("MuVoAifsn", uintegerValue);
569 muEdcaParameters.SetMuAifsn (AC_VO, uintegerValue.Get ());
570 heConfiguration->GetAttribute ("MuVoCwMin", uintegerValue);
571 muEdcaParameters.SetMuCwMin (AC_VO, uintegerValue.Get ());
572 heConfiguration->GetAttribute ("MuVoCwMax", uintegerValue);
573 muEdcaParameters.SetMuCwMax (AC_VO, uintegerValue.Get ());
574 heConfiguration->GetAttribute ("VoMuEdcaTimer", timeValue);
575 muEdcaParameters.SetMuEdcaTimer (AC_VO, timeValue.Get ());
576 }
577 return muEdcaParameters;
578}
579
582{
583 NS_LOG_FUNCTION (this);
584 HtOperation operation;
585 if (GetHtSupported ())
586 {
587 operation.SetHtSupported (1);
588 operation.SetPrimaryChannel (GetWifiPhy ()->GetPrimaryChannelNumber (20));
589 operation.SetRifsMode (false);
590 operation.SetNonGfHtStasPresent (true);
591 if (GetWifiPhy ()->GetChannelWidth () > 20)
592 {
593 operation.SetSecondaryChannelOffset (1);
594 operation.SetStaChannelWidth (1);
595 }
596 if (m_numNonHtStations == 0)
597 {
598 operation.SetHtProtection (NO_PROTECTION);
599 }
600 else
601 {
603 }
604 uint64_t maxSupportedRate = 0; //in bit/s
605 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT))
606 {
607 uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
608 NS_ASSERT (nss > 0 && nss < 5);
609 uint64_t dataRate = mcs.GetDataRate (GetWifiPhy ()->GetChannelWidth (), GetHtConfiguration ()->GetShortGuardIntervalSupported () ? 400 : 800, nss);
610 if (dataRate > maxSupportedRate)
611 {
612 maxSupportedRate = dataRate;
613 NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate);
614 }
615 }
616 uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedTxSpatialStreams ();
617 auto mcsList = GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT);
618 uint8_t nMcs = mcsList.size ();
619 for (const auto& sta : m_staList)
620 {
621 if (GetWifiRemoteStationManager ()->GetHtSupported (sta.second))
622 {
623 uint64_t maxSupportedRateByHtSta = 0; //in bit/s
624 auto itMcs = mcsList.begin ();
625 for (uint8_t j = 0; j < (std::min (nMcs, GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second))); j++)
626 {
627 WifiMode mcs = *itMcs++;
628 uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
629 NS_ASSERT (nss > 0 && nss < 5);
630 uint64_t dataRate = mcs.GetDataRate (GetWifiRemoteStationManager ()->GetChannelWidthSupported (sta.second),
631 GetWifiRemoteStationManager ()->GetShortGuardIntervalSupported (sta.second) ? 400 : 800, nss);
632 if (dataRate > maxSupportedRateByHtSta)
633 {
634 maxSupportedRateByHtSta = dataRate;
635 }
636 }
637 if (maxSupportedRateByHtSta < maxSupportedRate)
638 {
639 maxSupportedRate = maxSupportedRateByHtSta;
640 }
641 if (GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second) < nMcs)
642 {
643 nMcs = GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second);
644 }
645 if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream)
646 {
647 maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second);
648 }
649 }
650 }
651 operation.SetRxHighestSupportedDataRate (static_cast<uint16_t> (maxSupportedRate / 1e6)); //in Mbit/s
652 operation.SetTxMcsSetDefined (nMcs > 0);
653 operation.SetTxMaxNSpatialStreams (maxSpatialStream);
654 //To be filled in once supported
655 operation.SetObssNonHtStasPresent (0);
656 operation.SetDualBeacon (0);
657 operation.SetDualCtsProtection (0);
658 operation.SetStbcBeacon (0);
660 operation.SetPcoActive (0);
661 operation.SetPhase (0);
662 operation.SetRxMcsBitmask (0);
663 operation.SetTxRxMcsSetUnequal (0);
664 operation.SetTxUnequalModulation (0);
665 }
666 return operation;
667}
668
671{
672 NS_LOG_FUNCTION (this);
673 VhtOperation operation;
674 if (GetVhtSupported ())
675 {
676 operation.SetVhtSupported (1);
677 uint16_t channelWidth = GetVhtOperationalChannelWidth ();
678 if (channelWidth == 160)
679 {
680 operation.SetChannelWidth (2);
681 }
682 else if (channelWidth == 80)
683 {
684 operation.SetChannelWidth (1);
685 }
686 else
687 {
688 operation.SetChannelWidth (0);
689 }
690 uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams ();
691 for (const auto& sta : m_staList)
692 {
693 if (GetWifiRemoteStationManager ()->GetVhtSupported (sta.second))
694 {
695 if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream)
696 {
697 maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second);
698 }
699 }
700 }
701 for (uint8_t nss = 1; nss <= maxSpatialStream; nss++)
702 {
703 uint8_t maxMcs = 9; //TBD: hardcode to 9 for now since we assume all MCS values are supported
704 operation.SetMaxVhtMcsPerNss (nss, maxMcs);
705 }
706 }
707 return operation;
708}
709
712{
713 NS_LOG_FUNCTION (this);
714 HeOperation operation;
715 if (GetHeSupported ())
716 {
717 operation.SetHeSupported (1);
718 uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams ();
719 for (const auto& sta : m_staList)
720 {
721 if (GetWifiRemoteStationManager ()->GetHeSupported (sta.second))
722 {
723 if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream)
724 {
725 maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second);
726 }
727 }
728 }
729 for (uint8_t nss = 1; nss <= maxSpatialStream; nss++)
730 {
731 operation.SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported
732 }
733 operation.SetBssColor (GetHeConfiguration ()->GetBssColor ());
734 }
735 return operation;
736}
737
738void
740{
741 NS_LOG_FUNCTION (this << to);
742 WifiMacHeader hdr;
744 hdr.SetAddr1 (to);
745 hdr.SetAddr2 (GetAddress ());
746 hdr.SetAddr3 (GetAddress ());
747 hdr.SetDsNotFrom ();
748 hdr.SetDsNotTo ();
749 Ptr<Packet> packet = Create<Packet> ();
751 probe.SetSsid (GetSsid ());
753 probe.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
757 if (GetDsssSupported ())
758 {
760 }
761 if (GetErpSupported ())
762 {
764 }
765 if (GetQosSupported ())
766 {
768 }
769 if (GetHtSupported ())
770 {
774 }
775 if (GetVhtSupported ())
776 {
779 }
780 if (GetHeSupported ())
781 {
785 }
786 packet->AddHeader (probe);
787
788 if (!GetQosSupported ())
789 {
790 GetTxop ()->Queue (packet, hdr);
791 }
792 // "A QoS STA that transmits a Management frame determines access category used
793 // for medium access in transmission of the Management frame as follows
794 // (If dot11QMFActivated is false or not present)
795 // — If the Management frame is individually addressed to a non-QoS STA, category
796 // AC_BE should be selected.
797 // — If category AC_BE was not selected by the previous step, category AC_VO
798 // shall be selected." (Sec. 10.2.3.2 of 802.11-2020)
800 {
801 GetBEQueue ()->Queue (packet, hdr);
802 }
803 else
804 {
805 GetVOQueue ()->Queue (packet, hdr);
806 }
807}
808
809void
810ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc)
811{
812 NS_LOG_FUNCTION (this << to << success << isReassoc);
813 WifiMacHeader hdr;
815 hdr.SetAddr1 (to);
816 hdr.SetAddr2 (GetAddress ());
817 hdr.SetAddr3 (GetAddress ());
818 hdr.SetDsNotFrom ();
819 hdr.SetDsNotTo ();
820 Ptr<Packet> packet = Create<Packet> ();
822 StatusCode code;
823 if (success)
824 {
825 code.SetSuccess ();
826 uint16_t aid = 0;
827 bool found = false;
828 if (isReassoc)
829 {
830 for (const auto& sta : m_staList)
831 {
832 if (sta.second == to)
833 {
834 aid = sta.first;
835 found = true;
836 break;
837 }
838 }
839 }
840 if (!found)
841 {
842 aid = GetNextAssociationId ();
843 m_staList.insert (std::make_pair (aid, to));
844 m_assocLogger (aid, to);
846 if (GetWifiRemoteStationManager ()->GetDsssSupported (to) && !GetWifiRemoteStationManager ()->GetErpOfdmSupported (to))
847 {
849 }
851 {
853 }
856 }
857 assoc.SetAssociationId (aid);
858 }
859 else
860 {
861 code.SetFailure ();
862 }
864 assoc.SetStatusCode (code);
866 if (GetErpSupported ())
867 {
869 }
870 if (GetQosSupported ())
871 {
873 }
874 if (GetHtSupported ())
875 {
879 }
880 if (GetVhtSupported ())
881 {
884 }
885 if (GetHeSupported ())
886 {
890 }
891 packet->AddHeader (assoc);
892
893 if (!GetQosSupported ())
894 {
895 GetTxop ()->Queue (packet, hdr);
896 }
897 // "A QoS STA that transmits a Management frame determines access category used
898 // for medium access in transmission of the Management frame as follows
899 // (If dot11QMFActivated is false or not present)
900 // — If the Management frame is individually addressed to a non-QoS STA, category
901 // AC_BE should be selected.
902 // — If category AC_BE was not selected by the previous step, category AC_VO
903 // shall be selected." (Sec. 10.2.3.2 of 802.11-2020)
905 {
906 GetBEQueue ()->Queue (packet, hdr);
907 }
908 else
909 {
910 GetVOQueue ()->Queue (packet, hdr);
911 }
912}
913
914void
916{
917 NS_LOG_FUNCTION (this);
918 WifiMacHeader hdr;
921 hdr.SetAddr2 (GetAddress ());
922 hdr.SetAddr3 (GetAddress ());
923 hdr.SetDsNotFrom ();
924 hdr.SetDsNotTo ();
925 Ptr<Packet> packet = Create<Packet> ();
926 MgtBeaconHeader beacon;
927 beacon.SetSsid (GetSsid ());
929 beacon.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
933 if (GetDsssSupported ())
934 {
936 }
937 if (GetErpSupported ())
938 {
940 }
941 if (GetQosSupported ())
942 {
944 }
945 if (GetHtSupported ())
946 {
949 beacon.SetHtOperation (GetHtOperation ());
950 }
951 if (GetVhtSupported ())
952 {
955 }
956 if (GetHeSupported ())
957 {
959 beacon.SetHeOperation (GetHeOperation ());
961 }
962 packet->AddHeader (beacon);
963
964 //The beacon has it's own special queue, so we load it in there
965 m_beaconTxop->Queue (packet, hdr);
967
968 //If a STA that does not support Short Slot Time associates,
969 //the AP shall use long slot time beginning at the first Beacon
970 //subsequent to the association of the long slot time STA.
971 if (GetErpSupported ())
972 {
974 {
975 //Enable short slot time
977 }
978 else
979 {
980 //Disable short slot time
982 }
983 }
984}
985
986void
988{
989 NS_LOG_FUNCTION (this << *mpdu);
990 const WifiMacHeader& hdr = mpdu->GetHeader ();
991 if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
992 && GetWifiRemoteStationManager ()->IsWaitAssocTxOk (hdr.GetAddr1 ()))
993 {
994 NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
996 }
997}
998
999void
1001{
1002 NS_LOG_FUNCTION (this << +timeoutReason << *mpdu);
1003 const WifiMacHeader& hdr = mpdu->GetHeader ();
1004
1005 if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
1006 && GetWifiRemoteStationManager ()->IsWaitAssocTxOk (hdr.GetAddr1 ()))
1007 {
1008 NS_LOG_DEBUG ("association failed with sta=" << hdr.GetAddr1 ());
1010 }
1011}
1012
1013void
1015{
1016 NS_LOG_FUNCTION (this << *mpdu);
1017 const WifiMacHeader* hdr = &mpdu->GetHeader ();
1018 Ptr<const Packet> packet = mpdu->GetPacket ();
1019 Mac48Address from = hdr->GetAddr2 ();
1020 if (hdr->IsData ())
1021 {
1022 Mac48Address bssid = hdr->GetAddr1 ();
1023 if (!hdr->IsFromDs ()
1024 && hdr->IsToDs ()
1025 && bssid == GetAddress ()
1026 && GetWifiRemoteStationManager ()->IsAssociated (from))
1027 {
1028 Mac48Address to = hdr->GetAddr3 ();
1029 if (to == GetAddress ())
1030 {
1031 NS_LOG_DEBUG ("frame for me from=" << from);
1032 if (hdr->IsQosData ())
1033 {
1034 if (hdr->IsQosAmsdu ())
1035 {
1036 NS_LOG_DEBUG ("Received A-MSDU from=" << from << ", size=" << packet->GetSize ());
1038 packet = 0;
1039 }
1040 else
1041 {
1042 ForwardUp (packet, from, bssid);
1043 }
1044 }
1045 else if (hdr->HasData ())
1046 {
1047 ForwardUp (packet, from, bssid);
1048 }
1049 }
1050 else if (to.IsGroup ()
1051 || GetWifiRemoteStationManager ()->IsAssociated (to))
1052 {
1053 NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to);
1054 Ptr<Packet> copy = packet->Copy ();
1055
1056 //If the frame we are forwarding is of type QoS Data,
1057 //then we need to preserve the UP in the QoS control
1058 //header...
1059 if (hdr->IsQosData ())
1060 {
1061 ForwardDown (copy, from, to, hdr->GetQosTid ());
1062 }
1063 else
1064 {
1065 ForwardDown (copy, from, to);
1066 }
1067 ForwardUp (packet, from, to);
1068 }
1069 else
1070 {
1071 ForwardUp (packet, from, to);
1072 }
1073 }
1074 else if (hdr->IsFromDs ()
1075 && hdr->IsToDs ())
1076 {
1077 //this is an AP-to-AP frame
1078 //we ignore for now.
1079 NotifyRxDrop (packet);
1080 }
1081 else
1082 {
1083 //we can ignore these frames since
1084 //they are not targeted at the AP
1085 NotifyRxDrop (packet);
1086 }
1087 return;
1088 }
1089 else if (hdr->IsMgt ())
1090 {
1091 if (hdr->IsProbeReq ()
1092 && (hdr->GetAddr1 ().IsGroup () || hdr->GetAddr1 () == GetAddress ()))
1093 {
1094 // In the case where the Address 1 field contains a group address, the
1095 // Address 3 field also is validated to verify that the group addressed
1096 // frame originated from a STA in the BSS of which the receiving STA is
1097 // a member (Section 9.3.3.1 of 802.11-2020)
1098 if (hdr->GetAddr1 ().IsGroup ()
1099 && !hdr->GetAddr3 ().IsBroadcast () && hdr->GetAddr3 () != GetAddress ())
1100 {
1101 // not addressed to us
1102 return;
1103 }
1104 MgtProbeRequestHeader probeRequestHeader;
1105 packet->PeekHeader (probeRequestHeader);
1106 Ssid ssid = probeRequestHeader.GetSsid ();
1107 if (ssid == GetSsid () || ssid.IsBroadcast ())
1108 {
1109 NS_LOG_DEBUG ("Probe request received from " << from << ": send probe response");
1110 SendProbeResp (from);
1111 }
1112 return;
1113 }
1114 else if (hdr->GetAddr1 () == GetAddress ())
1115 {
1116 if (hdr->IsAssocReq ())
1117 {
1118 NS_LOG_DEBUG ("Association request received from " << from);
1119 //first, verify that the the station's supported
1120 //rate set is compatible with our Basic Rate set
1121 MgtAssocRequestHeader assocReq;
1122 packet->PeekHeader (assocReq);
1123 CapabilityInformation capabilities = assocReq.GetCapabilities ();
1125 SupportedRates rates = assocReq.GetSupportedRates ();
1126 bool problem = false;
1127 if (rates.GetNRates () == 0)
1128 {
1129 problem = true;
1130 }
1131 if (GetHtSupported ())
1132 {
1133 //check whether the HT STA supports all MCSs in Basic MCS Set
1134 HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
1135 if (htcapabilities.IsSupportedMcs (0))
1136 {
1137 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1138 {
1140 if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1141 {
1142 problem = true;
1143 break;
1144 }
1145 }
1146 }
1147 }
1148 if (GetVhtSupported ())
1149 {
1150 //check whether the VHT STA supports all MCSs in Basic MCS Set
1151 VhtCapabilities vhtcapabilities = assocReq.GetVhtCapabilities ();
1152 if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
1153 {
1154 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1155 {
1157 if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1158 {
1159 problem = true;
1160 break;
1161 }
1162 }
1163 }
1164 }
1165 if (GetHeSupported ())
1166 {
1167 //check whether the HE STA supports all MCSs in Basic MCS Set
1168 HeCapabilities hecapabilities = assocReq.GetHeCapabilities ();
1169 if (hecapabilities.GetSupportedMcsAndNss () != 0)
1170 {
1171 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1172 {
1174 if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1175 {
1176 problem = true;
1177 break;
1178 }
1179 }
1180 }
1181 }
1182 if (problem)
1183 {
1184 NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send association response with an error status");
1185 SendAssocResp (hdr->GetAddr2 (), false, false);
1186 }
1187 else
1188 {
1189 NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1190 //record all its supported modes in its associated WifiRemoteStation
1191 for (const auto & mode : GetWifiPhy ()->GetModeList ())
1192 {
1193 if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
1194 {
1196 }
1197 }
1198 if (GetErpSupported () && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ())
1199 {
1201 }
1202 if (GetHtSupported ())
1203 {
1204 HtCapabilities htCapabilities = assocReq.GetHtCapabilities ();
1205 if (htCapabilities.IsSupportedMcs (0))
1206 {
1207 GetWifiRemoteStationManager ()->AddStationHtCapabilities (from, htCapabilities);
1208 }
1209 }
1210 if (GetVhtSupported ())
1211 {
1212 VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilities ();
1213 //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1214 if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1215 {
1216 GetWifiRemoteStationManager ()->AddStationVhtCapabilities (from, vhtCapabilities);
1217 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT))
1218 {
1219 if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1220 {
1222 //here should add a control to add basic MCS when it is implemented
1223 }
1224 }
1225 }
1226 }
1227 if (GetHtSupported ())
1228 {
1229 ExtendedCapabilities extendedCapabilities = assocReq.GetExtendedCapabilities ();
1230 //TODO: to be completed
1231 }
1232 if (GetHeSupported ())
1233 {
1234 HeCapabilities heCapabilities = assocReq.GetHeCapabilities ();
1235 if (heCapabilities.GetSupportedMcsAndNss () != 0)
1236 {
1237 GetWifiRemoteStationManager ()->AddStationHeCapabilities (from, heCapabilities);
1238 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
1239 {
1240 if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1241 {
1243 //here should add a control to add basic MCS when it is implemented
1244 }
1245 }
1246 }
1247 }
1249 NS_LOG_DEBUG ("Send association response with success status");
1250 SendAssocResp (hdr->GetAddr2 (), true, false);
1251 }
1252 return;
1253 }
1254 else if (hdr->IsReassocReq ())
1255 {
1256 NS_LOG_DEBUG ("Reassociation request received from " << from);
1257 //first, verify that the the station's supported
1258 //rate set is compatible with our Basic Rate set
1259 MgtReassocRequestHeader reassocReq;
1260 packet->PeekHeader (reassocReq);
1261 CapabilityInformation capabilities = reassocReq.GetCapabilities ();
1263 SupportedRates rates = reassocReq.GetSupportedRates ();
1264 bool problem = false;
1265 if (rates.GetNRates () == 0)
1266 {
1267 problem = true;
1268 }
1269 if (GetHtSupported ())
1270 {
1271 //check whether the HT STA supports all MCSs in Basic MCS Set
1272 HtCapabilities htcapabilities = reassocReq.GetHtCapabilities ();
1273 if (htcapabilities.IsSupportedMcs (0))
1274 {
1275 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1276 {
1278 if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1279 {
1280 problem = true;
1281 break;
1282 }
1283 }
1284 }
1285 }
1286 if (GetVhtSupported ())
1287 {
1288 //check whether the VHT STA supports all MCSs in Basic MCS Set
1289 VhtCapabilities vhtcapabilities = reassocReq.GetVhtCapabilities ();
1290 if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
1291 {
1292 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1293 {
1295 if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1296 {
1297 problem = true;
1298 break;
1299 }
1300 }
1301 }
1302 }
1303 if (GetHeSupported ())
1304 {
1305 //check whether the HE STA supports all MCSs in Basic MCS Set
1306 HeCapabilities hecapabilities = reassocReq.GetHeCapabilities ();
1307 if (hecapabilities.GetSupportedMcsAndNss () != 0)
1308 {
1309 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1310 {
1312 if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1313 {
1314 problem = true;
1315 break;
1316 }
1317 }
1318 }
1319 }
1320 if (problem)
1321 {
1322 NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send reassociation response with an error status");
1323 SendAssocResp (hdr->GetAddr2 (), false, true);
1324 }
1325 else
1326 {
1327 NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1328 //update all its supported modes in its associated WifiRemoteStation
1329 for (const auto & mode : GetWifiPhy ()->GetModeList ())
1330 {
1331 if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
1332 {
1334 }
1335 }
1336 if (GetErpSupported () && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ())
1337 {
1339 }
1340 if (GetHtSupported ())
1341 {
1342 HtCapabilities htCapabilities = reassocReq.GetHtCapabilities ();
1343 if (htCapabilities.IsSupportedMcs (0))
1344 {
1345 GetWifiRemoteStationManager ()->AddStationHtCapabilities (from, htCapabilities);
1346 }
1347 }
1348 if (GetVhtSupported ())
1349 {
1350 VhtCapabilities vhtCapabilities = reassocReq.GetVhtCapabilities ();
1351 //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1352 if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1353 {
1354 GetWifiRemoteStationManager ()->AddStationVhtCapabilities (from, vhtCapabilities);
1355 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT))
1356 {
1357 if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1358 {
1360 //here should add a control to add basic MCS when it is implemented
1361 }
1362 }
1363 }
1364 }
1365 if (GetHtSupported ())
1366 {
1367 ExtendedCapabilities extendedCapabilities = reassocReq.GetExtendedCapabilities ();
1368 //TODO: to be completed
1369 }
1370 if (GetHeSupported ())
1371 {
1372 HeCapabilities heCapabilities = reassocReq.GetHeCapabilities ();
1373 if (heCapabilities.GetSupportedMcsAndNss () != 0)
1374 {
1375 GetWifiRemoteStationManager ()->AddStationHeCapabilities (from, heCapabilities);
1376 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
1377 {
1378 if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1379 {
1381 //here should add a control to add basic MCS when it is implemented
1382 }
1383 }
1384 }
1385 }
1387 NS_LOG_DEBUG ("Send reassociation response with success status");
1388 SendAssocResp (hdr->GetAddr2 (), true, true);
1389 }
1390 return;
1391 }
1392 else if (hdr->IsDisassociation ())
1393 {
1394 NS_LOG_DEBUG ("Disassociation received from " << from);
1396 for (auto it = m_staList.begin (); it != m_staList.end (); ++it)
1397 {
1398 if (it->second == from)
1399 {
1400 m_staList.erase (it);
1401 m_deAssocLogger (it->first, it->second);
1402 if (GetWifiRemoteStationManager ()->GetDsssSupported (from) && !GetWifiRemoteStationManager ()->GetErpOfdmSupported (from))
1403 {
1405 }
1407 {
1409 }
1412 break;
1413 }
1414 }
1415 return;
1416 }
1417 }
1418 }
1419
1420 //Invoke the receive handler of our parent class to deal with any
1421 //other frames. Specifically, this will handle Block Ack-related
1422 //Management Action frames.
1423 WifiMac::Receive (Create<WifiMacQueueItem> (packet, *hdr));
1424}
1425
1426void
1428{
1429 NS_LOG_FUNCTION (this << *mpdu);
1430 for (auto& i : *PeekPointer (mpdu))
1431 {
1432 if (i.second.GetDestinationAddr () == GetAddress ())
1433 {
1434 ForwardUp (i.first, i.second.GetSourceAddr (),
1435 i.second.GetDestinationAddr ());
1436 }
1437 else
1438 {
1439 Mac48Address from = i.second.GetSourceAddr ();
1440 Mac48Address to = i.second.GetDestinationAddr ();
1441 NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
1442 ForwardDown (i.first->Copy (), from, to, mpdu->GetHeader ().GetQosTid ());
1443 }
1444 }
1445}
1446
1447void
1449{
1450 NS_LOG_FUNCTION (this);
1454 {
1456 {
1457 Time jitter = MicroSeconds (static_cast<int64_t> (m_beaconJitter->GetValue (0, 1) * (GetBeaconInterval ().GetMicroSeconds ())));
1458 NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time " << jitter);
1460 }
1461 else
1462 {
1463 NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time 0");
1465 }
1466 }
1472}
1473
1474bool
1476{
1477 bool useProtection = (m_numNonErpStations > 0) && m_enableNonErpProtection;
1479 return useProtection;
1480}
1481
1482uint16_t
1484{
1485 //Return the first free AID value between 1 and 2007
1486 for (uint16_t nextAid = 1; nextAid <= 2007; nextAid++)
1487 {
1488 if (m_staList.find (nextAid) == m_staList.end ())
1489 {
1490 return nextAid;
1491 }
1492 }
1493 NS_FATAL_ERROR ("No free association ID available!");
1494 return 0;
1495}
1496
1497const std::map<uint16_t, Mac48Address>&
1499{
1500 return m_staList;
1501}
1502
1503uint16_t
1505{
1507}
1508
1509uint8_t
1511{
1512 auto it = m_bufferStatus.find (WifiAddressTidPair (address, tid));
1513 if (it == m_bufferStatus.end ()
1514 || it->second.timestamp + m_bsrLifetime < Simulator::Now ())
1515 {
1516 return 255;
1517 }
1518 return it->second.value;
1519}
1520
1521void
1523{
1524 if (size == 255)
1525 {
1526 // no point in storing an unspecified size
1528 }
1529 else
1530 {
1532 }
1533}
1534
1535uint8_t
1537{
1538 uint8_t maxSize = 0;
1539 bool found = false;
1540
1541 for (uint8_t tid = 0; tid < 8; tid++)
1542 {
1543 uint8_t size = GetBufferStatus (tid, address);
1544 if (size != 255)
1545 {
1546 maxSize = std::max (maxSize, size);
1547 found = true;
1548 }
1549 }
1550
1551 if (found)
1552 {
1553 return maxSize;
1554 }
1555 return 255;
1556}
1557
1558} //namespace ns3
#define min(a, b)
Definition: 80211b.c:42
#define max(a, b)
Definition: 80211b.c:43
Wi-Fi AP state machine.
Definition: ap-wifi-mac.h:51
void UpdateShortPreambleEnabled(void)
Update whether short preamble should be enabled or not in the BSS.
Definition: ap-wifi-mac.cc:237
bool m_shortPreambleEnabled
Flag whether short preamble is enabled in the BSS.
Definition: ap-wifi-mac.h:321
Ptr< Txop > m_beaconTxop
Dedicated Txop for beacons.
Definition: ap-wifi-mac.h:311
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
Definition: ap-wifi-mac.cc:158
void SendProbeResp(Mac48Address to)
Forward a probe response packet to the DCF.
Definition: ap-wifi-mac.cc:739
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
Definition: ap-wifi-mac.cc:390
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:192
HeOperation GetHeOperation(void) const
Return the HE operation of the current AP.
Definition: ap-wifi-mac.cc:711
uint16_t GetAssociationId(Mac48Address addr) const
void SetAddress(Mac48Address address) override
Definition: ap-wifi-mac.cc:138
uint16_t m_numNonHtStations
Number of non-HT stations currently associated to the AP.
Definition: ap-wifi-mac.h:319
Ptr< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
Definition: ap-wifi-mac.h:315
void TxOk(Ptr< const WifiMacQueueItem > mpdu)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:987
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
Definition: ap-wifi-mac.cc:353
virtual ~ApWifiMac()
Definition: ap-wifi-mac.cc:120
bool m_enableNonErpProtection
Flag whether protection mechanism is used or not when non-ERP STAs are present within the BSS.
Definition: ap-wifi-mac.h:322
bool m_shortSlotTimeEnabled
Flag whether short slot time is enabled within the BSS.
Definition: ap-wifi-mac.h:320
void Receive(Ptr< WifiMacQueueItem > mpdu) override
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
ErpInformation GetErpInformation(void) const
Return the ERP information of the current AP.
Definition: ap-wifi-mac.cc:457
HtOperation GetHtOperation(void) const
Return the HT operation of the current AP.
Definition: ap-wifi-mac.cc:581
bool SupportsSendFrom(void) const override
Definition: ap-wifi-mac.cc:383
std::map< uint16_t, Mac48Address > m_staList
Map of all stations currently associated to the AP with their association ID.
Definition: ap-wifi-mac.h:317
DsssParameterSet GetDsssParameterSet(void) const
Return the DSSS Parameter Set that we support.
Definition: ap-wifi-mac.cc:433
void UpdateShortSlotTimeEnabled(void)
Update whether short slot time should be enabled or not in the BSS.
Definition: ap-wifi-mac.cc:215
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current AP.
Definition: ap-wifi-mac.cc:446
void SendOneBeacon(void)
Forward a beacon packet to the beacon special DCF.
Definition: ap-wifi-mac.cc:915
TracedCallback< uint16_t, Mac48Address > m_deAssocLogger
deassociation logger
Definition: ap-wifi-mac.h:342
bool m_enableBeaconGeneration
Flag whether beacons are being generated.
Definition: ap-wifi-mac.h:312
Time m_beaconInterval
Beacon interval.
Definition: ap-wifi-mac.h:313
void TxFailed(WifiMacDropReason timeoutReason, Ptr< const WifiMacQueueItem > mpdu)
The packet we sent was successfully received by the receiver (i.e.
void DeaggregateAmsduAndForward(Ptr< WifiMacQueueItem > mpdu) override
This method is called to de-aggregate an A-MSDU and forward the constituent packets up the stack.
bool m_enableBeaconJitter
Flag whether the first beacon should be generated at random time.
Definition: ap-wifi-mac.h:316
void DoInitialize(void) override
Initialize() implementation.
MuEdcaParameterSet GetMuEdcaParameterSet(void) const
Return the MU EDCA Parameter Set of the current AP.
Definition: ap-wifi-mac.cc:527
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set of the current AP.
Definition: ap-wifi-mac.cc:479
TracedCallback< uint16_t, Mac48Address > m_assocLogger
association logger
Definition: ap-wifi-mac.h:341
bool GetUseNonErpProtection(void) const
Return whether protection for non-ERP stations is used in the BSS.
EventId m_beaconEvent
Event to generate one beacon.
Definition: ap-wifi-mac.h:314
uint16_t GetVhtOperationalChannelWidth(void) const
Determine the VHT operational channel width (in MHz).
Definition: ap-wifi-mac.cc:260
const std::map< uint16_t, Mac48Address > & GetStaList(void) const
Get a const reference to the map of associated stations.
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
Definition: ap-wifi-mac.cc:373
uint8_t GetMaxBufferStatus(Mac48Address address) const
Return the maximum among the values of the Queue Size subfield of the last QoS Data or QoS Null frame...
static TypeId GetTypeId(void)
Get the type ID.
Definition: ap-wifi-mac.cc:50
Time m_bsrLifetime
Lifetime of Buffer Status Reports.
Definition: ap-wifi-mac.h:323
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:207
uint16_t GetNextAssociationId(void)
uint8_t GetBufferStatus(uint8_t tid, Mac48Address address) const
Return the value of the Queue Size subfield of the last QoS Data or QoS Null frame received from the ...
void SetLinkUpCallback(Callback< void > linkUp) override
Definition: ap-wifi-mac.cc:180
uint16_t m_numNonErpStations
Number of non-ERP stations currently associated to the AP.
Definition: ap-wifi-mac.h:318
VhtOperation GetVhtOperation(void) const
Return the VHT operation of the current AP.
Definition: ap-wifi-mac.cc:670
void DoDispose(void) override
Destructor implementation.
Definition: ap-wifi-mac.cc:127
void SetBufferStatus(uint8_t tid, Mac48Address address, uint8_t size)
Store the value of the Queue Size subfield of the last QoS Data or QoS Null frame received from the s...
void SendAssocResp(Mac48Address to, bool success, bool isReassoc)
Forward an association or a reassociation response packet to the DCF.
Definition: ap-wifi-mac.cc:810
std::unordered_map< WifiAddressTidPair, bsrType, WifiAddressTidHash > m_bufferStatus
Per (MAC address, TID) buffer status reports.
Definition: ap-wifi-mac.h:331
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet down to DCF/EDCAF (enqueue the packet).
Definition: ap-wifi-mac.cc:277
Ptr< WifiMacQueue > GetTxopQueue(AcIndex ac) const override
Get the wifi MAC queue of the (Qos)Txop associated with the given AC, if such (Qos)Txop is installed,...
Definition: ap-wifi-mac.cc:148
Time GetBeaconInterval(void) const
Definition: ap-wifi-mac.cc:173
AttributeValue implementation for Boolean.
Definition: boolean.h:37
bool IsShortPreamble(void) const
Check if the short preamble bit in the capability information field is set to 1.
bool IsShortSlotTime(void) const
Check if the short slot time in the capability information field is set to 1.
void SetShortSlotTime(bool shortSlotTime)
Set the short slot time bit in the capability information field.
void SetShortPreamble(bool shortPreamble)
Set the short preamble bit in the capability information field.
void SetEss(void)
Set the Extended Service Set (ESS) bit in the capability information field.
The DSSS Parameter Set.
void SetCurrentChannel(uint8_t currentChannel)
Set the Current Channel field in the DsssParameterSet information element.
void SetDsssSupported(uint8_t dsssSupported)
Set DSSS supported.
The EDCA Parameter Set.
void SetViTxopLimit(uint16_t txop)
Set the AC_VI TXOP Limit field in the EdcaParameterSet information element.
void SetViAifsn(uint8_t aifsn)
Set the AC_VI AIFSN field in the EdcaParameterSet information element.
void SetVoAci(uint8_t aci)
Set the AC_VO ACI field in the EdcaParameterSet information element.
void SetVoCWmax(uint32_t cwMax)
Set the AC_VO CWmax field in the EdcaParameterSet information element.
void SetViCWmin(uint32_t cwMin)
Set the AC_VI CWmin field in the EdcaParameterSet information element.
void SetVoTxopLimit(uint16_t txop)
Set the AC_VO TXOP Limit field in the EdcaParameterSet information element.
void SetVoAifsn(uint8_t aifsn)
Set the AC_VO AIFSN field in the EdcaParameterSet information element.
void SetQosInfo(uint8_t qosInfo)
Set the QoS Info field in the EdcaParameterSet information element.
void SetBkCWmin(uint32_t cwMin)
Set the AC_BK CWmin field in the EdcaParameterSet information element.
void SetViAci(uint8_t aci)
Set the AC_VI ACI field in the EdcaParameterSet information element.
void SetViCWmax(uint32_t cwMax)
Set the AC_VI CWmax field in the EdcaParameterSet information element.
void SetVoCWmin(uint32_t cwMin)
Set the AC_VO CWmin field in the EdcaParameterSet information element.
void SetBeTxopLimit(uint16_t txop)
Set the AC_BE TXOP Limit field in the EdcaParameterSet information element.
void SetBeCWmax(uint32_t cwMax)
Set the AC_BE CWmax field in the EdcaParameterSet information element.
void SetBeAci(uint8_t aci)
Set the AC_BE ACI field in the EdcaParameterSet information element.
void SetBkCWmax(uint32_t cwMax)
Set the AC_BK CWmax field in the EdcaParameterSet information element.
void SetBkTxopLimit(uint16_t txop)
Set the AC_BK TXOP Limit field in the EdcaParameterSet information element.
void SetBkAifsn(uint8_t aifsn)
Set the AC_BK AIFSN field in the EdcaParameterSet information element.
void SetBeCWmin(uint32_t cwMin)
Set the AC_BE CWmin field in the EdcaParameterSet information element.
void SetBkAci(uint8_t aci)
Set the AC_BK ACI field in the EdcaParameterSet information element.
void SetQosSupported(uint8_t qosSupported)
Set QOS supported function.
void SetBeAifsn(uint8_t aifsn)
Set the AC_BE AIFSN field in the EdcaParameterSet information element.
The ErpInformation Information Element.
void SetErpSupported(uint8_t erpSupported)
Set the ERP supported field.
void SetBarkerPreambleMode(uint8_t barkerPreambleMode)
Set the Barker_Preamble_Mode field in the ErpInformation information element.
void SetUseProtection(uint8_t useProtection)
Set the Use_Protection field in the ErpInformation information element.
void SetNonErpPresent(uint8_t nonErpPresent)
Set the Non_Erp_Present field in the ErpInformation information element.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
The Extended Capabilities Information Element.
The IEEE 802.11ax HE Capabilities.
bool IsSupportedTxMcs(uint8_t mcs) const
Is RX MCS supported.
uint16_t GetSupportedMcsAndNss() const
Return the MCS and NSS field in the HE Capabilities information element.
The HE Operation Information Element.
Definition: he-operation.h:36
void SetBssColor(uint8_t bssColor)
Set the BSS color.
void SetMaxHeMcsPerNss(uint8_t nss, uint8_t maxHeMcs)
Set the Basic HE-MCS and NSS field in the HE Operation information element by specifying the tuple (n...
Definition: he-operation.cc:97
void SetHeSupported(uint8_t heSupported)
Set the HE supported information element.
Definition: he-operation.cc:53
The HT Capabilities Information Element.
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
The HT Operation Information Element.
Definition: ht-operation.h:51
void SetObssNonHtStasPresent(uint8_t obssNonHtStasPresent)
Set the OBSS non HT STAs present.
void SetRifsMode(uint8_t rifsMode)
Set the RIFS mode.
Definition: ht-operation.cc:99
void SetSecondaryChannelOffset(uint8_t secondaryChannelOffset)
Set the secondary channel offset.
Definition: ht-operation.cc:87
void SetPcoActive(uint8_t pcoActive)
Set the PCO active.
void SetTxUnequalModulation(uint8_t txUnequalModulation)
Set the transmit unequal modulation.
void SetHtProtection(uint8_t htProtection)
Set the HT protection.
void SetTxMaxNSpatialStreams(uint8_t maxTxSpatialStreams)
Set the transmit maximum number spatial streams.
void SetTxRxMcsSetUnequal(uint8_t txRxMcsSetUnequal)
Set the transmit / receive MCS set unequal.
void SetDualBeacon(uint8_t dualBeacon)
Set the dual beacon.
void SetNonGfHtStasPresent(uint8_t nonGfHtStasPresent)
Set the non GF HT STAs present.
void SetTxMcsSetDefined(uint8_t txMcsSetDefined)
Set the transmit MCS set defined.
void SetLSigTxopProtectionFullSupport(uint8_t lSigTxopProtectionFullSupport)
Set the LSIG TXOP protection full support.
void SetStaChannelWidth(uint8_t staChannelWidth)
Set the STA channel width.
Definition: ht-operation.cc:93
void SetRxHighestSupportedDataRate(uint16_t maxSupportedRate)
Set the receive highest supported data rate.
void SetRxMcsBitmask(uint8_t index)
Set the receive MCS bitmask.
void SetPrimaryChannel(uint8_t ctrl)
Set the Primary Channel field in the HT Operation information element.
Definition: ht-operation.cc:81
void SetDualCtsProtection(uint8_t dualCtsProtection)
Set the dual CTS protection.
void SetPhase(uint8_t pcoPhase)
Set the PCO phase.
void SetHtSupported(uint8_t htSupported)
Set the HT Supported.
Definition: ht-operation.cc:67
void SetStbcBeacon(uint8_t stbcBeacon)
Set the STBC beacon.
an EUI-48 address
Definition: mac48-address.h:44
static Mac48Address GetBroadcast(void)
bool IsGroup(void) const
bool IsBroadcast(void) const
Implement the header for management frames of type association request.
Definition: mgt-headers.h:50
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:602
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:554
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:566
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:578
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:590
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:614
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:320
void SetErpInformation(ErpInformation erpInformation)
Set the ERP information.
void SetVhtCapabilities(VhtCapabilities vhtCapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:986
void SetHtCapabilities(HtCapabilities htCapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:962
void SetHtOperation(HtOperation htOperation)
Set the HT operation.
Definition: mgt-headers.cc:974
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:938
void SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
void SetStatusCode(StatusCode code)
Set the status code.
Definition: mgt-headers.cc:926
void SetAssociationId(uint16_t aid)
Set the association ID.
void SetMuEdcaParameterSet(MuEdcaParameterSet muEdcaParameterSet)
Set the MU EDCA Parameter Set.
void SetEdcaParameterSet(EdcaParameterSet edcaParameterSet)
Set the EDCA Parameter Set.
void SetHeOperation(HeOperation heOperation)
Set the HE operation.
void SetExtendedCapabilities(ExtendedCapabilities extendedCapabilities)
Set the extended capabilities.
Definition: mgt-headers.cc:950
void SetVhtOperation(VhtOperation vhtOperation)
Set the VHT operation.
Definition: mgt-headers.cc:998
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:932
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:862
Implement the header for management frames of type probe request.
Definition: mgt-headers.h:529
Ssid GetSsid(void) const
Return the Service Set Identifier (SSID).
Definition: mgt-headers.cc:46
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:633
void SetVhtCapabilities(VhtCapabilities vhtCapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:268
void SetErpInformation(ErpInformation erpInformation)
Set the ERP information.
Definition: mgt-headers.cc:346
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:220
void SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:292
void SetExtendedCapabilities(ExtendedCapabilities extendedCapabilities)
Set the extended capabilities.
Definition: mgt-headers.cc:232
void SetVhtOperation(VhtOperation vhtOperation)
Set the VHT operation.
Definition: mgt-headers.cc:280
void SetHtCapabilities(HtCapabilities htCapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:244
void SetHtOperation(HtOperation htOperation)
Set the HT operation.
Definition: mgt-headers.cc:256
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:316
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:328
void SetDsssParameterSet(DsssParameterSet dsssParameterSet)
Set the DSSS Parameter Set.
Definition: mgt-headers.cc:334
void SetBeaconIntervalUs(uint64_t us)
Set the beacon interval in microseconds unit.
Definition: mgt-headers.cc:322
void SetEdcaParameterSet(EdcaParameterSet edcaParameterSet)
Set the EDCA Parameter Set.
Definition: mgt-headers.cc:358
void SetHeOperation(HeOperation heOperation)
Set the HE operation.
Definition: mgt-headers.cc:304
void SetMuEdcaParameterSet(MuEdcaParameterSet muEdcaParameterSet)
Set the MU EDCA Parameter Set.
Definition: mgt-headers.cc:364
Implement the header for management frames of type reassociation request.
Definition: mgt-headers.h:182
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:801
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:789
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:777
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:765
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:741
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:753
The MU EDCA Parameter Set.
void SetMuCwMin(uint8_t aci, uint16_t cwMin)
Set the ECWmin subfield of the ECWmin/ECWmax field in the MU AC Parameter Record field corresponding ...
void SetMuEdcaTimer(uint8_t aci, Time timer)
Set the MU EDCA Timer field in the MU AC Parameter Record field corresponding to the given AC Index (...
void SetMuAifsn(uint8_t aci, uint8_t aifsn)
Set the AIFSN subfield of the ACI/AIFSN field in the MU AC Parameter Record field corresponding to th...
void SetQosInfo(uint8_t qosInfo)
Set the QoS Info field in the MuEdcaParameterSet information element.
void SetMuCwMax(uint8_t aci, uint16_t cwMax)
Set the ECWmax subfield of the ECWmin/ECWmax field in the MU AC Parameter Record field corresponding ...
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:364
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Definition: object.cc:183
void Dispose(void)
Dispose of this Object.
Definition: object.cc:214
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:856
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
uint32_t GetMinCw(void) const override
Return the minimum contention window size from the EDCA Parameter Set or the MU EDCA Parameter Set,...
Definition: qos-txop.cc:211
uint8_t GetAifsn(void) const override
Return the number of slots that make up an AIFS according to the EDCA Parameter Set or the MU EDCA Pa...
Definition: qos-txop.cc:233
uint32_t GetMaxCw(void) const override
Return the maximum contention window size from the EDCA Parameter Set or the MU EDCA Parameter Set,...
Definition: qos-txop.cc:222
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:587
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
Status code for association response.
Definition: status-code.h:32
void SetFailure(void)
Set success bit to 1 (failure).
Definition: status-code.cc:36
void SetSuccess(void)
Set success bit to 0 (success).
Definition: status-code.cc:30
Hold variables of type string.
Definition: string.h:41
The Supported Rates Information Element.
void SetBasicRate(uint64_t bs)
Set the given rate to basic rates.
void AddBssMembershipSelectorRate(uint64_t bs)
Add a special value to the supported rate set, corresponding to a BSS membership selector.
uint8_t GetNRates(void) const
Return the number of supported rates.
void AddSupportedRate(uint64_t bs)
Add the given rate to the supported rates.
bool IsSupportedRate(uint64_t bs) const
Check if the given rate is supported.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:387
AttributeValue implementation for Time.
Definition: nstime.h:1308
Time Get(void) const
Definition: time.cc:533
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:173
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Definition: txop.cc:154
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: txop.cc:280
virtual void SetWifiMac(const Ptr< WifiMac > mac)
Set the wifi MAC this Txop is associated to.
Definition: txop.cc:136
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Definition: txop.cc:129
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:247
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:161
void SetChannelAccessManager(const Ptr< ChannelAccessManager > manager)
Set ChannelAccessManager this Txop is associated to.
Definition: txop.cc:122
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:294
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Hold an unsigned integer type.
Definition: uinteger.h:44
uint64_t Get(void) const
Definition: uinteger.cc:35
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
The IEEE 802.11ac VHT Capabilities.
bool IsSupportedTxMcs(uint8_t mcs) const
Returns true if transmit MCS is supported.
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
uint32_t GetVhtCapabilitiesInfo() const
Return the VHT Capabilities Info field in the VHT Capabilities information element.
The VHT Operation Information Element.
Definition: vht-operation.h:36
void SetVhtSupported(uint8_t vhtSupported)
Set the VHT supported information element.
void SetMaxVhtMcsPerNss(uint8_t nss, uint8_t maxVhtMcs)
Set the Basic VHT-MCS and NSS field in the VHT Operation information element by specifying the tuple ...
void SetChannelWidth(uint8_t channelWidth)
Set the Channel Width field in the VHT Operation information element.
Implements the IEEE 802.11 MAC header.
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.
bool HasData(void) const
Return true if the header type is DATA and is not DATA_NULL.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
bool IsFromDs(void) const
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
bool IsDisassociation(void) const
Return true if the header is a Disassociation header.
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
bool IsProbeReq(void) const
Return true if the header is a Probe Request header.
bool IsMgt(void) const
Return true if the Type is Management.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
void SetNoOrder(void)
Unset order bit in the frame control field.
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
bool IsData(void) const
Return true if the Type is DATA.
void SetDsFrom(void)
Set the From DS bit in the Frame Control field.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
bool IsToDs(void) const
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:85
Ptr< HtConfiguration > GetHtConfiguration(void) const
Definition: wifi-mac.cc:1047
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities of the device.
Definition: wifi-mac.cc:1175
bool GetShortSlotTimeSupported(void) const
Definition: wifi-mac.cc:872
Ptr< HeConfiguration > GetHeConfiguration(void) const
Definition: wifi-mac.cc:1059
bool GetVhtSupported() const
Return whether the device supports VHT.
Definition: wifi-mac.cc:1075
bool GetQosSupported() const
Return whether the device supports QoS.
Definition: wifi-mac.cc:822
virtual void SetAddress(Mac48Address address)
Definition: wifi-mac.cc:396
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
Definition: wifi-mac.cc:1325
Ssid GetSsid(void) const
Definition: wifi-mac.cc:416
void DoInitialize() override
Initialize() implementation.
Definition: wifi-mac.cc:320
Mac48Address GetAddress(void) const
Definition: wifi-mac.cc:403
Ptr< QosTxop > GetBEQueue(void) const
Accessor for the AC_BE channel access function.
Definition: wifi-mac.cc:485
bool GetHtSupported() const
Return whether the device supports HT.
Definition: wifi-mac.cc:1065
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Definition: wifi-mac.cc:371
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
Definition: wifi-mac.cc:757
Ptr< QosTxop > GetVOQueue(void) const
Accessor for the AC_VO channel access function.
Definition: wifi-mac.cc:473
Ptr< ChannelAccessManager > m_channelAccessManager
channel access manager
Definition: wifi-mac.h:521
bool GetHeSupported() const
Return whether the device supports HE.
Definition: wifi-mac.cc:1085
virtual void Receive(Ptr< WifiMacQueueItem > mpdu)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
Definition: wifi-mac.cc:923
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
Definition: wifi-mac.h:520
Ptr< WifiPhy > GetWifiPhy(void) const
Definition: wifi-mac.cc:776
virtual Ptr< WifiMacQueue > GetTxopQueue(AcIndex ac) const
Get the wifi MAC queue of the (Qos)Txop associated with the given AC, if such (Qos)Txop is installed,...
Definition: wifi-mac.cc:497
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:543
virtual void SetLinkUpCallback(Callback< void > linkUp)
Definition: wifi-mac.cc:891
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
Definition: wifi-mac.cc:916
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
Definition: wifi-mac.cc:1242
bool GetErpSupported() const
Return whether the device supports ERP.
Definition: wifi-mac.cc:828
bool GetDsssSupported() const
Return whether the device supports DSSS.
Definition: wifi-mac.cc:852
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
Definition: wifi-mac.cc:1186
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
Definition: wifi-mac.cc:452
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:525
void DoDispose() override
Destructor implementation.
Definition: wifi-mac.cc:336
void SetBssid(Mac48Address bssid)
Definition: wifi-mac.cc:422
Ptr< Txop > GetTxop(void) const
Accessor for the Txop object.
Definition: wifi-mac.cc:446
represent a single transmission mode
Definition: wifi-mode.h:48
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:155
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:140
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:114
std::list< WifiMode > GetMcsList(void) const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
Definition: wifi-phy.cc:1750
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1117
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1099
void SetSlot(Time slot)
Set the slot duration for this PHY.
Definition: wifi-phy.cc:665
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:901
uint8_t GetNumberOfSupportedStreams(Mac48Address address) const
Return the number of spatial streams supported by the station.
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
uint16_t GetAssociationId(Mac48Address remoteAddress) const
Get the AID of a remote station.
uint8_t GetNBasicMcs(void) const
Return the number of basic MCS index.
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
uint8_t GetNBasicModes(void) const
Return the number of basic modes we support.
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtCapabilities)
Records VHT capabilities of the remote station.
void SetShortPreambleEnabled(bool enable)
Enable or disable short PHY preambles.
void RecordWaitAssocTxOk(Mac48Address address)
Records that we are waiting for an ACK for the association response we sent.
void RecordGotAssocTxOk(Mac48Address address)
Records that we got an ACK for the association response we sent.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
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...
WifiMode GetBasicMcs(uint8_t i) const
Return the MCS at the given list index.
uint8_t GetNMcsSupported(Mac48Address address) const
Return the number of MCS supported by the station.
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
void AddSupportedPhyPreamble(Mac48Address address, bool isShortPreambleSupported)
Record whether the short PHY preamble is supported by the station.
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
uint16_t GetChannelWidthSupported(Mac48Address address) const
Return the channel width supported by the station.
void SetAssociationId(Mac48Address remoteAddress, uint16_t aid)
Record the AID of a remote station.
void AddSupportedErpSlotTime(Mac48Address address, bool isShortSlotTimeSupported)
Record whether the short ERP slot time is supported by the station.
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
Records HT capabilities of the remote station.
void RecordGotAssocTxFailed(Mac48Address address)
Records that we missed an ACK for the association response we sent.
#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
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:85
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:227
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1309
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Definition: abort.h:77
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1260
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1252
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
WifiMacDropReason
The reason why an MPDU was dropped.
Definition: wifi-mac.h:66
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a QoS tag is attached to the packet, returns a value < 8.
Definition: qos-utils.cc:152
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:71
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ AC_BE
Best Effort.
Definition: qos-utils.h:73
@ AC_VO
Voice.
Definition: qos-utils.h:79
@ AC_VI
Video.
Definition: qos-utils.h:77
@ AC_BK
Background.
Definition: qos-utils.h:75
@ AC_BEACON
Beacon queue.
Definition: qos-utils.h:83
address
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:415
@ AP
Definition: wifi-mac.h:54
@ NO_PROTECTION
Definition: ht-operation.h:37
@ MIXED_MODE_PROTECTION
Definition: ht-operation.h:40
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:536
@ WIFI_MAC_MGT_BEACON
@ WIFI_MAC_MGT_ASSOCIATION_RESPONSE
@ WIFI_MAC_MGT_PROBE_RESPONSE
@ WIFI_MAC_DATA
@ WIFI_MAC_MGT_REASSOCIATION_RESPONSE
@ WIFI_MAC_QOSDATA
std::pair< Mac48Address, uint8_t > WifiAddressTidPair
(MAC address, TID) pair
Definition: qos-utils.h:32
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1648
ssid
Definition: third.py:97