A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
arf-wifi-manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2004,2005,2006 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
9#include "arf-wifi-manager.h"
10
11#include "ns3/log.h"
12#include "ns3/wifi-tx-vector.h"
13
14namespace ns3
15{
16
17NS_LOG_COMPONENT_DEFINE("ArfWifiManager");
18
19/**
20 * @brief hold per-remote-station state for ARF Wifi manager.
21 *
22 * This struct extends from WifiRemoteStation struct to hold additional
23 * information required by the ARF Wifi manager
24 */
26{
27 uint32_t m_timer; ///< timer value
28 uint32_t m_success; ///< success count
29 uint32_t m_failed; ///< failed count
30 bool m_recovery; ///< recovery
31 uint32_t m_timerTimeout; ///< timer timeout
32 uint32_t m_successThreshold; ///< success threshold
33 uint8_t m_rate; ///< rate
34};
35
37
40{
41 static TypeId tid =
42 TypeId("ns3::ArfWifiManager")
44 .SetGroupName("Wifi")
45 .AddConstructor<ArfWifiManager>()
46 .AddAttribute("TimerThreshold",
47 "The 'timer' threshold in the ARF algorithm.",
48 UintegerValue(15),
51 .AddAttribute("SuccessThreshold",
52 "The minimum number of successful transmissions to try a new rate.",
53 UintegerValue(10),
56 .AddTraceSource("Rate",
57 "Traced value for rate changes (b/s)",
59 "ns3::TracedValueCallback::Uint64");
60 return tid;
61}
62
69
74
75void
77{
78 NS_LOG_FUNCTION(this);
79 if (GetHtSupported())
80 {
81 NS_FATAL_ERROR("WifiRemoteStationManager selected does not support HT rates");
82 }
83 if (GetVhtSupported())
84 {
85 NS_FATAL_ERROR("WifiRemoteStationManager selected does not support VHT rates");
86 }
87 if (GetHeSupported())
88 {
89 NS_FATAL_ERROR("WifiRemoteStationManager selected does not support HE rates");
90 }
91}
92
95{
96 NS_LOG_FUNCTION(this);
97 auto station = new ArfWifiRemoteStation();
98
99 station->m_successThreshold = m_successThreshold;
100 station->m_timerTimeout = m_timerThreshold;
101 station->m_rate = 0;
102 station->m_success = 0;
103 station->m_failed = 0;
104 station->m_recovery = false;
105 station->m_timer = 0;
106
107 return station;
108}
109
110void
115
116/**
117 * It is important to realize that "recovery" mode starts after failure of
118 * the first transmission after a rate increase and ends at the first successful
119 * transmission. Specifically, recovery mode transcends retransmissions boundaries.
120 * Fundamentally, ARF handles each data transmission independently, whether it
121 * is the initial transmission of a packet or the retransmission of a packet.
122 * The fundamental reason for this is that there is a backoff between each data
123 * transmission, be it an initial transmission or a retransmission.
124 *
125 * @param st the station that we failed to send Data
126 */
127void
129{
130 NS_LOG_FUNCTION(this << st);
131 auto station = static_cast<ArfWifiRemoteStation*>(st);
132 station->m_timer++;
133 station->m_failed++;
134 station->m_success = 0;
135
136 if (station->m_recovery)
137 {
138 NS_ASSERT(station->m_failed >= 1);
139 if (station->m_failed == 1)
140 {
141 // need recovery fallback
142 if (station->m_rate != 0)
143 {
144 station->m_rate--;
145 }
146 }
147 station->m_timer = 0;
148 }
149 else
150 {
151 NS_ASSERT(station->m_failed >= 1);
152 if (((station->m_failed - 1) % 2) == 1)
153 {
154 // need normal fallback
155 if (station->m_rate != 0)
156 {
157 station->m_rate--;
158 }
159 }
160 if (station->m_failed >= 2)
161 {
162 station->m_timer = 0;
163 }
164 }
165}
166
167void
169{
170 NS_LOG_FUNCTION(this << station << rxSnr << txMode);
171}
172
173void
175 double ctsSnr,
176 WifiMode ctsMode,
177 double rtsSnr)
178{
179 NS_LOG_FUNCTION(this << station << ctsSnr << ctsMode << rtsSnr);
180 NS_LOG_DEBUG("station=" << station << " rts ok");
181}
182
183void
185 double ackSnr,
186 WifiMode ackMode,
187 double dataSnr,
188 MHz_u dataChannelWidth,
189 uint8_t dataNss)
190{
191 NS_LOG_FUNCTION(this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss);
192 auto station = static_cast<ArfWifiRemoteStation*>(st);
193 station->m_timer++;
194 station->m_success++;
195 station->m_failed = 0;
196 station->m_recovery = false;
197 NS_LOG_DEBUG("station=" << station << " data ok success=" << station->m_success
198 << ", timer=" << station->m_timer);
199 if ((station->m_success == m_successThreshold || station->m_timer == m_timerThreshold) &&
200 (station->m_rate < (station->m_state->m_operationalRateSet.size() - 1)))
201 {
202 NS_LOG_DEBUG("station=" << station << " inc rate");
203 station->m_rate++;
204 station->m_timer = 0;
205 station->m_success = 0;
206 station->m_recovery = true;
207 }
208}
209
210void
215
216void
221
224{
225 NS_LOG_FUNCTION(this << st << allowedWidth);
226 auto station = static_cast<ArfWifiRemoteStation*>(st);
227 auto channelWidth = GetChannelWidth(station);
228 if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22})
229 {
230 channelWidth = MHz_u{20};
231 }
232 WifiMode mode = GetSupported(station, station->m_rate);
233 uint64_t rate = mode.GetDataRate(channelWidth);
234 if (m_currentRate != rate)
235 {
236 NS_LOG_DEBUG("New datarate: " << rate);
237 m_currentRate = rate;
238 }
239 return WifiTxVector(
240 mode,
243 NanoSeconds(800),
244 1,
245 1,
246 0,
247 channelWidth,
248 GetAggregation(station));
249}
250
253{
254 NS_LOG_FUNCTION(this << st);
255 /// @todo we could/should implement the ARF algorithm for
256 /// RTS only by picking a single rate within the BasicRateSet.
257 auto station = static_cast<ArfWifiRemoteStation*>(st);
258 auto channelWidth = GetChannelWidth(station);
259 if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22})
260 {
261 channelWidth = MHz_u{20};
262 }
263 WifiMode mode;
265 {
266 mode = GetSupported(station, 0);
267 }
268 else
269 {
270 mode = GetNonErpSupported(station, 0);
271 }
272 return WifiTxVector(
273 mode,
276 NanoSeconds(800),
277 1,
278 1,
279 0,
280 channelWidth,
281 GetAggregation(station));
282}
283
284} // namespace ns3
ARF Rate control algorithm.
static TypeId GetTypeId()
Get the type ID.
void DoReportFinalRtsFailed(WifiRemoteStation *station) 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.
WifiRemoteStation * DoCreateStation() const override
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
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.
uint32_t m_successThreshold
success threshold
void DoInitialize() override
Initialize() implementation.
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, MHz_u allowedWidth) override
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.
uint32_t m_timerThreshold
timer threshold
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
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 DoReportDataFailed(WifiRemoteStation *station) override
It is important to realize that "recovery" mode starts after failure of the first transmission after ...
TracedValue< uint64_t > m_currentRate
Trace rate changes.
a unique identifier for an interface.
Definition type-id.h:49
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
represent a single transmission mode
Definition wifi-mode.h:38
WifiModulationClass GetModulationClass() const
Definition wifi-mode.cc:172
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
Definition wifi-mode.cc:110
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.
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,...
Definition assert.h:55
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition uinteger.h:35
#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.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#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.
Definition object-base.h:35
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1405
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.
double MHz_u
MHz weak type.
Definition wifi-units.h:31
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
hold per-remote-station state for ARF Wifi manager.
uint32_t m_timer
timer value
uint32_t m_failed
failed count
uint32_t m_timerTimeout
timer timeout
uint32_t m_successThreshold
success threshold
uint32_t m_success
success count
hold per-remote-station state.