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_timerTimeout;
44  uint32_t m_successThreshold;
45  uint8_t m_rate;
46 };
47 
49 
50 TypeId
52 {
53  static TypeId tid = TypeId ("ns3::ArfWifiManager")
55  .SetGroupName ("Wifi")
56  .AddConstructor<ArfWifiManager> ()
57  .AddAttribute ("TimerThreshold", "The 'timer' threshold in the ARF algorithm.",
58  UintegerValue (15),
60  MakeUintegerChecker<uint32_t> ())
61  .AddAttribute ("SuccessThreshold",
62  "The minimum number of successful transmissions to try a new rate.",
63  UintegerValue (10),
65  MakeUintegerChecker<uint32_t> ())
66  .AddTraceSource ("Rate",
67  "Traced value for rate changes (b/s)",
69  "ns3::TracedValueCallback::Uint64")
70  ;
71  return tid;
72 }
73 
76  m_currentRate (0)
77 {
78  NS_LOG_FUNCTION (this);
79 }
80 
82 {
83  NS_LOG_FUNCTION (this);
84 }
85 
86 void
88 {
89  NS_LOG_FUNCTION (this);
90  if (GetHtSupported ())
91  {
92  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HT rates");
93  }
94  if (GetVhtSupported ())
95  {
96  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support VHT rates");
97  }
98  if (GetHeSupported ())
99  {
100  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rates");
101  }
102 }
103 
106 {
107  NS_LOG_FUNCTION (this);
108  ArfWifiRemoteStation *station = new ArfWifiRemoteStation ();
109 
111  station->m_timerTimeout = m_timerThreshold;
112  station->m_rate = 0;
113  station->m_success = 0;
114  station->m_failed = 0;
115  station->m_recovery = false;
116  station->m_timer = 0;
117 
118  return station;
119 }
120 
121 void
123 {
124  NS_LOG_FUNCTION (this << station);
125 }
126 
138 void
140 {
141  NS_LOG_FUNCTION (this << st);
143  station->m_timer++;
144  station->m_failed++;
145  station->m_success = 0;
146 
147  if (station->m_recovery)
148  {
149  NS_ASSERT (station->m_failed >= 1);
150  if (station->m_failed == 1)
151  {
152  //need recovery fallback
153  if (station->m_rate != 0)
154  {
155  station->m_rate--;
156  }
157  }
158  station->m_timer = 0;
159  }
160  else
161  {
162  NS_ASSERT (station->m_failed >= 1);
163  if (((station->m_failed - 1) % 2) == 1)
164  {
165  //need normal fallback
166  if (station->m_rate != 0)
167  {
168  station->m_rate--;
169  }
170  }
171  if (station->m_failed >= 2)
172  {
173  station->m_timer = 0;
174  }
175  }
176 }
177 
178 void
180  double rxSnr, WifiMode txMode)
181 {
182  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
183 }
184 
186  double ctsSnr, WifiMode ctsMode, double rtsSnr)
187 {
188  NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
189  NS_LOG_DEBUG ("station=" << station << " rts ok");
190 }
191 
193  double ackSnr, WifiMode ackMode, double dataSnr)
194 {
195  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
196  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
197  station->m_timer++;
198  station->m_success++;
199  station->m_failed = 0;
200  station->m_recovery = false;
201  NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
202  if ((station->m_success == m_successThreshold
203  || station->m_timer == m_timerThreshold)
204  && (station->m_rate < (station->m_state->m_operationalRateSet.size () - 1)))
205  {
206  NS_LOG_DEBUG ("station=" << station << " inc rate");
207  station->m_rate++;
208  station->m_timer = 0;
209  station->m_success = 0;
210  station->m_recovery = true;
211  }
212 }
213 
214 void
216 {
217  NS_LOG_FUNCTION (this << station);
218 }
219 
220 void
222 {
223  NS_LOG_FUNCTION (this << station);
224 }
225 
228 {
229  NS_LOG_FUNCTION (this << st);
230  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
231  uint16_t channelWidth = GetChannelWidth (station);
232  if (channelWidth > 20 && channelWidth != 22)
233  {
234  channelWidth = 20;
235  }
236  WifiMode mode = GetSupported (station, station->m_rate);
237  if (m_currentRate != mode.GetDataRate (channelWidth))
238  {
239  NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (channelWidth));
240  m_currentRate = mode.GetDataRate (channelWidth);
241  }
242  return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode.GetModulationClass (), GetShortPreambleEnabled (), UseGreenfieldForDestination (GetAddress (station))), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
243 }
244 
247 {
248  NS_LOG_FUNCTION (this << st);
251  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
252  uint16_t channelWidth = GetChannelWidth (station);
253  if (channelWidth > 20 && channelWidth != 22)
254  {
255  channelWidth = 20;
256  }
257  WifiTxVector rtsTxVector;
258  WifiMode mode;
259  if (GetUseNonErpProtection () == false)
260  {
261  mode = GetSupported (station, 0);
262  }
263  else
264  {
265  mode = GetNonErpSupported (station, 0);
266  }
267  rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode.GetModulationClass (), GetShortPreambleEnabled (), UseGreenfieldForDestination (GetAddress (station))), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
268  return rtsTxVector;
269 }
270 
271 bool
273 {
274  return true;
275 }
276 
277 } //namespace ns3
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 "...
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 DoInitialize(void)
Initialize() implementation.
void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
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
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
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. ...
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.
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.
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
bool GetHtSupported(void) const
Return whether the device has HT capability support enabled.
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 ...
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:494
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...
bool UseGreenfieldForDestination(Mac48Address dest) const
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 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:272
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:150
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.
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.