A Discrete-Event Network Simulator
API
aarf-wifi-manager.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2004,2005,2006 INRIA
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 */
20
21#include "ns3/log.h"
22#include "aarf-wifi-manager.h"
23#include "ns3/wifi-tx-vector.h"
24
25#define Min(a,b) ((a < b) ? a : b)
26#define Max(a,b) ((a > b) ? a : b)
27
28namespace ns3 {
29
30NS_LOG_COMPONENT_DEFINE ("AarfWifiManager");
31
39{
46 uint8_t m_rate;
47};
48
50
53{
54 static TypeId tid = TypeId ("ns3::AarfWifiManager")
56 .SetGroupName ("Wifi")
57 .AddConstructor<AarfWifiManager> ()
58 .AddAttribute ("SuccessK", "Multiplication factor for the success threshold in the AARF algorithm.",
59 DoubleValue (2.0),
61 MakeDoubleChecker<double> ())
62 .AddAttribute ("TimerK",
63 "Multiplication factor for the timer threshold in the AARF algorithm.",
64 DoubleValue (2.0),
66 MakeDoubleChecker<double> ())
67 .AddAttribute ("MaxSuccessThreshold",
68 "Maximum value of the success threshold in the AARF algorithm.",
69 UintegerValue (60),
71 MakeUintegerChecker<uint32_t> ())
72 .AddAttribute ("MinTimerThreshold",
73 "The minimum value for the 'timer' threshold in the AARF algorithm.",
74 UintegerValue (15),
76 MakeUintegerChecker<uint32_t> ())
77 .AddAttribute ("MinSuccessThreshold",
78 "The minimum value for the success threshold in the AARF algorithm.",
79 UintegerValue (10),
81 MakeUintegerChecker<uint32_t> ())
82 .AddTraceSource ("Rate",
83 "Traced value for rate changes (b/s)",
85 "ns3::TracedValueCallback::Uint64")
86 ;
87 return tid;
88}
89
92 m_currentRate (0)
93{
94 NS_LOG_FUNCTION (this);
95}
96
98{
99 NS_LOG_FUNCTION (this);
100}
101
102void
104{
105 NS_LOG_FUNCTION (this);
106 if (GetHtSupported ())
107 {
108 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HT rates");
109 }
110 if (GetVhtSupported ())
111 {
112 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support VHT rates");
113 }
114 if (GetHeSupported ())
115 {
116 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rates");
117 }
118}
119
122{
123 NS_LOG_FUNCTION (this);
125
128 station->m_rate = 0;
129 station->m_success = 0;
130 station->m_failed = 0;
131 station->m_recovery = false;
132 station->m_timer = 0;
133
134 return station;
135}
136
137void
139{
140 NS_LOG_FUNCTION (this << station);
141}
153void
155{
156 NS_LOG_FUNCTION (this << st);
157 AarfWifiRemoteStation *station = static_cast<AarfWifiRemoteStation*> (st);
158 station->m_timer++;
159 station->m_failed++;
160 station->m_success = 0;
161
162 if (station->m_recovery)
163 {
164 NS_ASSERT (station->m_failed >= 1);
165 if (station->m_failed == 1)
166 {
167 //need recovery fallback
168 station->m_successThreshold = (int)(Min (station->m_successThreshold * m_successK,
170 station->m_timerTimeout = (int)(Max (station->m_timerTimeout * m_timerK,
172 if (station->m_rate != 0)
173 {
174 station->m_rate--;
175 }
176 }
177 station->m_timer = 0;
178 }
179 else
180 {
181 NS_ASSERT (station->m_failed >= 1);
182 if (((station->m_failed - 1) % 2) == 1)
183 {
184 //need normal fallback
187 if (station->m_rate != 0)
188 {
189 station->m_rate--;
190 }
191 }
192 if (station->m_failed >= 2)
193 {
194 station->m_timer = 0;
195 }
196 }
197}
198
199void
201 double rxSnr, WifiMode txMode)
202{
203 NS_LOG_FUNCTION (this << station << rxSnr << txMode);
204}
205
206void
208 double ctsSnr, WifiMode ctsMode, double rtsSnr)
209{
210 NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
211 NS_LOG_DEBUG ("station=" << station << " rts ok");
212}
213
214void
216 double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
217{
218 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss);
219 AarfWifiRemoteStation *station = static_cast<AarfWifiRemoteStation*> (st);
220 station->m_timer++;
221 station->m_success++;
222 station->m_failed = 0;
223 station->m_recovery = false;
224 NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
225 if ((station->m_success == station->m_successThreshold
226 || station->m_timer == station->m_timerTimeout)
227 && (station->m_rate < (GetNSupported (station) - 1)))
228 {
229 NS_LOG_DEBUG ("station=" << station << " inc rate");
230 station->m_rate++;
231 station->m_timer = 0;
232 station->m_success = 0;
233 station->m_recovery = true;
234 }
235}
236
237void
239{
240 NS_LOG_FUNCTION (this << station);
241}
242
243void
245{
246 NS_LOG_FUNCTION (this << station);
247}
248
251{
252 NS_LOG_FUNCTION (this << st);
253 AarfWifiRemoteStation *station = static_cast<AarfWifiRemoteStation*> (st);
254 uint16_t channelWidth = GetChannelWidth (station);
255 if (channelWidth > 20 && channelWidth != 22)
256 {
257 channelWidth = 20;
258 }
259 WifiMode mode = GetSupported (station, station->m_rate);
260 uint64_t rate = mode.GetDataRate (channelWidth);
261 if (m_currentRate != rate)
262 {
263 NS_LOG_DEBUG ("New datarate: " << rate);
264 m_currentRate = rate;
265 }
266 return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode.GetModulationClass (), GetShortPreambleEnabled ()), 800, 1, 1, 0, channelWidth, GetAggregation (station));
267}
268
271{
272 NS_LOG_FUNCTION (this << st);
275 AarfWifiRemoteStation *station = static_cast<AarfWifiRemoteStation*> (st);
276 uint16_t channelWidth = GetChannelWidth (station);
277 if (channelWidth > 20 && channelWidth != 22)
278 {
279 channelWidth = 20;
280 }
281 WifiMode mode;
282 if (GetUseNonErpProtection () == false)
283 {
284 mode = GetSupported (station, 0);
285 }
286 else
287 {
288 mode = GetNonErpSupported (station, 0);
289 }
290 return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode.GetModulationClass (), GetShortPreambleEnabled ()), 800, 1, 1, 0, channelWidth, GetAggregation (station));
291}
292
293} //namespace ns3
AARF Rate control algorithm.
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_minSuccessThreshold
minimum success threshold
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
WifiRemoteStation * DoCreateStation(void) const override
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station) override
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
double m_successK
Multiplication factor for the success threshold.
void DoReportDataFailed(WifiRemoteStation *station) override
It is important to realize that "recovery" mode starts after failure of the first transmission after ...
double m_timerK
Multiplication factor for the timer threshold.
void DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
uint32_t m_maxSuccessThreshold
maximum success threshold
static TypeId GetTypeId(void)
Get the type ID.
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode) override
This method is a pure virtual method that must be implemented by the sub-class.
uint32_t m_minTimerThreshold
minimum timer threshold
void DoInitialize(void) override
Initialize() implementation.
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.
TracedValue< uint64_t > m_currentRate
Trace rate changes.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Hold an unsigned integer type.
Definition: uinteger.h:44
represent a single transmission mode
Definition: wifi-mode.h:48
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:177
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:114
hold a list of per-remote-station state.
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
bool GetVhtSupported(void) const
Return whether the device has VHT capability support enabled.
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
bool GetUseNonErpProtection(void) const
Return whether the device supports protection of non-ERP stations.
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether non-ERP mode associated with the specified station at the specified index.
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PHY preambles.
bool GetHeSupported(void) const
Return whether the device has HE capability support enabled.
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index.
bool GetHtSupported(void) const
Return whether the device has HT 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:67
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:42
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:45
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:230
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:218
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#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:45
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.
hold per-remote-station state for AARF Wifi manager.
uint32_t m_timerTimeout
timer timeout
uint32_t m_successThreshold
success threshold
hold per-remote-station state.