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 "wifi-tx-vector.h"
24 
25 #define Min(a,b) ((a < b) ? a : b)
26 #define Max(a,b) ((a > b) ? a : b)
27 
28 namespace ns3 {
29 
30 NS_LOG_COMPONENT_DEFINE ("AarfWifiManager");
31 
39 {
40  uint32_t m_timer;
41  uint32_t m_success;
42  uint32_t m_failed;
43  bool m_recovery;
44  uint32_t m_retry;
45  uint32_t m_timerTimeout;
46  uint32_t m_successThreshold;
47  uint8_t m_rate;
48 };
49 
51 
52 TypeId
54 {
55  static TypeId tid = TypeId ("ns3::AarfWifiManager")
57  .SetGroupName ("Wifi")
58  .AddConstructor<AarfWifiManager> ()
59  .AddAttribute ("SuccessK", "Multiplication factor for the success threshold in the AARF algorithm.",
60  DoubleValue (2.0),
62  MakeDoubleChecker<double> ())
63  .AddAttribute ("TimerK",
64  "Multiplication factor for the timer threshold in the AARF algorithm.",
65  DoubleValue (2.0),
67  MakeDoubleChecker<double> ())
68  .AddAttribute ("MaxSuccessThreshold",
69  "Maximum value of the success threshold in the AARF algorithm.",
70  UintegerValue (60),
72  MakeUintegerChecker<uint32_t> ())
73  .AddAttribute ("MinTimerThreshold",
74  "The minimum value for the 'timer' threshold in the AARF algorithm.",
75  UintegerValue (15),
77  MakeUintegerChecker<uint32_t> ())
78  .AddAttribute ("MinSuccessThreshold",
79  "The minimum value for the success threshold in the AARF algorithm.",
80  UintegerValue (10),
82  MakeUintegerChecker<uint32_t> ())
83  .AddTraceSource ("Rate",
84  "Traced value for rate changes (b/s)",
86  "ns3::TracedValueCallback::Uint64")
87  ;
88  return tid;
89 }
90 
93  m_currentRate (0)
94 {
95  NS_LOG_FUNCTION (this);
96 }
97 
99 {
100  NS_LOG_FUNCTION (this);
101 }
102 
105 {
106  NS_LOG_FUNCTION (this);
108 
111  station->m_rate = 0;
112  station->m_success = 0;
113  station->m_failed = 0;
114  station->m_recovery = false;
115  station->m_retry = 0;
116  station->m_timer = 0;
117 
118  return station;
119 }
120 
121 void
123 {
124  NS_LOG_FUNCTION (this << station);
125 }
137 void
139 {
140  NS_LOG_FUNCTION (this << st);
142  station->m_timer++;
143  station->m_failed++;
144  station->m_retry++;
145  station->m_success = 0;
146 
147  if (station->m_recovery)
148  {
149  NS_ASSERT (station->m_retry >= 1);
150  if (station->m_retry == 1)
151  {
152  //need recovery fallback
153  station->m_successThreshold = (int)(Min (station->m_successThreshold * m_successK,
155  station->m_timerTimeout = (int)(Max (station->m_timerTimeout * m_timerK,
157  if (station->m_rate != 0)
158  {
159  station->m_rate--;
160  }
161  }
162  station->m_timer = 0;
163  }
164  else
165  {
166  NS_ASSERT (station->m_retry >= 1);
167  if (((station->m_retry - 1) % 2) == 1)
168  {
169  //need normal fallback
172  if (station->m_rate != 0)
173  {
174  station->m_rate--;
175  }
176  }
177  if (station->m_retry >= 2)
178  {
179  station->m_timer = 0;
180  }
181  }
182 }
183 
184 void
186  double rxSnr, WifiMode txMode)
187 {
188  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
189 }
190 
191 void
193  double ctsSnr, WifiMode ctsMode, double rtsSnr)
194 {
195  NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
196  NS_LOG_DEBUG ("station=" << station << " rts ok");
197 }
198 
199 void
201  double ackSnr, WifiMode ackMode, double dataSnr)
202 {
203  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
205  station->m_timer++;
206  station->m_success++;
207  station->m_failed = 0;
208  station->m_recovery = false;
209  station->m_retry = 0;
210  NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
211  if ((station->m_success == station->m_successThreshold
212  || station->m_timer == station->m_timerTimeout)
213  && (station->m_rate < (GetNSupported (station) - 1)))
214  {
215  NS_LOG_DEBUG ("station=" << station << " inc rate");
216  station->m_rate++;
217  station->m_timer = 0;
218  station->m_success = 0;
219  station->m_recovery = true;
220  }
221 }
222 
223 void
225 {
226  NS_LOG_FUNCTION (this << station);
227 }
228 
229 void
231 {
232  NS_LOG_FUNCTION (this << station);
233 }
234 
237 {
238  NS_LOG_FUNCTION (this << st);
240  uint16_t channelWidth = GetChannelWidth (station);
241  if (channelWidth > 20 && channelWidth != 22)
242  {
243  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
244  channelWidth = 20;
245  }
246  WifiMode mode = GetSupported (station, station->m_rate);
247  if (m_currentRate != mode.GetDataRate (channelWidth))
248  {
249  NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (channelWidth));
250  m_currentRate = mode.GetDataRate (channelWidth);
251  }
252  return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
253 }
254 
257 {
258  NS_LOG_FUNCTION (this << st);
262  uint16_t channelWidth = GetChannelWidth (station);
263  if (channelWidth > 20 && channelWidth != 22)
264  {
265  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
266  channelWidth = 20;
267  }
268  WifiTxVector rtsTxVector;
269  WifiMode mode;
270  if (GetUseNonErpProtection () == false)
271  {
272  mode = GetSupported (station, 0);
273  }
274  else
275  {
276  mode = GetNonErpSupported (station, 0);
277  }
278  rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
279  return rtsTxVector;
280 }
281 
282 bool
284 {
285  return true;
286 }
287 
288 void
290 {
291  //HT is not supported by this algorithm.
292  if (enable)
293  {
294  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HT rates");
295  }
296 }
297 
298 void
300 {
301  //VHT is not supported by this algorithm.
302  if (enable)
303  {
304  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support VHT rates");
305  }
306 }
307 
308 void
310 {
311  //HE is not supported by this algorithm.
312  if (enable)
313  {
314  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rates");
315  }
316 }
317 
318 } //namespace ns3
uint32_t m_minSuccessThreshold
minimum success threshold
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
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...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
double m_successK
Multiplication factor for the success threshold.
#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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
bool IsLowLatency(void) const
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index. ...
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
void DoReportDataFailed(WifiRemoteStation *station)
It is important to realize that "recovery" mode starts after failure of the first transmission after ...
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
This method is a pure virtual method that must be implemented by the sub-class.
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)
This method is a pure virtual method that must be implemented by the sub-class.
void DoReportFinalDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:197
WifiRemoteStation * DoCreateStation(void) const
void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
Hold an unsigned integer type.
Definition: uinteger.h:44
WifiPreamble GetPreambleForTransmission(WifiMode mode, Mac48Address dest)
Return the preamble to be used for the transmission.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:209
uint32_t m_minTimerThreshold
minimum timer threshold
hold a list of per-remote-station state.
AARF Rate control algorithmThis class implements the AARF rate control algorithm which was initially ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double m_timerK
Multiplication factor for the timer threshold.
void SetHtSupported(bool enable)
Enable or disable HT capability support.
Mac48Address GetAddress(const WifiRemoteStation *station) const
Return the address of the station.
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether non-ERP mode associated with the specified station at the specified index...
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
uint32_t m_successThreshold
success threshold
void SetHeSupported(bool enable)
Enable or disable HE capability support.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
hold per-remote-station state for AARF Wifi manager.
void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)
This method is a pure virtual method that must be implemented by the sub-class.
bool GetUseNonErpProtection(void) const
Return whether the device supports protection of non-ERP stations.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:270
TracedValue< uint64_t > m_currentRate
Trace rate changes.
void DoReportFinalRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
uint32_t m_timerTimeout
timer timeout
void SetVhtSupported(bool enable)
Enable or disable VHT capability support.
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
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:45
a unique identifier for an interface.
Definition: type-id.h:58
uint32_t m_maxSuccessThreshold
maximum success threshold
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
hold per-remote-station state.
static TypeId GetTypeId(void)
Get the type ID.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:156
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station)
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.