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 "ns3/log.h"
22 #include "arf-wifi-manager.h"
23 #include "wifi-tx-vector.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  uint8_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 successful 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 }
110 
122 void
124 {
125  NS_LOG_FUNCTION (this << st);
127  station->m_timer++;
128  station->m_failed++;
129  station->m_retry++;
130  station->m_success = 0;
131 
132  if (station->m_recovery)
133  {
134  NS_ASSERT (station->m_retry >= 1);
135  if (station->m_retry == 1)
136  {
137  //need recovery fallback
138  if (station->m_rate != 0)
139  {
140  station->m_rate--;
141  }
142  }
143  station->m_timer = 0;
144  }
145  else
146  {
147  NS_ASSERT (station->m_retry >= 1);
148  if (((station->m_retry - 1) % 2) == 1)
149  {
150  //need normal fallback
151  if (station->m_rate != 0)
152  {
153  station->m_rate--;
154  }
155  }
156  if (station->m_retry >= 2)
157  {
158  station->m_timer = 0;
159  }
160  }
161 }
162 
163 void
165  double rxSnr, WifiMode txMode)
166 {
167  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
168 }
169 
171  double ctsSnr, WifiMode ctsMode, double rtsSnr)
172 {
173  NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
174  NS_LOG_DEBUG ("station=" << station << " rts ok");
175 }
176 
178  double ackSnr, WifiMode ackMode, double dataSnr)
179 {
180  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
181  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
182  station->m_timer++;
183  station->m_success++;
184  station->m_failed = 0;
185  station->m_recovery = false;
186  station->m_retry = 0;
187  NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
188  if ((station->m_success == m_successThreshold
189  || station->m_timer == m_timerThreshold)
190  && (station->m_rate < (station->m_state->m_operationalRateSet.size () - 1)))
191  {
192  NS_LOG_DEBUG ("station=" << station << " inc rate");
193  station->m_rate++;
194  station->m_timer = 0;
195  station->m_success = 0;
196  station->m_recovery = true;
197  }
198 }
199 
200 void
202 {
203  NS_LOG_FUNCTION (this << station);
204 }
205 
206 void
208 {
209  NS_LOG_FUNCTION (this << station);
210 }
211 
214 {
215  NS_LOG_FUNCTION (this << st);
216  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
217  uint16_t channelWidth = GetChannelWidth (station);
218  if (channelWidth > 20 && channelWidth != 22)
219  {
220  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
221  channelWidth = 20;
222  }
223  WifiMode mode = GetSupported (station, station->m_rate);
224  if (m_currentRate != mode.GetDataRate (channelWidth))
225  {
226  NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (channelWidth));
227  m_currentRate = mode.GetDataRate (channelWidth);
228  }
229  return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
230 }
231 
234 {
235  NS_LOG_FUNCTION (this << st);
238  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
239  uint16_t channelWidth = GetChannelWidth (station);
240  if (channelWidth > 20 && channelWidth != 22)
241  {
242  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
243  channelWidth = 20;
244  }
245  WifiTxVector rtsTxVector;
246  WifiMode mode;
247  if (GetUseNonErpProtection () == false)
248  {
249  mode = GetSupported (station, 0);
250  }
251  else
252  {
253  mode = GetNonErpSupported (station, 0);
254  }
255  rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
256  return rtsTxVector;
257 }
258 
259 bool
261 {
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 "...
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:45
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:202
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
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index. ...
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
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.
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
WifiPreamble GetPreambleForTransmission(WifiMode mode, Mac48Address dest)
Return the preamble to be used for the transmission.
uint32_t m_successThreshold
success threshold
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...
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...
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)
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
bool IsLowLatency(void) const
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
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:915
hold per-remote-station state.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:156
WifiRemoteStation * DoCreateStation(void) const
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
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.