A Discrete-Event Network Simulator
API
wifi-remote-station-manager.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2005,2006,2007 INRIA
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 */
20
21#include "ns3/log.h"
22#include "ns3/boolean.h"
23#include "ns3/uinteger.h"
24#include "ns3/enum.h"
25#include "ns3/simulator.h"
27#include "wifi-phy.h"
28#include "ap-wifi-mac.h"
29#include "sta-wifi-mac.h"
30#include "wifi-mac-header.h"
31#include "wifi-mpdu.h"
32#include "wifi-mac-trailer.h"
33#include "ns3/ht-configuration.h"
34#include "ns3/ht-phy.h"
35#include "ns3/vht-configuration.h"
36#include "ns3/he-configuration.h"
37#include "ns3/eht-configuration.h"
38#include "wifi-net-device.h"
39
40namespace ns3 {
41
42NS_LOG_COMPONENT_DEFINE ("WifiRemoteStationManager");
43
44NS_OBJECT_ENSURE_REGISTERED (WifiRemoteStationManager);
45
46TypeId
48{
49 static TypeId tid = TypeId ("ns3::WifiRemoteStationManager")
50 .SetParent<Object> ()
51 .SetGroupName ("Wifi")
52 .AddAttribute ("MaxSsrc",
53 "The maximum number of retransmission attempts for any packet with size <= RtsCtsThreshold. "
54 "This value will not have any effect on some rate control algorithms.",
55 UintegerValue (7),
57 MakeUintegerChecker<uint32_t> ())
58 .AddAttribute ("MaxSlrc",
59 "The maximum number of retransmission attempts for any packet with size > RtsCtsThreshold. "
60 "This value will not have any effect on some rate control algorithms.",
61 UintegerValue (4),
63 MakeUintegerChecker<uint32_t> ())
64 .AddAttribute ("RtsCtsThreshold",
65 "If the size of the PSDU is bigger than this value, we use an RTS/CTS handshake before sending the data frame."
66 "This value will not have any effect on some rate control algorithms.",
67 UintegerValue (65535),
69 MakeUintegerChecker<uint32_t> ())
70 .AddAttribute ("FragmentationThreshold",
71 "If the size of the PSDU is bigger than this value, we fragment it such that the size of the fragments are equal or smaller. "
72 "This value does not apply when it is carried in an A-MPDU. "
73 "This value will not have any effect on some rate control algorithms.",
74 UintegerValue (65535),
77 MakeUintegerChecker<uint32_t> ())
78 .AddAttribute ("NonUnicastMode",
79 "Wifi mode used for non-unicast transmissions.",
81 MakeWifiModeAccessor (&WifiRemoteStationManager::m_nonUnicastMode),
82 MakeWifiModeChecker ())
83 .AddAttribute ("DefaultTxPowerLevel",
84 "Default power level to be used for transmissions. "
85 "This is the power level that is used by all those WifiManagers that do not implement TX power control.",
86 UintegerValue (0),
88 MakeUintegerChecker<uint8_t> ())
89 .AddAttribute ("ErpProtectionMode",
90 "Protection mode used when non-ERP STAs are connected to an ERP AP: Rts-Cts or Cts-To-Self",
95 .AddAttribute ("HtProtectionMode",
96 "Protection mode used when non-HT STAs are connected to a HT AP: Rts-Cts or Cts-To-Self",
101 .AddTraceSource ("MacTxRtsFailed",
102 "The transmission of a RTS by the MAC layer has failed",
104 "ns3::Mac48Address::TracedCallback")
105 .AddTraceSource ("MacTxDataFailed",
106 "The transmission of a data packet by the MAC layer has failed",
108 "ns3::Mac48Address::TracedCallback")
109 .AddTraceSource ("MacTxFinalRtsFailed",
110 "The transmission of a RTS has exceeded the maximum number of attempts",
112 "ns3::Mac48Address::TracedCallback")
113 .AddTraceSource ("MacTxFinalDataFailed",
114 "The transmission of a data packet has exceeded the maximum number of attempts",
116 "ns3::Mac48Address::TracedCallback")
117 ;
118 return tid;
119}
120
122 : m_useNonErpProtection (false),
123 m_useNonHtProtection (false),
124 m_shortPreambleEnabled (false),
125 m_shortSlotTimeEnabled (false)
126{
127 NS_LOG_FUNCTION (this);
128}
129
131{
132 NS_LOG_FUNCTION (this);
133}
134
135void
137{
138 NS_LOG_FUNCTION (this);
139 Reset ();
140}
141
142void
144{
145 NS_LOG_FUNCTION (this << phy);
146 //We need to track our PHY because it is the object that knows the
147 //full set of transmit rates that are supported. We need to know
148 //this in order to find the relevant mandatory rates when choosing a
149 //transmit rate for automatic control responses like
150 //acknowledgments.
151 m_wifiPhy = phy;
152 m_defaultTxMode = phy->GetDefaultMode ();
154 if (GetHtSupported ())
155 {
157 }
158 Reset ();
159}
160
161void
163{
164 NS_LOG_FUNCTION (this << mac);
165 //We need to track our MAC because it is the object that knows the
166 //full set of interframe spaces.
167 m_wifiMac = mac;
168 Reset ();
169}
170
171int64_t
173{
174 NS_LOG_FUNCTION (this << stream);
175 return 0;
176}
177
178void
180{
181 NS_LOG_FUNCTION (this << maxSsrc);
182 m_maxSsrc = maxSsrc;
183}
184
185void
187{
188 NS_LOG_FUNCTION (this << maxSlrc);
189 m_maxSlrc = maxSlrc;
190}
191
192void
194{
195 NS_LOG_FUNCTION (this << threshold);
196 m_rtsCtsThreshold = threshold;
197}
198
199void
201{
202 NS_LOG_FUNCTION (this << threshold);
203 DoSetFragmentationThreshold (threshold);
204}
205
206void
208{
209 NS_LOG_FUNCTION (this << enable);
210 m_shortPreambleEnabled = enable;
211}
212
213void
215{
216 NS_LOG_FUNCTION (this << enable);
217 m_shortSlotTimeEnabled = enable;
218}
219
220bool
222{
224}
225
226bool
228{
230}
231
232bool
234{
235 return bool (m_wifiPhy->GetDevice ()->GetHtConfiguration ());
236}
237
238bool
240{
243}
244
245bool
247{
248 return bool (m_wifiPhy->GetDevice ()->GetHeConfiguration ());
249}
250
251bool
253{
254 return bool (m_wifiPhy->GetDevice ()->GetEhtConfiguration ());
255}
256
257bool
259{
260 if (GetHtSupported ())
261 {
263 NS_ASSERT (htConfiguration); //If HT is supported, we should have a HT configuration attached
264 return htConfiguration->GetLdpcSupported ();
265 }
266 return false;
267}
268
269bool
271{
272 if (GetHtSupported ())
273 {
275 NS_ASSERT (htConfiguration); //If HT is supported, we should have a HT configuration attached
276 if (htConfiguration->GetShortGuardIntervalSupported ())
277 {
278 return true;
279 }
280 }
281 return false;
282}
283
284uint16_t
286{
287 uint16_t gi = 0;
288 if (GetHeSupported ())
289 {
291 NS_ASSERT (heConfiguration); //If HE is supported, we should have a HE configuration attached
292 gi = static_cast<uint16_t>(heConfiguration->GetGuardInterval ().GetNanoSeconds ());
293 }
294 return gi;
295}
296
299{
301}
302
303void
305{
306 NS_LOG_FUNCTION (this << address << isShortPreambleSupported);
307 NS_ASSERT (!address.IsGroup ());
308 LookupState (address)->m_shortPreamble = isShortPreambleSupported;
309}
310
311void
313{
314 NS_LOG_FUNCTION (this << address << isShortSlotTimeSupported);
315 NS_ASSERT (!address.IsGroup ());
316 LookupState (address)->m_shortSlotTime = isShortSlotTimeSupported;
317}
318
319void
321{
322 NS_LOG_FUNCTION (this << address << mode);
323 NS_ASSERT (!address.IsGroup ());
324 auto state = LookupState (address);
325 for (const auto& i : state->m_operationalRateSet)
326 {
327 if (i == mode) return; // already in
328 }
330 {
331 state->m_dsssSupported = true;
332 }
334 {
335 state->m_erpOfdmSupported = true;
336 }
337 else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
338 {
339 state->m_ofdmSupported = true;
340 }
341 state->m_operationalRateSet.push_back (mode);
342}
343
344void
346{
347 NS_LOG_FUNCTION (this << address);
348 NS_ASSERT (!address.IsGroup ());
349 auto state = LookupState (address);
350 state->m_operationalRateSet.clear ();
351 for (const auto & mode : m_wifiPhy->GetModeList ())
352 {
353 state->m_operationalRateSet.push_back (mode);
354 if (mode.IsMandatory ())
355 {
356 AddBasicMode (mode);
357 }
358 }
359}
360
361void
363{
364 NS_LOG_FUNCTION (this << address);
365 NS_ASSERT (!address.IsGroup ());
366 auto state = LookupState (address);
367 state->m_operationalMcsSet.clear ();
368 for (const auto & mcs : m_wifiPhy->GetMcsList ())
369 {
370 state->m_operationalMcsSet.push_back (mcs);
371 }
372}
373
374void
376{
377 NS_LOG_FUNCTION (this << address);
378 NS_ASSERT (!address.IsGroup ());
379 LookupState (address)->m_operationalMcsSet.clear ();
380}
381
382void
384{
385 NS_LOG_FUNCTION (this << address << mcs);
386 NS_ASSERT (!address.IsGroup ());
387 auto state = LookupState (address);
388 for (const auto& i : state->m_operationalMcsSet)
389 {
390 if (i == mcs) return; //already in
391 }
392 state->m_operationalMcsSet.push_back (mcs);
393}
394
395bool
397{
398 return LookupState (address)->m_shortPreamble;
399}
400
401bool
403{
404 return LookupState (address)->m_shortSlotTime;
405}
406
407bool
409{
410 return LookupState (address)->m_qosSupported;
411}
412
413bool
415{
416 if (address.IsGroup ())
417 {
418 return false;
419 }
421}
422
423bool
425{
426 if (address.IsGroup ())
427 {
428 return true;
429 }
431}
432
433bool
435{
436 if (address.IsGroup ())
437 {
438 return false;
439 }
441}
442
443void
445{
446 NS_ASSERT (!address.IsGroup ());
448}
449
450void
452{
453 NS_ASSERT (!address.IsGroup ());
455}
456
457void
459{
460 NS_ASSERT (!address.IsGroup ());
462}
463
464void
466{
467 NS_ASSERT (!address.IsGroup ());
469}
470
471bool
473{
474 if (address.IsGroup ())
475 {
476 return false;
477 }
479}
480
481void
483{
484 NS_ASSERT (!address.IsGroup ());
486}
487
488uint16_t
490{
491 std::shared_ptr<WifiRemoteStationState> state;
492 if (!remoteAddress.IsGroup ()
493 && (state = LookupState (remoteAddress))->m_state == WifiRemoteStationState::GOT_ASSOC_TX_OK)
494 {
495 return state->m_aid;
496 }
497 return SU_STA_ID;
498}
499
500uint16_t
502{
503 NS_LOG_FUNCTION (this << address << txVector);
504
505 uint16_t staId = SU_STA_ID;
506
507 if (txVector.IsMu ())
508 {
509 if (m_wifiMac->GetTypeOfStation () == AP)
510 {
511 staId = GetAssociationId (address);
512 }
513 else if (m_wifiMac->GetTypeOfStation () == STA)
514 {
515 Ptr<StaWifiMac> staMac = StaticCast<StaWifiMac> (m_wifiMac);
516 if (staMac->IsAssociated ())
517 {
518 staId = staMac->GetAssociationId ();
519 }
520 }
521 }
522
523 NS_LOG_DEBUG ("Returning STAID = " << staId);
524 return staId;
525}
526
527void
529{
530 NS_LOG_FUNCTION (this << address << mldAddress);
531
532 auto state = LookupState (address);
533 state->m_mldAddress = mldAddress;
534 // insert another entry in m_states indexed by the MLD address and pointing to the same state
535 const_cast<WifiRemoteStationManager *> (this)->m_states.insert ({mldAddress, state});
536}
537
538std::optional<Mac48Address>
539WifiRemoteStationManager::GetMldAddress (const Mac48Address& address) const
540{
541 return LookupState (address)->m_mldAddress;
542}
543
544std::optional<Mac48Address>
545WifiRemoteStationManager::GetAffiliatedStaAddress (const Mac48Address& mldAddress) const
546{
547 auto stateIt = m_states.find (mldAddress);
548
549 if (stateIt == m_states.end ())
550 {
551 // MLD address not found
552 return std::optional<Mac48Address> ();
553 }
554
555 NS_ASSERT (stateIt->second->m_mldAddress.has_value ()
556 && *stateIt->second->m_mldAddress == mldAddress);
557 return stateIt->second->m_address;
558}
559
561WifiRemoteStationManager::GetDataTxVector (const WifiMacHeader &header, uint16_t allowedWidth)
562{
563 NS_LOG_FUNCTION (this << header << allowedWidth);
564 Mac48Address address = header.GetAddr1 ();
565 if (!header.IsMgt () && address.IsGroup ())
566 {
567 WifiMode mode = GetNonUnicastMode ();
568 WifiTxVector v;
569 v.SetMode (mode);
570 v.SetPreambleType (GetPreambleForTransmission (mode.GetModulationClass (), GetShortPreambleEnabled ()));
571 v.SetTxPowerLevel (m_defaultTxPowerLevel);
572 v.SetChannelWidth (GetChannelWidthForTransmission (mode, allowedWidth));
573 v.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mode, m_wifiPhy->GetDevice ()));
574 v.SetNTx (GetNumberOfAntennas ());
575 v.SetNss (1);
576 v.SetNess (0);
577 return v;
578 }
579 WifiTxVector txVector;
580 if (header.IsMgt ())
581 {
582 //Use the lowest basic rate for management frames
583 WifiMode mgtMode;
584 if (GetNBasicModes () > 0)
585 {
586 mgtMode = GetBasicMode (0);
587 }
588 else
589 {
590 mgtMode = GetDefaultMode ();
591 }
592 txVector.SetMode (mgtMode);
593 txVector.SetPreambleType (GetPreambleForTransmission (mgtMode.GetModulationClass (), GetShortPreambleEnabled ()));
594 txVector.SetTxPowerLevel (m_defaultTxPowerLevel);
595 uint16_t channelWidth = allowedWidth;
596 if (!header.GetAddr1 ().IsGroup ())
597 {
598 if (uint16_t rxWidth = GetChannelWidthSupported (header.GetAddr1 ());
599 rxWidth < channelWidth)
600 {
601 channelWidth = rxWidth;
602 }
603 }
604
605 txVector.SetChannelWidth (GetChannelWidthForTransmission (mgtMode, channelWidth));
606 txVector.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mgtMode, m_wifiPhy->GetDevice ()));
607 }
608 else
609 {
610 txVector = DoGetDataTxVector (Lookup (address), allowedWidth);
611 txVector.SetLdpc (txVector.GetMode ().GetModulationClass () < WIFI_MOD_CLASS_HT ? 0 : UseLdpcForDestination (address));
612 }
613 Ptr<HeConfiguration> heConfiguration = m_wifiPhy->GetDevice ()->GetHeConfiguration ();
614 if (heConfiguration)
615 {
616 txVector.SetBssColor (heConfiguration->GetBssColor ());
617 }
618 // If both the allowed width and the TXVECTOR channel width are integer multiple
619 // of 20 MHz, then the TXVECTOR channel width must not exceed the allowed width
620 NS_ASSERT_MSG ((txVector.GetChannelWidth () % 20 != 0) || (allowedWidth % 20 != 0)
621 || (txVector.GetChannelWidth () <= allowedWidth),
622 "TXVECTOR channel width (" << txVector.GetChannelWidth ()
623 << " MHz) exceeds allowed width (" << allowedWidth << " MHz)");
624 return txVector;
625}
626
628WifiRemoteStationManager::GetCtsToSelfTxVector (void)
629{
630 WifiMode defaultMode = GetDefaultMode ();
631 WifiPreamble defaultPreamble;
632 if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_EHT)
633 {
634 defaultPreamble = WIFI_PREAMBLE_EHT_MU;
635 }
636 else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HE)
637 {
638 defaultPreamble = WIFI_PREAMBLE_HE_SU;
639 }
640 else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
641 {
642 defaultPreamble = WIFI_PREAMBLE_VHT_SU;
643 }
644 else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HT)
645 {
646 defaultPreamble = WIFI_PREAMBLE_HT_MF;
647 }
648 else
649 {
650 defaultPreamble = WIFI_PREAMBLE_LONG;
651 }
652
653 return WifiTxVector (defaultMode,
654 GetDefaultTxPowerLevel (),
655 defaultPreamble,
656 ConvertGuardIntervalToNanoSeconds (defaultMode, m_wifiPhy->GetDevice ()),
657 GetNumberOfAntennas (),
658 1,
659 0,
660 GetChannelWidthForTransmission (defaultMode, m_wifiPhy->GetChannelWidth ()),
661 false);
662}
663
665WifiRemoteStationManager::GetRtsTxVector (Mac48Address address)
666{
667 NS_LOG_FUNCTION (this << address);
668 if (address.IsGroup ())
669 {
670 WifiMode mode = GetNonUnicastMode ();
671 WifiTxVector v;
672 v.SetMode (mode);
673 v.SetPreambleType (GetPreambleForTransmission (mode.GetModulationClass (), GetShortPreambleEnabled ()));
674 v.SetTxPowerLevel (m_defaultTxPowerLevel);
675 v.SetChannelWidth (GetChannelWidthForTransmission (mode, m_wifiPhy->GetChannelWidth ()));
676 v.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mode, m_wifiPhy->GetDevice ()));
677 v.SetNTx (GetNumberOfAntennas ());
678 v.SetNss (1);
679 v.SetNess (0);
680 return v;
681 }
682 return DoGetRtsTxVector (Lookup (address));
683}
684
686WifiRemoteStationManager::GetCtsTxVector (Mac48Address to, WifiMode rtsTxMode) const
687{
688 NS_ASSERT (!to.IsGroup ());
689 WifiMode ctsMode = GetControlAnswerMode (rtsTxMode);
690 WifiTxVector v;
691 v.SetMode (ctsMode);
692 v.SetPreambleType (GetPreambleForTransmission (ctsMode.GetModulationClass (), GetShortPreambleEnabled ()));
693 v.SetTxPowerLevel (GetDefaultTxPowerLevel ());
694 v.SetChannelWidth (GetChannelWidthForTransmission (ctsMode, m_wifiPhy->GetChannelWidth ()));
695 uint16_t ctsTxGuardInterval = ConvertGuardIntervalToNanoSeconds (ctsMode, m_wifiPhy->GetDevice ());
696 v.SetGuardInterval (ctsTxGuardInterval);
697 v.SetNss (1);
698 return v;
699}
700
702WifiRemoteStationManager::GetAckTxVector (Mac48Address to, const WifiTxVector& dataTxVector) const
703{
704 NS_ASSERT (!to.IsGroup ());
705 WifiMode ackMode = GetControlAnswerMode (dataTxVector.GetMode (GetStaId (to, dataTxVector)));
706 WifiTxVector v;
707 v.SetMode (ackMode);
708 v.SetPreambleType (GetPreambleForTransmission (ackMode.GetModulationClass (), GetShortPreambleEnabled ()));
709 v.SetTxPowerLevel (GetDefaultTxPowerLevel ());
710 v.SetChannelWidth (GetChannelWidthForTransmission (ackMode, m_wifiPhy->GetChannelWidth ()));
711 uint16_t ackTxGuardInterval = ConvertGuardIntervalToNanoSeconds (ackMode, m_wifiPhy->GetDevice ());
712 v.SetGuardInterval (ackTxGuardInterval);
713 v.SetNss (1);
714 return v;
715}
716
718WifiRemoteStationManager::GetBlockAckTxVector (Mac48Address to, const WifiTxVector& dataTxVector) const
719{
720 NS_ASSERT (!to.IsGroup ());
721 WifiMode blockAckMode = GetControlAnswerMode (dataTxVector.GetMode (GetStaId (to, dataTxVector)));
722 WifiTxVector v;
723 v.SetMode (blockAckMode);
724 v.SetPreambleType (GetPreambleForTransmission (blockAckMode.GetModulationClass (), GetShortPreambleEnabled ()));
725 v.SetTxPowerLevel (GetDefaultTxPowerLevel ());
726 v.SetChannelWidth (GetChannelWidthForTransmission (blockAckMode, m_wifiPhy->GetChannelWidth ()));
727 uint16_t blockAckTxGuardInterval = ConvertGuardIntervalToNanoSeconds (blockAckMode, m_wifiPhy->GetDevice ());
728 v.SetGuardInterval (blockAckTxGuardInterval);
729 v.SetNss (1);
730 return v;
731}
732
734WifiRemoteStationManager::GetControlAnswerMode (WifiMode reqMode) const
735{
750 NS_LOG_FUNCTION (this << reqMode);
751 WifiMode mode = GetDefaultMode ();
752 bool found = false;
753 //First, search the BSS Basic Rate set
754 for (uint8_t i = 0; i < GetNBasicModes (); i++)
755 {
756 WifiMode testMode = GetBasicMode (i);
757 if ((!found || testMode.IsHigherDataRate (mode))
758 && (!testMode.IsHigherDataRate (reqMode))
760 {
761 mode = testMode;
762 //We've found a potentially-suitable transmit rate, but we
763 //need to continue and consider all the basic rates before
764 //we can be sure we've got the right one.
765 found = true;
766 }
767 }
768 if (GetHtSupported ())
769 {
770 if (!found)
771 {
772 mode = GetDefaultMcs ();
773 for (uint8_t i = 0; i != GetNBasicMcs (); i++)
774 {
775 WifiMode testMode = GetBasicMcs (i);
776 if ((!found || testMode.IsHigherDataRate (mode))
777 && (!testMode.IsHigherDataRate (reqMode))
778 && (testMode.GetModulationClass () == reqMode.GetModulationClass ()))
779 {
780 mode = testMode;
781 //We've found a potentially-suitable transmit rate, but we
782 //need to continue and consider all the basic rates before
783 //we can be sure we've got the right one.
784 found = true;
785 }
786 }
787 }
788 }
789 //If we found a suitable rate in the BSSBasicRateSet, then we are
790 //done and can return that mode.
791 if (found)
792 {
793 NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
794 return mode;
795 }
796
814 for (const auto & thismode : m_wifiPhy->GetModeList ())
815 {
816 /* If the rate:
817 *
818 * - is a mandatory rate for the PHY, and
819 * - is equal to or faster than our current best choice, and
820 * - is less than or equal to the rate of the received frame, and
821 * - is of the same modulation class as the received frame
822 *
823 * ...then it's our best choice so far.
824 */
825 if (thismode.IsMandatory ()
826 && (!found || thismode.IsHigherDataRate (mode))
827 && (!thismode.IsHigherDataRate (reqMode))
828 && (IsAllowedControlAnswerModulationClass (reqMode.GetModulationClass (), thismode.GetModulationClass ())))
829 {
830 mode = thismode;
831 //As above; we've found a potentially-suitable transmit
832 //rate, but we need to continue and consider all the
833 //mandatory rates before we can be sure we've got the right one.
834 found = true;
835 }
836 }
837 if (GetHtSupported () )
838 {
839 for (const auto & thismode : m_wifiPhy->GetMcsList ())
840 {
841 if (thismode.IsMandatory ()
842 && (!found || thismode.IsHigherDataRate (mode))
843 && (!thismode.IsHigherCodeRate (reqMode))
844 && (thismode.GetModulationClass () == reqMode.GetModulationClass ()))
845 {
846 mode = thismode;
847 //As above; we've found a potentially-suitable transmit
848 //rate, but we need to continue and consider all the
849 //mandatory rates before we can be sure we've got the right one.
850 found = true;
851 }
852 }
853 }
854
864 if (!found)
865 {
866 NS_FATAL_ERROR ("Can't find response rate for " << reqMode);
867 }
868
869 NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
870 return mode;
871}
872
873void
874WifiRemoteStationManager::ReportRtsFailed (const WifiMacHeader& header)
875{
876 NS_LOG_FUNCTION (this << header);
877 NS_ASSERT (!header.GetAddr1 ().IsGroup ());
878 AcIndex ac = QosUtilsMapTidToAc ((header.IsQosData ()) ? header.GetQosTid () : 0);
879 m_ssrc[ac]++;
880 m_macTxRtsFailed (header.GetAddr1 ());
881 DoReportRtsFailed (Lookup (header.GetAddr1 ()));
882}
883
884void
885WifiRemoteStationManager::ReportDataFailed (Ptr<const WifiMpdu> mpdu)
886{
887 NS_LOG_FUNCTION (this << *mpdu);
888 NS_ASSERT (!mpdu->GetHeader ().GetAddr1 ().IsGroup ());
889 AcIndex ac = QosUtilsMapTidToAc ((mpdu->GetHeader ().IsQosData ()) ? mpdu->GetHeader ().GetQosTid () : 0);
890 bool longMpdu = (mpdu->GetSize () > m_rtsCtsThreshold);
891 if (longMpdu)
892 {
893 m_slrc[ac]++;
894 }
895 else
896 {
897 m_ssrc[ac]++;
898 }
899 m_macTxDataFailed (mpdu->GetHeader ().GetAddr1 ());
900 DoReportDataFailed (Lookup (mpdu->GetHeader ().GetAddr1 ()));
901}
902
903void
904WifiRemoteStationManager::ReportRtsOk (const WifiMacHeader& header,
905 double ctsSnr, WifiMode ctsMode, double rtsSnr)
906{
907 NS_LOG_FUNCTION (this << header << ctsSnr << ctsMode << rtsSnr);
908 NS_ASSERT (!header.GetAddr1 ().IsGroup ());
909 WifiRemoteStation *station = Lookup (header.GetAddr1 ());
910 AcIndex ac = QosUtilsMapTidToAc ((header.IsQosData ()) ? header.GetQosTid () : 0);
911 station->m_state->m_info.NotifyTxSuccess (m_ssrc[ac]);
912 m_ssrc[ac] = 0;
913 DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
914}
915
916void
917WifiRemoteStationManager::ReportDataOk (Ptr<const WifiMpdu> mpdu, double ackSnr,
918 WifiMode ackMode, double dataSnr, WifiTxVector dataTxVector)
919{
920 NS_LOG_FUNCTION (this << *mpdu << ackSnr << ackMode << dataSnr << dataTxVector);
921 const WifiMacHeader& hdr = mpdu->GetHeader ();
922 NS_ASSERT (!hdr.GetAddr1 ().IsGroup ());
923 WifiRemoteStation *station = Lookup (hdr.GetAddr1 ());
924 AcIndex ac = QosUtilsMapTidToAc ((hdr.IsQosData ()) ? hdr.GetQosTid () : 0);
925 bool longMpdu = (mpdu->GetSize () > m_rtsCtsThreshold);
926 if (longMpdu)
927 {
928 station->m_state->m_info.NotifyTxSuccess (m_slrc[ac]);
929 m_slrc[ac] = 0;
930 }
931 else
932 {
933 station->m_state->m_info.NotifyTxSuccess (m_ssrc[ac]);
934 m_ssrc[ac] = 0;
935 }
936 DoReportDataOk (station, ackSnr, ackMode, dataSnr, dataTxVector.GetChannelWidth (),
937 dataTxVector.GetNss (GetStaId (hdr.GetAddr1 (), dataTxVector)));
938}
939
940void
941WifiRemoteStationManager::ReportFinalRtsFailed (const WifiMacHeader& header)
942{
943 NS_LOG_FUNCTION (this << header);
944 NS_ASSERT (!header.GetAddr1 ().IsGroup ());
945 WifiRemoteStation *station = Lookup (header.GetAddr1 ());
946 AcIndex ac = QosUtilsMapTidToAc ((header.IsQosData ()) ? header.GetQosTid () : 0);
947 station->m_state->m_info.NotifyTxFailed ();
948 m_ssrc[ac] = 0;
949 m_macTxFinalRtsFailed (header.GetAddr1 ());
950 DoReportFinalRtsFailed (station);
951}
952
953void
954WifiRemoteStationManager::ReportFinalDataFailed (Ptr<const WifiMpdu> mpdu)
955{
956 NS_LOG_FUNCTION (this << *mpdu);
957 NS_ASSERT (!mpdu->GetHeader ().GetAddr1 ().IsGroup ());
958 WifiRemoteStation *station = Lookup (mpdu->GetHeader ().GetAddr1 ());
959 AcIndex ac = QosUtilsMapTidToAc ((mpdu->GetHeader ().IsQosData ()) ? mpdu->GetHeader ().GetQosTid () : 0);
960 station->m_state->m_info.NotifyTxFailed ();
961 bool longMpdu = (mpdu->GetSize () > m_rtsCtsThreshold);
962 if (longMpdu)
963 {
964 m_slrc[ac] = 0;
965 }
966 else
967 {
968 m_ssrc[ac] = 0;
969 }
970 m_macTxFinalDataFailed (mpdu->GetHeader ().GetAddr1 ());
971 DoReportFinalDataFailed (station);
972}
973
974void
975WifiRemoteStationManager::ReportRxOk (Mac48Address address, RxSignalInfo rxSignalInfo, WifiTxVector txVector)
976{
977 NS_LOG_FUNCTION (this << address << rxSignalInfo << txVector);
978 if (address.IsGroup ())
979 {
980 return;
981 }
982 WifiRemoteStation *station = Lookup (address);
983 DoReportRxOk (station, rxSignalInfo.snr, txVector.GetMode (GetStaId (address, txVector)));
984 station->m_rssiAndUpdateTimePair = std::make_pair (rxSignalInfo.rssi, Simulator::Now ());
985}
986
987void
988WifiRemoteStationManager::ReportAmpduTxStatus (Mac48Address address,
989 uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus,
990 double rxSnr, double dataSnr, WifiTxVector dataTxVector)
991{
992 NS_LOG_FUNCTION (this << address << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr << dataTxVector);
993 NS_ASSERT (!address.IsGroup ());
994 for (uint8_t i = 0; i < nFailedMpdus; i++)
995 {
996 m_macTxDataFailed (address);
997 }
998 DoReportAmpduTxStatus (Lookup (address), nSuccessfulMpdus, nFailedMpdus, rxSnr, dataSnr, dataTxVector.GetChannelWidth (), dataTxVector.GetNss (GetStaId (address, dataTxVector)));
999}
1000
1001bool
1002WifiRemoteStationManager::NeedRts (const WifiMacHeader &header, uint32_t size)
1003{
1004 NS_LOG_FUNCTION (this << header << size);
1005 Mac48Address address = header.GetAddr1 ();
1006 WifiTxVector txVector = GetDataTxVector (header, m_wifiPhy->GetChannelWidth ());
1007 const auto modulationClass = txVector.GetModulationClass ();
1008 if (address.IsGroup ())
1009 {
1010 return false;
1011 }
1012 if (m_erpProtectionMode == RTS_CTS
1013 && ((modulationClass == WIFI_MOD_CLASS_ERP_OFDM)
1014 || (modulationClass == WIFI_MOD_CLASS_HT)
1015 || (modulationClass == WIFI_MOD_CLASS_VHT)
1016 || (modulationClass == WIFI_MOD_CLASS_HE)
1017 || (modulationClass == WIFI_MOD_CLASS_EHT))
1018 && m_useNonErpProtection)
1019 {
1020 NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-ERP stations");
1021 return true;
1022 }
1023 else if (m_htProtectionMode == RTS_CTS
1024 && ((modulationClass == WIFI_MOD_CLASS_HT)
1025 || (modulationClass == WIFI_MOD_CLASS_VHT))
1026 && m_useNonHtProtection
1027 && !(m_erpProtectionMode != RTS_CTS && m_useNonErpProtection))
1028 {
1029 NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-HT stations");
1030 return true;
1031 }
1032 bool normally = (size > m_rtsCtsThreshold);
1033 return DoNeedRts (Lookup (address), size, normally);
1034}
1035
1036bool
1037WifiRemoteStationManager::NeedCtsToSelf (WifiTxVector txVector)
1038{
1039 WifiMode mode = txVector.GetMode ();
1040 NS_LOG_FUNCTION (this << mode);
1041 if (m_erpProtectionMode == CTS_TO_SELF
1046 || (mode.GetModulationClass () == WIFI_MOD_CLASS_EHT))
1047 && m_useNonErpProtection)
1048 {
1049 NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
1050 return true;
1051 }
1052 else if (m_htProtectionMode == CTS_TO_SELF
1053 && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1054 || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
1055 && m_useNonHtProtection
1056 && !(m_erpProtectionMode != CTS_TO_SELF && m_useNonErpProtection))
1057 {
1058 NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-HT stations");
1059 return true;
1060 }
1061 else if (!m_useNonErpProtection)
1062 {
1063 //search for the BSS Basic Rate set, if the used mode is in the basic set then there is no need for CTS To Self
1064 for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1065 {
1066 if (mode == *i)
1067 {
1068 NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
1069 return false;
1070 }
1071 }
1072 if (GetHtSupported ())
1073 {
1074 //search for the BSS Basic MCS set, if the used mode is in the basic set then there is no need for CTS To Self
1075 for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1076 {
1077 if (mode == *i)
1078 {
1079 NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
1080 return false;
1081 }
1082 }
1083 }
1084 NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
1085 return true;
1086 }
1087 return false;
1088}
1089
1090void
1091WifiRemoteStationManager::SetUseNonErpProtection (bool enable)
1092{
1093 NS_LOG_FUNCTION (this << enable);
1094 m_useNonErpProtection = enable;
1095}
1096
1097bool
1098WifiRemoteStationManager::GetUseNonErpProtection (void) const
1099{
1100 return m_useNonErpProtection;
1101}
1102
1103void
1104WifiRemoteStationManager::SetUseNonHtProtection (bool enable)
1105{
1106 NS_LOG_FUNCTION (this << enable);
1107 m_useNonHtProtection = enable;
1108}
1109
1110bool
1111WifiRemoteStationManager::GetUseNonHtProtection (void) const
1112{
1113 return m_useNonHtProtection;
1114}
1115
1116bool
1117WifiRemoteStationManager::NeedRetransmission (Ptr<const WifiMpdu> mpdu)
1118{
1119 NS_LOG_FUNCTION (this << *mpdu);
1120 NS_ASSERT (!mpdu->GetHeader ().GetAddr1 ().IsGroup ());
1121 AcIndex ac = QosUtilsMapTidToAc ((mpdu->GetHeader ().IsQosData ()) ? mpdu->GetHeader ().GetQosTid () : 0);
1122 bool longMpdu = (mpdu->GetSize () > m_rtsCtsThreshold);
1123 uint32_t retryCount, maxRetryCount;
1124 if (longMpdu)
1125 {
1126 retryCount = m_slrc[ac];
1127 maxRetryCount = m_maxSlrc;
1128 }
1129 else
1130 {
1131 retryCount = m_ssrc[ac];
1132 maxRetryCount = m_maxSsrc;
1133 }
1134 bool normally = retryCount < maxRetryCount;
1135 NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRetransmission count: " << retryCount << " result: " << std::boolalpha << normally);
1136 return DoNeedRetransmission (Lookup (mpdu->GetHeader ().GetAddr1 ()), mpdu->GetPacket (), normally);
1137}
1138
1139bool
1140WifiRemoteStationManager::NeedFragmentation (Ptr<const WifiMpdu> mpdu)
1141{
1142 NS_LOG_FUNCTION (this << *mpdu);
1143 if (mpdu->GetHeader ().GetAddr1 ().IsGroup ())
1144 {
1145 return false;
1146 }
1147 bool normally = mpdu->GetSize () > GetFragmentationThreshold ();
1148 NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
1149 return DoNeedFragmentation (Lookup (mpdu->GetHeader ().GetAddr1 ()), mpdu->GetPacket (), normally);
1150}
1151
1152void
1153WifiRemoteStationManager::DoSetFragmentationThreshold (uint32_t threshold)
1154{
1155 NS_LOG_FUNCTION (this << threshold);
1156 if (threshold < 256)
1157 {
1158 /*
1159 * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
1160 */
1161 NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
1162 m_fragmentationThreshold = 256;
1163 }
1164 else
1165 {
1166 /*
1167 * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
1168 * MMPDU, which may be either an even or an odd number of octets.
1169 */
1170 if (threshold % 2 != 0)
1171 {
1172 NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
1173 m_fragmentationThreshold = threshold - 1;
1174 }
1175 else
1176 {
1177 m_fragmentationThreshold = threshold;
1178 }
1179 }
1180}
1181
1183WifiRemoteStationManager::DoGetFragmentationThreshold (void) const
1184{
1185 return m_fragmentationThreshold;
1186}
1187
1189WifiRemoteStationManager::GetNFragments (Ptr<const WifiMpdu> mpdu)
1190{
1191 NS_LOG_FUNCTION (this << *mpdu);
1192 //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1193 uint32_t nFragments = (mpdu->GetPacket ()->GetSize () / (GetFragmentationThreshold () - mpdu->GetHeader ().GetSize () - WIFI_MAC_FCS_LENGTH));
1194
1195 //If the size of the last fragment is not 0.
1196 if ((mpdu->GetPacket ()->GetSize () % (GetFragmentationThreshold () - mpdu->GetHeader ().GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
1197 {
1198 nFragments++;
1199 }
1200 NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
1201 return nFragments;
1202}
1203
1205WifiRemoteStationManager::GetFragmentSize (Ptr<const WifiMpdu> mpdu, uint32_t fragmentNumber)
1206{
1207 NS_LOG_FUNCTION (this << *mpdu << fragmentNumber);
1208 NS_ASSERT (!mpdu->GetHeader ().GetAddr1 ().IsGroup ());
1209 uint32_t nFragment = GetNFragments (mpdu);
1210 if (fragmentNumber >= nFragment)
1211 {
1212 NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
1213 return 0;
1214 }
1215 //Last fragment
1216 if (fragmentNumber == nFragment - 1)
1217 {
1218 uint32_t lastFragmentSize = mpdu->GetPacket ()->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - mpdu->GetHeader ().GetSize () - WIFI_MAC_FCS_LENGTH));
1219 NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
1220 return lastFragmentSize;
1221 }
1222 //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1223 else
1224 {
1225 uint32_t fragmentSize = GetFragmentationThreshold () - mpdu->GetHeader ().GetSize () - WIFI_MAC_FCS_LENGTH;
1226 NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
1227 return fragmentSize;
1228 }
1229}
1230
1232WifiRemoteStationManager::GetFragmentOffset (Ptr<const WifiMpdu> mpdu, uint32_t fragmentNumber)
1233{
1234 NS_LOG_FUNCTION (this << *mpdu << fragmentNumber);
1235 NS_ASSERT (!mpdu->GetHeader ().GetAddr1 ().IsGroup ());
1236 NS_ASSERT (fragmentNumber < GetNFragments (mpdu));
1237 uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - mpdu->GetHeader ().GetSize () - WIFI_MAC_FCS_LENGTH);
1238 NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
1239 return fragmentOffset;
1240}
1241
1242bool
1243WifiRemoteStationManager::IsLastFragment (Ptr<const WifiMpdu> mpdu, uint32_t fragmentNumber)
1244{
1245 NS_LOG_FUNCTION (this << *mpdu << fragmentNumber);
1246 NS_ASSERT (!mpdu->GetHeader ().GetAddr1 ().IsGroup ());
1247 bool isLast = fragmentNumber == (GetNFragments (mpdu) - 1);
1248 NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
1249 return isLast;
1250}
1251
1252uint8_t
1253WifiRemoteStationManager::GetDefaultTxPowerLevel (void) const
1254{
1255 return m_defaultTxPowerLevel;
1256}
1257
1259WifiRemoteStationManager::GetInfo (Mac48Address address)
1260{
1261 return LookupState (address)->m_info;
1262}
1263
1264double
1265WifiRemoteStationManager::GetMostRecentRssi (Mac48Address address) const
1266{
1267 auto stationIt = m_stations.find (address);
1268 NS_ASSERT_MSG (stationIt != m_stations.end(), "Address: " << address << " not found");
1269 auto station = stationIt->second;
1270 auto rssi = station->m_rssiAndUpdateTimePair.first;
1271 auto ts = station->m_rssiAndUpdateTimePair.second;
1272 NS_ASSERT_MSG (ts.IsStrictlyPositive(), "address: " << address << " ts:" << ts);
1273 return rssi;
1274}
1275
1276std::shared_ptr<WifiRemoteStationState>
1277WifiRemoteStationManager::LookupState (Mac48Address address) const
1278{
1279 NS_LOG_FUNCTION (this << address);
1280 auto stateIt = m_states.find (address);
1281
1282 if (stateIt != m_states.end ())
1283 {
1284 NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1285 return stateIt->second;
1286 }
1287
1288 auto state = std::make_shared<WifiRemoteStationState> ();
1289 state->m_state = WifiRemoteStationState::BRAND_NEW;
1290 state->m_address = address;
1291 state->m_aid = 0;
1292 state->m_operationalRateSet.push_back (GetDefaultMode ());
1293 state->m_operationalMcsSet.push_back (GetDefaultMcs ());
1294 state->m_dsssSupported = false;
1295 state->m_erpOfdmSupported = false;
1296 state->m_ofdmSupported = false;
1297 state->m_htCapabilities = 0;
1298 state->m_vhtCapabilities = 0;
1299 state->m_heCapabilities = 0;
1300 state->m_ehtCapabilities = 0;
1301 state->m_channelWidth = m_wifiPhy->GetChannelWidth ();
1302 state->m_guardInterval = GetGuardInterval ();
1303 state->m_ness = 0;
1304 state->m_aggregation = false;
1305 state->m_qosSupported = false;
1306 const_cast<WifiRemoteStationManager *> (this)->m_states.insert ({address, state});
1307 NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1308 return state;
1309}
1310
1311WifiRemoteStation *
1312WifiRemoteStationManager::Lookup (Mac48Address address) const
1313{
1314 NS_LOG_FUNCTION (this << address);
1315 auto stationIt = m_stations.find (address);
1316
1317 if (stationIt != m_stations.end ())
1318 {
1319 return stationIt->second;
1320 }
1321
1322 WifiRemoteStation *station = DoCreateStation ();
1323 station->m_state = LookupState (address).get ();
1324 station->m_rssiAndUpdateTimePair = std::make_pair (0, Seconds (0));
1325 const_cast<WifiRemoteStationManager *> (this)->m_stations.insert ({address, station});
1326 return station;
1327}
1328
1329void
1330WifiRemoteStationManager::SetAssociationId (Mac48Address remoteAddress, uint16_t aid)
1331{
1332 NS_LOG_FUNCTION (this << remoteAddress << aid);
1333 LookupState (remoteAddress)->m_aid = aid;
1334}
1335
1336void
1337WifiRemoteStationManager::SetQosSupport (Mac48Address from, bool qosSupported)
1338{
1339 NS_LOG_FUNCTION (this << from << qosSupported);
1340 LookupState (from)->m_qosSupported = qosSupported;
1341}
1342
1343void
1344WifiRemoteStationManager::AddStationHtCapabilities (Mac48Address from, HtCapabilities htCapabilities)
1345{
1346 //Used by all stations to record HT capabilities of remote stations
1347 NS_LOG_FUNCTION (this << from << htCapabilities);
1348 auto state = LookupState (from);
1349 if (htCapabilities.GetSupportedChannelWidth () == 1)
1350 {
1351 state->m_channelWidth = 40;
1352 }
1353 else
1354 {
1355 state->m_channelWidth = 20;
1356 }
1357 SetQosSupport (from, true);
1358 for (const auto & mcs : m_wifiPhy->GetMcsList (WIFI_MOD_CLASS_HT))
1359 {
1360 if (htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1361 {
1362 AddSupportedMcs (from, mcs);
1363 }
1364 }
1365 state->m_htCapabilities = Create<const HtCapabilities> (htCapabilities);
1366}
1367
1368void
1369WifiRemoteStationManager::AddStationVhtCapabilities (Mac48Address from, VhtCapabilities vhtCapabilities)
1370{
1371 //Used by all stations to record VHT capabilities of remote stations
1372 NS_LOG_FUNCTION (this << from << vhtCapabilities);
1373 auto state = LookupState (from);
1374 if (vhtCapabilities.GetSupportedChannelWidthSet () == 1)
1375 {
1376 state->m_channelWidth = 160;
1377 }
1378 else
1379 {
1380 state->m_channelWidth = 80;
1381 }
1382 for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++)
1383 {
1384 for (const auto & mcs : m_wifiPhy->GetMcsList (WIFI_MOD_CLASS_VHT))
1385 {
1386 if (vhtCapabilities.IsSupportedMcs (mcs.GetMcsValue (), i))
1387 {
1388 AddSupportedMcs (from, mcs);
1389 }
1390 }
1391 }
1392 state->m_vhtCapabilities = Create<const VhtCapabilities> (vhtCapabilities);
1393}
1394
1395void
1396WifiRemoteStationManager::AddStationHeCapabilities (Mac48Address from, HeCapabilities heCapabilities)
1397{
1398 //Used by all stations to record HE capabilities of remote stations
1399 NS_LOG_FUNCTION (this << from << heCapabilities);
1400 auto state = LookupState (from);
1401 if ((m_wifiPhy->GetPhyBand () == WIFI_PHY_BAND_5GHZ) || (m_wifiPhy->GetPhyBand () == WIFI_PHY_BAND_6GHZ))
1402 {
1403 if (heCapabilities.GetChannelWidthSet () & 0x04)
1404 {
1405 state->m_channelWidth = 160;
1406 }
1407 else if (heCapabilities.GetChannelWidthSet () & 0x02)
1408 {
1409 state->m_channelWidth = 80;
1410 }
1411 //For other cases at 5 GHz, the supported channel width is set by the VHT capabilities
1412 }
1413 else if (m_wifiPhy->GetPhyBand () == WIFI_PHY_BAND_2_4GHZ)
1414 {
1415 if (heCapabilities.GetChannelWidthSet () & 0x01)
1416 {
1417 state->m_channelWidth = 40;
1418 }
1419 else
1420 {
1421 state->m_channelWidth = 20;
1422 }
1423 }
1424 if (heCapabilities.GetHeSuPpdu1xHeLtf800nsGi () == 1)
1425 {
1426 state->m_guardInterval = 800;
1427 }
1428 else
1429 {
1430 //todo: Using 3200ns, default value for HeConfiguration::GuardInterval
1431 state->m_guardInterval = 3200;
1432 }
1433 for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++)
1434 {
1435 for (const auto & mcs : m_wifiPhy->GetMcsList (WIFI_MOD_CLASS_HE))
1436 {
1437 if (heCapabilities.GetHighestNssSupported () >= i
1438 && heCapabilities.GetHighestMcsSupported () >= mcs.GetMcsValue ())
1439 {
1440 AddSupportedMcs (from, mcs);
1441 }
1442 }
1443 }
1444 state->m_heCapabilities = Create<const HeCapabilities> (heCapabilities);
1445 SetQosSupport (from, true);
1446}
1447
1448void
1449WifiRemoteStationManager::AddStationEhtCapabilities (Mac48Address from, EhtCapabilities ehtCapabilities)
1450{
1451 //Used by all stations to record EHT capabilities of remote stations
1452 NS_LOG_FUNCTION (this << from << ehtCapabilities);
1453 auto state = LookupState (from);
1454 //TODO: to be completed
1455 state->m_ehtCapabilities = Create<const EhtCapabilities> (ehtCapabilities);
1456 SetQosSupport (from, true);
1457}
1458
1460WifiRemoteStationManager::GetStationHtCapabilities (Mac48Address from)
1461{
1462 return LookupState (from)->m_htCapabilities;
1463}
1464
1466WifiRemoteStationManager::GetStationVhtCapabilities (Mac48Address from)
1467{
1468 return LookupState (from)->m_vhtCapabilities;
1469}
1470
1472WifiRemoteStationManager::GetStationHeCapabilities (Mac48Address from)
1473{
1474 return LookupState (from)->m_heCapabilities;
1475}
1476
1478WifiRemoteStationManager::GetStationEhtCapabilities (Mac48Address from)
1479{
1480 return LookupState (from)->m_ehtCapabilities;
1481}
1482
1483bool
1484WifiRemoteStationManager::GetLdpcSupported (Mac48Address address) const
1485{
1486 Ptr<const HtCapabilities> htCapabilities = LookupState (address)->m_htCapabilities;
1487 Ptr<const VhtCapabilities> vhtCapabilities = LookupState (address)->m_vhtCapabilities;
1488 Ptr<const HeCapabilities> heCapabilities = LookupState (address)->m_heCapabilities;
1489 bool supported = false;
1490 if (htCapabilities)
1491 {
1492 supported |= htCapabilities->GetLdpc ();
1493 }
1494 if (vhtCapabilities)
1495 {
1496 supported |= vhtCapabilities->GetRxLdpc ();
1497 }
1498 if (heCapabilities)
1499 {
1500 supported |= heCapabilities->GetLdpcCodingInPayload ();
1501 }
1502 return supported;
1503}
1504
1506WifiRemoteStationManager::GetDefaultMode (void) const
1507{
1508 return m_defaultTxMode;
1509}
1510
1512WifiRemoteStationManager::GetDefaultMcs (void) const
1513{
1514 return m_defaultTxMcs;
1515}
1516
1518WifiRemoteStationManager::GetDefaultModeForSta (const WifiRemoteStation *st) const
1519{
1520 NS_LOG_FUNCTION (this << st);
1521
1522 if (!GetHtSupported () || !GetHtSupported (st))
1523 {
1524 return GetDefaultMode ();
1525 }
1526
1527 // find the highest modulation class supported by both stations
1529 if (GetHeSupported () && GetHeSupported (st))
1530 {
1531 modClass = WIFI_MOD_CLASS_HE;
1532 }
1533 else if (GetVhtSupported () && GetVhtSupported (st))
1534 {
1535 modClass = WIFI_MOD_CLASS_VHT;
1536 }
1537
1538 // return the MCS with lowest index
1539 return *m_wifiPhy->GetPhyEntity (modClass)->begin ();
1540}
1541
1542void
1544{
1545 NS_LOG_FUNCTION (this);
1546 m_states.clear ();
1547 for (auto& state: m_stations)
1548 {
1549 delete (state.second);
1550 }
1551 m_stations.clear ();
1552 m_bssBasicRateSet.clear ();
1553 m_bssBasicMcsSet.clear ();
1554 m_ssrc.fill (0);
1555 m_slrc.fill (0);
1556}
1557
1558void
1559WifiRemoteStationManager::AddBasicMode (WifiMode mode)
1560{
1561 NS_LOG_FUNCTION (this << mode);
1563 {
1564 NS_FATAL_ERROR ("It is not allowed to add a HT rate in the BSSBasicRateSet!");
1565 }
1566 for (uint8_t i = 0; i < GetNBasicModes (); i++)
1567 {
1568 if (GetBasicMode (i) == mode)
1569 {
1570 return;
1571 }
1572 }
1573 m_bssBasicRateSet.push_back (mode);
1574}
1575
1576uint8_t
1577WifiRemoteStationManager::GetNBasicModes (void) const
1578{
1579 return static_cast<uint8_t> (m_bssBasicRateSet.size ());
1580}
1581
1583WifiRemoteStationManager::GetBasicMode (uint8_t i) const
1584{
1585 NS_ASSERT (i < GetNBasicModes ());
1586 return m_bssBasicRateSet[i];
1587}
1588
1590WifiRemoteStationManager::GetNNonErpBasicModes (void) const
1591{
1592 uint32_t size = 0;
1593 for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1594 {
1595 if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1596 {
1597 continue;
1598 }
1599 size++;
1600 }
1601 return size;
1602}
1603
1605WifiRemoteStationManager::GetNonErpBasicMode (uint8_t i) const
1606{
1607 NS_ASSERT (i < GetNNonErpBasicModes ());
1608 uint32_t index = 0;
1609 bool found = false;
1610 for (WifiModeListIterator j = m_bssBasicRateSet.begin (); j != m_bssBasicRateSet.end (); )
1611 {
1612 if (i == index)
1613 {
1614 found = true;
1615 }
1616 if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1617 {
1618 if (found)
1619 {
1620 break;
1621 }
1622 }
1623 index++;
1624 j++;
1625 }
1626 return m_bssBasicRateSet[index];
1627}
1628
1629void
1630WifiRemoteStationManager::AddBasicMcs (WifiMode mcs)
1631{
1632 NS_LOG_FUNCTION (this << +mcs.GetMcsValue ());
1633 for (uint8_t i = 0; i < GetNBasicMcs (); i++)
1634 {
1635 if (GetBasicMcs (i) == mcs)
1636 {
1637 return;
1638 }
1639 }
1640 m_bssBasicMcsSet.push_back (mcs);
1641}
1642
1643uint8_t
1644WifiRemoteStationManager::GetNBasicMcs (void) const
1645{
1646 return static_cast<uint8_t> (m_bssBasicMcsSet.size ());
1647}
1648
1650WifiRemoteStationManager::GetBasicMcs (uint8_t i) const
1651{
1652 NS_ASSERT (i < GetNBasicMcs ());
1653 return m_bssBasicMcsSet[i];
1654}
1655
1657WifiRemoteStationManager::GetNonUnicastMode (void) const
1658{
1659 if (m_nonUnicastMode == WifiMode ())
1660 {
1661 if (GetNBasicModes () > 0)
1662 {
1663 return GetBasicMode (0);
1664 }
1665 else
1666 {
1667 return GetDefaultMode ();
1668 }
1669 }
1670 else
1671 {
1672 return m_nonUnicastMode;
1673 }
1674}
1675
1676bool
1677WifiRemoteStationManager::DoNeedRts (WifiRemoteStation *station,
1678 uint32_t size, bool normally)
1679{
1680 return normally;
1681}
1682
1683bool
1684WifiRemoteStationManager::DoNeedRetransmission (WifiRemoteStation *station,
1685 Ptr<const Packet> packet, bool normally)
1686{
1687 return normally;
1688}
1689
1690bool
1691WifiRemoteStationManager::DoNeedFragmentation (WifiRemoteStation *station,
1692 Ptr<const Packet> packet, bool normally)
1693{
1694 return normally;
1695}
1696
1697void
1698WifiRemoteStationManager::DoReportAmpduTxStatus (WifiRemoteStation *station, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus, double rxSnr, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
1699{
1700 NS_LOG_DEBUG ("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
1701}
1702
1704WifiRemoteStationManager::GetSupported (const WifiRemoteStation *station, uint8_t i) const
1705{
1706 NS_ASSERT (i < GetNSupported (station));
1707 return station->m_state->m_operationalRateSet[i];
1708}
1709
1711WifiRemoteStationManager::GetMcsSupported (const WifiRemoteStation *station, uint8_t i) const
1712{
1713 NS_ASSERT (i < GetNMcsSupported (station));
1714 return station->m_state->m_operationalMcsSet[i];
1715}
1716
1718WifiRemoteStationManager::GetNonErpSupported (const WifiRemoteStation *station, uint8_t i) const
1719{
1720 NS_ASSERT (i < GetNNonErpSupported (station));
1721 //IEEE 802.11g standard defines that if the protection mechanism is enabled, RTS, CTS and CTS-To-Self
1722 //frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b basic rate.
1723 //This is a implemented here to avoid changes in every RAA, but should maybe be moved in case it breaks standard rules.
1724 uint32_t index = 0;
1725 bool found = false;
1726 for (WifiModeListIterator j = station->m_state->m_operationalRateSet.begin (); j != station->m_state->m_operationalRateSet.end (); )
1727 {
1728 if (i == index)
1729 {
1730 found = true;
1731 }
1732 if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1733 {
1734 if (found)
1735 {
1736 break;
1737 }
1738 }
1739 index++;
1740 j++;
1741 }
1742 return station->m_state->m_operationalRateSet[index];
1743}
1744
1746WifiRemoteStationManager::GetAddress (const WifiRemoteStation *station) const
1747{
1748 return station->m_state->m_address;
1749}
1750
1751uint16_t
1752WifiRemoteStationManager::GetChannelWidth (const WifiRemoteStation *station) const
1753{
1754 return station->m_state->m_channelWidth;
1755}
1756
1757bool
1758WifiRemoteStationManager::GetShortGuardIntervalSupported (const WifiRemoteStation *station) const
1759{
1760 Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1761
1762 if (!htCapabilities)
1763 {
1764 return false;
1765 }
1766 return htCapabilities->GetShortGuardInterval20 ();
1767}
1768
1769uint16_t
1770WifiRemoteStationManager::GetGuardInterval (const WifiRemoteStation *station) const
1771{
1772 return station->m_state->m_guardInterval;
1773}
1774
1775bool
1776WifiRemoteStationManager::GetAggregation (const WifiRemoteStation *station) const
1777{
1778 return station->m_state->m_aggregation;
1779}
1780
1781uint8_t
1782WifiRemoteStationManager::GetNumberOfSupportedStreams (const WifiRemoteStation *station) const
1783{
1784 Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1785
1786 if (!htCapabilities)
1787 {
1788 return 1;
1789 }
1790 return htCapabilities->GetRxHighestSupportedAntennas ();
1791}
1792
1793uint8_t
1794WifiRemoteStationManager::GetNess (const WifiRemoteStation *station) const
1795{
1796 return station->m_state->m_ness;
1797}
1798
1800WifiRemoteStationManager::GetPhy (void) const
1801{
1802 return m_wifiPhy;
1803}
1804
1806WifiRemoteStationManager::GetMac (void) const
1807{
1808 return m_wifiMac;
1809}
1810
1811uint8_t
1812WifiRemoteStationManager::GetNSupported (const WifiRemoteStation *station) const
1813{
1814 return static_cast<uint8_t> (station->m_state->m_operationalRateSet.size ());
1815}
1816
1817bool
1818WifiRemoteStationManager::GetQosSupported (const WifiRemoteStation *station) const
1819{
1820 return station->m_state->m_qosSupported;
1821}
1822
1823bool
1824WifiRemoteStationManager::GetHtSupported (const WifiRemoteStation *station) const
1825{
1826 return bool (station->m_state->m_htCapabilities);
1827}
1828
1829bool
1830WifiRemoteStationManager::GetVhtSupported (const WifiRemoteStation *station) const
1831{
1832 return bool (station->m_state->m_vhtCapabilities);
1833}
1834
1835bool
1836WifiRemoteStationManager::GetHeSupported (const WifiRemoteStation *station) const
1837{
1838 return bool (station->m_state->m_heCapabilities);
1839}
1840
1841bool
1842WifiRemoteStationManager::GetEhtSupported (const WifiRemoteStation *station) const
1843{
1844 return (bool)(station->m_state->m_ehtCapabilities);
1845}
1846
1847uint8_t
1848WifiRemoteStationManager::GetNMcsSupported (const WifiRemoteStation *station) const
1849{
1850 return static_cast<uint8_t> (station->m_state->m_operationalMcsSet.size ());
1851}
1852
1854WifiRemoteStationManager::GetNNonErpSupported (const WifiRemoteStation *station) const
1855{
1856 uint32_t size = 0;
1857 for (WifiModeListIterator i = station->m_state->m_operationalRateSet.begin (); i != station->m_state->m_operationalRateSet.end (); i++)
1858 {
1859 if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1860 {
1861 continue;
1862 }
1863 size++;
1864 }
1865 return size;
1866}
1867
1868uint16_t
1869WifiRemoteStationManager::GetChannelWidthSupported (Mac48Address address) const
1870{
1871 return LookupState (address)->m_channelWidth;
1872}
1873
1874bool
1875WifiRemoteStationManager::GetShortGuardIntervalSupported (Mac48Address address) const
1876{
1877 Ptr<const HtCapabilities> htCapabilities = LookupState (address)->m_htCapabilities;
1878
1879 if (!htCapabilities)
1880 {
1881 return false;
1882 }
1883 return htCapabilities->GetShortGuardInterval20 ();
1884}
1885
1886uint8_t
1887WifiRemoteStationManager::GetNumberOfSupportedStreams (Mac48Address address) const
1888{
1889 Ptr<const HtCapabilities> htCapabilities = LookupState (address)->m_htCapabilities;
1890
1891 if (!htCapabilities)
1892 {
1893 return 1;
1894 }
1895 return htCapabilities->GetRxHighestSupportedAntennas ();
1896}
1897
1898uint8_t
1899WifiRemoteStationManager::GetNMcsSupported (Mac48Address address) const
1900{
1901 return static_cast<uint8_t> (LookupState (address)->m_operationalMcsSet.size ());
1902}
1903
1904bool
1905WifiRemoteStationManager::GetDsssSupported (const Mac48Address& address) const
1906{
1907 return (LookupState (address)->m_dsssSupported);
1908}
1909
1910bool
1911WifiRemoteStationManager::GetErpOfdmSupported (const Mac48Address& address) const
1912{
1913 return (LookupState (address)->m_erpOfdmSupported);
1914}
1915
1916bool
1917WifiRemoteStationManager::GetOfdmSupported (const Mac48Address& address) const
1918{
1919 return (LookupState (address)->m_ofdmSupported);
1920}
1921
1922bool
1923WifiRemoteStationManager::GetHtSupported (Mac48Address address) const
1924{
1925 return bool (LookupState (address)->m_htCapabilities);
1926}
1927
1928bool
1929WifiRemoteStationManager::GetVhtSupported (Mac48Address address) const
1930{
1931 return bool (LookupState (address)->m_vhtCapabilities);
1932}
1933
1934bool
1935WifiRemoteStationManager::GetHeSupported (Mac48Address address) const
1936{
1937 return bool (LookupState (address)->m_heCapabilities);
1938}
1939
1940bool
1941WifiRemoteStationManager::GetEhtSupported (Mac48Address address) const
1942{
1943 return (bool)(LookupState (address)->m_ehtCapabilities);
1944}
1945
1946void
1947WifiRemoteStationManager::SetDefaultTxPowerLevel (uint8_t txPower)
1948{
1949 m_defaultTxPowerLevel = txPower;
1950}
1951
1952uint8_t
1953WifiRemoteStationManager::GetNumberOfAntennas (void) const
1954{
1955 return m_wifiPhy->GetNumberOfAntennas ();
1956}
1957
1958uint8_t
1959WifiRemoteStationManager::GetMaxNumberOfTransmitStreams (void) const
1960{
1961 return m_wifiPhy->GetMaxSupportedTxSpatialStreams ();
1962}
1963
1964bool
1965WifiRemoteStationManager::UseLdpcForDestination (Mac48Address dest) const
1966{
1967 return (GetLdpcSupported () && GetLdpcSupported (dest));
1968}
1969
1970} //namespace ns3
The IEEE 802.11be EHT Capabilities.
Hold variables of type enum.
Definition: enum.h:55
The IEEE 802.11ax HE Capabilities.
uint8_t GetHighestMcsSupported(void) const
Get highest MCS supported.
bool GetHeSuPpdu1xHeLtf800nsGi(void) const
Get 1xHE-LTF and 800ns GI in HE SU PPDU reception support.
uint8_t GetChannelWidthSet(void) const
Get channel width set.
uint8_t GetHighestNssSupported(void) const
Get highest NSS supported.
The HT Capabilities Information Element.
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
uint8_t GetSupportedChannelWidth(void) const
Return the supported channel width.
static WifiMode GetHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition: ht-phy.cc:458
an EUI-48 address
Definition: mac48-address.h:44
bool IsGroup(void) const
A base class which provides memory management and object aggregation.
Definition: object.h:88
uint16_t GetAssociationId(void) const
Return the association ID.
bool IsAssociated(void) const
Return whether we are associated with an AP.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Hold an unsigned integer type.
Definition: uinteger.h:44
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(void) const
Return the Traffic ID of a QoS header.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
bool IsMgt(void) const
Return true if the Type is Management.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
represent a single transmission mode
Definition: wifi-mode.h:48
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:155
bool IsHigherDataRate(WifiMode mode) const
Definition: wifi-mode.cc:199
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:177
bool IsMandatory(void) const
Definition: wifi-mode.cc:148
AttributeValue implementation for WifiMode.
Ptr< HtConfiguration > GetHtConfiguration(void) const
Ptr< VhtConfiguration > GetVhtConfiguration(void) const
Ptr< EhtConfiguration > GetEhtConfiguration(void) const
Ptr< HeConfiguration > GetHeConfiguration(void) const
std::list< WifiMode > GetMcsList(void) const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
Definition: wifi-phy.cc:1818
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:938
Ptr< WifiNetDevice > GetDevice(void) const
Return the device this PHY is associated with.
Definition: wifi-phy.cc:575
std::list< WifiMode > GetModeList(void) const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition: wifi-phy.cc:1769
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.
bool GetLdpcSupported(void) const
Return whether the device has LDPC support enabled.
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 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.
uint32_t DoGetFragmentationThreshold(void) const
Return the current fragmentation threshold.
bool GetVhtSupported(void) const
Return whether the device has VHT capability support enabled.
virtual void DoDispose(void)
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.
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.
WifiMode m_nonUnicastMode
Transmission mode for non-unicast Data frames.
bool IsAssociated(Mac48Address address) const
Return whether the station associated.
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...
uint32_t GetFragmentationThreshold(void) const
Return the fragmentation threshold.
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.
void AddSupportedMode(Mac48Address address, WifiMode mode)
Invoked in a STA or AP to store the set of modes supported by a destination which is also supported l...
std::shared_ptr< WifiRemoteStationState > LookupState(Mac48Address address) const
Return the state of the station associated with the given address.
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PHY preambles.
void RecordAssocRefused(Mac48Address address)
Records that association request was refused.
StationStates m_states
States of known stations.
static TypeId GetTypeId(void)
Get the type ID.
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.
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.
bool GetHeSupported(void) const
Return whether the device has HE capability support enabled.
uint32_t m_maxSlrc
Maximum STA long retry count (SLRC)
bool IsAssocRefused(Mac48Address address) const
Return whether we refused an association request from the given station.
ProtectionMode m_erpProtectionMode
Protection mode for ERP stations when non-ERP stations are detected.
void Reset(void)
Reset the station, invoked in a STA upon dis-association or in an AP upon reboot.
void AddSupportedErpSlotTime(Mac48Address address, bool isShortSlotTimeSupported)
Record whether the short ERP slot time is supported by the station.
bool GetShortGuardIntervalSupported(void) const
Return whether the device has SGI support enabled.
WifiMode m_defaultTxMode
The default transmission mode.
bool GetEhtSupported(void) const
Return whether the device has EHT capability support enabled.
bool GetHtSupported(void) const
Return whether the device has HT capability support enabled.
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...
uint16_t GetGuardInterval(void) const
Return the supported HE guard interval duration (in nanoseconds).
bool GetShortSlotTimeEnabled(void) const
Return whether the device uses short slot time.
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.
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(void) 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(void) 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.
WifiModulationClass GetModulationClass(void) const
Get the modulation class specified by this TXVECTOR.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
#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:88
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:205
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:45
void Reset(void)
Reset the initial value of every attribute as well as the value of every global to what they were bef...
Definition: config.cc:820
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:206
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:274
#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:266
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1245
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:126
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:73
@ 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:59
@ AP
Definition: wifi-mac.h:60
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:264
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:162
mac
Definition: third.py:87
phy
Definition: third.py:84
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.
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:32