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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
21
22#include "ap-wifi-mac.h"
23#include "sta-wifi-mac.h"
24#include "wifi-mac-header.h"
25#include "wifi-mac-trailer.h"
26#include "wifi-mpdu.h"
27#include "wifi-net-device.h"
28#include "wifi-phy.h"
29
30#include "ns3/boolean.h"
31#include "ns3/eht-configuration.h"
32#include "ns3/enum.h"
33#include "ns3/erp-ofdm-phy.h"
34#include "ns3/he-configuration.h"
35#include "ns3/ht-configuration.h"
36#include "ns3/ht-phy.h"
37#include "ns3/log.h"
38#include "ns3/simulator.h"
39#include "ns3/uinteger.h"
40#include "ns3/vht-configuration.h"
41
42namespace ns3
43{
44
45NS_LOG_COMPONENT_DEFINE("WifiRemoteStationManager");
46
47NS_OBJECT_ENSURE_REGISTERED(WifiRemoteStationManager);
48
49TypeId
51{
52 static TypeId tid =
53 TypeId("ns3::WifiRemoteStationManager")
55 .SetGroupName("Wifi")
56 .AddAttribute("MaxSsrc",
57 "The maximum number of retransmission attempts for any packet with size "
58 "<= RtsCtsThreshold. "
59 "This value will not have any effect on some rate control algorithms.",
62 MakeUintegerChecker<uint32_t>())
63 .AddAttribute("MaxSlrc",
64 "The maximum number of retransmission attempts for any packet with size "
65 "> RtsCtsThreshold. "
66 "This value will not have any effect on some rate control algorithms.",
69 MakeUintegerChecker<uint32_t>())
70 .AddAttribute("RtsCtsThreshold",
71 "If the size of the PSDU is bigger than this value, we use an RTS/CTS "
72 "handshake before sending the data frame."
73 "This value will not have any effect on some rate control algorithms.",
74 UintegerValue(65535),
76 MakeUintegerChecker<uint32_t>())
77 .AddAttribute(
78 "FragmentationThreshold",
79 "If the size of the PSDU is bigger than this value, we fragment it such that the "
80 "size of the fragments are equal or smaller. "
81 "This value does not apply when it is carried in an A-MPDU. "
82 "This value will not have any effect on some rate control algorithms.",
83 UintegerValue(65535),
86 MakeUintegerChecker<uint32_t>())
87 .AddAttribute("NonUnicastMode",
88 "Wifi mode used for non-unicast transmissions.",
90 MakeWifiModeAccessor(&WifiRemoteStationManager::m_nonUnicastMode),
91 MakeWifiModeChecker())
92 .AddAttribute("DefaultTxPowerLevel",
93 "Default power level to be used for transmissions. "
94 "This is the power level that is used by all those WifiManagers that do "
95 "not implement TX power control.",
98 MakeUintegerChecker<uint8_t>())
99 .AddAttribute("ErpProtectionMode",
100 "Protection mode used when non-ERP STAs are connected to an ERP AP: "
101 "Rts-Cts or Cts-To-Self",
105 "Rts-Cts",
107 "Cts-To-Self"))
108 .AddAttribute("HtProtectionMode",
109 "Protection mode used when non-HT STAs are connected to a HT AP: Rts-Cts "
110 "or Cts-To-Self",
114 "Rts-Cts",
116 "Cts-To-Self"))
117 .AddTraceSource("MacTxRtsFailed",
118 "The transmission of a RTS by the MAC layer has failed",
120 "ns3::Mac48Address::TracedCallback")
121 .AddTraceSource("MacTxDataFailed",
122 "The transmission of a data packet by the MAC layer has failed",
124 "ns3::Mac48Address::TracedCallback")
125 .AddTraceSource(
126 "MacTxFinalRtsFailed",
127 "The transmission of a RTS has exceeded the maximum number of attempts",
129 "ns3::Mac48Address::TracedCallback")
130 .AddTraceSource(
131 "MacTxFinalDataFailed",
132 "The transmission of a data packet has exceeded the maximum number of attempts",
134 "ns3::Mac48Address::TracedCallback");
135 return tid;
136}
137
139 : m_useNonErpProtection(false),
140 m_useNonHtProtection(false),
141 m_shortPreambleEnabled(false),
142 m_shortSlotTimeEnabled(false)
143{
144 NS_LOG_FUNCTION(this);
145}
146
148{
149 NS_LOG_FUNCTION(this);
150}
151
152void
154{
155 NS_LOG_FUNCTION(this);
156 Reset();
157}
158
159void
161{
162 NS_LOG_FUNCTION(this << phy);
163 // We need to track our PHY because it is the object that knows the
164 // full set of transmit rates that are supported. We need to know
165 // this in order to find the relevant mandatory rates when choosing a
166 // transmit rate for automatic control responses like
167 // acknowledgments.
168 m_wifiPhy = phy;
169 m_defaultTxMode = phy->GetDefaultMode();
171 if (GetHtSupported())
172 {
174 }
175 Reset();
176}
177
178void
180{
181 NS_LOG_FUNCTION(this << mac);
182 // We need to track our MAC because it is the object that knows the
183 // full set of interframe spaces.
184 m_wifiMac = mac;
185 Reset();
186}
187
188int64_t
190{
191 NS_LOG_FUNCTION(this << stream);
192 return 0;
193}
194
195void
197{
198 NS_LOG_FUNCTION(this << maxSsrc);
199 m_maxSsrc = maxSsrc;
200}
201
202void
204{
205 NS_LOG_FUNCTION(this << maxSlrc);
206 m_maxSlrc = maxSlrc;
207}
208
209void
211{
212 NS_LOG_FUNCTION(this << threshold);
213 m_rtsCtsThreshold = threshold;
214}
215
216void
218{
219 NS_LOG_FUNCTION(this << threshold);
221}
222
223void
225{
226 NS_LOG_FUNCTION(this << enable);
227 m_shortPreambleEnabled = enable;
228}
229
230void
232{
233 NS_LOG_FUNCTION(this << enable);
234 m_shortSlotTimeEnabled = enable;
235}
236
237bool
239{
241}
242
243bool
245{
247}
248
249bool
251{
252 return bool(m_wifiPhy->GetDevice()->GetHtConfiguration());
253}
254
255bool
257{
260}
261
262bool
264{
265 return bool(m_wifiPhy->GetDevice()->GetHeConfiguration());
266}
267
268bool
270{
271 return bool(m_wifiPhy->GetDevice()->GetEhtConfiguration());
272}
273
274bool
276{
277 if (GetHtSupported())
278 {
280 NS_ASSERT(htConfiguration); // If HT is supported, we should have a HT configuration
281 // attached
282 return htConfiguration->GetLdpcSupported();
283 }
284 return false;
285}
286
287bool
289{
290 if (GetHtSupported())
291 {
293 NS_ASSERT(htConfiguration); // If HT is supported, we should have a HT configuration
294 // attached
295 if (htConfiguration->GetShortGuardIntervalSupported())
296 {
297 return true;
298 }
299 }
300 return false;
301}
302
303uint16_t
305{
306 uint16_t gi = 0;
307 if (GetHeSupported())
308 {
310 NS_ASSERT(heConfiguration); // If HE is supported, we should have a HE configuration
311 // attached
312 gi = static_cast<uint16_t>(heConfiguration->GetGuardInterval().GetNanoSeconds());
313 }
314 return gi;
315}
316
319{
321}
322
323void
325 bool isShortPreambleSupported)
326{
327 NS_LOG_FUNCTION(this << address << isShortPreambleSupported);
328 NS_ASSERT(!address.IsGroup());
329 LookupState(address)->m_shortPreamble = isShortPreambleSupported;
330}
331
332void
334 bool isShortSlotTimeSupported)
335{
336 NS_LOG_FUNCTION(this << address << isShortSlotTimeSupported);
337 NS_ASSERT(!address.IsGroup());
338 LookupState(address)->m_shortSlotTime = isShortSlotTimeSupported;
339}
340
341void
343{
344 NS_LOG_FUNCTION(this << address << mode);
345 NS_ASSERT(!address.IsGroup());
346 auto state = LookupState(address);
347 for (const auto& i : state->m_operationalRateSet)
348 {
349 if (i == mode)
350 {
351 return; // already in
352 }
353 }
354 if ((mode.GetModulationClass() == WIFI_MOD_CLASS_DSSS) ||
356 {
357 state->m_dsssSupported = true;
358 }
360 {
361 state->m_erpOfdmSupported = true;
362 }
363 else if (mode.GetModulationClass() == WIFI_MOD_CLASS_OFDM)
364 {
365 state->m_ofdmSupported = true;
366 }
367 state->m_operationalRateSet.push_back(mode);
368}
369
370void
372{
373 NS_LOG_FUNCTION(this << address);
374 NS_ASSERT(!address.IsGroup());
375 auto state = LookupState(address);
376 state->m_operationalRateSet.clear();
377 for (const auto& mode : m_wifiPhy->GetModeList())
378 {
379 state->m_operationalRateSet.push_back(mode);
380 if (mode.IsMandatory())
381 {
382 AddBasicMode(mode);
383 }
384 }
385}
386
387void
389{
390 NS_LOG_FUNCTION(this << address);
391 NS_ASSERT(!address.IsGroup());
392 auto state = LookupState(address);
393
394 const auto& mcsList = m_wifiPhy->GetMcsList();
395 state->m_operationalMcsSet = WifiModeList(mcsList.begin(), mcsList.end());
396}
397
398void
400{
401 NS_LOG_FUNCTION(this << address);
402 NS_ASSERT(!address.IsGroup());
403 LookupState(address)->m_operationalMcsSet.clear();
404}
405
406void
408{
409 NS_LOG_FUNCTION(this << address << mcs);
410 NS_ASSERT(!address.IsGroup());
411 auto state = LookupState(address);
412 for (const auto& i : state->m_operationalMcsSet)
413 {
414 if (i == mcs)
415 {
416 return; // already in
417 }
418 }
419 state->m_operationalMcsSet.push_back(mcs);
420}
421
422bool
424{
425 return LookupState(address)->m_shortPreamble;
426}
427
428bool
430{
431 return LookupState(address)->m_shortSlotTime;
432}
433
434bool
436{
437 return LookupState(address)->m_qosSupported;
438}
439
440bool
442{
443 if (address.IsGroup())
444 {
445 return false;
446 }
447 return LookupState(address)->m_state == WifiRemoteStationState::BRAND_NEW;
448}
449
450bool
452{
453 if (address.IsGroup())
454 {
455 return true;
456 }
457 return LookupState(address)->m_state == WifiRemoteStationState::GOT_ASSOC_TX_OK;
458}
459
460bool
462{
463 if (address.IsGroup())
464 {
465 return false;
466 }
467 return LookupState(address)->m_state == WifiRemoteStationState::WAIT_ASSOC_TX_OK;
468}
469
470void
472{
473 NS_ASSERT(!address.IsGroup());
475}
476
477void
479{
480 NS_ASSERT(!address.IsGroup());
482}
483
484void
486{
487 NS_ASSERT(!address.IsGroup());
489}
490
491void
493{
494 NS_ASSERT(!address.IsGroup());
496}
497
498bool
500{
501 if (address.IsGroup())
502 {
503 return false;
504 }
505 return LookupState(address)->m_state == WifiRemoteStationState::ASSOC_REFUSED;
506}
507
508void
510{
511 NS_ASSERT(!address.IsGroup());
513}
514
515uint16_t
517{
518 std::shared_ptr<WifiRemoteStationState> state;
519 if (!remoteAddress.IsGroup() &&
520 (state = LookupState(remoteAddress))->m_state == WifiRemoteStationState::GOT_ASSOC_TX_OK)
521 {
522 return state->m_aid;
523 }
524 return SU_STA_ID;
525}
526
527uint16_t
529{
530 NS_LOG_FUNCTION(this << address << txVector);
531
532 uint16_t staId = SU_STA_ID;
533
534 if (txVector.IsMu())
535 {
536 if (m_wifiMac->GetTypeOfStation() == AP)
537 {
538 staId = GetAssociationId(address);
539 }
540 else if (m_wifiMac->GetTypeOfStation() == STA)
541 {
542 Ptr<StaWifiMac> staMac = StaticCast<StaWifiMac>(m_wifiMac);
543 if (staMac->IsAssociated())
544 {
545 staId = staMac->GetAssociationId();
546 }
547 }
548 }
549
550 NS_LOG_DEBUG("Returning STAID = " << staId);
551 return staId;
552}
553
554bool
556{
557 return LookupState(address)->m_isInPsMode;
558}
559
560void
561WifiRemoteStationManager::SetPsMode(const Mac48Address& address, bool isInPsMode)
562{
563 LookupState(address)->m_isInPsMode = isInPsMode;
564}
565
566std::optional<Mac48Address>
568{
569 if (auto stateIt = m_states.find(address);
570 stateIt != m_states.end() && stateIt->second->m_mleCommonInfo)
571 {
572 return stateIt->second->m_mleCommonInfo->m_mldMacAddress;
573 }
574
575 return std::nullopt;
576}
577
578std::optional<Mac48Address>
580{
581 auto stateIt = m_states.find(mldAddress);
582
583 if (stateIt == m_states.end() || !stateIt->second->m_mleCommonInfo)
584 {
585 // MLD address not found
586 return std::nullopt;
587 }
588
589 NS_ASSERT(stateIt->second->m_mleCommonInfo->m_mldMacAddress == mldAddress);
590 return stateIt->second->m_address;
591}
592
594WifiRemoteStationManager::GetDataTxVector(const WifiMacHeader& header, uint16_t allowedWidth)
595{
596 NS_LOG_FUNCTION(this << header << allowedWidth);
597 Mac48Address address = header.GetAddr1();
598 if (!header.IsMgt() && address.IsGroup())
599 {
601 WifiTxVector v;
602 v.SetMode(mode);
606 v.SetChannelWidth(m_wifiPhy->GetTxBandwidth(mode, allowedWidth));
609 v.SetNss(1);
610 v.SetNess(0);
611 return v;
612 }
613 WifiTxVector txVector;
614 if (header.IsMgt())
615 {
616 // Use the lowest basic rate for management frames
617 WifiMode mgtMode;
618 if (GetNBasicModes() > 0)
619 {
620 mgtMode = GetBasicMode(0);
621 }
622 else
623 {
624 mgtMode = GetDefaultMode();
625 }
626 txVector.SetMode(mgtMode);
627 txVector.SetPreambleType(
630 uint16_t channelWidth = allowedWidth;
631 if (!header.GetAddr1().IsGroup())
632 {
633 if (uint16_t rxWidth = GetChannelWidthSupported(header.GetAddr1());
634 rxWidth < channelWidth)
635 {
636 channelWidth = rxWidth;
637 }
638 }
639
640 txVector.SetChannelWidth(m_wifiPhy->GetTxBandwidth(mgtMode, channelWidth));
641 txVector.SetGuardInterval(
643 }
644 else
645 {
646 txVector = DoGetDataTxVector(Lookup(address), allowedWidth);
648 ? false
649 : UseLdpcForDestination(address));
650 }
652 if (heConfiguration)
653 {
654 txVector.SetBssColor(heConfiguration->GetBssColor());
655 }
656 // If both the allowed width and the TXVECTOR channel width are integer multiple
657 // of 20 MHz, then the TXVECTOR channel width must not exceed the allowed width
658 NS_ASSERT_MSG((txVector.GetChannelWidth() % 20 != 0) || (allowedWidth % 20 != 0) ||
659 (txVector.GetChannelWidth() <= allowedWidth),
660 "TXVECTOR channel width (" << txVector.GetChannelWidth()
661 << " MHz) exceeds allowed width (" << allowedWidth
662 << " MHz)");
663 return txVector;
664}
665
668{
669 WifiMode defaultMode = GetDefaultMode();
670 WifiPreamble defaultPreamble;
671 if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_EHT)
672 {
673 defaultPreamble = WIFI_PREAMBLE_EHT_MU;
674 }
675 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_HE)
676 {
677 defaultPreamble = WIFI_PREAMBLE_HE_SU;
678 }
679 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_VHT)
680 {
681 defaultPreamble = WIFI_PREAMBLE_VHT_SU;
682 }
683 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_HT)
684 {
685 defaultPreamble = WIFI_PREAMBLE_HT_MF;
686 }
687 else
688 {
689 defaultPreamble = WIFI_PREAMBLE_LONG;
690 }
691
692 return WifiTxVector(defaultMode,
694 defaultPreamble,
697 1,
698 0,
699 m_wifiPhy->GetTxBandwidth(defaultMode),
700 false);
701}
702
705{
706 NS_LOG_FUNCTION(this << address);
707 if (address.IsGroup())
708 {
710 WifiTxVector v;
711 v.SetMode(mode);
718 v.SetNss(1);
719 v.SetNess(0);
720 return v;
721 }
722 return DoGetRtsTxVector(Lookup(address));
723}
724
727{
728 NS_ASSERT(!to.IsGroup());
729 WifiMode ctsMode = GetControlAnswerMode(rtsTxMode);
730 WifiTxVector v;
731 v.SetMode(ctsMode);
736 uint16_t ctsTxGuardInterval =
738 v.SetGuardInterval(ctsTxGuardInterval);
739 v.SetNss(1);
740 return v;
741}
742
743void
745{
746 NS_LOG_FUNCTION(this << txVector);
747
748 auto txMode = txVector.GetMode();
749 if (txMode.GetModulationClass() >= WIFI_MOD_CLASS_HT)
750 {
751 auto rate = txMode.GetDataRate(txVector);
752 if (rate >= 24e6)
753 {
754 rate = 24e6;
755 }
756 else if (rate >= 12e6)
757 {
758 rate = 12e6;
759 }
760 else
761 {
762 rate = 6e6;
763 }
766 {
767 txVector.SetMode(ErpOfdmPhy::GetErpOfdmRate(rate));
768 }
769 else
770 {
771 txVector.SetMode(OfdmPhy::GetOfdmRate(rate));
772 }
773 }
774}
775
778{
779 NS_ASSERT(!to.IsGroup());
780 WifiMode ackMode = GetControlAnswerMode(dataTxVector.GetMode(GetStaId(to, dataTxVector)));
781 WifiTxVector v;
782 v.SetMode(ackMode);
787 uint16_t ackTxGuardInterval =
789 v.SetGuardInterval(ackTxGuardInterval);
790 v.SetNss(1);
791 return v;
792}
793
796 const WifiTxVector& dataTxVector) const
797{
798 NS_ASSERT(!to.IsGroup());
799 WifiMode blockAckMode = GetControlAnswerMode(dataTxVector.GetMode(GetStaId(to, dataTxVector)));
800 WifiTxVector v;
801 v.SetMode(blockAckMode);
805 v.SetChannelWidth(m_wifiPhy->GetTxBandwidth(blockAckMode));
806 uint16_t blockAckTxGuardInterval =
808 v.SetGuardInterval(blockAckTxGuardInterval);
809 v.SetNss(1);
810 return v;
811}
812
815{
830 NS_LOG_FUNCTION(this << reqMode);
831 WifiMode mode = GetDefaultMode();
832 bool found = false;
833 // First, search the BSS Basic Rate set
834 for (uint8_t i = 0; i < GetNBasicModes(); i++)
835 {
836 WifiMode testMode = GetBasicMode(i);
837 if ((!found || testMode.IsHigherDataRate(mode)) && (!testMode.IsHigherDataRate(reqMode)) &&
839 testMode.GetModulationClass())))
840 {
841 mode = testMode;
842 // We've found a potentially-suitable transmit rate, but we
843 // need to continue and consider all the basic rates before
844 // we can be sure we've got the right one.
845 found = true;
846 }
847 }
848 if (GetHtSupported())
849 {
850 if (!found)
851 {
852 mode = GetDefaultMcs();
853 for (uint8_t i = 0; i != GetNBasicMcs(); i++)
854 {
855 WifiMode testMode = GetBasicMcs(i);
856 if ((!found || testMode.IsHigherDataRate(mode)) &&
857 (!testMode.IsHigherDataRate(reqMode)) &&
858 (testMode.GetModulationClass() == reqMode.GetModulationClass()))
859 {
860 mode = testMode;
861 // We've found a potentially-suitable transmit rate, but we
862 // need to continue and consider all the basic rates before
863 // we can be sure we've got the right one.
864 found = true;
865 }
866 }
867 }
868 }
869 // If we found a suitable rate in the BSSBasicRateSet, then we are
870 // done and can return that mode.
871 if (found)
872 {
873 NS_LOG_DEBUG("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
874 return mode;
875 }
876
894 for (const auto& thismode : m_wifiPhy->GetModeList())
895 {
896 /* If the rate:
897 *
898 * - is a mandatory rate for the PHY, and
899 * - is equal to or faster than our current best choice, and
900 * - is less than or equal to the rate of the received frame, and
901 * - is of the same modulation class as the received frame
902 *
903 * ...then it's our best choice so far.
904 */
905 if (thismode.IsMandatory() && (!found || thismode.IsHigherDataRate(mode)) &&
906 (!thismode.IsHigherDataRate(reqMode)) &&
908 thismode.GetModulationClass())))
909 {
910 mode = thismode;
911 // As above; we've found a potentially-suitable transmit
912 // rate, but we need to continue and consider all the
913 // mandatory rates before we can be sure we've got the right one.
914 found = true;
915 }
916 }
917 if (GetHtSupported())
918 {
919 for (const auto& thismode : m_wifiPhy->GetMcsList())
920 {
921 if (thismode.IsMandatory() && (!found || thismode.IsHigherDataRate(mode)) &&
922 (!thismode.IsHigherCodeRate(reqMode)) &&
923 (thismode.GetModulationClass() == reqMode.GetModulationClass()))
924 {
925 mode = thismode;
926 // As above; we've found a potentially-suitable transmit
927 // rate, but we need to continue and consider all the
928 // mandatory rates before we can be sure we've got the right one.
929 found = true;
930 }
931 }
932 }
933
943 if (!found)
944 {
945 NS_FATAL_ERROR("Can't find response rate for " << reqMode);
946 }
947
948 NS_LOG_DEBUG("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
949 return mode;
950}
951
952void
954{
955 NS_LOG_FUNCTION(this << header);
956 NS_ASSERT(!header.GetAddr1().IsGroup());
957 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
958 m_ssrc[ac]++;
959 m_macTxRtsFailed(header.GetAddr1());
961}
962
963void
965{
966 NS_LOG_FUNCTION(this << *mpdu);
967 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
968 AcIndex ac =
969 QosUtilsMapTidToAc((mpdu->GetHeader().IsQosData()) ? mpdu->GetHeader().GetQosTid() : 0);
970 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
971 if (longMpdu)
972 {
973 m_slrc[ac]++;
974 }
975 else
976 {
977 m_ssrc[ac]++;
978 }
979 m_macTxDataFailed(mpdu->GetHeader().GetAddr1());
980 DoReportDataFailed(Lookup(mpdu->GetHeader().GetAddr1()));
981}
982
983void
985 double ctsSnr,
986 WifiMode ctsMode,
987 double rtsSnr)
988{
989 NS_LOG_FUNCTION(this << header << ctsSnr << ctsMode << rtsSnr);
990 NS_ASSERT(!header.GetAddr1().IsGroup());
991 WifiRemoteStation* station = Lookup(header.GetAddr1());
992 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
993 station->m_state->m_info.NotifyTxSuccess(m_ssrc[ac]);
994 m_ssrc[ac] = 0;
995 DoReportRtsOk(station, ctsSnr, ctsMode, rtsSnr);
996}
997
998void
1000 double ackSnr,
1001 WifiMode ackMode,
1002 double dataSnr,
1003 WifiTxVector dataTxVector)
1004{
1005 NS_LOG_FUNCTION(this << *mpdu << ackSnr << ackMode << dataSnr << dataTxVector);
1006 const WifiMacHeader& hdr = mpdu->GetHeader();
1007 NS_ASSERT(!hdr.GetAddr1().IsGroup());
1008 WifiRemoteStation* station = Lookup(hdr.GetAddr1());
1009 AcIndex ac = QosUtilsMapTidToAc((hdr.IsQosData()) ? hdr.GetQosTid() : 0);
1010 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
1011 if (longMpdu)
1012 {
1013 station->m_state->m_info.NotifyTxSuccess(m_slrc[ac]);
1014 m_slrc[ac] = 0;
1015 }
1016 else
1017 {
1018 station->m_state->m_info.NotifyTxSuccess(m_ssrc[ac]);
1019 m_ssrc[ac] = 0;
1020 }
1021 DoReportDataOk(station,
1022 ackSnr,
1023 ackMode,
1024 dataSnr,
1025 dataTxVector.GetChannelWidth(),
1026 dataTxVector.GetNss(GetStaId(hdr.GetAddr1(), dataTxVector)));
1027}
1028
1029void
1031{
1032 NS_LOG_FUNCTION(this << header);
1033 NS_ASSERT(!header.GetAddr1().IsGroup());
1034 WifiRemoteStation* station = Lookup(header.GetAddr1());
1035 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
1036 station->m_state->m_info.NotifyTxFailed();
1037 m_ssrc[ac] = 0;
1039 DoReportFinalRtsFailed(station);
1040}
1041
1042void
1044{
1045 NS_LOG_FUNCTION(this << *mpdu);
1046 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1047 WifiRemoteStation* station = Lookup(mpdu->GetHeader().GetAddr1());
1048 AcIndex ac =
1049 QosUtilsMapTidToAc((mpdu->GetHeader().IsQosData()) ? mpdu->GetHeader().GetQosTid() : 0);
1050 station->m_state->m_info.NotifyTxFailed();
1051 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
1052 if (longMpdu)
1053 {
1054 m_slrc[ac] = 0;
1055 }
1056 else
1057 {
1058 m_ssrc[ac] = 0;
1059 }
1060 m_macTxFinalDataFailed(mpdu->GetHeader().GetAddr1());
1061 DoReportFinalDataFailed(station);
1062}
1063
1064void
1066 RxSignalInfo rxSignalInfo,
1067 WifiTxVector txVector)
1068{
1069 NS_LOG_FUNCTION(this << address << rxSignalInfo << txVector);
1070 if (address.IsGroup())
1071 {
1072 return;
1073 }
1074 WifiRemoteStation* station = Lookup(address);
1075 DoReportRxOk(station, rxSignalInfo.snr, txVector.GetMode(GetStaId(address, txVector)));
1076 station->m_rssiAndUpdateTimePair = std::make_pair(rxSignalInfo.rssi, Simulator::Now());
1077}
1078
1079void
1081 uint16_t nSuccessfulMpdus,
1082 uint16_t nFailedMpdus,
1083 double rxSnr,
1084 double dataSnr,
1085 WifiTxVector dataTxVector)
1086{
1087 NS_LOG_FUNCTION(this << address << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr
1088 << dataTxVector);
1089 NS_ASSERT(!address.IsGroup());
1090 for (uint16_t i = 0; i < nFailedMpdus; i++)
1091 {
1092 m_macTxDataFailed(address);
1093 }
1095 nSuccessfulMpdus,
1096 nFailedMpdus,
1097 rxSnr,
1098 dataSnr,
1099 dataTxVector.GetChannelWidth(),
1100 dataTxVector.GetNss(GetStaId(address, dataTxVector)));
1101}
1102
1103bool
1105{
1106 NS_LOG_FUNCTION(this << header << size);
1107 Mac48Address address = header.GetAddr1();
1109 const auto modulationClass = txVector.GetModulationClass();
1110 if (address.IsGroup())
1111 {
1112 return false;
1113 }
1115 ((modulationClass == WIFI_MOD_CLASS_ERP_OFDM) || (modulationClass == WIFI_MOD_CLASS_HT) ||
1116 (modulationClass == WIFI_MOD_CLASS_VHT) || (modulationClass == WIFI_MOD_CLASS_HE) ||
1117 (modulationClass == WIFI_MOD_CLASS_EHT)) &&
1119 {
1121 "WifiRemoteStationManager::NeedRTS returning true to protect non-ERP stations");
1122 return true;
1123 }
1124 else if (m_htProtectionMode == RTS_CTS &&
1125 ((modulationClass == WIFI_MOD_CLASS_HT) || (modulationClass == WIFI_MOD_CLASS_VHT)) &&
1127 {
1128 NS_LOG_DEBUG("WifiRemoteStationManager::NeedRTS returning true to protect non-HT stations");
1129 return true;
1130 }
1131 bool normally = (size > m_rtsCtsThreshold);
1132 return DoNeedRts(Lookup(address), size, normally);
1133}
1134
1135bool
1137{
1138 WifiMode mode = txVector.GetMode();
1139 NS_LOG_FUNCTION(this << mode);
1147 {
1149 "WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
1150 return true;
1151 }
1152 else if (m_htProtectionMode == CTS_TO_SELF &&
1156 {
1158 "WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-HT stations");
1159 return true;
1160 }
1161 else if (!m_useNonErpProtection)
1162 {
1163 // search for the BSS Basic Rate set, if the used mode is in the basic set then there is no
1164 // need for CTS To Self
1165 for (auto i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++)
1166 {
1167 if (mode == *i)
1168 {
1169 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning false");
1170 return false;
1171 }
1172 }
1173 if (GetHtSupported())
1174 {
1175 // search for the BSS Basic MCS set, if the used mode is in the basic set then there is
1176 // no need for CTS To Self
1177 for (auto i = m_bssBasicMcsSet.begin(); i != m_bssBasicMcsSet.end(); i++)
1178 {
1179 if (mode == *i)
1180 {
1181 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning false");
1182 return false;
1183 }
1184 }
1185 }
1186 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning true");
1187 return true;
1188 }
1189 return false;
1190}
1191
1192void
1194{
1195 NS_LOG_FUNCTION(this << enable);
1196 m_useNonErpProtection = enable;
1197}
1198
1199bool
1201{
1202 return m_useNonErpProtection;
1203}
1204
1205void
1207{
1208 NS_LOG_FUNCTION(this << enable);
1209 m_useNonHtProtection = enable;
1210}
1211
1212bool
1214{
1215 return m_useNonHtProtection;
1216}
1217
1218bool
1220{
1221 NS_LOG_FUNCTION(this << *mpdu);
1222 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1223 AcIndex ac =
1224 QosUtilsMapTidToAc((mpdu->GetHeader().IsQosData()) ? mpdu->GetHeader().GetQosTid() : 0);
1225 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
1226 uint32_t retryCount;
1227 uint32_t maxRetryCount;
1228 if (longMpdu)
1229 {
1230 retryCount = m_slrc[ac];
1231 maxRetryCount = m_maxSlrc;
1232 }
1233 else
1234 {
1235 retryCount = m_ssrc[ac];
1236 maxRetryCount = m_maxSsrc;
1237 }
1238 bool normally = retryCount < maxRetryCount;
1239 NS_LOG_DEBUG("WifiRemoteStationManager::NeedRetransmission count: "
1240 << retryCount << " result: " << std::boolalpha << normally);
1241 return DoNeedRetransmission(Lookup(mpdu->GetHeader().GetAddr1()), mpdu->GetPacket(), normally);
1242}
1243
1244bool
1246{
1247 NS_LOG_FUNCTION(this << *mpdu);
1248 if (mpdu->GetHeader().GetAddr1().IsGroup())
1249 {
1250 return false;
1251 }
1252 bool normally = mpdu->GetSize() > GetFragmentationThreshold();
1253 NS_LOG_DEBUG("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha
1254 << normally);
1255 return DoNeedFragmentation(Lookup(mpdu->GetHeader().GetAddr1()), mpdu->GetPacket(), normally);
1256}
1257
1258void
1260{
1261 NS_LOG_FUNCTION(this << threshold);
1262 if (threshold < 256)
1263 {
1264 /*
1265 * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
1266 */
1267 NS_LOG_WARN("Fragmentation threshold should be larger than 256. Setting to 256.");
1269 }
1270 else
1271 {
1272 /*
1273 * The length of each fragment shall be an even number of octets, except for the last
1274 * fragment if an MSDU or MMPDU, which may be either an even or an odd number of octets.
1275 */
1276 if (threshold % 2 != 0)
1277 {
1278 NS_LOG_WARN("Fragmentation threshold should be an even number. Setting to "
1279 << threshold - 1);
1280 m_fragmentationThreshold = threshold - 1;
1281 }
1282 else
1283 {
1284 m_fragmentationThreshold = threshold;
1285 }
1286 }
1287}
1288
1291{
1293}
1294
1297{
1298 NS_LOG_FUNCTION(this << *mpdu);
1299 // The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1300 uint32_t nFragments =
1301 (mpdu->GetPacket()->GetSize() /
1302 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH));
1303
1304 // If the size of the last fragment is not 0.
1305 if ((mpdu->GetPacket()->GetSize() %
1306 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH)) > 0)
1307 {
1308 nFragments++;
1309 }
1310 NS_LOG_DEBUG("WifiRemoteStationManager::GetNFragments returning " << nFragments);
1311 return nFragments;
1312}
1313
1316{
1317 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1318 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1319 uint32_t nFragment = GetNFragments(mpdu);
1320 if (fragmentNumber >= nFragment)
1321 {
1322 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning 0");
1323 return 0;
1324 }
1325 // Last fragment
1326 if (fragmentNumber == nFragment - 1)
1327 {
1328 uint32_t lastFragmentSize =
1329 mpdu->GetPacket()->GetSize() -
1330 (fragmentNumber *
1331 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH));
1332 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
1333 return lastFragmentSize;
1334 }
1335 // All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1336 else
1337 {
1338 uint32_t fragmentSize =
1339 GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH;
1340 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
1341 return fragmentSize;
1342 }
1343}
1344
1347{
1348 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1349 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1350 NS_ASSERT(fragmentNumber < GetNFragments(mpdu));
1351 uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold() -
1352 mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH);
1353 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
1354 return fragmentOffset;
1355}
1356
1357bool
1359{
1360 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1361 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1362 bool isLast = fragmentNumber == (GetNFragments(mpdu) - 1);
1363 NS_LOG_DEBUG("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
1364 return isLast;
1365}
1366
1367uint8_t
1369{
1370 return m_defaultTxPowerLevel;
1371}
1372
1375{
1376 return LookupState(address)->m_info;
1377}
1378
1379std::optional<double>
1381{
1382 auto station = Lookup(address);
1383 auto rssi = station->m_rssiAndUpdateTimePair.first;
1384 auto ts = station->m_rssiAndUpdateTimePair.second;
1385 if (ts.IsStrictlyPositive())
1386 {
1387 return rssi;
1388 }
1389 return std::nullopt;
1390}
1391
1392std::shared_ptr<WifiRemoteStationState>
1394{
1395 NS_LOG_FUNCTION(this << address);
1396 auto stateIt = m_states.find(address);
1397
1398 if (stateIt != m_states.end())
1399 {
1400 NS_LOG_DEBUG("WifiRemoteStationManager::LookupState returning existing state");
1401 return stateIt->second;
1402 }
1403
1404 auto state = std::make_shared<WifiRemoteStationState>();
1405 state->m_state = WifiRemoteStationState::BRAND_NEW;
1406 state->m_address = address;
1407 state->m_aid = 0;
1408 state->m_operationalRateSet.push_back(GetDefaultMode());
1409 state->m_operationalMcsSet.push_back(GetDefaultMcs());
1410 state->m_dsssSupported = false;
1411 state->m_erpOfdmSupported = false;
1412 state->m_ofdmSupported = false;
1413 state->m_htCapabilities = nullptr;
1414 state->m_vhtCapabilities = nullptr;
1415 state->m_heCapabilities = nullptr;
1416 state->m_ehtCapabilities = nullptr;
1417 state->m_mleCommonInfo = nullptr;
1418 state->m_emlsrEnabled = false;
1419 state->m_channelWidth = m_wifiPhy->GetChannelWidth();
1420 state->m_guardInterval = GetGuardInterval();
1421 state->m_ness = 0;
1422 state->m_aggregation = false;
1423 state->m_qosSupported = false;
1424 state->m_isInPsMode = false;
1425 const_cast<WifiRemoteStationManager*>(this)->m_states.insert({address, state});
1426 NS_LOG_DEBUG("WifiRemoteStationManager::LookupState returning new state");
1427 return state;
1428}
1429
1430WifiRemoteStation*
1431WifiRemoteStationManager::Lookup(Mac48Address address) const
1432{
1433 NS_LOG_FUNCTION(this << address);
1434 auto stationIt = m_stations.find(address);
1435
1436 if (stationIt != m_stations.end())
1437 {
1438 return stationIt->second;
1439 }
1440
1441 WifiRemoteStation* station = DoCreateStation();
1442 station->m_state = LookupState(address).get();
1443 station->m_rssiAndUpdateTimePair = std::make_pair(0, Seconds(0));
1444 const_cast<WifiRemoteStationManager*>(this)->m_stations.insert({address, station});
1445 return station;
1446}
1447
1448void
1449WifiRemoteStationManager::SetAssociationId(Mac48Address remoteAddress, uint16_t aid)
1450{
1451 NS_LOG_FUNCTION(this << remoteAddress << aid);
1452 LookupState(remoteAddress)->m_aid = aid;
1453}
1454
1455void
1456WifiRemoteStationManager::SetQosSupport(Mac48Address from, bool qosSupported)
1457{
1458 NS_LOG_FUNCTION(this << from << qosSupported);
1459 LookupState(from)->m_qosSupported = qosSupported;
1460}
1461
1462void
1463WifiRemoteStationManager::SetEmlsrEnabled(const Mac48Address& from, bool emlsrEnabled)
1464{
1465 NS_LOG_FUNCTION(this << from << emlsrEnabled);
1466 LookupState(from)->m_emlsrEnabled = emlsrEnabled;
1467}
1468
1469void
1470WifiRemoteStationManager::AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
1471{
1472 // Used by all stations to record HT capabilities of remote stations
1473 NS_LOG_FUNCTION(this << from << htCapabilities);
1474 auto state = LookupState(from);
1475 if (htCapabilities.GetSupportedChannelWidth() == 1)
1476 {
1477 state->m_channelWidth = 40;
1478 }
1479 else
1480 {
1481 state->m_channelWidth = 20;
1482 }
1483 SetQosSupport(from, true);
1484 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_HT))
1485 {
1486 if (htCapabilities.IsSupportedMcs(mcs.GetMcsValue()))
1487 {
1488 AddSupportedMcs(from, mcs);
1489 }
1490 }
1491 state->m_htCapabilities = Create<const HtCapabilities>(htCapabilities);
1492}
1493
1494void
1495WifiRemoteStationManager::AddStationVhtCapabilities(Mac48Address from,
1496 VhtCapabilities vhtCapabilities)
1497{
1498 // Used by all stations to record VHT capabilities of remote stations
1499 NS_LOG_FUNCTION(this << from << vhtCapabilities);
1500 auto state = LookupState(from);
1501 if (vhtCapabilities.GetSupportedChannelWidthSet() == 1)
1502 {
1503 state->m_channelWidth = 160;
1504 }
1505 else
1506 {
1507 state->m_channelWidth = 80;
1508 }
1509 for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams(); i++)
1510 {
1511 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_VHT))
1512 {
1513 if (vhtCapabilities.IsSupportedMcs(mcs.GetMcsValue(), i))
1514 {
1515 AddSupportedMcs(from, mcs);
1516 }
1517 }
1518 }
1519 state->m_vhtCapabilities = Create<const VhtCapabilities>(vhtCapabilities);
1520}
1521
1522void
1523WifiRemoteStationManager::AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
1524{
1525 // Used by all stations to record HE capabilities of remote stations
1526 NS_LOG_FUNCTION(this << from << heCapabilities);
1527 auto state = LookupState(from);
1528 if ((m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_5GHZ) ||
1529 (m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_6GHZ))
1530 {
1531 if (heCapabilities.GetChannelWidthSet() & 0x04)
1532 {
1533 state->m_channelWidth = 160;
1534 }
1535 else if (heCapabilities.GetChannelWidthSet() & 0x02)
1536 {
1537 state->m_channelWidth = 80;
1538 }
1539 // For other cases at 5 GHz, the supported channel width is set by the VHT capabilities
1540 }
1541 else if (m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_2_4GHZ)
1542 {
1543 if (heCapabilities.GetChannelWidthSet() & 0x01)
1544 {
1545 state->m_channelWidth = 40;
1546 }
1547 else
1548 {
1549 state->m_channelWidth = 20;
1550 }
1551 }
1552 if (heCapabilities.GetHeSuPpdu1xHeLtf800nsGi())
1553 {
1554 state->m_guardInterval = 800;
1555 }
1556 else
1557 {
1558 // todo: Using 3200ns, default value for HeConfiguration::GuardInterval
1559 state->m_guardInterval = 3200;
1560 }
1561 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_HE))
1562 {
1563 if (heCapabilities.GetHighestMcsSupported() >= mcs.GetMcsValue())
1564 {
1565 AddSupportedMcs(from, mcs);
1566 }
1567 }
1568 state->m_heCapabilities = Create<const HeCapabilities>(heCapabilities);
1569 SetQosSupport(from, true);
1570}
1571
1572void
1573WifiRemoteStationManager::AddStationEhtCapabilities(Mac48Address from,
1574 EhtCapabilities ehtCapabilities)
1575{
1576 // Used by all stations to record EHT capabilities of remote stations
1577 NS_LOG_FUNCTION(this << from << ehtCapabilities);
1578 auto state = LookupState(from);
1579 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_EHT))
1580 {
1581 for (uint8_t mapType = 0; mapType < EhtMcsAndNssSet::EHT_MCS_MAP_TYPE_MAX; ++mapType)
1582 {
1583 if (ehtCapabilities.GetHighestSupportedRxMcs(
1584 static_cast<EhtMcsAndNssSet::EhtMcsMapType>(mapType)) >= mcs.GetMcsValue())
1585 {
1586 AddSupportedMcs(from, mcs);
1587 }
1588 }
1589 }
1590 state->m_ehtCapabilities = Create<const EhtCapabilities>(ehtCapabilities);
1591 SetQosSupport(from, true);
1592}
1593
1594void
1595WifiRemoteStationManager::AddStationMleCommonInfo(
1596 Mac48Address from,
1597 const std::shared_ptr<CommonInfoBasicMle>& mleCommonInfo)
1598{
1599 NS_LOG_FUNCTION(this << from);
1600 auto state = LookupState(from);
1601 state->m_mleCommonInfo = mleCommonInfo;
1602 // insert another entry in m_states indexed by the MLD address and pointing to the same state
1603 const_cast<WifiRemoteStationManager*>(this)->m_states.insert(
1604 {mleCommonInfo->m_mldMacAddress, state});
1605}
1606
1607Ptr<const HtCapabilities>
1608WifiRemoteStationManager::GetStationHtCapabilities(Mac48Address from)
1609{
1610 return LookupState(from)->m_htCapabilities;
1611}
1612
1614WifiRemoteStationManager::GetStationVhtCapabilities(Mac48Address from)
1615{
1616 return LookupState(from)->m_vhtCapabilities;
1617}
1618
1620WifiRemoteStationManager::GetStationHeCapabilities(Mac48Address from)
1621{
1622 return LookupState(from)->m_heCapabilities;
1623}
1624
1626WifiRemoteStationManager::GetStationEhtCapabilities(Mac48Address from)
1627{
1628 return LookupState(from)->m_ehtCapabilities;
1629}
1630
1631std::optional<std::reference_wrapper<CommonInfoBasicMle::EmlCapabilities>>
1632WifiRemoteStationManager::GetStationEmlCapabilities(const Mac48Address& from)
1633{
1634 if (auto state = LookupState(from);
1635 state->m_mleCommonInfo && state->m_mleCommonInfo->m_emlCapabilities)
1636 {
1637 return state->m_mleCommonInfo->m_emlCapabilities.value();
1638 }
1639 return std::nullopt;
1640}
1641
1642std::optional<std::reference_wrapper<CommonInfoBasicMle::MldCapabilities>>
1643WifiRemoteStationManager::GetStationMldCapabilities(const Mac48Address& from)
1644{
1645 if (auto state = LookupState(from);
1646 state->m_mleCommonInfo && state->m_mleCommonInfo->m_mldCapabilities)
1647 {
1648 return state->m_mleCommonInfo->m_mldCapabilities.value();
1649 }
1650 return std::nullopt;
1651}
1652
1653bool
1654WifiRemoteStationManager::GetLdpcSupported(Mac48Address address) const
1655{
1656 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
1657 Ptr<const VhtCapabilities> vhtCapabilities = LookupState(address)->m_vhtCapabilities;
1658 Ptr<const HeCapabilities> heCapabilities = LookupState(address)->m_heCapabilities;
1659 bool supported = false;
1660 if (htCapabilities)
1661 {
1662 supported |= htCapabilities->GetLdpc();
1663 }
1664 if (vhtCapabilities)
1665 {
1666 supported |= vhtCapabilities->GetRxLdpc();
1667 }
1668 if (heCapabilities)
1669 {
1670 supported |= heCapabilities->GetLdpcCodingInPayload();
1671 }
1672 return supported;
1673}
1674
1676WifiRemoteStationManager::GetDefaultMode() const
1677{
1678 return m_defaultTxMode;
1679}
1680
1682WifiRemoteStationManager::GetDefaultMcs() const
1683{
1684 return m_defaultTxMcs;
1685}
1686
1688WifiRemoteStationManager::GetDefaultModeForSta(const WifiRemoteStation* st) const
1689{
1690 NS_LOG_FUNCTION(this << st);
1691
1692 if (!GetHtSupported() || !GetHtSupported(st))
1693 {
1694 return GetDefaultMode();
1695 }
1696
1697 // find the highest modulation class supported by both stations
1699 if (GetHeSupported() && GetHeSupported(st))
1700 {
1701 modClass = WIFI_MOD_CLASS_HE;
1702 }
1703 else if (GetVhtSupported() && GetVhtSupported(st))
1704 {
1705 modClass = WIFI_MOD_CLASS_VHT;
1706 }
1707
1708 // return the MCS with lowest index
1709 return *m_wifiPhy->GetPhyEntity(modClass)->begin();
1710}
1711
1712void
1713WifiRemoteStationManager::Reset()
1714{
1715 NS_LOG_FUNCTION(this);
1716 m_states.clear();
1717 for (auto& state : m_stations)
1718 {
1719 delete (state.second);
1720 }
1721 m_stations.clear();
1722 m_bssBasicRateSet.clear();
1723 m_bssBasicMcsSet.clear();
1724 m_ssrc.fill(0);
1725 m_slrc.fill(0);
1726}
1727
1728void
1729WifiRemoteStationManager::AddBasicMode(WifiMode mode)
1730{
1731 NS_LOG_FUNCTION(this << mode);
1733 {
1734 NS_FATAL_ERROR("It is not allowed to add a HT rate in the BSSBasicRateSet!");
1735 }
1736 for (uint8_t i = 0; i < GetNBasicModes(); i++)
1737 {
1738 if (GetBasicMode(i) == mode)
1739 {
1740 return;
1741 }
1742 }
1743 m_bssBasicRateSet.push_back(mode);
1744}
1745
1746uint8_t
1747WifiRemoteStationManager::GetNBasicModes() const
1748{
1749 return static_cast<uint8_t>(m_bssBasicRateSet.size());
1750}
1751
1753WifiRemoteStationManager::GetBasicMode(uint8_t i) const
1754{
1755 NS_ASSERT(i < GetNBasicModes());
1756 return m_bssBasicRateSet[i];
1757}
1758
1760WifiRemoteStationManager::GetNNonErpBasicModes() const
1761{
1762 uint32_t size = 0;
1763 for (auto i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++)
1764 {
1765 if (i->GetModulationClass() == WIFI_MOD_CLASS_ERP_OFDM)
1766 {
1767 continue;
1768 }
1769 size++;
1770 }
1771 return size;
1772}
1773
1775WifiRemoteStationManager::GetNonErpBasicMode(uint8_t i) const
1776{
1777 NS_ASSERT(i < GetNNonErpBasicModes());
1778 uint32_t index = 0;
1779 bool found = false;
1780 for (auto j = m_bssBasicRateSet.begin(); j != m_bssBasicRateSet.end();)
1781 {
1782 if (i == index)
1783 {
1784 found = true;
1785 }
1786 if (j->GetModulationClass() != WIFI_MOD_CLASS_ERP_OFDM)
1787 {
1788 if (found)
1789 {
1790 break;
1791 }
1792 }
1793 index++;
1794 j++;
1795 }
1796 return m_bssBasicRateSet[index];
1797}
1798
1799void
1800WifiRemoteStationManager::AddBasicMcs(WifiMode mcs)
1801{
1802 NS_LOG_FUNCTION(this << +mcs.GetMcsValue());
1803 for (uint8_t i = 0; i < GetNBasicMcs(); i++)
1804 {
1805 if (GetBasicMcs(i) == mcs)
1806 {
1807 return;
1808 }
1809 }
1810 m_bssBasicMcsSet.push_back(mcs);
1811}
1812
1813uint8_t
1814WifiRemoteStationManager::GetNBasicMcs() const
1815{
1816 return static_cast<uint8_t>(m_bssBasicMcsSet.size());
1817}
1818
1820WifiRemoteStationManager::GetBasicMcs(uint8_t i) const
1821{
1822 NS_ASSERT(i < GetNBasicMcs());
1823 return m_bssBasicMcsSet[i];
1824}
1825
1827WifiRemoteStationManager::GetNonUnicastMode() const
1828{
1829 if (m_nonUnicastMode == WifiMode())
1830 {
1831 if (GetNBasicModes() > 0)
1832 {
1833 return GetBasicMode(0);
1834 }
1835 else
1836 {
1837 return GetDefaultMode();
1838 }
1839 }
1840 else
1841 {
1842 return m_nonUnicastMode;
1843 }
1844}
1845
1846bool
1847WifiRemoteStationManager::DoNeedRts(WifiRemoteStation* station, uint32_t size, bool normally)
1848{
1849 return normally;
1850}
1851
1852bool
1853WifiRemoteStationManager::DoNeedRetransmission(WifiRemoteStation* station,
1854 Ptr<const Packet> packet,
1855 bool normally)
1856{
1857 return normally;
1858}
1859
1860bool
1861WifiRemoteStationManager::DoNeedFragmentation(WifiRemoteStation* station,
1862 Ptr<const Packet> packet,
1863 bool normally)
1864{
1865 return normally;
1866}
1867
1868void
1869WifiRemoteStationManager::DoReportAmpduTxStatus(WifiRemoteStation* station,
1870 uint16_t nSuccessfulMpdus,
1871 uint16_t nFailedMpdus,
1872 double rxSnr,
1873 double dataSnr,
1874 uint16_t dataChannelWidth,
1875 uint8_t dataNss)
1876{
1877 NS_LOG_DEBUG("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
1878}
1879
1881WifiRemoteStationManager::GetSupported(const WifiRemoteStation* station, uint8_t i) const
1882{
1883 NS_ASSERT(i < GetNSupported(station));
1884 return station->m_state->m_operationalRateSet[i];
1885}
1886
1888WifiRemoteStationManager::GetMcsSupported(const WifiRemoteStation* station, uint8_t i) const
1889{
1890 NS_ASSERT(i < GetNMcsSupported(station));
1891 return station->m_state->m_operationalMcsSet[i];
1892}
1893
1895WifiRemoteStationManager::GetNonErpSupported(const WifiRemoteStation* station, uint8_t i) const
1896{
1897 NS_ASSERT(i < GetNNonErpSupported(station));
1898 // IEEE 802.11g standard defines that if the protection mechanism is enabled, RTS, CTS and
1899 // CTS-To-Self frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b
1900 // basic rate. This is a implemented here to avoid changes in every RAA, but should maybe be
1901 // moved in case it breaks standard rules.
1902 uint32_t index = 0;
1903 bool found = false;
1904 for (auto j = station->m_state->m_operationalRateSet.begin();
1905 j != station->m_state->m_operationalRateSet.end();)
1906 {
1907 if (i == index)
1908 {
1909 found = true;
1910 }
1911 if (j->GetModulationClass() != WIFI_MOD_CLASS_ERP_OFDM)
1912 {
1913 if (found)
1914 {
1915 break;
1916 }
1917 }
1918 index++;
1919 j++;
1920 }
1921 return station->m_state->m_operationalRateSet[index];
1922}
1923
1925WifiRemoteStationManager::GetAddress(const WifiRemoteStation* station) const
1926{
1927 return station->m_state->m_address;
1928}
1929
1930uint16_t
1931WifiRemoteStationManager::GetChannelWidth(const WifiRemoteStation* station) const
1932{
1933 return station->m_state->m_channelWidth;
1934}
1935
1936bool
1937WifiRemoteStationManager::GetShortGuardIntervalSupported(const WifiRemoteStation* station) const
1938{
1939 Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1940
1941 if (!htCapabilities)
1942 {
1943 return false;
1944 }
1945 return htCapabilities->GetShortGuardInterval20();
1946}
1947
1948uint16_t
1949WifiRemoteStationManager::GetGuardInterval(const WifiRemoteStation* station) const
1950{
1951 return station->m_state->m_guardInterval;
1952}
1953
1954bool
1955WifiRemoteStationManager::GetAggregation(const WifiRemoteStation* station) const
1956{
1957 return station->m_state->m_aggregation;
1958}
1959
1960uint8_t
1961WifiRemoteStationManager::GetNumberOfSupportedStreams(const WifiRemoteStation* station) const
1962{
1963 Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1964
1965 if (!htCapabilities)
1966 {
1967 return 1;
1968 }
1969 return htCapabilities->GetRxHighestSupportedAntennas();
1970}
1971
1972uint8_t
1973WifiRemoteStationManager::GetNess(const WifiRemoteStation* station) const
1974{
1975 return station->m_state->m_ness;
1976}
1977
1979WifiRemoteStationManager::GetPhy() const
1980{
1981 return m_wifiPhy;
1982}
1983
1985WifiRemoteStationManager::GetMac() const
1986{
1987 return m_wifiMac;
1988}
1989
1990uint8_t
1991WifiRemoteStationManager::GetNSupported(const WifiRemoteStation* station) const
1992{
1993 return static_cast<uint8_t>(station->m_state->m_operationalRateSet.size());
1994}
1995
1996bool
1997WifiRemoteStationManager::GetQosSupported(const WifiRemoteStation* station) const
1998{
1999 return station->m_state->m_qosSupported;
2000}
2001
2002bool
2003WifiRemoteStationManager::GetHtSupported(const WifiRemoteStation* station) const
2004{
2005 return bool(station->m_state->m_htCapabilities);
2006}
2007
2008bool
2009WifiRemoteStationManager::GetVhtSupported(const WifiRemoteStation* station) const
2010{
2011 return bool(station->m_state->m_vhtCapabilities);
2012}
2013
2014bool
2015WifiRemoteStationManager::GetHeSupported(const WifiRemoteStation* station) const
2016{
2017 return bool(station->m_state->m_heCapabilities);
2018}
2019
2020bool
2021WifiRemoteStationManager::GetEhtSupported(const WifiRemoteStation* station) const
2022{
2023 return (bool)(station->m_state->m_ehtCapabilities);
2024}
2025
2026bool
2027WifiRemoteStationManager::GetEmlsrSupported(const WifiRemoteStation* station) const
2028{
2029 auto mleCommonInfo = station->m_state->m_mleCommonInfo;
2030 return mleCommonInfo && mleCommonInfo->m_emlCapabilities &&
2031 mleCommonInfo->m_emlCapabilities->emlsrSupport == 1;
2032}
2033
2034bool
2035WifiRemoteStationManager::GetEmlsrEnabled(const WifiRemoteStation* station) const
2036{
2037 return station->m_state->m_emlsrEnabled;
2038}
2039
2040uint8_t
2041WifiRemoteStationManager::GetNMcsSupported(const WifiRemoteStation* station) const
2042{
2043 return static_cast<uint8_t>(station->m_state->m_operationalMcsSet.size());
2044}
2045
2047WifiRemoteStationManager::GetNNonErpSupported(const WifiRemoteStation* station) const
2048{
2049 uint32_t size = 0;
2050 for (auto i = station->m_state->m_operationalRateSet.begin();
2051 i != station->m_state->m_operationalRateSet.end();
2052 i++)
2053 {
2054 if (i->GetModulationClass() == WIFI_MOD_CLASS_ERP_OFDM)
2055 {
2056 continue;
2057 }
2058 size++;
2059 }
2060 return size;
2061}
2062
2063uint16_t
2064WifiRemoteStationManager::GetChannelWidthSupported(Mac48Address address) const
2065{
2066 return LookupState(address)->m_channelWidth;
2067}
2068
2069bool
2070WifiRemoteStationManager::GetShortGuardIntervalSupported(Mac48Address address) const
2071{
2072 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
2073
2074 if (!htCapabilities)
2075 {
2076 return false;
2077 }
2078 return htCapabilities->GetShortGuardInterval20();
2079}
2080
2081uint8_t
2082WifiRemoteStationManager::GetNumberOfSupportedStreams(Mac48Address address) const
2083{
2084 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
2085
2086 if (!htCapabilities)
2087 {
2088 return 1;
2089 }
2090 return htCapabilities->GetRxHighestSupportedAntennas();
2091}
2092
2093uint8_t
2094WifiRemoteStationManager::GetNMcsSupported(Mac48Address address) const
2095{
2096 return static_cast<uint8_t>(LookupState(address)->m_operationalMcsSet.size());
2097}
2098
2099bool
2100WifiRemoteStationManager::GetDsssSupported(const Mac48Address& address) const
2101{
2102 return (LookupState(address)->m_dsssSupported);
2103}
2104
2105bool
2106WifiRemoteStationManager::GetErpOfdmSupported(const Mac48Address& address) const
2107{
2108 return (LookupState(address)->m_erpOfdmSupported);
2109}
2110
2111bool
2112WifiRemoteStationManager::GetOfdmSupported(const Mac48Address& address) const
2113{
2114 return (LookupState(address)->m_ofdmSupported);
2115}
2116
2117bool
2118WifiRemoteStationManager::GetHtSupported(Mac48Address address) const
2119{
2120 return bool(LookupState(address)->m_htCapabilities);
2121}
2122
2123bool
2124WifiRemoteStationManager::GetVhtSupported(Mac48Address address) const
2125{
2126 return bool(LookupState(address)->m_vhtCapabilities);
2127}
2128
2129bool
2130WifiRemoteStationManager::GetHeSupported(Mac48Address address) const
2131{
2132 return bool(LookupState(address)->m_heCapabilities);
2133}
2134
2135bool
2136WifiRemoteStationManager::GetEhtSupported(Mac48Address address) const
2137{
2138 return (bool)(LookupState(address)->m_ehtCapabilities);
2139}
2140
2141bool
2142WifiRemoteStationManager::GetEmlsrSupported(const Mac48Address& address) const
2143{
2144 auto mleCommonInfo = LookupState(address)->m_mleCommonInfo;
2145 return mleCommonInfo && mleCommonInfo->m_emlCapabilities &&
2146 mleCommonInfo->m_emlCapabilities->emlsrSupport == 1;
2147}
2148
2149bool
2150WifiRemoteStationManager::GetEmlsrEnabled(const Mac48Address& address) const
2151{
2152 if (auto stateIt = m_states.find(address); stateIt != m_states.cend())
2153 {
2154 return stateIt->second->m_emlsrEnabled;
2155 }
2156 return false;
2157}
2158
2159void
2160WifiRemoteStationManager::SetDefaultTxPowerLevel(uint8_t txPower)
2161{
2162 m_defaultTxPowerLevel = txPower;
2163}
2164
2165uint8_t
2166WifiRemoteStationManager::GetNumberOfAntennas() const
2167{
2168 return m_wifiPhy->GetNumberOfAntennas();
2169}
2170
2171uint8_t
2172WifiRemoteStationManager::GetMaxNumberOfTransmitStreams() const
2173{
2174 return m_wifiPhy->GetMaxSupportedTxSpatialStreams();
2175}
2176
2177bool
2178WifiRemoteStationManager::UseLdpcForDestination(Mac48Address dest) const
2179{
2180 return (GetLdpcSupported() && GetLdpcSupported(dest));
2181}
2182
2183} // namespace ns3
The IEEE 802.11be EHT Capabilities.
uint8_t GetHighestSupportedRxMcs(EhtMcsAndNssSet::EhtMcsMapType mapType)
Get the highest supported RX MCS for a given EHT-MCS map type.
Hold variables of type enum.
Definition: enum.h:56
static WifiMode GetErpOfdmRate(uint64_t rate)
Return a WifiMode for ERP-OFDM corresponding to the provided rate.
The IEEE 802.11ax HE Capabilities.
uint8_t GetHighestMcsSupported() const
Get highest MCS supported.
bool GetHeSuPpdu1xHeLtf800nsGi() const
Get 1xHE-LTF and 800ns GI in HE SU PPDU reception support.
uint8_t GetChannelWidthSet() const
Get channel width set.
The HT Capabilities Information Element.
uint8_t GetSupportedChannelWidth() const
Return the supported channel width.
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
static WifiMode GetHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition: ht-phy.cc:488
an EUI-48 address
Definition: mac48-address.h:46
bool IsGroup() const
A base class which provides memory management and object aggregation.
Definition: object.h:89
static WifiMode GetOfdmRate(uint64_t rate, uint16_t bw=20)
Return a WifiMode for OFDM corresponding to the provided rate and the channel bandwidth (20,...
Definition: ofdm-phy.cc:411
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:199
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:930
Hold an unsigned integer type.
Definition: uinteger.h:45
The IEEE 802.11ac VHT Capabilities.
bool IsSupportedMcs(uint8_t mcs, uint8_t nss) const
Get the is MCS supported.
uint8_t GetSupportedChannelWidthSet() const
Get the supported channel width set.
Implements the IEEE 802.11 MAC header.
uint8_t GetQosTid() const
Return the Traffic ID of a QoS header.
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
bool IsMgt() const
Return true if the Type is Management.
bool IsQosData() const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
TypeOfStation GetTypeOfStation() const
Return the type of station.
Definition: wifi-mac.cc:427
represent a single transmission mode
Definition: wifi-mode.h:51
bool IsHigherDataRate(WifiMode mode) const
Definition: wifi-mode.cc:208
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:185
bool IsMandatory() const
Definition: wifi-mode.cc:156
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:122
uint8_t GetMcsValue() const
Definition: wifi-mode.cc:163
AttributeValue implementation for WifiMode.
Ptr< VhtConfiguration > GetVhtConfiguration() const
Ptr< EhtConfiguration > GetEhtConfiguration() const
Ptr< HtConfiguration > GetHtConfiguration() const
Ptr< HeConfiguration > GetHeConfiguration() const
uint16_t GetChannelWidth() const
Definition: wifi-phy.cc:1035
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:1005
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
Definition: wifi-phy.cc:615
uint16_t GetTxBandwidth(WifiMode mode, uint16_t maxAllowedBandWidth=std::numeric_limits< uint16_t >::max()) const
Get the bandwidth for a transmission occurring on the current operating channel and using the given W...
Definition: wifi-phy.cc:1059
std::list< WifiMode > GetMcsList() const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
Definition: wifi-phy.cc:1989
std::list< WifiMode > GetModeList() const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition: wifi-phy.cc:1940
TID independent remote station statistics.
void NotifyTxSuccess(uint32_t retryCounter)
Updates average frame error rate when data or RTS was transmitted successfully.
void NotifyTxFailed()
Updates average frame error rate when final data or RTS has failed.
hold a list of per-remote-station state.
void ReportDataFailed(Ptr< const WifiMpdu > mpdu)
Should be invoked whenever the AckTimeout associated to a transmission attempt expires.
bool GetQosSupported(Mac48Address address) const
Return whether the given station is QoS capable.
WifiTxVector GetAckTxVector(Mac48Address to, const WifiTxVector &dataTxVector) const
Return a TXVECTOR for the Ack frame given the destination and the mode of the Data used by the sender...
virtual bool DoNeedFragmentation(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
uint32_t m_fragmentationThreshold
Current threshold for fragmentation.
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
void SetPsMode(const Mac48Address &address, bool isInPsMode)
Register whether the STA is in Power Save mode or not.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
uint32_t GetNFragments(Ptr< const WifiMpdu > mpdu)
Return the number of fragments needed for the given packet.
uint16_t GetAssociationId(Mac48Address remoteAddress) const
Get the AID of a remote station.
WifiMode m_defaultTxMcs
The default transmission modulation-coding scheme (MCS)
ProtectionMode m_htProtectionMode
Protection mode for HT stations when non-HT stations are detected.
void AdjustTxVectorForIcf(WifiTxVector &txVector) const
Adjust the TXVECTOR for an initial Control frame to ensure that the modulation class is non-HT and th...
std::array< uint32_t, AC_BE_NQOS > m_slrc
long retry count per AC
WifiRemoteStation * Lookup(Mac48Address address) const
Return the station associated with the given address.
uint32_t GetFragmentationThreshold() const
Return the fragmentation threshold.
bool NeedRetransmission(Ptr< const WifiMpdu > mpdu)
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)
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.
bool GetShortSlotTimeEnabled() const
Return whether the device uses short slot time.
void DoDispose() override
Destructor implementation.
virtual void DoReportDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
bool NeedRts(const WifiMacHeader &header, uint32_t size)
bool IsLastFragment(Ptr< const WifiMpdu > mpdu, uint32_t fragmentNumber)
void ReportFinalDataFailed(Ptr< const WifiMpdu > mpdu)
Should be invoked after calling ReportDataFailed if NeedRetransmission returns false.
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
bool m_useNonHtProtection
flag if protection for non-HT stations against HT transmissions is enabled
bool GetShortPreambleSupported(Mac48Address address) const
Return whether the station supports short PHY preamble or not.
void AddAllSupportedModes(Mac48Address address)
Invoked in a STA or AP to store all of the modes supported by a destination which is also supported l...
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...
void ReportRtsOk(const WifiMacHeader &header, double ctsSnr, WifiMode ctsMode, double rtsSnr)
Should be invoked whenever we receive the CTS associated to an RTS we just sent.
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
WifiTxVector GetBlockAckTxVector(Mac48Address to, const WifiTxVector &dataTxVector) const
Return a TXVECTOR for the BlockAck frame given the destination and the mode of the Data used by the s...
void RemoveAllSupportedMcs(Mac48Address address)
Invoked in a STA or AP to delete all of the supported MCS by a destination.
uint32_t DoGetFragmentationThreshold() const
Return the current fragmentation threshold.
WifiModeList m_bssBasicMcsSet
basic MCS set
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
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.
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint16_t allowedWidth)=0
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 ReportRxOk(Mac48Address address, RxSignalInfo rxSignalInfo, WifiTxVector txVector)
uint8_t m_defaultTxPowerLevel
Default transmission power level.
static TypeId GetTypeId()
Get the type ID.
WifiMode m_nonUnicastMode
Transmission mode for non-unicast Data frames.
void SetUseNonHtProtection(bool enable)
Enable or disable protection for non-HT stations.
uint16_t GetGuardInterval() const
Return the supported HE guard interval duration (in nanoseconds).
bool IsAssociated(Mac48Address address) const
Return whether the station associated.
bool NeedFragmentation(Ptr< const WifiMpdu > mpdu)
void ReportAmpduTxStatus(Mac48Address address, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus, double rxSnr, double dataSnr, WifiTxVector dataTxVector)
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
uint32_t GetFragmentOffset(Ptr< const WifiMpdu > mpdu, uint32_t fragmentNumber)
WifiRemoteStationInfo GetInfo(Mac48Address address)
uint32_t GetFragmentSize(Ptr< const WifiMpdu > mpdu, uint32_t fragmentNumber)
WifiTxVector GetCtsToSelfTxVector()
Since CTS-to-self parameters are not dependent on the station, it is implemented in wifi remote stati...
uint8_t GetNBasicMcs() const
Return the number of basic MCS index.
bool GetHtSupported() const
Return whether the device has HT capability support enabled.
void RecordWaitAssocTxOk(Mac48Address address)
Records that we are waiting for an ACK for the association response we sent.
void SetFragmentationThreshold(uint32_t threshold)
Sets a fragmentation threshold.
Ptr< WifiMac > m_wifiMac
This is a pointer to the WifiMac associated with this WifiRemoteStationManager that is set on call to...
void RecordGotAssocTxOk(Mac48Address address)
Records that we got an ACK for the association response we sent.
bool GetLdpcSupported() const
Return whether the device has LDPC support enabled.
bool GetEhtSupported() const
Return whether the device has EHT capability support enabled.
void AddSupportedMode(Mac48Address address, WifiMode mode)
Invoked in a STA or AP to store the set of modes supported by a destination which is also supported l...
std::optional< double > GetMostRecentRssi(Mac48Address address) const
std::shared_ptr< WifiRemoteStationState > LookupState(Mac48Address address) const
Return the state of the station associated with the given address.
std::array< uint32_t, AC_BE_NQOS > m_ssrc
short retry count per AC
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 NeedRetransmission returns false.
StationStates m_states
States of known stations.
bool NeedCtsToSelf(WifiTxVector txVector)
Return if we need to do CTS-to-self before sending a DATA.
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.
void SetMaxSsrc(uint32_t maxSsrc)
Sets the maximum STA short retry count (SSRC).
WifiMode GetBasicMcs(uint8_t i) const
Return the MCS at the given list index.
TracedCallback< Mac48Address > m_macTxDataFailed
The trace source fired when the transmission of a single data packet has failed.
uint16_t GetStaId(Mac48Address address, const WifiTxVector &txVector) const
If the given TXVECTOR is used for a MU transmission, return the STAID of the station with the given a...
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
void AddSupportedPhyPreamble(Mac48Address address, bool isShortPreambleSupported)
Record whether the short PHY preamble is supported by the station.
bool GetShortGuardIntervalSupported() const
Return whether the device has SGI support enabled.
virtual void SetupPhy(const Ptr< WifiPhy > phy)
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
virtual void DoReportRtsFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)=0
uint16_t GetChannelWidthSupported(Mac48Address address) const
Return the channel width supported by the station.
uint32_t m_maxSlrc
Maximum STA long retry count (SLRC)
void Reset()
Reset the station, invoked in a STA upon dis-association or in an AP upon reboot.
bool GetUseNonErpProtection() const
Return whether the device supports protection of non-ERP stations.
bool IsAssocRefused(Mac48Address address) const
Return whether we refused an association request from the given station.
virtual void DoReportAmpduTxStatus(WifiRemoteStation *station, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus, double rxSnr, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
bool GetVhtSupported() const
Return whether the device has VHT capability support enabled.
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.
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)=0
This method is a pure virtual method that must be implemented by the sub-class.
WifiTxVector GetDataTxVector(const WifiMacHeader &header, uint16_t allowedWidth)
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.
bool GetHeSupported() const
Return whether the device has HE capability support enabled.
WifiMode m_defaultTxMode
The default transmission mode.
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.
virtual bool DoNeedRetransmission(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
WifiMode GetDefaultMode() const
Return the default transmission mode.
void RecordGotAssocTxFailed(Mac48Address address)
Records that we missed an ACK for the association response we sent.
std::optional< Mac48Address > GetMldAddress(const Mac48Address &address) const
Get the address of the MLD the given station is affiliated with, if any.
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
virtual void SetupMac(const Ptr< WifiMac > mac)
Set up MAC associated with this device since it is the object that knows the full set of timing param...
WifiTxVector GetRtsTxVector(Mac48Address address)
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 mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetNess(uint8_t ness)
Sets the Ness number.
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
void SetLdpc(bool ldpc)
Sets if LDPC FEC coding is being used.
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
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.
void SetBssColor(uint8_t color)
Set the BSS color.
void SetNTx(uint8_t nTx)
Sets the number of TX antennas.
uint16_t GetChannelWidth() const
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:66
#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:86
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:205
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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:261
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1325
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Definition: qos-utils.cc:134
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:72
@ STA
Definition: wifi-mac.h:65
@ AP
Definition: wifi-mac.h:66
@ 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.
Definition: wifi-phy-band.h:39
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
Definition: wifi-phy-band.h:35
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Definition: wifi-phy-band.h:37
@ 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.
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octets of the IEEE 802.11 MAC FCS field.
bool IsAllowedControlAnswerModulationClass(WifiModulationClass modClassReq, WifiModulationClass modClassAnswer)
Return whether the modulation class of the selected mode for the control answer frame is allowed.
uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode, const Ptr< WifiNetDevice > device)
Convert the guard interval to nanoseconds based on the WifiMode.
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
std::vector< WifiMode > WifiModeList
In various parts of the code, folk are interested in maintaining a list of transmission modes.
Definition: wifi-mode.h:262
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
Definition: wifi-mode.h:35
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:163
EhtMcsMapType
The different EHT-MCS map types as defined in 9.4.2.313.4 Supported EHT-MCS And NSS Set field.
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:69
double rssi
RSSI in dBm.
Definition: phy-entity.h:71
double snr
SNR in linear scale.
Definition: phy-entity.h:70
hold per-remote-station state.
WifiRemoteStationState * m_state
Remote station state.
std::pair< double, Time > m_rssiAndUpdateTimePair
RSSI (in dBm) 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.
uint16_t m_channelWidth
Channel width (in MHz) 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
uint16_t m_guardInterval
HE Guard interval duration (in nanoseconds) supported by the remote station.
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
Ptr< const HeCapabilities > m_heCapabilities
remote station HE capabilities