22 #include "ns3/data-rate.h"
24 #include "ns3/uinteger.h"
25 #include "ns3/wifi-phy.h"
27 #define Min(a, b) ((a < b) ? a : b)
62 TypeId(
"ns3::ParfWifiManager")
66 .AddAttribute(
"AttemptThreshold",
67 "The minimum number of transmission attempts to try a new power or rate.",
70 MakeUintegerChecker<uint32_t>())
73 "The minimum number of successful transmissions to try a new power or rate.",
76 MakeUintegerChecker<uint32_t>())
77 .AddTraceSource(
"PowerChange",
78 "The transmission power has change",
80 "ns3::WifiRemoteStationManager::PowerChangeTracedCallback")
81 .AddTraceSource(
"RateChange",
82 "The transmission rate has change",
84 "ns3::WifiRemoteStationManager::RateChangeTracedCallback");
113 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support HT rates");
117 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support VHT rates");
121 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support HE rates");
131 station->m_nSuccess = 0;
132 station->m_nFail = 0;
133 station->m_usingRecoveryRate =
false;
134 station->m_usingRecoveryPower =
false;
135 station->m_initialized =
false;
136 station->m_nRetry = 0;
137 station->m_nAttempt = 0;
139 NS_LOG_DEBUG(
"create station=" << station <<
", timer=" << station->m_nAttempt
140 <<
", rate=" << +station->m_rateIndex
141 <<
", power=" << +station->m_powerLevel);
187 station->m_nAttempt++;
190 station->m_nSuccess = 0;
192 NS_LOG_DEBUG(
"station=" << station <<
" data fail retry=" << station->m_nRetry <<
", timer="
193 << station->m_nAttempt <<
", rate=" << +station->m_rateIndex
194 <<
", power=" << +station->m_powerLevel);
195 if (station->m_usingRecoveryRate)
198 if (station->m_nRetry == 1)
201 if (station->m_rateIndex != 0)
204 station->m_rateIndex--;
205 station->m_usingRecoveryRate =
false;
208 station->m_nAttempt = 0;
210 else if (station->m_usingRecoveryPower)
213 if (station->m_nRetry == 1)
219 station->m_powerLevel++;
220 station->m_usingRecoveryPower =
false;
223 station->m_nAttempt = 0;
228 if (((station->m_nRetry - 1) % 2) == 1)
233 if (station->m_rateIndex != 0)
236 station->m_rateIndex--;
242 station->m_powerLevel++;
245 if (station->m_nRetry >= 2)
247 station->m_nAttempt = 0;
272 uint16_t dataChannelWidth,
275 NS_LOG_FUNCTION(
this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss);
278 station->m_nAttempt++;
279 station->m_nSuccess++;
280 station->m_nFail = 0;
281 station->m_usingRecoveryRate =
false;
282 station->m_usingRecoveryPower =
false;
283 station->m_nRetry = 0;
284 NS_LOG_DEBUG(
"station=" << station <<
" data ok success=" << station->m_nSuccess <<
", timer="
285 << station->m_nAttempt <<
", rate=" << +station->m_rateIndex
286 <<
", power=" << +station->m_powerLevel);
288 (station->m_rateIndex < (station->m_state->m_operationalRateSet.size() - 1)))
291 station->m_rateIndex++;
292 station->m_nAttempt = 0;
293 station->m_nSuccess = 0;
294 station->m_usingRecoveryRate =
true;
302 station->m_powerLevel--;
304 station->m_nAttempt = 0;
305 station->m_nSuccess = 0;
306 station->m_usingRecoveryPower =
true;
328 if (channelWidth > 20 && channelWidth != 22)
338 if (station->m_prevPowerLevel != station->m_powerLevel)
340 m_powerChange(prevPower, power, station->m_state->m_address);
341 station->m_prevPowerLevel = station->m_powerLevel;
343 if (station->m_prevRateIndex != station->m_rateIndex)
345 m_rateChange(prevRate, rate, station->m_state->m_address);
346 station->m_prevRateIndex = station->m_rateIndex;
350 station->m_powerLevel,
368 if (channelWidth > 20 && channelWidth != 22)
Class for representing data rates.
PARF Rate control algorithm.
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
uint32_t m_successThreshold
The minimum number of successful transmissions to try a new power or rate.
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 CheckInit(ParfWifiRemoteStation *station)
Check for initializations.
TracedCallback< double, double, Mac48Address > m_powerChange
The trace source fired when the transmission power changes.
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode) override
This method is a pure virtual method that must be implemented by the sub-class.
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint16_t allowedWidth) override
TracedCallback< DataRate, DataRate, Mac48Address > m_rateChange
The trace source fired when the transmission rate changes.
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.
void DoReportDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
uint32_t m_attemptThreshold
The minimum number of transmission attempts to try a new power or rate.
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...
uint8_t m_maxPower
Maximal power level.
WifiRemoteStation * DoCreateStation() const override
static TypeId GetTypeId()
Register this type.
~ParfWifiManager() override
uint8_t m_minPower
Minimal power level.
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
void DoInitialize() override
Initialize() implementation.
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
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
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
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.
Ptr< WifiPhy > GetPhy() const
Return the WifiPhy.
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.
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.
#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.
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.
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 PARF Wifi manager.
uint32_t m_nRetry
Number of transmission retries.
bool m_usingRecoveryPower
If using recovery power.
uint32_t m_nFail
Number of failed transmission attempts.
bool m_usingRecoveryRate
If using recovery rate.
uint8_t m_rateIndex
Current rate index used by the remote station.
uint32_t m_nSuccess
Number of successful transmission attempts.
uint8_t m_prevRateIndex
Rate index of the previous transmission.
uint8_t m_powerLevel
Current power level used by the remote station.
uint8_t m_nSupported
Number of supported rates by the remote station.
bool m_initialized
For initializing variables.
uint8_t m_prevPowerLevel
Power level of the previous transmission.
uint32_t m_nAttempt
Number of transmission attempts.
hold per-remote-station state.
WifiRemoteStationState * m_state
Remote station state.
Mac48Address m_address
Mac48Address of the remote station.