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 
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);
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 
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 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 
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);
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  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 ()), 800, 1, 1, 0, channelWidth, GetAggregation (station));
266 }
267 
270 {
271  NS_LOG_FUNCTION (this << st);
274  AarfWifiRemoteStation *station = static_cast<AarfWifiRemoteStation*> (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 ()), 800, 1, 1, 0, channelWidth, GetAggregation (station));
291  return rtsTxVector;
292 }
293 
294 } //namespace ns3
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::WifiRemoteStationManager::GetDefaultTxPowerLevel
uint8_t GetDefaultTxPowerLevel(void) const
Definition: wifi-remote-station-manager.cc:1206
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
NS_ASSERT
#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
ns3::AarfWifiManager::DoReportFinalRtsFailed
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: aarf-wifi-manager.cc:238
ns3::AarfWifiRemoteStation::m_success
uint32_t m_success
success
Definition: aarf-wifi-manager.cc:41
ns3::WifiRemoteStationManager::GetUseNonErpProtection
bool GetUseNonErpProtection(void) const
Return whether the device supports protection of non-ERP stations.
Definition: wifi-remote-station-manager.cc:1051
ns3::AarfWifiRemoteStation::m_failed
uint32_t m_failed
failed
Definition: aarf-wifi-manager.cc:42
ns3::AarfWifiManager::m_maxSuccessThreshold
uint32_t m_maxSuccessThreshold
maximum success threshold
Definition: aarf-wifi-manager.h:73
aarf-wifi-manager.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WifiRemoteStationManager::GetSupported
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index.
Definition: wifi-remote-station-manager.cc:1635
ns3::AarfWifiManager::DoInitialize
void DoInitialize(void) override
Initialize() implementation.
Definition: aarf-wifi-manager.cc:103
ns3::WifiMode::GetModulationClass
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:159
ns3::AarfWifiManager::DoReportRtsOk
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.
Definition: aarf-wifi-manager.cc:207
ns3::WifiRemoteStationManager
hold a list of per-remote-station state.
Definition: wifi-remote-station-manager.h:121
ns3::WifiRemoteStationManager::GetHtSupported
bool GetHtSupported(void) const
Return whether the device has HT capability support enabled.
Definition: wifi-remote-station-manager.cc:232
ns3::AarfWifiRemoteStation::m_timer
uint32_t m_timer
timer
Definition: aarf-wifi-manager.cc:40
ns3::WifiRemoteStationManager::GetVhtSupported
bool GetVhtSupported(void) const
Return whether the device has VHT capability support enabled.
Definition: wifi-remote-station-manager.cc:244
ns3::WifiRemoteStationManager::GetNSupported
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
Definition: wifi-remote-station-manager.cc:1743
ns3::WifiTxVector
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition: wifi-tx-vector.h:71
ns3::Min
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:218
ns3::AarfWifiManager::DoReportRtsFailed
void DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: aarf-wifi-manager.cc:138
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
ns3::WifiRemoteStationManager::GetShortPreambleEnabled
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PHY preambles.
Definition: wifi-remote-station-manager.cc:226
ns3::MakeTraceSourceAccessor
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Definition: trace-source-accessor.h:202
ns3::AarfWifiManager::DoReportRxOk
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: aarf-wifi-manager.cc:200
ns3::AarfWifiManager::m_minTimerThreshold
uint32_t m_minTimerThreshold
minimum timer threshold
Definition: aarf-wifi-manager.h:70
ns3::AarfWifiManager::DoReportFinalDataFailed
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: aarf-wifi-manager.cc:244
ns3::AarfWifiManager::m_successK
double m_successK
Multiplication factor for the success threshold.
Definition: aarf-wifi-manager.h:72
ns3::AarfWifiManager::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: aarf-wifi-manager.cc:52
ns3::Max
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:230
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
ns3::AarfWifiManager::DoReportDataFailed
void DoReportDataFailed(WifiRemoteStation *station) override
It is important to realize that "recovery" mode starts after failure of the first transmission after ...
Definition: aarf-wifi-manager.cc:154
ns3::WifiMode
represent a single transmission mode
Definition: wifi-mode.h:48
ns3::AarfWifiManager::m_timerK
double m_timerK
Multiplication factor for the timer threshold.
Definition: aarf-wifi-manager.h:74
ns3::AarfWifiManager::~AarfWifiManager
virtual ~AarfWifiManager()
Definition: aarf-wifi-manager.cc:97
ns3::MakeDoubleAccessor
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
ns3::GetPreambleForTransmission
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
Definition: wifi-phy-common.cc:87
ns3::AarfWifiRemoteStation::m_successThreshold
uint32_t m_successThreshold
success threshold
Definition: aarf-wifi-manager.cc:45
ns3::WifiRemoteStation
hold per-remote-station state.
Definition: wifi-remote-station-manager.h:62
ns3::AarfWifiManager::DoCreateStation
WifiRemoteStation * DoCreateStation(void) const override
Definition: aarf-wifi-manager.cc:121
ns3::AarfWifiRemoteStation
hold per-remote-station state for AARF Wifi manager.
Definition: aarf-wifi-manager.cc:39
ns3::AarfWifiRemoteStation::m_timerTimeout
uint32_t m_timerTimeout
timer timeout
Definition: aarf-wifi-manager.cc:44
ns3::WifiRemoteStationManager::GetAggregation
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
Definition: wifi-remote-station-manager.cc:1707
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
ns3::AarfWifiManager::AarfWifiManager
AarfWifiManager()
Definition: aarf-wifi-manager.cc:90
ns3::WifiRemoteStationManager::GetNonErpSupported
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether non-ERP mode associated with the specified station at the specified index.
Definition: wifi-remote-station-manager.cc:1649
ns3::AarfWifiManager::DoGetRtsTxVector
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
Definition: aarf-wifi-manager.cc:269
ns3::AarfWifiManager::DoReportDataOk
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.
Definition: aarf-wifi-manager.cc:215
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::AarfWifiManager
AARF Rate control algorithm.
Definition: aarf-wifi-manager.h:43
ns3::AarfWifiManager::m_minSuccessThreshold
uint32_t m_minSuccessThreshold
minimum success threshold
Definition: aarf-wifi-manager.h:71
ns3::AarfWifiRemoteStation::m_recovery
bool m_recovery
recovery
Definition: aarf-wifi-manager.cc:43
ns3::AarfWifiRemoteStation::m_rate
uint8_t m_rate
rate
Definition: aarf-wifi-manager.cc:46
ns3::UintegerValue
Hold an unsigned integer type.
Definition: uinteger.h:44
ns3::AarfWifiManager::m_currentRate
TracedValue< uint64_t > m_currentRate
Trace rate changes.
Definition: aarf-wifi-manager.h:76
ns3::WifiRemoteStationManager::GetChannelWidth
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
Definition: wifi-remote-station-manager.cc:1683
ns3::WifiMode::GetDataRate
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:100
ns3::MakeUintegerAccessor
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
ns3::AarfWifiManager::DoGetDataTxVector
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station) override
Definition: aarf-wifi-manager.cc:250
ns3::WifiRemoteStationManager::GetHeSupported
bool GetHeSupported(void) const
Return whether the device has HE capability support enabled.
Definition: wifi-remote-station-manager.cc:256