23 #include "ns3/packet.h"
24 #include "ns3/wifi-tx-vector.h"
26 #define Min(a, b) ((a < b) ? a : b)
27 #define Max(a, b) ((a > b) ? a : b)
62 TypeId(
"ns3::AarfcdWifiManager")
66 .AddAttribute(
"SuccessK",
67 "Multiplication factor for the success threshold in the AARF algorithm.",
70 MakeDoubleChecker<double>())
71 .AddAttribute(
"TimerK",
72 "Multiplication factor for the timer threshold in the AARF algorithm.",
75 MakeDoubleChecker<double>())
76 .AddAttribute(
"MaxSuccessThreshold",
77 "Maximum value of the success threshold in the AARF algorithm.",
80 MakeUintegerChecker<uint32_t>())
81 .AddAttribute(
"MinTimerThreshold",
82 "The minimum value for the 'timer' threshold in the AARF algorithm.",
85 MakeUintegerChecker<uint32_t>())
86 .AddAttribute(
"MinSuccessThreshold",
87 "The minimum value for the success threshold in the AARF algorithm.",
90 MakeUintegerChecker<uint32_t>())
91 .AddAttribute(
"MinRtsWnd",
92 "Minimum value for RTS window of AARF-CD",
95 MakeUintegerChecker<uint32_t>())
96 .AddAttribute(
"MaxRtsWnd",
97 "Maximum value for RTS window of AARF-CD",
100 MakeUintegerChecker<uint32_t>())
102 "TurnOffRtsAfterRateDecrease",
103 "If true the RTS mechanism will be turned off when the rate will be decreased",
108 "TurnOnRtsAfterRateIncrease",
109 "If true the RTS mechanism will be turned on when the rate will be increased",
113 .AddTraceSource(
"Rate",
114 "Traced value for rate changes (b/s)",
116 "ns3::TracedValueCallback::Uint64");
138 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support HT rates");
142 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support VHT rates");
146 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support HE rates");
160 station->m_success = 0;
161 station->m_failed = 0;
162 station->m_recovery =
false;
163 station->m_timer = 0;
166 station->m_rtsOn =
false;
168 station->m_rtsCounter = 0;
169 station->m_justModifyRate =
true;
170 station->m_haveASuccess =
false;
188 station->m_success = 0;
190 if (!station->m_rtsOn)
193 if (!station->m_justModifyRate && !station->m_haveASuccess)
201 station->m_rtsCounter = station->m_rtsWnd;
202 if (station->m_failed >= 2)
204 station->m_timer = 0;
207 else if (station->m_recovery)
210 station->m_justModifyRate =
false;
211 station->m_rtsCounter = station->m_rtsWnd;
212 if (station->m_failed == 1)
219 station->m_justModifyRate =
true;
220 station->m_successThreshold =
222 station->m_timerTimeout =
224 if (station->m_rate != 0)
229 station->m_timer = 0;
234 station->m_justModifyRate =
false;
235 station->m_rtsCounter = station->m_rtsWnd;
236 if (((station->m_failed - 1) % 2) == 1)
243 station->m_justModifyRate =
true;
246 if (station->m_rate != 0)
251 if (station->m_failed >= 2)
253 station->m_timer = 0;
274 station->m_rtsCounter--;
282 uint16_t dataChannelWidth,
285 NS_LOG_FUNCTION(
this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss);
288 station->m_success++;
289 station->m_failed = 0;
290 station->m_recovery =
false;
291 station->m_justModifyRate =
false;
292 station->m_haveASuccess =
true;
293 NS_LOG_DEBUG(
"station=" << station <<
" data ok success=" << station->m_success
294 <<
", timer=" << station->m_timer);
295 if ((station->m_success == station->m_successThreshold ||
296 station->m_timer == station->m_timerTimeout) &&
301 station->m_timer = 0;
302 station->m_success = 0;
303 station->m_recovery =
true;
304 station->m_justModifyRate =
true;
309 station->m_rtsCounter = station->m_rtsWnd;
333 if (channelWidth > 20 && channelWidth != 22)
364 if (channelWidth > 20 && channelWidth != 22)
394 NS_LOG_INFO(
"" << station <<
" rate=" << station->m_rate
395 <<
" rts=" << (station->m_rtsOn ?
"RTS" :
"BASIC")
396 <<
" rtsCounter=" << station->m_rtsCounter);
397 return station->m_rtsOn;
an implementation of the AARF-CD algorithm
void ResetRtsWnd(AarfcdWifiRemoteStation *station)
Reset the RTS window of the given station.
bool m_turnOnRtsAfterRateIncrease
turn on RTS after rate increase
double m_timerK
Multiplication factor for the timer threshold.
TracedValue< uint64_t > m_currentRate
Trace rate changes.
uint32_t m_maxSuccessThreshold
maximum success threshold
bool DoNeedRts(WifiRemoteStation *station, uint32_t size, bool normally) override
WifiRemoteStation * DoCreateStation() const override
uint32_t m_minTimerThreshold
minimum timer threshold
uint32_t m_minSuccessThreshold
minimum success threshold
uint32_t m_minRtsWnd
minimum RTS window
bool m_turnOffRtsAfterRateDecrease
turn off RTS after rate decrease
uint32_t m_maxRtsWnd
maximum RTS window
void TurnOffRts(AarfcdWifiRemoteStation *station)
Turn off RTS for the given station.
double m_successK
Multiplication factor for the success threshold.
void DoInitialize() override
Initialize() implementation.
void TurnOnRts(AarfcdWifiRemoteStation *station)
Turn on RTS for the given station.
~AarfcdWifiManager() override
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) 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
It is important to realize that "recovery" mode starts after failure of the first transmission after ...
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint16_t allowedWidth) override
static TypeId GetTypeId()
Get the type ID.
void DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
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 CheckRts(AarfcdWifiRemoteStation *station)
Check if the use of RTS for the given station can be turned off.
void DoReportFinalRtsFailed(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, uint16_t dataChannelWidth, uint8_t dataNss) override
This method is a pure virtual method that must be implemented by the sub-class.
void IncreaseRtsWnd(AarfcdWifiRemoteStation *station)
Increase the RTS window size of the given station.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
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(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
hold a list of per-remote-station state.
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
uint8_t GetDefaultTxPowerLevel() const
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given 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.
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.
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,...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
#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_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
hold per-remote-station state for AARF-CD Wifi manager.
uint32_t m_rtsCounter
RTS counter.
uint32_t m_successThreshold
success threshold
uint32_t m_success
success
uint32_t m_rtsWnd
RTS window.
bool m_haveASuccess
have a success
bool m_justModifyRate
just modify rate
uint32_t m_timerTimeout
timer timeout
hold per-remote-station state.