24 #include "ns3/boolean.h"
25 #include "ns3/double.h"
26 #include "ns3/uinteger.h"
27 #include "ns3/simulator.h"
29 #define Min(a,b) ((a < b) ? a : b)
66 .SetGroupName (
"Wifi")
68 .AddAttribute (
"Basic",
69 "If true the RRAA-BASIC algorithm will be used, otherwise the RRAA wil be used",
73 .AddAttribute (
"Timeout",
74 "Timeout for the RRAA BASIC loss estimation block (s)",
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))
93 .AddAttribute (
"Beta",
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")
127 for (uint32_t i = 0; i < nModes; i++)
136 NS_LOG_DEBUG (
"Calculating TX times: Mode= " << mode <<
" DataTxTime= " << dataTxTime <<
" AckTxTime= " << ackTxTime);
157 if (mode == i->second)
178 for (RraaThresholdsTable::const_iterator i = station->
m_thresholds.begin (); i != station->
m_thresholds.end (); i++)
180 if (mode == i->second)
185 NS_ABORT_MSG (
"No thresholds for mode " << mode <<
" found");
228 double nextCritical = 0;
232 for (uint32_t i = 0; i < station->
m_nRate; i++)
245 nextMtl =
m_alpha * nextCritical;
256 station->
m_thresholds.push_back (std::make_pair (th, mode));
310 double ctsSnr,
WifiMode ctsMode,
double rtsSnr)
318 double ackSnr,
WifiMode ackMode,
double dataSnr)
346 if (channelWidth > 20 && channelWidth != 22)
358 return WifiTxVector (mode,
GetDefaultTxPowerLevel (),
GetLongRetryCount (station),
GetPreambleForTransmission (mode,
GetAddress (station)), 800, 1, 1, 0, channelWidth,
GetAggregation (station),
false);
367 if (channelWidth > 20 && channelWidth != 22)
382 rtsTxVector =
WifiTxVector (mode,
GetDefaultTxPowerLevel (),
GetShortRetryCount (station),
GetPreambleForTransmission (mode,
GetAddress (station)), 800, 1, 1, 0, channelWidth,
GetAggregation (station),
false);
417 double ploss = (double) station->
m_nFailed / (
double) thresholds.
m_ewnd;
419 || ploss > thresholds.
m_mtl)
422 && ploss > thresholds.
m_mtl)
427 && ploss < thresholds.
m_ori)
482 NS_FATAL_ERROR (
"WifiRemoteStationManager selected does not support HT rates");
492 NS_FATAL_ERROR (
"WifiRemoteStationManager selected does not support VHT rates");
502 NS_FATAL_ERROR (
"WifiRemoteStationManager selected does not support HE rates");
uint32_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
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...
uint32_t GetMaxRate(RraaWifiRemoteStation *station)
Return the index for the maximum transmission rate for the given station.
Simulation virtual time values and global simulation resolution.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
AttributeValue implementation for Boolean.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
This method is a pure virtual method that must be implemented by the sub-class.
bool GetUseNonErpProtection(void) const
Return whether the device supports protection of non-ERP stations.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
double m_tau
Tau value for RRAA (value for calculating EWND size).
static TypeId GetTypeId(void)
Get the type ID.
void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)
This method is a pure virtual method that must be implemented by the sub-class.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void RunBasicAlgorithm(RraaWifiRemoteStation *station)
Find an appropriate rate for the given station, using a basic algorithm.
virtual ~RraaWifiManager()
TracedValue< uint64_t > m_currentRate
Trace rate changes.
uint32_t m_rateIndex
Current rate index.
uint32_t m_ewnd
Evaluation Window.
bool DoNeedRts(WifiRemoteStation *st, Ptr< const Packet > packet, bool normally)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
bool IsLowLatency(void) const
void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
void ResetCountersBasic(RraaWifiRemoteStation *station)
Reset the counters of the given station.
uint16_t GetFrequency(void) const
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
Return whether mode associated with the specified station at the specified index. ...
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
WifiRemoteStation * DoCreateStation(void) const
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
bool m_adaptiveRtsOn
Check if Adaptive RTS mechanism is on.
Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, uint16_t frequency)
uint32_t m_nRate
Number of supported rates.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
void CheckInit(RraaWifiRemoteStation *station)
Check for initializations.
uint32_t m_frameLength
Data frame length used for calculate mode TxTime.
void CheckTimeout(RraaWifiRemoteStation *station)
Check if the counter should be resetted.
double m_beta
Beta value for RRAA (value for calculating ORI threshold).
AttributeValue implementation for Time.
void DoReportDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
Hold an unsigned integer type.
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint32_t i) const
Return whether non-ERP mode associated with the specified station at the specified index...
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station)
WifiPreamble GetPreambleForTransmission(WifiMode mode, Mac48Address dest)
Return the preamble to be used for the transmission.
void SetHtSupported(bool enable)
Enable or disable HT capability support.
uint64_t GetDataRate(uint8_t channelWidth, uint16_t guardInterval, uint8_t nss) const
uint32_t m_counter
Counter for transmission attempts.
uint8_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
uint32_t m_rtsCounter
Counter for RTS transmission attempts.
std::vector< std::pair< WifiRraaThresholds, WifiMode > > RraaThresholdsTable
List of thresholds for each mode.
Mac48Address GetAddress(const WifiRemoteStation *station) const
Return the address of the station.
uint32_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
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...
hold a list of per-remote-station state.
Robust Rate Adaptation AlgorithmThis is an implementation of RRAA as described in "Robust rate adapta...
Time GetCalcTxTime(WifiMode mode) const
Get the estimated TxTime of a packet with a given mode.
RraaThresholdsTable m_thresholds
RRAA thresholds for this station.
double m_alpha
Alpha value for RRAA (value for calculating MTL threshold)
bool m_initialized
For initializing variables.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
TxTime m_calcTxTime
To hold all the calculated TxTime for all modes.
uint32_t m_ackLength
Ack frame length used for calculate mode TxTime.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static Time Now(void)
Return the current simulation virtual time.
void SetVhtSupported(bool enable)
Enable or disable VHT capability support.
double m_ori
Opportunistic Rate Increase threshold.
void ARts(RraaWifiRemoteStation *station)
Activate the use of RTS for the given station if the conditions are met.
void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)
This method is a pure virtual method that must be implemented by the sub-class.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
Time m_sifs
Value of SIFS configured in the device.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
uint8_t GetDefaultTxPowerLevel(void) const
Time m_difs
Value of DIFS configured in the device.
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...
WifiRraaThresholds structure.
void AddCalcTxTime(WifiMode mode, Time t)
Add transmission time for the given mode to an internal list.
uint32_t GetLongRetryCount(const WifiRemoteStation *station) const
Return the long retry limit of the given station.
Time m_lastReset
Time of the last reset.
uint32_t m_adaptiveRtsWnd
Window size for the Adaptive RTS mechanism.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
void InitThresholds(RraaWifiRemoteStation *station)
Initialize the thresholds internal list for the given station.
void SetHeSupported(bool enable)
Enable or disable HE capability support.
hold per-remote-station state for RRAA Wifi manager.
uint32_t GetShortRetryCount(const WifiRemoteStation *station) const
Return the short retry limit of the given station.
WifiRraaThresholds GetThresholds(RraaWifiRemoteStation *station, WifiMode mode) const
Get the thresholds for the given station and mode.
bool m_lastFrameFail
Flag if the last frame sent has failed.
uint32_t GetMinRate(RraaWifiRemoteStation *station)
Return the index for the minimum transmission rate for the given station.
double m_mtl
Maximum Tolerable Loss threshold.
void DoReportFinalDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
void DoReportFinalRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
hold per-remote-station state.
WifiMode GetMode(uint32_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
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...
uint32_t m_nFailed
Number of failed transmission attempts.