23 #include "ns3/packet.h"
24 #include "ns3/simulator.h"
25 #include "ns3/wifi-mac.h"
26 #include "ns3/wifi-phy.h"
28 #define Min(a, b) ((a < b) ? a : b)
63 TypeId(
"ns3::RraaWifiManager")
69 "If true the RRAA-BASIC algorithm will be used, otherwise the RRAA will be used",
73 .AddAttribute(
"Timeout",
74 "Timeout for the RRAA BASIC loss estimation block",
78 .AddAttribute(
"FrameLength",
79 "The Data frame length (in bytes) used for calculating mode TxTime.",
82 MakeUintegerChecker<uint32_t>())
83 .AddAttribute(
"AckFrameLength",
84 "The Ack frame length (in bytes) used for calculating mode TxTime.",
87 MakeUintegerChecker<uint32_t>())
88 .AddAttribute(
"Alpha",
89 "Constant for calculating the MTL threshold.",
92 MakeDoubleChecker<double>(1))
94 "Constant for calculating the ORI threshold.",
97 MakeDoubleChecker<double>(1))
99 "Constant for calculating the EWND size.",
102 MakeDoubleChecker<double>(0))
103 .AddTraceSource(
"Rate",
104 "Traced value for rate changes (b/s)",
106 "ns3::TracedValueCallback::Uint64");
128 for (
const auto& mode :
phy->GetModeList())
136 NS_LOG_DEBUG(
"Calculating TX times: Mode= " << mode <<
" DataTxTime= " << dataTxTime
137 <<
" AckTxTime= " << ackTxTime);
156 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support HT rates");
160 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support VHT rates");
164 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support HE rates");
174 if (mode == i->second)
197 if (mode == i->second)
202 NS_ABORT_MSG(
"No thresholds for mode " << mode <<
" found");
210 station->m_initialized =
false;
211 station->m_adaptiveRtsWnd = 0;
212 station->m_rtsCounter = 0;
213 station->m_adaptiveRtsOn =
false;
214 station->m_lastFrameFail =
false;
245 double nextCritical = 0;
249 for (uint8_t i = 0; i < station->
m_nRate; i++)
262 nextMtl =
m_alpha * nextCritical;
307 station->m_counter--;
308 station->m_nFailed++;
332 uint16_t dataChannelWidth,
335 NS_LOG_FUNCTION(
this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss);
339 station->m_counter--;
361 if (channelWidth > 20 && channelWidth != 22)
391 if (channelWidth > 20 && channelWidth != 22)
427 return station->m_adaptiveRtsOn;
446 auto ploss = (
static_cast<double>(station->
m_nFailed) / thresholds.
m_ewnd);
449 if (ploss > thresholds.
m_mtl)
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Robust Rate Adaptation Algorithm.
WifiRemoteStation * DoCreateStation() const override
double m_tau
Tau value for RRAA (value for calculating EWND size).
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
void ARts(RraaWifiRemoteStation *station)
Activate the use of RTS for the given station if the conditions are met.
void CheckInit(RraaWifiRemoteStation *station)
Check for initializations.
void DoReportDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
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.
static TypeId GetTypeId()
Get the type ID.
uint32_t m_frameLength
Data frame length used to calculate mode TxTime.
bool DoNeedRts(WifiRemoteStation *st, uint32_t size, bool normally) override
Time m_difs
Value of DIFS configured in the device.
void AddCalcTxTime(WifiMode mode, Time t)
Add transmission time for the given mode to an internal list.
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
void SetupMac(const Ptr< WifiMac > mac) override
Set up MAC associated with this device since it is the object that knows the full set of timing param...
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint16_t allowedWidth) override
void RunBasicAlgorithm(RraaWifiRemoteStation *station)
Find an appropriate rate for the given station, using a basic algorithm.
Time GetCalcTxTime(WifiMode mode) const
Get the estimated TxTime of a packet with a given mode.
void ResetCountersBasic(RraaWifiRemoteStation *station)
Reset the counters of the given station.
TxTime m_calcTxTime
To hold all the calculated TxTime for all modes.
void DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
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 m_beta
Beta value for RRAA (value for calculating ORI threshold).
void CheckTimeout(RraaWifiRemoteStation *station)
Check if the counter should be reset.
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 DoReportFinalDataFailed(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.
WifiRraaThresholds GetThresholds(RraaWifiRemoteStation *station, WifiMode mode) const
Get the thresholds for the given station and mode.
void DoInitialize() override
Initialize() implementation.
uint32_t m_ackLength
Ack frame length used to calculate mode TxTime.
double m_alpha
Alpha value for RRAA (value for calculating MTL threshold)
~RraaWifiManager() override
Time m_sifs
Value of SIFS configured in the device.
void InitThresholds(RraaWifiRemoteStation *station)
Initialize the thresholds internal list for the given station.
uint8_t GetMaxRate(RraaWifiRemoteStation *station) const
Return the index for the maximum transmission rate for the given station.
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
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.
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 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.
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...
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
#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.
#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_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
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.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
std::vector< std::pair< WifiRraaThresholds, WifiMode > > RraaThresholdsTable
List of thresholds for each mode.
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 RRAA Wifi manager.
uint8_t m_nRate
Number of supported rates.
Time m_lastReset
Time of the last reset.
RraaThresholdsTable m_thresholds
RRAA thresholds for this station.
bool m_initialized
For initializing variables.
uint32_t m_counter
Counter for transmission attempts.
uint32_t m_rtsCounter
Counter for RTS transmission attempts.
uint32_t m_adaptiveRtsWnd
Window size for the Adaptive RTS mechanism.
bool m_lastFrameFail
Flag if the last frame sent has failed.
bool m_adaptiveRtsOn
Check if Adaptive RTS mechanism is on.
uint8_t m_rateIndex
Current rate index.
uint32_t m_nFailed
Number of failed transmission attempts.
hold per-remote-station state.
WifiRraaThresholds structure.
double m_mtl
Maximum Tolerable Loss threshold.
uint32_t m_ewnd
Evaluation Window.
double m_ori
Opportunistic Rate Increase threshold.