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
259void
261 Mac48Address to)
262{
263 NS_LOG_FUNCTION (this << packet << from << to);
264 //If we are not a QoS AP then we definitely want to use AC_BE to
265 //transmit the packet. A TID of zero will map to AC_BE (through \c
266 //QosUtilsMapTidToAc()), so we use that as our default here.
267 uint8_t tid = 0;
268
269 //If we are a QoS AP then we attempt to get a TID for this packet
270 if (GetQosSupported ())
271 {
272 tid = QosUtilsGetTidForPacket (packet);
273 //Any value greater than 7 is invalid and likely indicates that
274 //the packet had no QoS tag, so we revert to zero, which'll
275 //mean that AC_BE is used.
276 if (tid > 7)
277 {
278 tid = 0;
279 }
280 }
281
282 ForwardDown (packet, from, to, tid);
283}
284
285void
287 Mac48Address to, uint8_t tid)
288{
289 NS_LOG_FUNCTION (this << packet << from << to << +tid);
290 WifiMacHeader hdr;
291
292 //For now, an AP that supports QoS does not support non-QoS
293 //associations, and vice versa. In future the AP model should
294 //support simultaneously associated QoS and non-QoS STAs, at which
295 //point there will need to be per-association QoS state maintained
296 //by the association state machine, and consulted here.
297 if (GetQosSupported ())
298 {
301 hdr.SetQosNoEosp ();
302 hdr.SetQosNoAmsdu ();
303 //Transmission of multiple frames in the same Polled TXOP is not supported for now
304 hdr.SetQosTxopLimit (0);
305 //Fill in the QoS control field in the MAC header
306 hdr.SetQosTid (tid);
307 }
308 else
309 {
311 }
312
313 if (GetQosSupported ())
314 {
315 hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT control field is not yet implemented (set it to 1 when implemented)
316 }
317 hdr.SetAddr1 (to);
318 hdr.SetAddr2 (GetAddress ());
319 hdr.SetAddr3 (from);
320 hdr.SetDsFrom ();
321 hdr.SetDsNotTo ();
322
323 if (GetQosSupported ())
324 {
325 //Sanity check that the TID is valid
326 NS_ASSERT (tid < 8);
327 GetQosTxop (tid)->Queue (packet, hdr);
328 }
329 else
330 {
331 GetTxop ()->Queue (packet, hdr);
332 }
333}
334
335bool
337{
338 return (to.IsGroup () || GetWifiRemoteStationManager ()->IsAssociated (to));
339}
340
341void
343{
344 NS_LOG_FUNCTION (this << packet << to << from);
345 if (CanForwardPacketsTo (to))
346 {
347 ForwardDown (packet, from, to);
348 }
349 else
350 {
351 NotifyTxDrop (packet);
352 }
353}
354
355void
357{
358 NS_LOG_FUNCTION (this << packet << to);
359 //We're sending this packet with a from address that is our own. We
360 //get that address from the lower MAC and make use of the
361 //from-spoofing Enqueue() method to avoid duplicated code.
362 Enqueue (packet, to, GetAddress ());
363}
364
365bool
367{
368 NS_LOG_FUNCTION (this);
369 return true;
370}
371
374{
375 NS_LOG_FUNCTION (this);
376 SupportedRates rates;
377 //Send the set of supported rates and make sure that we indicate
378 //the Basic Rate set in this set of supported rates.
379 for (const auto & mode : GetWifiPhy ()->GetModeList ())
380 {
381 uint64_t modeDataRate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ());
382 NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
383 rates.AddSupportedRate (modeDataRate);
384 //Add rates that are part of the BSSBasicRateSet (manufacturer dependent!)
385 //here we choose to add the mandatory rates to the BSSBasicRateSet,
386 //except for 802.11b where we assume that only the non HR-DSSS rates are part of the BSSBasicRateSet
387 if (mode.IsMandatory () && (mode.GetModulationClass () != WIFI_MOD_CLASS_HR_DSSS))
388 {
389 NS_LOG_DEBUG ("Adding basic mode " << mode.GetUniqueName ());
391 }
392 }
393 //set the basic rates
394 for (uint8_t j = 0; j < GetWifiRemoteStationManager ()->GetNBasicModes (); j++)
395 {
397 uint64_t modeDataRate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ());
398 NS_LOG_DEBUG ("Setting basic rate " << mode.GetUniqueName ());
399 rates.SetBasicRate (modeDataRate);
400 }
401 //If it is a HT AP, then add the BSSMembershipSelectorSet
402 //The standard says that the BSSMembershipSelectorSet
403 //must have its MSB set to 1 (must be treated as a Basic Rate)
404 //Also the standard mentioned that at least 1 element should be included in the SupportedRates the rest can be in the ExtendedSupportedRates
405 if (GetHtSupported ())
406 {
407 for (const auto & selector : GetWifiPhy ()->GetBssMembershipSelectorList ())
408 {
409 rates.AddBssMembershipSelectorRate (selector);
410 }
411 }
412 return rates;
413}
414
417{
418 NS_LOG_FUNCTION (this);
419 DsssParameterSet dsssParameters;
420 if (GetDsssSupported ())
421 {
422 dsssParameters.SetDsssSupported (1);
423 dsssParameters.SetCurrentChannel (GetWifiPhy ()->GetChannelNumber ());
424 }
425 return dsssParameters;
426}
427
430{
431 NS_LOG_FUNCTION (this);
432 CapabilityInformation capabilities;
435 capabilities.SetEss ();
436 return capabilities;
437}
438
441{
442 NS_LOG_FUNCTION (this);
443 ErpInformation information;
444 information.SetErpSupported (1);
445 if (GetErpSupported ())
446 {
447 information.SetNonErpPresent (m_numNonErpStations > 0);
450 {
451 information.SetBarkerPreambleMode (0);
452 }
453 else
454 {
455 information.SetBarkerPreambleMode (1);
456 }
457 }
458 return information;
459}
460
463{
464 NS_LOG_FUNCTION (this);
465 EdcaParameterSet edcaParameters;
466 if (GetQosSupported ())
467 {
468 edcaParameters.SetQosSupported (1);
469 Ptr<QosTxop> edca;
470 Time txopLimit;
471
472 edca = GetQosTxop (AC_BE);
473 txopLimit = edca->GetTxopLimit ();
474 edcaParameters.SetBeAci (0);
475 edcaParameters.SetBeCWmin (edca->GetMinCw ());
476 edcaParameters.SetBeCWmax (edca->GetMaxCw ());
477 edcaParameters.SetBeAifsn (edca->GetAifsn ());
478 edcaParameters.SetBeTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
479
480 edca = GetQosTxop (AC_BK);
481 txopLimit = edca->GetTxopLimit ();
482 edcaParameters.SetBkAci (1);
483 edcaParameters.SetBkCWmin (edca->GetMinCw ());
484 edcaParameters.SetBkCWmax (edca->GetMaxCw ());
485 edcaParameters.SetBkAifsn (edca->GetAifsn ());
486 edcaParameters.SetBkTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
487
488 edca = GetQosTxop (AC_VI);
489 txopLimit = edca->GetTxopLimit ();
490 edcaParameters.SetViAci (2);
491 edcaParameters.SetViCWmin (edca->GetMinCw ());
492 edcaParameters.SetViCWmax (edca->GetMaxCw ());
493 edcaParameters.SetViAifsn (edca->GetAifsn ());
494 edcaParameters.SetViTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
495
496 edca = GetQosTxop (AC_VO);
497 txopLimit = edca->GetTxopLimit ();
498 edcaParameters.SetVoAci (3);
499 edcaParameters.SetVoCWmin (edca->GetMinCw ());
500 edcaParameters.SetVoCWmax (edca->GetMaxCw ());
501 edcaParameters.SetVoAifsn (edca->GetAifsn ());
502 edcaParameters.SetVoTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
503
504 edcaParameters.SetQosInfo (0);
505 }
506 return edcaParameters;
507}
508
511{
512 NS_LOG_FUNCTION (this);
513 MuEdcaParameterSet muEdcaParameters;
514 if (GetHeSupported ())
515 {
516 Ptr<HeConfiguration> heConfiguration = GetHeConfiguration ();
517 NS_ASSERT (heConfiguration != 0);
518
519 muEdcaParameters.SetQosInfo (0);
520
521 UintegerValue uintegerValue;
522 TimeValue timeValue;
523
524 heConfiguration->GetAttribute ("MuBeAifsn", uintegerValue);
525 muEdcaParameters.SetMuAifsn (AC_BE, uintegerValue.Get ());
526 heConfiguration->GetAttribute ("MuBeCwMin", uintegerValue);
527 muEdcaParameters.SetMuCwMin (AC_BE, uintegerValue.Get ());
528 heConfiguration->GetAttribute ("MuBeCwMax", uintegerValue);
529 muEdcaParameters.SetMuCwMax (AC_BE, uintegerValue.Get ());
530 heConfiguration->GetAttribute ("BeMuEdcaTimer", timeValue);
531 muEdcaParameters.SetMuEdcaTimer (AC_BE, timeValue.Get ());
532
533 heConfiguration->GetAttribute ("MuBkAifsn", uintegerValue);
534 muEdcaParameters.SetMuAifsn (AC_BK, uintegerValue.Get ());
535 heConfiguration->GetAttribute ("MuBkCwMin", uintegerValue);
536 muEdcaParameters.SetMuCwMin (AC_BK, uintegerValue.Get ());
537 heConfiguration->GetAttribute ("MuBkCwMax", uintegerValue);
538 muEdcaParameters.SetMuCwMax (AC_BK, uintegerValue.Get ());
539 heConfiguration->GetAttribute ("BkMuEdcaTimer", timeValue);
540 muEdcaParameters.SetMuEdcaTimer (AC_BK, timeValue.Get ());
541
542 heConfiguration->GetAttribute ("MuViAifsn", uintegerValue);
543 muEdcaParameters.SetMuAifsn (AC_VI, uintegerValue.Get ());
544 heConfiguration->GetAttribute ("MuViCwMin", uintegerValue);
545 muEdcaParameters.SetMuCwMin (AC_VI, uintegerValue.Get ());
546 heConfiguration->GetAttribute ("MuViCwMax", uintegerValue);
547 muEdcaParameters.SetMuCwMax (AC_VI, uintegerValue.Get ());
548 heConfiguration->GetAttribute ("ViMuEdcaTimer", timeValue);
549 muEdcaParameters.SetMuEdcaTimer (AC_VI, timeValue.Get ());
550
551 heConfiguration->GetAttribute ("MuVoAifsn", uintegerValue);
552 muEdcaParameters.SetMuAifsn (AC_VO, uintegerValue.Get ());
553 heConfiguration->GetAttribute ("MuVoCwMin", uintegerValue);
554 muEdcaParameters.SetMuCwMin (AC_VO, uintegerValue.Get ());
555 heConfiguration->GetAttribute ("MuVoCwMax", uintegerValue);
556 muEdcaParameters.SetMuCwMax (AC_VO, uintegerValue.Get ());
557 heConfiguration->GetAttribute ("VoMuEdcaTimer", timeValue);
558 muEdcaParameters.SetMuEdcaTimer (AC_VO, timeValue.Get ());
559 }
560 return muEdcaParameters;
561}
562
565{
566 NS_LOG_FUNCTION (this);
567 HtOperation operation;
568 if (GetHtSupported ())
569 {
570 operation.SetHtSupported (1);
571 operation.SetPrimaryChannel (GetWifiPhy ()->GetPrimaryChannelNumber (20));
572 operation.SetRifsMode (false);
573 operation.SetNonGfHtStasPresent (true);
574 if (GetWifiPhy ()->GetChannelWidth () > 20)
575 {
576 operation.SetSecondaryChannelOffset (1);
577 operation.SetStaChannelWidth (1);
578 }
579 if (m_numNonHtStations == 0)
580 {
581 operation.SetHtProtection (NO_PROTECTION);
582 }
583 else
584 {
586 }
587 uint64_t maxSupportedRate = 0; //in bit/s
588 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT))
589 {
590 uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
591 NS_ASSERT (nss > 0 && nss < 5);
592 uint64_t dataRate = mcs.GetDataRate (GetWifiPhy ()->GetChannelWidth (), GetHtConfiguration ()->GetShortGuardIntervalSupported () ? 400 : 800, nss);
593 if (dataRate > maxSupportedRate)
594 {
595 maxSupportedRate = dataRate;
596 NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate);
597 }
598 }
599 uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedTxSpatialStreams ();
600 auto mcsList = GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT);
601 uint8_t nMcs = mcsList.size ();
602 for (const auto& sta : m_staList)
603 {
604 if (GetWifiRemoteStationManager ()->GetHtSupported (sta.second))
605 {
606 uint64_t maxSupportedRateByHtSta = 0; //in bit/s
607 auto itMcs = mcsList.begin ();
608 for (uint8_t j = 0; j < (std::min (nMcs, GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second))); j++)
609 {
610 WifiMode mcs = *itMcs++;
611 uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
612 NS_ASSERT (nss > 0 && nss < 5);
613 uint64_t dataRate = mcs.GetDataRate (GetWifiRemoteStationManager ()->GetChannelWidthSupported (sta.second),
614 GetWifiRemoteStationManager ()->GetShortGuardIntervalSupported (sta.second) ? 400 : 800, nss);
615 if (dataRate > maxSupportedRateByHtSta)
616 {
617 maxSupportedRateByHtSta = dataRate;
618 }
619 }
620 if (maxSupportedRateByHtSta < maxSupportedRate)
621 {
622 maxSupportedRate = maxSupportedRateByHtSta;
623 }
624 if (GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second) < nMcs)
625 {
626 nMcs = GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second);
627 }
628 if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream)
629 {
630 maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second);
631 }
632 }
633 }
634 operation.SetRxHighestSupportedDataRate (static_cast<uint16_t> (maxSupportedRate / 1e6)); //in Mbit/s
635 operation.SetTxMcsSetDefined (nMcs > 0);
636 operation.SetTxMaxNSpatialStreams (maxSpatialStream);
637 //To be filled in once supported
638 operation.SetObssNonHtStasPresent (0);
639 operation.SetDualBeacon (0);
640 operation.SetDualCtsProtection (0);
641 operation.SetStbcBeacon (0);
643 operation.SetPcoActive (0);
644 operation.SetPhase (0);
645 operation.SetRxMcsBitmask (0);
646 operation.SetTxRxMcsSetUnequal (0);
647 operation.SetTxUnequalModulation (0);
648 }
649 return operation;
650}
651
654{
655 NS_LOG_FUNCTION (this);
656 VhtOperation operation;
657 if (GetVhtSupported ())
658 {
659 operation.SetVhtSupported (1);
660 const uint16_t bssBandwidth = GetWifiPhy ()->GetChannelWidth ();
661 // Set to 0 for 20 MHz or 40 MHz BSS bandwidth.
662 // Set to 1 for 80 MHz, 160 MHz or 80+80 MHz BSS bandwidth.
663 operation.SetChannelWidth ((bssBandwidth > 40) ? 1 : 0);
664 // For 20, 40, or 80 MHz BSS bandwidth, indicates the channel center frequency
665 // index for the 20, 40, or 80 MHz channel on which the VHT BSS operates.
666 // For 160 MHz BSS bandwidth and the Channel Width subfield equal to 1,
667 // indicates the channel center frequency index of the 80 MHz channel
668 // segment that contains the primary channel.
669 operation.SetChannelCenterFrequencySegment0 ((bssBandwidth == 160) ?
670 GetWifiPhy ()->GetOperatingChannel ().GetPrimaryChannelNumber (80, WIFI_STANDARD_80211ac) :
671 GetWifiPhy ()->GetChannelNumber ());
672 // For a 20, 40, or 80 MHz BSS bandwidth, this subfield is set to 0.
673 // For a 160 MHz BSS bandwidth and the Channel Width subfield equal to 1,
674 // indicates the channel center frequency index of the 160 MHz channel on
675 // which the VHT BSS operates.
676 operation.SetChannelCenterFrequencySegment1 ((bssBandwidth == 160) ? GetWifiPhy ()->GetChannelNumber () : 0);
677 uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams ();
678 for (const auto& sta : m_staList)
679 {
680 if (GetWifiRemoteStationManager ()->GetVhtSupported (sta.second))
681 {
682 if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream)
683 {
684 maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second);
685 }
686 }
687 }
688 for (uint8_t nss = 1; nss <= maxSpatialStream; nss++)
689 {
690 uint8_t maxMcs = 9; //TBD: hardcode to 9 for now since we assume all MCS values are supported
691 operation.SetMaxVhtMcsPerNss (nss, maxMcs);
692 }
693 }
694 return operation;
695}
696
699{
700 NS_LOG_FUNCTION (this);
701 HeOperation operation;
702 if (GetHeSupported ())
703 {
704 operation.SetHeSupported (1);
705 uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams ();
706 for (const auto& sta : m_staList)
707 {
708 if (GetWifiRemoteStationManager ()->GetHeSupported (sta.second))
709 {
710 if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream)
711 {
712 maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second);
713 }
714 }
715 }
716 for (uint8_t nss = 1; nss <= maxSpatialStream; nss++)
717 {
718 operation.SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported
719 }
720 operation.SetBssColor (GetHeConfiguration ()->GetBssColor ());
721 }
722 return operation;
723}
724
725void
727{
728 NS_LOG_FUNCTION (this << to);
729 WifiMacHeader hdr;
731 hdr.SetAddr1 (to);
732 hdr.SetAddr2 (GetAddress ());
733 hdr.SetAddr3 (GetAddress ());
734 hdr.SetDsNotFrom ();
735 hdr.SetDsNotTo ();
736 Ptr<Packet> packet = Create<Packet> ();
738 probe.SetSsid (GetSsid ());
740 probe.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
744 if (GetDsssSupported ())
745 {
747 }
748 if (GetErpSupported ())
749 {
751 }
752 if (GetQosSupported ())
753 {
755 }
756 if (GetHtSupported ())
757 {
761 }
762 if (GetVhtSupported ())
763 {
766 }
767 if (GetHeSupported ())
768 {
772 }
773 if (GetEhtSupported ())
774 {
776 }
777 packet->AddHeader (probe);
778
779 if (!GetQosSupported ())
780 {
781 GetTxop ()->Queue (packet, hdr);
782 }
783 // "A QoS STA that transmits a Management frame determines access category used
784 // for medium access in transmission of the Management frame as follows
785 // (If dot11QMFActivated is false or not present)
786 // — If the Management frame is individually addressed to a non-QoS STA, category
787 // AC_BE should be selected.
788 // — If category AC_BE was not selected by the previous step, category AC_VO
789 // shall be selected." (Sec. 10.2.3.2 of 802.11-2020)
791 {
792 GetBEQueue ()->Queue (packet, hdr);
793 }
794 else
795 {
796 GetVOQueue ()->Queue (packet, hdr);
797 }
798}
799
800void
801ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc)
802{
803 NS_LOG_FUNCTION (this << to << success << isReassoc);
804 WifiMacHeader hdr;
806 hdr.SetAddr1 (to);
807 hdr.SetAddr2 (GetAddress ());
808 hdr.SetAddr3 (GetAddress ());
809 hdr.SetDsNotFrom ();
810 hdr.SetDsNotTo ();
811 Ptr<Packet> packet = Create<Packet> ();
813 StatusCode code;
814 if (success)
815 {
816 code.SetSuccess ();
817 uint16_t aid = 0;
818 bool found = false;
819 if (isReassoc)
820 {
821 for (const auto& sta : m_staList)
822 {
823 if (sta.second == to)
824 {
825 aid = sta.first;
826 found = true;
827 break;
828 }
829 }
830 }
831 if (!found)
832 {
833 aid = GetNextAssociationId ();
834 m_staList.insert (std::make_pair (aid, to));
835 m_assocLogger (aid, to);
837 if (GetWifiRemoteStationManager ()->GetDsssSupported (to) && !GetWifiRemoteStationManager ()->GetErpOfdmSupported (to))
838 {
840 }
842 {
844 }
847 }
848 assoc.SetAssociationId (aid);
849 }
850 else
851 {
852 code.SetFailure ();
853 }
855 assoc.SetStatusCode (code);
857 if (GetErpSupported ())
858 {
860 }
861 if (GetQosSupported ())
862 {
864 }
865 if (GetHtSupported ())
866 {
870 }
871 if (GetVhtSupported ())
872 {
875 }
876 if (GetHeSupported ())
877 {
881 }
882 if (GetEhtSupported ())
883 {
885 }
886 packet->AddHeader (assoc);
887
888 if (!GetQosSupported ())
889 {
890 GetTxop ()->Queue (packet, hdr);
891 }
892 // "A QoS STA that transmits a Management frame determines access category used
893 // for medium access in transmission of the Management frame as follows
894 // (If dot11QMFActivated is false or not present)
895 // — If the Management frame is individually addressed to a non-QoS STA, category
896 // AC_BE should be selected.
897 // — If category AC_BE was not selected by the previous step, category AC_VO
898 // shall be selected." (Sec. 10.2.3.2 of 802.11-2020)
900 {
901 GetBEQueue ()->Queue (packet, hdr);
902 }
903 else
904 {
905 GetVOQueue ()->Queue (packet, hdr);
906 }
907}
908
909void
911{
912 NS_LOG_FUNCTION (this);
913 WifiMacHeader hdr;
916 hdr.SetAddr2 (GetAddress ());
917 hdr.SetAddr3 (GetAddress ());
918 hdr.SetDsNotFrom ();
919 hdr.SetDsNotTo ();
920 Ptr<Packet> packet = Create<Packet> ();
921 MgtBeaconHeader beacon;
922 beacon.SetSsid (GetSsid ());
924 beacon.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
928 if (GetDsssSupported ())
929 {
931 }
932 if (GetErpSupported ())
933 {
935 }
936 if (GetQosSupported ())
937 {
939 }
940 if (GetHtSupported ())
941 {
944 beacon.SetHtOperation (GetHtOperation ());
945 }
946 if (GetVhtSupported ())
947 {
950 }
951 if (GetHeSupported ())
952 {
954 beacon.SetHeOperation (GetHeOperation ());
956 }
957 if (GetEhtSupported ())
958 {
960 }
961 packet->AddHeader (beacon);
962
963 //The beacon has it's own special queue, so we load it in there
964 m_beaconTxop->Queue (packet, hdr);
966
967 //If a STA that does not support Short Slot Time associates,
968 //the AP shall use long slot time beginning at the first Beacon
969 //subsequent to the association of the long slot time STA.
970 if (GetErpSupported ())
971 {
973 {
974 //Enable short slot time
976 }
977 else
978 {
979 //Disable short slot time
981 }
982 }
983}
984
985void
987{
988 NS_LOG_FUNCTION (this << *mpdu);
989 const WifiMacHeader& hdr = mpdu->GetHeader ();
990 if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
991 && GetWifiRemoteStationManager ()->IsWaitAssocTxOk (hdr.GetAddr1 ()))
992 {
993 NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
995 }
996}
997
998void
1000{
1001 NS_LOG_FUNCTION (this << +timeoutReason << *mpdu);
1002 const WifiMacHeader& hdr = mpdu->GetHeader ();
1003
1004 if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
1005 && GetWifiRemoteStationManager ()->IsWaitAssocTxOk (hdr.GetAddr1 ()))
1006 {
1007 NS_LOG_DEBUG ("association failed with sta=" << hdr.GetAddr1 ());
1009 }
1010}
1011
1012void
1014{
1015 NS_LOG_FUNCTION (this << *mpdu);
1016 const WifiMacHeader* hdr = &mpdu->GetHeader ();
1017 Ptr<const Packet> packet = mpdu->GetPacket ();
1018 Mac48Address from = hdr->GetAddr2 ();
1019 if (hdr->IsData ())
1020 {
1021 Mac48Address bssid = hdr->GetAddr1 ();
1022 if (!hdr->IsFromDs ()
1023 && hdr->IsToDs ()
1024 && bssid == GetAddress ()
1025 && GetWifiRemoteStationManager ()->IsAssociated (from))
1026 {
1027 Mac48Address to = hdr->GetAddr3 ();
1028 if (to == GetAddress ())
1029 {
1030 NS_LOG_DEBUG ("frame for me from=" << from);
1031 if (hdr->IsQosData ())
1032 {
1033 if (hdr->IsQosAmsdu ())
1034 {
1035 NS_LOG_DEBUG ("Received A-MSDU from=" << from << ", size=" << packet->GetSize ());
1037 packet = 0;
1038 }
1039 else
1040 {
1041 ForwardUp (packet, from, bssid);
1042 }
1043 }
1044 else if (hdr->HasData ())
1045 {
1046 ForwardUp (packet, from, bssid);
1047 }
1048 }
1049 else if (to.IsGroup ()
1050 || GetWifiRemoteStationManager ()->IsAssociated (to))
1051 {
1052 NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to);
1053 Ptr<Packet> copy = packet->Copy ();
1054
1055 //If the frame we are forwarding is of type QoS Data,
1056 //then we need to preserve the UP in the QoS control
1057 //header...
1058 if (hdr->IsQosData ())
1059 {
1060 ForwardDown (copy, from, to, hdr->GetQosTid ());
1061 }
1062 else
1063 {
1064 ForwardDown (copy, from, to);
1065 }
1066 ForwardUp (packet, from, to);
1067 }
1068 else
1069 {
1070 ForwardUp (packet, from, to);
1071 }
1072 }
1073 else if (hdr->IsFromDs ()
1074 && hdr->IsToDs ())
1075 {
1076 //this is an AP-to-AP frame
1077 //we ignore for now.
1078 NotifyRxDrop (packet);
1079 }
1080 else
1081 {
1082 //we can ignore these frames since
1083 //they are not targeted at the AP
1084 NotifyRxDrop (packet);
1085 }
1086 return;
1087 }
1088 else if (hdr->IsMgt ())
1089 {
1090 if (hdr->IsProbeReq ()
1091 && (hdr->GetAddr1 ().IsGroup () || hdr->GetAddr1 () == GetAddress ()))
1092 {
1093 // In the case where the Address 1 field contains a group address, the
1094 // Address 3 field also is validated to verify that the group addressed
1095 // frame originated from a STA in the BSS of which the receiving STA is
1096 // a member (Section 9.3.3.1 of 802.11-2020)
1097 if (hdr->GetAddr1 ().IsGroup ()
1098 && !hdr->GetAddr3 ().IsBroadcast () && hdr->GetAddr3 () != GetAddress ())
1099 {
1100 // not addressed to us
1101 return;
1102 }
1103 MgtProbeRequestHeader probeRequestHeader;
1104 packet->PeekHeader (probeRequestHeader);
1105 Ssid ssid = probeRequestHeader.GetSsid ();
1106 if (ssid == GetSsid () || ssid.IsBroadcast ())
1107 {
1108 NS_LOG_DEBUG ("Probe request received from " << from << ": send probe response");
1109 SendProbeResp (from);
1110 }
1111 return;
1112 }
1113 else if (hdr->GetAddr1 () == GetAddress ())
1114 {
1115 if (hdr->IsAssocReq ())
1116 {
1117 NS_LOG_DEBUG ("Association request received from " << from);
1118 //first, verify that the the station's supported
1119 //rate set is compatible with our Basic Rate set
1120 MgtAssocRequestHeader assocReq;
1121 packet->PeekHeader (assocReq);
1122 CapabilityInformation capabilities = assocReq.GetCapabilities ();
1124 SupportedRates rates = assocReq.GetSupportedRates ();
1125 bool problem = false;
1126 if (rates.GetNRates () == 0)
1127 {
1128 problem = true;
1129 }
1130 if (GetHtSupported ())
1131 {
1132 //check whether the HT STA supports all MCSs in Basic MCS Set
1133 HtCapabilities htCapabilities = assocReq.GetHtCapabilities ();
1134 if (htCapabilities.IsSupportedMcs (0))
1135 {
1136 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1137 {
1139 if (!htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1140 {
1141 problem = true;
1142 break;
1143 }
1144 }
1145 }
1146 }
1147 if (GetVhtSupported ())
1148 {
1149 //check whether the VHT STA supports all MCSs in Basic MCS Set
1150 VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilities ();
1151 if (vhtCapabilities.GetVhtCapabilitiesInfo () != 0)
1152 {
1153 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1154 {
1156 if (!vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1157 {
1158 problem = true;
1159 break;
1160 }
1161 }
1162 }
1163 }
1164 if (GetHeSupported ())
1165 {
1166 //check whether the HE STA supports all MCSs in Basic MCS Set
1167 HeCapabilities heCapabilities = assocReq.GetHeCapabilities ();
1168 if (heCapabilities.GetSupportedMcsAndNss () != 0)
1169 {
1170 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1171 {
1173 if (!heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1174 {
1175 problem = true;
1176 break;
1177 }
1178 }
1179 }
1180 }
1181 if (GetEhtSupported ())
1182 {
1183 //check whether the EHT STA supports all MCSs in Basic MCS Set
1184 EhtCapabilities ehtCapabilities = assocReq.GetEhtCapabilities ();
1185 //TODO: to be completed
1186 }
1187 if (problem)
1188 {
1189 NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send association response with an error status");
1190 SendAssocResp (hdr->GetAddr2 (), false, false);
1191 }
1192 else
1193 {
1194 NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1195 //record all its supported modes in its associated WifiRemoteStation
1196 for (const auto & mode : GetWifiPhy ()->GetModeList ())
1197 {
1198 if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
1199 {
1201 }
1202 }
1203 if (GetErpSupported () && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ())
1204 {
1206 }
1207 if (GetHtSupported ())
1208 {
1209 HtCapabilities htCapabilities = assocReq.GetHtCapabilities ();
1210 if (htCapabilities.IsSupportedMcs (0))
1211 {
1212 GetWifiRemoteStationManager ()->AddStationHtCapabilities (from, htCapabilities);
1213 }
1214 }
1215 if (GetVhtSupported ())
1216 {
1217 VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilities ();
1218 //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1219 if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1220 {
1221 GetWifiRemoteStationManager ()->AddStationVhtCapabilities (from, vhtCapabilities);
1222 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT))
1223 {
1224 if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1225 {
1227 //here should add a control to add basic MCS when it is implemented
1228 }
1229 }
1230 }
1231 }
1232 if (GetHtSupported ())
1233 {
1234 ExtendedCapabilities extendedCapabilities = assocReq.GetExtendedCapabilities ();
1235 //TODO: to be completed
1236 }
1237 if (GetHeSupported ())
1238 {
1239 HeCapabilities heCapabilities = assocReq.GetHeCapabilities ();
1240 if (heCapabilities.GetSupportedMcsAndNss () != 0)
1241 {
1242 GetWifiRemoteStationManager ()->AddStationHeCapabilities (from, heCapabilities);
1243 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
1244 {
1245 if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1246 {
1248 //here should add a control to add basic MCS when it is implemented
1249 }
1250 }
1251 }
1252 }
1253 if (GetEhtSupported ())
1254 {
1255 EhtCapabilities ehtCapabilities = assocReq.GetEhtCapabilities ();
1256 //TODO: once we support non constant rate managers, we should add checks here whether EHT is supported by the peer
1257 GetWifiRemoteStationManager ()->AddStationEhtCapabilities (from, ehtCapabilities);
1258 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_EHT))
1259 {
1260 //TODO: Add check whether MCS is supported from the capabilities
1262 //here should add a control to add basic MCS when it is implemented
1263 }
1264 }
1266 NS_LOG_DEBUG ("Send association response with success status");
1267 SendAssocResp (hdr->GetAddr2 (), true, false);
1268 }
1269 return;
1270 }
1271 else if (hdr->IsReassocReq ())
1272 {
1273 NS_LOG_DEBUG ("Reassociation request received from " << from);
1274 //first, verify that the the station's supported
1275 //rate set is compatible with our Basic Rate set
1276 MgtReassocRequestHeader reassocReq;
1277 packet->PeekHeader (reassocReq);
1278 CapabilityInformation capabilities = reassocReq.GetCapabilities ();
1280 SupportedRates rates = reassocReq.GetSupportedRates ();
1281 bool problem = false;
1282 if (rates.GetNRates () == 0)
1283 {
1284 problem = true;
1285 }
1286 if (GetHtSupported ())
1287 {
1288 //check whether the HT STA supports all MCSs in Basic MCS Set
1289 HtCapabilities htCapabilities = reassocReq.GetHtCapabilities ();
1290 if (htCapabilities.IsSupportedMcs (0))
1291 {
1292 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1293 {
1295 if (!htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1296 {
1297 problem = true;
1298 break;
1299 }
1300 }
1301 }
1302 }
1303 if (GetVhtSupported ())
1304 {
1305 //check whether the VHT STA supports all MCSs in Basic MCS Set
1306 VhtCapabilities vhtCapabilities = reassocReq.GetVhtCapabilities ();
1307 if (vhtCapabilities.GetVhtCapabilitiesInfo () != 0)
1308 {
1309 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1310 {
1312 if (!vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1313 {
1314 problem = true;
1315 break;
1316 }
1317 }
1318 }
1319 }
1320 if (GetHeSupported ())
1321 {
1322 //check whether the HE STA supports all MCSs in Basic MCS Set
1323 HeCapabilities heCapabilities = reassocReq.GetHeCapabilities ();
1324 if (heCapabilities.GetSupportedMcsAndNss () != 0)
1325 {
1326 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1327 {
1329 if (!heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1330 {
1331 problem = true;
1332 break;
1333 }
1334 }
1335 }
1336 }
1337 if (GetEhtSupported ())
1338 {
1339 //check whether the EHT STA supports all MCSs in Basic MCS Set
1340 EhtCapabilities ehtCapabilities = reassocReq.GetEhtCapabilities ();
1341 //TODO: to be completed
1342 }
1343 if (problem)
1344 {
1345 NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send reassociation response with an error status");
1346 SendAssocResp (hdr->GetAddr2 (), false, true);
1347 }
1348 else
1349 {
1350 NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1351 //update all its supported modes in its associated WifiRemoteStation
1352 for (const auto & mode : GetWifiPhy ()->GetModeList ())
1353 {
1354 if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
1355 {
1357 }
1358 }
1359 if (GetErpSupported () && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ())
1360 {
1362 }
1363 if (GetHtSupported ())
1364 {
1365 HtCapabilities htCapabilities = reassocReq.GetHtCapabilities ();
1366 if (htCapabilities.IsSupportedMcs (0))
1367 {
1368 GetWifiRemoteStationManager ()->AddStationHtCapabilities (from, htCapabilities);
1369 }
1370 }
1371 if (GetVhtSupported ())
1372 {
1373 VhtCapabilities vhtCapabilities = reassocReq.GetVhtCapabilities ();
1374 //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1375 if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1376 {
1377 GetWifiRemoteStationManager ()->AddStationVhtCapabilities (from, vhtCapabilities);
1378 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT))
1379 {
1380 if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1381 {
1383 //here should add a control to add basic MCS when it is implemented
1384 }
1385 }
1386 }
1387 }
1388 if (GetHtSupported ())
1389 {
1390 ExtendedCapabilities extendedCapabilities = reassocReq.GetExtendedCapabilities ();
1391 //TODO: to be completed
1392 }
1393 if (GetHeSupported ())
1394 {
1395 HeCapabilities heCapabilities = reassocReq.GetHeCapabilities ();
1396 if (heCapabilities.GetSupportedMcsAndNss () != 0)
1397 {
1398 GetWifiRemoteStationManager ()->AddStationHeCapabilities (from, heCapabilities);
1399 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
1400 {
1401 if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1402 {
1404 //here should add a control to add basic MCS when it is implemented
1405 }
1406 }
1407 }
1408 }
1409 if (GetEhtSupported ())
1410 {
1411 EhtCapabilities ehtCapabilities = reassocReq.GetEhtCapabilities ();
1412 //TODO: once we support non constant rate managers, we should add checks here whether HE is supported by the peer
1413 GetWifiRemoteStationManager ()->AddStationEhtCapabilities (from, ehtCapabilities);
1414 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
1415 {
1416 //TODO: Add check whether MCS is supported from the capabilities
1418 //here should add a control to add basic MCS when it is implemented
1419 }
1420 }
1422 NS_LOG_DEBUG ("Send reassociation response with success status");
1423 SendAssocResp (hdr->GetAddr2 (), true, true);
1424 }
1425 return;
1426 }
1427 else if (hdr->IsDisassociation ())
1428 {
1429 NS_LOG_DEBUG ("Disassociation received from " << from);
1431 for (auto it = m_staList.begin (); it != m_staList.end (); ++it)
1432 {
1433 if (it->second == from)
1434 {
1435 m_staList.erase (it);
1436 m_deAssocLogger (it->first, it->second);
1437 if (GetWifiRemoteStationManager ()->GetDsssSupported (from) && !GetWifiRemoteStationManager ()->GetErpOfdmSupported (from))
1438 {
1440 }
1442 {
1444 }
1447 break;
1448 }
1449 }
1450 return;
1451 }
1452 }
1453 }
1454
1455 //Invoke the receive handler of our parent class to deal with any
1456 //other frames. Specifically, this will handle Block Ack-related
1457 //Management Action frames.
1458 WifiMac::Receive (Create<WifiMacQueueItem> (packet, *hdr));
1459}
1460
1461void
1463{
1464 NS_LOG_FUNCTION (this << *mpdu);
1465 for (auto& i : *PeekPointer (mpdu))
1466 {
1467 if (i.second.GetDestinationAddr () == GetAddress ())
1468 {
1469 ForwardUp (i.first, i.second.GetSourceAddr (),
1470 i.second.GetDestinationAddr ());
1471 }
1472 else
1473 {
1474 Mac48Address from = i.second.GetSourceAddr ();
1475 Mac48Address to = i.second.GetDestinationAddr ();
1476 NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
1477 ForwardDown (i.first->Copy (), from, to, mpdu->GetHeader ().GetQosTid ());
1478 }
1479 }
1480}
1481
1482void
1484{
1485 NS_LOG_FUNCTION (this);
1489 {
1491 {
1492 Time jitter = MicroSeconds (static_cast<int64_t> (m_beaconJitter->GetValue (0, 1) * (GetBeaconInterval ().GetMicroSeconds ())));
1493 NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time " << jitter);
1495 }
1496 else
1497 {
1498 NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress () << " at time 0");
1500 }
1501 }
1507}
1508
1509bool
1511{
1512 bool useProtection = (m_numNonErpStations > 0) && m_enableNonErpProtection;
1514 return useProtection;
1515}
1516
1517uint16_t
1519{
1520 //Return the first free AID value between 1 and 2007
1521 for (uint16_t nextAid = 1; nextAid <= 2007; nextAid++)
1522 {
1523 if (m_staList.find (nextAid) == m_staList.end ())
1524 {
1525 return nextAid;
1526 }
1527 }
1528 NS_FATAL_ERROR ("No free association ID available!");
1529 return 0;
1530}
1531
1532const std::map<uint16_t, Mac48Address>&
1534{
1535 return m_staList;
1536}
1537
1538uint16_t
1540{
1542}
1543
1544uint8_t
1546{
1547 auto it = m_bufferStatus.find (WifiAddressTidPair (address, tid));
1548 if (it == m_bufferStatus.end ()
1549 || it->second.timestamp + m_bsrLifetime < Simulator::Now ())
1550 {
1551 return 255;
1552 }
1553 return it->second.value;
1554}
1555
1556void
1558{
1559 if (size == 255)
1560 {
1561 // no point in storing an unspecified size
1563 }
1564 else
1565 {
1567 }
1568}
1569
1570uint8_t
1572{
1573 uint8_t maxSize = 0;
1574 bool found = false;
1575
1576 for (uint8_t tid = 0; tid < 8; tid++)
1577 {
1578 uint8_t size = GetBufferStatus (tid, address);
1579 if (size != 255)
1580 {
1581 maxSize = std::max (maxSize, size);
1582 found = true;
1583 }
1584 }
1585
1586 if (found)
1587 {
1588 return maxSize;
1589 }
1590 return 255;
1591}
1592
1593} //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:314
Ptr< Txop > m_beaconTxop
Dedicated Txop for beacons.
Definition: ap-wifi-mac.h:304
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:726
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
Definition: ap-wifi-mac.cc:373
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:698
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:312
Ptr< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
Definition: ap-wifi-mac.h:308
void TxOk(Ptr< const WifiMacQueueItem > mpdu)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:986
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
Definition: ap-wifi-mac.cc:336
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:315
bool m_shortSlotTimeEnabled
Flag whether short slot time is enabled within the BSS.
Definition: ap-wifi-mac.h:313
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:440
HtOperation GetHtOperation(void) const
Return the HT operation of the current AP.
Definition: ap-wifi-mac.cc:564
bool SupportsSendFrom(void) const override
Definition: ap-wifi-mac.cc:366
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:310
DsssParameterSet GetDsssParameterSet(void) const
Return the DSSS Parameter Set that we support.
Definition: ap-wifi-mac.cc:416
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:429
void SendOneBeacon(void)
Forward a beacon packet to the beacon special DCF.
Definition: ap-wifi-mac.cc:910
TracedCallback< uint16_t, Mac48Address > m_deAssocLogger
deassociation logger
Definition: ap-wifi-mac.h:335
bool m_enableBeaconGeneration
Flag whether beacons are being generated.
Definition: ap-wifi-mac.h:305
Time m_beaconInterval
Beacon interval.
Definition: ap-wifi-mac.h:306
void TxFailed(WifiMacDropReason timeoutReason, Ptr< const WifiMacQueueItem > mpdu)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:999
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:309
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:510
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set of the current AP.
Definition: ap-wifi-mac.cc:462
TracedCallback< uint16_t, Mac48Address > m_assocLogger
association logger
Definition: ap-wifi-mac.h:334
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:307
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:356
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:316
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:311
VhtOperation GetVhtOperation(void) const
Return the VHT operation of the current AP.
Definition: ap-wifi-mac.cc:653
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:801
std::unordered_map< WifiAddressTidPair, bsrType, WifiAddressTidHash > m_bufferStatus
Per (MAC address, TID) buffer status reports.
Definition: ap-wifi-mac.h:324
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet down to DCF/EDCAF (enqueue the packet).
Definition: ap-wifi-mac.cc:260
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 IEEE 802.11be EHT Capabilities.
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:51
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:625
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:577
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:589
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:601
EhtCapabilities GetEhtCapabilities(void) const
Return the EHT capabilities.
Definition: mgt-headers.cc:637
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:613
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:649
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:347
void SetErpInformation(ErpInformation erpInformation)
Set the ERP information.
void SetVhtCapabilities(VhtCapabilities vhtCapabilities)
Set the VHT capabilities.
void SetHtCapabilities(HtCapabilities htCapabilities)
Set the HT capabilities.
void SetHtOperation(HtOperation htOperation)
Set the HT operation.
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:993
void SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
void SetStatusCode(StatusCode code)
Set the status code.
Definition: mgt-headers.cc:981
void SetAssociationId(uint16_t aid)
Set the association ID.
void SetMuEdcaParameterSet(MuEdcaParameterSet muEdcaParameterSet)
Set the MU EDCA Parameter Set.
void SetEhtCapabilities(EhtCapabilities ehtCapabilities)
Set the EHT capabilities.
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.
void SetVhtOperation(VhtOperation vhtOperation)
Set the VHT operation.
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:987
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:928
Implement the header for management frames of type probe request.
Definition: mgt-headers.h:569
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:686
void SetVhtCapabilities(VhtCapabilities vhtCapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:284
void SetErpInformation(ErpInformation erpInformation)
Set the ERP information.
Definition: mgt-headers.cc:374
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:236
void SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:308
void SetExtendedCapabilities(ExtendedCapabilities extendedCapabilities)
Set the extended capabilities.
Definition: mgt-headers.cc:248
void SetVhtOperation(VhtOperation vhtOperation)
Set the VHT operation.
Definition: mgt-headers.cc:296
void SetHtCapabilities(HtCapabilities htCapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:260
void SetHtOperation(HtOperation htOperation)
Set the HT operation.
Definition: mgt-headers.cc:272
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:344
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:356
void SetDsssParameterSet(DsssParameterSet dsssParameterSet)
Set the DSSS Parameter Set.
Definition: mgt-headers.cc:362
void SetBeaconIntervalUs(uint64_t us)
Set the beacon interval in microseconds unit.
Definition: mgt-headers.cc:350
void SetEdcaParameterSet(EdcaParameterSet edcaParameterSet)
Set the EDCA Parameter Set.
Definition: mgt-headers.cc:386
void SetHeOperation(HeOperation heOperation)
Set the HE operation.
Definition: mgt-headers.cc:320
void SetEhtCapabilities(EhtCapabilities ehtCapabilities)
Set the EHT capabilities.
Definition: mgt-headers.cc:332
void SetMuEdcaParameterSet(MuEdcaParameterSet muEdcaParameterSet)
Set the MU EDCA Parameter Set.
Definition: mgt-headers.cc:392
Implement the header for management frames of type reassociation request.
Definition: mgt-headers.h:196
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:852
EhtCapabilities GetEhtCapabilities(void) const
Return the EHT capabilities.
Definition: mgt-headers.cc:840
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:828
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:816
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:804
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:780
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:792
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:555
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:586
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:519
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.
void SetChannelCenterFrequencySegment1(uint8_t channelCenterFrequencySegment1)
Set the Channel Center Frequency Segment 1 field in the VHT Operation information element.
void SetChannelCenterFrequencySegment0(uint8_t channelCenterFrequencySegment0)
Set the Channel Center Frequency Segment 0 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:86
Ptr< HtConfiguration > GetHtConfiguration(void) const
Definition: wifi-mac.cc:1052
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities of the device.
Definition: wifi-mac.cc:1196
bool GetShortSlotTimeSupported(void) const
Definition: wifi-mac.cc:877
Ptr< HeConfiguration > GetHeConfiguration(void) const
Definition: wifi-mac.cc:1064
bool GetVhtSupported() const
Return whether the device supports VHT.
Definition: wifi-mac.cc:1086
bool GetQosSupported() const
Return whether the device supports QoS.
Definition: wifi-mac.cc:827
virtual void SetAddress(Mac48Address address)
Definition: wifi-mac.cc:401
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
Definition: wifi-mac.cc:1341
Ssid GetSsid(void) const
Definition: wifi-mac.cc:421
void DoInitialize() override
Initialize() implementation.
Definition: wifi-mac.cc:325
Mac48Address GetAddress(void) const
Definition: wifi-mac.cc:408
Ptr< QosTxop > GetBEQueue(void) const
Accessor for the AC_BE channel access function.
Definition: wifi-mac.cc:490
bool GetHtSupported() const
Return whether the device supports HT.
Definition: wifi-mac.cc:1076
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Definition: wifi-mac.cc:376
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
Definition: wifi-mac.cc:762
Ptr< QosTxop > GetVOQueue(void) const
Accessor for the AC_VO channel access function.
Definition: wifi-mac.cc:478
Ptr< ChannelAccessManager > m_channelAccessManager
channel access manager
Definition: wifi-mac.h:538
bool GetEhtSupported() const
Return whether the device supports EHT.
Definition: wifi-mac.cc:1106
bool GetHeSupported() const
Return whether the device supports HE.
Definition: wifi-mac.cc:1096
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:928
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
Definition: wifi-mac.h:537
Ptr< WifiPhy > GetWifiPhy(void) const
Definition: wifi-mac.cc:781
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:502
EhtCapabilities GetEhtCapabilities(void) const
Return the EHT capabilities of the device.
Definition: wifi-mac.cc:1395
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:548
virtual void SetLinkUpCallback(Callback< void > linkUp)
Definition: wifi-mac.cc:896
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
Definition: wifi-mac.cc:921
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
Definition: wifi-mac.cc:1263
bool GetErpSupported() const
Return whether the device supports ERP.
Definition: wifi-mac.cc:833
bool GetDsssSupported() const
Return whether the device supports DSSS.
Definition: wifi-mac.cc:857
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
Definition: wifi-mac.cc:1207
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
Definition: wifi-mac.cc:457
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:530
void DoDispose() override
Destructor implementation.
Definition: wifi-mac.cc:341
void SetBssid(Mac48Address bssid)
Definition: wifi-mac.cc:427
Ptr< Txop > GetTxop(void) const
Accessor for the Txop object.
Definition: wifi-mac.cc:451
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:1775
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1167
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1149
void SetSlot(Time slot)
Set the slot duration for this PHY.
Definition: wifi-phy.cc:683
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:929
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 AddStationEhtCapabilities(Mac48Address from, EhtCapabilities ehtCapabilities)
Records EHT capabilities of the remote station.
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.
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:67
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_STANDARD_80211ac
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_EHT
EHT (Clause 36)
@ 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:55
@ 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:522
@ 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