A Discrete-Event Network Simulator
API
arf-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 "arf-wifi-manager.h"
22 #include "ns3/log.h"
23 #include "ns3/uinteger.h"
24 
25 #define Min(a,b) ((a < b) ? a : b)
26 
27 namespace ns3 {
28 
29 NS_LOG_COMPONENT_DEFINE ("ArfWifiManager");
30 
38 {
39  uint32_t m_timer;
40  uint32_t m_success;
41  uint32_t m_failed;
42  bool m_recovery;
43  uint32_t m_retry;
44  uint32_t m_timerTimeout;
45  uint32_t m_successThreshold;
46  uint32_t m_rate;
47 };
48 
50 
51 TypeId
53 {
54  static TypeId tid = TypeId ("ns3::ArfWifiManager")
56  .SetGroupName ("Wifi")
57  .AddConstructor<ArfWifiManager> ()
58  .AddAttribute ("TimerThreshold", "The 'timer' threshold in the ARF algorithm.",
59  UintegerValue (15),
61  MakeUintegerChecker<uint32_t> ())
62  .AddAttribute ("SuccessThreshold",
63  "The minimum number of sucessfull transmissions to try a new rate.",
64  UintegerValue (10),
66  MakeUintegerChecker<uint32_t> ())
67  .AddTraceSource ("Rate",
68  "Traced value for rate changes (b/s)",
70  "ns3::TracedValueCallback::Uint64")
71  ;
72  return tid;
73 }
74 
77  m_currentRate (0)
78 {
79  NS_LOG_FUNCTION (this);
80 }
81 
83 {
84  NS_LOG_FUNCTION (this);
85 }
86 
89 {
90  NS_LOG_FUNCTION (this);
92 
95  station->m_rate = 0;
96  station->m_success = 0;
97  station->m_failed = 0;
98  station->m_recovery = false;
99  station->m_retry = 0;
100  station->m_timer = 0;
101 
102  return station;
103 }
104 
105 void
107 {
108  NS_LOG_FUNCTION (this << station);
109 }
121 void
123 {
124  NS_LOG_FUNCTION (this << st);
126  station->m_timer++;
127  station->m_failed++;
128  station->m_retry++;
129  station->m_success = 0;
130 
131  if (station->m_recovery)
132  {
133  NS_ASSERT (station->m_retry >= 1);
134  if (station->m_retry == 1)
135  {
136  //need recovery fallback
137  if (station->m_rate != 0)
138  {
139  station->m_rate--;
140  }
141  }
142  station->m_timer = 0;
143  }
144  else
145  {
146  NS_ASSERT (station->m_retry >= 1);
147  if (((station->m_retry - 1) % 2) == 1)
148  {
149  //need normal fallback
150  if (station->m_rate != 0)
151  {
152  station->m_rate--;
153  }
154  }
155  if (station->m_retry >= 2)
156  {
157  station->m_timer = 0;
158  }
159  }
160 }
161 
162 void
164  double rxSnr, WifiMode txMode)
165 {
166  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
167 }
168 
170  double ctsSnr, WifiMode ctsMode, double rtsSnr)
171 {
172  NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
173  NS_LOG_DEBUG ("station=" << station << " rts ok");
174 }
175 
177  double ackSnr, WifiMode ackMode, double dataSnr)
178 {
179  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
180  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
181  station->m_timer++;
182  station->m_success++;
183  station->m_failed = 0;
184  station->m_recovery = false;
185  station->m_retry = 0;
186  NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
187  if ((station->m_success == m_successThreshold
188  || station->m_timer == m_timerThreshold)
189  && (station->m_rate < (station->m_state->m_operationalRateSet.size () - 1)))
190  {
191  NS_LOG_DEBUG ("station=" << station << " inc rate");
192  station->m_rate++;
193  station->m_timer = 0;
194  station->m_success = 0;
195  station->m_recovery = true;
196  }
197 }
198 
199 void
201 {
202  NS_LOG_FUNCTION (this << station);
203 }
204 
205 void
207 {
208  NS_LOG_FUNCTION (this << station);
209 }
210 
213 {
214  NS_LOG_FUNCTION (this << st);
215  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
216  uint32_t channelWidth = GetChannelWidth (station);
217  if (channelWidth > 20 && channelWidth != 22)
218  {
219  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
220  channelWidth = 20;
221  }
222  WifiMode mode = GetSupported (station, station->m_rate);
223  if (m_currentRate != mode.GetDataRate (channelWidth))
224  {
225  NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (channelWidth));
226  m_currentRate = mode.GetDataRate (channelWidth);
227  }
228  return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
229 }
230 
233 {
234  NS_LOG_FUNCTION (this << st);
237  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
238  uint32_t channelWidth = GetChannelWidth (station);
239  if (channelWidth > 20 && channelWidth != 22)
240  {
241  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
242  channelWidth = 20;
243  }
244  WifiTxVector rtsTxVector;
245  WifiMode mode;
246  if (GetUseNonErpProtection () == false)
247  {
248  mode = GetSupported (station, 0);
249  }
250  else
251  {
252  mode = GetNonErpSupported (station, 0);
253  }
254  rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
255  return rtsTxVector;
256 }
257 
258 bool
260 {
261  NS_LOG_FUNCTION (this);
262  return true;
263 }
264 
265 void
267 {
268  //HT is not supported by this algorithm.
269  if (enable)
270  {
271  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HT rates");
272  }
273 }
274 
275 void
277 {
278  //VHT is not supported by this algorithm.
279  if (enable)
280  {
281  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support VHT rates");
282  }
283 }
284 
285 void
287 {
288  //HE is not supported by this algorithm.
289  if (enable)
290  {
291  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rates");
292  }
293 }
294 
295 } //namespace ns3
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
WifiRemoteStation * DoCreateStation(void) const
uint32_t m_retry
retry count
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint32_t m_timerThreshold
timer threshold
#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.
void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
#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
void SetHeSupported(bool enable)
Enable or disable HE capability support.
uint32_t m_success
success count
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
uint32_t m_timerTimeout
timer timeout
hold per-remote-station state for ARF Wifi manager.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
Return whether mode associated with the specified station at the specified index. ...
static TypeId GetTypeId(void)
Get the type ID.
WifiRemoteStationState * m_state
Remote station state.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
bool IsLowLatency(void) const
void DoReportFinalDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
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.
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...
WifiPreamble GetPreambleForTransmission(WifiMode mode, Mac48Address dest)
Return the preamble to be used for the transmission.
uint64_t GetDataRate(uint8_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:143
uint8_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
uint32_t m_successThreshold
success threshold
Mac48Address GetAddress(const WifiRemoteStation *station) const
Return the address of the station.
hold a list of per-remote-station state.
void DoReportDataFailed(WifiRemoteStation *station)
It is important to realize that "recovery" mode starts after failure of the first transmission after ...
TracedValue< uint64_t > m_currentRate
Trace rate changes.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t m_failed
failed count
WifiModeList m_operationalRateSet
This member is the list of WifiMode objects that comprise the OperationalRateSet parameter for this r...
void SetVhtSupported(bool enable)
Enable or disable VHT capability support.
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
This method is a pure virtual method that must be implemented by the sub-class.
ARF Rate control algorithm.
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
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:269
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station)
void DoReportFinalRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
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.
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 SetHtSupported(bool enable)
Enable or disable HT capability support.
uint32_t m_timer
timer value
uint32_t m_successThreshold
success threshold