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_timerTimeout;
45  uint32_t m_successThreshold;
46  uint8_t m_rate;
47 };
48 
50 
51 TypeId
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 
102 void
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 
137 void
139 {
140  NS_LOG_FUNCTION (this << station);
141 }
153 void
155 {
156  NS_LOG_FUNCTION (this << 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 
199 void
201  double rxSnr, WifiMode txMode)
202 {
203  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
204 }
205 
206 void
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 
214 void
216  double ackSnr, WifiMode ackMode, double dataSnr)
217 {
218  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
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 
237 void
239 {
240  NS_LOG_FUNCTION (this << station);
241 }
242 
243 void
245 {
246  NS_LOG_FUNCTION (this << station);
247 }
248 
251 {
252  NS_LOG_FUNCTION (this << 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  if (m_currentRate != mode.GetDataRate (channelWidth))
261  {
262  NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (channelWidth));
263  m_currentRate = mode.GetDataRate (channelWidth);
264  }
265  return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode.GetModulationClass (), GetShortPreambleEnabled (), UseGreenfieldForDestination (GetAddress (station))), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
266 }
267 
270 {
271  NS_LOG_FUNCTION (this << st);
275  uint16_t channelWidth = GetChannelWidth (station);
276  if (channelWidth > 20 && channelWidth != 22)
277  {
278  channelWidth = 20;
279  }
280  WifiTxVector rtsTxVector;
281  WifiMode mode;
282  if (GetUseNonErpProtection () == false)
283  {
284  mode = GetSupported (station, 0);
285  }
286  else
287  {
288  mode = GetNonErpSupported (station, 0);
289  }
290  rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode.GetModulationClass (), GetShortPreambleEnabled (), UseGreenfieldForDestination (GetAddress (station))), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
291  return rtsTxVector;
292 }
293 
294 bool
296 {
297  return true;
298 }
299 
300 } //namespace ns3
uint32_t m_minSuccessThreshold
minimum success threshold
bool GetVhtSupported(void) const
Return whether the device has VHT capability support enabled.
#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.
bool GetHeSupported(void) const
Return whether the device has HE capability support enabled.
#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:204
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
bool IsLowLatency(void) const
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble, bool useGreenfield)
Return the preamble to be used for the transmission.
Definition: wifi-utils.cc:128
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 DoInitialize(void)
Initialize() implementation.
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.
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PLCP preambles.
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
bool GetHtSupported(void) const
Return whether the device has HT capability support enabled.
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.
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:494
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.
bool UseGreenfieldForDestination(Mac48Address dest) const
double m_timerK
Multiplication factor for the timer threshold.
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
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:272
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
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:150
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station)
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.