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 "ns3/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);
142  ArfWifiRemoteStation *station = static_cast<ArfWifiRemoteStation*> (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 dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
194 {
195  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss);
196  ArfWifiRemoteStation *station = static_cast<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 = static_cast<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 ()), 800, 1, 1, 0, channelWidth, GetAggregation (station));
243 }
244 
247 {
248  NS_LOG_FUNCTION (this << st);
251  ArfWifiRemoteStation *station = static_cast<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 ()), 800, 1, 1, 0, channelWidth, GetAggregation (station));
268  return rtsTxVector;
269 }
270 
271 } //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
ns3::ArfWifiManager::m_timerThreshold
uint32_t m_timerThreshold
timer threshold
Definition: arf-wifi-manager.h:76
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::ArfWifiManager::DoReportDataFailed
void DoReportDataFailed(WifiRemoteStation *station) override
It is important to realize that "recovery" mode starts after failure of the first transmission after ...
Definition: arf-wifi-manager.cc:139
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
arf-wifi-manager.h
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::ArfWifiRemoteStation::m_success
uint32_t m_success
success count
Definition: arf-wifi-manager.cc:40
ns3::ArfWifiManager
ARF Rate control algorithm.
Definition: arf-wifi-manager.h:49
ns3::ArfWifiRemoteStation::m_timerTimeout
uint32_t m_timerTimeout
timer timeout
Definition: arf-wifi-manager.cc:43
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::ArfWifiRemoteStation::m_successThreshold
uint32_t m_successThreshold
success threshold
Definition: arf-wifi-manager.cc:44
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::ArfWifiManager::DoGetDataTxVector
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station) override
Definition: arf-wifi-manager.cc:227
ns3::WifiMode::GetModulationClass
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:159
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::ArfWifiManager::DoReportRtsFailed
void DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: arf-wifi-manager.cc:122
ns3::WifiRemoteStationManager::GetVhtSupported
bool GetVhtSupported(void) const
Return whether the device has VHT capability support enabled.
Definition: wifi-remote-station-manager.cc:244
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::ArfWifiRemoteStation
hold per-remote-station state for ARF Wifi manager.
Definition: arf-wifi-manager.cc:38
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
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::ArfWifiManager::ArfWifiManager
ArfWifiManager()
Definition: arf-wifi-manager.cc:74
ns3::ArfWifiManager::DoInitialize
void DoInitialize(void) override
Initialize() implementation.
Definition: arf-wifi-manager.cc:87
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
ns3::ArfWifiRemoteStation::m_recovery
bool m_recovery
recovery
Definition: arf-wifi-manager.cc:42
ns3::ArfWifiManager::DoCreateStation
WifiRemoteStation * DoCreateStation(void) const override
Definition: arf-wifi-manager.cc:105
ns3::ArfWifiRemoteStation::m_failed
uint32_t m_failed
failed count
Definition: arf-wifi-manager.cc:41
ns3::WifiMode
represent a single transmission mode
Definition: wifi-mode.h:48
ns3::ArfWifiRemoteStation::m_timer
uint32_t m_timer
timer value
Definition: arf-wifi-manager.cc:39
ns3::GetPreambleForTransmission
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
Definition: wifi-utils.cc:116
ns3::ArfWifiManager::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: arf-wifi-manager.cc:192
ns3::WifiRemoteStation
hold per-remote-station state.
Definition: wifi-remote-station-manager.h:62
ns3::WifiRemoteStationManager::GetAggregation
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
Definition: wifi-remote-station-manager.cc:1707
ns3::ArfWifiManager::DoReportFinalRtsFailed
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: arf-wifi-manager.cc:215
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
ns3::ArfWifiManager::DoReportFinalDataFailed
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: arf-wifi-manager.cc:221
ns3::WifiRemoteStation::m_state
WifiRemoteStationState * m_state
Remote station state.
Definition: wifi-remote-station-manager.h:63
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::ArfWifiManager::~ArfWifiManager
virtual ~ArfWifiManager()
Definition: arf-wifi-manager.cc:81
ns3::ArfWifiRemoteStation::m_rate
uint8_t m_rate
rate
Definition: arf-wifi-manager.cc:45
ns3::ArfWifiManager::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: arf-wifi-manager.cc:185
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::ArfWifiManager::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: arf-wifi-manager.cc:51
ns3::ArfWifiManager::m_successThreshold
uint32_t m_successThreshold
success threshold
Definition: arf-wifi-manager.h:77
ns3::UintegerValue
Hold an unsigned integer type.
Definition: uinteger.h:44
ns3::WifiRemoteStationState::m_operationalRateSet
WifiModeList m_operationalRateSet
This member is the list of WifiMode objects that comprise the OperationalRateSet parameter for this r...
Definition: wifi-remote-station-manager.h:93
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::ArfWifiManager::DoGetRtsTxVector
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
Definition: arf-wifi-manager.cc:246
ns3::WifiRemoteStationManager::GetHeSupported
bool GetHeSupported(void) const
Return whether the device has HE capability support enabled.
Definition: wifi-remote-station-manager.cc:256
ns3::ArfWifiManager::m_currentRate
TracedValue< uint64_t > m_currentRate
Trace rate changes.
Definition: arf-wifi-manager.h:79
ns3::ArfWifiManager::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: arf-wifi-manager.cc:179