24 #include "ns3/wifi-phy.h"
57 .SetGroupName (
"Wifi")
59 .AddAttribute (
"BerThreshold",
60 "The maximum Bit Error Rate acceptable at any transmission mode",
63 MakeDoubleChecker<double> ())
64 .AddTraceSource (
"Rate",
65 "Traced value for rate changes (b/s)",
67 "ns3::TracedValueCallback::Uint64")
121 for (
const auto & mode :
GetPhy ()->GetModeList ())
132 for (
const auto & mode :
GetPhy ()->GetMcsList ())
144 " channel width " << j <<
146 " GI " << guardInterval);
153 uint16_t guardInterval;
168 " channel width " << j <<
170 " GI " << guardInterval);
191 [&txVector] (
const std::pair<double, WifiTxVector>& p) ->
bool {
192 return ((txVector.GetMode () == p.second.GetMode ()) && (txVector.GetNss () == p.second.GetNss ()) && (txVector.GetChannelWidth () == p.second.GetChannelWidth ()));
200 [&txVector] (
const std::pair<double, WifiTxVector>& p) ->
bool {
201 return ((txVector.GetMode () == p.second.GetMode ()) && (txVector.GetNss () == p.second.GetNss ()) && (txVector.GetChannelWidth () == p.second.GetChannelWidth ()));
213 m_thresholds.push_back (std::make_pair (snr, txVector));
259 double ctsSnr,
WifiMode ctsMode,
double rtsSnr)
270 double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
276 NS_LOG_WARN (
"DataSnr reported to be zero; not saving this report.");
286 double rxSnr,
double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
288 NS_LOG_FUNCTION (
this << st << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr << dataChannelWidth << +dataNss);
292 NS_LOG_WARN (
"DataSnr reported to be zero; not saving this report.");
325 uint64_t bestRate = 0;
326 uint8_t selectedNss = 1;
327 uint16_t guardInterval;
339 " nss " << +selectedNss);
377 " data rate " << dataRate <<
378 " threshold " << threshold <<
" last snr observed " <<
382 if (dataRate > bestRate && threshold < snr)
385 " data rate " << dataRate <<
386 " threshold " << threshold <<
387 " channel width " << channelWidth <<
421 " data rate " << dataRate <<
422 " threshold " << threshold <<
" last snr observed " <<
426 if (dataRate > bestRate && threshold < snr)
429 " data rate " << dataRate <<
430 " channel width " << channelWidth <<
460 " data rate " << dataRate <<
461 " threshold " << threshold <<
" last snr observed " <<
465 if (dataRate > bestRate && threshold < snr)
468 " data rate " << dataRate <<
469 " threshold " << threshold <<
470 " channel width " << channelWidth <<
488 txVector.
SetNss (selectedNss);
494 " threshold " << threshold <<
495 " last snr observed " <<
498 if (dataRate > bestRate && threshold < snr)
501 " data rate " << dataRate <<
502 " threshold " << threshold <<
514 NS_LOG_DEBUG (
"Found maxMode: " << maxMode <<
" channelWidth: " << channelWidth <<
" nss: " << +selectedNss);
528 WifiTxVector bestTxVector {maxMode,
GetDefaultTxPowerLevel (),
GetPreambleForTransmission (maxMode.
GetModulationClass (),
GetShortPreambleEnabled ()), guardInterval,
GetNumberOfAntennas (), selectedNss, 0,
GetChannelWidthForTransmission (maxMode, channelWidth),
GetAggregation (station)};
529 uint64_t maxDataRate = maxMode.
GetDataRate (bestTxVector);
546 double maxThreshold = 0.0;
559 if (threshold > maxThreshold && threshold < station->m_lastSnrObserved)
561 maxThreshold = threshold;
583 "; computed SNR is " << snr <<
584 " for channel width " << channelWidth <<
585 " 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.
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
uint16_t GetChannelWidthForNonHtMode(WifiMode mode) const
Convenience function for selecting a channel width for non-HT mode.
double m_ber
The maximum Bit Error Rate acceptable at any transmission mode.
void DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
void DoInitialize(void) override
Initialize() implementation.
void BuildSnrThresholds(void)
Construct the vector of minimum SNRs needed to successfully transmit for all possible combinations (r...
static TypeId GetTypeId(void)
Get the type ID.
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station) override
void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss) override
This method is a pure virtual method that must be implemented by the sub-class.
void DoReportAmpduTxStatus(WifiRemoteStation *station, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus, double rxSnr, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss) override
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
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.
double GetLastObservedSnr(IdealWifiRemoteStation *station, uint16_t channelWidth, uint8_t nss) const
Convenience function to get the last observed SNR from a given station for a given channel width and ...
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.
virtual ~IdealWifiManager()
double GetSnrThreshold(WifiTxVector txVector)
Return the minimum SNR needed to successfully transmit data with this WifiTxVector at the specified B...
WifiRemoteStation * DoCreateStation(void) const override
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.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
represent a single transmission mode
uint8_t GetMcsValue(void) const
WifiModulationClass GetModulationClass() const
std::string GetUniqueName(void) const
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
bool IsAllowed(uint16_t channelWidth, uint8_t nss) const
uint8_t GetMaxSupportedTxSpatialStreams(void) const
uint16_t GetChannelWidth(void) const
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 GetDefaultMode(void) const
Return the default transmission mode.
uint8_t GetMaxNumberOfTransmitStreams(void) const
WifiMode GetDefaultModeForSta(const WifiRemoteStation *st) const
Return the default MCS to use to transmit frames to the given station.
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
bool GetVhtSupported(void) const
Return whether the device has VHT capability support enabled.
Ptr< WifiPhy > GetPhy(void) const
Return the WifiPhy.
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
uint8_t GetNBasicModes(void) const
Return the number of basic modes we support.
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PHY preambles.
uint8_t GetDefaultTxPowerLevel(void) 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.
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...
bool GetHeSupported(void) const
Return whether the device has HE capability support enabled.
WifiMode GetMcsSupported(const WifiRemoteStation *station, uint8_t i) const
Return the WifiMode supported by the specified station at the specified index.
void Reset(void)
Reset the station, invoked in a STA upon dis-association or in an AP upon reboot.
bool GetShortGuardIntervalSupported(void) const
Return whether the device has SGI support enabled.
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index.
bool GetHtSupported(void) const
Return whether the device has HT capability support enabled.
uint16_t GetGuardInterval(void) const
Return the supported HE guard interval duration (in nanoseconds).
uint8_t GetNumberOfAntennas(void) const
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
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.
bool IsValid(void) const
The standard disallows certain combinations of WifiMode, number of spatial streams,...
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.
uint16_t GetChannelWidth(void) const
uint16_t GetGuardInterval(void) 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 AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ 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.
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...
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.
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.
uint16_t m_lastChannelWidth
Channel width (in MHz) most recently used to the remote station.
uint16_t m_lastChannelWidthObserved
Channel width (in MHz) of most recently reported packet sent to the remote station.
hold per-remote-station state.