A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
aarf-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 "aarf-wifi-manager.h"
22 
23 #include "ns3/double.h"
24 #include "ns3/uinteger.h"
25 #include "ns3/log.h"
26 
27 #define Min(a,b) ((a < b) ? a : b)
28 #define Max(a,b) ((a > b) ? a : b)
29 
30 NS_LOG_COMPONENT_DEFINE ("AarfWifiManager");
31 
32 namespace ns3 {
33 
41 {
42  uint32_t m_timer;
43  uint32_t m_success;
44  uint32_t m_failed;
45  bool m_recovery;
46  uint32_t m_retry;
47 
48  uint32_t m_timerTimeout;
50 
51  uint32_t m_rate;
52 };
53 
54 
56 
57 TypeId
59 {
60  static TypeId tid = TypeId ("ns3::AarfWifiManager")
62  .AddConstructor<AarfWifiManager> ()
63  .AddAttribute ("SuccessK", "Multiplication factor for the success threshold in the AARF algorithm.",
64  DoubleValue (2.0),
65  MakeDoubleAccessor (&AarfWifiManager::m_successK),
66  MakeDoubleChecker<double> ())
67  .AddAttribute ("TimerK",
68  "Multiplication factor for the timer threshold in the AARF algorithm.",
69  DoubleValue (2.0),
70  MakeDoubleAccessor (&AarfWifiManager::m_timerK),
71  MakeDoubleChecker<double> ())
72  .AddAttribute ("MaxSuccessThreshold",
73  "Maximum value of the success threshold in the AARF algorithm.",
74  UintegerValue (60),
75  MakeUintegerAccessor (&AarfWifiManager::m_maxSuccessThreshold),
76  MakeUintegerChecker<uint32_t> ())
77  .AddAttribute ("MinTimerThreshold",
78  "The minimum value for the 'timer' threshold in the AARF algorithm.",
79  UintegerValue (15),
80  MakeUintegerAccessor (&AarfWifiManager::m_minTimerThreshold),
81  MakeUintegerChecker<uint32_t> ())
82  .AddAttribute ("MinSuccessThreshold",
83  "The minimum value for the success threshold in the AARF algorithm.",
84  UintegerValue (10),
85  MakeUintegerAccessor (&AarfWifiManager::m_minSuccessThreshold),
86  MakeUintegerChecker<uint32_t> ())
87  ;
88  return tid;
89 }
90 
92 {
93  NS_LOG_FUNCTION (this);
94 }
96 {
97  NS_LOG_FUNCTION (this);
98 }
99 
102 {
103  NS_LOG_FUNCTION (this);
105 
108  station->m_rate = 0;
109  station->m_success = 0;
110  station->m_failed = 0;
111  station->m_recovery = false;
112  station->m_retry = 0;
113  station->m_timer = 0;
114 
115  return station;
116 }
117 
118 void
120 {
121  NS_LOG_FUNCTION (this << station);
122 }
134 void
136 {
137  NS_LOG_FUNCTION (this << st);
139  station->m_timer++;
140  station->m_failed++;
141  station->m_retry++;
142  station->m_success = 0;
143 
144  if (station->m_recovery)
145  {
146  NS_ASSERT (station->m_retry >= 1);
147  if (station->m_retry == 1)
148  {
149  // need recovery fallback
150  station->m_successThreshold = (int)(Min (station->m_successThreshold * m_successK,
152  station->m_timerTimeout = (int)(Max (station->m_timerTimeout * m_timerK,
154  if (station->m_rate != 0)
155  {
156  station->m_rate--;
157  }
158  }
159  station->m_timer = 0;
160  }
161  else
162  {
163  NS_ASSERT (station->m_retry >= 1);
164  if (((station->m_retry - 1) % 2) == 1)
165  {
166  // need normal fallback
169  if (station->m_rate != 0)
170  {
171  station->m_rate--;
172  }
173  }
174  if (station->m_retry >= 2)
175  {
176  station->m_timer = 0;
177  }
178  }
179 }
180 void
182  double rxSnr, WifiMode txMode)
183 {
184  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
185 }
186 void
188  double ctsSnr, WifiMode ctsMode, double rtsSnr)
189 {
190  NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
191  NS_LOG_DEBUG ("station=" << station << " rts ok");
192 }
193 void
195  double ackSnr, WifiMode ackMode, double dataSnr)
196 {
197  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
199  station->m_timer++;
200  station->m_success++;
201  station->m_failed = 0;
202  station->m_recovery = false;
203  station->m_retry = 0;
204  NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
205  if ((station->m_success == station->m_successThreshold
206  || station->m_timer == station->m_timerTimeout)
207  && (station->m_rate < (GetNSupported (station) - 1)))
208  {
209  NS_LOG_DEBUG ("station=" << station << " inc rate");
210  station->m_rate++;
211  station->m_timer = 0;
212  station->m_success = 0;
213  station->m_recovery = true;
214  }
215 }
216 void
218 {
219  NS_LOG_FUNCTION (this << station);
220 }
221 void
223 {
224  NS_LOG_FUNCTION (this << station);
225 }
226 
229 {
230  NS_LOG_FUNCTION (this << st << size);
233 }
236 {
237  NS_LOG_FUNCTION (this << st);
242 }
243 
244 bool
246 {
247  NS_LOG_FUNCTION (this);
248  return true;
249 }
250 
251 } // namespace ns3
uint32_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
#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...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:91
virtual void DoReportDataFailed(WifiRemoteStation *station)
It is important to realize that "recovery" mode starts after failure of the first transmission after ...
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
This method is a pure virtual method that must be implemented by the sub-class.
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
uint32_t GetNumberOfReceiveAntennas(const WifiRemoteStation *station) const
Return the number of receive antenna the station has.
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
Return whether mode associated with the specified station at the specified index. ...
bool GetStbc(const WifiRemoteStation *station) const
Return whether the given station supports space-time block coding (STBC).
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 DoReportFinalDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:194
virtual void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
Hold an unsigned integer type.
Definition: uinteger.h:46
virtual bool IsLowLatency(void) const
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:204
hold a list of per-remote-station state.
AARF Rate control algorithmThis class implements the AARF rate control algorithm which was initially ...
bool GetShortGuardInterval(const WifiRemoteStation *station) const
Return whether the given station supports short guard interval.
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)
hold per-remote-station state for AARF Wifi manager.
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.
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:213
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
Hold a floating point type.
Definition: double.h:41
virtual WifiRemoteStation * DoCreateStation(void) const
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
hold per-remote-station state.
static TypeId GetTypeId(void)