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
40
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(
80 "RtsCtsThreshold",
81 "If the size of the PSDU is bigger than this value, we use an RTS/CTS "
82 "handshake before sending the data frame."
83 "This value will not have any effect on some rate control algorithms.",
87 .AddAttribute("RtsCtsTxDurationThresh",
88 "If this threshold is a strictly positive value and the TX duration of "
89 "the PSDU is greater than or equal to this threshold, we use an RTS/CTS "
90 "handshake before sending the data frame.",
91 TimeValue(),
94 .AddAttribute(
95 "FragmentationThreshold",
96 "If the size of the PSDU is bigger than this value, we fragment it such that the "
97 "size of the fragments are equal or smaller. "
98 "This value does not apply when it is carried in an A-MPDU. "
99 "This value will not have any effect on some rate control algorithms.",
104 .AddAttribute("NonUnicastMode",
105 "Wifi mode used for non-unicast transmissions.",
109 .AddAttribute(
110 "DefaultTxPowerLevel",
111 "Default power level to be used for transmissions. "
112 "This is the power level that is used by all those WifiManagers that do "
113 "not implement TX power control.",
114 UintegerValue(WIFI_MIN_TX_PWR_LEVEL), // corresponds to WifiPhy::TxPowerStart
117 std::numeric_limits<uint8_t>::max()))
118 .AddAttribute("ErpProtectionMode",
119 "Protection mode used when non-ERP STAs are connected to an ERP AP: "
120 "Rts-Cts or Cts-To-Self",
125 "Rts-Cts",
127 "Cts-To-Self"))
128 .AddAttribute("HtProtectionMode",
129 "Protection mode used when non-HT STAs are connected to a HT AP: Rts-Cts "
130 "or Cts-To-Self",
135 "Rts-Cts",
137 "Cts-To-Self"))
138 .AddTraceSource("MacTxRtsFailed",
139 "The transmission of a RTS by the MAC layer has failed",
141 "ns3::Mac48Address::TracedCallback")
142 .AddTraceSource("MacTxDataFailed",
143 "The transmission of a data packet by the MAC layer has failed",
145 "ns3::Mac48Address::TracedCallback")
146 .AddTraceSource(
147 "MacTxFinalRtsFailed",
148 "The transmission of a RTS has exceeded the maximum number of attempts",
150 "ns3::Mac48Address::TracedCallback")
151 .AddTraceSource(
152 "MacTxFinalDataFailed",
153 "The transmission of a data packet has exceeded the maximum number of attempts",
155 "ns3::Mac48Address::TracedCallback");
156 return tid;
157}
158
170
175
176void
182
183void
185{
186 NS_LOG_FUNCTION(this << phy);
187 // We need to track our PHY because it is the object that knows the
188 // full set of transmit rates that are supported. We need to know
189 // this in order to find the relevant mandatory rates when choosing a
190 // transmit rate for automatic control responses like
191 // acknowledgments.
192 m_wifiPhy = phy;
193}
194
195void
197{
198 NS_LOG_FUNCTION(this << mac);
199 // We need to track our MAC because it is the object that knows the
200 // full set of interframe spaces.
201 m_wifiMac = mac;
202}
203
204void
206{
207 NS_LOG_FUNCTION(this << +linkId);
208 m_linkId = linkId;
209}
210
211int64_t
213{
214 NS_LOG_FUNCTION(this << stream);
215 return 0;
216}
217
218void
220{
221 NS_LOG_FUNCTION(this << maxSsrc);
222 m_maxSsrc = maxSsrc;
223}
224
225void
227{
228 NS_LOG_FUNCTION(this << maxSlrc);
229 m_maxSlrc = maxSlrc;
230}
231
232void
234{
235 NS_LOG_FUNCTION(this << threshold);
236 m_rtsCtsThreshold = threshold;
237}
238
239void
245
246void
248{
249 NS_LOG_FUNCTION(this << enable);
250 m_shortPreambleEnabled = enable;
251}
252
253void
255{
256 NS_LOG_FUNCTION(this << enable);
257 m_shortSlotTimeEnabled = enable;
258}
259
260bool
265
266bool
271
272bool
274{
275 return (m_wifiPhy->GetDevice()->GetHtConfiguration() &&
276 m_wifiPhy->GetPhyBand() != WIFI_PHY_BAND_6GHZ);
277}
278
279bool
281{
282 return (m_wifiPhy->GetDevice()->GetVhtConfiguration() &&
283 m_wifiPhy->GetPhyBand() != WIFI_PHY_BAND_2_4GHZ &&
284 m_wifiPhy->GetPhyBand() != WIFI_PHY_BAND_6GHZ);
285}
286
287bool
289{
290 return bool(m_wifiPhy->GetDevice()->GetHeConfiguration());
291}
292
293bool
295{
296 return bool(m_wifiPhy->GetDevice()->GetEhtConfiguration());
297}
298
299bool
301{
302 if (auto htConfiguration = m_wifiPhy->GetDevice()->GetHtConfiguration())
303 {
304 return htConfiguration->m_ldpcSupported;
305 }
306 return false;
307}
308
309bool
311{
312 if (auto htConfiguration = m_wifiPhy->GetDevice()->GetHtConfiguration())
313 {
314 return htConfiguration->m_sgiSupported;
315 }
316 return false;
317}
318
319Time
321{
322 Time gi{};
323 if (GetHeSupported())
324 {
325 Ptr<HeConfiguration> heConfiguration = m_wifiPhy->GetDevice()->GetHeConfiguration();
326 NS_ASSERT(heConfiguration); // If HE is supported, we should have a HE configuration
327 // attached
328 gi = heConfiguration->GetGuardInterval();
329 }
330 return gi;
331}
332
338
339void
341 bool isShortPreambleSupported)
342{
343 NS_LOG_FUNCTION(this << address << isShortPreambleSupported);
344 NS_ASSERT(!address.IsGroup());
345 LookupState(address)->m_shortPreamble = isShortPreambleSupported;
346}
347
348void
350 bool isShortSlotTimeSupported)
351{
352 NS_LOG_FUNCTION(this << address << isShortSlotTimeSupported);
353 NS_ASSERT(!address.IsGroup());
354 LookupState(address)->m_shortSlotTime = isShortSlotTimeSupported;
355}
356
357void
359{
360 NS_LOG_FUNCTION(this << address << mode);
361 NS_ASSERT(!address.IsGroup());
362 auto state = LookupState(address);
363 for (const auto& i : state->m_operationalRateSet)
364 {
365 if (i == mode)
366 {
367 return; // already in
368 }
369 }
370 if ((mode.GetModulationClass() == WIFI_MOD_CLASS_DSSS) ||
372 {
373 state->m_dsssSupported = true;
374 }
376 {
377 state->m_erpOfdmSupported = true;
378 }
379 else if (mode.GetModulationClass() == WIFI_MOD_CLASS_OFDM)
380 {
381 state->m_ofdmSupported = true;
382 }
383 state->m_operationalRateSet.push_back(mode);
384}
385
386void
388{
389 NS_LOG_FUNCTION(this << address);
390 NS_ASSERT(!address.IsGroup());
391 auto state = LookupState(address);
392 state->m_operationalRateSet.clear();
393 for (const auto& mode : m_wifiPhy->GetModeList())
394 {
395 state->m_operationalRateSet.push_back(mode);
396 if (mode.IsMandatory())
397 {
398 AddBasicMode(mode);
399 }
400 }
401}
402
403void
405{
406 NS_LOG_FUNCTION(this << address);
407 NS_ASSERT(!address.IsGroup());
408 auto state = LookupState(address);
409
410 const auto& mcsList = m_wifiPhy->GetMcsList();
411 state->m_operationalMcsSet = WifiModeList(mcsList.begin(), mcsList.end());
412}
413
414void
416{
417 NS_LOG_FUNCTION(this << address);
418 NS_ASSERT(!address.IsGroup());
419 LookupState(address)->m_operationalMcsSet.clear();
420}
421
422void
424{
425 NS_LOG_FUNCTION(this << address << mcs);
426 NS_ASSERT(!address.IsGroup());
427 auto state = LookupState(address);
428 for (const auto& i : state->m_operationalMcsSet)
429 {
430 if (i == mcs)
431 {
432 return; // already in
433 }
434 }
435 state->m_operationalMcsSet.push_back(mcs);
436}
437
438bool
440{
441 return LookupState(address)->m_shortPreamble;
442}
443
444bool
446{
447 return LookupState(address)->m_shortSlotTime;
448}
449
450bool
452{
453 return LookupState(address)->m_qosSupported;
454}
455
456bool
458{
459 if (address.IsGroup())
460 {
461 return false;
462 }
463 return LookupState(address)->m_state == WifiRemoteStationState::BRAND_NEW;
464}
465
466bool
468{
469 if (address.IsGroup())
470 {
471 return true;
472 }
473 return LookupState(address)->m_state == WifiRemoteStationState::GOT_ASSOC_TX_OK;
474}
475
476bool
478{
479 if (address.IsGroup())
480 {
481 return false;
482 }
483 return LookupState(address)->m_state == WifiRemoteStationState::WAIT_ASSOC_TX_OK;
484}
485
486void
492
493void
499
500void
506
507void
513
514void
516{
517 NS_ASSERT(!address.IsGroup());
519}
520
521bool
523{
524 if (address.IsGroup())
525 {
526 return false;
527 }
528 return LookupState(address)->m_state == WifiRemoteStationState::ASSOC_REFUSED;
529}
530
531bool
533{
534 if (address.IsGroup())
535 {
536 return false;
537 }
538 return LookupState(address)->m_state == WifiRemoteStationState::ADHOC_PEER;
539}
540
541void
547
548uint16_t
550{
551 std::shared_ptr<WifiRemoteStationState> state;
552 if (!remoteAddress.IsGroup() &&
553 (state = LookupState(remoteAddress))->m_state == WifiRemoteStationState::GOT_ASSOC_TX_OK)
554 {
555 return state->m_aid;
556 }
557 return SU_STA_ID;
558}
559
560uint16_t
562{
563 NS_LOG_FUNCTION(this << address << txVector);
564
565 uint16_t staId = SU_STA_ID;
566
567 if (txVector.IsMu())
568 {
569 if (m_wifiMac->GetTypeOfStation() == AP)
570 {
571 staId = GetAssociationId(address);
572 }
573 else if (m_wifiMac->GetTypeOfStation() == STA)
574 {
576 if (staMac->IsAssociated())
577 {
578 staId = staMac->GetAssociationId();
579 }
580 }
581 }
582
583 NS_LOG_DEBUG("Returning STAID = " << staId);
584 return staId;
585}
586
587bool
589{
590 return LookupState(address)->m_isInPsMode;
591}
592
593void
594WifiRemoteStationManager::SetPsMode(const Mac48Address& address, bool isInPsMode)
595{
596 LookupState(address)->m_isInPsMode = isInPsMode;
597}
598
599std::optional<Mac48Address>
601{
602 if (auto stateIt = m_states.find(address);
603 stateIt != m_states.end() && stateIt->second->m_mleCommonInfo)
604 {
605 return stateIt->second->m_mleCommonInfo->m_mldMacAddress;
606 }
607
608 return std::nullopt;
609}
610
611std::optional<Mac48Address>
613{
614 auto stateIt = m_states.find(mldAddress);
615
616 if (stateIt == m_states.end() || !stateIt->second->m_mleCommonInfo)
617 {
618 // MLD address not found
619 return std::nullopt;
620 }
621
622 NS_ASSERT(stateIt->second->m_mleCommonInfo->m_mldMacAddress == mldAddress);
623 return stateIt->second->m_address;
624}
625
628{
629 NS_LOG_FUNCTION(this << header << allowedWidth);
630 const auto address = header.GetAddr1();
631 if (!header.IsMgt() && address.IsGroup())
632 {
633 return GetGroupcastTxVector(header, allowedWidth);
634 }
635 WifiTxVector txVector;
636 if (header.IsMgt())
637 {
638 // Use the lowest basic rate for management frames
639 WifiMode mgtMode;
640 if (GetNBasicModes() > 0)
641 {
642 mgtMode = GetBasicMode(0);
643 }
644 else
645 {
646 mgtMode = GetDefaultMode();
647 }
648 txVector.SetMode(mgtMode);
649 txVector.SetPreambleType(
652 auto channelWidth = allowedWidth;
653 if (!header.GetAddr1().IsGroup())
654 {
655 if (const auto rxWidth = GetChannelWidthSupported(header.GetAddr1());
656 rxWidth < channelWidth)
657 {
658 channelWidth = rxWidth;
659 }
660 }
661
662 txVector.SetChannelWidth(m_wifiPhy->GetTxBandwidth(mgtMode, channelWidth));
663 txVector.SetGuardInterval(GetGuardIntervalForMode(mgtMode, m_wifiPhy->GetDevice()));
664 }
665 else
666 {
667 txVector = DoGetDataTxVector(Lookup(address), allowedWidth);
669 ? false
670 : UseLdpcForDestination(address));
671 }
672 Ptr<HeConfiguration> heConfiguration = m_wifiPhy->GetDevice()->GetHeConfiguration();
673 if (heConfiguration)
674 {
675 txVector.SetBssColor(heConfiguration->m_bssColor);
676 }
677 // If both the allowed width and the TXVECTOR channel width are integer multiple
678 // of 20 MHz, then the TXVECTOR channel width must not exceed the allowed width
679 NS_ASSERT_MSG((static_cast<uint16_t>(txVector.GetChannelWidth()) % 20 != 0) ||
680 (static_cast<uint16_t>(allowedWidth) % 20 != 0) ||
681 (txVector.GetChannelWidth() <= allowedWidth),
682 "TXVECTOR channel width (" << txVector.GetChannelWidth()
683 << " MHz) exceeds allowed width (" << allowedWidth
684 << " MHz)");
685 return txVector;
686}
687
690{
691 WifiMode defaultMode = GetDefaultMode();
692 WifiPreamble defaultPreamble;
693 if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_EHT)
694 {
695 defaultPreamble = WIFI_PREAMBLE_EHT_MU;
696 }
697 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_HE)
698 {
699 defaultPreamble = WIFI_PREAMBLE_HE_SU;
700 }
701 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_VHT)
702 {
703 defaultPreamble = WIFI_PREAMBLE_VHT_SU;
704 }
705 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_HT)
706 {
707 defaultPreamble = WIFI_PREAMBLE_HT_MF;
708 }
709 else
710 {
711 defaultPreamble = WIFI_PREAMBLE_LONG;
712 }
713
714 WifiTxVector v(defaultMode,
716 defaultPreamble,
717 GetGuardIntervalForMode(defaultMode, m_wifiPhy->GetDevice()),
719 1,
720 0,
721 m_wifiPhy->GetTxBandwidth(defaultMode),
722 false);
723
724 // The CTS-to-self must cover the bandwidth of the data transmission it protects,
725 // because the TXOP holder shall not transmit any PPDU in the TXOP with a bandwidth
726 // exceeding that of the CTS-to-self frame (Sec. 10.23.2.8 of 802.11-2024); use the
727 // non-HT duplicate format for bandwidths wider than 20 MHz
728 AdjustTxVectorForCtlResponse(v, allowedWidth);
729
730 return v;
731}
732
733void
735 MHz_u allowedWidth) const
736{
737 NS_LOG_FUNCTION(this << txVector << allowedWidth);
738
739 auto modulation = txVector.GetModulationClass();
740
741 if (allowedWidth >= 40 &&
742 (modulation == WIFI_MOD_CLASS_DSSS || modulation == WIFI_MOD_CLASS_HR_DSSS))
743 {
744 // control frame must be sent in a non-HT duplicate PPDU because it must protect a frame
745 // being transmitted on at least 40 MHz. Change the modulation class to ERP-OFDM and the
746 // rate to 6 Mbps
748 modulation = txVector.GetModulationClass();
749 }
750 // do not set allowedWidth as the TX width if the modulation class is (HR-)DSSS (allowedWidth
751 // may be 20 MHz) or allowedWidth is 22 MHz (the selected modulation class may be OFDM)
752 if (modulation != WIFI_MOD_CLASS_DSSS && modulation != WIFI_MOD_CLASS_HR_DSSS &&
753 allowedWidth != 22)
754 {
755 txVector.SetChannelWidth(allowedWidth);
756 }
757}
758
761{
762 NS_LOG_FUNCTION(this << address << allowedWidth);
764 if (address.IsGroup())
765 {
767 v.SetMode(mode);
768 v.SetPreambleType(
770 v.SetTxPowerLevel(m_defaultTxPowerLevel);
771 v.SetChannelWidth(m_wifiPhy->GetTxBandwidth(mode));
772 v.SetGuardInterval(GetGuardIntervalForMode(mode, m_wifiPhy->GetDevice()));
773 v.SetNTx(GetNumberOfAntennas());
774 v.SetNss(1);
775 v.SetNess(0);
776 }
777 else
778 {
779 v = DoGetRtsTxVector(Lookup(address));
780 }
781
782 AdjustTxVectorForCtlResponse(v, allowedWidth);
783
784 return v;
785}
786
789{
790 auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
791 NS_ASSERT(!to.IsGroup() ||
792 (m_wifiMac && (m_wifiMac->GetTypeOfStation() == AP) && apMac->GetGcrManager()));
793 WifiMode ctsMode = GetControlAnswerMode(rtsTxMode);
795 v.SetMode(ctsMode);
796 v.SetPreambleType(
798 v.SetTxPowerLevel(GetDefaultTxPowerLevel());
799 v.SetChannelWidth(m_wifiPhy->GetTxBandwidth(ctsMode));
800 v.SetGuardInterval(GetGuardIntervalForMode(ctsMode, m_wifiPhy->GetDevice()));
801 v.SetNss(1);
802 return v;
803}
804
805void
807{
808 NS_LOG_FUNCTION(this << txVector);
809
810 auto txMode = txVector.GetMode();
811 if (txMode.GetModulationClass() >= WIFI_MOD_CLASS_HT)
812 {
813 auto rate = txMode.GetDataRate(txVector);
814 if (rate >= 24e6)
815 {
816 rate = 24e6;
817 }
818 else if (rate >= 12e6)
819 {
820 rate = 12e6;
821 }
822 else
823 {
824 rate = 6e6;
825 }
827 if (m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_2_4GHZ)
828 {
829 txVector.SetMode(ErpOfdmPhy::GetErpOfdmRate(rate));
830 }
831 else
832 {
833 txVector.SetMode(OfdmPhy::GetOfdmRate(rate));
834 }
835 }
836}
837
840{
841 NS_ASSERT(!to.IsGroup());
842 WifiMode ackMode = GetControlAnswerMode(dataTxVector.GetMode(GetStaId(to, dataTxVector)));
844 v.SetMode(ackMode);
845 v.SetPreambleType(
847 v.SetTxPowerLevel(GetDefaultTxPowerLevel());
848 v.SetChannelWidth(m_wifiPhy->GetTxBandwidth(ackMode));
849 v.SetGuardInterval(GetGuardIntervalForMode(ackMode, m_wifiPhy->GetDevice()));
850 v.SetNss(1);
851
853
854 return v;
855}
856
859 const WifiTxVector& dataTxVector) const
860{
861 NS_ASSERT(!to.IsGroup());
862 WifiMode blockAckMode = GetControlAnswerMode(dataTxVector.GetMode(GetStaId(to, dataTxVector)));
864 v.SetMode(blockAckMode);
865 v.SetPreambleType(
867 v.SetTxPowerLevel(GetDefaultTxPowerLevel());
868 v.SetChannelWidth(m_wifiPhy->GetTxBandwidth(blockAckMode));
869 v.SetGuardInterval(GetGuardIntervalForMode(blockAckMode, m_wifiPhy->GetDevice()));
870 v.SetNss(1);
871
873
874 return v;
875}
876
879 const WifiTxVector& dataTxVector) const
880{
881 return GetBlockAckTxVector(to, dataTxVector);
882}
883
886{
888 hdr.SetAddr1(to);
889 auto txVector = GetDataTxVector(hdr, allowedWidth);
890 return GetBlockAckReqTxVector(to, txVector);
891}
892
895{
896 /**
897 * The standard has relatively unambiguous rules for selecting a
898 * control response rate (the below is quoted from IEEE 802.11-2012,
899 * Section 9.7):
900 *
901 * To allow the transmitting STA to calculate the contents of the
902 * Duration/ID field, a STA responding to a received frame shall
903 * transmit its Control Response frame (either CTS or Ack), other
904 * than the BlockAck control frame, at the highest rate in the
905 * BSSBasicRateSet parameter that is less than or equal to the
906 * rate of the immediately previous frame in the frame exchange
907 * sequence (as defined in Annex G) and that is of the same
908 * modulation class (see Section 9.7.8) as the received frame...
909 */
910 NS_LOG_FUNCTION(this << reqMode);
911 WifiMode mode = GetDefaultMode();
912 bool found = false;
913 // First, search the BSS Basic Rate set
914 for (uint8_t i = 0; i < GetNBasicModes(); i++)
915 {
916 WifiMode testMode = GetBasicMode(i);
917 if ((!found || testMode.IsHigherDataRate(mode)) && (!testMode.IsHigherDataRate(reqMode)) &&
919 testMode.GetModulationClass())))
920 {
921 mode = testMode;
922 // We've found a potentially-suitable transmit rate, but we
923 // need to continue and consider all the basic rates before
924 // we can be sure we've got the right one.
925 found = true;
926 }
927 }
928 if (m_wifiPhy->GetDevice()->GetHtConfiguration())
929 {
930 if (!found)
931 {
932 mode = GetDefaultMcs();
933 for (uint8_t i = 0; i != GetNBasicMcs(); i++)
934 {
935 WifiMode testMode = GetBasicMcs(i);
936 if ((!found || testMode.IsHigherDataRate(mode)) &&
937 (!testMode.IsHigherDataRate(reqMode)) &&
938 (testMode.GetModulationClass() == reqMode.GetModulationClass()))
939 {
940 mode = testMode;
941 // We've found a potentially-suitable transmit rate, but we
942 // need to continue and consider all the basic rates before
943 // we can be sure we've got the right one.
944 found = true;
945 }
946 }
947 }
948 }
949 // If we found a suitable rate in the BSSBasicRateSet, then we are
950 // done and can return that mode.
951 if (found)
952 {
953 NS_LOG_DEBUG("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
954 return mode;
955 }
956
957 /**
958 * If no suitable basic rate was found, we search the mandatory
959 * rates. The standard (IEEE 802.11-2007, Section 9.6) says:
960 *
961 * ...If no rate contained in the BSSBasicRateSet parameter meets
962 * these conditions, then the control frame sent in response to a
963 * received frame shall be transmitted at the highest mandatory
964 * rate of the PHY that is less than or equal to the rate of the
965 * received frame, and that is of the same modulation class as the
966 * received frame. In addition, the Control Response frame shall
967 * be sent using the same PHY options as the received frame,
968 * unless they conflict with the requirement to use the
969 * BSSBasicRateSet parameter.
970 *
971 * @todo Note that we're ignoring the last sentence for now, because
972 * there is not yet any manipulation here of PHY options.
973 */
974 for (const auto& thismode : m_wifiPhy->GetModeList())
975 {
976 /* If the rate:
977 *
978 * - is a mandatory rate for the PHY, and
979 * - is equal to or faster than our current best choice, and
980 * - is less than or equal to the rate of the received frame, and
981 * - is of the same modulation class as the received frame
982 *
983 * ...then it's our best choice so far.
984 */
985 if (thismode.IsMandatory() && (!found || thismode.IsHigherDataRate(mode)) &&
986 (!thismode.IsHigherDataRate(reqMode)) &&
988 thismode.GetModulationClass())))
989 {
990 mode = thismode;
991 // As above; we've found a potentially-suitable transmit
992 // rate, but we need to continue and consider all the
993 // mandatory rates before we can be sure we've got the right one.
994 found = true;
995 }
996 }
997 if (m_wifiPhy->GetDevice()->GetHtConfiguration())
998 {
999 for (const auto& thismode : m_wifiPhy->GetMcsList())
1000 {
1001 if (thismode.IsMandatory() && (!found || thismode.IsHigherDataRate(mode)) &&
1002 (!thismode.IsHigherCodeRate(reqMode)) &&
1003 (thismode.GetModulationClass() == reqMode.GetModulationClass()))
1004 {
1005 mode = thismode;
1006 // As above; we've found a potentially-suitable transmit
1007 // rate, but we need to continue and consider all the
1008 // mandatory rates before we can be sure we've got the right one.
1009 found = true;
1010 }
1011 }
1012 }
1013
1014 /**
1015 * If we still haven't found a suitable rate for the response then
1016 * someone has messed up the simulation configuration. This probably means
1017 * that the WifiPhyStandard is not set correctly, or that a rate that
1018 * is not supported by the PHY has been explicitly requested.
1019 *
1020 * Either way, it is serious - we can either disobey the standard or
1021 * fail, and I have chosen to do the latter...
1022 */
1023 if (!found)
1024 {
1025 NS_FATAL_ERROR("Can't find response rate for " << reqMode);
1026 }
1027
1028 NS_LOG_DEBUG("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1029 return mode;
1030}
1031
1032void
1034{
1035 NS_LOG_FUNCTION(this << header);
1036 const auto recipient = GetIndividuallyAddressedRecipient(m_wifiMac, header);
1037 NS_ASSERT(!recipient.IsGroup());
1038 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
1039 m_ssrc[ac]++;
1040 m_macTxRtsFailed(recipient);
1041 DoReportRtsFailed(Lookup(recipient));
1042}
1043
1044void
1046{
1047 NS_LOG_FUNCTION(this << *mpdu);
1048 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1049 AcIndex ac =
1050 QosUtilsMapTidToAc((mpdu->GetHeader().IsQosData()) ? mpdu->GetHeader().GetQosTid() : 0);
1051 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
1052 if (longMpdu)
1053 {
1054 m_slrc[ac]++;
1055 }
1056 else
1057 {
1058 m_ssrc[ac]++;
1059 }
1060 m_macTxDataFailed(mpdu->GetHeader().GetAddr1());
1061 DoReportDataFailed(Lookup(mpdu->GetHeader().GetAddr1()));
1062}
1063
1064void
1066 double ctsSnr,
1067 WifiMode ctsMode,
1068 double rtsSnr)
1069{
1070 NS_LOG_FUNCTION(this << header << ctsSnr << ctsMode << rtsSnr);
1071 const auto recipient = GetIndividuallyAddressedRecipient(m_wifiMac, header);
1072 NS_ASSERT(!recipient.IsGroup());
1073 WifiRemoteStation* station = Lookup(recipient);
1074 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
1075 station->m_state->m_info.NotifyTxSuccess(m_ssrc[ac]);
1076 m_ssrc[ac] = 0;
1077 DoReportRtsOk(station, ctsSnr, ctsMode, rtsSnr);
1078}
1079
1080void
1082 double ackSnr,
1083 WifiMode ackMode,
1084 double dataSnr,
1085 WifiTxVector dataTxVector)
1086{
1087 NS_LOG_FUNCTION(this << *mpdu << ackSnr << ackMode << dataSnr << dataTxVector);
1088 const WifiMacHeader& hdr = mpdu->GetHeader();
1089 NS_ASSERT(!hdr.GetAddr1().IsGroup());
1090 WifiRemoteStation* station = Lookup(hdr.GetAddr1());
1091 AcIndex ac = QosUtilsMapTidToAc((hdr.IsQosData()) ? hdr.GetQosTid() : 0);
1092 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
1093 if (longMpdu)
1094 {
1095 station->m_state->m_info.NotifyTxSuccess(m_slrc[ac]);
1096 m_slrc[ac] = 0;
1097 }
1098 else
1099 {
1100 station->m_state->m_info.NotifyTxSuccess(m_ssrc[ac]);
1101 m_ssrc[ac] = 0;
1102 }
1103 DoReportDataOk(station,
1104 ackSnr,
1105 ackMode,
1106 dataSnr,
1107 dataTxVector.GetChannelWidth(),
1108 dataTxVector.GetNss(GetStaId(hdr.GetAddr1(), dataTxVector)));
1109}
1110
1111void
1113{
1114 NS_LOG_FUNCTION(this << header);
1115 NS_ASSERT(!header.GetAddr1().IsGroup());
1116 WifiRemoteStation* station = Lookup(header.GetAddr1());
1117 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
1118 station->m_state->m_info.NotifyTxFailed();
1119 m_ssrc[ac] = 0;
1121 DoReportFinalRtsFailed(station);
1122}
1123
1124void
1126{
1127 NS_LOG_FUNCTION(this << *mpdu);
1128 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1129 WifiRemoteStation* station = Lookup(mpdu->GetHeader().GetAddr1());
1130 AcIndex ac =
1131 QosUtilsMapTidToAc((mpdu->GetHeader().IsQosData()) ? mpdu->GetHeader().GetQosTid() : 0);
1132 station->m_state->m_info.NotifyTxFailed();
1133 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
1134 if (longMpdu)
1135 {
1136 m_slrc[ac] = 0;
1137 }
1138 else
1139 {
1140 m_ssrc[ac] = 0;
1141 }
1142 m_macTxFinalDataFailed(mpdu->GetHeader().GetAddr1());
1143 DoReportFinalDataFailed(station);
1144}
1145
1146void
1148 RxSignalInfo rxSignalInfo,
1149 const WifiTxVector& txVector)
1150{
1151 NS_LOG_FUNCTION(this << address << rxSignalInfo << txVector);
1152 if (address.IsGroup())
1153 {
1154 return;
1155 }
1156 WifiRemoteStation* station = Lookup(address);
1157 DoReportRxOk(station, rxSignalInfo.snr, txVector.GetMode(GetStaId(address, txVector)));
1158 station->m_rssiAndUpdateTimePair = std::make_pair(rxSignalInfo.rssi, Simulator::Now());
1159}
1160
1161void
1163 uint16_t nSuccessfulMpdus,
1164 uint16_t nFailedMpdus,
1165 double rxSnr,
1166 double dataSnr,
1167 const WifiTxVector& dataTxVector)
1168{
1169 NS_LOG_FUNCTION(this << address << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr
1170 << dataTxVector);
1171 NS_ASSERT(!address.IsGroup());
1172 for (uint16_t i = 0; i < nFailedMpdus; i++)
1173 {
1174 m_macTxDataFailed(address);
1175 }
1177 nSuccessfulMpdus,
1178 nFailedMpdus,
1179 rxSnr,
1180 dataSnr,
1181 dataTxVector.GetChannelWidth(),
1182 dataTxVector.GetNss(GetStaId(address, dataTxVector)));
1183}
1184
1185std::list<Ptr<WifiMpdu>>
1187{
1188 NS_LOG_FUNCTION(this << *psdu);
1189
1190 auto* station = Lookup(GetIndividuallyAddressedRecipient(m_wifiMac, psdu->GetHeader(0)));
1191
1192 DoIncrementRetryCountOnTxFailure(station, psdu);
1193 return DoGetMpdusToDropOnTxFailure(station, psdu);
1194}
1195
1196void
1198 Ptr<WifiPsdu> psdu)
1199{
1200 NS_LOG_FUNCTION(this << *psdu);
1201
1202 // The frame retry count for an MSDU or A-MSDU that is not part of a block ack agreement or
1203 // for an MMPDU shall be incremented every time transmission fails for that MSDU, A-MSDU, or
1204 // MMPDU, including of an associated RTS (Sec. 10.23.2.12.1 of 802.11-2020).
1205 // Frames for which the retry count needs to be incremented:
1206 // - management frames
1207 // - non-QoS Data frames
1208 // - QoS Data frames that are not part of a Block Ack agreement
1209 // - QoS Data frames that are part of a Block Ack agreement if the IncrementRetryCountUnderBa
1210 // attribute is set to true
1211 const auto& hdr = psdu->GetHeader(0);
1212
1213 if (hdr.IsMgt() || (hdr.IsData() && !hdr.IsQosData()) ||
1214 (hdr.IsQosData() &&
1215 (!m_wifiMac->GetBaAgreementEstablishedAsOriginator(hdr.GetAddr1(), hdr.GetQosTid()) ||
1217 {
1218 psdu->IncrementRetryCount();
1219 }
1220}
1221
1222std::list<Ptr<WifiMpdu>>
1224 Ptr<WifiPsdu> psdu)
1225{
1226 NS_LOG_FUNCTION(this << *psdu);
1227
1228 std::list<Ptr<WifiMpdu>> mpdusToDrop;
1229
1230 for (const auto& mpdu : *PeekPointer(psdu))
1231 {
1232 if (mpdu->GetRetryCount() == m_wifiMac->GetFrameRetryLimit())
1233 {
1234 // this MPDU needs to be dropped
1235 mpdusToDrop.push_back(mpdu);
1236 }
1237 }
1238
1239 return mpdusToDrop;
1240}
1241
1242bool
1244{
1245 NS_LOG_FUNCTION(this << header << &txParams);
1246 auto address = header.GetAddr1();
1247 const auto isGcr = IsGcr(m_wifiMac, header);
1248 if (!isGcr && address.IsGroup())
1249 {
1250 return false;
1251 }
1252 if (isGcr)
1253 {
1255 auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
1256 apMac->GetGcrManager()->GetAttribute("GcrProtectionMode", enumValue);
1257 if (enumValue.Get() != GroupcastProtectionMode::RTS_CTS)
1258 {
1259 return false;
1260 }
1261 address = apMac->GetGcrManager()->GetIndividuallyAddressedRecipient(address);
1262 }
1263 const auto modulationClass = txParams.m_txVector.GetModulationClass();
1265 ((modulationClass == WIFI_MOD_CLASS_ERP_OFDM) || (modulationClass == WIFI_MOD_CLASS_HT) ||
1266 (modulationClass == WIFI_MOD_CLASS_VHT) || (modulationClass == WIFI_MOD_CLASS_HE) ||
1267 (modulationClass == WIFI_MOD_CLASS_EHT)) &&
1269 {
1271 "WifiRemoteStationManager::NeedRTS returning true to protect non-ERP stations");
1272 return true;
1273 }
1274 else if (m_htProtectionMode == RTS_CTS &&
1275 ((modulationClass == WIFI_MOD_CLASS_HT) || (modulationClass == WIFI_MOD_CLASS_VHT)) &&
1277 {
1278 NS_LOG_DEBUG("WifiRemoteStationManager::NeedRTS returning true to protect non-HT stations");
1279 return true;
1280 }
1281 NS_ASSERT(txParams.m_txDuration.has_value());
1282 auto size = txParams.GetSize(header.GetAddr1());
1283 bool normally =
1284 (size > m_rtsCtsThreshold) || (m_rtsCtsTxDurationThresh.IsStrictlyPositive() &&
1286 return DoNeedRts(Lookup(address), size, normally);
1287}
1288
1289bool
1291{
1292 NS_LOG_FUNCTION(this << txVector << header);
1295 (txVector.GetModulationClass() == WIFI_MOD_CLASS_HT) ||
1296 (txVector.GetModulationClass() == WIFI_MOD_CLASS_VHT) ||
1297 (txVector.GetModulationClass() == WIFI_MOD_CLASS_HE) ||
1298 (txVector.GetModulationClass() == WIFI_MOD_CLASS_EHT)))
1299 {
1301 "WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
1302 return true;
1303 }
1304 else if (m_htProtectionMode == CTS_TO_SELF &&
1305 ((txVector.GetModulationClass() == WIFI_MOD_CLASS_HT) ||
1306 (txVector.GetModulationClass() == WIFI_MOD_CLASS_VHT)) &&
1308 {
1310 "WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-HT stations");
1311 return true;
1312 }
1313 else if (IsGcr(m_wifiMac, header))
1314 {
1316 auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
1317 apMac->GetGcrManager()->GetAttribute("GcrProtectionMode", enumValue);
1318 if (enumValue.Get() == GroupcastProtectionMode::CTS_TO_SELF)
1319 {
1320 return true;
1321 }
1322 }
1323 // FIXME: commented out for now
1324 /*else if (!m_useNonErpProtection)
1325 {
1326 const auto mode = txVector.GetMode();
1327 // search for the BSS Basic Rate set, if the used mode is in the basic set then there is no
1328 // need for CTS To Self
1329 for (auto i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++)
1330 {
1331 if (mode == *i)
1332 {
1333 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning false");
1334 return false;
1335 }
1336 }
1337 if (m_wifiPhy->GetDevice()->GetHtConfiguration())
1338 {
1339 // search for the BSS Basic MCS set, if the used mode is in the basic set then there is
1340 // no need for CTS To Self
1341 for (auto i = m_bssBasicMcsSet.begin(); i != m_bssBasicMcsSet.end(); i++)
1342 {
1343 if (mode == *i)
1344 {
1345 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning false");
1346 return false;
1347 }
1348 }
1349 }
1350 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning true");
1351 return true;
1352 }*/
1353 return false;
1354}
1355
1356void
1358{
1359 NS_LOG_FUNCTION(this << enable);
1360 m_useNonErpProtection = enable;
1361}
1362
1363bool
1368
1369void
1371{
1372 NS_LOG_FUNCTION(this << enable);
1373 m_useNonHtProtection = enable;
1374}
1375
1376bool
1381
1382bool
1384{
1385 NS_LOG_FUNCTION(this << *mpdu);
1386 if (mpdu->GetHeader().GetAddr1().IsGroup())
1387 {
1388 return false;
1389 }
1390 bool normally = mpdu->GetSize() > GetFragmentationThreshold();
1391 NS_LOG_DEBUG("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha
1392 << normally);
1393 return DoNeedFragmentation(Lookup(mpdu->GetHeader().GetAddr1()), mpdu->GetPacket(), normally);
1394}
1395
1396void
1398{
1399 NS_LOG_FUNCTION(this << threshold);
1400 if (threshold < WIFI_MIN_FRAG_THRESHOLD)
1401 {
1402 NS_LOG_WARN("Fragmentation threshold should be larger than "
1403 << WIFI_MIN_FRAG_THRESHOLD << ". Setting to " << WIFI_MIN_FRAG_THRESHOLD
1404 << ".");
1406 }
1407 else
1408 {
1409 /*
1410 * The length of each fragment shall be an even number of octets, except for the last
1411 * fragment if an MSDU or MMPDU, which may be either an even or an odd number of octets.
1412 */
1413 if (threshold % 2 != 0)
1414 {
1415 NS_LOG_WARN("Fragmentation threshold should be an even number. Setting to "
1416 << threshold - 1);
1417 m_fragmentationThreshold = threshold - 1;
1418 }
1419 else
1420 {
1421 m_fragmentationThreshold = threshold;
1422 }
1423 }
1424}
1425
1431
1434{
1435 NS_LOG_FUNCTION(this << *mpdu);
1436 // The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1437 uint32_t nFragments =
1438 (mpdu->GetPacket()->GetSize() /
1439 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH));
1440
1441 // If the size of the last fragment is not 0.
1442 if ((mpdu->GetPacket()->GetSize() %
1443 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH)) > 0)
1444 {
1445 nFragments++;
1446 }
1447 NS_LOG_DEBUG("WifiRemoteStationManager::GetNFragments returning " << nFragments);
1448 return nFragments;
1449}
1450
1453{
1454 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1455 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1456 uint32_t nFragment = GetNFragments(mpdu);
1457 if (fragmentNumber >= nFragment)
1458 {
1459 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning 0");
1460 return 0;
1461 }
1462 // Last fragment
1463 if (fragmentNumber == nFragment - 1)
1464 {
1465 uint32_t lastFragmentSize =
1466 mpdu->GetPacket()->GetSize() -
1467 (fragmentNumber *
1468 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH));
1469 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
1470 return lastFragmentSize;
1471 }
1472 // All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1473 else
1474 {
1475 uint32_t fragmentSize =
1476 GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH;
1477 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
1478 return fragmentSize;
1479 }
1480}
1481
1484{
1485 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1486 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1487 NS_ASSERT(fragmentNumber < GetNFragments(mpdu));
1488 uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold() -
1489 mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH);
1490 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
1491 return fragmentOffset;
1492}
1493
1494bool
1496{
1497 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1498 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1499 bool isLast = fragmentNumber == (GetNFragments(mpdu) - 1);
1500 NS_LOG_DEBUG("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
1501 return isLast;
1502}
1503
1504uint8_t
1509
1512{
1513 return LookupState(address)->m_info;
1514}
1515
1516std::optional<dBm_u>
1518{
1519 auto station = Lookup(address);
1520 auto rssi = station->m_rssiAndUpdateTimePair.first;
1521 auto ts = station->m_rssiAndUpdateTimePair.second;
1522 if (ts.IsStrictlyPositive())
1523 {
1524 return rssi;
1525 }
1526 return std::nullopt;
1527}
1528
1529std::shared_ptr<WifiRemoteStationState>
1531{
1532 if (const auto stateIt = m_states.find(address); stateIt != m_states.cend())
1533 {
1534 return stateIt->second;
1535 }
1536
1537 auto state = std::make_shared<WifiRemoteStationState>();
1538 const_cast<WifiRemoteStationManager*>(this)->m_states.insert({address, state});
1539 ResetState(address);
1540 NS_LOG_DEBUG("WifiRemoteStationManager::LookupState returning new state");
1541 return state;
1542}
1543
1546{
1547 NS_LOG_FUNCTION(this << address);
1548 NS_ASSERT(!address.IsGroup());
1549 NS_ASSERT(address != m_wifiMac->GetAddress());
1550 auto stationIt = m_stations.find(address);
1551
1552 if (stationIt != m_stations.end())
1553 {
1554 return stationIt->second;
1555 }
1556
1558 station->m_state = LookupState(address).get();
1559 station->m_rssiAndUpdateTimePair = std::make_pair(dBm_u{0}, Seconds(0));
1560 const_cast<WifiRemoteStationManager*>(this)->m_stations.insert({address, station});
1561 return station;
1562}
1563
1564void
1566{
1567 NS_LOG_FUNCTION(this << address);
1568 if (const auto stateIt = m_states.find(address); stateIt != m_states.cend())
1569 {
1570 auto& state = stateIt->second;
1571 state->m_state = WifiRemoteStationState::BRAND_NEW;
1572 state->m_address = address;
1573 state->m_aid = 0;
1574 state->m_operationalRateSet = {GetDefaultMode()};
1575 state->m_operationalMcsSet = {GetDefaultMcs()};
1576 state->m_dsssSupported = false;
1577 state->m_erpOfdmSupported = false;
1578 state->m_ofdmSupported = false;
1579 state->m_htCapabilities = nullptr;
1580 state->m_htOperation = nullptr;
1581 state->m_vhtCapabilities = nullptr;
1582 state->m_vhtOperation = nullptr;
1583 state->m_heCapabilities = nullptr;
1584 state->m_heOperation = nullptr;
1585 state->m_ehtCapabilities = nullptr;
1586 state->m_ehtOperation = nullptr;
1587 state->m_mleCommonInfo = nullptr;
1588 state->m_emlsrEnabled = false;
1589 state->m_channelWidth = m_wifiPhy->GetChannelWidth();
1590 state->m_guardInterval = GetGuardInterval();
1591 state->m_ness = 0;
1592 state->m_aggregation = false;
1593 state->m_qosSupported = false;
1594 state->m_isInPsMode = false;
1595 }
1596}
1597
1598void
1600{
1601 NS_LOG_FUNCTION(this << remoteAddress << aid);
1602 LookupState(remoteAddress)->m_aid = aid;
1603}
1604
1605void
1607{
1608 NS_LOG_FUNCTION(this << from << qosSupported);
1609 LookupState(from)->m_qosSupported = qosSupported;
1610}
1611
1612void
1614{
1615 NS_LOG_FUNCTION(this << from << emlsrEnabled);
1616 LookupState(from)->m_emlsrEnabled = emlsrEnabled;
1617}
1618
1619void
1621 const HtCapabilities& htCapabilities)
1622{
1623 // Used by all stations to record HT capabilities of remote stations
1624 NS_LOG_FUNCTION(this << from << htCapabilities);
1625 auto state = LookupState(from);
1626 if (htCapabilities.GetSupportedChannelWidth() == 1)
1627 {
1628 state->m_channelWidth = MHz_u{40};
1629 }
1630 else
1631 {
1632 state->m_channelWidth = MHz_u{20};
1633 }
1634 SetQosSupport(from, true);
1635 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_HT))
1636 {
1637 if (htCapabilities.IsSupportedMcs(mcs.GetMcsValue()))
1638 {
1639 AddSupportedMcs(from, mcs);
1640 }
1641 }
1642 state->m_htCapabilities = Create<const HtCapabilities>(htCapabilities);
1643}
1644
1645void
1647{
1648 NS_LOG_FUNCTION(this << from << htOperation);
1649 auto state = LookupState(from);
1650 if (htOperation.GetStaChannelWidth() == 0)
1651 {
1652 state->m_channelWidth = MHz_u{20};
1653 }
1654 state->m_htOperation = Create<const HtOperation>(htOperation);
1655}
1656
1657void
1659 Mac48Address from,
1660 const ExtendedCapabilities& extendedCapabilities)
1661{
1662 NS_LOG_FUNCTION(this << from << extendedCapabilities);
1663 auto state = LookupState(from);
1664 state->m_extendedCapabilities = Create<const ExtendedCapabilities>(extendedCapabilities);
1665}
1666
1667void
1669 const VhtCapabilities& vhtCapabilities)
1670{
1671 // Used by all stations to record VHT capabilities of remote stations
1672 NS_LOG_FUNCTION(this << from << vhtCapabilities);
1673 auto state = LookupState(from);
1674 if (vhtCapabilities.GetSupportedChannelWidthSet() == 1)
1675 {
1676 state->m_channelWidth = MHz_u{160};
1677 }
1678 else
1679 {
1680 state->m_channelWidth = MHz_u{80};
1681 }
1682 for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams(); i++)
1683 {
1684 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_VHT))
1685 {
1686 if (vhtCapabilities.IsSupportedMcs(mcs.GetMcsValue(), i))
1687 {
1688 AddSupportedMcs(from, mcs);
1689 }
1690 }
1691 }
1692 state->m_vhtCapabilities = Create<const VhtCapabilities>(vhtCapabilities);
1693}
1694
1695void
1697 const VhtOperation& vhtOperation)
1698{
1699 NS_LOG_FUNCTION(this << from << vhtOperation);
1700 auto state = LookupState(from);
1701 /*
1702 * Table 9-274 (VHT Operation Information subfields) of 802.11-2020:
1703 * Set to 0 for 20 MHz or 40 MHz BSS bandwidth.
1704 * Set to 1 for 80 MHz, 160 MHz or 80+80 MHz BSS bandwidth.
1705 */
1706 if (vhtOperation.GetChannelWidth() == 0)
1707 {
1708 state->m_channelWidth = std::min(MHz_u{40}, state->m_channelWidth);
1709 }
1710 else if (vhtOperation.GetChannelWidth() == 1)
1711 {
1712 state->m_channelWidth = std::min(MHz_u{160}, state->m_channelWidth);
1713 }
1714 state->m_vhtOperation = Create<const VhtOperation>(vhtOperation);
1715}
1716
1719{
1720 return LookupState(from)->m_vhtOperation;
1721}
1722
1723void
1725 const HeCapabilities& heCapabilities)
1726{
1727 // Used by all stations to record HE capabilities of remote stations
1728 NS_LOG_FUNCTION(this << from << heCapabilities);
1729 auto state = LookupState(from);
1730 if ((m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_5GHZ) ||
1731 (m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_6GHZ))
1732 {
1733 if (heCapabilities.GetChannelWidthSet() & 0x04)
1734 {
1735 state->m_channelWidth = MHz_u{160};
1736 }
1737 else if (heCapabilities.GetChannelWidthSet() & 0x02)
1738 {
1739 state->m_channelWidth = MHz_u{80};
1740 }
1741 else if (heCapabilities.GetChannelWidthSet() == 0x00)
1742 {
1743 state->m_channelWidth = MHz_u{20};
1744 }
1745 // For other cases at 5 GHz, the supported channel width is set by the VHT capabilities
1746 }
1747 else if (m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_2_4GHZ)
1748 {
1749 if (heCapabilities.GetChannelWidthSet() & 0x01)
1750 {
1751 state->m_channelWidth = MHz_u{40};
1752 }
1753 else
1754 {
1755 state->m_channelWidth = MHz_u{20};
1756 }
1757 }
1758 if (heCapabilities.GetHeSuPpdu1xHeLtf800nsGi())
1759 {
1760 state->m_guardInterval = NanoSeconds(800);
1761 }
1762 else
1763 {
1764 // todo: Using 3200ns, default value for HeConfiguration::GuardInterval
1765 state->m_guardInterval = NanoSeconds(3200);
1766 }
1767 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_HE))
1768 {
1769 if (heCapabilities.GetHighestMcsSupported() >= mcs.GetMcsValue())
1770 {
1771 AddSupportedMcs(from, mcs);
1772 }
1773 }
1774 state->m_heCapabilities = Create<const HeCapabilities>(heCapabilities);
1775 SetQosSupport(from, true);
1776}
1777
1778void
1780{
1781 NS_LOG_FUNCTION(this << from << heOperation);
1782 auto state = LookupState(from);
1783 if (auto& operation6GHz = heOperation.m_6GHzOpInfo)
1784 {
1785 switch (operation6GHz->m_chWid)
1786 {
1787 case 0:
1788 state->m_channelWidth = MHz_u{20};
1789 break;
1790 case 1:
1791 state->m_channelWidth = MHz_u{40};
1792 break;
1793 case 2:
1794 state->m_channelWidth = MHz_u{80};
1795 break;
1796 case 3:
1797 state->m_channelWidth = MHz_u{160};
1798 break;
1799 default:
1800 NS_FATAL_ERROR("Invalid channel width value in 6 GHz Operation Information field");
1801 }
1802 }
1803 state->m_heOperation = Create<const HeOperation>(heOperation);
1804}
1805
1806void
1808 const Mac48Address& from,
1809 const He6GhzBandCapabilities& he6GhzCapabilities)
1810{
1811 // Used by all stations to record HE 6GHz band capabilities of remote stations
1812 NS_LOG_FUNCTION(this << from << he6GhzCapabilities);
1813 auto state = LookupState(from);
1814 state->m_he6GhzBandCapabilities = Create<const He6GhzBandCapabilities>(he6GhzCapabilities);
1815 SetQosSupport(from, true);
1816}
1817
1818void
1820 const EhtCapabilities& ehtCapabilities)
1821{
1822 // Used by all stations to record EHT capabilities of remote stations
1823 NS_LOG_FUNCTION(this << from << ehtCapabilities);
1824 auto state = LookupState(from);
1825 if (ehtCapabilities.m_phyCapabilities.support320MhzIn6Ghz &&
1826 (m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_6GHZ))
1827 {
1828 state->m_channelWidth = MHz_u{320};
1829 }
1830 // For other cases, the supported channel width is set by the HT/VHT capabilities
1831 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_EHT))
1832 {
1833 for (uint8_t mapType = 0; mapType < EhtMcsAndNssSet::EHT_MCS_MAP_TYPE_MAX; ++mapType)
1834 {
1835 if (ehtCapabilities.GetHighestSupportedRxMcs(
1836 static_cast<EhtMcsAndNssSet::EhtMcsMapType>(mapType)) >= mcs.GetMcsValue())
1837 {
1838 AddSupportedMcs(from, mcs);
1839 }
1840 }
1841 }
1842 state->m_ehtCapabilities = Create<const EhtCapabilities>(ehtCapabilities);
1843 SetQosSupport(from, true);
1844}
1845
1846void
1848 const EhtOperation& ehtOperation)
1849{
1850 NS_LOG_FUNCTION(this << from << ehtOperation);
1851 auto state = LookupState(from);
1852 if (auto opControl = ehtOperation.m_opInfo)
1853 {
1854 switch (opControl->control.channelWidth)
1855 {
1856 case 0:
1857 state->m_channelWidth = MHz_u{20};
1858 break;
1859 case 1:
1860 state->m_channelWidth = MHz_u{40};
1861 break;
1862 case 2:
1863 state->m_channelWidth = MHz_u{80};
1864 break;
1865 case 3:
1866 state->m_channelWidth = MHz_u{160};
1867 break;
1868 case 4:
1869 state->m_channelWidth = MHz_u{320};
1870 break;
1871 default:
1872 NS_FATAL_ERROR("Invalid channel width value in EHT Operation Information field");
1873 }
1874 }
1875 state->m_ehtOperation = Create<const EhtOperation>(ehtOperation);
1876}
1877
1878void
1880 Mac48Address from,
1881 const std::shared_ptr<CommonInfoBasicMle>& mleCommonInfo)
1882{
1883 NS_LOG_FUNCTION(this << from);
1884 auto state = LookupState(from);
1885 state->m_mleCommonInfo = mleCommonInfo;
1886 // insert another entry in m_states indexed by the MLD address and pointing to the same state
1887 const_cast<WifiRemoteStationManager*>(this)->m_states.insert_or_assign(
1888 mleCommonInfo->m_mldMacAddress,
1889 state);
1890}
1891
1894{
1895 return LookupState(from)->m_htCapabilities;
1896}
1897
1900{
1901 return LookupState(from)->m_htOperation;
1902}
1903
1906{
1907 return LookupState(from)->m_extendedCapabilities;
1908}
1909
1912{
1913 return LookupState(from)->m_vhtCapabilities;
1914}
1915
1918{
1919 return LookupState(from)->m_heCapabilities;
1920}
1921
1924{
1925 return LookupState(from)->m_heOperation;
1926}
1927
1930{
1931 return LookupState(from)->m_he6GhzBandCapabilities;
1932}
1933
1936{
1937 return LookupState(from)->m_ehtCapabilities;
1938}
1939
1942{
1943 return LookupState(from)->m_ehtOperation;
1944}
1945
1946std::optional<std::reference_wrapper<CommonInfoBasicMle::EmlCapabilities>>
1948{
1949 if (auto state = LookupState(from);
1950 state->m_mleCommonInfo && state->m_mleCommonInfo->m_emlCapabilities)
1951 {
1952 return state->m_mleCommonInfo->m_emlCapabilities.value();
1953 }
1954 return std::nullopt;
1955}
1956
1957std::optional<std::reference_wrapper<CommonInfoBasicMle::MldCapabilities>>
1959{
1960 if (auto state = LookupState(from);
1961 state->m_mleCommonInfo && state->m_mleCommonInfo->m_mldCapabilities)
1962 {
1963 return state->m_mleCommonInfo->m_mldCapabilities.value();
1964 }
1965 return std::nullopt;
1966}
1967
1968bool
1970{
1971 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
1972 Ptr<const VhtCapabilities> vhtCapabilities = LookupState(address)->m_vhtCapabilities;
1973 Ptr<const HeCapabilities> heCapabilities = LookupState(address)->m_heCapabilities;
1974 bool supported = false;
1975 if (htCapabilities)
1976 {
1977 supported |= htCapabilities->GetLdpc();
1978 }
1979 if (vhtCapabilities)
1980 {
1981 supported |= vhtCapabilities->GetRxLdpc();
1982 }
1983 if (heCapabilities)
1984 {
1985 supported |= heCapabilities->GetLdpcCodingInPayload();
1986 }
1987 return supported;
1988}
1989
1992{
1994 auto defaultTxMode = m_wifiPhy->GetDefaultMode();
1995 NS_ASSERT(defaultTxMode.IsMandatory());
1996 return defaultTxMode;
1997}
1998
2004
2007{
2008 NS_LOG_FUNCTION(this << st);
2009
2010 if ((!m_wifiPhy->GetDevice()->GetHtConfiguration()) ||
2012 {
2013 return GetDefaultMode();
2014 }
2015
2016 // find the highest modulation class supported by both stations
2018 if (GetHeSupported() && GetHeSupported(st))
2019 {
2020 modClass = WIFI_MOD_CLASS_HE;
2021 }
2022 else if (GetVhtSupported() && GetVhtSupported(st))
2023 {
2024 modClass = WIFI_MOD_CLASS_VHT;
2025 }
2026
2027 // return the MCS with lowest index
2028 return *m_wifiPhy->GetPhyEntity(modClass)->begin();
2029}
2030
2031void
2033{
2034 NS_LOG_FUNCTION(this);
2035 m_states.clear();
2036 for (auto& state : m_stations)
2037 {
2038 delete (state.second);
2039 }
2040 m_stations.clear();
2041 m_bssBasicRateSet.clear();
2042 m_bssBasicMcsSet.clear();
2043 m_ssrc.fill(0);
2044 m_slrc.fill(0);
2045}
2046
2047void
2049{
2050 NS_LOG_FUNCTION(this << mode);
2052 {
2053 NS_FATAL_ERROR("It is not allowed to add a HT rate in the BSSBasicRateSet!");
2054 }
2055 for (uint8_t i = 0; i < GetNBasicModes(); i++)
2056 {
2057 if (GetBasicMode(i) == mode)
2058 {
2059 return;
2060 }
2061 }
2062 m_bssBasicRateSet.push_back(mode);
2063}
2064
2065uint8_t
2067{
2068 return static_cast<uint8_t>(m_bssBasicRateSet.size());
2069}
2070
2073{
2075 return m_bssBasicRateSet[i];
2076}
2077
2080{
2081 uint32_t size = 0;
2082 for (auto i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++)
2083 {
2084 if (i->GetModulationClass() == WIFI_MOD_CLASS_ERP_OFDM)
2085 {
2086 continue;
2087 }
2088 size++;
2089 }
2090 return size;
2091}
2092
2095{
2097 uint32_t index = 0;
2098 bool found = false;
2099 for (auto j = m_bssBasicRateSet.begin(); j != m_bssBasicRateSet.end();)
2100 {
2101 if (i == index)
2102 {
2103 found = true;
2104 }
2105 if (j->GetModulationClass() != WIFI_MOD_CLASS_ERP_OFDM)
2106 {
2107 if (found)
2108 {
2109 break;
2110 }
2111 }
2112 index++;
2113 j++;
2114 }
2115 return m_bssBasicRateSet[index];
2116}
2117
2118void
2120{
2121 NS_LOG_FUNCTION(this << +mcs.GetMcsValue());
2122 for (uint8_t i = 0; i < GetNBasicMcs(); i++)
2123 {
2124 if (GetBasicMcs(i) == mcs)
2125 {
2126 return;
2127 }
2128 }
2129 m_bssBasicMcsSet.push_back(mcs);
2130}
2131
2132uint8_t
2134{
2135 return static_cast<uint8_t>(m_bssBasicMcsSet.size());
2136}
2137
2140{
2141 NS_ASSERT(i < GetNBasicMcs());
2142 return m_bssBasicMcsSet[i];
2143}
2144
2147{
2148 if (m_nonUnicastMode == WifiMode())
2149 {
2150 if (GetNBasicModes() > 0)
2151 {
2152 return GetBasicMode(0);
2153 }
2154 else
2155 {
2156 return GetDefaultMode();
2157 }
2158 }
2159 else
2160 {
2161 return m_nonUnicastMode;
2162 }
2163}
2164
2167{
2168 const auto& to = header.GetAddr1();
2169 NS_ASSERT(to.IsGroup());
2170
2171 WifiTxVector groupcastTxVector{};
2172 const auto mode = GetNonUnicastMode();
2173 groupcastTxVector.SetMode(mode);
2174 groupcastTxVector.SetPreambleType(
2175 GetPreambleForTransmission(mode.GetModulationClass(), GetShortPreambleEnabled()));
2176 groupcastTxVector.SetTxPowerLevel(m_defaultTxPowerLevel);
2177 groupcastTxVector.SetChannelWidth(m_wifiPhy->GetTxBandwidth(mode, allowedWidth));
2178 groupcastTxVector.SetNTx(GetNumberOfAntennas());
2179
2180 if (to.IsBroadcast())
2181 {
2182 return groupcastTxVector;
2183 }
2184
2185 auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
2186 if (!apMac)
2187 {
2188 return groupcastTxVector;
2189 }
2190
2191 auto gcrManager = apMac->GetGcrManager();
2192 if (!gcrManager)
2193 {
2194 return groupcastTxVector;
2195 }
2196
2197 const auto& groupStas = gcrManager->GetMemberStasForGroupAddress(to);
2198 if (groupStas.empty())
2199 {
2200 return groupcastTxVector;
2201 }
2202
2203 if (!gcrManager->UseConcealment(header))
2204 {
2205 return groupcastTxVector;
2206 }
2207
2208 // If we are here, that means the mode will be used for the transmission of a groupcast frame
2209 // using the GCR service. We should loop over each member STA that is going to receive the
2210 // groupcast frame and select the highest possible mode over all STAs.
2211 std::optional<WifiMode> groupcastMode;
2212 auto maxWidth = allowedWidth;
2213 auto maxNss = m_wifiPhy->GetMaxSupportedTxSpatialStreams();
2214 std::map<WifiModulationClass, Time> minGisPerMc{/* non-HT OFDM is always 800 ns */
2217 const std::map<WifiModulationClass, WifiModulationClass> giRefModClass{
2218 /* HT/VHT: short or long GI */
2221 /* HE/EHT: 3 possible GIs */
2224 for (const auto& staAddress : groupStas)
2225 {
2226 // Get the equivalent TXVECTOR if the frame would be a unicast frame to that STA in order to
2227 // get what rate would be selected for that STA.
2229 hdr.SetAddr1(staAddress);
2230 const auto unicastTxVector = GetDataTxVector(hdr, allowedWidth);
2231
2232 // update the groupcast mode if:
2233 // - this is the first mode to inspect;
2234 // - this mode has a lower modulation class than the currently selected groupcast mode;
2235 // - when the modulation class is similar, this mode has a lower MCS than the currently
2236 // selected groupcast mode.
2237 if (!groupcastMode.has_value() ||
2238 (unicastTxVector.GetModulationClass() < groupcastMode->GetModulationClass()) ||
2239 ((unicastTxVector.GetModulationClass() == groupcastMode->GetModulationClass()) &&
2240 (unicastTxVector.GetMode().GetMcsValue() < groupcastMode->GetMcsValue())))
2241 {
2242 groupcastMode = unicastTxVector.GetMode();
2243 }
2244 maxWidth = std::min(unicastTxVector.GetChannelWidth(), maxWidth);
2245 maxNss = std::min(unicastTxVector.GetNss(), maxNss);
2246 auto mc = unicastTxVector.GetModulationClass();
2247 if (const auto it = giRefModClass.find(mc); it != giRefModClass.cend())
2248 {
2249 mc = it->second;
2250 }
2251 if (auto it = minGisPerMc.find(mc); it != minGisPerMc.end())
2252 {
2253 it->second = std::max(unicastTxVector.GetGuardInterval(), it->second);
2254 }
2255 }
2256 NS_ASSERT(groupcastMode.has_value());
2257
2258 groupcastTxVector.SetMode(*groupcastMode);
2259 groupcastTxVector.SetPreambleType(
2260 GetPreambleForTransmission(groupcastMode->GetModulationClass(), GetShortPreambleEnabled()));
2261 groupcastTxVector.SetChannelWidth(maxWidth);
2262 groupcastTxVector.SetNss(maxNss);
2263 auto mc = groupcastMode->GetModulationClass();
2264 if (const auto it = giRefModClass.find(mc); it != giRefModClass.cend())
2265 {
2266 mc = it->second;
2267 }
2268 if (const auto it = minGisPerMc.find(mc); it != minGisPerMc.cend())
2269 {
2270 groupcastTxVector.SetGuardInterval(it->second);
2271 }
2272
2273 return groupcastTxVector;
2274}
2275
2276bool
2278{
2279 return normally;
2280}
2281
2282bool
2284 Ptr<const Packet> packet,
2285 bool normally)
2286{
2287 return normally;
2288}
2289
2290void
2292 uint16_t nSuccessfulMpdus,
2293 uint16_t nFailedMpdus,
2294 double rxSnr,
2295 double dataSnr,
2296 MHz_u dataChannelWidth,
2297 uint8_t dataNss)
2298{
2299 NS_LOG_DEBUG("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
2300}
2301
2304{
2305 NS_ASSERT(i < GetNSupported(station));
2306 return station->m_state->m_operationalRateSet[i];
2307}
2308
2311{
2312 NS_ASSERT(i < GetNMcsSupported(station));
2313 return station->m_state->m_operationalMcsSet[i];
2314}
2315
2318{
2319 NS_ASSERT(i < GetNNonErpSupported(station));
2320 // IEEE 802.11g standard defines that if the protection mechanism is enabled, RTS, CTS and
2321 // CTS-To-Self frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b
2322 // basic rate. This is a implemented here to avoid changes in every RAA, but should maybe be
2323 // moved in case it breaks standard rules.
2324 uint32_t index = 0;
2325 bool found = false;
2326 for (auto j = station->m_state->m_operationalRateSet.begin();
2327 j != station->m_state->m_operationalRateSet.end();)
2328 {
2329 if (i == index)
2330 {
2331 found = true;
2332 }
2333 if (j->GetModulationClass() != WIFI_MOD_CLASS_ERP_OFDM)
2334 {
2335 if (found)
2336 {
2337 break;
2338 }
2339 }
2340 index++;
2341 j++;
2342 }
2343 return station->m_state->m_operationalRateSet[index];
2344}
2345
2348{
2349 return station->m_state->m_address;
2350}
2351
2352MHz_u
2354{
2355 return station->m_state->m_channelWidth;
2356}
2357
2358bool
2360{
2361 Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
2362
2363 if (!htCapabilities)
2364 {
2365 return false;
2366 }
2367 return htCapabilities->GetShortGuardInterval20();
2368}
2369
2370Time
2372{
2373 return station->m_state->m_guardInterval;
2374}
2375
2376bool
2378{
2379 return station->m_state->m_aggregation;
2380}
2381
2382uint8_t
2384{
2385 const auto htCapabilities = station->m_state->m_htCapabilities;
2386
2387 if (!htCapabilities)
2388 {
2389 if (const auto heCapabilities = station->m_state->m_heCapabilities)
2390 {
2391 return heCapabilities->GetHighestNssSupported();
2392 }
2393 return 1;
2394 }
2395 return htCapabilities->GetRxHighestSupportedAntennas();
2396}
2397
2398uint8_t
2400{
2401 return station->m_state->m_ness;
2402}
2403
2406{
2407 return m_wifiPhy;
2408}
2409
2412{
2413 return m_wifiMac;
2414}
2415
2416uint8_t
2418{
2419 return static_cast<uint8_t>(station->m_state->m_operationalRateSet.size());
2420}
2421
2422bool
2424{
2425 return station->m_state->m_qosSupported;
2426}
2427
2428bool
2430{
2431 return bool(station->m_state->m_htCapabilities);
2432}
2433
2434bool
2436{
2437 return bool(station->m_state->m_vhtCapabilities);
2438}
2439
2440bool
2442{
2443 return bool(station->m_state->m_heCapabilities);
2444}
2445
2446bool
2448{
2449 return (bool)(station->m_state->m_ehtCapabilities);
2450}
2451
2452bool
2454{
2455 auto mleCommonInfo = station->m_state->m_mleCommonInfo;
2456 return mleCommonInfo && mleCommonInfo->m_emlCapabilities &&
2457 mleCommonInfo->m_emlCapabilities->emlsrSupport == 1;
2458}
2459
2460bool
2462{
2463 return station->m_state->m_emlsrEnabled;
2464}
2465
2466uint8_t
2468{
2469 return static_cast<uint8_t>(station->m_state->m_operationalMcsSet.size());
2470}
2471
2474{
2475 uint32_t size = 0;
2476 for (auto i = station->m_state->m_operationalRateSet.begin();
2477 i != station->m_state->m_operationalRateSet.end();
2478 i++)
2479 {
2480 if (i->GetModulationClass() == WIFI_MOD_CLASS_ERP_OFDM)
2481 {
2482 continue;
2483 }
2484 size++;
2485 }
2486 return size;
2487}
2488
2489MHz_u
2491{
2492 return LookupState(address)->m_channelWidth;
2493}
2494
2495bool
2497{
2498 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
2499
2500 if (!htCapabilities)
2501 {
2502 return false;
2503 }
2504 return htCapabilities->GetShortGuardInterval20();
2505}
2506
2507uint8_t
2509{
2510 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
2511
2512 if (!htCapabilities)
2513 {
2514 return 1;
2515 }
2516 return htCapabilities->GetRxHighestSupportedAntennas();
2517}
2518
2519uint8_t
2521{
2522 return static_cast<uint8_t>(LookupState(address)->m_operationalMcsSet.size());
2523}
2524
2525bool
2527{
2528 return (LookupState(address)->m_dsssSupported);
2529}
2530
2531bool
2533{
2534 return (LookupState(address)->m_erpOfdmSupported);
2535}
2536
2537bool
2539{
2540 return (LookupState(address)->m_ofdmSupported);
2541}
2542
2543bool
2545{
2546 return bool(LookupState(address)->m_htCapabilities);
2547}
2548
2549bool
2551{
2552 return bool(LookupState(address)->m_vhtCapabilities);
2553}
2554
2555bool
2557{
2558 return bool(LookupState(address)->m_heCapabilities);
2559}
2560
2561bool
2563{
2564 return (bool)(LookupState(address)->m_ehtCapabilities);
2565}
2566
2567bool
2569{
2570 auto mleCommonInfo = LookupState(address)->m_mleCommonInfo;
2571 return mleCommonInfo && mleCommonInfo->m_emlCapabilities &&
2572 mleCommonInfo->m_emlCapabilities->emlsrSupport == 1;
2573}
2574
2575bool
2577{
2578 if (auto stateIt = m_states.find(address); stateIt != m_states.cend())
2579 {
2580 return stateIt->second->m_emlsrEnabled;
2581 }
2582 return false;
2583}
2584
2585void
2590
2591uint8_t
2593{
2594 return m_wifiPhy->GetNumberOfAntennas();
2595}
2596
2597uint8_t
2599{
2600 return m_wifiPhy->GetMaxSupportedTxSpatialStreams();
2601}
2602
2603bool
2608
2609} // namespace ns3
uint32_t v
The IEEE 802.11be EHT Capabilities.
EhtPhyCapabilities m_phyCapabilities
EHT PHY Capabilities Info subfield.
uint8_t GetHighestSupportedRxMcs(EhtMcsAndNssSet::EhtMcsMapType mapType) const
Get the highest supported RX MCS for a given EHT-MCS map type.
EHT Operation Information Element.
std::optional< EhtOpInfo > m_opInfo
EHT Operation Information.
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()
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 HE Operation Information Element.
OptFieldWithPresenceInd< OpInfo6GHz > m_6GHzOpInfo
6 GHz Operation Information field
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.
The HT Operation Information Element.
uint8_t GetStaChannelWidth() const
Return the STA channel width.
static WifiMode GetHtMcs0()
an EUI-48 address
bool IsGroup() const
Object()
Caller graph was not generated because of its size.
Definition object.cc:93
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:403
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:191
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
a unique identifier for an interface.
Definition type-id.h:50
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1003
@ OBSOLETE
Attribute or trace source is not used anymore; simulation fails.
Definition type-id.h:67
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.
The VHT Operation Information Element.
uint8_t GetChannelWidth() const
Return the Channel Width field in the VHT Operation information element.
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:39
bool IsHigherDataRate(WifiMode mode) const
Definition wifi-mode.cc:195
WifiModulationClass GetModulationClass() const
Definition wifi-mode.cc:172
uint8_t GetMcsValue() const
Definition wifi-mode.cc:151
AttributeValue implementation for WifiMode.
Definition wifi-mode.h:258
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.
void AddStationHeOperation(Mac48Address from, const HeOperation &heOperation)
Records HE operation of the remote station.
bool GetQosSupported(Mac48Address address) const
Return whether the given station is QoS capable.
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, MHz_u allowedWidth)=0
uint8_t GetNumberOfSupportedStreams(Mac48Address address) const
Return the number of spatial streams supported by the station.
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.
uint8_t GetNess(const WifiRemoteStation *station) const
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
bool GetEmlsrEnabled(const Mac48Address &address) const
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< const HeOperation > GetStationHeOperation(Mac48Address from)
Return the HE operation sent by the remote station.
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.
WifiMode GetDefaultModeForSta(const WifiRemoteStation *st) const
Return the default MCS to use to transmit frames to the given station.
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.
void AddStationHtOperation(Mac48Address from, const HtOperation &htOperation)
Records HT operation of the remote station.
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 AddStationHeCapabilities(Mac48Address from, const HeCapabilities &heCapabilities)
Records HE capabilities of the remote station.
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.
void AdjustTxVectorForCtlResponse(WifiTxVector &txVector, MHz_u allowedWidth) const
Adjust the TXVECTOR for a control response frame to ensure that, if appropriate, the non-HT duplicate...
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.
void AddStationMleCommonInfo(Mac48Address from, const std::shared_ptr< CommonInfoBasicMle > &mleCommonInfo)
Records the Common Info field advertised by the given remote station in a Multi-Link Element.
virtual void DoReportDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
WifiTxVector GetCtsToSelfTxVector(MHz_u allowedWidth)
Since CTS-to-self parameters are not dependent on the station, it is implemented in wifi remote stati...
Ptr< const VhtOperation > GetStationVhtOperation(Mac48Address from)
Return the VHT operation sent by the remote station.
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.
uint32_t GetNNonErpBasicModes() const
Return the number of non-ERP basic modes we support.
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
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.
Ptr< const EhtOperation > GetStationEhtOperation(Mac48Address from)
Return the EHT operation sent by the remote station.
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...
WifiMode GetNonErpBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes that is not an ERP mode.
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.
Ptr< WifiPhy > GetPhy() const
Return the WifiPhy.
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
std::optional< std::reference_wrapper< CommonInfoBasicMle::EmlCapabilities > > GetStationEmlCapabilities(const Mac48Address &from)
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.
MHz_u GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
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
void RecordAdhocPeer(Mac48Address address)
Records that the STA is an adhoc peer.
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...
void AddBasicMcs(WifiMode mcs)
Add a given Modulation and Coding Scheme (MCS) index to the set of basic MCS.
uint8_t m_defaultTxPowerLevel
Default transmission power level.
bool GetErpOfdmSupported(const Mac48Address &address) const
Return whether the station supports ERP OFDM or not.
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.
Ptr< const HtCapabilities > GetStationHtCapabilities(Mac48Address from)
Return the HT capabilities sent by the remote station.
bool IsAdhocPeer(Mac48Address address) const
Return whether the station state is a known adhoc peer.
bool NeedFragmentation(Ptr< const WifiMpdu > mpdu)
void ReportAmpduTxStatus(Mac48Address address, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus, double rxSnr, double dataSnr, const WifiTxVector &dataTxVector)
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
Ptr< const He6GhzBandCapabilities > GetStationHe6GhzCapabilities(const Mac48Address &from) const
Return the HE 6 GHz Band Capabilities sent by a remote station.
bool GetDsssSupported(const Mac48Address &address) const
Return whether the station supports DSSS or not.
uint32_t GetFragmentOffset(Ptr< const WifiMpdu > mpdu, uint32_t fragmentNumber)
void SetQosSupport(Mac48Address from, bool qosSupported)
Records QoS support of the remote station.
void AddStationHe6GhzCapabilities(const Mac48Address &from, const He6GhzBandCapabilities &he6GhzCapabilities)
Records HE 6 GHz Band Capabilities of a remote station.
WifiRemoteStationInfo GetInfo(Mac48Address address)
bool GetOfdmSupported(const Mac48Address &address) const
Return whether the station supports OFDM or not.
uint32_t GetFragmentSize(Ptr< const WifiMpdu > mpdu, uint32_t fragmentNumber)
uint8_t GetNBasicMcs() const
Return the number of basic MCS index.
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
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.
void AddStationVhtCapabilities(Mac48Address from, const VhtCapabilities &vhtCapabilities)
Records VHT capabilities of the remote station.
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.
Ptr< WifiMac > GetMac() const
Return the WifiMac.
bool m_incrRetryCountUnderBa
whether to increment the retry count of frames that are part of a Block Ack agreement
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether non-ERP mode associated with the specified station at the specified index.
std::array< uint32_t, AC_BE_NQOS > m_ssrc
short retry count per AC
void AddStationEhtCapabilities(Mac48Address from, const EhtCapabilities &ehtCapabilities)
Records EHT capabilities of the remote station.
Ptr< const EhtCapabilities > GetStationEhtCapabilities(Mac48Address from)
Return the EHT capabilities sent by the remote station.
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).
Ptr< const HeCapabilities > GetStationHeCapabilities(Mac48Address from)
Return the HE capabilities sent by the remote station.
WifiMode GetBasicMcs(uint8_t i) const
Return the MCS at the given list index.
uint8_t GetNMcsSupported(Mac48Address address) const
Return the number of MCS supported by the station.
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 GetEmlsrSupported(const Mac48Address &address) const
Ptr< const ExtendedCapabilities > GetStationExtendedCapabilities(const Mac48Address &from)
Return the extended capabilities sent by the remote station.
bool GetShortGuardIntervalSupported() const
Return whether the device has SGI support enabled.
Mac48Address GetAddress(const WifiRemoteStation *station) const
Return the address of the station.
Ptr< const HtOperation > GetStationHtOperation(Mac48Address from)
Return the HT operation sent by the remote station.
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 SetDefaultTxPowerLevel(uint8_t txPower)
Set the default transmission power level.
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
Stations m_stations
Information for each known stations.
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)=0
WifiMode GetMcsSupported(const WifiRemoteStation *station, uint8_t i) const
Return the WifiMode supported by the specified station at the specified index.
std::optional< std::reference_wrapper< CommonInfoBasicMle::MldCapabilities > > GetStationMldCapabilities(const Mac48Address &from)
uint32_t GetNNonErpSupported(const WifiRemoteStation *station) const
Return the number of non-ERP modes supported by the given station.
uint32_t m_maxSlrc
Maximum STA long retry count (SLRC).
virtual WifiRemoteStation * DoCreateStation() const =0
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.
void SetAssociationId(Mac48Address remoteAddress, uint16_t aid)
Record the AID of a remote station.
bool GetVhtSupported() const
Return whether the device has VHT capability support enabled on the link this manager is associated w...
Ptr< const VhtCapabilities > GetStationVhtCapabilities(Mac48Address from)
Return the VHT capabilities sent by the remote station.
void AddStationHtCapabilities(Mac48Address from, const HtCapabilities &htCapabilities)
Records HT capabilities of the remote station.
ProtectionMode m_erpProtectionMode
Protection mode for ERP stations when non-ERP stations are detected.
WifiModeList m_bssBasicRateSet
This member is the list of WifiMode objects that comprise the BSSBasicRateSet parameter.
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
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index.
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 SetEmlsrEnabled(const Mac48Address &from, bool emlsrEnabled)
void AddStationExtendedCapabilities(Mac48Address from, const ExtendedCapabilities &extendedCapabilities)
Records extended capabilities of the remote station.
void ResetState(Mac48Address address) const
Reset the state of the station corresponding to the given address (if one exists).
void AddStationVhtOperation(Mac48Address from, const VhtOperation &vhtOperation)
Records VHT operation of the remote station.
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 WifiTxVector GetBlockAckReqTxVector(Mac48Address to, const WifiTxVector &dataTxVector) const
Return a TXVECTOR for a BlockAckReq frame sent in a frame exchange sequence involving the transmissio...
void AddStationEhtOperation(Mac48Address from, const EhtOperation &ehtOperation)
Records EHT operation of the remote station.
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 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.
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:76
#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:201
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:267
#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:260
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:492
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1364
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1313
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
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 QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Definition qos-utils.cc:123
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition qos-utils.h:64
@ STA
Definition wifi-mac.h:60
@ AP
Definition wifi-mac.h:61
@ 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.
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition boolean.cc:113
Ptr< const AttributeAccessor > MakeWifiModeAccessor(T1 a1)
Definition wifi-mode.h:280
Mac48Address GetIndividuallyAddressedRecipient(Ptr< WifiMac > mac, const WifiMacHeader &hdr)
Get the MAC address of the individually addressed recipient to use for a given packet.
U * PeekPointer(const Ptr< U > &p)
Definition ptr.h:501
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
static constexpr uint32_t WIFI_DEFAULT_FRAG_THRESHOLD
The default value for dot11FragmentationThreshold (C.3 MIB detail in IEEE Std 802....
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition nstime.h:1416
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35
static constexpr uint16_t WIFI_MAC_FCS_LENGTH
The length in octets of the IEEE 802.11 MAC FCS field.
static constexpr uint8_t WIFI_MIN_TX_PWR_LEVEL
minimum TX power level value
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:181
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:643
static constexpr uint32_t WIFI_MIN_RTS_THRESHOLD
The minimum value for dot11RTSThreshold (C.3 MIB detail in IEEE Std 802.11-2020).
double dBm_u
dBm weak type
Definition wifi-units.h:27
static constexpr uint32_t WIFI_MIN_FRAG_THRESHOLD
The minimum value for dot11FragmentationThreshold (C.3 MIB detail in IEEE Std 802....
static constexpr uint32_t WIFI_MAX_FRAG_THRESHOLD
The maximum value for dot11FragmentationThreshold (C.3 MIB detail in IEEE Std 802....
@ WIFI_MAC_QOSDATA
Ptr< const AttributeChecker > MakeWifiModeChecker()
Definition wifi-mode.cc:250
bool IsGcr(Ptr< WifiMac > mac, const WifiMacHeader &hdr)
Return whether a given packet is transmitted using the GCR service.
@ CTS_TO_SELF
Definition gcr-manager.h:41
@ RTS_CTS
Definition gcr-manager.h:40
static constexpr uint32_t WIFI_DEFAULT_RTS_THRESHOLD
The default value for dot11RTSThreshold (C.3 MIB detail in IEEE Std 802.11-2020).
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:650
Time GetGuardIntervalForMode(WifiMode mode, const Ptr< WifiNetDevice > device)
Get the guard interval for a given WifiMode.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition boolean.h:70
std::vector< WifiMode > WifiModeList
In various parts of the code, folk are interested in maintaining a list of transmission modes.
Definition wifi-mode.h:289
static constexpr uint32_t WIFI_MAX_RTS_THRESHOLD
The maximum value for dot11RTSThreshold (C.3 MIB detail in IEEE Std 802.11-2020).
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU).
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition enum.h:223
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1436
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr, bool isAmpdu)
Return the total size of the packet after WifiMacHeader and FCS trailer have been added.
EhtMcsMapType
The different EHT-MCS map types as defined in 9.4.2.313.4 Supported EHT-MCS And NSS Set field.
uint8_t support320MhzIn6Ghz
Support For 320 MHz In 6 GHz.
RxSignalInfo structure containing info on the received signal.
Definition wifi-types.h:85
double snr
SNR in linear scale.
Definition wifi-types.h:86
dBm_u rssi
RSSI.
Definition wifi-types.h:87
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