11#include "ns3/ht-configuration.h"
13#include "ns3/wifi-net-device.h"
14#include "ns3/wifi-phy.h"
51 TypeId(
"ns3::IdealWifiManager")
55 .AddAttribute(
"BerThreshold",
56 "The maximum Bit Error Rate acceptable at any transmission mode",
60 .AddTraceSource(
"Rate",
61 "Traced value for rate changes (b/s)",
63 "ns3::TracedValueCallback::Uint64");
123 if (
GetPhy()->GetDevice()->GetHtConfiguration())
132 const auto guardInterval =
142 << j <<
" nss " << +nss <<
" GI "
149 << j <<
" nss " << +nss <<
" GI "
155 Time guardInterval{};
174 <<
" channel width " << j <<
" nss "
175 << +k <<
" GI " << guardInterval);
181 <<
" channel width " << j <<
" nss "
182 << +k <<
" GI " << guardInterval);
202 [&txVector](
const std::pair<double, WifiTxVector>& p) ->
bool {
203 return ((txVector.GetMode() == p.second.GetMode()) &&
204 (txVector.GetNss() == p.second.GetNss()) &&
205 (txVector.GetChannelWidth() == p.second.GetChannelWidth()));
213 [&txVector](
const std::pair<double, WifiTxVector>& p) ->
bool {
214 return ((txVector.GetMode() == p.second.GetMode()) &&
215 (txVector.GetNss() == p.second.GetNss()) &&
216 (txVector.GetChannelWidth() == p.second.GetChannelWidth()));
246 st->m_lastChannelWidthObserved =
MHz_u{0};
247 st->m_lastNssObserved = 1;
250 st->m_lastChannelWidth =
MHz_u{0};
281 station->m_lastChannelWidthObserved =
283 station->m_lastNssObserved = 1;
291 MHz_u dataChannelWidth,
299 NS_LOG_WARN(
"DataSnr reported to be zero; not saving this report.");
302 station->m_lastSnrObserved = dataSnr;
303 station->m_lastChannelWidthObserved = dataChannelWidth;
304 station->m_lastNssObserved = dataNss;
309 uint16_t nSuccessfulMpdus,
310 uint16_t nFailedMpdus,
313 MHz_u dataChannelWidth,
316 NS_LOG_FUNCTION(
this << st << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr
317 << dataChannelWidth << +dataNss);
321 NS_LOG_WARN(
"DataSnr reported to be zero; not saving this report.");
324 station->m_lastSnrObserved = dataSnr;
325 station->m_lastChannelWidthObserved = dataChannelWidth;
326 station->m_lastNssObserved = dataNss;
353 uint64_t bestRate = 0;
354 uint8_t selectedNss = 1;
355 Time guardInterval{};
356 const auto channelWidth = std::min(
GetChannelWidth(station), allowedWidth);
359 (station->m_lastSnrObserved == station->m_lastSnrCached) &&
360 (channelWidth == station->m_lastChannelWidth))
363 maxMode = station->m_lastMode;
364 selectedNss = station->m_lastNss;
366 << station->m_lastSnrObserved <<
" cached "
367 << station->m_lastSnrCached <<
" channel width "
368 << station->m_lastChannelWidth <<
" nss "
373 if (
GetPhy()->GetDevice()->GetHtConfiguration() &&
384 Time guardInterval{};
400 uint8_t nss = (mode.GetMcsValue() / 8) + 1;
405 NS_LOG_DEBUG(
"Skipping mode " << mode.GetUniqueName() <<
" nss " << +nss
413 NS_LOG_DEBUG(
"Testing mode " << mode.GetUniqueName() <<
" data rate "
414 << dataRate <<
" threshold " << threshold
415 <<
" last snr observed "
416 << station->m_lastSnrObserved <<
" cached "
417 << station->m_lastSnrCached);
419 if (dataRate > bestRate && threshold < snr)
421 NS_LOG_DEBUG(
"Candidate mode = " << mode.GetUniqueName() <<
" data rate "
422 << dataRate <<
" threshold " << threshold
423 <<
" channel width " << channelWidth
439 NS_LOG_DEBUG(
"Skipping mode " << mode.GetUniqueName() <<
" nss " << +nss
448 NS_LOG_DEBUG(
"Testing mode = " << mode.GetUniqueName() <<
" data rate "
449 << dataRate <<
" threshold " << threshold
450 <<
" last snr observed "
451 << station->m_lastSnrObserved <<
" cached "
452 << station->m_lastSnrCached);
454 if (dataRate > bestRate && threshold < snr)
457 << mode.GetUniqueName() <<
" data rate " << dataRate
458 <<
" threshold " << threshold <<
" channel width "
459 << channelWidth <<
" snr " << snr);
476 txVector.
SetNss(selectedNss);
483 NS_LOG_DEBUG(
"mode = " << mode.GetUniqueName() <<
" threshold " << threshold
484 <<
" last snr observed " << station->m_lastSnrObserved);
486 if (dataRate > bestRate && threshold < snr)
488 NS_LOG_DEBUG(
"Candidate mode = " << mode.GetUniqueName() <<
" data rate "
489 << dataRate <<
" threshold " << threshold
497 << station->m_lastSnrObserved);
498 station->m_lastSnrCached = station->m_lastSnrObserved;
499 station->m_lastMode = maxMode;
500 station->m_lastNss = selectedNss;
502 NS_LOG_DEBUG(
"Found maxMode: " << maxMode <<
" channelWidth: " << channelWidth
503 <<
" nss: " << +selectedNss);
504 station->m_lastChannelWidth = channelWidth;
528 uint64_t maxDataRate = maxMode.
GetDataRate(bestTxVector);
545 double maxThreshold = 0.0;
558 if (threshold > maxThreshold && threshold < station->m_lastSnrObserved)
560 maxThreshold = threshold;
593 << snr <<
" for channel width " << channelWidth
594 <<
" and nss " << +nss);
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Ideal rate control algorithm.
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
void AddSnrThreshold(WifiTxVector txVector, double snr)
Adds a pair of WifiTxVector and the minimum SNR for that given vector to the list.
void BuildSnrThresholds()
Construct the vector of minimum SNRs needed to successfully transmit for all possible combinations (r...
void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr, MHz_u dataChannelWidth, uint8_t dataNss) override
This method is a pure virtual method that must be implemented by the sub-class.
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
void DoInitialize() override
Initialize() implementation.
double m_ber
The maximum Bit Error Rate acceptable at any transmission mode.
WifiRemoteStation * DoCreateStation() const override
MHz_u GetChannelWidthForNonHtMode(WifiMode mode) const
Convenience function for selecting a channel width for non-HT mode.
~IdealWifiManager() override
void DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
static TypeId GetTypeId()
Get the type ID.
double GetLastObservedSnr(IdealWifiRemoteStation *station, MHz_u channelWidth, uint8_t nss) const
Convenience function to get the last observed SNR from a given station for a given channel width and ...
void DoReportAmpduTxStatus(WifiRemoteStation *station, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus, double rxSnr, double dataSnr, MHz_u dataChannelWidth, uint8_t dataNss) override
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
bool IsModulationClassSupported(WifiModulationClass mc, IdealWifiRemoteStation *station)
Check whether a given modulation class is supported by both the node and the peer.
bool IsCandidateModulationClass(WifiModulationClass mc, IdealWifiRemoteStation *station)
Check whether a given modulation class is supported and that there are no higher modulation classes t...
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, MHz_u allowedWidth) override
void SetupPhy(const Ptr< WifiPhy > phy) override
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
TracedValue< uint64_t > m_currentRate
Trace rate changes.
void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr) override
This method is a pure virtual method that must be implemented by the sub-class.
Thresholds m_thresholds
List of WifiTxVector and the minimum SNR pair.
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode) override
This method is a pure virtual method that must be implemented by the sub-class.
double GetSnrThreshold(WifiTxVector txVector)
Return the minimum SNR needed to successfully transmit data with this WifiTxVector at the specified B...
void DoReportDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
represent a single transmission mode
const std::string & GetUniqueName() const
WifiModulationClass GetModulationClass() const
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
bool IsAllowed(MHz_u channelWidth, uint8_t nss) const
uint8_t GetMcsValue() const
MHz_u GetTxBandwidth(WifiMode mode, MHz_u maxAllowedBandWidth=MHz_u{ std::numeric_limits< double >::max()}) const
Get the bandwidth for a transmission occurring on the current operating channel and using the given W...
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
MHz_u GetChannelWidth() const
uint8_t GetMaxSupportedTxSpatialStreams() const
std::list< WifiMode > GetMcsList() const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
std::list< WifiMode > GetModeList() const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
hold a list of per-remote-station state.
uint8_t GetNumberOfSupportedStreams(Mac48Address address) const
Return the number of spatial streams supported by the station.
WifiMode GetDefaultModeForSta(const WifiRemoteStation *st) const
Return the default MCS to use to transmit frames to the given station.
uint8_t GetNBasicModes() const
Return the number of basic modes we support.
Time GetGuardInterval() const
Return the shortest supported HE guard interval duration.
uint8_t GetDefaultTxPowerLevel() const
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
Ptr< WifiPhy > GetPhy() const
Return the WifiPhy.
MHz_u GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
Ptr< const He6GhzBandCapabilities > GetStationHe6GhzCapabilities(const Mac48Address &from) const
Return the HE 6 GHz Band Capabilities sent by a remote station.
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
bool GetHtSupported() const
Return whether the device has HT capability support enabled on the link this manager is associated wi...
bool GetEhtSupported() const
Return whether the device has EHT capability support enabled.
uint8_t GetNumberOfAntennas() const
uint8_t GetNMcsSupported(Mac48Address address) const
Return the number of MCS supported by the station.
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
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...
uint8_t GetMaxNumberOfTransmitStreams() const
WifiMode GetMcsSupported(const WifiRemoteStation *station, uint8_t i) const
Return the WifiMode supported by the specified station at the specified index.
void Reset()
Reset the station, invoked in a STA upon dis-association or in an AP upon reboot.
bool GetVhtSupported() const
Return whether the device has VHT capability support enabled on the link this manager is associated w...
bool GetShortPreambleEnabled() const
Return whether the device uses short PHY preambles.
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index.
bool GetHeSupported() const
Return whether the device has HE capability support enabled.
WifiMode GetDefaultMode() const
Return the default transmission mode.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetGuardInterval(Time guardInterval)
Sets the guard interval duration (in nanoseconds)
bool IsValid(WifiPhyBand band=WIFI_PHY_BAND_UNSPECIFIED) const
The standard disallows certain combinations of WifiMode, number of spatial streams,...
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
void SetChannelWidth(MHz_u channelWidth)
Sets the selected channelWidth.
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
MHz_u GetChannelWidth() const
Time GetGuardInterval() const
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void SetNss(uint8_t nss)
Sets the number of Nss.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeChecker > MakeDoubleChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#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.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
@ 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)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const double CACHE_INITIAL_VALUE
To avoid using the cache before a valid value has been cached.
double MHz_u
MHz weak type.
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
hold per-remote-station state for Ideal Wifi manager.
WifiMode m_lastMode
Mode most recently used to the remote station.
double m_lastSnrObserved
SNR of most recently reported packet sent to the remote station.
double m_lastSnrCached
SNR most recently used to select a rate.
MHz_u m_lastChannelWidth
Channel width most recently used to the remote station.
MHz_u m_lastChannelWidthObserved
Channel width of most recently reported packet sent to the remote station.
uint8_t m_lastNss
Number of spatial streams most recently used to the remote station.
uint16_t m_lastNssObserved
Number of spatial streams of most recently reported packet sent to the remote station.
hold per-remote-station state.
WifiRemoteStationState * m_state
Remote station state.
Mac48Address m_address
Mac48Address of the remote station.