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 "aarf-wifi-manager.h"
22 #include "ns3/double.h"
23 #include "ns3/uinteger.h"
24 #include "ns3/log.h"
25 
26 #define Min(a,b) ((a < b) ? a : b)
27 #define Max(a,b) ((a > b) ? a : b)
28 
29 namespace ns3 {
30 
31 NS_LOG_COMPONENT_DEFINE ("AarfWifiManager");
32 
40 {
41  uint32_t m_timer;
42  uint32_t m_success;
43  uint32_t m_failed;
44  bool m_recovery;
45  uint32_t m_retry;
46  uint32_t m_timerTimeout;
48  uint32_t m_rate;
49 };
50 
52 
53 TypeId
55 {
56  static TypeId tid = TypeId ("ns3::AarfWifiManager")
58  .SetGroupName ("Wifi")
59  .AddConstructor<AarfWifiManager> ()
60  .AddAttribute ("SuccessK", "Multiplication factor for the success threshold in the AARF algorithm.",
61  DoubleValue (2.0),
63  MakeDoubleChecker<double> ())
64  .AddAttribute ("TimerK",
65  "Multiplication factor for the timer threshold in the AARF algorithm.",
66  DoubleValue (2.0),
68  MakeDoubleChecker<double> ())
69  .AddAttribute ("MaxSuccessThreshold",
70  "Maximum value of the success threshold in the AARF algorithm.",
71  UintegerValue (60),
73  MakeUintegerChecker<uint32_t> ())
74  .AddAttribute ("MinTimerThreshold",
75  "The minimum value for the 'timer' threshold in the AARF algorithm.",
76  UintegerValue (15),
78  MakeUintegerChecker<uint32_t> ())
79  .AddAttribute ("MinSuccessThreshold",
80  "The minimum value for the success threshold in the AARF algorithm.",
81  UintegerValue (10),
83  MakeUintegerChecker<uint32_t> ())
84  ;
85  return tid;
86 }
87 
89 {
90  NS_LOG_FUNCTION (this);
91 }
92 
94 {
95  NS_LOG_FUNCTION (this);
96 }
97 
100 {
101  NS_LOG_FUNCTION (this);
103 
106  station->m_rate = 0;
107  station->m_success = 0;
108  station->m_failed = 0;
109  station->m_recovery = false;
110  station->m_retry = 0;
111  station->m_timer = 0;
112 
113  return station;
114 }
115 
116 void
118 {
119  NS_LOG_FUNCTION (this << station);
120 }
132 void
134 {
135  NS_LOG_FUNCTION (this << st);
137  station->m_timer++;
138  station->m_failed++;
139  station->m_retry++;
140  station->m_success = 0;
141 
142  if (station->m_recovery)
143  {
144  NS_ASSERT (station->m_retry >= 1);
145  if (station->m_retry == 1)
146  {
147  //need recovery fallback
148  station->m_successThreshold = (int)(Min (station->m_successThreshold * m_successK,
150  station->m_timerTimeout = (int)(Max (station->m_timerTimeout * m_timerK,
152  if (station->m_rate != 0)
153  {
154  station->m_rate--;
155  }
156  }
157  station->m_timer = 0;
158  }
159  else
160  {
161  NS_ASSERT (station->m_retry >= 1);
162  if (((station->m_retry - 1) % 2) == 1)
163  {
164  //need normal fallback
167  if (station->m_rate != 0)
168  {
169  station->m_rate--;
170  }
171  }
172  if (station->m_retry >= 2)
173  {
174  station->m_timer = 0;
175  }
176  }
177 }
178 
179 void
181  double rxSnr, WifiMode txMode)
182 {
183  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
184 }
185 
186 void
188  double ctsSnr, WifiMode ctsMode, double rtsSnr)
189 {
190  NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
191  NS_LOG_DEBUG ("station=" << station << " rts ok");
192 }
193 
194 void
196  double ackSnr, WifiMode ackMode, double dataSnr)
197 {
198  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
200  station->m_timer++;
201  station->m_success++;
202  station->m_failed = 0;
203  station->m_recovery = false;
204  station->m_retry = 0;
205  NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
206  if ((station->m_success == station->m_successThreshold
207  || station->m_timer == station->m_timerTimeout)
208  && (station->m_rate < (GetNSupported (station) - 1)))
209  {
210  NS_LOG_DEBUG ("station=" << station << " inc rate");
211  station->m_rate++;
212  station->m_timer = 0;
213  station->m_success = 0;
214  station->m_recovery = true;
215  }
216 }
217 
218 void
220 {
221  NS_LOG_FUNCTION (this << station);
222 }
223 
224 void
226 {
227  NS_LOG_FUNCTION (this << station);
228 }
229 
232 {
233  NS_LOG_FUNCTION (this << st);
235  uint32_t channelWidth = GetChannelWidth (station);
236  if (channelWidth > 20 && channelWidth != 22)
237  {
238  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
239  channelWidth = 20;
240  }
241  return WifiTxVector (GetSupported (station, station->m_rate), GetDefaultTxPowerLevel (), GetLongRetryCount (station), false, 1, 0, channelWidth, GetAggregation (station), false);
242 }
243 
246 {
247  NS_LOG_FUNCTION (this << st);
251  uint32_t channelWidth = GetChannelWidth (station);
252  if (channelWidth > 20 && channelWidth != 22)
253  {
254  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
255  channelWidth = 20;
256  }
257  WifiTxVector rtsTxVector;
258  if (GetUseNonErpProtection () == false)
259  {
260  rtsTxVector = WifiTxVector (GetSupported (station, 0), GetDefaultTxPowerLevel (), GetLongRetryCount (station), false, 1, 0, channelWidth, GetAggregation (station), false);
261  }
262  else
263  {
264  rtsTxVector = WifiTxVector (GetNonErpSupported (station, 0), GetDefaultTxPowerLevel (), GetLongRetryCount (station), false, 1, 0, channelWidth, GetAggregation (station), false);
265  }
266  return rtsTxVector;
267 }
268 
269 bool
271 {
272  NS_LOG_FUNCTION (this);
273  return true;
274 }
275 
276 void
278 {
279  //HT is not supported by this algorithm.
280  if (enable)
281  {
282  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HT rates");
283  }
284 }
285 
286 void
288 {
289  //VHT is not supported by this algorithm.
290  if (enable)
291  {
292  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support VHT rates");
293  }
294 }
295 
296 } //namespace ns3
uint32_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
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:44
bool GetUseNonErpProtection(void) const
Return whether the device supports protection of non-ERP stations.
#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:201
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
virtual void DoReportDataFailed(WifiRemoteStation *station)
It is important to realize that "recovery" mode starts after failure of the first transmission after ...
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
This method is a pure virtual method that must be implemented by the sub-class.
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
Return whether mode associated with the specified station at the specified index. ...
virtual 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.
virtual 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
virtual 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
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint32_t i) const
Return whether non-ERP mode associated with the specified station at the specified index...
virtual bool IsLowLatency(void) const
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:209
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.
virtual void SetHtSupported(bool enable)
Enable or disable HT 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.
virtual 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.
uint32_t GetLongRetryCount(const WifiRemoteStation *station) const
Return the long retry limit of the given station.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
uint32_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
virtual void SetVhtSupported(bool enable)
Enable or disable VHT capability support.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
virtual WifiRemoteStation * DoCreateStation(void) const
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
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
hold per-remote-station state.
static TypeId GetTypeId(void)
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station)