A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-remote-station-manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006,2007 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
10
11#include "ap-wifi-mac.h"
12#include "gcr-manager.h"
13#include "sta-wifi-mac.h"
14#include "wifi-mac-header.h"
15#include "wifi-mac-trailer.h"
16#include "wifi-mpdu.h"
17#include "wifi-net-device.h"
18#include "wifi-phy.h"
19#include "wifi-psdu.h"
20#include "wifi-tx-parameters.h"
21
22#include "ns3/boolean.h"
23#include "ns3/eht-configuration.h"
24#include "ns3/enum.h"
25#include "ns3/erp-ofdm-phy.h"
26#include "ns3/he-configuration.h"
27#include "ns3/ht-configuration.h"
28#include "ns3/ht-phy.h"
29#include "ns3/log.h"
30#include "ns3/simulator.h"
31#include "ns3/uinteger.h"
32#include "ns3/vht-configuration.h"
33
34namespace ns3
35{
36
37NS_LOG_COMPONENT_DEFINE("WifiRemoteStationManager");
38
39NS_OBJECT_ENSURE_REGISTERED(WifiRemoteStationManager);
40
41TypeId
43{
44 static TypeId tid =
45 TypeId("ns3::WifiRemoteStationManager")
47 .SetGroupName("Wifi")
48 .AddAttribute("MaxSsrc",
49 "The maximum number of retransmission attempts for any packet with size "
50 "<= RtsCtsThreshold. "
51 "This value will not have any effect on some rate control algorithms.",
56 "Use WifiMac::FrameRetryLimit instead")
57 .AddAttribute("MaxSlrc",
58 "The maximum number of retransmission attempts for any packet with size "
59 "> RtsCtsThreshold. "
60 "This value will not have any effect on some rate control algorithms.",
65 "Use WifiMac::FrameRetryLimit instead")
66 .AddAttribute(
67 "IncrementRetryCountUnderBa",
68 "The 802.11-2020 standard states that the retry count for frames that are part of "
69 "a Block Ack agreement shall not be incremented when a transmission fails. As a "
70 "consequence, frames that are part of a Block Ack agreement are not dropped based "
71 "on the number of retries. Set this attribute to true to override the standard "
72 "behavior and increment the retry count (and eventually drop) frames that are "
73 "part of a Block Ack agreement.",
74 BooleanValue(false),
77 .AddAttribute("RtsCtsThreshold",
78 "If the size of the PSDU is bigger than this value, we use an RTS/CTS "
79 "handshake before sending the data frame."
80 "This value will not have any effect on some rate control algorithms.",
81 UintegerValue(4692480),
84 .AddAttribute("RtsCtsTxDurationThresh",
85 "If this threshold is a strictly positive value and the TX duration of "
86 "the PSDU is greater than or equal to this threshold, we use an RTS/CTS "
87 "handshake before sending the data frame.",
88 TimeValue(Time{0}),
91 .AddAttribute(
92 "FragmentationThreshold",
93 "If the size of the PSDU is bigger than this value, we fragment it such that the "
94 "size of the fragments are equal or smaller. "
95 "This value does not apply when it is carried in an A-MPDU. "
96 "This value will not have any effect on some rate control algorithms.",
97 UintegerValue(65535),
101 .AddAttribute("NonUnicastMode",
102 "Wifi mode used for non-unicast transmissions.",
106 .AddAttribute("DefaultTxPowerLevel",
107 "Default power level to be used for transmissions. "
108 "This is the power level that is used by all those WifiManagers that do "
109 "not implement TX power control.",
110 UintegerValue(0),
113 .AddAttribute("ErpProtectionMode",
114 "Protection mode used when non-ERP STAs are connected to an ERP AP: "
115 "Rts-Cts or Cts-To-Self",
120 "Rts-Cts",
122 "Cts-To-Self"))
123 .AddAttribute("HtProtectionMode",
124 "Protection mode used when non-HT STAs are connected to a HT AP: Rts-Cts "
125 "or Cts-To-Self",
130 "Rts-Cts",
132 "Cts-To-Self"))
133 .AddTraceSource("MacTxRtsFailed",
134 "The transmission of a RTS by the MAC layer has failed",
136 "ns3::Mac48Address::TracedCallback")
137 .AddTraceSource("MacTxDataFailed",
138 "The transmission of a data packet by the MAC layer has failed",
140 "ns3::Mac48Address::TracedCallback")
141 .AddTraceSource(
142 "MacTxFinalRtsFailed",
143 "The transmission of a RTS has exceeded the maximum number of attempts",
145 "ns3::Mac48Address::TracedCallback")
146 .AddTraceSource(
147 "MacTxFinalDataFailed",
148 "The transmission of a data packet has exceeded the maximum number of attempts",
150 "ns3::Mac48Address::TracedCallback");
151 return tid;
152}
153
155 : m_linkId(0),
156 m_useNonErpProtection(false),
157 m_useNonHtProtection(false),
158 m_shortPreambleEnabled(false),
159 m_shortSlotTimeEnabled(false)
160{
161 NS_LOG_FUNCTION(this);
162 m_ssrc.fill(0);
163 m_slrc.fill(0);
164}
165
170
171void
177
178void
180{
181 NS_LOG_FUNCTION(this << phy);
182 // We need to track our PHY because it is the object that knows the
183 // full set of transmit rates that are supported. We need to know
184 // this in order to find the relevant mandatory rates when choosing a
185 // transmit rate for automatic control responses like
186 // acknowledgments.
187 m_wifiPhy = phy;
188}
189
190void
192{
193 NS_LOG_FUNCTION(this << mac);
194 // We need to track our MAC because it is the object that knows the
195 // full set of interframe spaces.
196 m_wifiMac = mac;
197}
198
199void
201{
202 NS_LOG_FUNCTION(this << +linkId);
203 m_linkId = linkId;
204}
205
206int64_t
208{
209 NS_LOG_FUNCTION(this << stream);
210 return 0;
211}
212
213void
215{
216 NS_LOG_FUNCTION(this << maxSsrc);
217 m_maxSsrc = maxSsrc;
218}
219
220void
222{
223 NS_LOG_FUNCTION(this << maxSlrc);
224 m_maxSlrc = maxSlrc;
225}
226
227void
229{
230 NS_LOG_FUNCTION(this << threshold);
231 m_rtsCtsThreshold = threshold;
232}
233
234void
240
241void
243{
244 NS_LOG_FUNCTION(this << enable);
245 m_shortPreambleEnabled = enable;
246}
247
248void
250{
251 NS_LOG_FUNCTION(this << enable);
252 m_shortSlotTimeEnabled = enable;
253}
254
255bool
260
261bool
266
267bool
269{
270 return (m_wifiPhy->GetDevice()->GetHtConfiguration() &&
272}
273
274bool
276{
277 return (m_wifiPhy->GetDevice()->GetVhtConfiguration() &&
280}
281
282bool
284{
285 return bool(m_wifiPhy->GetDevice()->GetHeConfiguration());
286}
287
288bool
290{
291 return bool(m_wifiPhy->GetDevice()->GetEhtConfiguration());
292}
293
294bool
296{
297 if (auto htConfiguration = m_wifiPhy->GetDevice()->GetHtConfiguration())
298 {
299 return htConfiguration->m_ldpcSupported;
300 }
301 return false;
302}
303
304bool
306{
307 if (auto htConfiguration = m_wifiPhy->GetDevice()->GetHtConfiguration())
308 {
309 return htConfiguration->m_sgiSupported;
310 }
311 return false;
312}
313
314Time
316{
317 Time gi{};
318 if (GetHeSupported())
319 {
320 Ptr<HeConfiguration> heConfiguration = m_wifiPhy->GetDevice()->GetHeConfiguration();
321 NS_ASSERT(heConfiguration); // If HE is supported, we should have a HE configuration
322 // attached
323 gi = heConfiguration->GetGuardInterval();
324 }
325 return gi;
326}
327
333
334void
336 bool isShortPreambleSupported)
337{
338 NS_LOG_FUNCTION(this << address << isShortPreambleSupported);
339 NS_ASSERT(!address.IsGroup());
340 LookupState(address)->m_shortPreamble = isShortPreambleSupported;
341}
342
343void
345 bool isShortSlotTimeSupported)
346{
347 NS_LOG_FUNCTION(this << address << isShortSlotTimeSupported);
348 NS_ASSERT(!address.IsGroup());
349 LookupState(address)->m_shortSlotTime = isShortSlotTimeSupported;
350}
351
352void
354{
355 NS_LOG_FUNCTION(this << address << mode);
356 NS_ASSERT(!address.IsGroup());
357 auto state = LookupState(address);
358 for (const auto& i : state->m_operationalRateSet)
359 {
360 if (i == mode)
361 {
362 return; // already in
363 }
364 }
365 if ((mode.GetModulationClass() == WIFI_MOD_CLASS_DSSS) ||
367 {
368 state->m_dsssSupported = true;
369 }
371 {
372 state->m_erpOfdmSupported = true;
373 }
374 else if (mode.GetModulationClass() == WIFI_MOD_CLASS_OFDM)
375 {
376 state->m_ofdmSupported = true;
377 }
378 state->m_operationalRateSet.push_back(mode);
379}
380
381void
383{
384 NS_LOG_FUNCTION(this << address);
385 NS_ASSERT(!address.IsGroup());
386 auto state = LookupState(address);
387 state->m_operationalRateSet.clear();
388 for (const auto& mode : m_wifiPhy->GetModeList())
389 {
390 state->m_operationalRateSet.push_back(mode);
391 if (mode.IsMandatory())
392 {
393 AddBasicMode(mode);
394 }
395 }
396}
397
398void
400{
401 NS_LOG_FUNCTION(this << address);
402 NS_ASSERT(!address.IsGroup());
403 auto state = LookupState(address);
404
405 const auto& mcsList = m_wifiPhy->GetMcsList();
406 state->m_operationalMcsSet = WifiModeList(mcsList.begin(), mcsList.end());
407}
408
409void
411{
412 NS_LOG_FUNCTION(this << address);
413 NS_ASSERT(!address.IsGroup());
414 LookupState(address)->m_operationalMcsSet.clear();
415}
416
417void
419{
420 NS_LOG_FUNCTION(this << address << mcs);
421 NS_ASSERT(!address.IsGroup());
422 auto state = LookupState(address);
423 for (const auto& i : state->m_operationalMcsSet)
424 {
425 if (i == mcs)
426 {
427 return; // already in
428 }
429 }
430 state->m_operationalMcsSet.push_back(mcs);
431}
432
433bool
435{
436 return LookupState(address)->m_shortPreamble;
437}
438
439bool
441{
442 return LookupState(address)->m_shortSlotTime;
443}
444
445bool
447{
448 return LookupState(address)->m_qosSupported;
449}
450
451bool
453{
454 if (address.IsGroup())
455 {
456 return false;
457 }
458 return LookupState(address)->m_state == WifiRemoteStationState::BRAND_NEW;
459}
460
461bool
463{
464 if (address.IsGroup())
465 {
466 return true;
467 }
468 return LookupState(address)->m_state == WifiRemoteStationState::GOT_ASSOC_TX_OK;
469}
470
471bool
473{
474 if (address.IsGroup())
475 {
476 return false;
477 }
478 return LookupState(address)->m_state == WifiRemoteStationState::WAIT_ASSOC_TX_OK;
479}
480
481void
487
488void
494
495void
501
502void
508
509bool
511{
512 if (address.IsGroup())
513 {
514 return false;
515 }
516 return LookupState(address)->m_state == WifiRemoteStationState::ASSOC_REFUSED;
517}
518
519void
525
526uint16_t
528{
529 std::shared_ptr<WifiRemoteStationState> state;
530 if (!remoteAddress.IsGroup() &&
531 (state = LookupState(remoteAddress))->m_state == WifiRemoteStationState::GOT_ASSOC_TX_OK)
532 {
533 return state->m_aid;
534 }
535 return SU_STA_ID;
536}
537
538uint16_t
540{
541 NS_LOG_FUNCTION(this << address << txVector);
542
543 uint16_t staId = SU_STA_ID;
544
545 if (txVector.IsMu())
546 {
547 if (m_wifiMac->GetTypeOfStation() == AP)
548 {
549 staId = GetAssociationId(address);
550 }
551 else if (m_wifiMac->GetTypeOfStation() == STA)
552 {
554 if (staMac->IsAssociated())
555 {
556 staId = staMac->GetAssociationId();
557 }
558 }
559 }
560
561 NS_LOG_DEBUG("Returning STAID = " << staId);
562 return staId;
563}
564
565bool
567{
568 return LookupState(address)->m_isInPsMode;
569}
570
571void
572WifiRemoteStationManager::SetPsMode(const Mac48Address& address, bool isInPsMode)
573{
574 LookupState(address)->m_isInPsMode = isInPsMode;
575}
576
577std::optional<Mac48Address>
579{
580 if (auto stateIt = m_states.find(address);
581 stateIt != m_states.end() && stateIt->second->m_mleCommonInfo)
582 {
583 return stateIt->second->m_mleCommonInfo->m_mldMacAddress;
584 }
585
586 return std::nullopt;
587}
588
589std::optional<Mac48Address>
591{
592 auto stateIt = m_states.find(mldAddress);
593
594 if (stateIt == m_states.end() || !stateIt->second->m_mleCommonInfo)
595 {
596 // MLD address not found
597 return std::nullopt;
598 }
599
600 NS_ASSERT(stateIt->second->m_mleCommonInfo->m_mldMacAddress == mldAddress);
601 return stateIt->second->m_address;
602}
603
606{
607 NS_LOG_FUNCTION(this << header << allowedWidth);
608 const auto address = header.GetAddr1();
609 if (!header.IsMgt() && address.IsGroup())
610 {
611 return GetGroupcastTxVector(header, allowedWidth);
612 }
613 WifiTxVector txVector;
614 if (header.IsMgt())
615 {
616 // Use the lowest basic rate for management frames
617 WifiMode mgtMode;
618 if (GetNBasicModes() > 0)
619 {
620 mgtMode = GetBasicMode(0);
621 }
622 else
623 {
624 mgtMode = GetDefaultMode();
625 }
626 txVector.SetMode(mgtMode);
627 txVector.SetPreambleType(
630 auto channelWidth = allowedWidth;
631 if (!header.GetAddr1().IsGroup())
632 {
633 if (const auto rxWidth = GetChannelWidthSupported(header.GetAddr1());
634 rxWidth < channelWidth)
635 {
636 channelWidth = rxWidth;
637 }
638 }
639
640 txVector.SetChannelWidth(m_wifiPhy->GetTxBandwidth(mgtMode, channelWidth));
642 }
643 else
644 {
645 txVector = DoGetDataTxVector(Lookup(address), allowedWidth);
647 ? false
648 : UseLdpcForDestination(address));
649 }
650 Ptr<HeConfiguration> heConfiguration = m_wifiPhy->GetDevice()->GetHeConfiguration();
651 if (heConfiguration)
652 {
653 txVector.SetBssColor(heConfiguration->m_bssColor);
654 }
655 // If both the allowed width and the TXVECTOR channel width are integer multiple
656 // of 20 MHz, then the TXVECTOR channel width must not exceed the allowed width
657 NS_ASSERT_MSG((static_cast<uint16_t>(txVector.GetChannelWidth()) % 20 != 0) ||
658 (static_cast<uint16_t>(allowedWidth) % 20 != 0) ||
659 (txVector.GetChannelWidth() <= allowedWidth),
660 "TXVECTOR channel width (" << txVector.GetChannelWidth()
661 << " MHz) exceeds allowed width (" << allowedWidth
662 << " MHz)");
663 return txVector;
664}
665
668{
669 WifiMode defaultMode = GetDefaultMode();
670 WifiPreamble defaultPreamble;
671 if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_EHT)
672 {
673 defaultPreamble = WIFI_PREAMBLE_EHT_MU;
674 }
675 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_HE)
676 {
677 defaultPreamble = WIFI_PREAMBLE_HE_SU;
678 }
679 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_VHT)
680 {
681 defaultPreamble = WIFI_PREAMBLE_VHT_SU;
682 }
683 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_HT)
684 {
685 defaultPreamble = WIFI_PREAMBLE_HT_MF;
686 }
687 else
688 {
689 defaultPreamble = WIFI_PREAMBLE_LONG;
690 }
691
692 return WifiTxVector(defaultMode,
694 defaultPreamble,
697 1,
698 0,
699 m_wifiPhy->GetTxBandwidth(defaultMode),
700 false);
701}
702
705{
706 NS_LOG_FUNCTION(this << address << allowedWidth);
707 WifiTxVector v;
708 if (address.IsGroup())
709 {
711 v.SetMode(mode);
718 v.SetNss(1);
719 v.SetNess(0);
720 }
721 else
722 {
723 v = DoGetRtsTxVector(Lookup(address));
724 }
725 auto modulation = v.GetModulationClass();
726
727 if (allowedWidth >= 40 &&
728 (modulation == WIFI_MOD_CLASS_DSSS || modulation == WIFI_MOD_CLASS_HR_DSSS))
729 {
730 // RTS must be sent in a non-HT duplicate PPDU because it must protect a frame being
731 // transmitted on at least 40 MHz. Change the modulation class to ERP-OFDM and the rate
732 // to 6 Mbps
734 modulation = v.GetModulationClass();
735 }
736 // do not set allowedWidth as the TX width if the modulation class is (HR-)DSSS (allowedWidth
737 // may be >= 40 MHz) or allowedWidth is 22 MHz (the selected modulation class may be OFDM)
738 if (modulation != WIFI_MOD_CLASS_DSSS && modulation != WIFI_MOD_CLASS_HR_DSSS &&
739 allowedWidth != 22)
740 {
741 v.SetChannelWidth(allowedWidth);
742 }
743
744 return v;
745}
746
749{
750 auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
751 NS_ASSERT(!to.IsGroup() ||
752 (m_wifiMac && (m_wifiMac->GetTypeOfStation() == AP) && apMac->GetGcrManager()));
753 WifiMode ctsMode = GetControlAnswerMode(rtsTxMode);
754 WifiTxVector v;
755 v.SetMode(ctsMode);
761 v.SetNss(1);
762 return v;
763}
764
765void
767{
768 NS_LOG_FUNCTION(this << txVector);
769
770 auto txMode = txVector.GetMode();
771 if (txMode.GetModulationClass() >= WIFI_MOD_CLASS_HT)
772 {
773 auto rate = txMode.GetDataRate(txVector);
774 if (rate >= 24e6)
775 {
776 rate = 24e6;
777 }
778 else if (rate >= 12e6)
779 {
780 rate = 12e6;
781 }
782 else
783 {
784 rate = 6e6;
785 }
788 {
789 txVector.SetMode(ErpOfdmPhy::GetErpOfdmRate(rate));
790 }
791 else
792 {
793 txVector.SetMode(OfdmPhy::GetOfdmRate(rate));
794 }
795 }
796}
797
800{
801 NS_ASSERT(!to.IsGroup());
802 WifiMode ackMode = GetControlAnswerMode(dataTxVector.GetMode(GetStaId(to, dataTxVector)));
803 WifiTxVector v;
804 v.SetMode(ackMode);
810 v.SetNss(1);
811 return v;
812}
813
816 const WifiTxVector& dataTxVector) const
817{
818 NS_ASSERT(!to.IsGroup());
819 WifiMode blockAckMode = GetControlAnswerMode(dataTxVector.GetMode(GetStaId(to, dataTxVector)));
820 WifiTxVector v;
821 v.SetMode(blockAckMode);
825 v.SetChannelWidth(m_wifiPhy->GetTxBandwidth(blockAckMode));
827 v.SetNss(1);
828 return v;
829}
830
833{
834 /**
835 * The standard has relatively unambiguous rules for selecting a
836 * control response rate (the below is quoted from IEEE 802.11-2012,
837 * Section 9.7):
838 *
839 * To allow the transmitting STA to calculate the contents of the
840 * Duration/ID field, a STA responding to a received frame shall
841 * transmit its Control Response frame (either CTS or Ack), other
842 * than the BlockAck control frame, at the highest rate in the
843 * BSSBasicRateSet parameter that is less than or equal to the
844 * rate of the immediately previous frame in the frame exchange
845 * sequence (as defined in Annex G) and that is of the same
846 * modulation class (see Section 9.7.8) as the received frame...
847 */
848 NS_LOG_FUNCTION(this << reqMode);
849 WifiMode mode = GetDefaultMode();
850 bool found = false;
851 // First, search the BSS Basic Rate set
852 for (uint8_t i = 0; i < GetNBasicModes(); i++)
853 {
854 WifiMode testMode = GetBasicMode(i);
855 if ((!found || testMode.IsHigherDataRate(mode)) && (!testMode.IsHigherDataRate(reqMode)) &&
857 testMode.GetModulationClass())))
858 {
859 mode = testMode;
860 // We've found a potentially-suitable transmit rate, but we
861 // need to continue and consider all the basic rates before
862 // we can be sure we've got the right one.
863 found = true;
864 }
865 }
866 if (m_wifiPhy->GetDevice()->GetHtConfiguration())
867 {
868 if (!found)
869 {
870 mode = GetDefaultMcs();
871 for (uint8_t i = 0; i != GetNBasicMcs(); i++)
872 {
873 WifiMode testMode = GetBasicMcs(i);
874 if ((!found || testMode.IsHigherDataRate(mode)) &&
875 (!testMode.IsHigherDataRate(reqMode)) &&
876 (testMode.GetModulationClass() == reqMode.GetModulationClass()))
877 {
878 mode = testMode;
879 // We've found a potentially-suitable transmit rate, but we
880 // need to continue and consider all the basic rates before
881 // we can be sure we've got the right one.
882 found = true;
883 }
884 }
885 }
886 }
887 // If we found a suitable rate in the BSSBasicRateSet, then we are
888 // done and can return that mode.
889 if (found)
890 {
891 NS_LOG_DEBUG("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
892 return mode;
893 }
894
895 /**
896 * If no suitable basic rate was found, we search the mandatory
897 * rates. The standard (IEEE 802.11-2007, Section 9.6) says:
898 *
899 * ...If no rate contained in the BSSBasicRateSet parameter meets
900 * these conditions, then the control frame sent in response to a
901 * received frame shall be transmitted at the highest mandatory
902 * rate of the PHY that is less than or equal to the rate of the
903 * received frame, and that is of the same modulation class as the
904 * received frame. In addition, the Control Response frame shall
905 * be sent using the same PHY options as the received frame,
906 * unless they conflict with the requirement to use the
907 * BSSBasicRateSet parameter.
908 *
909 * @todo Note that we're ignoring the last sentence for now, because
910 * there is not yet any manipulation here of PHY options.
911 */
912 for (const auto& thismode : m_wifiPhy->GetModeList())
913 {
914 /* If the rate:
915 *
916 * - is a mandatory rate for the PHY, and
917 * - is equal to or faster than our current best choice, and
918 * - is less than or equal to the rate of the received frame, and
919 * - is of the same modulation class as the received frame
920 *
921 * ...then it's our best choice so far.
922 */
923 if (thismode.IsMandatory() && (!found || thismode.IsHigherDataRate(mode)) &&
924 (!thismode.IsHigherDataRate(reqMode)) &&
926 thismode.GetModulationClass())))
927 {
928 mode = thismode;
929 // As above; we've found a potentially-suitable transmit
930 // rate, but we need to continue and consider all the
931 // mandatory rates before we can be sure we've got the right one.
932 found = true;
933 }
934 }
935 if (m_wifiPhy->GetDevice()->GetHtConfiguration())
936 {
937 for (const auto& thismode : m_wifiPhy->GetMcsList())
938 {
939 if (thismode.IsMandatory() && (!found || thismode.IsHigherDataRate(mode)) &&
940 (!thismode.IsHigherCodeRate(reqMode)) &&
941 (thismode.GetModulationClass() == reqMode.GetModulationClass()))
942 {
943 mode = thismode;
944 // As above; we've found a potentially-suitable transmit
945 // rate, but we need to continue and consider all the
946 // mandatory rates before we can be sure we've got the right one.
947 found = true;
948 }
949 }
950 }
951
952 /**
953 * If we still haven't found a suitable rate for the response then
954 * someone has messed up the simulation configuration. This probably means
955 * that the WifiPhyStandard is not set correctly, or that a rate that
956 * is not supported by the PHY has been explicitly requested.
957 *
958 * Either way, it is serious - we can either disobey the standard or
959 * fail, and I have chosen to do the latter...
960 */
961 if (!found)
962 {
963 NS_FATAL_ERROR("Can't find response rate for " << reqMode);
964 }
965
966 NS_LOG_DEBUG("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
967 return mode;
968}
969
970void
972{
973 NS_LOG_FUNCTION(this << header);
974 const auto recipient = GetIndividuallyAddressedRecipient(m_wifiMac, header);
975 NS_ASSERT(!recipient.IsGroup());
976 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
977 m_ssrc[ac]++;
978 m_macTxRtsFailed(recipient);
979 DoReportRtsFailed(Lookup(recipient));
980}
981
982void
984{
985 NS_LOG_FUNCTION(this << *mpdu);
986 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
987 AcIndex ac =
988 QosUtilsMapTidToAc((mpdu->GetHeader().IsQosData()) ? mpdu->GetHeader().GetQosTid() : 0);
989 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
990 if (longMpdu)
991 {
992 m_slrc[ac]++;
993 }
994 else
995 {
996 m_ssrc[ac]++;
997 }
998 m_macTxDataFailed(mpdu->GetHeader().GetAddr1());
999 DoReportDataFailed(Lookup(mpdu->GetHeader().GetAddr1()));
1000}
1001
1002void
1004 double ctsSnr,
1005 WifiMode ctsMode,
1006 double rtsSnr)
1007{
1008 NS_LOG_FUNCTION(this << header << ctsSnr << ctsMode << rtsSnr);
1009 const auto recipient = GetIndividuallyAddressedRecipient(m_wifiMac, header);
1010 NS_ASSERT(!recipient.IsGroup());
1011 WifiRemoteStation* station = Lookup(recipient);
1012 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
1013 station->m_state->m_info.NotifyTxSuccess(m_ssrc[ac]);
1014 m_ssrc[ac] = 0;
1015 DoReportRtsOk(station, ctsSnr, ctsMode, rtsSnr);
1016}
1017
1018void
1020 double ackSnr,
1021 WifiMode ackMode,
1022 double dataSnr,
1023 WifiTxVector dataTxVector)
1024{
1025 NS_LOG_FUNCTION(this << *mpdu << ackSnr << ackMode << dataSnr << dataTxVector);
1026 const WifiMacHeader& hdr = mpdu->GetHeader();
1027 NS_ASSERT(!hdr.GetAddr1().IsGroup());
1028 WifiRemoteStation* station = Lookup(hdr.GetAddr1());
1029 AcIndex ac = QosUtilsMapTidToAc((hdr.IsQosData()) ? hdr.GetQosTid() : 0);
1030 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
1031 if (longMpdu)
1032 {
1033 station->m_state->m_info.NotifyTxSuccess(m_slrc[ac]);
1034 m_slrc[ac] = 0;
1035 }
1036 else
1037 {
1038 station->m_state->m_info.NotifyTxSuccess(m_ssrc[ac]);
1039 m_ssrc[ac] = 0;
1040 }
1041 DoReportDataOk(station,
1042 ackSnr,
1043 ackMode,
1044 dataSnr,
1045 dataTxVector.GetChannelWidth(),
1046 dataTxVector.GetNss(GetStaId(hdr.GetAddr1(), dataTxVector)));
1047}
1048
1049void
1051{
1052 NS_LOG_FUNCTION(this << header);
1053 NS_ASSERT(!header.GetAddr1().IsGroup());
1054 WifiRemoteStation* station = Lookup(header.GetAddr1());
1055 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
1056 station->m_state->m_info.NotifyTxFailed();
1057 m_ssrc[ac] = 0;
1059 DoReportFinalRtsFailed(station);
1060}
1061
1062void
1064{
1065 NS_LOG_FUNCTION(this << *mpdu);
1066 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1067 WifiRemoteStation* station = Lookup(mpdu->GetHeader().GetAddr1());
1068 AcIndex ac =
1069 QosUtilsMapTidToAc((mpdu->GetHeader().IsQosData()) ? mpdu->GetHeader().GetQosTid() : 0);
1070 station->m_state->m_info.NotifyTxFailed();
1071 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
1072 if (longMpdu)
1073 {
1074 m_slrc[ac] = 0;
1075 }
1076 else
1077 {
1078 m_ssrc[ac] = 0;
1079 }
1080 m_macTxFinalDataFailed(mpdu->GetHeader().GetAddr1());
1081 DoReportFinalDataFailed(station);
1082}
1083
1084void
1086 RxSignalInfo rxSignalInfo,
1087 const WifiTxVector& txVector)
1088{
1089 NS_LOG_FUNCTION(this << address << rxSignalInfo << txVector);
1090 if (address.IsGroup())
1091 {
1092 return;
1093 }
1094 WifiRemoteStation* station = Lookup(address);
1095 DoReportRxOk(station, rxSignalInfo.snr, txVector.GetMode(GetStaId(address, txVector)));
1096 station->m_rssiAndUpdateTimePair = std::make_pair(rxSignalInfo.rssi, Simulator::Now());
1097}
1098
1099void
1101 uint16_t nSuccessfulMpdus,
1102 uint16_t nFailedMpdus,
1103 double rxSnr,
1104 double dataSnr,
1105 WifiTxVector dataTxVector)
1106{
1107 NS_LOG_FUNCTION(this << address << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr
1108 << dataTxVector);
1109 NS_ASSERT(!address.IsGroup());
1110 for (uint16_t i = 0; i < nFailedMpdus; i++)
1111 {
1112 m_macTxDataFailed(address);
1113 }
1115 nSuccessfulMpdus,
1116 nFailedMpdus,
1117 rxSnr,
1118 dataSnr,
1119 dataTxVector.GetChannelWidth(),
1120 dataTxVector.GetNss(GetStaId(address, dataTxVector)));
1121}
1122
1123std::list<Ptr<WifiMpdu>>
1125{
1126 NS_LOG_FUNCTION(this << *psdu);
1127
1128 auto* station = Lookup(GetIndividuallyAddressedRecipient(m_wifiMac, psdu->GetHeader(0)));
1129
1130 DoIncrementRetryCountOnTxFailure(station, psdu);
1131 return DoGetMpdusToDropOnTxFailure(station, psdu);
1132}
1133
1134void
1136 Ptr<WifiPsdu> psdu)
1137{
1138 NS_LOG_FUNCTION(this << *psdu);
1139
1140 // The frame retry count for an MSDU or A-MSDU that is not part of a block ack agreement or
1141 // for an MMPDU shall be incremented every time transmission fails for that MSDU, A-MSDU, or
1142 // MMPDU, including of an associated RTS (Sec. 10.23.2.12.1 of 802.11-2020).
1143 // Frames for which the retry count needs to be incremented:
1144 // - management frames
1145 // - non-QoS Data frames
1146 // - QoS Data frames that are not part of a Block Ack agreement
1147 // - QoS Data frames that are part of a Block Ack agreement if the IncrementRetryCountUnderBa
1148 // attribute is set to true
1149 const auto& hdr = psdu->GetHeader(0);
1150
1151 if (hdr.IsMgt() || (hdr.IsData() && !hdr.IsQosData()) ||
1152 (hdr.IsQosData() && (!m_wifiMac->GetBaAgreementEstablishedAsOriginator(
1153 hdr.GetAddr1(),
1154 hdr.GetQosTid() || m_incrRetryCountUnderBa))))
1155 {
1156 psdu->IncrementRetryCount();
1157 }
1158}
1159
1160std::list<Ptr<WifiMpdu>>
1162 Ptr<WifiPsdu> psdu)
1163{
1164 NS_LOG_FUNCTION(this << *psdu);
1165
1166 std::list<Ptr<WifiMpdu>> mpdusToDrop;
1167
1168 for (const auto& mpdu : *PeekPointer(psdu))
1169 {
1170 if (mpdu->GetRetryCount() == m_wifiMac->GetFrameRetryLimit())
1171 {
1172 // this MPDU needs to be dropped
1173 mpdusToDrop.push_back(mpdu);
1174 }
1175 }
1176
1177 return mpdusToDrop;
1178}
1179
1180bool
1182{
1183 NS_LOG_FUNCTION(this << header << &txParams);
1184 auto address = header.GetAddr1();
1185 const auto isGcr = IsGcr(m_wifiMac, header);
1186 if (!isGcr && address.IsGroup())
1187 {
1188 return false;
1189 }
1190 if (isGcr)
1191 {
1193 auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
1194 apMac->GetGcrManager()->GetAttribute("GcrProtectionMode", enumValue);
1195 if (enumValue.Get() != GroupcastProtectionMode::RTS_CTS)
1196 {
1197 return false;
1198 }
1199 address = apMac->GetGcrManager()->GetIndividuallyAddressedRecipient(address);
1200 }
1201 const auto modulationClass = txParams.m_txVector.GetModulationClass();
1203 ((modulationClass == WIFI_MOD_CLASS_ERP_OFDM) || (modulationClass == WIFI_MOD_CLASS_HT) ||
1204 (modulationClass == WIFI_MOD_CLASS_VHT) || (modulationClass == WIFI_MOD_CLASS_HE) ||
1205 (modulationClass == WIFI_MOD_CLASS_EHT)) &&
1207 {
1209 "WifiRemoteStationManager::NeedRTS returning true to protect non-ERP stations");
1210 return true;
1211 }
1212 else if (m_htProtectionMode == RTS_CTS &&
1213 ((modulationClass == WIFI_MOD_CLASS_HT) || (modulationClass == WIFI_MOD_CLASS_VHT)) &&
1215 {
1216 NS_LOG_DEBUG("WifiRemoteStationManager::NeedRTS returning true to protect non-HT stations");
1217 return true;
1218 }
1219 NS_ASSERT(txParams.m_txDuration.has_value());
1220 auto size = txParams.GetSize(header.GetAddr1());
1221 bool normally =
1224 return DoNeedRts(Lookup(address), size, normally);
1225}
1226
1227bool
1229{
1230 NS_LOG_FUNCTION(this << txVector << header);
1233 (txVector.GetModulationClass() == WIFI_MOD_CLASS_HT) ||
1234 (txVector.GetModulationClass() == WIFI_MOD_CLASS_VHT) ||
1235 (txVector.GetModulationClass() == WIFI_MOD_CLASS_HE) ||
1236 (txVector.GetModulationClass() == WIFI_MOD_CLASS_EHT)))
1237 {
1239 "WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
1240 return true;
1241 }
1242 else if (m_htProtectionMode == CTS_TO_SELF &&
1243 ((txVector.GetModulationClass() == WIFI_MOD_CLASS_HT) ||
1244 (txVector.GetModulationClass() == WIFI_MOD_CLASS_VHT)) &&
1246 {
1248 "WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-HT stations");
1249 return true;
1250 }
1251 else if (IsGcr(m_wifiMac, header))
1252 {
1254 auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
1255 apMac->GetGcrManager()->GetAttribute("GcrProtectionMode", enumValue);
1256 if (enumValue.Get() == GroupcastProtectionMode::CTS_TO_SELF)
1257 {
1258 return true;
1259 }
1260 }
1261 // FIXME: commented out for now
1262 /*else if (!m_useNonErpProtection)
1263 {
1264 const auto mode = txVector.GetMode();
1265 // search for the BSS Basic Rate set, if the used mode is in the basic set then there is no
1266 // need for CTS To Self
1267 for (auto i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++)
1268 {
1269 if (mode == *i)
1270 {
1271 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning false");
1272 return false;
1273 }
1274 }
1275 if (m_wifiPhy->GetDevice()->GetHtConfiguration())
1276 {
1277 // search for the BSS Basic MCS set, if the used mode is in the basic set then there is
1278 // no need for CTS To Self
1279 for (auto i = m_bssBasicMcsSet.begin(); i != m_bssBasicMcsSet.end(); i++)
1280 {
1281 if (mode == *i)
1282 {
1283 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning false");
1284 return false;
1285 }
1286 }
1287 }
1288 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning true");
1289 return true;
1290 }*/
1291 return false;
1292}
1293
1294void
1296{
1297 NS_LOG_FUNCTION(this << enable);
1298 m_useNonErpProtection = enable;
1299}
1300
1301bool
1306
1307void
1309{
1310 NS_LOG_FUNCTION(this << enable);
1311 m_useNonHtProtection = enable;
1312}
1313
1314bool
1319
1320bool
1322{
1323 NS_LOG_FUNCTION(this << *mpdu);
1324 if (mpdu->GetHeader().GetAddr1().IsGroup())
1325 {
1326 return false;
1327 }
1328 bool normally = mpdu->GetSize() > GetFragmentationThreshold();
1329 NS_LOG_DEBUG("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha
1330 << normally);
1331 return DoNeedFragmentation(Lookup(mpdu->GetHeader().GetAddr1()), mpdu->GetPacket(), normally);
1332}
1333
1334void
1336{
1337 NS_LOG_FUNCTION(this << threshold);
1338 if (threshold < 256)
1339 {
1340 /*
1341 * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
1342 */
1343 NS_LOG_WARN("Fragmentation threshold should be larger than 256. Setting to 256.");
1345 }
1346 else
1347 {
1348 /*
1349 * The length of each fragment shall be an even number of octets, except for the last
1350 * fragment if an MSDU or MMPDU, which may be either an even or an odd number of octets.
1351 */
1352 if (threshold % 2 != 0)
1353 {
1354 NS_LOG_WARN("Fragmentation threshold should be an even number. Setting to "
1355 << threshold - 1);
1356 m_fragmentationThreshold = threshold - 1;
1357 }
1358 else
1359 {
1360 m_fragmentationThreshold = threshold;
1361 }
1362 }
1363}
1364
1370
1373{
1374 NS_LOG_FUNCTION(this << *mpdu);
1375 // The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1376 uint32_t nFragments =
1377 (mpdu->GetPacket()->GetSize() /
1378 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH));
1379
1380 // If the size of the last fragment is not 0.
1381 if ((mpdu->GetPacket()->GetSize() %
1382 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH)) > 0)
1383 {
1384 nFragments++;
1385 }
1386 NS_LOG_DEBUG("WifiRemoteStationManager::GetNFragments returning " << nFragments);
1387 return nFragments;
1388}
1389
1392{
1393 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1394 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1395 uint32_t nFragment = GetNFragments(mpdu);
1396 if (fragmentNumber >= nFragment)
1397 {
1398 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning 0");
1399 return 0;
1400 }
1401 // Last fragment
1402 if (fragmentNumber == nFragment - 1)
1403 {
1404 uint32_t lastFragmentSize =
1405 mpdu->GetPacket()->GetSize() -
1406 (fragmentNumber *
1407 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH));
1408 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
1409 return lastFragmentSize;
1410 }
1411 // All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1412 else
1413 {
1414 uint32_t fragmentSize =
1415 GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH;
1416 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
1417 return fragmentSize;
1418 }
1419}
1420
1423{
1424 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1425 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1426 NS_ASSERT(fragmentNumber < GetNFragments(mpdu));
1427 uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold() -
1428 mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH);
1429 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
1430 return fragmentOffset;
1431}
1432
1433bool
1435{
1436 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1437 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1438 bool isLast = fragmentNumber == (GetNFragments(mpdu) - 1);
1439 NS_LOG_DEBUG("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
1440 return isLast;
1441}
1442
1443uint8_t
1448
1451{
1452 return LookupState(address)->m_info;
1453}
1454
1455std::optional<dBm_u>
1457{
1458 auto station = Lookup(address);
1459 auto rssi = station->m_rssiAndUpdateTimePair.first;
1460 auto ts = station->m_rssiAndUpdateTimePair.second;
1461 if (ts.IsStrictlyPositive())
1462 {
1463 return rssi;
1464 }
1465 return std::nullopt;
1466}
1467
1468std::shared_ptr<WifiRemoteStationState>
1470{
1471 NS_LOG_FUNCTION(this << address);
1472 auto stateIt = m_states.find(address);
1473
1474 if (stateIt != m_states.end())
1475 {
1476 NS_LOG_DEBUG("WifiRemoteStationManager::LookupState returning existing state");
1477 return stateIt->second;
1478 }
1479
1480 auto state = std::make_shared<WifiRemoteStationState>();
1481 state->m_state = WifiRemoteStationState::BRAND_NEW;
1482 state->m_address = address;
1483 state->m_aid = 0;
1484 state->m_operationalRateSet.push_back(GetDefaultMode());
1485 state->m_operationalMcsSet.push_back(GetDefaultMcs());
1486 state->m_dsssSupported = false;
1487 state->m_erpOfdmSupported = false;
1488 state->m_ofdmSupported = false;
1489 state->m_htCapabilities = nullptr;
1490 state->m_vhtCapabilities = nullptr;
1491 state->m_heCapabilities = nullptr;
1492 state->m_ehtCapabilities = nullptr;
1493 state->m_mleCommonInfo = nullptr;
1494 state->m_emlsrEnabled = false;
1495 state->m_channelWidth = m_wifiPhy->GetChannelWidth();
1496 state->m_guardInterval = GetGuardInterval();
1497 state->m_ness = 0;
1498 state->m_aggregation = false;
1499 state->m_qosSupported = false;
1500 state->m_isInPsMode = false;
1501 const_cast<WifiRemoteStationManager*>(this)->m_states.insert({address, state});
1502 NS_LOG_DEBUG("WifiRemoteStationManager::LookupState returning new state");
1503 return state;
1504}
1505
1506WifiRemoteStation*
1507WifiRemoteStationManager::Lookup(Mac48Address address) const
1508{
1509 NS_LOG_FUNCTION(this << address);
1510 NS_ASSERT(!address.IsGroup());
1511 NS_ASSERT(address != m_wifiMac->GetAddress());
1512 auto stationIt = m_stations.find(address);
1513
1514 if (stationIt != m_stations.end())
1515 {
1516 return stationIt->second;
1517 }
1518
1519 WifiRemoteStation* station = DoCreateStation();
1520 station->m_state = LookupState(address).get();
1521 station->m_rssiAndUpdateTimePair = std::make_pair(dBm_u{0}, Seconds(0));
1522 const_cast<WifiRemoteStationManager*>(this)->m_stations.insert({address, station});
1523 return station;
1524}
1525
1526void
1527WifiRemoteStationManager::SetAssociationId(Mac48Address remoteAddress, uint16_t aid)
1528{
1529 NS_LOG_FUNCTION(this << remoteAddress << aid);
1530 LookupState(remoteAddress)->m_aid = aid;
1531}
1532
1533void
1534WifiRemoteStationManager::SetQosSupport(Mac48Address from, bool qosSupported)
1535{
1536 NS_LOG_FUNCTION(this << from << qosSupported);
1537 LookupState(from)->m_qosSupported = qosSupported;
1538}
1539
1540void
1541WifiRemoteStationManager::SetEmlsrEnabled(const Mac48Address& from, bool emlsrEnabled)
1542{
1543 NS_LOG_FUNCTION(this << from << emlsrEnabled);
1544 LookupState(from)->m_emlsrEnabled = emlsrEnabled;
1545}
1546
1547void
1548WifiRemoteStationManager::AddStationHtCapabilities(Mac48Address from,
1549 const HtCapabilities& htCapabilities)
1550{
1551 // Used by all stations to record HT capabilities of remote stations
1552 NS_LOG_FUNCTION(this << from << htCapabilities);
1553 auto state = LookupState(from);
1554 if (htCapabilities.GetSupportedChannelWidth() == 1)
1555 {
1556 state->m_channelWidth = MHz_u{40};
1557 }
1558 else
1559 {
1560 state->m_channelWidth = MHz_u{20};
1561 }
1562 SetQosSupport(from, true);
1563 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_HT))
1564 {
1565 if (htCapabilities.IsSupportedMcs(mcs.GetMcsValue()))
1566 {
1567 AddSupportedMcs(from, mcs);
1568 }
1569 }
1570 state->m_htCapabilities = Create<const HtCapabilities>(htCapabilities);
1571}
1572
1573void
1574WifiRemoteStationManager::AddStationExtendedCapabilities(
1575 Mac48Address from,
1576 const ExtendedCapabilities& extendedCapabilities)
1577{
1578 NS_LOG_FUNCTION(this << from << extendedCapabilities);
1579 auto state = LookupState(from);
1580 state->m_extendedCapabilities = Create<const ExtendedCapabilities>(extendedCapabilities);
1581}
1582
1583void
1584WifiRemoteStationManager::AddStationVhtCapabilities(Mac48Address from,
1585 const VhtCapabilities& vhtCapabilities)
1586{
1587 // Used by all stations to record VHT capabilities of remote stations
1588 NS_LOG_FUNCTION(this << from << vhtCapabilities);
1589 auto state = LookupState(from);
1590 if (vhtCapabilities.GetSupportedChannelWidthSet() == 1)
1591 {
1592 state->m_channelWidth = MHz_u{160};
1593 }
1594 else
1595 {
1596 state->m_channelWidth = MHz_u{80};
1597 }
1598 for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams(); i++)
1599 {
1600 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_VHT))
1601 {
1602 if (vhtCapabilities.IsSupportedMcs(mcs.GetMcsValue(), i))
1603 {
1604 AddSupportedMcs(from, mcs);
1605 }
1606 }
1607 }
1608 state->m_vhtCapabilities = Create<const VhtCapabilities>(vhtCapabilities);
1609}
1610
1611void
1612WifiRemoteStationManager::AddStationHeCapabilities(Mac48Address from,
1613 const HeCapabilities& heCapabilities)
1614{
1615 // Used by all stations to record HE capabilities of remote stations
1616 NS_LOG_FUNCTION(this << from << heCapabilities);
1617 auto state = LookupState(from);
1618 if ((m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_5GHZ) ||
1619 (m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_6GHZ))
1620 {
1621 if (heCapabilities.GetChannelWidthSet() & 0x04)
1622 {
1623 state->m_channelWidth = MHz_u{160};
1624 }
1625 else if (heCapabilities.GetChannelWidthSet() & 0x02)
1626 {
1627 state->m_channelWidth = MHz_u{80};
1628 }
1629 // For other cases at 5 GHz, the supported channel width is set by the VHT capabilities
1630 }
1631 else if (m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_2_4GHZ)
1632 {
1633 if (heCapabilities.GetChannelWidthSet() & 0x01)
1634 {
1635 state->m_channelWidth = MHz_u{40};
1636 }
1637 else
1638 {
1639 state->m_channelWidth = MHz_u{20};
1640 }
1641 }
1642 if (heCapabilities.GetHeSuPpdu1xHeLtf800nsGi())
1643 {
1644 state->m_guardInterval = NanoSeconds(800);
1645 }
1646 else
1647 {
1648 // todo: Using 3200ns, default value for HeConfiguration::GuardInterval
1649 state->m_guardInterval = NanoSeconds(3200);
1650 }
1651 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_HE))
1652 {
1653 if (heCapabilities.GetHighestMcsSupported() >= mcs.GetMcsValue())
1654 {
1655 AddSupportedMcs(from, mcs);
1656 }
1657 }
1658 state->m_heCapabilities = Create<const HeCapabilities>(heCapabilities);
1659 SetQosSupport(from, true);
1660}
1661
1662void
1663WifiRemoteStationManager::AddStationHe6GhzCapabilities(
1664 const Mac48Address& from,
1665 const He6GhzBandCapabilities& he6GhzCapabilities)
1666{
1667 // Used by all stations to record HE 6GHz band capabilities of remote stations
1668 NS_LOG_FUNCTION(this << from << he6GhzCapabilities);
1669 auto state = LookupState(from);
1670 state->m_he6GhzBandCapabilities = Create<const He6GhzBandCapabilities>(he6GhzCapabilities);
1671 SetQosSupport(from, true);
1672}
1673
1674void
1675WifiRemoteStationManager::AddStationEhtCapabilities(Mac48Address from,
1676 const EhtCapabilities& ehtCapabilities)
1677{
1678 // Used by all stations to record EHT capabilities of remote stations
1679 NS_LOG_FUNCTION(this << from << ehtCapabilities);
1680 auto state = LookupState(from);
1681 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_EHT))
1682 {
1683 for (uint8_t mapType = 0; mapType < EhtMcsAndNssSet::EHT_MCS_MAP_TYPE_MAX; ++mapType)
1684 {
1685 if (ehtCapabilities.GetHighestSupportedRxMcs(
1686 static_cast<EhtMcsAndNssSet::EhtMcsMapType>(mapType)) >= mcs.GetMcsValue())
1687 {
1688 AddSupportedMcs(from, mcs);
1689 }
1690 }
1691 }
1692 state->m_ehtCapabilities = Create<const EhtCapabilities>(ehtCapabilities);
1693 SetQosSupport(from, true);
1694}
1695
1696void
1697WifiRemoteStationManager::AddStationMleCommonInfo(
1698 Mac48Address from,
1699 const std::shared_ptr<CommonInfoBasicMle>& mleCommonInfo)
1700{
1701 NS_LOG_FUNCTION(this << from);
1702 auto state = LookupState(from);
1703 state->m_mleCommonInfo = mleCommonInfo;
1704 // insert another entry in m_states indexed by the MLD address and pointing to the same state
1705 const_cast<WifiRemoteStationManager*>(this)->m_states.insert(
1706 {mleCommonInfo->m_mldMacAddress, state});
1707}
1708
1709Ptr<const HtCapabilities>
1710WifiRemoteStationManager::GetStationHtCapabilities(Mac48Address from)
1711{
1712 return LookupState(from)->m_htCapabilities;
1713}
1714
1716WifiRemoteStationManager::GetStationExtendedCapabilities(const Mac48Address& from)
1717{
1718 return LookupState(from)->m_extendedCapabilities;
1719}
1720
1722WifiRemoteStationManager::GetStationVhtCapabilities(Mac48Address from)
1723{
1724 return LookupState(from)->m_vhtCapabilities;
1725}
1726
1728WifiRemoteStationManager::GetStationHeCapabilities(Mac48Address from)
1729{
1730 return LookupState(from)->m_heCapabilities;
1731}
1732
1734WifiRemoteStationManager::GetStationHe6GhzCapabilities(const Mac48Address& from) const
1735{
1736 return LookupState(from)->m_he6GhzBandCapabilities;
1737}
1738
1740WifiRemoteStationManager::GetStationEhtCapabilities(Mac48Address from)
1741{
1742 return LookupState(from)->m_ehtCapabilities;
1743}
1744
1745std::optional<std::reference_wrapper<CommonInfoBasicMle::EmlCapabilities>>
1746WifiRemoteStationManager::GetStationEmlCapabilities(const Mac48Address& from)
1747{
1748 if (auto state = LookupState(from);
1749 state->m_mleCommonInfo && state->m_mleCommonInfo->m_emlCapabilities)
1750 {
1751 return state->m_mleCommonInfo->m_emlCapabilities.value();
1752 }
1753 return std::nullopt;
1754}
1755
1756std::optional<std::reference_wrapper<CommonInfoBasicMle::MldCapabilities>>
1757WifiRemoteStationManager::GetStationMldCapabilities(const Mac48Address& from)
1758{
1759 if (auto state = LookupState(from);
1760 state->m_mleCommonInfo && state->m_mleCommonInfo->m_mldCapabilities)
1761 {
1762 return state->m_mleCommonInfo->m_mldCapabilities.value();
1763 }
1764 return std::nullopt;
1765}
1766
1767bool
1768WifiRemoteStationManager::GetLdpcSupported(Mac48Address address) const
1769{
1770 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
1771 Ptr<const VhtCapabilities> vhtCapabilities = LookupState(address)->m_vhtCapabilities;
1772 Ptr<const HeCapabilities> heCapabilities = LookupState(address)->m_heCapabilities;
1773 bool supported = false;
1774 if (htCapabilities)
1775 {
1776 supported |= htCapabilities->GetLdpc();
1777 }
1778 if (vhtCapabilities)
1779 {
1780 supported |= vhtCapabilities->GetRxLdpc();
1781 }
1782 if (heCapabilities)
1783 {
1784 supported |= heCapabilities->GetLdpcCodingInPayload();
1785 }
1786 return supported;
1787}
1788
1790WifiRemoteStationManager::GetDefaultMode() const
1791{
1792 NS_ASSERT(m_wifiPhy);
1793 auto defaultTxMode = m_wifiPhy->GetDefaultMode();
1794 NS_ASSERT(defaultTxMode.IsMandatory());
1795 return defaultTxMode;
1796}
1797
1799WifiRemoteStationManager::GetDefaultMcs() const
1800{
1801 return HtPhy::GetHtMcs0();
1802}
1803
1805WifiRemoteStationManager::GetDefaultModeForSta(const WifiRemoteStation* st) const
1806{
1807 NS_LOG_FUNCTION(this << st);
1808
1809 if ((!m_wifiPhy->GetDevice()->GetHtConfiguration()) ||
1810 (!GetHtSupported(st) && !GetStationHe6GhzCapabilities(st->m_state->m_address)))
1811 {
1812 return GetDefaultMode();
1813 }
1814
1815 // find the highest modulation class supported by both stations
1817 if (GetHeSupported() && GetHeSupported(st))
1818 {
1819 modClass = WIFI_MOD_CLASS_HE;
1820 }
1821 else if (GetVhtSupported() && GetVhtSupported(st))
1822 {
1823 modClass = WIFI_MOD_CLASS_VHT;
1824 }
1825
1826 // return the MCS with lowest index
1827 return *m_wifiPhy->GetPhyEntity(modClass)->begin();
1828}
1829
1830void
1831WifiRemoteStationManager::Reset()
1832{
1833 NS_LOG_FUNCTION(this);
1834 m_states.clear();
1835 for (auto& state : m_stations)
1836 {
1837 delete (state.second);
1838 }
1839 m_stations.clear();
1840 m_bssBasicRateSet.clear();
1841 m_bssBasicMcsSet.clear();
1842 m_ssrc.fill(0);
1843 m_slrc.fill(0);
1844}
1845
1846void
1847WifiRemoteStationManager::AddBasicMode(WifiMode mode)
1848{
1849 NS_LOG_FUNCTION(this << mode);
1851 {
1852 NS_FATAL_ERROR("It is not allowed to add a HT rate in the BSSBasicRateSet!");
1853 }
1854 for (uint8_t i = 0; i < GetNBasicModes(); i++)
1855 {
1856 if (GetBasicMode(i) == mode)
1857 {
1858 return;
1859 }
1860 }
1861 m_bssBasicRateSet.push_back(mode);
1862}
1863
1864uint8_t
1865WifiRemoteStationManager::GetNBasicModes() const
1866{
1867 return static_cast<uint8_t>(m_bssBasicRateSet.size());
1868}
1869
1871WifiRemoteStationManager::GetBasicMode(uint8_t i) const
1872{
1873 NS_ASSERT(i < GetNBasicModes());
1874 return m_bssBasicRateSet[i];
1875}
1876
1878WifiRemoteStationManager::GetNNonErpBasicModes() const
1879{
1880 uint32_t size = 0;
1881 for (auto i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++)
1882 {
1883 if (i->GetModulationClass() == WIFI_MOD_CLASS_ERP_OFDM)
1884 {
1885 continue;
1886 }
1887 size++;
1888 }
1889 return size;
1890}
1891
1893WifiRemoteStationManager::GetNonErpBasicMode(uint8_t i) const
1894{
1895 NS_ASSERT(i < GetNNonErpBasicModes());
1896 uint32_t index = 0;
1897 bool found = false;
1898 for (auto j = m_bssBasicRateSet.begin(); j != m_bssBasicRateSet.end();)
1899 {
1900 if (i == index)
1901 {
1902 found = true;
1903 }
1904 if (j->GetModulationClass() != WIFI_MOD_CLASS_ERP_OFDM)
1905 {
1906 if (found)
1907 {
1908 break;
1909 }
1910 }
1911 index++;
1912 j++;
1913 }
1914 return m_bssBasicRateSet[index];
1915}
1916
1917void
1918WifiRemoteStationManager::AddBasicMcs(WifiMode mcs)
1919{
1920 NS_LOG_FUNCTION(this << +mcs.GetMcsValue());
1921 for (uint8_t i = 0; i < GetNBasicMcs(); i++)
1922 {
1923 if (GetBasicMcs(i) == mcs)
1924 {
1925 return;
1926 }
1927 }
1928 m_bssBasicMcsSet.push_back(mcs);
1929}
1930
1931uint8_t
1932WifiRemoteStationManager::GetNBasicMcs() const
1933{
1934 return static_cast<uint8_t>(m_bssBasicMcsSet.size());
1935}
1936
1938WifiRemoteStationManager::GetBasicMcs(uint8_t i) const
1939{
1940 NS_ASSERT(i < GetNBasicMcs());
1941 return m_bssBasicMcsSet[i];
1942}
1943
1945WifiRemoteStationManager::GetNonUnicastMode() const
1946{
1947 if (m_nonUnicastMode == WifiMode())
1948 {
1949 if (GetNBasicModes() > 0)
1950 {
1951 return GetBasicMode(0);
1952 }
1953 else
1954 {
1955 return GetDefaultMode();
1956 }
1957 }
1958 else
1959 {
1960 return m_nonUnicastMode;
1961 }
1962}
1963
1965WifiRemoteStationManager::GetGroupcastTxVector(const WifiMacHeader& header, MHz_u allowedWidth)
1966{
1967 const auto& to = header.GetAddr1();
1968 NS_ASSERT(to.IsGroup());
1969
1970 WifiTxVector groupcastTxVector{};
1971 const auto mode = GetNonUnicastMode();
1972 groupcastTxVector.SetMode(mode);
1973 groupcastTxVector.SetPreambleType(
1974 GetPreambleForTransmission(mode.GetModulationClass(), GetShortPreambleEnabled()));
1975 groupcastTxVector.SetTxPowerLevel(m_defaultTxPowerLevel);
1976 groupcastTxVector.SetChannelWidth(m_wifiPhy->GetTxBandwidth(mode, allowedWidth));
1977 groupcastTxVector.SetNTx(GetNumberOfAntennas());
1978
1979 if (to.IsBroadcast())
1980 {
1981 return groupcastTxVector;
1982 }
1983
1984 auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
1985 if (!apMac)
1986 {
1987 return groupcastTxVector;
1988 }
1989
1990 auto gcrManager = apMac->GetGcrManager();
1991 if (!gcrManager)
1992 {
1993 return groupcastTxVector;
1994 }
1995
1996 const auto& groupStas = gcrManager->GetMemberStasForGroupAddress(to);
1997 if (groupStas.empty())
1998 {
1999 return groupcastTxVector;
2000 }
2001
2002 if (!gcrManager->UseConcealment(header))
2003 {
2004 return groupcastTxVector;
2005 }
2006
2007 // If we are here, that means the mode will be used for the transmission of a groupcast frame
2008 // using the GCR service. We should loop over each member STA that is going to receive the
2009 // groupcast frame and select the highest possible mode over all STAs.
2010 std::optional<WifiMode> groupcastMode;
2011 auto maxWidth = allowedWidth;
2012 auto maxNss = m_wifiPhy->GetMaxSupportedTxSpatialStreams();
2013 std::map<WifiModulationClass, Time> minGisPerMc{/* non-HT OFDM is always 800 ns */
2016 const std::map<WifiModulationClass, WifiModulationClass> giRefModClass{
2017 /* HT/VHT: short or long GI */
2020 /* HE/EHT: 3 possible GIs */
2023 for (const auto& staAddress : groupStas)
2024 {
2025 // Get the equivalent TXVECTOR if the frame would be a unicast frame to that STA in order to
2026 // get what rate would be selected for that STA.
2028 hdr.SetAddr1(staAddress);
2029 const auto unicastTxVector = GetDataTxVector(hdr, allowedWidth);
2030
2031 // update the groupcast mode if:
2032 // - this is the first mode to inspect;
2033 // - this mode has a lower modulation class than the currently selected groupcast mode;
2034 // - when the modulation class is similar, this mode has a lower MCS than the currently
2035 // selected groupcast mode.
2036 if (!groupcastMode.has_value() ||
2037 (unicastTxVector.GetModulationClass() < groupcastMode->GetModulationClass()) ||
2038 ((unicastTxVector.GetModulationClass() == groupcastMode->GetModulationClass()) &&
2039 (unicastTxVector.GetMode().GetMcsValue() < groupcastMode->GetMcsValue())))
2040 {
2041 groupcastMode = unicastTxVector.GetMode();
2042 }
2043 maxWidth = std::min(unicastTxVector.GetChannelWidth(), maxWidth);
2044 maxNss = std::min(unicastTxVector.GetNss(), maxNss);
2045 auto mc = unicastTxVector.GetModulationClass();
2046 if (const auto it = giRefModClass.find(mc); it != giRefModClass.cend())
2047 {
2048 mc = it->second;
2049 }
2050 if (auto it = minGisPerMc.find(mc); it != minGisPerMc.end())
2051 {
2052 it->second = std::max(unicastTxVector.GetGuardInterval(), it->second);
2053 }
2054 }
2055 NS_ASSERT(groupcastMode.has_value());
2056
2057 groupcastTxVector.SetMode(*groupcastMode);
2058 groupcastTxVector.SetPreambleType(
2059 GetPreambleForTransmission(groupcastMode->GetModulationClass(), GetShortPreambleEnabled()));
2060 groupcastTxVector.SetChannelWidth(maxWidth);
2061 groupcastTxVector.SetNss(maxNss);
2062 auto mc = groupcastMode->GetModulationClass();
2063 if (const auto it = giRefModClass.find(mc); it != giRefModClass.cend())
2064 {
2065 mc = it->second;
2066 }
2067 if (const auto it = minGisPerMc.find(mc); it != minGisPerMc.cend())
2068 {
2069 groupcastTxVector.SetGuardInterval(it->second);
2070 }
2071
2072 return groupcastTxVector;
2073}
2074
2075bool
2076WifiRemoteStationManager::DoNeedRts(WifiRemoteStation* station, uint32_t size, bool normally)
2077{
2078 return normally;
2079}
2080
2081bool
2082WifiRemoteStationManager::DoNeedFragmentation(WifiRemoteStation* station,
2083 Ptr<const Packet> packet,
2084 bool normally)
2085{
2086 return normally;
2087}
2088
2089void
2090WifiRemoteStationManager::DoReportAmpduTxStatus(WifiRemoteStation* station,
2091 uint16_t nSuccessfulMpdus,
2092 uint16_t nFailedMpdus,
2093 double rxSnr,
2094 double dataSnr,
2095 MHz_u dataChannelWidth,
2096 uint8_t dataNss)
2097{
2098 NS_LOG_DEBUG("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
2099}
2100
2102WifiRemoteStationManager::GetSupported(const WifiRemoteStation* station, uint8_t i) const
2103{
2104 NS_ASSERT(i < GetNSupported(station));
2105 return station->m_state->m_operationalRateSet[i];
2106}
2107
2109WifiRemoteStationManager::GetMcsSupported(const WifiRemoteStation* station, uint8_t i) const
2110{
2111 NS_ASSERT(i < GetNMcsSupported(station));
2112 return station->m_state->m_operationalMcsSet[i];
2113}
2114
2116WifiRemoteStationManager::GetNonErpSupported(const WifiRemoteStation* station, uint8_t i) const
2117{
2118 NS_ASSERT(i < GetNNonErpSupported(station));
2119 // IEEE 802.11g standard defines that if the protection mechanism is enabled, RTS, CTS and
2120 // CTS-To-Self frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b
2121 // basic rate. This is a implemented here to avoid changes in every RAA, but should maybe be
2122 // moved in case it breaks standard rules.
2123 uint32_t index = 0;
2124 bool found = false;
2125 for (auto j = station->m_state->m_operationalRateSet.begin();
2126 j != station->m_state->m_operationalRateSet.end();)
2127 {
2128 if (i == index)
2129 {
2130 found = true;
2131 }
2132 if (j->GetModulationClass() != WIFI_MOD_CLASS_ERP_OFDM)
2133 {
2134 if (found)
2135 {
2136 break;
2137 }
2138 }
2139 index++;
2140 j++;
2141 }
2142 return station->m_state->m_operationalRateSet[index];
2143}
2144
2146WifiRemoteStationManager::GetAddress(const WifiRemoteStation* station) const
2147{
2148 return station->m_state->m_address;
2149}
2150
2151MHz_u
2152WifiRemoteStationManager::GetChannelWidth(const WifiRemoteStation* station) const
2153{
2154 return station->m_state->m_channelWidth;
2155}
2156
2157bool
2158WifiRemoteStationManager::GetShortGuardIntervalSupported(const WifiRemoteStation* station) const
2159{
2160 Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
2161
2162 if (!htCapabilities)
2163 {
2164 return false;
2165 }
2166 return htCapabilities->GetShortGuardInterval20();
2167}
2168
2169Time
2170WifiRemoteStationManager::GetGuardInterval(const WifiRemoteStation* station) const
2171{
2172 return station->m_state->m_guardInterval;
2173}
2174
2175bool
2176WifiRemoteStationManager::GetAggregation(const WifiRemoteStation* station) const
2177{
2178 return station->m_state->m_aggregation;
2179}
2180
2181uint8_t
2182WifiRemoteStationManager::GetNumberOfSupportedStreams(const WifiRemoteStation* station) const
2183{
2184 const auto htCapabilities = station->m_state->m_htCapabilities;
2185
2186 if (!htCapabilities)
2187 {
2188 if (const auto heCapabilities = station->m_state->m_heCapabilities)
2189 {
2190 return heCapabilities->GetHighestNssSupported();
2191 }
2192 return 1;
2193 }
2194 return htCapabilities->GetRxHighestSupportedAntennas();
2195}
2196
2197uint8_t
2198WifiRemoteStationManager::GetNess(const WifiRemoteStation* station) const
2199{
2200 return station->m_state->m_ness;
2201}
2202
2204WifiRemoteStationManager::GetPhy() const
2205{
2206 return m_wifiPhy;
2207}
2208
2210WifiRemoteStationManager::GetMac() const
2211{
2212 return m_wifiMac;
2213}
2214
2215uint8_t
2216WifiRemoteStationManager::GetNSupported(const WifiRemoteStation* station) const
2217{
2218 return static_cast<uint8_t>(station->m_state->m_operationalRateSet.size());
2219}
2220
2221bool
2222WifiRemoteStationManager::GetQosSupported(const WifiRemoteStation* station) const
2223{
2224 return station->m_state->m_qosSupported;
2225}
2226
2227bool
2228WifiRemoteStationManager::GetHtSupported(const WifiRemoteStation* station) const
2229{
2230 return bool(station->m_state->m_htCapabilities);
2231}
2232
2233bool
2234WifiRemoteStationManager::GetVhtSupported(const WifiRemoteStation* station) const
2235{
2236 return bool(station->m_state->m_vhtCapabilities);
2237}
2238
2239bool
2240WifiRemoteStationManager::GetHeSupported(const WifiRemoteStation* station) const
2241{
2242 return bool(station->m_state->m_heCapabilities);
2243}
2244
2245bool
2246WifiRemoteStationManager::GetEhtSupported(const WifiRemoteStation* station) const
2247{
2248 return (bool)(station->m_state->m_ehtCapabilities);
2249}
2250
2251bool
2252WifiRemoteStationManager::GetEmlsrSupported(const WifiRemoteStation* station) const
2253{
2254 auto mleCommonInfo = station->m_state->m_mleCommonInfo;
2255 return mleCommonInfo && mleCommonInfo->m_emlCapabilities &&
2256 mleCommonInfo->m_emlCapabilities->emlsrSupport == 1;
2257}
2258
2259bool
2260WifiRemoteStationManager::GetEmlsrEnabled(const WifiRemoteStation* station) const
2261{
2262 return station->m_state->m_emlsrEnabled;
2263}
2264
2265uint8_t
2266WifiRemoteStationManager::GetNMcsSupported(const WifiRemoteStation* station) const
2267{
2268 return static_cast<uint8_t>(station->m_state->m_operationalMcsSet.size());
2269}
2270
2272WifiRemoteStationManager::GetNNonErpSupported(const WifiRemoteStation* station) const
2273{
2274 uint32_t size = 0;
2275 for (auto i = station->m_state->m_operationalRateSet.begin();
2276 i != station->m_state->m_operationalRateSet.end();
2277 i++)
2278 {
2279 if (i->GetModulationClass() == WIFI_MOD_CLASS_ERP_OFDM)
2280 {
2281 continue;
2282 }
2283 size++;
2284 }
2285 return size;
2286}
2287
2288MHz_u
2289WifiRemoteStationManager::GetChannelWidthSupported(Mac48Address address) const
2290{
2291 return LookupState(address)->m_channelWidth;
2292}
2293
2294bool
2295WifiRemoteStationManager::GetShortGuardIntervalSupported(Mac48Address address) const
2296{
2297 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
2298
2299 if (!htCapabilities)
2300 {
2301 return false;
2302 }
2303 return htCapabilities->GetShortGuardInterval20();
2304}
2305
2306uint8_t
2307WifiRemoteStationManager::GetNumberOfSupportedStreams(Mac48Address address) const
2308{
2309 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
2310
2311 if (!htCapabilities)
2312 {
2313 return 1;
2314 }
2315 return htCapabilities->GetRxHighestSupportedAntennas();
2316}
2317
2318uint8_t
2319WifiRemoteStationManager::GetNMcsSupported(Mac48Address address) const
2320{
2321 return static_cast<uint8_t>(LookupState(address)->m_operationalMcsSet.size());
2322}
2323
2324bool
2325WifiRemoteStationManager::GetDsssSupported(const Mac48Address& address) const
2326{
2327 return (LookupState(address)->m_dsssSupported);
2328}
2329
2330bool
2331WifiRemoteStationManager::GetErpOfdmSupported(const Mac48Address& address) const
2332{
2333 return (LookupState(address)->m_erpOfdmSupported);
2334}
2335
2336bool
2337WifiRemoteStationManager::GetOfdmSupported(const Mac48Address& address) const
2338{
2339 return (LookupState(address)->m_ofdmSupported);
2340}
2341
2342bool
2343WifiRemoteStationManager::GetHtSupported(Mac48Address address) const
2344{
2345 return bool(LookupState(address)->m_htCapabilities);
2346}
2347
2348bool
2349WifiRemoteStationManager::GetVhtSupported(Mac48Address address) const
2350{
2351 return bool(LookupState(address)->m_vhtCapabilities);
2352}
2353
2354bool
2355WifiRemoteStationManager::GetHeSupported(Mac48Address address) const
2356{
2357 return bool(LookupState(address)->m_heCapabilities);
2358}
2359
2360bool
2361WifiRemoteStationManager::GetEhtSupported(Mac48Address address) const
2362{
2363 return (bool)(LookupState(address)->m_ehtCapabilities);
2364}
2365
2366bool
2367WifiRemoteStationManager::GetEmlsrSupported(const Mac48Address& address) const
2368{
2369 auto mleCommonInfo = LookupState(address)->m_mleCommonInfo;
2370 return mleCommonInfo && mleCommonInfo->m_emlCapabilities &&
2371 mleCommonInfo->m_emlCapabilities->emlsrSupport == 1;
2372}
2373
2374bool
2375WifiRemoteStationManager::GetEmlsrEnabled(const Mac48Address& address) const
2376{
2377 if (auto stateIt = m_states.find(address); stateIt != m_states.cend())
2378 {
2379 return stateIt->second->m_emlsrEnabled;
2380 }
2381 return false;
2382}
2383
2384void
2385WifiRemoteStationManager::SetDefaultTxPowerLevel(uint8_t txPower)
2386{
2387 m_defaultTxPowerLevel = txPower;
2388}
2389
2390uint8_t
2391WifiRemoteStationManager::GetNumberOfAntennas() const
2392{
2393 return m_wifiPhy->GetNumberOfAntennas();
2394}
2395
2396uint8_t
2397WifiRemoteStationManager::GetMaxNumberOfTransmitStreams() const
2398{
2399 return m_wifiPhy->GetMaxSupportedTxSpatialStreams();
2400}
2401
2402bool
2403WifiRemoteStationManager::UseLdpcForDestination(Mac48Address dest) const
2404{
2405 return (GetLdpcSupported() && GetLdpcSupported(dest));
2406}
2407
2408} // namespace ns3
AttributeValue implementation for Boolean.
Definition boolean.h:26
The IEEE 802.11be EHT Capabilities.
uint8_t GetHighestSupportedRxMcs(EhtMcsAndNssSet::EhtMcsMapType mapType) const
Get the highest supported RX MCS for a given EHT-MCS map type.
Hold variables of type enum.
Definition enum.h:52
T Get() const
Definition enum.h:87
static WifiMode GetErpOfdmRate(uint64_t rate)
Return a WifiMode for ERP-OFDM corresponding to the provided rate.
static WifiMode GetErpOfdmRate6Mbps()
Return a WifiMode for ERP-OFDM at 6 Mbps.
The Extended Capabilities Information Element.
The HE 6 GHz Band Capabilities (IEEE 802.11ax-2021 9.4.2.263)
The IEEE 802.11ax HE Capabilities.
uint8_t GetHighestMcsSupported() const
Get highest MCS supported.
bool GetHeSuPpdu1xHeLtf800nsGi() const
Get 1xHE-LTF and 800ns GI in HE SU PPDU reception support.
uint8_t GetChannelWidthSet() const
Get channel width set.
The HT Capabilities Information Element.
uint8_t GetSupportedChannelWidth() const
Return the supported channel width.
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
an EUI-48 address
bool IsGroup() const
A base class which provides memory management and object aggregation.
Definition object.h:78
static WifiMode GetOfdmRate(uint64_t rate, MHz_u bw=MHz_u{20})
Return a WifiMode for OFDM corresponding to the provided rate and the channel bandwidth (20,...
Definition ofdm-phy.cc:404
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
Definition nstime.h:340
AttributeValue implementation for Time.
Definition nstime.h:1431
a unique identifier for an interface.
Definition type-id.h:49
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
@ OBSOLETE
Attribute or trace source is not used anymore; simulation fails.
Hold an unsigned integer type.
Definition uinteger.h:34
The IEEE 802.11ac VHT Capabilities.
bool IsSupportedMcs(uint8_t mcs, uint8_t nss) const
Get the is MCS supported.
uint8_t GetSupportedChannelWidthSet() const
Get the supported channel width set.
Implements the IEEE 802.11 MAC header.
uint8_t GetQosTid() const
Return the Traffic ID of a QoS header.
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
bool IsMgt() const
Return true if the Type is Management.
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
bool IsQosData() const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
represent a single transmission mode
Definition wifi-mode.h:40
bool IsHigherDataRate(WifiMode mode) const
Definition wifi-mode.cc:197
WifiModulationClass GetModulationClass() const
Definition wifi-mode.cc:174
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
Definition wifi-mode.cc:111
uint8_t GetMcsValue() const
Definition wifi-mode.cc:152
AttributeValue implementation for WifiMode.
Definition wifi-mode.h:243
MHz_u GetTxBandwidth(WifiMode mode, MHz_u maxAllowedBandWidth=MHz_u{ std::numeric_limits< double >::max()}) const
Get the bandwidth for a transmission occurring on the current operating channel and using the given W...
Definition wifi-phy.cc:1123
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Definition wifi-phy.cc:1069
MHz_u GetChannelWidth() const
Definition wifi-phy.cc:1099
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
Definition wifi-phy.cc:647
std::list< WifiMode > GetMcsList() const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
Definition wifi-phy.cc:2113
std::list< WifiMode > GetModeList() const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition wifi-phy.cc:2064
TID independent remote station statistics.
void NotifyTxSuccess(uint32_t retryCounter)
Updates average frame error rate when data or RTS was transmitted successfully.
void NotifyTxFailed()
Updates average frame error rate when final data or RTS has failed.
hold a list of per-remote-station state.
void ReportDataFailed(Ptr< const WifiMpdu > mpdu)
Should be invoked whenever the AckTimeout associated to a transmission attempt expires.
bool GetQosSupported(Mac48Address address) const
Return whether the given station is QoS capable.
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, MHz_u allowedWidth)=0
WifiTxVector GetAckTxVector(Mac48Address to, const WifiTxVector &dataTxVector) const
Return a TXVECTOR for the Ack frame given the destination and the mode of the Data used by the sender...
virtual bool DoNeedFragmentation(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
uint32_t m_fragmentationThreshold
Current threshold for fragmentation.
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
void SetPsMode(const Mac48Address &address, bool isInPsMode)
Register whether the STA is in Power Save mode or not.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
uint32_t GetNFragments(Ptr< const WifiMpdu > mpdu)
Return the number of fragments needed for the given packet.
uint16_t GetAssociationId(Mac48Address remoteAddress) const
Get the AID of a remote station.
virtual void DoIncrementRetryCountOnTxFailure(WifiRemoteStation *station, Ptr< WifiPsdu > psdu)
Increment the retry count (if needed) for the given PSDU, whose transmission failed.
ProtectionMode m_htProtectionMode
Protection mode for HT stations when non-HT stations are detected.
void AdjustTxVectorForIcf(WifiTxVector &txVector) const
Adjust the TXVECTOR for an initial Control frame to ensure that the modulation class is non-HT and th...
std::array< uint32_t, AC_BE_NQOS > m_slrc
long retry count per AC
WifiRemoteStation * Lookup(Mac48Address address) const
Return the station associated with the given address.
uint32_t GetFragmentationThreshold() const
Return the fragmentation threshold.
uint8_t GetNBasicModes() const
Return the number of basic modes we support.
bool UseLdpcForDestination(Mac48Address dest) const
uint32_t m_maxSsrc
Maximum STA short retry count (SSRC)
void SetRtsCtsThreshold(uint32_t threshold)
Sets the RTS threshold.
void AddAllSupportedMcs(Mac48Address address)
Invoked in a STA or AP to store all of the MCS supported by a destination which is also supported loc...
TracedCallback< Mac48Address > m_macTxRtsFailed
The trace source fired when the transmission of a single RTS has failed.
virtual bool DoNeedRts(WifiRemoteStation *station, uint32_t size, bool normally)
Time GetGuardInterval() const
Return the shortest supported HE guard interval duration.
WifiTxVector GetRtsTxVector(Mac48Address address, MHz_u allowedWidth)
void DoSetFragmentationThreshold(uint32_t threshold)
Actually sets the fragmentation threshold, it also checks the validity of the given threshold.
bool IsBrandNew(Mac48Address address) const
Return whether the station state is brand new.
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
virtual void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)=0
This method is a pure virtual method that must be implemented by the sub-class.
Time m_rtsCtsTxDurationThresh
TX duration threshold for RTS/CTS.
bool GetShortSlotTimeEnabled() const
Return whether the device uses short slot time.
void DoDispose() override
Destructor implementation.
virtual void DoReportDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
bool IsLastFragment(Ptr< const WifiMpdu > mpdu, uint32_t fragmentNumber)
void ReportFinalDataFailed(Ptr< const WifiMpdu > mpdu)
Should be invoked after calling ReportDataFailed if frames are dropped.
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
bool m_useNonHtProtection
flag if protection for non-HT stations against HT transmissions is enabled
bool GetShortPreambleSupported(Mac48Address address) const
Return whether the station supports short PHY preamble or not.
void AddAllSupportedModes(Mac48Address address)
Invoked in a STA or AP to store all of the modes supported by a destination which is also supported l...
virtual void DoReportAmpduTxStatus(WifiRemoteStation *station, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus, double rxSnr, double dataSnr, MHz_u dataChannelWidth, uint8_t dataNss)
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
std::optional< Mac48Address > GetAffiliatedStaAddress(const Mac48Address &mldAddress) const
Get the address of the remote station operating on this link and affiliated with the MLD having the g...
std::list< Ptr< WifiMpdu > > GetMpdusToDropOnTxFailure(Ptr< WifiPsdu > psdu)
Increment the retry count for all the MPDUs (if needed) in the given PSDU and find the MPDUs to drop ...
WifiTxVector GetDataTxVector(const WifiMacHeader &header, MHz_u allowedWidth)
std::optional< dBm_u > GetMostRecentRssi(Mac48Address address) const
void ReportRtsOk(const WifiMacHeader &header, double ctsSnr, WifiMode ctsMode, double rtsSnr)
Should be invoked whenever we receive the CTS associated to an RTS we just sent.
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
WifiTxVector GetBlockAckTxVector(Mac48Address to, const WifiTxVector &dataTxVector) const
Return a TXVECTOR for the BlockAck frame given the destination and the mode of the Data used by the s...
void RemoveAllSupportedMcs(Mac48Address address)
Invoked in a STA or AP to delete all of the supported MCS by a destination.
void ReportRxOk(Mac48Address address, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector)
uint32_t DoGetFragmentationThreshold() const
Return the current fragmentation threshold.
TracedCallback< Mac48Address > m_macTxFinalRtsFailed
The trace source fired when the transmission of a RTS has exceeded the maximum number of attempts.
WifiMode GetNonUnicastMode() const
Return a mode for non-unicast packets.
bool m_shortPreambleEnabled
flag if short PHY preamble is enabled
WifiTxVector GetGroupcastTxVector(const WifiMacHeader &header, MHz_u allowedWidth)
Return the TXVECTOR to use for a groupcast packet.
bool GetShortSlotTimeSupported(Mac48Address address) const
Return whether the station supports short ERP slot time or not.
void SetShortPreambleEnabled(bool enable)
Enable or disable short PHY preambles.
WifiMode GetDefaultMcs() const
Return the default Modulation and Coding Scheme (MCS) index.
Ptr< WifiPhy > m_wifiPhy
This is a pointer to the WifiPhy associated with this WifiRemoteStationManager that is set on call to...
uint8_t m_defaultTxPowerLevel
Default transmission power level.
static TypeId GetTypeId()
Get the type ID.
WifiMode m_nonUnicastMode
Transmission mode for non-unicast Data frames.
void SetUseNonHtProtection(bool enable)
Enable or disable protection for non-HT stations.
MHz_u GetChannelWidthSupported(Mac48Address address) const
Return the channel width supported by the station.
bool IsAssociated(Mac48Address address) const
Return whether the station associated.
bool NeedFragmentation(Ptr< const WifiMpdu > mpdu)
void ReportAmpduTxStatus(Mac48Address address, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus, double rxSnr, double dataSnr, WifiTxVector dataTxVector)
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
uint32_t GetFragmentOffset(Ptr< const WifiMpdu > mpdu, uint32_t fragmentNumber)
WifiRemoteStationInfo GetInfo(Mac48Address address)
uint32_t GetFragmentSize(Ptr< const WifiMpdu > mpdu, uint32_t fragmentNumber)
WifiTxVector GetCtsToSelfTxVector()
Since CTS-to-self parameters are not dependent on the station, it is implemented in wifi remote stati...
uint8_t GetNBasicMcs() const
Return the number of basic MCS index.
bool GetHtSupported() const
Return whether the device has HT capability support enabled on the link this manager is associated wi...
void RecordWaitAssocTxOk(Mac48Address address)
Records that we are waiting for an ACK for the association response we sent.
void SetFragmentationThreshold(uint32_t threshold)
Sets a fragmentation threshold.
Ptr< WifiMac > m_wifiMac
This is a pointer to the WifiMac associated with this WifiRemoteStationManager that is set on call to...
void RecordGotAssocTxOk(Mac48Address address)
Records that we got an ACK for the association response we sent.
bool GetLdpcSupported() const
Return whether the device has LDPC support enabled.
bool GetEhtSupported() const
Return whether the device has EHT capability support enabled.
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...
std::shared_ptr< WifiRemoteStationState > LookupState(Mac48Address address) const
Return the state of the station associated with the given address.
bool m_incrRetryCountUnderBa
whether to increment the retry count of frames that are part of a Block Ack agreement
std::array< uint32_t, AC_BE_NQOS > m_ssrc
short retry count per AC
virtual std::list< Ptr< WifiMpdu > > DoGetMpdusToDropOnTxFailure(WifiRemoteStation *station, Ptr< WifiPsdu > psdu)
Find the MPDUs to drop (possibly based on their frame retry count) in the given PSDU,...
void RecordAssocRefused(Mac48Address address)
Records that association request was refused.
bool IsInPsMode(const Mac48Address &address) const
Return whether the STA is currently in Power Save mode.
void ReportFinalRtsFailed(const WifiMacHeader &header)
Should be invoked after calling ReportRtsFailed if frames are dropped.
StationStates m_states
States of known stations.
WifiTxVector GetCtsTxVector(Mac48Address to, WifiMode rtsTxMode) const
Return a TXVECTOR for the CTS frame given the destination and the mode of the RTS used by the sender.
bool NeedCtsToSelf(const WifiTxVector &txVector, const WifiMacHeader &header)
Return if we need to do CTS-to-self before sending a DATA.
void SetMaxSsrc(uint32_t maxSsrc)
Sets the maximum STA short retry count (SSRC).
WifiMode GetBasicMcs(uint8_t i) const
Return the MCS at the given list index.
TracedCallback< Mac48Address > m_macTxDataFailed
The trace source fired when the transmission of a single data packet has failed.
uint16_t GetStaId(Mac48Address address, const WifiTxVector &txVector) const
If the given TXVECTOR is used for a MU transmission, return the STAID of the station with the given a...
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr, MHz_u dataChannelWidth, uint8_t dataNss)=0
This method is a pure virtual method that must be implemented by the sub-class.
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
void AddSupportedPhyPreamble(Mac48Address address, bool isShortPreambleSupported)
Record whether the short PHY preamble is supported by the station.
bool GetShortGuardIntervalSupported() const
Return whether the device has SGI support enabled.
virtual void SetupPhy(const Ptr< WifiPhy > phy)
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
virtual void DoReportRtsFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)=0
uint32_t m_maxSlrc
Maximum STA long retry count (SLRC)
void Reset()
Reset the station, invoked in a STA upon dis-association or in an AP upon reboot.
bool GetUseNonErpProtection() const
Return whether the device supports protection of non-ERP stations.
bool IsAssocRefused(Mac48Address address) const
Return whether we refused an association request from the given station.
bool GetVhtSupported() const
Return whether the device has VHT capability support enabled on the link this manager is associated w...
ProtectionMode m_erpProtectionMode
Protection mode for ERP stations when non-ERP stations are detected.
void ReportDataOk(Ptr< const WifiMpdu > mpdu, double ackSnr, WifiMode ackMode, double dataSnr, WifiTxVector dataTxVector)
Should be invoked whenever we receive the ACK associated to a data packet we just sent.
void ReportRtsFailed(const WifiMacHeader &header)
Should be invoked whenever the RtsTimeout associated to a transmission attempt expires.
void AddSupportedErpSlotTime(Mac48Address address, bool isShortSlotTimeSupported)
Record whether the short ERP slot time is supported by the station.
bool GetShortPreambleEnabled() const
Return whether the device uses short PHY preambles.
uint8_t m_linkId
the ID of the link this object is associated with
bool GetHeSupported() const
Return whether the device has HE capability support enabled.
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)=0
This method is a pure virtual method that must be implemented by the sub-class.
WifiMode GetDefaultMode() const
Return the default transmission mode.
void RecordGotAssocTxFailed(Mac48Address address)
Records that we missed an ACK for the association response we sent.
std::optional< Mac48Address > GetMldAddress(const Mac48Address &address) const
Get the address of the MLD the given station is affiliated with, if any.
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
virtual void SetupMac(const Ptr< WifiMac > mac)
Set up MAC associated with this device since it is the object that knows the full set of timing param...
void SetLinkId(uint8_t linkId)
Set the ID of the link this Remote Station Manager is associated with.
bool NeedRts(const WifiMacHeader &header, const WifiTxParameters &txParams)
uint32_t m_rtsCtsThreshold
Threshold for RTS/CTS.
bool m_useNonErpProtection
flag if protection for non-ERP stations against ERP transmissions is enabled
WifiMode GetControlAnswerMode(WifiMode reqMode) const
Get control answer mode function.
bool m_shortSlotTimeEnabled
flag if short slot time is enabled
bool IsWaitAssocTxOk(Mac48Address address) const
Return whether we are waiting for an ACK for the association response we sent.
void SetMaxSlrc(uint32_t maxSlrc)
Sets the maximum STA long retry count (SLRC).
TracedCallback< Mac48Address > m_macTxFinalDataFailed
The trace source fired when the transmission of a data packet has exceeded the maximum number of atte...
bool GetUseNonHtProtection() const
Return whether the device supports protection of non-HT stations.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
std::optional< Time > m_txDuration
TX duration of the frame.
uint32_t GetSize(Mac48Address receiver) const
Get the size in bytes of the (A-)MPDU addressed to the given receiver.
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetNess(uint8_t ness)
Sets the Ness number.
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
void SetLdpc(bool ldpc)
Sets if LDPC FEC coding is being used.
void SetGuardInterval(Time guardInterval)
Sets the guard interval duration (in nanoseconds)
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
void SetChannelWidth(MHz_u channelWidth)
Sets the selected channelWidth.
WifiModulationClass GetModulationClass() const
Get the modulation class specified by this TXVECTOR.
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
MHz_u GetChannelWidth() const
void SetBssColor(uint8_t color)
Set the BSS color.
void SetNTx(uint8_t nTx)
Sets the number of TX antennas.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void SetNss(uint8_t nss)
Sets the number of Nss.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition boolean.cc:113
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition boolean.h:70
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition enum.h:221
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition nstime.h:1432
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1452
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition uinteger.h:35
Ptr< const AttributeAccessor > MakeWifiModeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition wifi-mode.h:243
Ptr< const AttributeChecker > MakeWifiModeChecker()
Definition wifi-mode.cc:252
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition log.h:250
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1380
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Definition qos-utils.cc:123
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition qos-utils.h:62
@ STA
Definition wifi-mac.h:59
@ AP
Definition wifi-mac.h:60
@ WIFI_PREAMBLE_LONG
@ WIFI_PREAMBLE_EHT_MU
@ WIFI_PREAMBLE_HE_SU
@ WIFI_PREAMBLE_VHT_SU
@ WIFI_PREAMBLE_HT_MF
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
@ 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)
@ WIFI_MOD_CLASS_DSSS
DSSS (Clause 15)
@ WIFI_MOD_CLASS_ERP_OFDM
ERP-OFDM (18.4)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Definition ptr.h:443
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octets of the IEEE 802.11 MAC FCS field.
Time GetGuardIntervalForMode(WifiMode mode, const Ptr< WifiNetDevice > device)
Get the guard interval for a given WifiMode.
bool IsAllowedControlAnswerModulationClass(WifiModulationClass modClassReq, WifiModulationClass modClassAnswer)
Return whether the modulation class of the selected mode for the control answer frame is allowed.
double MHz_u
MHz weak type.
Definition wifi-units.h:31
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition enum.h:179
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580
@ WIFI_MAC_QOSDATA
@ CTS_TO_SELF
Definition gcr-manager.h:40
@ RTS_CTS
Definition gcr-manager.h:39
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:587
std::vector< WifiMode > WifiModeList
In various parts of the code, folk are interested in maintaining a list of transmission modes.
Definition wifi-mode.h:251
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
Definition wifi-mode.h:24
bool IsGcr(Ptr< WifiMac > mac, const WifiMacHeader &hdr)
Return whether a given packet is transmitted using the GCR service.
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
Mac48Address GetIndividuallyAddressedRecipient(Ptr< WifiMac > mac, const WifiMacHeader &hdr)
Get the MAC address of the individually addressed recipient to use for a given packet.
EhtMcsMapType
The different EHT-MCS map types as defined in 9.4.2.313.4 Supported EHT-MCS And NSS Set field.
RxSignalInfo structure containing info on the received signal.
Definition wifi-types.h:72
double snr
SNR in linear scale.
Definition wifi-types.h:73
dBm_u rssi
RSSI.
Definition wifi-types.h:74
hold per-remote-station state.
WifiRemoteStationState * m_state
Remote station state.
std::pair< dBm_u, Time > m_rssiAndUpdateTimePair
RSSI of the most recent packet received from the remote station along with update time.
std::shared_ptr< CommonInfoBasicMle > m_mleCommonInfo
remote station Multi-Link Element Common Info
Mac48Address m_address
Mac48Address of the remote station.
MHz_u m_channelWidth
Channel width supported by the remote station.
uint8_t m_ness
Number of extended spatial streams of the remote station.
bool m_aggregation
Flag if MPDU aggregation is used by the remote station.
bool m_qosSupported
Flag if QoS is supported by the station.
WifiModeList m_operationalRateSet
This member is the list of WifiMode objects that comprise the OperationalRateSet parameter for this r...
WifiModeList m_operationalMcsSet
operational MCS set
Ptr< const EhtCapabilities > m_ehtCapabilities
remote station EHT capabilities
Ptr< const VhtCapabilities > m_vhtCapabilities
remote station VHT capabilities
WifiRemoteStationInfo m_info
remote station info
bool m_emlsrEnabled
whether EMLSR mode is enabled on this link
Ptr< const HtCapabilities > m_htCapabilities
remote station HT capabilities
Time m_guardInterval
HE Guard interval durationsupported by the remote station.
Ptr< const HeCapabilities > m_heCapabilities
remote station HE capabilities