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 // NS_DEPRECATED_3_44
49 .AddAttribute("MaxSsrc",
50 "The maximum number of retransmission attempts for any packet with size "
51 "<= RtsCtsThreshold. "
52 "This value will not have any effect on some rate control algorithms.",
57 "Use WifiMac::FrameRetryLimit instead")
58 // NS_DEPRECATED_3_44
59 .AddAttribute("MaxSlrc",
60 "The maximum number of retransmission attempts for any packet with size "
61 "> RtsCtsThreshold. "
62 "This value will not have any effect on some rate control algorithms.",
67 "Use WifiMac::FrameRetryLimit instead")
68 .AddAttribute(
69 "IncrementRetryCountUnderBa",
70 "The 802.11-2020 standard states that the retry count for frames that are part of "
71 "a Block Ack agreement shall not be incremented when a transmission fails. As a "
72 "consequence, frames that are part of a Block Ack agreement are not dropped based "
73 "on the number of retries. Set this attribute to true to override the standard "
74 "behavior and increment the retry count (and eventually drop) frames that are "
75 "part of a Block Ack agreement.",
76 BooleanValue(false),
79 .AddAttribute("RtsCtsThreshold",
80 "If the size of the PSDU is bigger than this value, we use an RTS/CTS "
81 "handshake before sending the data frame."
82 "This value will not have any effect on some rate control algorithms.",
83 UintegerValue(4692480),
86 .AddAttribute("RtsCtsTxDurationThresh",
87 "If this threshold is a strictly positive value and the TX duration of "
88 "the PSDU is greater than or equal to this threshold, we use an RTS/CTS "
89 "handshake before sending the data frame.",
90 TimeValue(Time{0}),
93 .AddAttribute(
94 "FragmentationThreshold",
95 "If the size of the PSDU is bigger than this value, we fragment it such that the "
96 "size of the fragments are equal or smaller. "
97 "This value does not apply when it is carried in an A-MPDU. "
98 "This value will not have any effect on some rate control algorithms.",
99 UintegerValue(65535),
103 .AddAttribute("NonUnicastMode",
104 "Wifi mode used for non-unicast transmissions.",
108 .AddAttribute("DefaultTxPowerLevel",
109 "Default power level to be used for transmissions. "
110 "This is the power level that is used by all those WifiManagers that do "
111 "not implement TX power control.",
112 UintegerValue(0),
115 .AddAttribute("ErpProtectionMode",
116 "Protection mode used when non-ERP STAs are connected to an ERP AP: "
117 "Rts-Cts or Cts-To-Self",
122 "Rts-Cts",
124 "Cts-To-Self"))
125 .AddAttribute("HtProtectionMode",
126 "Protection mode used when non-HT STAs are connected to a HT AP: Rts-Cts "
127 "or Cts-To-Self",
132 "Rts-Cts",
134 "Cts-To-Self"))
135 .AddTraceSource("MacTxRtsFailed",
136 "The transmission of a RTS by the MAC layer has failed",
138 "ns3::Mac48Address::TracedCallback")
139 .AddTraceSource("MacTxDataFailed",
140 "The transmission of a data packet by the MAC layer has failed",
142 "ns3::Mac48Address::TracedCallback")
143 .AddTraceSource(
144 "MacTxFinalRtsFailed",
145 "The transmission of a RTS has exceeded the maximum number of attempts",
147 "ns3::Mac48Address::TracedCallback")
148 .AddTraceSource(
149 "MacTxFinalDataFailed",
150 "The transmission of a data packet has exceeded the maximum number of attempts",
152 "ns3::Mac48Address::TracedCallback");
153 return tid;
154}
155
157 : m_linkId(0),
158 m_useNonErpProtection(false),
159 m_useNonHtProtection(false),
160 m_shortPreambleEnabled(false),
161 m_shortSlotTimeEnabled(false)
162{
163 NS_LOG_FUNCTION(this);
164 m_ssrc.fill(0);
165 m_slrc.fill(0);
166}
167
172
173void
179
180void
182{
183 NS_LOG_FUNCTION(this << phy);
184 // We need to track our PHY because it is the object that knows the
185 // full set of transmit rates that are supported. We need to know
186 // this in order to find the relevant mandatory rates when choosing a
187 // transmit rate for automatic control responses like
188 // acknowledgments.
189 m_wifiPhy = phy;
190}
191
192void
194{
195 NS_LOG_FUNCTION(this << mac);
196 // We need to track our MAC because it is the object that knows the
197 // full set of interframe spaces.
198 m_wifiMac = mac;
199}
200
201void
203{
204 NS_LOG_FUNCTION(this << +linkId);
205 m_linkId = linkId;
206}
207
208int64_t
210{
211 NS_LOG_FUNCTION(this << stream);
212 return 0;
213}
214
215void
217{
218 NS_LOG_FUNCTION(this << maxSsrc);
219 m_maxSsrc = maxSsrc;
220}
221
222void
224{
225 NS_LOG_FUNCTION(this << maxSlrc);
226 m_maxSlrc = maxSlrc;
227}
228
229void
231{
232 NS_LOG_FUNCTION(this << threshold);
233 m_rtsCtsThreshold = threshold;
234}
235
236void
242
243void
245{
246 NS_LOG_FUNCTION(this << enable);
247 m_shortPreambleEnabled = enable;
248}
249
250void
252{
253 NS_LOG_FUNCTION(this << enable);
254 m_shortSlotTimeEnabled = enable;
255}
256
257bool
262
263bool
268
269bool
271{
272 return (m_wifiPhy->GetDevice()->GetHtConfiguration() &&
274}
275
276bool
278{
279 return (m_wifiPhy->GetDevice()->GetVhtConfiguration() &&
282}
283
284bool
286{
287 return bool(m_wifiPhy->GetDevice()->GetHeConfiguration());
288}
289
290bool
292{
293 return bool(m_wifiPhy->GetDevice()->GetEhtConfiguration());
294}
295
296bool
298{
299 if (auto htConfiguration = m_wifiPhy->GetDevice()->GetHtConfiguration())
300 {
301 return htConfiguration->m_ldpcSupported;
302 }
303 return false;
304}
305
306bool
308{
309 if (auto htConfiguration = m_wifiPhy->GetDevice()->GetHtConfiguration())
310 {
311 return htConfiguration->m_sgiSupported;
312 }
313 return false;
314}
315
316Time
318{
319 Time gi{};
320 if (GetHeSupported())
321 {
322 Ptr<HeConfiguration> heConfiguration = m_wifiPhy->GetDevice()->GetHeConfiguration();
323 NS_ASSERT(heConfiguration); // If HE is supported, we should have a HE configuration
324 // attached
325 gi = heConfiguration->GetGuardInterval();
326 }
327 return gi;
328}
329
335
336void
338 bool isShortPreambleSupported)
339{
340 NS_LOG_FUNCTION(this << address << isShortPreambleSupported);
341 NS_ASSERT(!address.IsGroup());
342 LookupState(address)->m_shortPreamble = isShortPreambleSupported;
343}
344
345void
347 bool isShortSlotTimeSupported)
348{
349 NS_LOG_FUNCTION(this << address << isShortSlotTimeSupported);
350 NS_ASSERT(!address.IsGroup());
351 LookupState(address)->m_shortSlotTime = isShortSlotTimeSupported;
352}
353
354void
356{
357 NS_LOG_FUNCTION(this << address << mode);
358 NS_ASSERT(!address.IsGroup());
359 auto state = LookupState(address);
360 for (const auto& i : state->m_operationalRateSet)
361 {
362 if (i == mode)
363 {
364 return; // already in
365 }
366 }
367 if ((mode.GetModulationClass() == WIFI_MOD_CLASS_DSSS) ||
369 {
370 state->m_dsssSupported = true;
371 }
373 {
374 state->m_erpOfdmSupported = true;
375 }
376 else if (mode.GetModulationClass() == WIFI_MOD_CLASS_OFDM)
377 {
378 state->m_ofdmSupported = true;
379 }
380 state->m_operationalRateSet.push_back(mode);
381}
382
383void
385{
386 NS_LOG_FUNCTION(this << address);
387 NS_ASSERT(!address.IsGroup());
388 auto state = LookupState(address);
389 state->m_operationalRateSet.clear();
390 for (const auto& mode : m_wifiPhy->GetModeList())
391 {
392 state->m_operationalRateSet.push_back(mode);
393 if (mode.IsMandatory())
394 {
395 AddBasicMode(mode);
396 }
397 }
398}
399
400void
402{
403 NS_LOG_FUNCTION(this << address);
404 NS_ASSERT(!address.IsGroup());
405 auto state = LookupState(address);
406
407 const auto& mcsList = m_wifiPhy->GetMcsList();
408 state->m_operationalMcsSet = WifiModeList(mcsList.begin(), mcsList.end());
409}
410
411void
413{
414 NS_LOG_FUNCTION(this << address);
415 NS_ASSERT(!address.IsGroup());
416 LookupState(address)->m_operationalMcsSet.clear();
417}
418
419void
421{
422 NS_LOG_FUNCTION(this << address << mcs);
423 NS_ASSERT(!address.IsGroup());
424 auto state = LookupState(address);
425 for (const auto& i : state->m_operationalMcsSet)
426 {
427 if (i == mcs)
428 {
429 return; // already in
430 }
431 }
432 state->m_operationalMcsSet.push_back(mcs);
433}
434
435bool
437{
438 return LookupState(address)->m_shortPreamble;
439}
440
441bool
443{
444 return LookupState(address)->m_shortSlotTime;
445}
446
447bool
449{
450 return LookupState(address)->m_qosSupported;
451}
452
453bool
455{
456 if (address.IsGroup())
457 {
458 return false;
459 }
460 return LookupState(address)->m_state == WifiRemoteStationState::BRAND_NEW;
461}
462
463bool
465{
466 if (address.IsGroup())
467 {
468 return true;
469 }
470 return LookupState(address)->m_state == WifiRemoteStationState::GOT_ASSOC_TX_OK;
471}
472
473bool
475{
476 if (address.IsGroup())
477 {
478 return false;
479 }
480 return LookupState(address)->m_state == WifiRemoteStationState::WAIT_ASSOC_TX_OK;
481}
482
483void
489
490void
496
497void
503
504void
510
511bool
513{
514 if (address.IsGroup())
515 {
516 return false;
517 }
518 return LookupState(address)->m_state == WifiRemoteStationState::ASSOC_REFUSED;
519}
520
521void
527
528uint16_t
530{
531 std::shared_ptr<WifiRemoteStationState> state;
532 if (!remoteAddress.IsGroup() &&
533 (state = LookupState(remoteAddress))->m_state == WifiRemoteStationState::GOT_ASSOC_TX_OK)
534 {
535 return state->m_aid;
536 }
537 return SU_STA_ID;
538}
539
540uint16_t
542{
543 NS_LOG_FUNCTION(this << address << txVector);
544
545 uint16_t staId = SU_STA_ID;
546
547 if (txVector.IsMu())
548 {
549 if (m_wifiMac->GetTypeOfStation() == AP)
550 {
551 staId = GetAssociationId(address);
552 }
553 else if (m_wifiMac->GetTypeOfStation() == STA)
554 {
556 if (staMac->IsAssociated())
557 {
558 staId = staMac->GetAssociationId();
559 }
560 }
561 }
562
563 NS_LOG_DEBUG("Returning STAID = " << staId);
564 return staId;
565}
566
567bool
569{
570 return LookupState(address)->m_isInPsMode;
571}
572
573void
574WifiRemoteStationManager::SetPsMode(const Mac48Address& address, bool isInPsMode)
575{
576 LookupState(address)->m_isInPsMode = isInPsMode;
577}
578
579std::optional<Mac48Address>
581{
582 if (auto stateIt = m_states.find(address);
583 stateIt != m_states.end() && stateIt->second->m_mleCommonInfo)
584 {
585 return stateIt->second->m_mleCommonInfo->m_mldMacAddress;
586 }
587
588 return std::nullopt;
589}
590
591std::optional<Mac48Address>
593{
594 auto stateIt = m_states.find(mldAddress);
595
596 if (stateIt == m_states.end() || !stateIt->second->m_mleCommonInfo)
597 {
598 // MLD address not found
599 return std::nullopt;
600 }
601
602 NS_ASSERT(stateIt->second->m_mleCommonInfo->m_mldMacAddress == mldAddress);
603 return stateIt->second->m_address;
604}
605
608{
609 NS_LOG_FUNCTION(this << header << allowedWidth);
610 const auto address = header.GetAddr1();
611 if (!header.IsMgt() && address.IsGroup())
612 {
613 return GetGroupcastTxVector(header, allowedWidth);
614 }
615 WifiTxVector txVector;
616 if (header.IsMgt())
617 {
618 // Use the lowest basic rate for management frames
619 WifiMode mgtMode;
620 if (GetNBasicModes() > 0)
621 {
622 mgtMode = GetBasicMode(0);
623 }
624 else
625 {
626 mgtMode = GetDefaultMode();
627 }
628 txVector.SetMode(mgtMode);
629 txVector.SetPreambleType(
632 auto channelWidth = allowedWidth;
633 if (!header.GetAddr1().IsGroup())
634 {
635 if (const auto rxWidth = GetChannelWidthSupported(header.GetAddr1());
636 rxWidth < channelWidth)
637 {
638 channelWidth = rxWidth;
639 }
640 }
641
642 txVector.SetChannelWidth(m_wifiPhy->GetTxBandwidth(mgtMode, channelWidth));
644 }
645 else
646 {
647 txVector = DoGetDataTxVector(Lookup(address), allowedWidth);
649 ? false
650 : UseLdpcForDestination(address));
651 }
652 Ptr<HeConfiguration> heConfiguration = m_wifiPhy->GetDevice()->GetHeConfiguration();
653 if (heConfiguration)
654 {
655 txVector.SetBssColor(heConfiguration->m_bssColor);
656 }
657 // If both the allowed width and the TXVECTOR channel width are integer multiple
658 // of 20 MHz, then the TXVECTOR channel width must not exceed the allowed width
659 NS_ASSERT_MSG((static_cast<uint16_t>(txVector.GetChannelWidth()) % 20 != 0) ||
660 (static_cast<uint16_t>(allowedWidth) % 20 != 0) ||
661 (txVector.GetChannelWidth() <= allowedWidth),
662 "TXVECTOR channel width (" << txVector.GetChannelWidth()
663 << " MHz) exceeds allowed width (" << allowedWidth
664 << " MHz)");
665 return txVector;
666}
667
670{
671 WifiMode defaultMode = GetDefaultMode();
672 WifiPreamble defaultPreamble;
673 if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_EHT)
674 {
675 defaultPreamble = WIFI_PREAMBLE_EHT_MU;
676 }
677 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_HE)
678 {
679 defaultPreamble = WIFI_PREAMBLE_HE_SU;
680 }
681 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_VHT)
682 {
683 defaultPreamble = WIFI_PREAMBLE_VHT_SU;
684 }
685 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_HT)
686 {
687 defaultPreamble = WIFI_PREAMBLE_HT_MF;
688 }
689 else
690 {
691 defaultPreamble = WIFI_PREAMBLE_LONG;
692 }
693
694 return WifiTxVector(defaultMode,
696 defaultPreamble,
699 1,
700 0,
701 m_wifiPhy->GetTxBandwidth(defaultMode),
702 false);
703}
704
707{
708 NS_LOG_FUNCTION(this << address << allowedWidth);
709 WifiTxVector v;
710 if (address.IsGroup())
711 {
713 v.SetMode(mode);
720 v.SetNss(1);
721 v.SetNess(0);
722 }
723 else
724 {
725 v = DoGetRtsTxVector(Lookup(address));
726 }
727 auto modulation = v.GetModulationClass();
728
729 if (allowedWidth >= 40 &&
730 (modulation == WIFI_MOD_CLASS_DSSS || modulation == WIFI_MOD_CLASS_HR_DSSS))
731 {
732 // RTS must be sent in a non-HT duplicate PPDU because it must protect a frame being
733 // transmitted on at least 40 MHz. Change the modulation class to ERP-OFDM and the rate
734 // to 6 Mbps
736 modulation = v.GetModulationClass();
737 }
738 // do not set allowedWidth as the TX width if the modulation class is (HR-)DSSS (allowedWidth
739 // may be >= 40 MHz) or allowedWidth is 22 MHz (the selected modulation class may be OFDM)
740 if (modulation != WIFI_MOD_CLASS_DSSS && modulation != WIFI_MOD_CLASS_HR_DSSS &&
741 allowedWidth != 22)
742 {
743 v.SetChannelWidth(allowedWidth);
744 }
745
746 return v;
747}
748
751{
752 auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
753 NS_ASSERT(!to.IsGroup() ||
754 (m_wifiMac && (m_wifiMac->GetTypeOfStation() == AP) && apMac->GetGcrManager()));
755 WifiMode ctsMode = GetControlAnswerMode(rtsTxMode);
756 WifiTxVector v;
757 v.SetMode(ctsMode);
763 v.SetNss(1);
764 return v;
765}
766
767void
769{
770 NS_LOG_FUNCTION(this << txVector);
771
772 auto txMode = txVector.GetMode();
773 if (txMode.GetModulationClass() >= WIFI_MOD_CLASS_HT)
774 {
775 auto rate = txMode.GetDataRate(txVector);
776 if (rate >= 24e6)
777 {
778 rate = 24e6;
779 }
780 else if (rate >= 12e6)
781 {
782 rate = 12e6;
783 }
784 else
785 {
786 rate = 6e6;
787 }
790 {
791 txVector.SetMode(ErpOfdmPhy::GetErpOfdmRate(rate));
792 }
793 else
794 {
795 txVector.SetMode(OfdmPhy::GetOfdmRate(rate));
796 }
797 }
798}
799
802{
803 NS_ASSERT(!to.IsGroup());
804 WifiMode ackMode = GetControlAnswerMode(dataTxVector.GetMode(GetStaId(to, dataTxVector)));
805 WifiTxVector v;
806 v.SetMode(ackMode);
812 v.SetNss(1);
813 return v;
814}
815
818 const WifiTxVector& dataTxVector) const
819{
820 NS_ASSERT(!to.IsGroup());
821 WifiMode blockAckMode = GetControlAnswerMode(dataTxVector.GetMode(GetStaId(to, dataTxVector)));
822 WifiTxVector v;
823 v.SetMode(blockAckMode);
827 v.SetChannelWidth(m_wifiPhy->GetTxBandwidth(blockAckMode));
829 v.SetNss(1);
830 return v;
831}
832
835{
836 /**
837 * The standard has relatively unambiguous rules for selecting a
838 * control response rate (the below is quoted from IEEE 802.11-2012,
839 * Section 9.7):
840 *
841 * To allow the transmitting STA to calculate the contents of the
842 * Duration/ID field, a STA responding to a received frame shall
843 * transmit its Control Response frame (either CTS or Ack), other
844 * than the BlockAck control frame, at the highest rate in the
845 * BSSBasicRateSet parameter that is less than or equal to the
846 * rate of the immediately previous frame in the frame exchange
847 * sequence (as defined in Annex G) and that is of the same
848 * modulation class (see Section 9.7.8) as the received frame...
849 */
850 NS_LOG_FUNCTION(this << reqMode);
851 WifiMode mode = GetDefaultMode();
852 bool found = false;
853 // First, search the BSS Basic Rate set
854 for (uint8_t i = 0; i < GetNBasicModes(); i++)
855 {
856 WifiMode testMode = GetBasicMode(i);
857 if ((!found || testMode.IsHigherDataRate(mode)) && (!testMode.IsHigherDataRate(reqMode)) &&
859 testMode.GetModulationClass())))
860 {
861 mode = testMode;
862 // We've found a potentially-suitable transmit rate, but we
863 // need to continue and consider all the basic rates before
864 // we can be sure we've got the right one.
865 found = true;
866 }
867 }
868 if (m_wifiPhy->GetDevice()->GetHtConfiguration())
869 {
870 if (!found)
871 {
872 mode = GetDefaultMcs();
873 for (uint8_t i = 0; i != GetNBasicMcs(); i++)
874 {
875 WifiMode testMode = GetBasicMcs(i);
876 if ((!found || testMode.IsHigherDataRate(mode)) &&
877 (!testMode.IsHigherDataRate(reqMode)) &&
878 (testMode.GetModulationClass() == reqMode.GetModulationClass()))
879 {
880 mode = testMode;
881 // We've found a potentially-suitable transmit rate, but we
882 // need to continue and consider all the basic rates before
883 // we can be sure we've got the right one.
884 found = true;
885 }
886 }
887 }
888 }
889 // If we found a suitable rate in the BSSBasicRateSet, then we are
890 // done and can return that mode.
891 if (found)
892 {
893 NS_LOG_DEBUG("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
894 return mode;
895 }
896
897 /**
898 * If no suitable basic rate was found, we search the mandatory
899 * rates. The standard (IEEE 802.11-2007, Section 9.6) says:
900 *
901 * ...If no rate contained in the BSSBasicRateSet parameter meets
902 * these conditions, then the control frame sent in response to a
903 * received frame shall be transmitted at the highest mandatory
904 * rate of the PHY that is less than or equal to the rate of the
905 * received frame, and that is of the same modulation class as the
906 * received frame. In addition, the Control Response frame shall
907 * be sent using the same PHY options as the received frame,
908 * unless they conflict with the requirement to use the
909 * BSSBasicRateSet parameter.
910 *
911 * @todo Note that we're ignoring the last sentence for now, because
912 * there is not yet any manipulation here of PHY options.
913 */
914 for (const auto& thismode : m_wifiPhy->GetModeList())
915 {
916 /* If the rate:
917 *
918 * - is a mandatory rate for the PHY, and
919 * - is equal to or faster than our current best choice, and
920 * - is less than or equal to the rate of the received frame, and
921 * - is of the same modulation class as the received frame
922 *
923 * ...then it's our best choice so far.
924 */
925 if (thismode.IsMandatory() && (!found || thismode.IsHigherDataRate(mode)) &&
926 (!thismode.IsHigherDataRate(reqMode)) &&
928 thismode.GetModulationClass())))
929 {
930 mode = thismode;
931 // As above; we've found a potentially-suitable transmit
932 // rate, but we need to continue and consider all the
933 // mandatory rates before we can be sure we've got the right one.
934 found = true;
935 }
936 }
937 if (m_wifiPhy->GetDevice()->GetHtConfiguration())
938 {
939 for (const auto& thismode : m_wifiPhy->GetMcsList())
940 {
941 if (thismode.IsMandatory() && (!found || thismode.IsHigherDataRate(mode)) &&
942 (!thismode.IsHigherCodeRate(reqMode)) &&
943 (thismode.GetModulationClass() == reqMode.GetModulationClass()))
944 {
945 mode = thismode;
946 // As above; we've found a potentially-suitable transmit
947 // rate, but we need to continue and consider all the
948 // mandatory rates before we can be sure we've got the right one.
949 found = true;
950 }
951 }
952 }
953
954 /**
955 * If we still haven't found a suitable rate for the response then
956 * someone has messed up the simulation configuration. This probably means
957 * that the WifiPhyStandard is not set correctly, or that a rate that
958 * is not supported by the PHY has been explicitly requested.
959 *
960 * Either way, it is serious - we can either disobey the standard or
961 * fail, and I have chosen to do the latter...
962 */
963 if (!found)
964 {
965 NS_FATAL_ERROR("Can't find response rate for " << reqMode);
966 }
967
968 NS_LOG_DEBUG("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
969 return mode;
970}
971
972void
974{
975 NS_LOG_FUNCTION(this << header);
976 const auto recipient = GetIndividuallyAddressedRecipient(m_wifiMac, header);
977 NS_ASSERT(!recipient.IsGroup());
978 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
979 m_ssrc[ac]++;
980 m_macTxRtsFailed(recipient);
981 DoReportRtsFailed(Lookup(recipient));
982}
983
984void
986{
987 NS_LOG_FUNCTION(this << *mpdu);
988 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
989 AcIndex ac =
990 QosUtilsMapTidToAc((mpdu->GetHeader().IsQosData()) ? mpdu->GetHeader().GetQosTid() : 0);
991 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
992 if (longMpdu)
993 {
994 m_slrc[ac]++;
995 }
996 else
997 {
998 m_ssrc[ac]++;
999 }
1000 m_macTxDataFailed(mpdu->GetHeader().GetAddr1());
1001 DoReportDataFailed(Lookup(mpdu->GetHeader().GetAddr1()));
1002}
1003
1004void
1006 double ctsSnr,
1007 WifiMode ctsMode,
1008 double rtsSnr)
1009{
1010 NS_LOG_FUNCTION(this << header << ctsSnr << ctsMode << rtsSnr);
1011 const auto recipient = GetIndividuallyAddressedRecipient(m_wifiMac, header);
1012 NS_ASSERT(!recipient.IsGroup());
1013 WifiRemoteStation* station = Lookup(recipient);
1014 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
1015 station->m_state->m_info.NotifyTxSuccess(m_ssrc[ac]);
1016 m_ssrc[ac] = 0;
1017 DoReportRtsOk(station, ctsSnr, ctsMode, rtsSnr);
1018}
1019
1020void
1022 double ackSnr,
1023 WifiMode ackMode,
1024 double dataSnr,
1025 WifiTxVector dataTxVector)
1026{
1027 NS_LOG_FUNCTION(this << *mpdu << ackSnr << ackMode << dataSnr << dataTxVector);
1028 const WifiMacHeader& hdr = mpdu->GetHeader();
1029 NS_ASSERT(!hdr.GetAddr1().IsGroup());
1030 WifiRemoteStation* station = Lookup(hdr.GetAddr1());
1031 AcIndex ac = QosUtilsMapTidToAc((hdr.IsQosData()) ? hdr.GetQosTid() : 0);
1032 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
1033 if (longMpdu)
1034 {
1035 station->m_state->m_info.NotifyTxSuccess(m_slrc[ac]);
1036 m_slrc[ac] = 0;
1037 }
1038 else
1039 {
1040 station->m_state->m_info.NotifyTxSuccess(m_ssrc[ac]);
1041 m_ssrc[ac] = 0;
1042 }
1043 DoReportDataOk(station,
1044 ackSnr,
1045 ackMode,
1046 dataSnr,
1047 dataTxVector.GetChannelWidth(),
1048 dataTxVector.GetNss(GetStaId(hdr.GetAddr1(), dataTxVector)));
1049}
1050
1051void
1053{
1054 NS_LOG_FUNCTION(this << header);
1055 NS_ASSERT(!header.GetAddr1().IsGroup());
1056 WifiRemoteStation* station = Lookup(header.GetAddr1());
1057 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
1058 station->m_state->m_info.NotifyTxFailed();
1059 m_ssrc[ac] = 0;
1061 DoReportFinalRtsFailed(station);
1062}
1063
1064void
1066{
1067 NS_LOG_FUNCTION(this << *mpdu);
1068 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1069 WifiRemoteStation* station = Lookup(mpdu->GetHeader().GetAddr1());
1070 AcIndex ac =
1071 QosUtilsMapTidToAc((mpdu->GetHeader().IsQosData()) ? mpdu->GetHeader().GetQosTid() : 0);
1072 station->m_state->m_info.NotifyTxFailed();
1073 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
1074 if (longMpdu)
1075 {
1076 m_slrc[ac] = 0;
1077 }
1078 else
1079 {
1080 m_ssrc[ac] = 0;
1081 }
1082 m_macTxFinalDataFailed(mpdu->GetHeader().GetAddr1());
1083 DoReportFinalDataFailed(station);
1084}
1085
1086void
1088 RxSignalInfo rxSignalInfo,
1089 const WifiTxVector& txVector)
1090{
1091 NS_LOG_FUNCTION(this << address << rxSignalInfo << txVector);
1092 if (address.IsGroup())
1093 {
1094 return;
1095 }
1096 WifiRemoteStation* station = Lookup(address);
1097 DoReportRxOk(station, rxSignalInfo.snr, txVector.GetMode(GetStaId(address, txVector)));
1098 station->m_rssiAndUpdateTimePair = std::make_pair(rxSignalInfo.rssi, Simulator::Now());
1099}
1100
1101void
1103 uint16_t nSuccessfulMpdus,
1104 uint16_t nFailedMpdus,
1105 double rxSnr,
1106 double dataSnr,
1107 WifiTxVector dataTxVector)
1108{
1109 NS_LOG_FUNCTION(this << address << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr
1110 << dataTxVector);
1111 NS_ASSERT(!address.IsGroup());
1112 for (uint16_t i = 0; i < nFailedMpdus; i++)
1113 {
1114 m_macTxDataFailed(address);
1115 }
1117 nSuccessfulMpdus,
1118 nFailedMpdus,
1119 rxSnr,
1120 dataSnr,
1121 dataTxVector.GetChannelWidth(),
1122 dataTxVector.GetNss(GetStaId(address, dataTxVector)));
1123}
1124
1125std::list<Ptr<WifiMpdu>>
1127{
1128 NS_LOG_FUNCTION(this << *psdu);
1129
1130 auto* station = Lookup(GetIndividuallyAddressedRecipient(m_wifiMac, psdu->GetHeader(0)));
1131
1132 DoIncrementRetryCountOnTxFailure(station, psdu);
1133 return DoGetMpdusToDropOnTxFailure(station, psdu);
1134}
1135
1136void
1138 Ptr<WifiPsdu> psdu)
1139{
1140 NS_LOG_FUNCTION(this << *psdu);
1141
1142 // The frame retry count for an MSDU or A-MSDU that is not part of a block ack agreement or
1143 // for an MMPDU shall be incremented every time transmission fails for that MSDU, A-MSDU, or
1144 // MMPDU, including of an associated RTS (Sec. 10.23.2.12.1 of 802.11-2020).
1145 // Frames for which the retry count needs to be incremented:
1146 // - management frames
1147 // - non-QoS Data frames
1148 // - QoS Data frames that are not part of a Block Ack agreement
1149 // - QoS Data frames that are part of a Block Ack agreement if the IncrementRetryCountUnderBa
1150 // attribute is set to true
1151 const auto& hdr = psdu->GetHeader(0);
1152
1153 if (hdr.IsMgt() || (hdr.IsData() && !hdr.IsQosData()) ||
1154 (hdr.IsQosData() && (!m_wifiMac->GetBaAgreementEstablishedAsOriginator(
1155 hdr.GetAddr1(),
1156 hdr.GetQosTid() || m_incrRetryCountUnderBa))))
1157 {
1158 psdu->IncrementRetryCount();
1159 }
1160}
1161
1162std::list<Ptr<WifiMpdu>>
1164 Ptr<WifiPsdu> psdu)
1165{
1166 NS_LOG_FUNCTION(this << *psdu);
1167
1168 std::list<Ptr<WifiMpdu>> mpdusToDrop;
1169
1170 for (const auto& mpdu : *PeekPointer(psdu))
1171 {
1172 if (mpdu->GetRetryCount() == m_wifiMac->GetFrameRetryLimit())
1173 {
1174 // this MPDU needs to be dropped
1175 mpdusToDrop.push_back(mpdu);
1176 }
1177 }
1178
1179 return mpdusToDrop;
1180}
1181
1182bool
1184{
1185 NS_LOG_FUNCTION(this << header << &txParams);
1186 auto address = header.GetAddr1();
1187 const auto isGcr = IsGcr(m_wifiMac, header);
1188 if (!isGcr && address.IsGroup())
1189 {
1190 return false;
1191 }
1192 if (isGcr)
1193 {
1195 auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
1196 apMac->GetGcrManager()->GetAttribute("GcrProtectionMode", enumValue);
1197 if (enumValue.Get() != GroupcastProtectionMode::RTS_CTS)
1198 {
1199 return false;
1200 }
1201 address = apMac->GetGcrManager()->GetIndividuallyAddressedRecipient(address);
1202 }
1203 const auto modulationClass = txParams.m_txVector.GetModulationClass();
1205 ((modulationClass == WIFI_MOD_CLASS_ERP_OFDM) || (modulationClass == WIFI_MOD_CLASS_HT) ||
1206 (modulationClass == WIFI_MOD_CLASS_VHT) || (modulationClass == WIFI_MOD_CLASS_HE) ||
1207 (modulationClass == WIFI_MOD_CLASS_EHT)) &&
1209 {
1211 "WifiRemoteStationManager::NeedRTS returning true to protect non-ERP stations");
1212 return true;
1213 }
1214 else if (m_htProtectionMode == RTS_CTS &&
1215 ((modulationClass == WIFI_MOD_CLASS_HT) || (modulationClass == WIFI_MOD_CLASS_VHT)) &&
1217 {
1218 NS_LOG_DEBUG("WifiRemoteStationManager::NeedRTS returning true to protect non-HT stations");
1219 return true;
1220 }
1221 NS_ASSERT(txParams.m_txDuration.has_value());
1222 auto size = txParams.GetSize(header.GetAddr1());
1223 bool normally =
1226 return DoNeedRts(Lookup(address), size, normally);
1227}
1228
1229bool
1231{
1232 NS_LOG_FUNCTION(this << txVector << header);
1235 (txVector.GetModulationClass() == WIFI_MOD_CLASS_HT) ||
1236 (txVector.GetModulationClass() == WIFI_MOD_CLASS_VHT) ||
1237 (txVector.GetModulationClass() == WIFI_MOD_CLASS_HE) ||
1238 (txVector.GetModulationClass() == WIFI_MOD_CLASS_EHT)))
1239 {
1241 "WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
1242 return true;
1243 }
1244 else if (m_htProtectionMode == CTS_TO_SELF &&
1245 ((txVector.GetModulationClass() == WIFI_MOD_CLASS_HT) ||
1246 (txVector.GetModulationClass() == WIFI_MOD_CLASS_VHT)) &&
1248 {
1250 "WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-HT stations");
1251 return true;
1252 }
1253 else if (IsGcr(m_wifiMac, header))
1254 {
1256 auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
1257 apMac->GetGcrManager()->GetAttribute("GcrProtectionMode", enumValue);
1258 if (enumValue.Get() == GroupcastProtectionMode::CTS_TO_SELF)
1259 {
1260 return true;
1261 }
1262 }
1263 // FIXME: commented out for now
1264 /*else if (!m_useNonErpProtection)
1265 {
1266 const auto mode = txVector.GetMode();
1267 // search for the BSS Basic Rate set, if the used mode is in the basic set then there is no
1268 // need for CTS To Self
1269 for (auto i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++)
1270 {
1271 if (mode == *i)
1272 {
1273 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning false");
1274 return false;
1275 }
1276 }
1277 if (m_wifiPhy->GetDevice()->GetHtConfiguration())
1278 {
1279 // search for the BSS Basic MCS set, if the used mode is in the basic set then there is
1280 // no need for CTS To Self
1281 for (auto i = m_bssBasicMcsSet.begin(); i != m_bssBasicMcsSet.end(); i++)
1282 {
1283 if (mode == *i)
1284 {
1285 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning false");
1286 return false;
1287 }
1288 }
1289 }
1290 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning true");
1291 return true;
1292 }*/
1293 return false;
1294}
1295
1296void
1298{
1299 NS_LOG_FUNCTION(this << enable);
1300 m_useNonErpProtection = enable;
1301}
1302
1303bool
1308
1309void
1311{
1312 NS_LOG_FUNCTION(this << enable);
1313 m_useNonHtProtection = enable;
1314}
1315
1316bool
1321
1322bool
1324{
1325 NS_LOG_FUNCTION(this << *mpdu);
1326 if (mpdu->GetHeader().GetAddr1().IsGroup())
1327 {
1328 return false;
1329 }
1330 bool normally = mpdu->GetSize() > GetFragmentationThreshold();
1331 NS_LOG_DEBUG("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha
1332 << normally);
1333 return DoNeedFragmentation(Lookup(mpdu->GetHeader().GetAddr1()), mpdu->GetPacket(), normally);
1334}
1335
1336void
1338{
1339 NS_LOG_FUNCTION(this << threshold);
1340 if (threshold < 256)
1341 {
1342 /*
1343 * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
1344 */
1345 NS_LOG_WARN("Fragmentation threshold should be larger than 256. Setting to 256.");
1347 }
1348 else
1349 {
1350 /*
1351 * The length of each fragment shall be an even number of octets, except for the last
1352 * fragment if an MSDU or MMPDU, which may be either an even or an odd number of octets.
1353 */
1354 if (threshold % 2 != 0)
1355 {
1356 NS_LOG_WARN("Fragmentation threshold should be an even number. Setting to "
1357 << threshold - 1);
1358 m_fragmentationThreshold = threshold - 1;
1359 }
1360 else
1361 {
1362 m_fragmentationThreshold = threshold;
1363 }
1364 }
1365}
1366
1372
1375{
1376 NS_LOG_FUNCTION(this << *mpdu);
1377 // The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1378 uint32_t nFragments =
1379 (mpdu->GetPacket()->GetSize() /
1380 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH));
1381
1382 // If the size of the last fragment is not 0.
1383 if ((mpdu->GetPacket()->GetSize() %
1384 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH)) > 0)
1385 {
1386 nFragments++;
1387 }
1388 NS_LOG_DEBUG("WifiRemoteStationManager::GetNFragments returning " << nFragments);
1389 return nFragments;
1390}
1391
1394{
1395 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1396 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1397 uint32_t nFragment = GetNFragments(mpdu);
1398 if (fragmentNumber >= nFragment)
1399 {
1400 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning 0");
1401 return 0;
1402 }
1403 // Last fragment
1404 if (fragmentNumber == nFragment - 1)
1405 {
1406 uint32_t lastFragmentSize =
1407 mpdu->GetPacket()->GetSize() -
1408 (fragmentNumber *
1409 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH));
1410 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
1411 return lastFragmentSize;
1412 }
1413 // All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1414 else
1415 {
1416 uint32_t fragmentSize =
1417 GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH;
1418 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
1419 return fragmentSize;
1420 }
1421}
1422
1425{
1426 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1427 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1428 NS_ASSERT(fragmentNumber < GetNFragments(mpdu));
1429 uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold() -
1430 mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH);
1431 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
1432 return fragmentOffset;
1433}
1434
1435bool
1437{
1438 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1439 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1440 bool isLast = fragmentNumber == (GetNFragments(mpdu) - 1);
1441 NS_LOG_DEBUG("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
1442 return isLast;
1443}
1444
1445uint8_t
1450
1453{
1454 return LookupState(address)->m_info;
1455}
1456
1457std::optional<dBm_u>
1459{
1460 auto station = Lookup(address);
1461 auto rssi = station->m_rssiAndUpdateTimePair.first;
1462 auto ts = station->m_rssiAndUpdateTimePair.second;
1463 if (ts.IsStrictlyPositive())
1464 {
1465 return rssi;
1466 }
1467 return std::nullopt;
1468}
1469
1470std::shared_ptr<WifiRemoteStationState>
1472{
1473 NS_LOG_FUNCTION(this << address);
1474 auto stateIt = m_states.find(address);
1475
1476 if (stateIt != m_states.end())
1477 {
1478 NS_LOG_DEBUG("WifiRemoteStationManager::LookupState returning existing state");
1479 return stateIt->second;
1480 }
1481
1482 auto state = std::make_shared<WifiRemoteStationState>();
1483 state->m_state = WifiRemoteStationState::BRAND_NEW;
1484 state->m_address = address;
1485 state->m_aid = 0;
1486 state->m_operationalRateSet.push_back(GetDefaultMode());
1487 state->m_operationalMcsSet.push_back(GetDefaultMcs());
1488 state->m_dsssSupported = false;
1489 state->m_erpOfdmSupported = false;
1490 state->m_ofdmSupported = false;
1491 state->m_htCapabilities = nullptr;
1492 state->m_vhtCapabilities = nullptr;
1493 state->m_heCapabilities = nullptr;
1494 state->m_ehtCapabilities = nullptr;
1495 state->m_mleCommonInfo = nullptr;
1496 state->m_emlsrEnabled = false;
1497 state->m_channelWidth = m_wifiPhy->GetChannelWidth();
1498 state->m_guardInterval = GetGuardInterval();
1499 state->m_ness = 0;
1500 state->m_aggregation = false;
1501 state->m_qosSupported = false;
1502 state->m_isInPsMode = false;
1503 const_cast<WifiRemoteStationManager*>(this)->m_states.insert({address, state});
1504 NS_LOG_DEBUG("WifiRemoteStationManager::LookupState returning new state");
1505 return state;
1506}
1507
1508WifiRemoteStation*
1509WifiRemoteStationManager::Lookup(Mac48Address address) const
1510{
1511 NS_LOG_FUNCTION(this << address);
1512 NS_ASSERT(!address.IsGroup());
1513 NS_ASSERT(address != m_wifiMac->GetAddress());
1514 auto stationIt = m_stations.find(address);
1515
1516 if (stationIt != m_stations.end())
1517 {
1518 return stationIt->second;
1519 }
1520
1521 WifiRemoteStation* station = DoCreateStation();
1522 station->m_state = LookupState(address).get();
1523 station->m_rssiAndUpdateTimePair = std::make_pair(dBm_u{0}, Seconds(0));
1524 const_cast<WifiRemoteStationManager*>(this)->m_stations.insert({address, station});
1525 return station;
1526}
1527
1528void
1529WifiRemoteStationManager::SetAssociationId(Mac48Address remoteAddress, uint16_t aid)
1530{
1531 NS_LOG_FUNCTION(this << remoteAddress << aid);
1532 LookupState(remoteAddress)->m_aid = aid;
1533}
1534
1535void
1536WifiRemoteStationManager::SetQosSupport(Mac48Address from, bool qosSupported)
1537{
1538 NS_LOG_FUNCTION(this << from << qosSupported);
1539 LookupState(from)->m_qosSupported = qosSupported;
1540}
1541
1542void
1543WifiRemoteStationManager::SetEmlsrEnabled(const Mac48Address& from, bool emlsrEnabled)
1544{
1545 NS_LOG_FUNCTION(this << from << emlsrEnabled);
1546 LookupState(from)->m_emlsrEnabled = emlsrEnabled;
1547}
1548
1549void
1550WifiRemoteStationManager::AddStationHtCapabilities(Mac48Address from,
1551 const HtCapabilities& htCapabilities)
1552{
1553 // Used by all stations to record HT capabilities of remote stations
1554 NS_LOG_FUNCTION(this << from << htCapabilities);
1555 auto state = LookupState(from);
1556 if (htCapabilities.GetSupportedChannelWidth() == 1)
1557 {
1558 state->m_channelWidth = MHz_u{40};
1559 }
1560 else
1561 {
1562 state->m_channelWidth = MHz_u{20};
1563 }
1564 SetQosSupport(from, true);
1565 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_HT))
1566 {
1567 if (htCapabilities.IsSupportedMcs(mcs.GetMcsValue()))
1568 {
1569 AddSupportedMcs(from, mcs);
1570 }
1571 }
1572 state->m_htCapabilities = Create<const HtCapabilities>(htCapabilities);
1573}
1574
1575void
1576WifiRemoteStationManager::AddStationExtendedCapabilities(
1577 Mac48Address from,
1578 const ExtendedCapabilities& extendedCapabilities)
1579{
1580 NS_LOG_FUNCTION(this << from << extendedCapabilities);
1581 auto state = LookupState(from);
1582 state->m_extendedCapabilities = Create<const ExtendedCapabilities>(extendedCapabilities);
1583}
1584
1585void
1586WifiRemoteStationManager::AddStationVhtCapabilities(Mac48Address from,
1587 const VhtCapabilities& vhtCapabilities)
1588{
1589 // Used by all stations to record VHT capabilities of remote stations
1590 NS_LOG_FUNCTION(this << from << vhtCapabilities);
1591 auto state = LookupState(from);
1592 if (vhtCapabilities.GetSupportedChannelWidthSet() == 1)
1593 {
1594 state->m_channelWidth = MHz_u{160};
1595 }
1596 else
1597 {
1598 state->m_channelWidth = MHz_u{80};
1599 }
1600 for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams(); i++)
1601 {
1602 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_VHT))
1603 {
1604 if (vhtCapabilities.IsSupportedMcs(mcs.GetMcsValue(), i))
1605 {
1606 AddSupportedMcs(from, mcs);
1607 }
1608 }
1609 }
1610 state->m_vhtCapabilities = Create<const VhtCapabilities>(vhtCapabilities);
1611}
1612
1613void
1614WifiRemoteStationManager::AddStationHeCapabilities(Mac48Address from,
1615 const HeCapabilities& heCapabilities)
1616{
1617 // Used by all stations to record HE capabilities of remote stations
1618 NS_LOG_FUNCTION(this << from << heCapabilities);
1619 auto state = LookupState(from);
1620 if ((m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_5GHZ) ||
1621 (m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_6GHZ))
1622 {
1623 if (heCapabilities.GetChannelWidthSet() & 0x04)
1624 {
1625 state->m_channelWidth = MHz_u{160};
1626 }
1627 else if (heCapabilities.GetChannelWidthSet() & 0x02)
1628 {
1629 state->m_channelWidth = MHz_u{80};
1630 }
1631 // For other cases at 5 GHz, the supported channel width is set by the VHT capabilities
1632 }
1633 else if (m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_2_4GHZ)
1634 {
1635 if (heCapabilities.GetChannelWidthSet() & 0x01)
1636 {
1637 state->m_channelWidth = MHz_u{40};
1638 }
1639 else
1640 {
1641 state->m_channelWidth = MHz_u{20};
1642 }
1643 }
1644 if (heCapabilities.GetHeSuPpdu1xHeLtf800nsGi())
1645 {
1646 state->m_guardInterval = NanoSeconds(800);
1647 }
1648 else
1649 {
1650 // todo: Using 3200ns, default value for HeConfiguration::GuardInterval
1651 state->m_guardInterval = NanoSeconds(3200);
1652 }
1653 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_HE))
1654 {
1655 if (heCapabilities.GetHighestMcsSupported() >= mcs.GetMcsValue())
1656 {
1657 AddSupportedMcs(from, mcs);
1658 }
1659 }
1660 state->m_heCapabilities = Create<const HeCapabilities>(heCapabilities);
1661 SetQosSupport(from, true);
1662}
1663
1664void
1665WifiRemoteStationManager::AddStationHe6GhzCapabilities(
1666 const Mac48Address& from,
1667 const He6GhzBandCapabilities& he6GhzCapabilities)
1668{
1669 // Used by all stations to record HE 6GHz band capabilities of remote stations
1670 NS_LOG_FUNCTION(this << from << he6GhzCapabilities);
1671 auto state = LookupState(from);
1672 state->m_he6GhzBandCapabilities = Create<const He6GhzBandCapabilities>(he6GhzCapabilities);
1673 SetQosSupport(from, true);
1674}
1675
1676void
1677WifiRemoteStationManager::AddStationEhtCapabilities(Mac48Address from,
1678 const EhtCapabilities& ehtCapabilities)
1679{
1680 // Used by all stations to record EHT capabilities of remote stations
1681 NS_LOG_FUNCTION(this << from << ehtCapabilities);
1682 auto state = LookupState(from);
1683 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_EHT))
1684 {
1685 for (uint8_t mapType = 0; mapType < EhtMcsAndNssSet::EHT_MCS_MAP_TYPE_MAX; ++mapType)
1686 {
1687 if (ehtCapabilities.GetHighestSupportedRxMcs(
1688 static_cast<EhtMcsAndNssSet::EhtMcsMapType>(mapType)) >= mcs.GetMcsValue())
1689 {
1690 AddSupportedMcs(from, mcs);
1691 }
1692 }
1693 }
1694 state->m_ehtCapabilities = Create<const EhtCapabilities>(ehtCapabilities);
1695 SetQosSupport(from, true);
1696}
1697
1698void
1699WifiRemoteStationManager::AddStationMleCommonInfo(
1700 Mac48Address from,
1701 const std::shared_ptr<CommonInfoBasicMle>& mleCommonInfo)
1702{
1703 NS_LOG_FUNCTION(this << from);
1704 auto state = LookupState(from);
1705 state->m_mleCommonInfo = mleCommonInfo;
1706 // insert another entry in m_states indexed by the MLD address and pointing to the same state
1707 const_cast<WifiRemoteStationManager*>(this)->m_states.insert(
1708 {mleCommonInfo->m_mldMacAddress, state});
1709}
1710
1711Ptr<const HtCapabilities>
1712WifiRemoteStationManager::GetStationHtCapabilities(Mac48Address from)
1713{
1714 return LookupState(from)->m_htCapabilities;
1715}
1716
1718WifiRemoteStationManager::GetStationExtendedCapabilities(const Mac48Address& from)
1719{
1720 return LookupState(from)->m_extendedCapabilities;
1721}
1722
1724WifiRemoteStationManager::GetStationVhtCapabilities(Mac48Address from)
1725{
1726 return LookupState(from)->m_vhtCapabilities;
1727}
1728
1730WifiRemoteStationManager::GetStationHeCapabilities(Mac48Address from)
1731{
1732 return LookupState(from)->m_heCapabilities;
1733}
1734
1736WifiRemoteStationManager::GetStationHe6GhzCapabilities(const Mac48Address& from) const
1737{
1738 return LookupState(from)->m_he6GhzBandCapabilities;
1739}
1740
1742WifiRemoteStationManager::GetStationEhtCapabilities(Mac48Address from)
1743{
1744 return LookupState(from)->m_ehtCapabilities;
1745}
1746
1747std::optional<std::reference_wrapper<CommonInfoBasicMle::EmlCapabilities>>
1748WifiRemoteStationManager::GetStationEmlCapabilities(const Mac48Address& from)
1749{
1750 if (auto state = LookupState(from);
1751 state->m_mleCommonInfo && state->m_mleCommonInfo->m_emlCapabilities)
1752 {
1753 return state->m_mleCommonInfo->m_emlCapabilities.value();
1754 }
1755 return std::nullopt;
1756}
1757
1758std::optional<std::reference_wrapper<CommonInfoBasicMle::MldCapabilities>>
1759WifiRemoteStationManager::GetStationMldCapabilities(const Mac48Address& from)
1760{
1761 if (auto state = LookupState(from);
1762 state->m_mleCommonInfo && state->m_mleCommonInfo->m_mldCapabilities)
1763 {
1764 return state->m_mleCommonInfo->m_mldCapabilities.value();
1765 }
1766 return std::nullopt;
1767}
1768
1769bool
1770WifiRemoteStationManager::GetLdpcSupported(Mac48Address address) const
1771{
1772 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
1773 Ptr<const VhtCapabilities> vhtCapabilities = LookupState(address)->m_vhtCapabilities;
1774 Ptr<const HeCapabilities> heCapabilities = LookupState(address)->m_heCapabilities;
1775 bool supported = false;
1776 if (htCapabilities)
1777 {
1778 supported |= htCapabilities->GetLdpc();
1779 }
1780 if (vhtCapabilities)
1781 {
1782 supported |= vhtCapabilities->GetRxLdpc();
1783 }
1784 if (heCapabilities)
1785 {
1786 supported |= heCapabilities->GetLdpcCodingInPayload();
1787 }
1788 return supported;
1789}
1790
1792WifiRemoteStationManager::GetDefaultMode() const
1793{
1794 NS_ASSERT(m_wifiPhy);
1795 auto defaultTxMode = m_wifiPhy->GetDefaultMode();
1796 NS_ASSERT(defaultTxMode.IsMandatory());
1797 return defaultTxMode;
1798}
1799
1801WifiRemoteStationManager::GetDefaultMcs() const
1802{
1803 return HtPhy::GetHtMcs0();
1804}
1805
1807WifiRemoteStationManager::GetDefaultModeForSta(const WifiRemoteStation* st) const
1808{
1809 NS_LOG_FUNCTION(this << st);
1810
1811 if ((!m_wifiPhy->GetDevice()->GetHtConfiguration()) ||
1812 (!GetHtSupported(st) && !GetStationHe6GhzCapabilities(st->m_state->m_address)))
1813 {
1814 return GetDefaultMode();
1815 }
1816
1817 // find the highest modulation class supported by both stations
1819 if (GetHeSupported() && GetHeSupported(st))
1820 {
1821 modClass = WIFI_MOD_CLASS_HE;
1822 }
1823 else if (GetVhtSupported() && GetVhtSupported(st))
1824 {
1825 modClass = WIFI_MOD_CLASS_VHT;
1826 }
1827
1828 // return the MCS with lowest index
1829 return *m_wifiPhy->GetPhyEntity(modClass)->begin();
1830}
1831
1832void
1833WifiRemoteStationManager::Reset()
1834{
1835 NS_LOG_FUNCTION(this);
1836 m_states.clear();
1837 for (auto& state : m_stations)
1838 {
1839 delete (state.second);
1840 }
1841 m_stations.clear();
1842 m_bssBasicRateSet.clear();
1843 m_bssBasicMcsSet.clear();
1844 m_ssrc.fill(0);
1845 m_slrc.fill(0);
1846}
1847
1848void
1849WifiRemoteStationManager::AddBasicMode(WifiMode mode)
1850{
1851 NS_LOG_FUNCTION(this << mode);
1853 {
1854 NS_FATAL_ERROR("It is not allowed to add a HT rate in the BSSBasicRateSet!");
1855 }
1856 for (uint8_t i = 0; i < GetNBasicModes(); i++)
1857 {
1858 if (GetBasicMode(i) == mode)
1859 {
1860 return;
1861 }
1862 }
1863 m_bssBasicRateSet.push_back(mode);
1864}
1865
1866uint8_t
1867WifiRemoteStationManager::GetNBasicModes() const
1868{
1869 return static_cast<uint8_t>(m_bssBasicRateSet.size());
1870}
1871
1873WifiRemoteStationManager::GetBasicMode(uint8_t i) const
1874{
1875 NS_ASSERT(i < GetNBasicModes());
1876 return m_bssBasicRateSet[i];
1877}
1878
1880WifiRemoteStationManager::GetNNonErpBasicModes() const
1881{
1882 uint32_t size = 0;
1883 for (auto i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++)
1884 {
1885 if (i->GetModulationClass() == WIFI_MOD_CLASS_ERP_OFDM)
1886 {
1887 continue;
1888 }
1889 size++;
1890 }
1891 return size;
1892}
1893
1895WifiRemoteStationManager::GetNonErpBasicMode(uint8_t i) const
1896{
1897 NS_ASSERT(i < GetNNonErpBasicModes());
1898 uint32_t index = 0;
1899 bool found = false;
1900 for (auto j = m_bssBasicRateSet.begin(); j != m_bssBasicRateSet.end();)
1901 {
1902 if (i == index)
1903 {
1904 found = true;
1905 }
1906 if (j->GetModulationClass() != WIFI_MOD_CLASS_ERP_OFDM)
1907 {
1908 if (found)
1909 {
1910 break;
1911 }
1912 }
1913 index++;
1914 j++;
1915 }
1916 return m_bssBasicRateSet[index];
1917}
1918
1919void
1920WifiRemoteStationManager::AddBasicMcs(WifiMode mcs)
1921{
1922 NS_LOG_FUNCTION(this << +mcs.GetMcsValue());
1923 for (uint8_t i = 0; i < GetNBasicMcs(); i++)
1924 {
1925 if (GetBasicMcs(i) == mcs)
1926 {
1927 return;
1928 }
1929 }
1930 m_bssBasicMcsSet.push_back(mcs);
1931}
1932
1933uint8_t
1934WifiRemoteStationManager::GetNBasicMcs() const
1935{
1936 return static_cast<uint8_t>(m_bssBasicMcsSet.size());
1937}
1938
1940WifiRemoteStationManager::GetBasicMcs(uint8_t i) const
1941{
1942 NS_ASSERT(i < GetNBasicMcs());
1943 return m_bssBasicMcsSet[i];
1944}
1945
1947WifiRemoteStationManager::GetNonUnicastMode() const
1948{
1949 if (m_nonUnicastMode == WifiMode())
1950 {
1951 if (GetNBasicModes() > 0)
1952 {
1953 return GetBasicMode(0);
1954 }
1955 else
1956 {
1957 return GetDefaultMode();
1958 }
1959 }
1960 else
1961 {
1962 return m_nonUnicastMode;
1963 }
1964}
1965
1967WifiRemoteStationManager::GetGroupcastTxVector(const WifiMacHeader& header, MHz_u allowedWidth)
1968{
1969 const auto& to = header.GetAddr1();
1970 NS_ASSERT(to.IsGroup());
1971
1972 WifiTxVector groupcastTxVector{};
1973 const auto mode = GetNonUnicastMode();
1974 groupcastTxVector.SetMode(mode);
1975 groupcastTxVector.SetPreambleType(
1976 GetPreambleForTransmission(mode.GetModulationClass(), GetShortPreambleEnabled()));
1977 groupcastTxVector.SetTxPowerLevel(m_defaultTxPowerLevel);
1978 groupcastTxVector.SetChannelWidth(m_wifiPhy->GetTxBandwidth(mode, allowedWidth));
1979 groupcastTxVector.SetNTx(GetNumberOfAntennas());
1980
1981 if (to.IsBroadcast())
1982 {
1983 return groupcastTxVector;
1984 }
1985
1986 auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
1987 if (!apMac)
1988 {
1989 return groupcastTxVector;
1990 }
1991
1992 auto gcrManager = apMac->GetGcrManager();
1993 if (!gcrManager)
1994 {
1995 return groupcastTxVector;
1996 }
1997
1998 const auto& groupStas = gcrManager->GetMemberStasForGroupAddress(to);
1999 if (groupStas.empty())
2000 {
2001 return groupcastTxVector;
2002 }
2003
2004 if (!gcrManager->UseConcealment(header))
2005 {
2006 return groupcastTxVector;
2007 }
2008
2009 // If we are here, that means the mode will be used for the transmission of a groupcast frame
2010 // using the GCR service. We should loop over each member STA that is going to receive the
2011 // groupcast frame and select the highest possible mode over all STAs.
2012 std::optional<WifiMode> groupcastMode;
2013 auto maxWidth = allowedWidth;
2014 auto maxNss = m_wifiPhy->GetMaxSupportedTxSpatialStreams();
2015 std::map<WifiModulationClass, Time> minGisPerMc{/* non-HT OFDM is always 800 ns */
2018 const std::map<WifiModulationClass, WifiModulationClass> giRefModClass{
2019 /* HT/VHT: short or long GI */
2022 /* HE/EHT: 3 possible GIs */
2025 for (const auto& staAddress : groupStas)
2026 {
2027 // Get the equivalent TXVECTOR if the frame would be a unicast frame to that STA in order to
2028 // get what rate would be selected for that STA.
2030 hdr.SetAddr1(staAddress);
2031 const auto unicastTxVector = GetDataTxVector(hdr, allowedWidth);
2032
2033 // update the groupcast mode if:
2034 // - this is the first mode to inspect;
2035 // - this mode has a lower modulation class than the currently selected groupcast mode;
2036 // - when the modulation class is similar, this mode has a lower MCS than the currently
2037 // selected groupcast mode.
2038 if (!groupcastMode.has_value() ||
2039 (unicastTxVector.GetModulationClass() < groupcastMode->GetModulationClass()) ||
2040 ((unicastTxVector.GetModulationClass() == groupcastMode->GetModulationClass()) &&
2041 (unicastTxVector.GetMode().GetMcsValue() < groupcastMode->GetMcsValue())))
2042 {
2043 groupcastMode = unicastTxVector.GetMode();
2044 }
2045 maxWidth = std::min(unicastTxVector.GetChannelWidth(), maxWidth);
2046 maxNss = std::min(unicastTxVector.GetNss(), maxNss);
2047 auto mc = unicastTxVector.GetModulationClass();
2048 if (const auto it = giRefModClass.find(mc); it != giRefModClass.cend())
2049 {
2050 mc = it->second;
2051 }
2052 if (auto it = minGisPerMc.find(mc); it != minGisPerMc.end())
2053 {
2054 it->second = std::max(unicastTxVector.GetGuardInterval(), it->second);
2055 }
2056 }
2057 NS_ASSERT(groupcastMode.has_value());
2058
2059 groupcastTxVector.SetMode(*groupcastMode);
2060 groupcastTxVector.SetPreambleType(
2061 GetPreambleForTransmission(groupcastMode->GetModulationClass(), GetShortPreambleEnabled()));
2062 groupcastTxVector.SetChannelWidth(maxWidth);
2063 groupcastTxVector.SetNss(maxNss);
2064 auto mc = groupcastMode->GetModulationClass();
2065 if (const auto it = giRefModClass.find(mc); it != giRefModClass.cend())
2066 {
2067 mc = it->second;
2068 }
2069 if (const auto it = minGisPerMc.find(mc); it != minGisPerMc.cend())
2070 {
2071 groupcastTxVector.SetGuardInterval(it->second);
2072 }
2073
2074 return groupcastTxVector;
2075}
2076
2077bool
2078WifiRemoteStationManager::DoNeedRts(WifiRemoteStation* station, uint32_t size, bool normally)
2079{
2080 return normally;
2081}
2082
2083bool
2084WifiRemoteStationManager::DoNeedFragmentation(WifiRemoteStation* station,
2085 Ptr<const Packet> packet,
2086 bool normally)
2087{
2088 return normally;
2089}
2090
2091void
2092WifiRemoteStationManager::DoReportAmpduTxStatus(WifiRemoteStation* station,
2093 uint16_t nSuccessfulMpdus,
2094 uint16_t nFailedMpdus,
2095 double rxSnr,
2096 double dataSnr,
2097 MHz_u dataChannelWidth,
2098 uint8_t dataNss)
2099{
2100 NS_LOG_DEBUG("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
2101}
2102
2104WifiRemoteStationManager::GetSupported(const WifiRemoteStation* station, uint8_t i) const
2105{
2106 NS_ASSERT(i < GetNSupported(station));
2107 return station->m_state->m_operationalRateSet[i];
2108}
2109
2111WifiRemoteStationManager::GetMcsSupported(const WifiRemoteStation* station, uint8_t i) const
2112{
2113 NS_ASSERT(i < GetNMcsSupported(station));
2114 return station->m_state->m_operationalMcsSet[i];
2115}
2116
2118WifiRemoteStationManager::GetNonErpSupported(const WifiRemoteStation* station, uint8_t i) const
2119{
2120 NS_ASSERT(i < GetNNonErpSupported(station));
2121 // IEEE 802.11g standard defines that if the protection mechanism is enabled, RTS, CTS and
2122 // CTS-To-Self frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b
2123 // basic rate. This is a implemented here to avoid changes in every RAA, but should maybe be
2124 // moved in case it breaks standard rules.
2125 uint32_t index = 0;
2126 bool found = false;
2127 for (auto j = station->m_state->m_operationalRateSet.begin();
2128 j != station->m_state->m_operationalRateSet.end();)
2129 {
2130 if (i == index)
2131 {
2132 found = true;
2133 }
2134 if (j->GetModulationClass() != WIFI_MOD_CLASS_ERP_OFDM)
2135 {
2136 if (found)
2137 {
2138 break;
2139 }
2140 }
2141 index++;
2142 j++;
2143 }
2144 return station->m_state->m_operationalRateSet[index];
2145}
2146
2148WifiRemoteStationManager::GetAddress(const WifiRemoteStation* station) const
2149{
2150 return station->m_state->m_address;
2151}
2152
2153MHz_u
2154WifiRemoteStationManager::GetChannelWidth(const WifiRemoteStation* station) const
2155{
2156 return station->m_state->m_channelWidth;
2157}
2158
2159bool
2160WifiRemoteStationManager::GetShortGuardIntervalSupported(const WifiRemoteStation* station) const
2161{
2162 Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
2163
2164 if (!htCapabilities)
2165 {
2166 return false;
2167 }
2168 return htCapabilities->GetShortGuardInterval20();
2169}
2170
2171Time
2172WifiRemoteStationManager::GetGuardInterval(const WifiRemoteStation* station) const
2173{
2174 return station->m_state->m_guardInterval;
2175}
2176
2177bool
2178WifiRemoteStationManager::GetAggregation(const WifiRemoteStation* station) const
2179{
2180 return station->m_state->m_aggregation;
2181}
2182
2183uint8_t
2184WifiRemoteStationManager::GetNumberOfSupportedStreams(const WifiRemoteStation* station) const
2185{
2186 const auto htCapabilities = station->m_state->m_htCapabilities;
2187
2188 if (!htCapabilities)
2189 {
2190 if (const auto heCapabilities = station->m_state->m_heCapabilities)
2191 {
2192 return heCapabilities->GetHighestNssSupported();
2193 }
2194 return 1;
2195 }
2196 return htCapabilities->GetRxHighestSupportedAntennas();
2197}
2198
2199uint8_t
2200WifiRemoteStationManager::GetNess(const WifiRemoteStation* station) const
2201{
2202 return station->m_state->m_ness;
2203}
2204
2206WifiRemoteStationManager::GetPhy() const
2207{
2208 return m_wifiPhy;
2209}
2210
2212WifiRemoteStationManager::GetMac() const
2213{
2214 return m_wifiMac;
2215}
2216
2217uint8_t
2218WifiRemoteStationManager::GetNSupported(const WifiRemoteStation* station) const
2219{
2220 return static_cast<uint8_t>(station->m_state->m_operationalRateSet.size());
2221}
2222
2223bool
2224WifiRemoteStationManager::GetQosSupported(const WifiRemoteStation* station) const
2225{
2226 return station->m_state->m_qosSupported;
2227}
2228
2229bool
2230WifiRemoteStationManager::GetHtSupported(const WifiRemoteStation* station) const
2231{
2232 return bool(station->m_state->m_htCapabilities);
2233}
2234
2235bool
2236WifiRemoteStationManager::GetVhtSupported(const WifiRemoteStation* station) const
2237{
2238 return bool(station->m_state->m_vhtCapabilities);
2239}
2240
2241bool
2242WifiRemoteStationManager::GetHeSupported(const WifiRemoteStation* station) const
2243{
2244 return bool(station->m_state->m_heCapabilities);
2245}
2246
2247bool
2248WifiRemoteStationManager::GetEhtSupported(const WifiRemoteStation* station) const
2249{
2250 return (bool)(station->m_state->m_ehtCapabilities);
2251}
2252
2253bool
2254WifiRemoteStationManager::GetEmlsrSupported(const WifiRemoteStation* station) const
2255{
2256 auto mleCommonInfo = station->m_state->m_mleCommonInfo;
2257 return mleCommonInfo && mleCommonInfo->m_emlCapabilities &&
2258 mleCommonInfo->m_emlCapabilities->emlsrSupport == 1;
2259}
2260
2261bool
2262WifiRemoteStationManager::GetEmlsrEnabled(const WifiRemoteStation* station) const
2263{
2264 return station->m_state->m_emlsrEnabled;
2265}
2266
2267uint8_t
2268WifiRemoteStationManager::GetNMcsSupported(const WifiRemoteStation* station) const
2269{
2270 return static_cast<uint8_t>(station->m_state->m_operationalMcsSet.size());
2271}
2272
2274WifiRemoteStationManager::GetNNonErpSupported(const WifiRemoteStation* station) const
2275{
2276 uint32_t size = 0;
2277 for (auto i = station->m_state->m_operationalRateSet.begin();
2278 i != station->m_state->m_operationalRateSet.end();
2279 i++)
2280 {
2281 if (i->GetModulationClass() == WIFI_MOD_CLASS_ERP_OFDM)
2282 {
2283 continue;
2284 }
2285 size++;
2286 }
2287 return size;
2288}
2289
2290MHz_u
2291WifiRemoteStationManager::GetChannelWidthSupported(Mac48Address address) const
2292{
2293 return LookupState(address)->m_channelWidth;
2294}
2295
2296bool
2297WifiRemoteStationManager::GetShortGuardIntervalSupported(Mac48Address address) const
2298{
2299 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
2300
2301 if (!htCapabilities)
2302 {
2303 return false;
2304 }
2305 return htCapabilities->GetShortGuardInterval20();
2306}
2307
2308uint8_t
2309WifiRemoteStationManager::GetNumberOfSupportedStreams(Mac48Address address) const
2310{
2311 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
2312
2313 if (!htCapabilities)
2314 {
2315 return 1;
2316 }
2317 return htCapabilities->GetRxHighestSupportedAntennas();
2318}
2319
2320uint8_t
2321WifiRemoteStationManager::GetNMcsSupported(Mac48Address address) const
2322{
2323 return static_cast<uint8_t>(LookupState(address)->m_operationalMcsSet.size());
2324}
2325
2326bool
2327WifiRemoteStationManager::GetDsssSupported(const Mac48Address& address) const
2328{
2329 return (LookupState(address)->m_dsssSupported);
2330}
2331
2332bool
2333WifiRemoteStationManager::GetErpOfdmSupported(const Mac48Address& address) const
2334{
2335 return (LookupState(address)->m_erpOfdmSupported);
2336}
2337
2338bool
2339WifiRemoteStationManager::GetOfdmSupported(const Mac48Address& address) const
2340{
2341 return (LookupState(address)->m_ofdmSupported);
2342}
2343
2344bool
2345WifiRemoteStationManager::GetHtSupported(Mac48Address address) const
2346{
2347 return bool(LookupState(address)->m_htCapabilities);
2348}
2349
2350bool
2351WifiRemoteStationManager::GetVhtSupported(Mac48Address address) const
2352{
2353 return bool(LookupState(address)->m_vhtCapabilities);
2354}
2355
2356bool
2357WifiRemoteStationManager::GetHeSupported(Mac48Address address) const
2358{
2359 return bool(LookupState(address)->m_heCapabilities);
2360}
2361
2362bool
2363WifiRemoteStationManager::GetEhtSupported(Mac48Address address) const
2364{
2365 return (bool)(LookupState(address)->m_ehtCapabilities);
2366}
2367
2368bool
2369WifiRemoteStationManager::GetEmlsrSupported(const Mac48Address& address) const
2370{
2371 auto mleCommonInfo = LookupState(address)->m_mleCommonInfo;
2372 return mleCommonInfo && mleCommonInfo->m_emlCapabilities &&
2373 mleCommonInfo->m_emlCapabilities->emlsrSupport == 1;
2374}
2375
2376bool
2377WifiRemoteStationManager::GetEmlsrEnabled(const Mac48Address& address) const
2378{
2379 if (auto stateIt = m_states.find(address); stateIt != m_states.cend())
2380 {
2381 return stateIt->second->m_emlsrEnabled;
2382 }
2383 return false;
2384}
2385
2386void
2387WifiRemoteStationManager::SetDefaultTxPowerLevel(uint8_t txPower)
2388{
2389 m_defaultTxPowerLevel = txPower;
2390}
2391
2392uint8_t
2393WifiRemoteStationManager::GetNumberOfAntennas() const
2394{
2395 return m_wifiPhy->GetNumberOfAntennas();
2396}
2397
2398uint8_t
2399WifiRemoteStationManager::GetMaxNumberOfTransmitStreams() const
2400{
2401 return m_wifiPhy->GetMaxSupportedTxSpatialStreams();
2402}
2403
2404bool
2405WifiRemoteStationManager::UseLdpcForDestination(Mac48Address dest) const
2406{
2407 return (GetLdpcSupported() && GetLdpcSupported(dest));
2408}
2409
2410} // 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:1432
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:196
WifiModulationClass GetModulationClass() const
Definition wifi-mode.cc:173
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
Definition wifi-mode.cc:110
uint8_t GetMcsValue() const
Definition wifi-mode.cc:151
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:1124
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Definition wifi-phy.cc:1070
MHz_u GetChannelWidth() const
Definition wifi-phy.cc:1100
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
Definition wifi-phy.cc:648
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:2132
std::list< WifiMode > GetModeList() const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition wifi-phy.cc:2083
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:1433
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1453
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:251
#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:1381
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1345
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:78
double snr
SNR in linear scale.
Definition wifi-types.h:79
dBm_u rssi
RSSI.
Definition wifi-types.h:80
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