12#include "ns3/simulator.h"
13#include "ns3/wifi-tx-vector.h"
45 TypeId(
"ns3::AmrrWifiManager")
49 .AddAttribute(
"UpdatePeriod",
50 "The interval between decisions about rate control changes",
56 "Ratio of minimum erroneous transmissions needed to switch to a lower rate",
62 "Ratio of maximum erroneous transmissions needed to switch to a higher rate",
67 "MaxSuccessThreshold",
68 "Maximum number of consecutive success periods needed to switch to a higher rate",
73 "MinSuccessThreshold",
74 "Minimum number of consecutive success periods needed to switch to a higher rate",
78 .AddTraceSource(
"Rate",
79 "Traced value for rate changes (b/s)",
81 "ns3::TracedValueCallback::Uint64");
103 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support HT rates");
107 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support VHT rates");
111 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support HE rates");
121 station->m_tx_ok = 0;
122 station->m_tx_err = 0;
123 station->m_tx_retr = 0;
124 station->m_retry = 0;
125 station->m_txrate = 0;
127 station->m_success = 0;
128 station->m_recovery =
false;
150 station->m_tx_retr++;
167 MHz_u dataChannelWidth,
170 NS_LOG_FUNCTION(
this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss);
262 bool needChange =
false;
313 if (
IsEnough(station) || needChange)
328 if (station->m_retry < 1)
330 rateIndex = station->m_txrate;
332 else if (station->m_retry < 2)
334 if (station->m_txrate > 0)
336 rateIndex = station->m_txrate - 1;
340 rateIndex = station->m_txrate;
343 else if (station->m_retry < 3)
345 if (station->m_txrate > 1)
347 rateIndex = station->m_txrate - 2;
351 rateIndex = station->m_txrate;
356 if (station->m_txrate > 2)
358 rateIndex = station->m_txrate - 3;
362 rateIndex = station->m_txrate;
366 if (channelWidth >
MHz_u{20} && channelWidth !=
MHz_u{22})
368 channelWidth =
MHz_u{20};
395 if (channelWidth >
MHz_u{20} && channelWidth !=
MHz_u{22})
397 channelWidth =
MHz_u{20};
AMRR Rate control algorithm.
double m_failureRatio
failure ratio
static TypeId GetTypeId()
Get the type ID.
void UpdateMode(AmrrWifiRemoteStation *station)
Update the mode used to send to the given station.
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
uint32_t m_minSuccessThreshold
minimum success threshold
bool IsMaxRate(AmrrWifiRemoteStation *station) const
Check if the current rate for the given station is the maximum rate.
TracedValue< uint64_t > m_currentRate
Trace rate changes.
bool IsMinRate(AmrrWifiRemoteStation *station) const
Check if the current rate for the given station is the minimum rate.
void DoInitialize() override
Initialize() implementation.
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.
void ResetCnt(AmrrWifiRemoteStation *station)
Reset transmission statistics of the given station.
uint32_t m_maxSuccessThreshold
maximum success threshold
bool IsEnough(AmrrWifiRemoteStation *station) const
Check if the number of retransmission, transmission error, and successful transmission are greater th...
void DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
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.
void DecreaseRate(AmrrWifiRemoteStation *station)
Decrease the transmission rate to the given station.
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
bool IsSuccess(AmrrWifiRemoteStation *station) const
Check if the number of retransmission and transmission error is less than the number of successful tr...
WifiRemoteStation * DoCreateStation() const override
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode) override
This method is a pure virtual method that must be implemented by the sub-class.
void DoReportDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Time m_updatePeriod
update period
~AmrrWifiManager() override
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, MHz_u allowedWidth) override
void IncreaseRate(AmrrWifiRemoteStation *station)
Increase the transmission rate to the given station.
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
bool IsFailure(AmrrWifiRemoteStation *station) const
Check if the number of retransmission and transmission error is greater than the number of successful...
double m_successRatio
success ratio
This class can be used to hold variables of floating point type such as 'double' or 'float'.
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
represent a single transmission mode
WifiModulationClass GetModulationClass() const
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
uint8_t GetDefaultTxPowerLevel() const
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
MHz_u GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
WifiRemoteStationManager()
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...
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether non-ERP mode associated with the specified station at the specified index.
bool GetUseNonErpProtection() const
Return whether the device supports protection of non-ERP stations.
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.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
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.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeChecker > MakeUintegerChecker()
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#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_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double 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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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 AMRR Wifi manager.
uint8_t m_txrate
transmit rate
Time m_nextModeUpdate
next mode update time
uint32_t m_success
success
uint32_t m_tx_err
transmit error
uint32_t m_tx_ok
transmit OK
uint32_t m_tx_retr
transmit retry
uint32_t m_successThreshold
success threshold
hold per-remote-station state.