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"
32#include "mac-tx-middle.h"
33#include "mac-rx-middle.h"
34#include "mgt-headers.h"
35#include "msdu-aggregator.h"
37#include "wifi-phy.h"
38#include "wifi-net-device.h"
39#include "wifi-mac-queue.h"
40#include "ns3/ht-configuration.h"
41#include "ns3/he-configuration.h"
42#include "qos-txop.h"
43
44namespace ns3 {
45
46NS_LOG_COMPONENT_DEFINE ("ApWifiMac");
47
49
50TypeId
52{
53 static TypeId tid = TypeId ("ns3::ApWifiMac")
55 .SetGroupName ("Wifi")
56 .AddConstructor<ApWifiMac> ()
57 .AddAttribute ("BeaconInterval",
58 "Delay between two beacons",
59 TimeValue (MicroSeconds (102400)),
63 .AddAttribute ("BeaconJitter",
64 "A uniform random variable to cause the initial beacon starting time (after simulation time 0) "
65 "to be distributed between 0 and the BeaconInterval.",
66 StringValue ("ns3::UniformRandomVariable"),
68 MakePointerChecker<UniformRandomVariable> ())
69 .AddAttribute ("EnableBeaconJitter",
70 "If beacons are enabled, whether to jitter the initial send event.",
71 BooleanValue (true),
74 .AddAttribute ("BeaconGeneration",
75 "Whether or not beacons are generated.",
76 BooleanValue (true),
79 .AddAttribute ("EnableNonErpProtection", "Whether or not protection mechanism should be used when non-ERP STAs are present within the BSS."
80 "This parameter is only used when ERP is supported by the AP.",
81 BooleanValue (true),
84 .AddAttribute ("BsrLifetime",
85 "Lifetime of Buffer Status Reports received from stations.",
89 .AddTraceSource ("AssociatedSta",
90 "A station associated with this access point.",
92 "ns3::ApWifiMac::AssociationCallback")
93 .AddTraceSource ("DeAssociatedSta",
94 "A station lost association with this access point.",
96 "ns3::ApWifiMac::AssociationCallback")
97 ;
98 return tid;
99}
100
102 : m_enableBeaconGeneration (false),
103 m_numNonErpStations (0),
104 m_numNonHtStations (0),
105 m_shortSlotTimeEnabled (false),
106 m_shortPreambleEnabled (false)
107{
108 NS_LOG_FUNCTION (this);
109 m_beaconTxop = CreateObject<Txop> (CreateObject<WifiMacQueue> (AC_BEACON));
111
112 //Let the lower layers know that we are acting as an AP.
114}
115
117{
118 NS_LOG_FUNCTION (this);
119 m_staList.clear ();
120}
121
122void
124{
125 NS_LOG_FUNCTION (this);
127 m_beaconTxop = 0;
130}
131
133{
136}
137
138std::unique_ptr<WifiMac::LinkEntity>
140{
141 return std::make_unique<ApLinkEntity> ();
142}
143
145ApWifiMac::GetLink (uint8_t linkId) const
146{
147 return static_cast<ApLinkEntity&> (WifiMac::GetLink (linkId));
148}
149
150void
152{
153 NS_LOG_FUNCTION (this << address);
154 //As an AP, our MAC address is also the BSSID. Hence we are
155 //overriding this function and setting both in our parent class.
158}
159
160void
162{
163 NS_LOG_FUNCTION (this << standard);
165 m_beaconTxop->SetWifiMac (this);
166 m_beaconTxop->SetAifsns (std::vector<uint8_t> (GetNLinks (), 1));
167 m_beaconTxop->SetMinCws (std::vector<uint32_t> (GetNLinks (), 0));
168 m_beaconTxop->SetMaxCws (std::vector<uint32_t> (GetNLinks (), 0));
169 for (uint8_t linkId = 0; linkId < GetNLinks (); linkId++)
170 {
172 }
173}
174
177{
178 if (ac == AC_BEACON)
179 {
180 return m_beaconTxop->GetWifiMacQueue ();
181 }
182 return WifiMac::GetTxopQueue (ac);
183}
184
185void
187{
188 NS_LOG_FUNCTION (this << enable);
189 for (uint8_t linkId = 0; linkId < GetNLinks (); ++linkId)
190 {
191 if (!enable)
192 {
193 GetLink (linkId).beaconEvent.Cancel ();
194 }
195 else if (!m_enableBeaconGeneration)
196 {
198 this, linkId);
199 }
200 }
202}
203
204Time
206{
207 NS_LOG_FUNCTION (this);
208 return m_beaconInterval;
209}
210
211void
213{
214 NS_LOG_FUNCTION (this << &linkUp);
216
217 //The approach taken here is that, from the point of view of an AP,
218 //the link is always up, so we immediately invoke the callback if
219 //one is set
220 linkUp ();
221}
222
223void
225{
226 NS_LOG_FUNCTION (this << interval);
227 if ((interval.GetMicroSeconds () % 1024) != 0)
228 {
229 NS_FATAL_ERROR ("beacon interval should be multiple of 1024us (802.11 time unit), see IEEE Std. 802.11-2012");
230 }
231 if (interval.GetMicroSeconds () > (1024 * 65535))
232 {
233 NS_FATAL_ERROR ("beacon interval should be smaller then or equal to 65535 * 1024us (802.11 time unit)");
234 }
235 m_beaconInterval = interval;
236}
237
238int64_t
240{
241 NS_LOG_FUNCTION (this << stream);
242 m_beaconJitter->SetStream (stream);
243 return 1;
244}
245
246void
248{
249 NS_LOG_FUNCTION (this);
251 {
252 for (const auto& sta : m_staList)
253 {
255 {
257 return;
258 }
259 }
261 }
262 else
263 {
265 }
266}
267
268void
270{
271 NS_LOG_FUNCTION (this);
272 if (GetErpSupported (SINGLE_LINK_OP_ID) && GetWifiPhy ()->GetShortPhyPreambleSupported ())
273 {
274 for (const auto& sta : m_staList)
275 {
276 if (!GetWifiRemoteStationManager ()->GetErpOfdmSupported (sta.second) ||
277 !GetWifiRemoteStationManager ()->GetShortPreambleSupported (sta.second))
278 {
280 return;
281 }
282 }
284 }
285 else
286 {
288 }
289}
290
291void
293 Mac48Address to)
294{
295 NS_LOG_FUNCTION (this << packet << from << to);
296 //If we are not a QoS AP then we definitely want to use AC_BE to
297 //transmit the packet. A TID of zero will map to AC_BE (through \c
298 //QosUtilsMapTidToAc()), so we use that as our default here.
299 uint8_t tid = 0;
300
301 //If we are a QoS AP then we attempt to get a TID for this packet
302 if (GetQosSupported ())
303 {
304 tid = QosUtilsGetTidForPacket (packet);
305 //Any value greater than 7 is invalid and likely indicates that
306 //the packet had no QoS tag, so we revert to zero, which'll
307 //mean that AC_BE is used.
308 if (tid > 7)
309 {
310 tid = 0;
311 }
312 }
313
314 ForwardDown (packet, from, to, tid);
315}
316
317void
319 Mac48Address to, uint8_t tid)
320{
321 NS_LOG_FUNCTION (this << packet << from << to << +tid);
322 WifiMacHeader hdr;
323
324 //For now, an AP that supports QoS does not support non-QoS
325 //associations, and vice versa. In future the AP model should
326 //support simultaneously associated QoS and non-QoS STAs, at which
327 //point there will need to be per-association QoS state maintained
328 //by the association state machine, and consulted here.
329 if (GetQosSupported ())
330 {
333 hdr.SetQosNoEosp ();
334 hdr.SetQosNoAmsdu ();
335 //Transmission of multiple frames in the same Polled TXOP is not supported for now
336 hdr.SetQosTxopLimit (0);
337 //Fill in the QoS control field in the MAC header
338 hdr.SetQosTid (tid);
339 }
340 else
341 {
343 }
344
345 if (GetQosSupported ())
346 {
347 hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT control field is not yet implemented (set it to 1 when implemented)
348 }
349 hdr.SetAddr1 (to);
350 hdr.SetAddr2 (GetAddress ());
351 hdr.SetAddr3 (from);
352 hdr.SetDsFrom ();
353 hdr.SetDsNotTo ();
354
355 if (GetQosSupported ())
356 {
357 //Sanity check that the TID is valid
358 NS_ASSERT (tid < 8);
359 GetQosTxop (tid)->Queue (packet, hdr);
360 }
361 else
362 {
363 GetTxop ()->Queue (packet, hdr);
364 }
365}
366
367bool
369{
370 return (to.IsGroup () || GetWifiRemoteStationManager ()->IsAssociated (to));
371}
372
373void
375{
376 NS_LOG_FUNCTION (this << packet << to << from);
377 if (CanForwardPacketsTo (to))
378 {
379 ForwardDown (packet, from, to);
380 }
381 else
382 {
383 NotifyTxDrop (packet);
384 }
385}
386
387void
389{
390 NS_LOG_FUNCTION (this << packet << to);
391 //We're sending this packet with a from address that is our own. We
392 //get that address from the lower MAC and make use of the
393 //from-spoofing Enqueue() method to avoid duplicated code.
394 Enqueue (packet, to, GetAddress ());
395}
396
397bool
399{
400 NS_LOG_FUNCTION (this);
401 return true;
402}
403
406{
407 NS_LOG_FUNCTION (this);
408 SupportedRates rates;
409 //Send the set of supported rates and make sure that we indicate
410 //the Basic Rate set in this set of supported rates.
411 for (const auto & mode : GetWifiPhy ()->GetModeList ())
412 {
413 uint64_t modeDataRate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ());
414 NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
415 rates.AddSupportedRate (modeDataRate);
416 //Add rates that are part of the BSSBasicRateSet (manufacturer dependent!)
417 //here we choose to add the mandatory rates to the BSSBasicRateSet,
418 //except for 802.11b where we assume that only the non HR-DSSS rates are part of the BSSBasicRateSet
419 if (mode.IsMandatory () && (mode.GetModulationClass () != WIFI_MOD_CLASS_HR_DSSS))
420 {
421 NS_LOG_DEBUG ("Adding basic mode " << mode.GetUniqueName ());
423 }
424 }
425 //set the basic rates
426 for (uint8_t j = 0; j < GetWifiRemoteStationManager ()->GetNBasicModes (); j++)
427 {
429 uint64_t modeDataRate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ());
430 NS_LOG_DEBUG ("Setting basic rate " << mode.GetUniqueName ());
431 rates.SetBasicRate (modeDataRate);
432 }
433 //If it is a HT AP, then add the BSSMembershipSelectorSet
434 //The standard says that the BSSMembershipSelectorSet
435 //must have its MSB set to 1 (must be treated as a Basic Rate)
436 //Also the standard mentioned that at least 1 element should be included in the SupportedRates the rest can be in the ExtendedSupportedRates
437 if (GetHtSupported ())
438 {
439 for (const auto & selector : GetWifiPhy ()->GetBssMembershipSelectorList ())
440 {
441 rates.AddBssMembershipSelectorRate (selector);
442 }
443 }
444 return rates;
445}
446
448ApWifiMac::GetDsssParameterSet (uint8_t linkId) const
449{
450 NS_LOG_FUNCTION (this << +linkId);
451 DsssParameterSet dsssParameters;
452 if (GetDsssSupported (linkId))
453 {
454 dsssParameters.SetDsssSupported (1);
455 dsssParameters.SetCurrentChannel (GetWifiPhy (linkId)->GetChannelNumber ());
456 }
457 return dsssParameters;
458}
459
462{
463 NS_LOG_FUNCTION (this);
464 CapabilityInformation capabilities;
467 capabilities.SetEss ();
468 return capabilities;
469}
470
472ApWifiMac::GetErpInformation (uint8_t linkId) const
473{
474 NS_LOG_FUNCTION (this << +linkId);
475 ErpInformation information;
476 information.SetErpSupported (1);
477 if (GetErpSupported (linkId))
478 {
479 information.SetNonErpPresent (m_numNonErpStations > 0);
482 {
483 information.SetBarkerPreambleMode (0);
484 }
485 else
486 {
487 information.SetBarkerPreambleMode (1);
488 }
489 }
490 return information;
491}
492
494ApWifiMac::GetEdcaParameterSet (uint8_t linkId) const
495{
496 NS_LOG_FUNCTION (this << +linkId);
497 EdcaParameterSet edcaParameters;
498 if (GetQosSupported ())
499 {
500 edcaParameters.SetQosSupported (1);
501 Ptr<QosTxop> edca;
502 Time txopLimit;
503
504 edca = GetQosTxop (AC_BE);
505 txopLimit = edca->GetTxopLimit (linkId);
506 edcaParameters.SetBeAci (0);
507 edcaParameters.SetBeCWmin (edca->GetMinCw (linkId));
508 edcaParameters.SetBeCWmax (edca->GetMaxCw (linkId));
509 edcaParameters.SetBeAifsn (edca->GetAifsn (linkId));
510 edcaParameters.SetBeTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
511
512 edca = GetQosTxop (AC_BK);
513 txopLimit = edca->GetTxopLimit (linkId);
514 edcaParameters.SetBkAci (1);
515 edcaParameters.SetBkCWmin (edca->GetMinCw (linkId));
516 edcaParameters.SetBkCWmax (edca->GetMaxCw (linkId));
517 edcaParameters.SetBkAifsn (edca->GetAifsn (linkId));
518 edcaParameters.SetBkTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
519
520 edca = GetQosTxop (AC_VI);
521 txopLimit = edca->GetTxopLimit (linkId);
522 edcaParameters.SetViAci (2);
523 edcaParameters.SetViCWmin (edca->GetMinCw (linkId));
524 edcaParameters.SetViCWmax (edca->GetMaxCw (linkId));
525 edcaParameters.SetViAifsn (edca->GetAifsn (linkId));
526 edcaParameters.SetViTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
527
528 edca = GetQosTxop (AC_VO);
529 txopLimit = edca->GetTxopLimit (linkId);
530 edcaParameters.SetVoAci (3);
531 edcaParameters.SetVoCWmin (edca->GetMinCw (linkId));
532 edcaParameters.SetVoCWmax (edca->GetMaxCw (linkId));
533 edcaParameters.SetVoAifsn (edca->GetAifsn (linkId));
534 edcaParameters.SetVoTxopLimit (static_cast<uint16_t> (txopLimit.GetMicroSeconds () / 32));
535
536 edcaParameters.SetQosInfo (0);
537 }
538 return edcaParameters;
539}
540
543{
544 NS_LOG_FUNCTION (this);
545 MuEdcaParameterSet muEdcaParameters;
546 if (GetHeSupported ())
547 {
548 Ptr<HeConfiguration> heConfiguration = GetHeConfiguration ();
549 NS_ASSERT (heConfiguration != 0);
550
551 muEdcaParameters.SetQosInfo (0);
552
553 UintegerValue uintegerValue;
554 TimeValue timeValue;
555
556 heConfiguration->GetAttribute ("MuBeAifsn", uintegerValue);
557 muEdcaParameters.SetMuAifsn (AC_BE, uintegerValue.Get ());
558 heConfiguration->GetAttribute ("MuBeCwMin", uintegerValue);
559 muEdcaParameters.SetMuCwMin (AC_BE, uintegerValue.Get ());
560 heConfiguration->GetAttribute ("MuBeCwMax", uintegerValue);
561 muEdcaParameters.SetMuCwMax (AC_BE, uintegerValue.Get ());
562 heConfiguration->GetAttribute ("BeMuEdcaTimer", timeValue);
563 muEdcaParameters.SetMuEdcaTimer (AC_BE, timeValue.Get ());
564
565 heConfiguration->GetAttribute ("MuBkAifsn", uintegerValue);
566 muEdcaParameters.SetMuAifsn (AC_BK, uintegerValue.Get ());
567 heConfiguration->GetAttribute ("MuBkCwMin", uintegerValue);
568 muEdcaParameters.SetMuCwMin (AC_BK, uintegerValue.Get ());
569 heConfiguration->GetAttribute ("MuBkCwMax", uintegerValue);
570 muEdcaParameters.SetMuCwMax (AC_BK, uintegerValue.Get ());
571 heConfiguration->GetAttribute ("BkMuEdcaTimer", timeValue);
572 muEdcaParameters.SetMuEdcaTimer (AC_BK, timeValue.Get ());
573
574 heConfiguration->GetAttribute ("MuViAifsn", uintegerValue);
575 muEdcaParameters.SetMuAifsn (AC_VI, uintegerValue.Get ());
576 heConfiguration->GetAttribute ("MuViCwMin", uintegerValue);
577 muEdcaParameters.SetMuCwMin (AC_VI, uintegerValue.Get ());
578 heConfiguration->GetAttribute ("MuViCwMax", uintegerValue);
579 muEdcaParameters.SetMuCwMax (AC_VI, uintegerValue.Get ());
580 heConfiguration->GetAttribute ("ViMuEdcaTimer", timeValue);
581 muEdcaParameters.SetMuEdcaTimer (AC_VI, timeValue.Get ());
582
583 heConfiguration->GetAttribute ("MuVoAifsn", uintegerValue);
584 muEdcaParameters.SetMuAifsn (AC_VO, uintegerValue.Get ());
585 heConfiguration->GetAttribute ("MuVoCwMin", uintegerValue);
586 muEdcaParameters.SetMuCwMin (AC_VO, uintegerValue.Get ());
587 heConfiguration->GetAttribute ("MuVoCwMax", uintegerValue);
588 muEdcaParameters.SetMuCwMax (AC_VO, uintegerValue.Get ());
589 heConfiguration->GetAttribute ("VoMuEdcaTimer", timeValue);
590 muEdcaParameters.SetMuEdcaTimer (AC_VO, timeValue.Get ());
591 }
592 return muEdcaParameters;
593}
594
597{
598 NS_LOG_FUNCTION (this);
599 HtOperation operation;
600 if (GetHtSupported ())
601 {
602 operation.SetHtSupported (1);
603 operation.SetPrimaryChannel (GetWifiPhy ()->GetPrimaryChannelNumber (20));
604 operation.SetRifsMode (false);
605 operation.SetNonGfHtStasPresent (true);
606 if (GetWifiPhy ()->GetChannelWidth () > 20)
607 {
608 operation.SetSecondaryChannelOffset (1);
609 operation.SetStaChannelWidth (1);
610 }
611 if (m_numNonHtStations == 0)
612 {
613 operation.SetHtProtection (NO_PROTECTION);
614 }
615 else
616 {
618 }
619 uint64_t maxSupportedRate = 0; //in bit/s
620 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT))
621 {
622 uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
623 NS_ASSERT (nss > 0 && nss < 5);
624 uint64_t dataRate = mcs.GetDataRate (GetWifiPhy ()->GetChannelWidth (), GetHtConfiguration ()->GetShortGuardIntervalSupported () ? 400 : 800, nss);
625 if (dataRate > maxSupportedRate)
626 {
627 maxSupportedRate = dataRate;
628 NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate);
629 }
630 }
631 uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedTxSpatialStreams ();
632 auto mcsList = GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT);
633 uint8_t nMcs = mcsList.size ();
634 for (const auto& sta : m_staList)
635 {
636 if (GetWifiRemoteStationManager ()->GetHtSupported (sta.second))
637 {
638 uint64_t maxSupportedRateByHtSta = 0; //in bit/s
639 auto itMcs = mcsList.begin ();
640 for (uint8_t j = 0; j < (std::min (nMcs, GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second))); j++)
641 {
642 WifiMode mcs = *itMcs++;
643 uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
644 NS_ASSERT (nss > 0 && nss < 5);
645 uint64_t dataRate = mcs.GetDataRate (GetWifiRemoteStationManager ()->GetChannelWidthSupported (sta.second),
646 GetWifiRemoteStationManager ()->GetShortGuardIntervalSupported (sta.second) ? 400 : 800, nss);
647 if (dataRate > maxSupportedRateByHtSta)
648 {
649 maxSupportedRateByHtSta = dataRate;
650 }
651 }
652 if (maxSupportedRateByHtSta < maxSupportedRate)
653 {
654 maxSupportedRate = maxSupportedRateByHtSta;
655 }
656 if (GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second) < nMcs)
657 {
658 nMcs = GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second);
659 }
660 if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream)
661 {
662 maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second);
663 }
664 }
665 }
666 operation.SetRxHighestSupportedDataRate (static_cast<uint16_t> (maxSupportedRate / 1e6)); //in Mbit/s
667 operation.SetTxMcsSetDefined (nMcs > 0);
668 operation.SetTxMaxNSpatialStreams (maxSpatialStream);
669 //To be filled in once supported
670 operation.SetObssNonHtStasPresent (0);
671 operation.SetDualBeacon (0);
672 operation.SetDualCtsProtection (0);
673 operation.SetStbcBeacon (0);
675 operation.SetPcoActive (0);
676 operation.SetPhase (0);
677 operation.SetRxMcsBitmask (0);
678 operation.SetTxRxMcsSetUnequal (0);
679 operation.SetTxUnequalModulation (0);
680 }
681 return operation;
682}
683
686{
687 NS_LOG_FUNCTION (this);
688 VhtOperation operation;
689 if (GetVhtSupported ())
690 {
691 operation.SetVhtSupported (1);
692 const uint16_t bssBandwidth = GetWifiPhy ()->GetChannelWidth ();
693 // Set to 0 for 20 MHz or 40 MHz BSS bandwidth.
694 // Set to 1 for 80 MHz, 160 MHz or 80+80 MHz BSS bandwidth.
695 operation.SetChannelWidth ((bssBandwidth > 40) ? 1 : 0);
696 // For 20, 40, or 80 MHz BSS bandwidth, indicates the channel center frequency
697 // index for the 20, 40, or 80 MHz channel on which the VHT BSS operates.
698 // For 160 MHz BSS bandwidth and the Channel Width subfield equal to 1,
699 // indicates the channel center frequency index of the 80 MHz channel
700 // segment that contains the primary channel.
701 operation.SetChannelCenterFrequencySegment0 ((bssBandwidth == 160) ?
702 GetWifiPhy ()->GetOperatingChannel ().GetPrimaryChannelNumber (80, WIFI_STANDARD_80211ac) :
703 GetWifiPhy ()->GetChannelNumber ());
704 // For a 20, 40, or 80 MHz BSS bandwidth, this subfield is set to 0.
705 // For a 160 MHz BSS bandwidth and the Channel Width subfield equal to 1,
706 // indicates the channel center frequency index of the 160 MHz channel on
707 // which the VHT BSS operates.
708 operation.SetChannelCenterFrequencySegment1 ((bssBandwidth == 160) ? GetWifiPhy ()->GetChannelNumber () : 0);
709 uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams ();
710 for (const auto& sta : m_staList)
711 {
712 if (GetWifiRemoteStationManager ()->GetVhtSupported (sta.second))
713 {
714 if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream)
715 {
716 maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second);
717 }
718 }
719 }
720 for (uint8_t nss = 1; nss <= maxSpatialStream; nss++)
721 {
722 uint8_t maxMcs = 9; //TBD: hardcode to 9 for now since we assume all MCS values are supported
723 operation.SetMaxVhtMcsPerNss (nss, maxMcs);
724 }
725 }
726 return operation;
727}
728
731{
732 NS_LOG_FUNCTION (this);
733 HeOperation operation;
734 if (GetHeSupported ())
735 {
736 operation.SetHeSupported (1);
737 uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams ();
738 for (const auto& sta : m_staList)
739 {
740 if (GetWifiRemoteStationManager ()->GetHeSupported (sta.second))
741 {
742 if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream)
743 {
744 maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second);
745 }
746 }
747 }
748 for (uint8_t nss = 1; nss <= maxSpatialStream; nss++)
749 {
750 operation.SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported
751 }
752 operation.SetBssColor (GetHeConfiguration ()->GetBssColor ());
753 }
754 return operation;
755}
756
757void
759{
760 NS_LOG_FUNCTION (this << to);
761 WifiMacHeader hdr;
763 hdr.SetAddr1 (to);
764 hdr.SetAddr2 (GetAddress ());
765 hdr.SetAddr3 (GetAddress ());
766 hdr.SetDsNotFrom ();
767 hdr.SetDsNotTo ();
768 Ptr<Packet> packet = Create<Packet> ();
770 probe.SetSsid (GetSsid ());
772 probe.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
777 {
779 }
781 {
783 }
784 if (GetQosSupported ())
785 {
787 }
788 if (GetHtSupported ())
789 {
793 }
794 if (GetVhtSupported ())
795 {
798 }
799 if (GetHeSupported ())
800 {
804 }
805 if (GetEhtSupported ())
806 {
808 }
809 packet->AddHeader (probe);
810
811 if (!GetQosSupported ())
812 {
813 GetTxop ()->Queue (packet, hdr);
814 }
815 // "A QoS STA that transmits a Management frame determines access category used
816 // for medium access in transmission of the Management frame as follows
817 // (If dot11QMFActivated is false or not present)
818 // — If the Management frame is individually addressed to a non-QoS STA, category
819 // AC_BE should be selected.
820 // — If category AC_BE was not selected by the previous step, category AC_VO
821 // shall be selected." (Sec. 10.2.3.2 of 802.11-2020)
823 {
824 GetBEQueue ()->Queue (packet, hdr);
825 }
826 else
827 {
828 GetVOQueue ()->Queue (packet, hdr);
829 }
830}
831
832void
833ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc)
834{
835 NS_LOG_FUNCTION (this << to << success << isReassoc);
836 WifiMacHeader hdr;
838 hdr.SetAddr1 (to);
839 hdr.SetAddr2 (GetAddress ());
840 hdr.SetAddr3 (GetAddress ());
841 hdr.SetDsNotFrom ();
842 hdr.SetDsNotTo ();
843 Ptr<Packet> packet = Create<Packet> ();
845 StatusCode code;
846 if (success)
847 {
848 code.SetSuccess ();
849 uint16_t aid = 0;
850 bool found = false;
851 if (isReassoc)
852 {
853 for (const auto& sta : m_staList)
854 {
855 if (sta.second == to)
856 {
857 aid = sta.first;
858 found = true;
859 break;
860 }
861 }
862 }
863 if (!found)
864 {
865 aid = GetNextAssociationId ();
866 m_staList.insert (std::make_pair (aid, to));
867 m_assocLogger (aid, to);
869 if (GetWifiRemoteStationManager ()->GetDsssSupported (to) && !GetWifiRemoteStationManager ()->GetErpOfdmSupported (to))
870 {
872 }
874 {
876 }
879 }
880 assoc.SetAssociationId (aid);
881 }
882 else
883 {
884 code.SetFailure ();
885 }
887 assoc.SetStatusCode (code);
890 {
892 }
893 if (GetQosSupported ())
894 {
896 }
897 if (GetHtSupported ())
898 {
902 }
903 if (GetVhtSupported ())
904 {
907 }
908 if (GetHeSupported ())
909 {
913 }
914 if (GetEhtSupported ())
915 {
917 }
918 packet->AddHeader (assoc);
919
920 if (!GetQosSupported ())
921 {
922 GetTxop ()->Queue (packet, hdr);
923 }
924 // "A QoS STA that transmits a Management frame determines access category used
925 // for medium access in transmission of the Management frame as follows
926 // (If dot11QMFActivated is false or not present)
927 // — If the Management frame is individually addressed to a non-QoS STA, category
928 // AC_BE should be selected.
929 // — If category AC_BE was not selected by the previous step, category AC_VO
930 // shall be selected." (Sec. 10.2.3.2 of 802.11-2020)
932 {
933 GetBEQueue ()->Queue (packet, hdr);
934 }
935 else
936 {
937 GetVOQueue ()->Queue (packet, hdr);
938 }
939}
940
941void
943{
944 NS_LOG_FUNCTION (this << +linkId);
945 WifiMacHeader hdr;
948 hdr.SetAddr2 (GetLink (linkId).feManager->GetAddress ());
949 hdr.SetAddr3 (GetLink (linkId).feManager->GetAddress ());
950 hdr.SetDsNotFrom ();
951 hdr.SetDsNotTo ();
952 Ptr<Packet> packet = Create<Packet> ();
953 MgtBeaconHeader beacon;
954 beacon.SetSsid (GetSsid ());
956 beacon.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ());
960 if (GetDsssSupported (linkId))
961 {
963 }
964 if (GetErpSupported (linkId))
965 {
966 beacon.SetErpInformation (GetErpInformation (linkId));
967 }
968 if (GetQosSupported ())
969 {
971 }
972 if (GetHtSupported ())
973 {
976 beacon.SetHtOperation (GetHtOperation ());
977 }
978 if (GetVhtSupported ())
979 {
982 }
983 if (GetHeSupported ())
984 {
986 beacon.SetHeOperation (GetHeOperation ());
988 }
989 if (GetEhtSupported ())
990 {
992 }
993 packet->AddHeader (beacon);
994
995 //The beacon has it's own special queue, so we load it in there
996 m_beaconTxop->Queue (packet, hdr);
998
999 //If a STA that does not support Short Slot Time associates,
1000 //the AP shall use long slot time beginning at the first Beacon
1001 //subsequent to the association of the long slot time STA.
1002 if (GetErpSupported (linkId))
1003 {
1005 {
1006 //Enable short slot time
1007 GetWifiPhy (linkId)->SetSlot (MicroSeconds (9));
1008 }
1009 else
1010 {
1011 //Disable short slot time
1012 GetWifiPhy (linkId)->SetSlot (MicroSeconds (20));
1013 }
1014 }
1015}
1016
1017void
1019{
1020 NS_LOG_FUNCTION (this << *mpdu);
1021 const WifiMacHeader& hdr = mpdu->GetHeader ();
1022 if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
1023 && GetWifiRemoteStationManager ()->IsWaitAssocTxOk (hdr.GetAddr1 ()))
1024 {
1025 NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
1027 }
1028}
1029
1030void
1032{
1033 NS_LOG_FUNCTION (this << +timeoutReason << *mpdu);
1034 const WifiMacHeader& hdr = mpdu->GetHeader ();
1035
1036 if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
1037 && GetWifiRemoteStationManager ()->IsWaitAssocTxOk (hdr.GetAddr1 ()))
1038 {
1039 NS_LOG_DEBUG ("association failed with sta=" << hdr.GetAddr1 ());
1041 }
1042}
1043
1044void
1046{
1047 NS_LOG_FUNCTION (this << *mpdu << +linkId);
1048 const WifiMacHeader* hdr = &mpdu->GetHeader ();
1049 Ptr<const Packet> packet = mpdu->GetPacket ();
1050 Mac48Address from = hdr->GetAddr2 ();
1051 if (hdr->IsData ())
1052 {
1053 Mac48Address bssid = hdr->GetAddr1 ();
1054 if (!hdr->IsFromDs ()
1055 && hdr->IsToDs ()
1056 && bssid == GetAddress ()
1057 && GetWifiRemoteStationManager ()->IsAssociated (from))
1058 {
1059 Mac48Address to = hdr->GetAddr3 ();
1060 if (to == GetAddress ())
1061 {
1062 NS_LOG_DEBUG ("frame for me from=" << from);
1063 if (hdr->IsQosData ())
1064 {
1065 if (hdr->IsQosAmsdu ())
1066 {
1067 NS_LOG_DEBUG ("Received A-MSDU from=" << from << ", size=" << packet->GetSize ());
1069 packet = 0;
1070 }
1071 else
1072 {
1073 ForwardUp (packet, from, bssid);
1074 }
1075 }
1076 else if (hdr->HasData ())
1077 {
1078 ForwardUp (packet, from, bssid);
1079 }
1080 }
1081 else if (to.IsGroup ()
1082 || GetWifiRemoteStationManager ()->IsAssociated (to))
1083 {
1084 NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to);
1085 Ptr<Packet> copy = packet->Copy ();
1086
1087 //If the frame we are forwarding is of type QoS Data,
1088 //then we need to preserve the UP in the QoS control
1089 //header...
1090 if (hdr->IsQosData ())
1091 {
1092 ForwardDown (copy, from, to, hdr->GetQosTid ());
1093 }
1094 else
1095 {
1096 ForwardDown (copy, from, to);
1097 }
1098 ForwardUp (packet, from, to);
1099 }
1100 else
1101 {
1102 ForwardUp (packet, from, to);
1103 }
1104 }
1105 else if (hdr->IsFromDs ()
1106 && hdr->IsToDs ())
1107 {
1108 //this is an AP-to-AP frame
1109 //we ignore for now.
1110 NotifyRxDrop (packet);
1111 }
1112 else
1113 {
1114 //we can ignore these frames since
1115 //they are not targeted at the AP
1116 NotifyRxDrop (packet);
1117 }
1118 return;
1119 }
1120 else if (hdr->IsMgt ())
1121 {
1122 if (hdr->IsProbeReq ()
1123 && (hdr->GetAddr1 ().IsGroup () || hdr->GetAddr1 () == GetAddress ()))
1124 {
1125 // In the case where the Address 1 field contains a group address, the
1126 // Address 3 field also is validated to verify that the group addressed
1127 // frame originated from a STA in the BSS of which the receiving STA is
1128 // a member (Section 9.3.3.1 of 802.11-2020)
1129 if (hdr->GetAddr1 ().IsGroup ()
1130 && !hdr->GetAddr3 ().IsBroadcast () && hdr->GetAddr3 () != GetAddress ())
1131 {
1132 // not addressed to us
1133 return;
1134 }
1135 MgtProbeRequestHeader probeRequestHeader;
1136 packet->PeekHeader (probeRequestHeader);
1137 const Ssid& ssid = probeRequestHeader.GetSsid ();
1138 if (ssid == GetSsid () || ssid.IsBroadcast ())
1139 {
1140 NS_LOG_DEBUG ("Probe request received from " << from << ": send probe response");
1141 SendProbeResp (from);
1142 }
1143 return;
1144 }
1145 else if (hdr->GetAddr1 () == GetAddress ())
1146 {
1147 if (hdr->IsAssocReq ())
1148 {
1149 NS_LOG_DEBUG ("Association request received from " << from);
1150 //first, verify that the the station's supported
1151 //rate set is compatible with our Basic Rate set
1152 MgtAssocRequestHeader assocReq;
1153 packet->PeekHeader (assocReq);
1154 const CapabilityInformation& capabilities = assocReq.GetCapabilities ();
1156 const SupportedRates& rates = assocReq.GetSupportedRates ();
1157 bool problem = false;
1158 if (rates.GetNRates () == 0)
1159 {
1160 problem = true;
1161 }
1162 if (GetHtSupported ())
1163 {
1164 //check whether the HT STA supports all MCSs in Basic MCS Set
1165 const HtCapabilities& htCapabilities = assocReq.GetHtCapabilities ();
1166 if (htCapabilities.IsSupportedMcs (0))
1167 {
1168 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1169 {
1171 if (!htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1172 {
1173 problem = true;
1174 break;
1175 }
1176 }
1177 }
1178 }
1179 if (GetVhtSupported ())
1180 {
1181 //check whether the VHT STA supports all MCSs in Basic MCS Set
1182 const VhtCapabilities& vhtCapabilities = assocReq.GetVhtCapabilities ();
1183 if (vhtCapabilities.GetVhtCapabilitiesInfo () != 0)
1184 {
1185 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1186 {
1188 if (!vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1189 {
1190 problem = true;
1191 break;
1192 }
1193 }
1194 }
1195 }
1196 if (GetHeSupported ())
1197 {
1198 //check whether the HE STA supports all MCSs in Basic MCS Set
1199 const HeCapabilities& heCapabilities = assocReq.GetHeCapabilities ();
1200 if (heCapabilities.GetSupportedMcsAndNss () != 0)
1201 {
1202 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1203 {
1205 if (!heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1206 {
1207 problem = true;
1208 break;
1209 }
1210 }
1211 }
1212 }
1213 if (GetEhtSupported ())
1214 {
1215 //check whether the EHT STA supports all MCSs in Basic MCS Set
1216 // const EhtCapabilities& ehtCapabilities = assocReq.GetEhtCapabilities ();
1217 //TODO: to be completed
1218 }
1219 if (problem)
1220 {
1221 NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send association response with an error status");
1222 SendAssocResp (hdr->GetAddr2 (), false, false);
1223 }
1224 else
1225 {
1226 NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1227 //record all its supported modes in its associated WifiRemoteStation
1228 for (const auto & mode : GetWifiPhy ()->GetModeList ())
1229 {
1230 if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
1231 {
1233 }
1234 }
1235 if (GetErpSupported (SINGLE_LINK_OP_ID) && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ())
1236 {
1238 }
1239 if (GetHtSupported ())
1240 {
1241 const HtCapabilities& htCapabilities = assocReq.GetHtCapabilities ();
1242 if (htCapabilities.IsSupportedMcs (0))
1243 {
1244 GetWifiRemoteStationManager ()->AddStationHtCapabilities (from, htCapabilities);
1245 }
1246 }
1247 if (GetVhtSupported ())
1248 {
1249 const VhtCapabilities& vhtCapabilities = assocReq.GetVhtCapabilities ();
1250 //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1251 if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1252 {
1253 GetWifiRemoteStationManager ()->AddStationVhtCapabilities (from, vhtCapabilities);
1254 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT))
1255 {
1256 if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1257 {
1259 //here should add a control to add basic MCS when it is implemented
1260 }
1261 }
1262 }
1263 }
1264 if (GetHtSupported ())
1265 {
1266 // const ExtendedCapabilities& extendedCapabilities = assocReq.GetExtendedCapabilities ();
1267 //TODO: to be completed
1268 }
1269 if (GetHeSupported ())
1270 {
1271 const HeCapabilities& heCapabilities = assocReq.GetHeCapabilities ();
1272 if (heCapabilities.GetSupportedMcsAndNss () != 0)
1273 {
1274 GetWifiRemoteStationManager ()->AddStationHeCapabilities (from, heCapabilities);
1275 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
1276 {
1277 if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1278 {
1280 //here should add a control to add basic MCS when it is implemented
1281 }
1282 }
1283 }
1284 }
1285 if (GetEhtSupported ())
1286 {
1287 const EhtCapabilities& ehtCapabilities = assocReq.GetEhtCapabilities ();
1288 //TODO: once we support non constant rate managers, we should add checks here whether EHT is supported by the peer
1289 GetWifiRemoteStationManager ()->AddStationEhtCapabilities (from, ehtCapabilities);
1290 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_EHT))
1291 {
1292 //TODO: Add check whether MCS is supported from the capabilities
1294 //here should add a control to add basic MCS when it is implemented
1295 }
1296 }
1298 NS_LOG_DEBUG ("Send association response with success status");
1299 SendAssocResp (hdr->GetAddr2 (), true, false);
1300 }
1301 return;
1302 }
1303 else if (hdr->IsReassocReq ())
1304 {
1305 NS_LOG_DEBUG ("Reassociation request received from " << from);
1306 //first, verify that the the station's supported
1307 //rate set is compatible with our Basic Rate set
1308 MgtReassocRequestHeader reassocReq;
1309 packet->PeekHeader (reassocReq);
1310 const CapabilityInformation& capabilities = reassocReq.GetCapabilities ();
1312 const SupportedRates& rates = reassocReq.GetSupportedRates ();
1313 bool problem = false;
1314 if (rates.GetNRates () == 0)
1315 {
1316 problem = true;
1317 }
1318 if (GetHtSupported ())
1319 {
1320 //check whether the HT STA supports all MCSs in Basic MCS Set
1321 const HtCapabilities& htCapabilities = reassocReq.GetHtCapabilities ();
1322 if (htCapabilities.IsSupportedMcs (0))
1323 {
1324 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1325 {
1327 if (!htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1328 {
1329 problem = true;
1330 break;
1331 }
1332 }
1333 }
1334 }
1335 if (GetVhtSupported ())
1336 {
1337 //check whether the VHT STA supports all MCSs in Basic MCS Set
1338 const VhtCapabilities& vhtCapabilities = reassocReq.GetVhtCapabilities ();
1339 if (vhtCapabilities.GetVhtCapabilitiesInfo () != 0)
1340 {
1341 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1342 {
1344 if (!vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1345 {
1346 problem = true;
1347 break;
1348 }
1349 }
1350 }
1351 }
1352 if (GetHeSupported ())
1353 {
1354 //check whether the HE STA supports all MCSs in Basic MCS Set
1355 const HeCapabilities& heCapabilities = reassocReq.GetHeCapabilities ();
1356 if (heCapabilities.GetSupportedMcsAndNss () != 0)
1357 {
1358 for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++)
1359 {
1361 if (!heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1362 {
1363 problem = true;
1364 break;
1365 }
1366 }
1367 }
1368 }
1369 if (GetEhtSupported ())
1370 {
1371 //check whether the EHT STA supports all MCSs in Basic MCS Set
1372 // const EhtCapabilities& ehtCapabilities = reassocReq.GetEhtCapabilities ();
1373 //TODO: to be completed
1374 }
1375 if (problem)
1376 {
1377 NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send reassociation response with an error status");
1378 SendAssocResp (hdr->GetAddr2 (), false, true);
1379 }
1380 else
1381 {
1382 NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station");
1383 //update all its supported modes in its associated WifiRemoteStation
1384 for (const auto & mode : GetWifiPhy ()->GetModeList ())
1385 {
1386 if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
1387 {
1389 }
1390 }
1391 if (GetErpSupported (SINGLE_LINK_OP_ID) && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ())
1392 {
1394 }
1395 if (GetHtSupported ())
1396 {
1397 const HtCapabilities& htCapabilities = reassocReq.GetHtCapabilities ();
1398 if (htCapabilities.IsSupportedMcs (0))
1399 {
1400 GetWifiRemoteStationManager ()->AddStationHtCapabilities (from, htCapabilities);
1401 }
1402 }
1403 if (GetVhtSupported ())
1404 {
1405 const VhtCapabilities& vhtCapabilities = reassocReq.GetVhtCapabilities ();
1406 //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1407 if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1408 {
1409 GetWifiRemoteStationManager ()->AddStationVhtCapabilities (from, vhtCapabilities);
1410 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT))
1411 {
1412 if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1413 {
1415 //here should add a control to add basic MCS when it is implemented
1416 }
1417 }
1418 }
1419 }
1420 if (GetHtSupported ())
1421 {
1422 // const ExtendedCapabilities& extendedCapabilities = reassocReq.GetExtendedCapabilities ();
1423 //TODO: to be completed
1424 }
1425 if (GetHeSupported ())
1426 {
1427 const HeCapabilities& heCapabilities = reassocReq.GetHeCapabilities ();
1428 if (heCapabilities.GetSupportedMcsAndNss () != 0)
1429 {
1430 GetWifiRemoteStationManager ()->AddStationHeCapabilities (from, heCapabilities);
1431 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
1432 {
1433 if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1434 {
1436 //here should add a control to add basic MCS when it is implemented
1437 }
1438 }
1439 }
1440 }
1441 if (GetEhtSupported ())
1442 {
1443 const EhtCapabilities& ehtCapabilities = reassocReq.GetEhtCapabilities ();
1444 //TODO: once we support non constant rate managers, we should add checks here whether HE is supported by the peer
1445 GetWifiRemoteStationManager ()->AddStationEhtCapabilities (from, ehtCapabilities);
1446 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
1447 {
1448 //TODO: Add check whether MCS is supported from the capabilities
1450 //here should add a control to add basic MCS when it is implemented
1451 }
1452 }
1454 NS_LOG_DEBUG ("Send reassociation response with success status");
1455 SendAssocResp (hdr->GetAddr2 (), true, true);
1456 }
1457 return;
1458 }
1459 else if (hdr->IsDisassociation ())
1460 {
1461 NS_LOG_DEBUG ("Disassociation received from " << from);
1463 for (auto it = m_staList.begin (); it != m_staList.end (); ++it)
1464 {
1465 if (it->second == from)
1466 {
1467 m_staList.erase (it);
1468 m_deAssocLogger (it->first, it->second);
1469 if (GetWifiRemoteStationManager ()->GetDsssSupported (from) && !GetWifiRemoteStationManager ()->GetErpOfdmSupported (from))
1470 {
1472 }
1474 {
1476 }
1479 break;
1480 }
1481 }
1482 return;
1483 }
1484 }
1485 }
1486
1487 //Invoke the receive handler of our parent class to deal with any
1488 //other frames. Specifically, this will handle Block Ack-related
1489 //Management Action frames.
1490 WifiMac::Receive (Create<WifiMacQueueItem> (packet, *hdr), linkId);
1491}
1492
1493void
1495{
1496 NS_LOG_FUNCTION (this << *mpdu);
1497 for (auto& i : *PeekPointer (mpdu))
1498 {
1499 if (i.second.GetDestinationAddr () == GetAddress ())
1500 {
1501 ForwardUp (i.first, i.second.GetSourceAddr (),
1502 i.second.GetDestinationAddr ());
1503 }
1504 else
1505 {
1506 Mac48Address from = i.second.GetSourceAddr ();
1507 Mac48Address to = i.second.GetDestinationAddr ();
1508 NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
1509 ForwardDown (i.first->Copy (), from, to, mpdu->GetHeader ().GetQosTid ());
1510 }
1511 }
1512}
1513
1514void
1516{
1517 NS_LOG_FUNCTION (this);
1519
1520 for (uint8_t linkId = 0; linkId < GetNLinks (); ++linkId)
1521 {
1522 GetLink (linkId).beaconEvent.Cancel ();
1524 {
1525 uint64_t jitterUs = (m_enableBeaconJitter
1526 ? static_cast <uint64_t> (m_beaconJitter->GetValue (0, 1) * (GetBeaconInterval ().GetMicroSeconds ()))
1527 : 0);
1528 NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddress ()
1529 << " at time " << jitterUs << "us");
1530 GetLink (linkId).beaconEvent = Simulator::Schedule (MicroSeconds (jitterUs),
1532 this, linkId);
1533 }
1534 }
1535
1541}
1542
1543bool
1545{
1546 bool useProtection = (m_numNonErpStations > 0) && m_enableNonErpProtection;
1548 return useProtection;
1549}
1550
1551uint16_t
1553{
1554 //Return the first free AID value between 1 and 2007
1555 for (uint16_t nextAid = 1; nextAid <= 2007; nextAid++)
1556 {
1557 if (m_staList.find (nextAid) == m_staList.end ())
1558 {
1559 return nextAid;
1560 }
1561 }
1562 NS_FATAL_ERROR ("No free association ID available!");
1563 return 0;
1564}
1565
1566const std::map<uint16_t, Mac48Address>&
1568{
1569 return m_staList;
1570}
1571
1572uint16_t
1574{
1576}
1577
1578uint8_t
1580{
1581 auto it = m_bufferStatus.find (WifiAddressTidPair (address, tid));
1582 if (it == m_bufferStatus.end ()
1583 || it->second.timestamp + m_bsrLifetime < Simulator::Now ())
1584 {
1585 return 255;
1586 }
1587 return it->second.value;
1588}
1589
1590void
1592{
1593 if (size == 255)
1594 {
1595 // no point in storing an unspecified size
1597 }
1598 else
1599 {
1601 }
1602}
1603
1604uint8_t
1606{
1607 uint8_t maxSize = 0;
1608 bool found = false;
1609
1610 for (uint8_t tid = 0; tid < 8; tid++)
1611 {
1612 uint8_t size = GetBufferStatus (tid, address);
1613 if (size != 255)
1614 {
1615 maxSize = std::max (maxSize, size);
1616 found = true;
1617 }
1618 }
1619
1620 if (found)
1621 {
1622 return maxSize;
1623 }
1624 return 255;
1625}
1626
1627} //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:269
bool m_shortPreambleEnabled
Flag whether short preamble is enabled in the BSS.
Definition: ap-wifi-mac.h:344
Ptr< Txop > m_beaconTxop
Dedicated Txop for beacons.
Definition: ap-wifi-mac.h:335
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
Definition: ap-wifi-mac.cc:186
void SendProbeResp(Mac48Address to)
Forward a probe response packet to the DCF.
Definition: ap-wifi-mac.cc:758
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
Definition: ap-wifi-mac.cc:405
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:224
HeOperation GetHeOperation(void) const
Return the HE operation of the current AP.
Definition: ap-wifi-mac.cc:730
uint16_t GetAssociationId(Mac48Address addr) const
void SetAddress(Mac48Address address) override
Definition: ap-wifi-mac.cc:151
uint16_t m_numNonHtStations
Number of non-HT stations currently associated to the AP.
Definition: ap-wifi-mac.h:342
Ptr< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
Definition: ap-wifi-mac.h:338
void TxOk(Ptr< const WifiMacQueueItem > mpdu)
The packet we sent was successfully received by the receiver (i.e.
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
Definition: ap-wifi-mac.cc:368
virtual ~ApWifiMac()
Definition: ap-wifi-mac.cc:116
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:345
bool m_shortSlotTimeEnabled
Flag whether short slot time is enabled within the BSS.
Definition: ap-wifi-mac.h:343
HtOperation GetHtOperation(void) const
Return the HT operation of the current AP.
Definition: ap-wifi-mac.cc:596
EdcaParameterSet GetEdcaParameterSet(uint8_t linkId) const
Return the EDCA Parameter Set of the current AP for the given link.
Definition: ap-wifi-mac.cc:494
bool SupportsSendFrom(void) const override
Definition: ap-wifi-mac.cc:398
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:340
void UpdateShortSlotTimeEnabled(void)
Update whether short slot time should be enabled or not in the BSS.
Definition: ap-wifi-mac.cc:247
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current AP.
Definition: ap-wifi-mac.cc:461
TracedCallback< uint16_t, Mac48Address > m_deAssocLogger
deassociation logger
Definition: ap-wifi-mac.h:365
bool m_enableBeaconGeneration
Flag whether beacons are being generated.
Definition: ap-wifi-mac.h:336
Time m_beaconInterval
Beacon interval.
Definition: ap-wifi-mac.h:337
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:339
void DoInitialize(void) override
Initialize() implementation.
DsssParameterSet GetDsssParameterSet(uint8_t linkId) const
Return the DSSS Parameter Set that we support on the given link.
Definition: ap-wifi-mac.cc:448
MuEdcaParameterSet GetMuEdcaParameterSet(void) const
Return the MU EDCA Parameter Set of the current AP.
Definition: ap-wifi-mac.cc:542
TracedCallback< uint16_t, Mac48Address > m_assocLogger
association logger
Definition: ap-wifi-mac.h:364
bool GetUseNonErpProtection(void) const
Return whether protection for non-ERP stations is used in the BSS.
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:388
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:51
Time m_bsrLifetime
Lifetime of Buffer Status Reports.
Definition: ap-wifi-mac.h:346
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:239
ApLinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition: ap-wifi-mac.cc:145
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 ConfigureStandard(WifiStandard standard) override
Definition: ap-wifi-mac.cc:161
ErpInformation GetErpInformation(uint8_t linkId) const
Return the ERP information of the current AP for the given link.
Definition: ap-wifi-mac.cc:472
void SetLinkUpCallback(Callback< void > linkUp) override
Definition: ap-wifi-mac.cc:212
uint16_t m_numNonErpStations
Number of non-ERP stations currently associated to the AP.
Definition: ap-wifi-mac.h:341
VhtOperation GetVhtOperation(void) const
Return the VHT operation of the current AP.
Definition: ap-wifi-mac.cc:685
void DoDispose(void) override
Destructor implementation.
Definition: ap-wifi-mac.cc:123
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 Receive(Ptr< WifiMacQueueItem > mpdu, uint8_t linkId) override
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
void SendAssocResp(Mac48Address to, bool success, bool isReassoc)
Forward an association or a reassociation response packet to the DCF.
Definition: ap-wifi-mac.cc:833
std::unordered_map< WifiAddressTidPair, bsrType, WifiAddressTidHash > m_bufferStatus
Per (MAC address, TID) buffer status reports.
Definition: ap-wifi-mac.h:354
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet down to DCF/EDCAF (enqueue the packet).
Definition: ap-wifi-mac.cc:292
std::unique_ptr< LinkEntity > CreateLinkEntity(void) const override
Create a LinkEntity object.
Definition: ap-wifi-mac.cc:139
void SendOneBeacon(uint8_t linkId)
Forward a beacon packet to the beacon special DCF for transmission on the given link.
Definition: ap-wifi-mac.cc:942
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:176
Time GetBeaconInterval(void) const
Definition: ap-wifi-mac.cc:205
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 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
const VhtCapabilities & GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:781
const EhtCapabilities & GetEhtCapabilities(void) const
Return the EHT capabilities.
Definition: mgt-headers.cc:817
const HtCapabilities & GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:763
const CapabilityInformation & GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:727
const HeCapabilities & GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:799
const SupportedRates & GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:829
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:413
void SetHeCapabilities(const HeCapabilities &heCapabilities)
Set the HE capabilities.
void SetHtOperation(const HtOperation &htOperation)
Set the HT operation.
void SetMuEdcaParameterSet(const MuEdcaParameterSet &muEdcaParameterSet)
Set the MU EDCA Parameter Set.
void SetEdcaParameterSet(const EdcaParameterSet &edcaParameterSet)
Set the EDCA Parameter Set.
void SetEhtCapabilities(const EhtCapabilities &ehtCapabilities)
Set the EHT capabilities.
void SetStatusCode(StatusCode code)
Set the status code.
void SetVhtOperation(const VhtOperation &vhtOperation)
Set the VHT operation.
void SetHeOperation(const HeOperation &heOperation)
Set the HE operation.
void SetAssociationId(uint16_t aid)
Set the association ID.
void SetCapabilities(const CapabilityInformation &capabilities)
Set the Capability information.
void SetVhtCapabilities(const VhtCapabilities &vhtCapabilities)
Set the VHT capabilities.
void SetSupportedRates(const SupportedRates &rates)
Set the supported rates.
void SetExtendedCapabilities(const ExtendedCapabilities &extendedCapabilities)
Set the extended capabilities.
void SetHtCapabilities(const HtCapabilities &htCapabilities)
Set the HT capabilities.
void SetErpInformation(const ErpInformation &erpInformation)
Set the ERP information.
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:1144
Implement the header for management frames of type probe request.
Definition: mgt-headers.h:689
const Ssid & GetSsid(void) const
Return the Service Set Identifier (SSID).
Definition: mgt-headers.cc:52
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:840
void SetVhtOperation(const VhtOperation &vhtOperation)
Set the VHT operation.
Definition: mgt-headers.cc:368
void SetHtOperation(const HtOperation &htOperation)
Set the HT operation.
Definition: mgt-headers.cc:332
void SetDsssParameterSet(const DsssParameterSet &dsssParameterSet)
Set the DSSS Parameter Set.
Definition: mgt-headers.cc:470
void SetCapabilities(const CapabilityInformation &capabilities)
Set the Capability information.
Definition: mgt-headers.cc:278
void SetEhtCapabilities(const EhtCapabilities &ehtCapabilities)
Set the EHT capabilities.
Definition: mgt-headers.cc:422
void SetVhtCapabilities(const VhtCapabilities &vhtCapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:350
void SetHtCapabilities(const HtCapabilities &htCapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:314
void SetSsid(const Ssid &ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:440
void SetSupportedRates(const SupportedRates &rates)
Set the supported rates.
Definition: mgt-headers.cc:458
void SetHeOperation(const HeOperation &heOperation)
Set the HE operation.
Definition: mgt-headers.cc:404
void SetErpInformation(const ErpInformation &erpInformation)
Set the ERP information.
Definition: mgt-headers.cc:488
void SetExtendedCapabilities(const ExtendedCapabilities &extendedCapabilities)
Set the extended capabilities.
Definition: mgt-headers.cc:296
void SetBeaconIntervalUs(uint64_t us)
Set the beacon interval in microseconds unit.
Definition: mgt-headers.cc:452
void SetEdcaParameterSet(const EdcaParameterSet &edcaParameterSet)
Set the EDCA Parameter Set.
Definition: mgt-headers.cc:506
void SetHeCapabilities(const HeCapabilities &heCapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:386
void SetMuEdcaParameterSet(const MuEdcaParameterSet &muEdcaParameterSet)
Set the MU EDCA Parameter Set.
Definition: mgt-headers.cc:518
Implement the header for management frames of type reassociation request.
Definition: mgt-headers.h:229
const VhtCapabilities & GetVhtCapabilities(void) const
Return the VHT capabilities.
const HeCapabilities & GetHeCapabilities(void) const
Return the HE capabilities.
const SupportedRates & GetSupportedRates(void) const
Return the supported rates.
const CapabilityInformation & GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:978
const EhtCapabilities & GetEhtCapabilities(void) const
Return the EHT capabilities.
const HtCapabilities & GetHtCapabilities(void) const
Return the HT capabilities.
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
uint8_t GetAifsn(uint8_t linkId) const override
For the given link, return the number of slots that make up an AIFS according to the EDCA Parameter S...
Definition: qos-txop.cc:232
uint32_t GetMinCw(uint8_t linkId) const override
For the given link, return the minimum contention window size from the EDCA Parameter Set or the MU E...
Definition: qos-txop.cc:210
uint32_t GetMaxCw(uint8_t linkId) const override
For the given link, return the maximum contention window size from the EDCA Parameter Set or the MU E...
Definition: qos-txop.cc:221
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:104
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:388
AttributeValue implementation for Time.
Definition: nstime.h:1309
Time Get(void) const
Definition: time.cc:519
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Definition: txop.cc:203
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: txop.cc:454
virtual void SetWifiMac(const Ptr< WifiMac > mac)
Set the wifi MAC this Txop is associated to.
Definition: txop.cc:178
void SetMaxCws(std::vector< uint32_t > maxCws)
Set the maximum contention window size for each link.
Definition: txop.cc:245
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Definition: txop.cc:171
void SetMinCws(std::vector< uint32_t > minCws)
Set the minimum contention window size for each link.
Definition: txop.cc:216
void SetAifsns(std::vector< uint8_t > aifsns)
Set the number of slots that make up an AIFS for each link.
Definition: txop.cc:342
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:485
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:90
Ptr< HtConfiguration > GetHtConfiguration(void) const
Definition: wifi-mac.cc:1166
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities of the device.
Definition: wifi-mac.cc:1310
bool GetShortSlotTimeSupported(void) const
Definition: wifi-mac.cc:990
Ptr< HeConfiguration > GetHeConfiguration(void) const
Definition: wifi-mac.cc:1178
uint8_t GetNLinks(void) const
Get the number of links (can be greater than 1 for 11be devices only).
Definition: wifi-mac.cc:843
bool GetVhtSupported() const
Return whether the device supports VHT.
Definition: wifi-mac.cc:1200
bool GetQosSupported() const
Return whether the device supports QoS.
Definition: wifi-mac.cc:940
virtual void SetAddress(Mac48Address address)
Definition: wifi-mac.cc:399
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
Definition: wifi-mac.cc:1455
Ssid GetSsid(void) const
Definition: wifi-mac.cc:419
void DoInitialize() override
Initialize() implementation.
Definition: wifi-mac.cc:321
virtual void ConfigureStandard(WifiStandard standard)
Definition: wifi-mac.cc:671
Mac48Address GetAddress(void) const
Definition: wifi-mac.cc:406
bool GetErpSupported(uint8_t linkId) const
Return whether the device supports ERP on the given link.
Definition: wifi-mac.cc:946
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:1190
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Definition: wifi-mac.cc:374
Ptr< WifiPhy > GetWifiPhy(uint8_t linkId=SINGLE_LINK_OP_ID) const
Definition: wifi-mac.cc:888
Ptr< QosTxop > GetVOQueue(void) const
Accessor for the AC_VO channel access function.
Definition: wifi-mac.cc:478
bool GetEhtSupported() const
Return whether the device supports EHT.
Definition: wifi-mac.cc:1220
bool GetHeSupported() const
Return whether the device supports HE.
Definition: wifi-mac.cc:1210
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
Definition: wifi-mac.h:616
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:1510
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:548
virtual void SetLinkUpCallback(Callback< void > linkUp)
Definition: wifi-mac.cc:1009
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId=0) const
Definition: wifi-mac.cc:823
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
Definition: wifi-mac.cc:1034
virtual void Receive(Ptr< WifiMacQueueItem > mpdu, uint8_t linkId)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
Definition: wifi-mac.cc:1041
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
Definition: wifi-mac.cc:1377
LinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition: wifi-mac.cc:835
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
Definition: wifi-mac.cc:1321
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:337
bool GetDsssSupported(uint8_t linkId) const
Return whether the device supports DSSS on the given link.
Definition: wifi-mac.cc:970
void SetBssid(Mac48Address bssid)
Definition: wifi-mac.cc:425
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:1797
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1200
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1182
void SetSlot(Time slot)
Set the slot duration for this PHY.
Definition: wifi-phy.cc:716
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:963
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:1310
#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_NOARGS()
Output the name of the function.
#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:1261
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1253
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiMacDropReason
The reason why an MPDU was dropped.
Definition: wifi-mac.h:71
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:40
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:59
@ 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
static constexpr uint8_t SINGLE_LINK_OP_ID
Link ID for single link operations (helps tracking places where correct link ID is to be used to supp...
Definition: wifi-utils.h:138
@ 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:88