11#include "ns3/data-rate.h"
13#include "ns3/uinteger.h"
14#include "ns3/wifi-phy.h"
16#define Min(a, b) ((a < b) ? a : b)
51 TypeId(
"ns3::ParfWifiManager")
55 .AddAttribute(
"AttemptThreshold",
56 "The minimum number of transmission attempts to try a new power or rate.",
62 "The minimum number of successful transmissions to try a new power or rate.",
66 .AddTraceSource(
"PowerChange",
67 "The transmission power has change",
69 "ns3::WifiRemoteStationManager::PowerChangeTracedCallback")
70 .AddTraceSource(
"RateChange",
71 "The transmission rate has change",
73 "ns3::WifiRemoteStationManager::RateChangeTracedCallback");
102 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support HT rates");
106 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support VHT rates");
110 NS_FATAL_ERROR(
"WifiRemoteStationManager selected does not support HE rates");
120 station->m_nSuccess = 0;
121 station->m_nFail = 0;
122 station->m_usingRecoveryRate =
false;
123 station->m_usingRecoveryPower =
false;
124 station->m_initialized =
false;
125 station->m_nRetry = 0;
126 station->m_nAttempt = 0;
128 NS_LOG_DEBUG(
"create station=" << station <<
", timer=" << station->m_nAttempt
129 <<
", rate=" << +station->m_rateIndex
130 <<
", power=" << +station->m_powerLevel);
176 station->m_nAttempt++;
179 station->m_nSuccess = 0;
181 NS_LOG_DEBUG(
"station=" << station <<
" data fail retry=" << station->m_nRetry <<
", timer="
182 << station->m_nAttempt <<
", rate=" << +station->m_rateIndex
183 <<
", power=" << +station->m_powerLevel);
184 if (station->m_usingRecoveryRate)
187 if (station->m_nRetry == 1)
190 if (station->m_rateIndex != 0)
193 station->m_rateIndex--;
194 station->m_usingRecoveryRate =
false;
197 station->m_nAttempt = 0;
199 else if (station->m_usingRecoveryPower)
202 if (station->m_nRetry == 1)
208 station->m_powerLevel++;
209 station->m_usingRecoveryPower =
false;
212 station->m_nAttempt = 0;
217 if (((station->m_nRetry - 1) % 2) == 1)
222 if (station->m_rateIndex != 0)
225 station->m_rateIndex--;
231 station->m_powerLevel++;
234 if (station->m_nRetry >= 2)
236 station->m_nAttempt = 0;
261 MHz_u dataChannelWidth,
264 NS_LOG_FUNCTION(
this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss);
267 station->m_nAttempt++;
268 station->m_nSuccess++;
269 station->m_nFail = 0;
270 station->m_usingRecoveryRate =
false;
271 station->m_usingRecoveryPower =
false;
272 station->m_nRetry = 0;
273 NS_LOG_DEBUG(
"station=" << station <<
" data ok success=" << station->m_nSuccess <<
", timer="
274 << station->m_nAttempt <<
", rate=" << +station->m_rateIndex
275 <<
", power=" << +station->m_powerLevel);
277 (station->m_rateIndex < (station->m_state->m_operationalRateSet.size() - 1)))
280 station->m_rateIndex++;
281 station->m_nAttempt = 0;
282 station->m_nSuccess = 0;
283 station->m_usingRecoveryRate =
true;
291 station->m_powerLevel--;
293 station->m_nAttempt = 0;
294 station->m_nSuccess = 0;
295 station->m_usingRecoveryPower =
true;
317 if (channelWidth > 20 && channelWidth != 22)
326 const auto prevPower =
GetPhy()->
GetPower(station->m_prevPowerLevel);
327 if (station->m_prevPowerLevel != station->m_powerLevel)
329 m_powerChange(prevPower, power, station->m_state->m_address);
330 station->m_prevPowerLevel = station->m_powerLevel;
332 if (station->m_prevRateIndex != station->m_rateIndex)
334 m_rateChange(prevRate, rate, station->m_state->m_address);
335 station->m_prevRateIndex = station->m_rateIndex;
339 station->m_powerLevel,
357 if (channelWidth > 20 && channelWidth != 22)
Class for representing data rates.
PARF Rate control algorithm.
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, MHz_u allowedWidth) override
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 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.
void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr, MHz_u dataChannelWidth, uint8_t dataNss) override
This method is a pure virtual method that must be implemented by the sub-class.
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.
Smart pointer class similar to boost::intrusive_ptr.
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(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
dBm_u GetPower(uint8_t powerLevel) const
Get the power of the given power level.
hold a list of per-remote-station state.
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.
MHz_u GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the 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 on the link this manager is associated wi...
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 on the link this manager is associated w...
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.
Time NanoSeconds(uint64_t 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 > MakeUintegerChecker()
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
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.