|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
21 #include "ns3/packet.h"
23 #include "ns3/boolean.h"
24 #include "ns3/double.h"
25 #include "ns3/uinteger.h"
26 #include "ns3/simulator.h"
27 #include "ns3/data-rate.h"
29 #include "ns3/wifi-phy.h"
30 #include "ns3/wifi-mac.h"
68 .SetGroupName (
"Wifi")
70 .AddAttribute (
"Basic",
71 "If true the RRPAA-BASIC algorithm will be used, otherwise the RRPAA will be used.",
75 .AddAttribute (
"Timeout",
76 "Timeout for the RRPAA-BASIC loss estimation block.",
80 .AddAttribute (
"FrameLength",
81 "The Data frame length (in bytes) used for calculating mode TxTime.",
84 MakeUintegerChecker <uint32_t> ())
85 .AddAttribute (
"AckFrameLength",
86 "The Ack frame length (in bytes) used for calculating mode TxTime.",
89 MakeUintegerChecker <uint32_t> ())
90 .AddAttribute (
"Alpha",
91 "Constant for calculating the MTL threshold.",
94 MakeDoubleChecker<double> (1))
95 .AddAttribute (
"Beta",
96 "Constant for calculating the ORI threshold.",
99 MakeDoubleChecker<double> (1))
100 .AddAttribute (
"Tau",
101 "Constant for calculating the EWND size.",
104 MakeDoubleChecker<double> (0))
105 .AddAttribute (
"Gamma",
106 "Constant for Probabilistic Decision Table decrements.",
109 MakeDoubleChecker<double> (1))
110 .AddAttribute (
"Delta",
111 "Constant for Probabilistic Decision Table increments.",
114 MakeDoubleChecker<double> (1))
115 .AddTraceSource (
"RateChange",
116 "The transmission rate has change.",
118 "ns3::WifiRemoteStationManager::RateChangeTracedCallback")
119 .AddTraceSource (
"PowerChange",
120 "The transmission power has change.",
122 "ns3::WifiRemoteStationManager::PowerChangeTracedCallback")
156 for (
const auto & mode :
phy->GetModeList ())
164 NS_LOG_DEBUG (
"Calculating TX times: Mode= " << mode <<
" DataTxTime= " << dataTxTime <<
" AckTxTime= " << ackTxTime);
183 NS_FATAL_ERROR (
"WifiRemoteStationManager selected does not support HT rates");
187 NS_FATAL_ERROR (
"WifiRemoteStationManager selected does not support VHT rates");
191 NS_FATAL_ERROR (
"WifiRemoteStationManager selected does not support HE rates");
201 if (mode == i->second)
222 for (RrpaaThresholdsTable::const_iterator i = station->
m_thresholds.begin (); i != station->
m_thresholds.end (); i++)
224 if (mode == i->second)
229 NS_ABORT_MSG (
"No thresholds for mode " << mode <<
" found");
270 for (uint8_t i = 0; i < station->
m_nRate; i++)
290 double nextCritical = 0;
294 for (uint8_t i = 0; i < station->
m_nRate; i++)
307 nextMtl =
m_alpha * nextCritical;
318 station->
m_thresholds.push_back (std::make_pair (th, mode));
361 double ctsSnr,
WifiMode ctsMode,
double rtsSnr)
368 double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
370 NS_LOG_FUNCTION (
this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss);
395 if (channelWidth > 20 && channelWidth != 22)
423 if (channelWidth > 20 && channelWidth != 22)
443 uint32_t size,
bool normally)
472 double bploss = (
static_cast<double> (station->
m_nFailed) / thresholds.
m_ewnd);
476 if (bploss >= thresholds.
m_mtl)
480 NS_LOG_DEBUG (
"bploss >= MTL and power < maxPower => Increase Power");
488 NS_LOG_DEBUG (
"bploss >= MTL and power = maxPower => Decrease Rate");
496 NS_LOG_DEBUG (
"bploss >= MTL but already at maxPower and minRate");
499 else if (wploss <= thresholds.
m_ori)
503 NS_LOG_DEBUG (
"wploss <= ORI and rate < maxRate => Probabilistic Rate Increase");
506 for (uint8_t i = 0; i <= station->
m_rateIndex; i++)
524 NS_LOG_DEBUG (
"wploss <= ORI and rate = maxRate => Probabilistic Power Decrease");
545 else if (bploss > thresholds.
m_ori && wploss < thresholds.
m_mtl)
549 NS_LOG_DEBUG (
"loss between ORI and MTL and power > minPowerLevel => Probabilistic Power Decrease");
a unique identifier for an interface.
uint8_t GetDefaultTxPowerLevel(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
double m_alpha
Alpha value for RRPAA (value for calculating MTL threshold)
Time m_lastReset
Time of the last reset.
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode) override
This method is a pure virtual method that must be implemented by the sub-class.
Time m_timeout
Timeout for the RRAA BASIC loss estimation block.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
WifiRrpaaThresholds GetThresholds(RrpaaWifiRemoteStation *station, WifiMode mode) const
Get the thresholds for the given station and mode.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
AttributeValue implementation for Boolean.
void CheckTimeout(RrpaaWifiRemoteStation *station)
Check if the counter should be reset.
bool GetUseNonErpProtection(void) const
Return whether the device supports protection of non-ERP stations.
uint32_t m_ackLength
Ack frame length used for calculate mode TxTime (in bytes).
void DoInitialize(void) override
Initialize() implementation.
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
double m_mtl
The Maximum Tolerable Loss threshold.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index.
std::vector< std::pair< WifiRrpaaThresholds, WifiMode > > RrpaaThresholdsTable
List of thresholds for each mode.
uint32_t m_rtsCounter
Counter for RTS transmission attempts.
uint8_t m_prevRateIndex
Rate index of the previous transmission.
virtual ~RrpaaWifiManager()
WifiModulationClass GetModulationClass() const
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
hold a list of per-remote-station state.
bool m_basic
If using the basic algorithm (without RTS/CTS).
bool GetHtSupported(void) const
Return whether the device has HT capability support enabled.
bool m_lastFrameFail
Flag if the last frame sent has failed.
bool GetVhtSupported(void) const
Return whether the device has VHT capability support enabled.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Time m_sifs
Value of SIFS configured in the device.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
void CheckInit(RrpaaWifiRemoteStation *station)
Check for initializations.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PHY preambles.
uint8_t m_powerLevel
Current power level.
void ResetCountersBasic(RrpaaWifiRemoteStation *station)
Reset the counters of the given station.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station) override
void DoReportDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Robust Rate and Power Adaptation Algorithm.
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Hold per-remote-station state for RRPAA Wifi manager.
RrpaaThresholdsTable m_thresholds
RRPAA thresholds for this station.
double m_ori
The Opportunistic Rate Increase threshold.
Ptr< WifiPhy > GetPhy(void) const
Return the WifiPhy.
uint32_t m_adaptiveRtsWnd
Window size for the Adaptive RTS mechanism.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Class for representing data rates.
void AddCalcTxTime(WifiMode mode, Time t)
Add transmission time for the given mode to an internal list.
uint32_t m_counter
Counter for transmission attempts.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
bool m_adaptiveRtsOn
Check if Adaptive RTS mechanism is on.
represent a single transmission mode
uint8_t m_rateIndex
Current rate index.
void RunBasicAlgorithm(RrpaaWifiRemoteStation *station)
Find an appropriate rate and power for the given station, using a basic algorithm.
void RunAdaptiveRtsAlgorithm(RrpaaWifiRemoteStation *station)
Run an enhanced algorithm which activates the use of RTS for the given station if the conditions are ...
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables for probabilistic changes.
uint8_t m_minPowerLevel
Differently form rate, power levels do not depend on the remote station.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
RrpaaProbabilitiesTable m_pdTable
Probability table for power and rate changes.
double m_gamma
Gamma value for RRPAA (value for pdTable decrements).
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Simulation virtual time values and global simulation resolution.
double m_beta
Beta value for RRPAA (value for calculating ORI threshold).
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...
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 m_nPowerLevels
Number of power levels.
TxTime m_calcTxTime
To hold all the calculated TxTime for all modes.
bool m_initialized
For initializing variables.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
hold per-remote-station state.
uint8_t m_maxPowerLevel
Maximal power level.
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
uint32_t m_nFailed
Number of failed transmission attempts.
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 DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
WifiRemoteStationState * m_state
Remote station state.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether non-ERP mode associated with the specified station at the specified index.
uint8_t m_prevPowerLevel
Power level of the previous transmission.
WifiRemoteStation * DoCreateStation(void) const override
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
static TypeId GetTypeId(void)
Register this type.
uint32_t m_ewnd
The Estimation Window size.
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...
uint32_t m_frameLength
Data frame length used for calculate mode TxTime (in bytes).
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Hold an unsigned integer type.
Time m_difs
Value of DIFS configured in the device.
double m_tau
Tau value for RRPAA (value for calculating EWND size).
std::vector< std::vector< double > > RrpaaProbabilitiesTable
List of probabilities.
Mac48Address m_address
Mac48Address of the remote station.
bool DoNeedRts(WifiRemoteStation *st, uint32_t size, bool normally) override
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Ptr< const AttributeAccessor > MakeUintegerAccessor(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.
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...
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.
Time GetCalcTxTime(WifiMode mode) const
Get the estimated TxTime of a packet with a given mode.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
double m_delta
Delta value for RRPAA (value for pdTable increments).
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
bool GetHeSupported(void) const
Return whether the device has HE capability support enabled.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
uint8_t m_nRate
Number of supported rates.
TracedCallback< DataRate, DataRate, Mac48Address > m_rateChange
The trace source fired when the transmission rate change.
TracedCallback< double, double, Mac48Address > m_powerChange
The trace source fired when the transmission power change.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.