25 #include "ns3/assert.h"
27 #include "ns3/boolean.h"
28 #include "ns3/double.h"
29 #include "ns3/uinteger.h"
30 #include "ns3/simulator.h"
69 .SetGroupName (
"Wifi")
71 .AddAttribute (
"Basic",
72 "If true the RRAA-BASIC algorithm will be used, otherwise the RRAA will be used.",
76 .AddAttribute (
"Timeout",
77 "Timeout for the RRAA-BASIC loss estimation block (s).",
81 .AddAttribute (
"FrameLength",
82 "The data frame length (in bytes) used for calculating mode TxTime.",
85 MakeUintegerChecker <uint32_t> ())
86 .AddAttribute (
"AckFrameLength",
87 "The ACK frame length (in bytes) used for calculating mode TxTime.",
90 MakeUintegerChecker <uint32_t> ())
91 .AddAttribute (
"Alpha",
92 "Constant for calculating the MTL threshold.",
95 MakeDoubleChecker<double> (1))
96 .AddAttribute (
"Beta",
97 "Constant for calculating the ORI threshold.",
100 MakeDoubleChecker<double> (1))
101 .AddAttribute (
"Tau",
102 "Constant for calculating the EWND size.",
105 MakeDoubleChecker<double> (0))
106 .AddAttribute (
"Gamma",
107 "Constant for Probabilistic Decision Table decrements.",
110 MakeDoubleChecker<double> (1))
111 .AddAttribute (
"Delta",
112 "Constant for Probabilistic Decision Table increments.",
115 MakeDoubleChecker<double> (1))
116 .AddTraceSource (
"RateChange",
117 "The transmission rate has change.",
119 "ns3::WifiRemoteStationManager::RateChangeTracedCallback")
120 .AddTraceSource (
"PowerChange",
121 "The transmission power has change.",
123 "ns3::WifiRemoteStationManager::PowerChangeTracedCallback")
156 for (uint8_t i = 0; i < nModes; i++)
165 NS_LOG_DEBUG (
"Calculating TX times: Mode= " << mode <<
" DataTxTime= " << dataTxTime <<
" AckTxTime= " << ackTxTime);
186 if (mode == i->second)
207 for (RrpaaThresholdsTable::const_iterator i = station->
m_thresholds.begin (); i != station->
m_thresholds.end (); i++)
209 if (mode == i->second)
214 NS_ABORT_MSG (
"No thresholds for mode " << mode <<
" found");
255 for (uint8_t i = 0; i < station->
m_nRate; i++)
275 double nextCritical = 0;
279 for (uint8_t i = 0; i < station->
m_nRate; i++)
292 nextMtl =
m_alpha * nextCritical;
303 station->
m_thresholds.push_back (std::make_pair (th, mode));
346 double ctsSnr,
WifiMode ctsMode,
double rtsSnr)
353 double ackSnr,
WifiMode ackMode,
double dataSnr)
380 if (channelWidth > 20 && channelWidth != 22)
401 return WifiTxVector (mode, station->
m_powerLevel,
GetPreambleForTransmission (mode,
GetAddress (station)), 800, 1, 1, 0, channelWidth,
GetAggregation (station),
false);
409 if (channelWidth > 20 && channelWidth != 22)
424 rtsTxVector =
WifiTxVector (mode,
GetDefaultTxPowerLevel (),
GetPreambleForTransmission (mode,
GetAddress (st)), 800, 1, 1, 0, channelWidth,
GetAggregation (station),
false);
459 double bploss = (
static_cast<double> (station->
m_nFailed) / thresholds.
m_ewnd);
463 if (bploss >= thresholds.
m_mtl)
467 NS_LOG_DEBUG (
"bploss >= MTL and power < maxPower => Increase Power");
475 NS_LOG_DEBUG (
"bploss >= MTL and power = maxPower => Decrease Rate");
483 NS_LOG_DEBUG (
"bploss >= MTL but already at maxPower and minRate");
486 else if (wploss <= thresholds.
m_ori)
490 NS_LOG_DEBUG (
"wploss <= ORI and rate < maxRate => Probabilistic Rate Increase");
493 for (uint8_t i = 0; i <= station->
m_rateIndex; i++)
511 NS_LOG_DEBUG (
"wploss <= ORI and rate = maxRate => Probabilistic Power Decrease");
532 else if (bploss > thresholds.
m_ori && wploss < thresholds.
m_mtl)
536 NS_LOG_DEBUG (
"loss between ORI and MTL and power > minPowerLevel => Probabilistic Power Decrease");
610 NS_FATAL_ERROR (
"WifiRemoteStationManager selected does not support HT rates");
620 NS_FATAL_ERROR (
"WifiRemoteStationManager selected does not support VHT rates");
630 NS_FATAL_ERROR (
"WifiRemoteStationManager selected does not support HE rates");
uint8_t GetNTxPower(void) const
Return the number of available transmission power levels.
virtual 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.
Hold per-remote-station state for RRPAA Wifi manager.
Simulation virtual time values and global simulation resolution.
uint8_t m_nPowerLevels
Number of power levels.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
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...
Time m_lastReset
Time of the last reset.
void CheckInit(RrpaaWifiRemoteStation *station)
Check for initializations.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
double m_ori
The Oportunistic Rate Increase threshold.
uint32_t m_rtsCounter
Counter for RTS transmission attempts.
uint8_t m_prevRateIndex
Rate index of the previous transmission.
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...
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...
Time m_sifs
Value of SIFS configured in the device.
uint8_t m_minPowerLevel
Differently form rate, power levels do not depend on the remote station.
#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.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
void AddCalcTxTime(WifiMode mode, Time t)
Add transmission time for the given mode to an internal list.
Mac48Address m_address
Mac48Address of the remote station.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
bool m_basic
If using the basic algorithm (without RTS/CTS).
virtual void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
uint32_t m_counter
Counter for transmission attempts.
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.
RrpaaThresholdsTable m_thresholds
Rrpaa thresholds for this station.
uint8_t m_rateIndex
Current rate index.
WifiRemoteStationState * m_state
Remote station state.
virtual WifiRemoteStation * DoCreateStation(void) const
bool m_lastFrameFail
Flag if the last frame sent has failed.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual bool IsLowLatency(void) const
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
Class for representing data rates.
uint32_t m_ewnd
The Estimation Window size.
Ptr< WifiPhy > GetPhy(void) const
Return the WifiPhy.
Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, uint16_t frequency)
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
void ResetCountersBasic(RrpaaWifiRemoteStation *station)
Reset the counters of the given station.
double m_beta
Beta value for RRPAA (value for calculating ORI threshold).
uint8_t m_powerLevel
Current power level.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables for probabilistic changes.
Time m_timeout
Timeout for the RRAA BASIC loss estimation block.
AttributeValue implementation for Time.
double m_tau
Tau value for RRPAA (value for calculating EWND size).
Time m_difs
Value of DIFS configured in the device.
Hold an unsigned integer type.
WifiPreamble GetPreambleForTransmission(WifiMode mode, Mac48Address dest)
Return the preamble to be used for the transmission.
uint64_t GetDataRate(uint8_t channelWidth, uint16_t guardInterval, uint8_t nss) const
uint8_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
Time GetCalcTxTime(WifiMode mode) const
Get the estimated TxTime of a packet with a given mode.
WifiMode GetMode(uint8_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
static TypeId GetTypeId(void)
Register this type.
uint32_t m_adaptiveRtsWnd
Window size for the Adaptive RTS mechanism.
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
Mac48Address GetAddress(const WifiRemoteStation *station) const
Return the address of the station.
double m_mtl
The Maximum Tolerable Loss threshold.
virtual void SetHtSupported(bool enable)
Enable or disable HT capability support.
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.
double m_delta
Delta value for RRPAA (value for pdTable increments).
uint32_t m_nFailed
Number of failed transmission attempts.
TracedCallback< double, double, Mac48Address > m_powerChange
The trace source fired when the transmission power change.
TracedCallback< DataRate, DataRate, Mac48Address > m_rateChange
The trace source fired when the transmission rate change.
RrpaaProbabilitiesTable m_pdTable
Probability table for power and rate changes.
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)
uint8_t m_prevPowerLevel
Power level of the previous transmission.
bool m_adaptiveRtsOn
Check if Adaptive RTS mechanism is on.
WifiRrpaaThresholds GetThresholds(RrpaaWifiRemoteStation *station, WifiMode mode) const
Get the thresholds for the given station and mode.
virtual bool DoNeedRts(WifiRemoteStation *st, Ptr< const Packet > packet, bool normally)
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.
virtual 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 RunBasicAlgorithm(RrpaaWifiRemoteStation *station)
Find an appropriate rate and power for the given station, using a basic algorithm.
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index. ...
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
uint32_t m_frameLength
Data frame length used for calculate mode TxTime.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void InitThresholds(RrpaaWifiRemoteStation *station)
Initialize the thresholds internal list for the given station.
uint8_t m_maxPowerLevel
Maximal power level.
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...
uint8_t GetDefaultTxPowerLevel(void) const
uint32_t m_ackLength
Ack frame length used for calculate mode TxTime.
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...
Robust Rate and Power Adaptation Algorithm.
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether non-ERP mode associated with the specified station at the specified index...
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
double m_alpha
Alpha value for RRPAA (value for calculating MTL threshold)
bool m_initialized
For initializing variables.
#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.
TxTime m_calcTxTime
To hold all the calculated TxTime for all modes.
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
This method is a pure virtual method that must be implemented by the sub-class.
std::vector< std::pair< WifiRrpaaThresholds, WifiMode > > RrpaaThresholdsTable
List of thresholds for each mode.
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
virtual void DoReportDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station)
virtual void SetHeSupported(bool enable)
Enable or disable HE capability support.
virtual void SetVhtSupported(bool enable)
Enable or disable VHT capability support.
uint8_t m_nRate
Number of supported rates.
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...
void RunAdaptiveRtsAlgorithm(RrpaaWifiRemoteStation *station)
Run an enhanced algorithm which activates the use of RTS for the given station if the conditions are ...
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual ~RrpaaWifiManager()
hold per-remote-station state.
void CheckTimeout(RrpaaWifiRemoteStation *station)
Check if the counter should be reseted.
double m_gamma
Gamma value for RRPAA (value for pdTable decrements).
uint8_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
std::vector< std::vector< double > > RrpaaProbabilitiesTable
List of probabilities.