A Discrete-Event Network Simulator
API
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/he-configuration.h"
34#include "ns3/ht-configuration.h"
35#include "ns3/ht-phy.h"
36#include "ns3/log.h"
37#include "ns3/simulator.h"
38#include "ns3/uinteger.h"
39#include "ns3/vht-configuration.h"
40
41namespace ns3
42{
43
44NS_LOG_COMPONENT_DEFINE("WifiRemoteStationManager");
45
46NS_OBJECT_ENSURE_REGISTERED(WifiRemoteStationManager);
47
48TypeId
50{
51 static TypeId tid =
52 TypeId("ns3::WifiRemoteStationManager")
54 .SetGroupName("Wifi")
55 .AddAttribute("MaxSsrc",
56 "The maximum number of retransmission attempts for any packet with size "
57 "<= RtsCtsThreshold. "
58 "This value will not have any effect on some rate control algorithms.",
61 MakeUintegerChecker<uint32_t>())
62 .AddAttribute("MaxSlrc",
63 "The maximum number of retransmission attempts for any packet with size "
64 "> RtsCtsThreshold. "
65 "This value will not have any effect on some rate control algorithms.",
68 MakeUintegerChecker<uint32_t>())
69 .AddAttribute("RtsCtsThreshold",
70 "If the size of the PSDU is bigger than this value, we use an RTS/CTS "
71 "handshake before sending the data frame."
72 "This value will not have any effect on some rate control algorithms.",
73 UintegerValue(65535),
75 MakeUintegerChecker<uint32_t>())
76 .AddAttribute(
77 "FragmentationThreshold",
78 "If the size of the PSDU is bigger than this value, we fragment it such that the "
79 "size of the fragments are equal or smaller. "
80 "This value does not apply when it is carried in an A-MPDU. "
81 "This value will not have any effect on some rate control algorithms.",
82 UintegerValue(65535),
85 MakeUintegerChecker<uint32_t>())
86 .AddAttribute("NonUnicastMode",
87 "Wifi mode used for non-unicast transmissions.",
89 MakeWifiModeAccessor(&WifiRemoteStationManager::m_nonUnicastMode),
90 MakeWifiModeChecker())
91 .AddAttribute("DefaultTxPowerLevel",
92 "Default power level to be used for transmissions. "
93 "This is the power level that is used by all those WifiManagers that do "
94 "not implement TX power control.",
97 MakeUintegerChecker<uint8_t>())
98 .AddAttribute("ErpProtectionMode",
99 "Protection mode used when non-ERP STAs are connected to an ERP AP: "
100 "Rts-Cts or Cts-To-Self",
104 "Rts-Cts",
106 "Cts-To-Self"))
107 .AddAttribute("HtProtectionMode",
108 "Protection mode used when non-HT STAs are connected to a HT AP: Rts-Cts "
109 "or Cts-To-Self",
113 "Rts-Cts",
115 "Cts-To-Self"))
116 .AddTraceSource("MacTxRtsFailed",
117 "The transmission of a RTS by the MAC layer has failed",
119 "ns3::Mac48Address::TracedCallback")
120 .AddTraceSource("MacTxDataFailed",
121 "The transmission of a data packet by the MAC layer has failed",
123 "ns3::Mac48Address::TracedCallback")
124 .AddTraceSource(
125 "MacTxFinalRtsFailed",
126 "The transmission of a RTS has exceeded the maximum number of attempts",
128 "ns3::Mac48Address::TracedCallback")
129 .AddTraceSource(
130 "MacTxFinalDataFailed",
131 "The transmission of a data packet has exceeded the maximum number of attempts",
133 "ns3::Mac48Address::TracedCallback");
134 return tid;
135}
136
138 : m_useNonErpProtection(false),
139 m_useNonHtProtection(false),
140 m_shortPreambleEnabled(false),
141 m_shortSlotTimeEnabled(false)
142{
143 NS_LOG_FUNCTION(this);
144}
145
147{
148 NS_LOG_FUNCTION(this);
149}
150
151void
153{
154 NS_LOG_FUNCTION(this);
155 Reset();
156}
157
158void
160{
161 NS_LOG_FUNCTION(this << phy);
162 // We need to track our PHY because it is the object that knows the
163 // full set of transmit rates that are supported. We need to know
164 // this in order to find the relevant mandatory rates when choosing a
165 // transmit rate for automatic control responses like
166 // acknowledgments.
167 m_wifiPhy = phy;
168 m_defaultTxMode = phy->GetDefaultMode();
170 if (GetHtSupported())
171 {
173 }
174 Reset();
175}
176
177void
179{
180 NS_LOG_FUNCTION(this << mac);
181 // We need to track our MAC because it is the object that knows the
182 // full set of interframe spaces.
183 m_wifiMac = mac;
184 Reset();
185}
186
187int64_t
189{
190 NS_LOG_FUNCTION(this << stream);
191 return 0;
192}
193
194void
196{
197 NS_LOG_FUNCTION(this << maxSsrc);
198 m_maxSsrc = maxSsrc;
199}
200
201void
203{
204 NS_LOG_FUNCTION(this << maxSlrc);
205 m_maxSlrc = maxSlrc;
206}
207
208void
210{
211 NS_LOG_FUNCTION(this << threshold);
212 m_rtsCtsThreshold = threshold;
213}
214
215void
217{
218 NS_LOG_FUNCTION(this << threshold);
220}
221
222void
224{
225 NS_LOG_FUNCTION(this << enable);
226 m_shortPreambleEnabled = enable;
227}
228
229void
231{
232 NS_LOG_FUNCTION(this << enable);
233 m_shortSlotTimeEnabled = enable;
234}
235
236bool
238{
240}
241
242bool
244{
246}
247
248bool
250{
251 return bool(m_wifiPhy->GetDevice()->GetHtConfiguration());
252}
253
254bool
256{
259}
260
261bool
263{
264 return bool(m_wifiPhy->GetDevice()->GetHeConfiguration());
265}
266
267bool
269{
270 return bool(m_wifiPhy->GetDevice()->GetEhtConfiguration());
271}
272
273bool
275{
276 if (GetHtSupported())
277 {
279 NS_ASSERT(htConfiguration); // If HT is supported, we should have a HT configuration
280 // attached
281 return htConfiguration->GetLdpcSupported();
282 }
283 return false;
284}
285
286bool
288{
289 if (GetHtSupported())
290 {
292 NS_ASSERT(htConfiguration); // If HT is supported, we should have a HT configuration
293 // attached
294 if (htConfiguration->GetShortGuardIntervalSupported())
295 {
296 return true;
297 }
298 }
299 return false;
300}
301
302uint16_t
304{
305 uint16_t gi = 0;
306 if (GetHeSupported())
307 {
309 NS_ASSERT(heConfiguration); // If HE is supported, we should have a HE configuration
310 // attached
311 gi = static_cast<uint16_t>(heConfiguration->GetGuardInterval().GetNanoSeconds());
312 }
313 return gi;
314}
315
318{
320}
321
322void
324 bool isShortPreambleSupported)
325{
326 NS_LOG_FUNCTION(this << address << isShortPreambleSupported);
327 NS_ASSERT(!address.IsGroup());
328 LookupState(address)->m_shortPreamble = isShortPreambleSupported;
329}
330
331void
333 bool isShortSlotTimeSupported)
334{
335 NS_LOG_FUNCTION(this << address << isShortSlotTimeSupported);
336 NS_ASSERT(!address.IsGroup());
337 LookupState(address)->m_shortSlotTime = isShortSlotTimeSupported;
338}
339
340void
342{
343 NS_LOG_FUNCTION(this << address << mode);
344 NS_ASSERT(!address.IsGroup());
345 auto state = LookupState(address);
346 for (const auto& i : state->m_operationalRateSet)
347 {
348 if (i == mode)
349 {
350 return; // already in
351 }
352 }
353 if ((mode.GetModulationClass() == WIFI_MOD_CLASS_DSSS) ||
355 {
356 state->m_dsssSupported = true;
357 }
359 {
360 state->m_erpOfdmSupported = true;
361 }
362 else if (mode.GetModulationClass() == WIFI_MOD_CLASS_OFDM)
363 {
364 state->m_ofdmSupported = true;
365 }
366 state->m_operationalRateSet.push_back(mode);
367}
368
369void
371{
372 NS_LOG_FUNCTION(this << address);
373 NS_ASSERT(!address.IsGroup());
374 auto state = LookupState(address);
375 state->m_operationalRateSet.clear();
376 for (const auto& mode : m_wifiPhy->GetModeList())
377 {
378 state->m_operationalRateSet.push_back(mode);
379 if (mode.IsMandatory())
380 {
381 AddBasicMode(mode);
382 }
383 }
384}
385
386void
388{
389 NS_LOG_FUNCTION(this << address);
390 NS_ASSERT(!address.IsGroup());
391 auto state = LookupState(address);
392 state->m_operationalMcsSet.clear();
393 for (const auto& mcs : m_wifiPhy->GetMcsList())
394 {
395 state->m_operationalMcsSet.push_back(mcs);
396 }
397}
398
399void
401{
402 NS_LOG_FUNCTION(this << address);
403 NS_ASSERT(!address.IsGroup());
404 LookupState(address)->m_operationalMcsSet.clear();
405}
406
407void
409{
410 NS_LOG_FUNCTION(this << address << mcs);
411 NS_ASSERT(!address.IsGroup());
412 auto state = LookupState(address);
413 for (const auto& i : state->m_operationalMcsSet)
414 {
415 if (i == mcs)
416 {
417 return; // already in
418 }
419 }
420 state->m_operationalMcsSet.push_back(mcs);
421}
422
423bool
425{
426 return LookupState(address)->m_shortPreamble;
427}
428
429bool
431{
432 return LookupState(address)->m_shortSlotTime;
433}
434
435bool
437{
438 return LookupState(address)->m_qosSupported;
439}
440
441bool
443{
444 if (address.IsGroup())
445 {
446 return false;
447 }
449}
450
451bool
453{
454 if (address.IsGroup())
455 {
456 return true;
457 }
459}
460
461bool
463{
464 if (address.IsGroup())
465 {
466 return false;
467 }
469}
470
471void
473{
474 NS_ASSERT(!address.IsGroup());
476}
477
478void
480{
481 NS_ASSERT(!address.IsGroup());
483}
484
485void
487{
488 NS_ASSERT(!address.IsGroup());
490}
491
492void
494{
495 NS_ASSERT(!address.IsGroup());
497}
498
499bool
501{
502 if (address.IsGroup())
503 {
504 return false;
505 }
507}
508
509void
511{
512 NS_ASSERT(!address.IsGroup());
514}
515
516uint16_t
518{
519 std::shared_ptr<WifiRemoteStationState> state;
520 if (!remoteAddress.IsGroup() &&
521 (state = LookupState(remoteAddress))->m_state == WifiRemoteStationState::GOT_ASSOC_TX_OK)
522 {
523 return state->m_aid;
524 }
525 return SU_STA_ID;
526}
527
528uint16_t
530{
531 NS_LOG_FUNCTION(this << address << txVector);
532
533 uint16_t staId = SU_STA_ID;
534
535 if (txVector.IsMu())
536 {
537 if (m_wifiMac->GetTypeOfStation() == AP)
538 {
539 staId = GetAssociationId(address);
540 }
541 else if (m_wifiMac->GetTypeOfStation() == STA)
542 {
543 Ptr<StaWifiMac> staMac = StaticCast<StaWifiMac>(m_wifiMac);
544 if (staMac->IsAssociated())
545 {
546 staId = staMac->GetAssociationId();
547 }
548 }
549 }
550
551 NS_LOG_DEBUG("Returning STAID = " << staId);
552 return staId;
553}
554
555void
557{
558 NS_LOG_FUNCTION(this << address << mldAddress);
559
560 auto state = LookupState(address);
561 state->m_mldAddress = mldAddress;
562 // insert another entry in m_states indexed by the MLD address and pointing to the same state
563 const_cast<WifiRemoteStationManager*>(this)->m_states.insert({mldAddress, state});
564}
565
566std::optional<Mac48Address>
567WifiRemoteStationManager::GetMldAddress(const Mac48Address& address) const
568{
569 return LookupState(address)->m_mldAddress;
570}
571
572std::optional<Mac48Address>
573WifiRemoteStationManager::GetAffiliatedStaAddress(const Mac48Address& mldAddress) const
574{
575 auto stateIt = m_states.find(mldAddress);
576
577 if (stateIt == m_states.end())
578 {
579 // MLD address not found
580 return std::optional<Mac48Address>();
581 }
582
583 NS_ASSERT(stateIt->second->m_mldAddress.has_value() &&
584 *stateIt->second->m_mldAddress == mldAddress);
585 return stateIt->second->m_address;
586}
587
589WifiRemoteStationManager::GetDataTxVector(const WifiMacHeader& header, uint16_t allowedWidth)
590{
591 NS_LOG_FUNCTION(this << header << allowedWidth);
592 Mac48Address address = header.GetAddr1();
593 if (!header.IsMgt() && address.IsGroup())
594 {
595 WifiMode mode = GetNonUnicastMode();
596 WifiTxVector v;
597 v.SetMode(mode);
599 GetPreambleForTransmission(mode.GetModulationClass(), GetShortPreambleEnabled()));
600 v.SetTxPowerLevel(m_defaultTxPowerLevel);
601 v.SetChannelWidth(GetChannelWidthForTransmission(mode, allowedWidth));
602 v.SetGuardInterval(ConvertGuardIntervalToNanoSeconds(mode, m_wifiPhy->GetDevice()));
603 v.SetNTx(GetNumberOfAntennas());
604 v.SetNss(1);
605 v.SetNess(0);
606 return v;
607 }
608 WifiTxVector txVector;
609 if (header.IsMgt())
610 {
611 // Use the lowest basic rate for management frames
612 WifiMode mgtMode;
613 if (GetNBasicModes() > 0)
614 {
615 mgtMode = GetBasicMode(0);
616 }
617 else
618 {
619 mgtMode = GetDefaultMode();
620 }
621 txVector.SetMode(mgtMode);
622 txVector.SetPreambleType(
623 GetPreambleForTransmission(mgtMode.GetModulationClass(), GetShortPreambleEnabled()));
624 txVector.SetTxPowerLevel(m_defaultTxPowerLevel);
625 uint16_t channelWidth = allowedWidth;
626 if (!header.GetAddr1().IsGroup())
627 {
628 if (uint16_t rxWidth = GetChannelWidthSupported(header.GetAddr1());
629 rxWidth < channelWidth)
630 {
631 channelWidth = rxWidth;
632 }
633 }
634
635 txVector.SetChannelWidth(GetChannelWidthForTransmission(mgtMode, channelWidth));
636 txVector.SetGuardInterval(
637 ConvertGuardIntervalToNanoSeconds(mgtMode, m_wifiPhy->GetDevice()));
638 }
639 else
640 {
641 txVector = DoGetDataTxVector(Lookup(address), allowedWidth);
643 ? 0
644 : UseLdpcForDestination(address));
645 }
646 Ptr<HeConfiguration> heConfiguration = m_wifiPhy->GetDevice()->GetHeConfiguration();
647 if (heConfiguration)
648 {
649 txVector.SetBssColor(heConfiguration->GetBssColor());
650 }
651 // If both the allowed width and the TXVECTOR channel width are integer multiple
652 // of 20 MHz, then the TXVECTOR channel width must not exceed the allowed width
653 NS_ASSERT_MSG((txVector.GetChannelWidth() % 20 != 0) || (allowedWidth % 20 != 0) ||
654 (txVector.GetChannelWidth() <= allowedWidth),
655 "TXVECTOR channel width (" << txVector.GetChannelWidth()
656 << " MHz) exceeds allowed width (" << allowedWidth
657 << " MHz)");
658 return txVector;
659}
660
662WifiRemoteStationManager::GetCtsToSelfTxVector()
663{
664 WifiMode defaultMode = GetDefaultMode();
665 WifiPreamble defaultPreamble;
666 if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_EHT)
667 {
668 defaultPreamble = WIFI_PREAMBLE_EHT_MU;
669 }
670 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_HE)
671 {
672 defaultPreamble = WIFI_PREAMBLE_HE_SU;
673 }
674 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_VHT)
675 {
676 defaultPreamble = WIFI_PREAMBLE_VHT_SU;
677 }
678 else if (defaultMode.GetModulationClass() == WIFI_MOD_CLASS_HT)
679 {
680 defaultPreamble = WIFI_PREAMBLE_HT_MF;
681 }
682 else
683 {
684 defaultPreamble = WIFI_PREAMBLE_LONG;
685 }
686
687 return WifiTxVector(defaultMode,
688 GetDefaultTxPowerLevel(),
689 defaultPreamble,
690 ConvertGuardIntervalToNanoSeconds(defaultMode, m_wifiPhy->GetDevice()),
691 GetNumberOfAntennas(),
692 1,
693 0,
694 GetChannelWidthForTransmission(defaultMode, m_wifiPhy->GetChannelWidth()),
695 false);
696}
697
699WifiRemoteStationManager::GetRtsTxVector(Mac48Address address)
700{
701 NS_LOG_FUNCTION(this << address);
702 if (address.IsGroup())
703 {
704 WifiMode mode = GetNonUnicastMode();
705 WifiTxVector v;
706 v.SetMode(mode);
708 GetPreambleForTransmission(mode.GetModulationClass(), GetShortPreambleEnabled()));
709 v.SetTxPowerLevel(m_defaultTxPowerLevel);
710 v.SetChannelWidth(GetChannelWidthForTransmission(mode, m_wifiPhy->GetChannelWidth()));
711 v.SetGuardInterval(ConvertGuardIntervalToNanoSeconds(mode, m_wifiPhy->GetDevice()));
712 v.SetNTx(GetNumberOfAntennas());
713 v.SetNss(1);
714 v.SetNess(0);
715 return v;
716 }
717 return DoGetRtsTxVector(Lookup(address));
718}
719
721WifiRemoteStationManager::GetCtsTxVector(Mac48Address to, WifiMode rtsTxMode) const
722{
723 NS_ASSERT(!to.IsGroup());
724 WifiMode ctsMode = GetControlAnswerMode(rtsTxMode);
725 WifiTxVector v;
726 v.SetMode(ctsMode);
728 GetPreambleForTransmission(ctsMode.GetModulationClass(), GetShortPreambleEnabled()));
729 v.SetTxPowerLevel(GetDefaultTxPowerLevel());
730 v.SetChannelWidth(GetChannelWidthForTransmission(ctsMode, m_wifiPhy->GetChannelWidth()));
731 uint16_t ctsTxGuardInterval =
732 ConvertGuardIntervalToNanoSeconds(ctsMode, m_wifiPhy->GetDevice());
733 v.SetGuardInterval(ctsTxGuardInterval);
734 v.SetNss(1);
735 return v;
736}
737
739WifiRemoteStationManager::GetAckTxVector(Mac48Address to, const WifiTxVector& dataTxVector) const
740{
741 NS_ASSERT(!to.IsGroup());
742 WifiMode ackMode = GetControlAnswerMode(dataTxVector.GetMode(GetStaId(to, dataTxVector)));
743 WifiTxVector v;
744 v.SetMode(ackMode);
746 GetPreambleForTransmission(ackMode.GetModulationClass(), GetShortPreambleEnabled()));
747 v.SetTxPowerLevel(GetDefaultTxPowerLevel());
748 v.SetChannelWidth(GetChannelWidthForTransmission(ackMode, m_wifiPhy->GetChannelWidth()));
749 uint16_t ackTxGuardInterval =
750 ConvertGuardIntervalToNanoSeconds(ackMode, m_wifiPhy->GetDevice());
751 v.SetGuardInterval(ackTxGuardInterval);
752 v.SetNss(1);
753 return v;
754}
755
757WifiRemoteStationManager::GetBlockAckTxVector(Mac48Address to,
758 const WifiTxVector& dataTxVector) const
759{
760 NS_ASSERT(!to.IsGroup());
761 WifiMode blockAckMode = GetControlAnswerMode(dataTxVector.GetMode(GetStaId(to, dataTxVector)));
762 WifiTxVector v;
763 v.SetMode(blockAckMode);
765 GetPreambleForTransmission(blockAckMode.GetModulationClass(), GetShortPreambleEnabled()));
766 v.SetTxPowerLevel(GetDefaultTxPowerLevel());
767 v.SetChannelWidth(GetChannelWidthForTransmission(blockAckMode, m_wifiPhy->GetChannelWidth()));
768 uint16_t blockAckTxGuardInterval =
769 ConvertGuardIntervalToNanoSeconds(blockAckMode, m_wifiPhy->GetDevice());
770 v.SetGuardInterval(blockAckTxGuardInterval);
771 v.SetNss(1);
772 return v;
773}
774
776WifiRemoteStationManager::GetControlAnswerMode(WifiMode reqMode) const
777{
792 NS_LOG_FUNCTION(this << reqMode);
793 WifiMode mode = GetDefaultMode();
794 bool found = false;
795 // First, search the BSS Basic Rate set
796 for (uint8_t i = 0; i < GetNBasicModes(); i++)
797 {
798 WifiMode testMode = GetBasicMode(i);
799 if ((!found || testMode.IsHigherDataRate(mode)) && (!testMode.IsHigherDataRate(reqMode)) &&
801 testMode.GetModulationClass())))
802 {
803 mode = testMode;
804 // We've found a potentially-suitable transmit rate, but we
805 // need to continue and consider all the basic rates before
806 // we can be sure we've got the right one.
807 found = true;
808 }
809 }
810 if (GetHtSupported())
811 {
812 if (!found)
813 {
814 mode = GetDefaultMcs();
815 for (uint8_t i = 0; i != GetNBasicMcs(); i++)
816 {
817 WifiMode testMode = GetBasicMcs(i);
818 if ((!found || testMode.IsHigherDataRate(mode)) &&
819 (!testMode.IsHigherDataRate(reqMode)) &&
820 (testMode.GetModulationClass() == reqMode.GetModulationClass()))
821 {
822 mode = testMode;
823 // We've found a potentially-suitable transmit rate, but we
824 // need to continue and consider all the basic rates before
825 // we can be sure we've got the right one.
826 found = true;
827 }
828 }
829 }
830 }
831 // If we found a suitable rate in the BSSBasicRateSet, then we are
832 // done and can return that mode.
833 if (found)
834 {
835 NS_LOG_DEBUG("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
836 return mode;
837 }
838
856 for (const auto& thismode : m_wifiPhy->GetModeList())
857 {
858 /* If the rate:
859 *
860 * - is a mandatory rate for the PHY, and
861 * - is equal to or faster than our current best choice, and
862 * - is less than or equal to the rate of the received frame, and
863 * - is of the same modulation class as the received frame
864 *
865 * ...then it's our best choice so far.
866 */
867 if (thismode.IsMandatory() && (!found || thismode.IsHigherDataRate(mode)) &&
868 (!thismode.IsHigherDataRate(reqMode)) &&
870 thismode.GetModulationClass())))
871 {
872 mode = thismode;
873 // As above; we've found a potentially-suitable transmit
874 // rate, but we need to continue and consider all the
875 // mandatory rates before we can be sure we've got the right one.
876 found = true;
877 }
878 }
879 if (GetHtSupported())
880 {
881 for (const auto& thismode : m_wifiPhy->GetMcsList())
882 {
883 if (thismode.IsMandatory() && (!found || thismode.IsHigherDataRate(mode)) &&
884 (!thismode.IsHigherCodeRate(reqMode)) &&
885 (thismode.GetModulationClass() == reqMode.GetModulationClass()))
886 {
887 mode = thismode;
888 // As above; we've found a potentially-suitable transmit
889 // rate, but we need to continue and consider all the
890 // mandatory rates before we can be sure we've got the right one.
891 found = true;
892 }
893 }
894 }
895
905 if (!found)
906 {
907 NS_FATAL_ERROR("Can't find response rate for " << reqMode);
908 }
909
910 NS_LOG_DEBUG("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
911 return mode;
912}
913
914void
915WifiRemoteStationManager::ReportRtsFailed(const WifiMacHeader& header)
916{
917 NS_LOG_FUNCTION(this << header);
918 NS_ASSERT(!header.GetAddr1().IsGroup());
919 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
920 m_ssrc[ac]++;
921 m_macTxRtsFailed(header.GetAddr1());
922 DoReportRtsFailed(Lookup(header.GetAddr1()));
923}
924
925void
926WifiRemoteStationManager::ReportDataFailed(Ptr<const WifiMpdu> mpdu)
927{
928 NS_LOG_FUNCTION(this << *mpdu);
929 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
930 AcIndex ac =
931 QosUtilsMapTidToAc((mpdu->GetHeader().IsQosData()) ? mpdu->GetHeader().GetQosTid() : 0);
932 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
933 if (longMpdu)
934 {
935 m_slrc[ac]++;
936 }
937 else
938 {
939 m_ssrc[ac]++;
940 }
941 m_macTxDataFailed(mpdu->GetHeader().GetAddr1());
942 DoReportDataFailed(Lookup(mpdu->GetHeader().GetAddr1()));
943}
944
945void
946WifiRemoteStationManager::ReportRtsOk(const WifiMacHeader& header,
947 double ctsSnr,
948 WifiMode ctsMode,
949 double rtsSnr)
950{
951 NS_LOG_FUNCTION(this << header << ctsSnr << ctsMode << rtsSnr);
952 NS_ASSERT(!header.GetAddr1().IsGroup());
953 WifiRemoteStation* station = Lookup(header.GetAddr1());
954 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
955 station->m_state->m_info.NotifyTxSuccess(m_ssrc[ac]);
956 m_ssrc[ac] = 0;
957 DoReportRtsOk(station, ctsSnr, ctsMode, rtsSnr);
958}
959
960void
961WifiRemoteStationManager::ReportDataOk(Ptr<const WifiMpdu> mpdu,
962 double ackSnr,
963 WifiMode ackMode,
964 double dataSnr,
965 WifiTxVector dataTxVector)
966{
967 NS_LOG_FUNCTION(this << *mpdu << ackSnr << ackMode << dataSnr << dataTxVector);
968 const WifiMacHeader& hdr = mpdu->GetHeader();
969 NS_ASSERT(!hdr.GetAddr1().IsGroup());
970 WifiRemoteStation* station = Lookup(hdr.GetAddr1());
971 AcIndex ac = QosUtilsMapTidToAc((hdr.IsQosData()) ? hdr.GetQosTid() : 0);
972 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
973 if (longMpdu)
974 {
975 station->m_state->m_info.NotifyTxSuccess(m_slrc[ac]);
976 m_slrc[ac] = 0;
977 }
978 else
979 {
980 station->m_state->m_info.NotifyTxSuccess(m_ssrc[ac]);
981 m_ssrc[ac] = 0;
982 }
983 DoReportDataOk(station,
984 ackSnr,
985 ackMode,
986 dataSnr,
987 dataTxVector.GetChannelWidth(),
988 dataTxVector.GetNss(GetStaId(hdr.GetAddr1(), dataTxVector)));
989}
990
991void
992WifiRemoteStationManager::ReportFinalRtsFailed(const WifiMacHeader& header)
993{
994 NS_LOG_FUNCTION(this << header);
995 NS_ASSERT(!header.GetAddr1().IsGroup());
996 WifiRemoteStation* station = Lookup(header.GetAddr1());
997 AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
998 station->m_state->m_info.NotifyTxFailed();
999 m_ssrc[ac] = 0;
1000 m_macTxFinalRtsFailed(header.GetAddr1());
1001 DoReportFinalRtsFailed(station);
1002}
1003
1004void
1005WifiRemoteStationManager::ReportFinalDataFailed(Ptr<const WifiMpdu> mpdu)
1006{
1007 NS_LOG_FUNCTION(this << *mpdu);
1008 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1009 WifiRemoteStation* station = Lookup(mpdu->GetHeader().GetAddr1());
1010 AcIndex ac =
1011 QosUtilsMapTidToAc((mpdu->GetHeader().IsQosData()) ? mpdu->GetHeader().GetQosTid() : 0);
1012 station->m_state->m_info.NotifyTxFailed();
1013 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
1014 if (longMpdu)
1015 {
1016 m_slrc[ac] = 0;
1017 }
1018 else
1019 {
1020 m_ssrc[ac] = 0;
1021 }
1022 m_macTxFinalDataFailed(mpdu->GetHeader().GetAddr1());
1023 DoReportFinalDataFailed(station);
1024}
1025
1026void
1027WifiRemoteStationManager::ReportRxOk(Mac48Address address,
1028 RxSignalInfo rxSignalInfo,
1029 WifiTxVector txVector)
1030{
1031 NS_LOG_FUNCTION(this << address << rxSignalInfo << txVector);
1032 if (address.IsGroup())
1033 {
1034 return;
1035 }
1036 WifiRemoteStation* station = Lookup(address);
1037 DoReportRxOk(station, rxSignalInfo.snr, txVector.GetMode(GetStaId(address, txVector)));
1038 station->m_rssiAndUpdateTimePair = std::make_pair(rxSignalInfo.rssi, Simulator::Now());
1039}
1040
1041void
1042WifiRemoteStationManager::ReportAmpduTxStatus(Mac48Address address,
1043 uint16_t nSuccessfulMpdus,
1044 uint16_t nFailedMpdus,
1045 double rxSnr,
1046 double dataSnr,
1047 WifiTxVector dataTxVector)
1048{
1049 NS_LOG_FUNCTION(this << address << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr
1050 << dataTxVector);
1051 NS_ASSERT(!address.IsGroup());
1052 for (uint16_t i = 0; i < nFailedMpdus; i++)
1053 {
1054 m_macTxDataFailed(address);
1055 }
1056 DoReportAmpduTxStatus(Lookup(address),
1057 nSuccessfulMpdus,
1058 nFailedMpdus,
1059 rxSnr,
1060 dataSnr,
1061 dataTxVector.GetChannelWidth(),
1062 dataTxVector.GetNss(GetStaId(address, dataTxVector)));
1063}
1064
1065bool
1066WifiRemoteStationManager::NeedRts(const WifiMacHeader& header, uint32_t size)
1067{
1068 NS_LOG_FUNCTION(this << header << size);
1069 Mac48Address address = header.GetAddr1();
1070 WifiTxVector txVector = GetDataTxVector(header, m_wifiPhy->GetChannelWidth());
1071 const auto modulationClass = txVector.GetModulationClass();
1072 if (address.IsGroup())
1073 {
1074 return false;
1075 }
1076 if (m_erpProtectionMode == RTS_CTS &&
1077 ((modulationClass == WIFI_MOD_CLASS_ERP_OFDM) || (modulationClass == WIFI_MOD_CLASS_HT) ||
1078 (modulationClass == WIFI_MOD_CLASS_VHT) || (modulationClass == WIFI_MOD_CLASS_HE) ||
1079 (modulationClass == WIFI_MOD_CLASS_EHT)) &&
1080 m_useNonErpProtection)
1081 {
1083 "WifiRemoteStationManager::NeedRTS returning true to protect non-ERP stations");
1084 return true;
1085 }
1086 else if (m_htProtectionMode == RTS_CTS &&
1087 ((modulationClass == WIFI_MOD_CLASS_HT) || (modulationClass == WIFI_MOD_CLASS_VHT)) &&
1088 m_useNonHtProtection && !(m_erpProtectionMode != RTS_CTS && m_useNonErpProtection))
1089 {
1090 NS_LOG_DEBUG("WifiRemoteStationManager::NeedRTS returning true to protect non-HT stations");
1091 return true;
1092 }
1093 bool normally = (size > m_rtsCtsThreshold);
1094 return DoNeedRts(Lookup(address), size, normally);
1095}
1096
1097bool
1098WifiRemoteStationManager::NeedCtsToSelf(WifiTxVector txVector)
1099{
1100 WifiMode mode = txVector.GetMode();
1101 NS_LOG_FUNCTION(this << mode);
1102 if (m_erpProtectionMode == CTS_TO_SELF &&
1108 m_useNonErpProtection)
1109 {
1111 "WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
1112 return true;
1113 }
1114 else if (m_htProtectionMode == CTS_TO_SELF &&
1117 m_useNonHtProtection && !(m_erpProtectionMode != CTS_TO_SELF && m_useNonErpProtection))
1118 {
1120 "WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-HT stations");
1121 return true;
1122 }
1123 else if (!m_useNonErpProtection)
1124 {
1125 // search for the BSS Basic Rate set, if the used mode is in the basic set then there is no
1126 // need for CTS To Self
1127 for (WifiModeListIterator i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++)
1128 {
1129 if (mode == *i)
1130 {
1131 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning false");
1132 return false;
1133 }
1134 }
1135 if (GetHtSupported())
1136 {
1137 // search for the BSS Basic MCS set, if the used mode is in the basic set then there is
1138 // no need for CTS To Self
1139 for (WifiModeListIterator i = m_bssBasicMcsSet.begin(); i != m_bssBasicMcsSet.end();
1140 i++)
1141 {
1142 if (mode == *i)
1143 {
1144 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning false");
1145 return false;
1146 }
1147 }
1148 }
1149 NS_LOG_DEBUG("WifiRemoteStationManager::NeedCtsToSelf returning true");
1150 return true;
1151 }
1152 return false;
1153}
1154
1155void
1156WifiRemoteStationManager::SetUseNonErpProtection(bool enable)
1157{
1158 NS_LOG_FUNCTION(this << enable);
1159 m_useNonErpProtection = enable;
1160}
1161
1162bool
1163WifiRemoteStationManager::GetUseNonErpProtection() const
1164{
1165 return m_useNonErpProtection;
1166}
1167
1168void
1169WifiRemoteStationManager::SetUseNonHtProtection(bool enable)
1170{
1171 NS_LOG_FUNCTION(this << enable);
1172 m_useNonHtProtection = enable;
1173}
1174
1175bool
1176WifiRemoteStationManager::GetUseNonHtProtection() const
1177{
1178 return m_useNonHtProtection;
1179}
1180
1181bool
1182WifiRemoteStationManager::NeedRetransmission(Ptr<const WifiMpdu> mpdu)
1183{
1184 NS_LOG_FUNCTION(this << *mpdu);
1185 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1186 AcIndex ac =
1187 QosUtilsMapTidToAc((mpdu->GetHeader().IsQosData()) ? mpdu->GetHeader().GetQosTid() : 0);
1188 bool longMpdu = (mpdu->GetSize() > m_rtsCtsThreshold);
1189 uint32_t retryCount;
1190 uint32_t maxRetryCount;
1191 if (longMpdu)
1192 {
1193 retryCount = m_slrc[ac];
1194 maxRetryCount = m_maxSlrc;
1195 }
1196 else
1197 {
1198 retryCount = m_ssrc[ac];
1199 maxRetryCount = m_maxSsrc;
1200 }
1201 bool normally = retryCount < maxRetryCount;
1202 NS_LOG_DEBUG("WifiRemoteStationManager::NeedRetransmission count: "
1203 << retryCount << " result: " << std::boolalpha << normally);
1204 return DoNeedRetransmission(Lookup(mpdu->GetHeader().GetAddr1()), mpdu->GetPacket(), normally);
1205}
1206
1207bool
1208WifiRemoteStationManager::NeedFragmentation(Ptr<const WifiMpdu> mpdu)
1209{
1210 NS_LOG_FUNCTION(this << *mpdu);
1211 if (mpdu->GetHeader().GetAddr1().IsGroup())
1212 {
1213 return false;
1214 }
1215 bool normally = mpdu->GetSize() > GetFragmentationThreshold();
1216 NS_LOG_DEBUG("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha
1217 << normally);
1218 return DoNeedFragmentation(Lookup(mpdu->GetHeader().GetAddr1()), mpdu->GetPacket(), normally);
1219}
1220
1221void
1222WifiRemoteStationManager::DoSetFragmentationThreshold(uint32_t threshold)
1223{
1224 NS_LOG_FUNCTION(this << threshold);
1225 if (threshold < 256)
1226 {
1227 /*
1228 * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
1229 */
1230 NS_LOG_WARN("Fragmentation threshold should be larger than 256. Setting to 256.");
1231 m_fragmentationThreshold = 256;
1232 }
1233 else
1234 {
1235 /*
1236 * The length of each fragment shall be an even number of octets, except for the last
1237 * fragment if an MSDU or MMPDU, which may be either an even or an odd number of octets.
1238 */
1239 if (threshold % 2 != 0)
1240 {
1241 NS_LOG_WARN("Fragmentation threshold should be an even number. Setting to "
1242 << threshold - 1);
1243 m_fragmentationThreshold = threshold - 1;
1244 }
1245 else
1246 {
1247 m_fragmentationThreshold = threshold;
1248 }
1249 }
1250}
1251
1253WifiRemoteStationManager::DoGetFragmentationThreshold() const
1254{
1255 return m_fragmentationThreshold;
1256}
1257
1259WifiRemoteStationManager::GetNFragments(Ptr<const WifiMpdu> mpdu)
1260{
1261 NS_LOG_FUNCTION(this << *mpdu);
1262 // The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1263 uint32_t nFragments =
1264 (mpdu->GetPacket()->GetSize() /
1265 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH));
1266
1267 // If the size of the last fragment is not 0.
1268 if ((mpdu->GetPacket()->GetSize() %
1269 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH)) > 0)
1270 {
1271 nFragments++;
1272 }
1273 NS_LOG_DEBUG("WifiRemoteStationManager::GetNFragments returning " << nFragments);
1274 return nFragments;
1275}
1276
1278WifiRemoteStationManager::GetFragmentSize(Ptr<const WifiMpdu> mpdu, uint32_t fragmentNumber)
1279{
1280 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1281 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1282 uint32_t nFragment = GetNFragments(mpdu);
1283 if (fragmentNumber >= nFragment)
1284 {
1285 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning 0");
1286 return 0;
1287 }
1288 // Last fragment
1289 if (fragmentNumber == nFragment - 1)
1290 {
1291 uint32_t lastFragmentSize =
1292 mpdu->GetPacket()->GetSize() -
1293 (fragmentNumber *
1294 (GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH));
1295 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
1296 return lastFragmentSize;
1297 }
1298 // All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1299 else
1300 {
1301 uint32_t fragmentSize =
1302 GetFragmentationThreshold() - mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH;
1303 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
1304 return fragmentSize;
1305 }
1306}
1307
1309WifiRemoteStationManager::GetFragmentOffset(Ptr<const WifiMpdu> mpdu, uint32_t fragmentNumber)
1310{
1311 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1312 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1313 NS_ASSERT(fragmentNumber < GetNFragments(mpdu));
1314 uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold() -
1315 mpdu->GetHeader().GetSize() - WIFI_MAC_FCS_LENGTH);
1316 NS_LOG_DEBUG("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
1317 return fragmentOffset;
1318}
1319
1320bool
1321WifiRemoteStationManager::IsLastFragment(Ptr<const WifiMpdu> mpdu, uint32_t fragmentNumber)
1322{
1323 NS_LOG_FUNCTION(this << *mpdu << fragmentNumber);
1324 NS_ASSERT(!mpdu->GetHeader().GetAddr1().IsGroup());
1325 bool isLast = fragmentNumber == (GetNFragments(mpdu) - 1);
1326 NS_LOG_DEBUG("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
1327 return isLast;
1328}
1329
1330uint8_t
1331WifiRemoteStationManager::GetDefaultTxPowerLevel() const
1332{
1333 return m_defaultTxPowerLevel;
1334}
1335
1337WifiRemoteStationManager::GetInfo(Mac48Address address)
1338{
1339 return LookupState(address)->m_info;
1340}
1341
1342double
1343WifiRemoteStationManager::GetMostRecentRssi(Mac48Address address) const
1344{
1345 auto stationIt = m_stations.find(address);
1346 NS_ASSERT_MSG(stationIt != m_stations.end(), "Address: " << address << " not found");
1347 auto station = stationIt->second;
1348 auto rssi = station->m_rssiAndUpdateTimePair.first;
1349 auto ts = station->m_rssiAndUpdateTimePair.second;
1350 NS_ASSERT_MSG(ts.IsStrictlyPositive(), "address: " << address << " ts:" << ts);
1351 return rssi;
1352}
1353
1354std::shared_ptr<WifiRemoteStationState>
1355WifiRemoteStationManager::LookupState(Mac48Address address) const
1356{
1357 NS_LOG_FUNCTION(this << address);
1358 auto stateIt = m_states.find(address);
1359
1360 if (stateIt != m_states.end())
1361 {
1362 NS_LOG_DEBUG("WifiRemoteStationManager::LookupState returning existing state");
1363 return stateIt->second;
1364 }
1365
1366 auto state = std::make_shared<WifiRemoteStationState>();
1367 state->m_state = WifiRemoteStationState::BRAND_NEW;
1368 state->m_address = address;
1369 state->m_aid = 0;
1370 state->m_operationalRateSet.push_back(GetDefaultMode());
1371 state->m_operationalMcsSet.push_back(GetDefaultMcs());
1372 state->m_dsssSupported = false;
1373 state->m_erpOfdmSupported = false;
1374 state->m_ofdmSupported = false;
1375 state->m_htCapabilities = nullptr;
1376 state->m_vhtCapabilities = nullptr;
1377 state->m_heCapabilities = nullptr;
1378 state->m_ehtCapabilities = nullptr;
1379 state->m_channelWidth = m_wifiPhy->GetChannelWidth();
1380 state->m_guardInterval = GetGuardInterval();
1381 state->m_ness = 0;
1382 state->m_aggregation = false;
1383 state->m_qosSupported = false;
1384 const_cast<WifiRemoteStationManager*>(this)->m_states.insert({address, state});
1385 NS_LOG_DEBUG("WifiRemoteStationManager::LookupState returning new state");
1386 return state;
1387}
1388
1389WifiRemoteStation*
1390WifiRemoteStationManager::Lookup(Mac48Address address) const
1391{
1392 NS_LOG_FUNCTION(this << address);
1393 auto stationIt = m_stations.find(address);
1394
1395 if (stationIt != m_stations.end())
1396 {
1397 return stationIt->second;
1398 }
1399
1400 WifiRemoteStation* station = DoCreateStation();
1401 station->m_state = LookupState(address).get();
1402 station->m_rssiAndUpdateTimePair = std::make_pair(0, Seconds(0));
1403 const_cast<WifiRemoteStationManager*>(this)->m_stations.insert({address, station});
1404 return station;
1405}
1406
1407void
1408WifiRemoteStationManager::SetAssociationId(Mac48Address remoteAddress, uint16_t aid)
1409{
1410 NS_LOG_FUNCTION(this << remoteAddress << aid);
1411 LookupState(remoteAddress)->m_aid = aid;
1412}
1413
1414void
1415WifiRemoteStationManager::SetQosSupport(Mac48Address from, bool qosSupported)
1416{
1417 NS_LOG_FUNCTION(this << from << qosSupported);
1418 LookupState(from)->m_qosSupported = qosSupported;
1419}
1420
1421void
1422WifiRemoteStationManager::AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
1423{
1424 // Used by all stations to record HT capabilities of remote stations
1425 NS_LOG_FUNCTION(this << from << htCapabilities);
1426 auto state = LookupState(from);
1427 if (htCapabilities.GetSupportedChannelWidth() == 1)
1428 {
1429 state->m_channelWidth = 40;
1430 }
1431 else
1432 {
1433 state->m_channelWidth = 20;
1434 }
1435 SetQosSupport(from, true);
1436 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_HT))
1437 {
1438 if (htCapabilities.IsSupportedMcs(mcs.GetMcsValue()))
1439 {
1440 AddSupportedMcs(from, mcs);
1441 }
1442 }
1443 state->m_htCapabilities = Create<const HtCapabilities>(htCapabilities);
1444}
1445
1446void
1447WifiRemoteStationManager::AddStationVhtCapabilities(Mac48Address from,
1448 VhtCapabilities vhtCapabilities)
1449{
1450 // Used by all stations to record VHT capabilities of remote stations
1451 NS_LOG_FUNCTION(this << from << vhtCapabilities);
1452 auto state = LookupState(from);
1453 if (vhtCapabilities.GetSupportedChannelWidthSet() == 1)
1454 {
1455 state->m_channelWidth = 160;
1456 }
1457 else
1458 {
1459 state->m_channelWidth = 80;
1460 }
1461 for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams(); i++)
1462 {
1463 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_VHT))
1464 {
1465 if (vhtCapabilities.IsSupportedMcs(mcs.GetMcsValue(), i))
1466 {
1467 AddSupportedMcs(from, mcs);
1468 }
1469 }
1470 }
1471 state->m_vhtCapabilities = Create<const VhtCapabilities>(vhtCapabilities);
1472}
1473
1474void
1475WifiRemoteStationManager::AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
1476{
1477 // Used by all stations to record HE capabilities of remote stations
1478 NS_LOG_FUNCTION(this << from << heCapabilities);
1479 auto state = LookupState(from);
1480 if ((m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_5GHZ) ||
1481 (m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_6GHZ))
1482 {
1483 if (heCapabilities.GetChannelWidthSet() & 0x04)
1484 {
1485 state->m_channelWidth = 160;
1486 }
1487 else if (heCapabilities.GetChannelWidthSet() & 0x02)
1488 {
1489 state->m_channelWidth = 80;
1490 }
1491 // For other cases at 5 GHz, the supported channel width is set by the VHT capabilities
1492 }
1493 else if (m_wifiPhy->GetPhyBand() == WIFI_PHY_BAND_2_4GHZ)
1494 {
1495 if (heCapabilities.GetChannelWidthSet() & 0x01)
1496 {
1497 state->m_channelWidth = 40;
1498 }
1499 else
1500 {
1501 state->m_channelWidth = 20;
1502 }
1503 }
1504 if (heCapabilities.GetHeSuPpdu1xHeLtf800nsGi() == 1)
1505 {
1506 state->m_guardInterval = 800;
1507 }
1508 else
1509 {
1510 // todo: Using 3200ns, default value for HeConfiguration::GuardInterval
1511 state->m_guardInterval = 3200;
1512 }
1513 for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams(); i++)
1514 {
1515 for (const auto& mcs : m_wifiPhy->GetMcsList(WIFI_MOD_CLASS_HE))
1516 {
1517 if (heCapabilities.GetHighestNssSupported() >= i &&
1518 heCapabilities.GetHighestMcsSupported() >= mcs.GetMcsValue())
1519 {
1520 AddSupportedMcs(from, mcs);
1521 }
1522 }
1523 }
1524 state->m_heCapabilities = Create<const HeCapabilities>(heCapabilities);
1525 SetQosSupport(from, true);
1526}
1527
1528void
1529WifiRemoteStationManager::AddStationEhtCapabilities(Mac48Address from,
1530 EhtCapabilities ehtCapabilities)
1531{
1532 // Used by all stations to record EHT capabilities of remote stations
1533 NS_LOG_FUNCTION(this << from << ehtCapabilities);
1534 auto state = LookupState(from);
1535 // TODO: to be completed
1536 state->m_ehtCapabilities = Create<const EhtCapabilities>(ehtCapabilities);
1537 SetQosSupport(from, true);
1538}
1539
1541WifiRemoteStationManager::GetStationHtCapabilities(Mac48Address from)
1542{
1543 return LookupState(from)->m_htCapabilities;
1544}
1545
1547WifiRemoteStationManager::GetStationVhtCapabilities(Mac48Address from)
1548{
1549 return LookupState(from)->m_vhtCapabilities;
1550}
1551
1553WifiRemoteStationManager::GetStationHeCapabilities(Mac48Address from)
1554{
1555 return LookupState(from)->m_heCapabilities;
1556}
1557
1559WifiRemoteStationManager::GetStationEhtCapabilities(Mac48Address from)
1560{
1561 return LookupState(from)->m_ehtCapabilities;
1562}
1563
1564bool
1565WifiRemoteStationManager::GetLdpcSupported(Mac48Address address) const
1566{
1567 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
1568 Ptr<const VhtCapabilities> vhtCapabilities = LookupState(address)->m_vhtCapabilities;
1569 Ptr<const HeCapabilities> heCapabilities = LookupState(address)->m_heCapabilities;
1570 bool supported = false;
1571 if (htCapabilities)
1572 {
1573 supported |= htCapabilities->GetLdpc();
1574 }
1575 if (vhtCapabilities)
1576 {
1577 supported |= vhtCapabilities->GetRxLdpc();
1578 }
1579 if (heCapabilities)
1580 {
1581 supported |= heCapabilities->GetLdpcCodingInPayload();
1582 }
1583 return supported;
1584}
1585
1587WifiRemoteStationManager::GetDefaultMode() const
1588{
1589 return m_defaultTxMode;
1590}
1591
1593WifiRemoteStationManager::GetDefaultMcs() const
1594{
1595 return m_defaultTxMcs;
1596}
1597
1599WifiRemoteStationManager::GetDefaultModeForSta(const WifiRemoteStation* st) const
1600{
1601 NS_LOG_FUNCTION(this << st);
1602
1603 if (!GetHtSupported() || !GetHtSupported(st))
1604 {
1605 return GetDefaultMode();
1606 }
1607
1608 // find the highest modulation class supported by both stations
1610 if (GetHeSupported() && GetHeSupported(st))
1611 {
1612 modClass = WIFI_MOD_CLASS_HE;
1613 }
1614 else if (GetVhtSupported() && GetVhtSupported(st))
1615 {
1616 modClass = WIFI_MOD_CLASS_VHT;
1617 }
1618
1619 // return the MCS with lowest index
1620 return *m_wifiPhy->GetPhyEntity(modClass)->begin();
1621}
1622
1623void
1625{
1626 NS_LOG_FUNCTION(this);
1627 m_states.clear();
1628 for (auto& state : m_stations)
1629 {
1630 delete (state.second);
1631 }
1632 m_stations.clear();
1633 m_bssBasicRateSet.clear();
1634 m_bssBasicMcsSet.clear();
1635 m_ssrc.fill(0);
1636 m_slrc.fill(0);
1637}
1638
1639void
1640WifiRemoteStationManager::AddBasicMode(WifiMode mode)
1641{
1642 NS_LOG_FUNCTION(this << mode);
1644 {
1645 NS_FATAL_ERROR("It is not allowed to add a HT rate in the BSSBasicRateSet!");
1646 }
1647 for (uint8_t i = 0; i < GetNBasicModes(); i++)
1648 {
1649 if (GetBasicMode(i) == mode)
1650 {
1651 return;
1652 }
1653 }
1654 m_bssBasicRateSet.push_back(mode);
1655}
1656
1657uint8_t
1658WifiRemoteStationManager::GetNBasicModes() const
1659{
1660 return static_cast<uint8_t>(m_bssBasicRateSet.size());
1661}
1662
1664WifiRemoteStationManager::GetBasicMode(uint8_t i) const
1665{
1666 NS_ASSERT(i < GetNBasicModes());
1667 return m_bssBasicRateSet[i];
1668}
1669
1671WifiRemoteStationManager::GetNNonErpBasicModes() const
1672{
1673 uint32_t size = 0;
1674 for (WifiModeListIterator i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++)
1675 {
1676 if (i->GetModulationClass() == WIFI_MOD_CLASS_ERP_OFDM)
1677 {
1678 continue;
1679 }
1680 size++;
1681 }
1682 return size;
1683}
1684
1686WifiRemoteStationManager::GetNonErpBasicMode(uint8_t i) const
1687{
1688 NS_ASSERT(i < GetNNonErpBasicModes());
1689 uint32_t index = 0;
1690 bool found = false;
1691 for (WifiModeListIterator j = m_bssBasicRateSet.begin(); j != m_bssBasicRateSet.end();)
1692 {
1693 if (i == index)
1694 {
1695 found = true;
1696 }
1697 if (j->GetModulationClass() != WIFI_MOD_CLASS_ERP_OFDM)
1698 {
1699 if (found)
1700 {
1701 break;
1702 }
1703 }
1704 index++;
1705 j++;
1706 }
1707 return m_bssBasicRateSet[index];
1708}
1709
1710void
1711WifiRemoteStationManager::AddBasicMcs(WifiMode mcs)
1712{
1713 NS_LOG_FUNCTION(this << +mcs.GetMcsValue());
1714 for (uint8_t i = 0; i < GetNBasicMcs(); i++)
1715 {
1716 if (GetBasicMcs(i) == mcs)
1717 {
1718 return;
1719 }
1720 }
1721 m_bssBasicMcsSet.push_back(mcs);
1722}
1723
1724uint8_t
1725WifiRemoteStationManager::GetNBasicMcs() const
1726{
1727 return static_cast<uint8_t>(m_bssBasicMcsSet.size());
1728}
1729
1731WifiRemoteStationManager::GetBasicMcs(uint8_t i) const
1732{
1733 NS_ASSERT(i < GetNBasicMcs());
1734 return m_bssBasicMcsSet[i];
1735}
1736
1738WifiRemoteStationManager::GetNonUnicastMode() const
1739{
1740 if (m_nonUnicastMode == WifiMode())
1741 {
1742 if (GetNBasicModes() > 0)
1743 {
1744 return GetBasicMode(0);
1745 }
1746 else
1747 {
1748 return GetDefaultMode();
1749 }
1750 }
1751 else
1752 {
1753 return m_nonUnicastMode;
1754 }
1755}
1756
1757bool
1758WifiRemoteStationManager::DoNeedRts(WifiRemoteStation* station, uint32_t size, bool normally)
1759{
1760 return normally;
1761}
1762
1763bool
1764WifiRemoteStationManager::DoNeedRetransmission(WifiRemoteStation* station,
1765 Ptr<const Packet> packet,
1766 bool normally)
1767{
1768 return normally;
1769}
1770
1771bool
1772WifiRemoteStationManager::DoNeedFragmentation(WifiRemoteStation* station,
1773 Ptr<const Packet> packet,
1774 bool normally)
1775{
1776 return normally;
1777}
1778
1779void
1780WifiRemoteStationManager::DoReportAmpduTxStatus(WifiRemoteStation* station,
1781 uint16_t nSuccessfulMpdus,
1782 uint16_t nFailedMpdus,
1783 double rxSnr,
1784 double dataSnr,
1785 uint16_t dataChannelWidth,
1786 uint8_t dataNss)
1787{
1788 NS_LOG_DEBUG("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
1789}
1790
1792WifiRemoteStationManager::GetSupported(const WifiRemoteStation* station, uint8_t i) const
1793{
1794 NS_ASSERT(i < GetNSupported(station));
1795 return station->m_state->m_operationalRateSet[i];
1796}
1797
1799WifiRemoteStationManager::GetMcsSupported(const WifiRemoteStation* station, uint8_t i) const
1800{
1801 NS_ASSERT(i < GetNMcsSupported(station));
1802 return station->m_state->m_operationalMcsSet[i];
1803}
1804
1806WifiRemoteStationManager::GetNonErpSupported(const WifiRemoteStation* station, uint8_t i) const
1807{
1808 NS_ASSERT(i < GetNNonErpSupported(station));
1809 // IEEE 802.11g standard defines that if the protection mechanism is enabled, RTS, CTS and
1810 // CTS-To-Self frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b
1811 // basic rate. This is a implemented here to avoid changes in every RAA, but should maybe be
1812 // moved in case it breaks standard rules.
1813 uint32_t index = 0;
1814 bool found = false;
1815 for (WifiModeListIterator j = station->m_state->m_operationalRateSet.begin();
1816 j != station->m_state->m_operationalRateSet.end();)
1817 {
1818 if (i == index)
1819 {
1820 found = true;
1821 }
1822 if (j->GetModulationClass() != WIFI_MOD_CLASS_ERP_OFDM)
1823 {
1824 if (found)
1825 {
1826 break;
1827 }
1828 }
1829 index++;
1830 j++;
1831 }
1832 return station->m_state->m_operationalRateSet[index];
1833}
1834
1836WifiRemoteStationManager::GetAddress(const WifiRemoteStation* station) const
1837{
1838 return station->m_state->m_address;
1839}
1840
1841uint16_t
1842WifiRemoteStationManager::GetChannelWidth(const WifiRemoteStation* station) const
1843{
1844 return station->m_state->m_channelWidth;
1845}
1846
1847bool
1848WifiRemoteStationManager::GetShortGuardIntervalSupported(const WifiRemoteStation* station) const
1849{
1850 Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1851
1852 if (!htCapabilities)
1853 {
1854 return false;
1855 }
1856 return htCapabilities->GetShortGuardInterval20();
1857}
1858
1859uint16_t
1860WifiRemoteStationManager::GetGuardInterval(const WifiRemoteStation* station) const
1861{
1862 return station->m_state->m_guardInterval;
1863}
1864
1865bool
1866WifiRemoteStationManager::GetAggregation(const WifiRemoteStation* station) const
1867{
1868 return station->m_state->m_aggregation;
1869}
1870
1871uint8_t
1872WifiRemoteStationManager::GetNumberOfSupportedStreams(const WifiRemoteStation* station) const
1873{
1874 Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1875
1876 if (!htCapabilities)
1877 {
1878 return 1;
1879 }
1880 return htCapabilities->GetRxHighestSupportedAntennas();
1881}
1882
1883uint8_t
1884WifiRemoteStationManager::GetNess(const WifiRemoteStation* station) const
1885{
1886 return station->m_state->m_ness;
1887}
1888
1890WifiRemoteStationManager::GetPhy() const
1891{
1892 return m_wifiPhy;
1893}
1894
1896WifiRemoteStationManager::GetMac() const
1897{
1898 return m_wifiMac;
1899}
1900
1901uint8_t
1902WifiRemoteStationManager::GetNSupported(const WifiRemoteStation* station) const
1903{
1904 return static_cast<uint8_t>(station->m_state->m_operationalRateSet.size());
1905}
1906
1907bool
1908WifiRemoteStationManager::GetQosSupported(const WifiRemoteStation* station) const
1909{
1910 return station->m_state->m_qosSupported;
1911}
1912
1913bool
1914WifiRemoteStationManager::GetHtSupported(const WifiRemoteStation* station) const
1915{
1916 return bool(station->m_state->m_htCapabilities);
1917}
1918
1919bool
1920WifiRemoteStationManager::GetVhtSupported(const WifiRemoteStation* station) const
1921{
1922 return bool(station->m_state->m_vhtCapabilities);
1923}
1924
1925bool
1926WifiRemoteStationManager::GetHeSupported(const WifiRemoteStation* station) const
1927{
1928 return bool(station->m_state->m_heCapabilities);
1929}
1930
1931bool
1932WifiRemoteStationManager::GetEhtSupported(const WifiRemoteStation* station) const
1933{
1934 return (bool)(station->m_state->m_ehtCapabilities);
1935}
1936
1937uint8_t
1938WifiRemoteStationManager::GetNMcsSupported(const WifiRemoteStation* station) const
1939{
1940 return static_cast<uint8_t>(station->m_state->m_operationalMcsSet.size());
1941}
1942
1944WifiRemoteStationManager::GetNNonErpSupported(const WifiRemoteStation* station) const
1945{
1946 uint32_t size = 0;
1947 for (WifiModeListIterator i = station->m_state->m_operationalRateSet.begin();
1948 i != station->m_state->m_operationalRateSet.end();
1949 i++)
1950 {
1951 if (i->GetModulationClass() == WIFI_MOD_CLASS_ERP_OFDM)
1952 {
1953 continue;
1954 }
1955 size++;
1956 }
1957 return size;
1958}
1959
1960uint16_t
1961WifiRemoteStationManager::GetChannelWidthSupported(Mac48Address address) const
1962{
1963 return LookupState(address)->m_channelWidth;
1964}
1965
1966bool
1967WifiRemoteStationManager::GetShortGuardIntervalSupported(Mac48Address address) const
1968{
1969 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
1970
1971 if (!htCapabilities)
1972 {
1973 return false;
1974 }
1975 return htCapabilities->GetShortGuardInterval20();
1976}
1977
1978uint8_t
1979WifiRemoteStationManager::GetNumberOfSupportedStreams(Mac48Address address) const
1980{
1981 Ptr<const HtCapabilities> htCapabilities = LookupState(address)->m_htCapabilities;
1982
1983 if (!htCapabilities)
1984 {
1985 return 1;
1986 }
1987 return htCapabilities->GetRxHighestSupportedAntennas();
1988}
1989
1990uint8_t
1991WifiRemoteStationManager::GetNMcsSupported(Mac48Address address) const
1992{
1993 return static_cast<uint8_t>(LookupState(address)->m_operationalMcsSet.size());
1994}
1995
1996bool
1997WifiRemoteStationManager::GetDsssSupported(const Mac48Address& address) const
1998{
1999 return (LookupState(address)->m_dsssSupported);
2000}
2001
2002bool
2003WifiRemoteStationManager::GetErpOfdmSupported(const Mac48Address& address) const
2004{
2005 return (LookupState(address)->m_erpOfdmSupported);
2006}
2007
2008bool
2009WifiRemoteStationManager::GetOfdmSupported(const Mac48Address& address) const
2010{
2011 return (LookupState(address)->m_ofdmSupported);
2012}
2013
2014bool
2015WifiRemoteStationManager::GetHtSupported(Mac48Address address) const
2016{
2017 return bool(LookupState(address)->m_htCapabilities);
2018}
2019
2020bool
2021WifiRemoteStationManager::GetVhtSupported(Mac48Address address) const
2022{
2023 return bool(LookupState(address)->m_vhtCapabilities);
2024}
2025
2026bool
2027WifiRemoteStationManager::GetHeSupported(Mac48Address address) const
2028{
2029 return bool(LookupState(address)->m_heCapabilities);
2030}
2031
2032bool
2033WifiRemoteStationManager::GetEhtSupported(Mac48Address address) const
2034{
2035 return (bool)(LookupState(address)->m_ehtCapabilities);
2036}
2037
2038void
2039WifiRemoteStationManager::SetDefaultTxPowerLevel(uint8_t txPower)
2040{
2041 m_defaultTxPowerLevel = txPower;
2042}
2043
2044uint8_t
2045WifiRemoteStationManager::GetNumberOfAntennas() const
2046{
2047 return m_wifiPhy->GetNumberOfAntennas();
2048}
2049
2050uint8_t
2051WifiRemoteStationManager::GetMaxNumberOfTransmitStreams() const
2052{
2053 return m_wifiPhy->GetMaxSupportedTxSpatialStreams();
2054}
2055
2056bool
2057WifiRemoteStationManager::UseLdpcForDestination(Mac48Address dest) const
2058{
2059 return (GetLdpcSupported() && GetLdpcSupported(dest));
2060}
2061
2062} // namespace ns3
The IEEE 802.11be EHT Capabilities.
Hold variables of type enum.
Definition: enum.h:56
The IEEE 802.11ax HE Capabilities.
uint8_t GetHighestMcsSupported() const
Get highest MCS supported.
uint8_t GetHighestNssSupported() const
Get highest NSS 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:491
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
uint16_t GetAssociationId() const
Return the association ID.
bool IsAssociated() const
Return whether we are associated with an AP.
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
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.
represent a single transmission mode
Definition: wifi-mode.h:50
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
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
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:950
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
Definition: wifi-phy.cc:581
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:1896
std::list< WifiMode > GetModeList() const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition: wifi-phy.cc:1847
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.
bool GetQosSupported(Mac48Address address) const
Return whether the given station is QoS capable.
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
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.
uint32_t GetFragmentationThreshold() const
Return the fragmentation threshold.
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.
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.
bool GetShortSlotTimeEnabled() const
Return whether the device uses short slot time.
void DoDispose() override
Destructor implementation.
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...
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
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.
TracedCallback< Mac48Address > m_macTxFinalRtsFailed
The trace source fired when the transmission of a RTS has exceeded the maximum number of attempts.
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.
Ptr< WifiPhy > m_wifiPhy
This is a pointer to the WifiPhy associated with this WifiRemoteStationManager that is set on call to...
uint8_t m_defaultTxPowerLevel
Default transmission power level.
static TypeId GetTypeId()
Get the type ID.
WifiMode m_nonUnicastMode
Transmission mode for non-unicast Data frames.
uint16_t GetGuardInterval() const
Return the supported HE guard interval duration (in nanoseconds).
bool IsAssociated(Mac48Address address) const
Return whether the station associated.
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 SetMldAddress(const Mac48Address &address, const Mac48Address &mldAddress)
Set the address of the MLD the given station is affiliated with.
void RecordGotAssocTxOk(Mac48Address address)
Records that we got an ACK for the association response we sent.
bool GetLdpcSupported() const
Return whether the device has LDPC support enabled.
bool GetEhtSupported() const
Return whether the device has EHT capability support enabled.
void AddSupportedMode(Mac48Address address, WifiMode mode)
Invoked in a STA or AP to store the set of modes supported by a destination which is also supported l...
std::shared_ptr< WifiRemoteStationState > LookupState(Mac48Address address) const
Return the state of the station associated with the given address.
void RecordAssocRefused(Mac48Address address)
Records that association request was refused.
StationStates m_states
States of known stations.
void SetMaxSsrc(uint32_t maxSsrc)
Sets the maximum STA short retry count (SSRC).
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...
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...
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
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 IsAssocRefused(Mac48Address address) const
Return whether we refused an association request from the given station.
bool GetVhtSupported() const
Return whether the device has VHT capability support enabled.
ProtectionMode m_erpProtectionMode
Protection mode for ERP stations when non-ERP stations are detected.
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.
void RecordGotAssocTxFailed(Mac48Address address)
Records that we missed an ACK for the association response we sent.
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...
uint32_t m_rtsCtsThreshold
Threshold for RTS/CTS.
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...
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.
bool IsMu() const
Return true if this TX vector is used for a multi-user transmission.
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
void Reset()
Reset the initial value of every attribute as well as the value of every global to what they were bef...
Definition: config.cc:856
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:160
#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:45
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:296
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
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:132
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:74
@ 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)
address
Definition: first.py:40
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ STA
Definition: wifi-mac.h:60
@ AP
Definition: wifi-mac.h:61
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects 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.
WifiModeList::const_iterator WifiModeListIterator
An iterator for WifiModeList vector.
Definition: wifi-mode.h:265
uint16_t GetChannelWidthForTransmission(WifiMode mode, uint16_t maxAllowedChannelWidth)
Return the channel width that is allowed based on the selected mode and the given maximum channel wid...
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.
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
mac
Definition: third.py:85
phy
Definition: third.py:82
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:70
double rssi
RSSI in dBm.
Definition: phy-entity.h:72
double snr
SNR in linear scale.
Definition: phy-entity.h:71
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.
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
Ptr< const HtCapabilities > m_htCapabilities
remote station HT capabilities
Ptr< const HeCapabilities > m_heCapabilities
remote station HE capabilities
#define SU_STA_ID
Definition: wifi-mode.h:34