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/assert.h"
23 #include "ns3/log.h"
24 #include "ns3/uinteger.h"
25 
26 #define Min(a,b) ((a < b) ? a : b)
27 
28 namespace ns3 {
29 
30 NS_LOG_COMPONENT_DEFINE ("ArfWifiManager");
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_retry;
45  uint32_t m_timerTimeout;
47  uint32_t m_rate;
48 };
49 
51 
52 TypeId
54 {
55  static TypeId tid = TypeId ("ns3::ArfWifiManager")
57  .SetGroupName ("Wifi")
58  .AddConstructor<ArfWifiManager> ()
59  .AddAttribute ("TimerThreshold", "The 'timer' threshold in the ARF algorithm.",
60  UintegerValue (15),
62  MakeUintegerChecker<uint32_t> ())
63  .AddAttribute ("SuccessThreshold",
64  "The minimum number of sucessfull transmissions to try a new rate.",
65  UintegerValue (10),
67  MakeUintegerChecker<uint32_t> ())
68  ;
69  return tid;
70 }
71 
73 {
74  NS_LOG_FUNCTION (this);
75 }
76 
78 {
79  NS_LOG_FUNCTION (this);
80 }
81 
84 {
85  NS_LOG_FUNCTION (this);
87 
90  station->m_rate = 0;
91  station->m_success = 0;
92  station->m_failed = 0;
93  station->m_recovery = false;
94  station->m_retry = 0;
95  station->m_timer = 0;
96 
97  return station;
98 }
99 
100 void
102 {
103  NS_LOG_FUNCTION (this << station);
104 }
116 void
118 {
119  NS_LOG_FUNCTION (this << st);
121  station->m_timer++;
122  station->m_failed++;
123  station->m_retry++;
124  station->m_success = 0;
125 
126  if (station->m_recovery)
127  {
128  NS_ASSERT (station->m_retry >= 1);
129  if (station->m_retry == 1)
130  {
131  //need recovery fallback
132  if (station->m_rate != 0)
133  {
134  station->m_rate--;
135  }
136  }
137  station->m_timer = 0;
138  }
139  else
140  {
141  NS_ASSERT (station->m_retry >= 1);
142  if (((station->m_retry - 1) % 2) == 1)
143  {
144  //need normal fallback
145  if (station->m_rate != 0)
146  {
147  station->m_rate--;
148  }
149  }
150  if (station->m_retry >= 2)
151  {
152  station->m_timer = 0;
153  }
154  }
155 }
156 
157 void
159  double rxSnr, WifiMode txMode)
160 {
161  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
162 }
163 
165  double ctsSnr, WifiMode ctsMode, double rtsSnr)
166 {
167  NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
168  NS_LOG_DEBUG ("station=" << station << " rts ok");
169 }
170 
172  double ackSnr, WifiMode ackMode, double dataSnr)
173 {
174  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
175  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
176  station->m_timer++;
177  station->m_success++;
178  station->m_failed = 0;
179  station->m_recovery = false;
180  station->m_retry = 0;
181  NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
182  if ((station->m_success == m_successThreshold
183  || station->m_timer == m_timerThreshold)
184  && (station->m_rate < (station->m_state->m_operationalRateSet.size () - 1)))
185  {
186  NS_LOG_DEBUG ("station=" << station << " inc rate");
187  station->m_rate++;
188  station->m_timer = 0;
189  station->m_success = 0;
190  station->m_recovery = true;
191  }
192 }
193 
194 void
196 {
197  NS_LOG_FUNCTION (this << station);
198 }
199 
200 void
202 {
203  NS_LOG_FUNCTION (this << station);
204 }
205 
208 {
209  NS_LOG_FUNCTION (this << st);
210  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
211  uint32_t channelWidth = GetChannelWidth (station);
212  if (channelWidth > 20 && channelWidth != 22)
213  {
214  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
215  channelWidth = 20;
216  }
217  return WifiTxVector (GetSupported (station, station->m_rate), GetDefaultTxPowerLevel (), GetLongRetryCount (station), false, 1, 1, channelWidth, GetAggregation (station), false);
218 }
219 
222 {
223  NS_LOG_FUNCTION (this << st);
226  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
227  uint32_t channelWidth = GetChannelWidth (station);
228  if (channelWidth > 20 && channelWidth != 22)
229  {
230  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
231  channelWidth = 20;
232  }
233  WifiTxVector rtsTxVector;
234  if (GetUseNonErpProtection () == false)
235  {
236  rtsTxVector = WifiTxVector (GetSupported (station, 0), GetDefaultTxPowerLevel (), GetLongRetryCount (station), false, 1, 0, channelWidth, GetAggregation (station), false);
237  }
238  else
239  {
240  rtsTxVector = WifiTxVector (GetNonErpSupported (station, 0), GetDefaultTxPowerLevel (), GetLongRetryCount (station), false, 1, 0, channelWidth, GetAggregation (station), false);
241  }
242  return rtsTxVector;
243 }
244 
245 bool
247 {
248  NS_LOG_FUNCTION (this);
249  return true;
250 }
251 
252 void
254 {
255  //HT is not supported by this algorithm.
256  if (enable)
257  {
258  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HT rates");
259  }
260 }
261 
262 void
264 {
265  //VHT is not supported by this algorithm.
266  if (enable)
267  {
268  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support VHT rates");
269  }
270 }
271 
272 } //namespace ns3
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual WifiRemoteStation * DoCreateStation(void) const
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.
virtual 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
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
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:99
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)
WifiRemoteStationState * m_state
Remote station state.
virtual bool IsLowLatency(void) const
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
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.
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...
hold a list of per-remote-station state.
virtual void DoReportDataFailed(WifiRemoteStation *station)
It is important to realize that "recovery" mode starts after failure of the first transmission after ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiModeList m_operationalRateSet
This member is the list of WifiMode objects that comprise the OperationalRateSet parameter for this r...
virtual void SetVhtSupported(bool enable)
Enable or disable VHT capability support.
virtual 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.
virtual 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:236
uint32_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station)
virtual 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.
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 SetHtSupported(bool enable)
Enable or disable HT capability support.