A Discrete-Event Network Simulator
API
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 namespace ns3 {
31 
32 NS_LOG_COMPONENT_DEFINE ("AarfWifiManager");
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  .SetGroupName ("Wifi")
63  .AddConstructor<AarfWifiManager> ()
64  .AddAttribute ("SuccessK", "Multiplication factor for the success threshold in the AARF algorithm.",
65  DoubleValue (2.0),
67  MakeDoubleChecker<double> ())
68  .AddAttribute ("TimerK",
69  "Multiplication factor for the timer threshold in the AARF algorithm.",
70  DoubleValue (2.0),
72  MakeDoubleChecker<double> ())
73  .AddAttribute ("MaxSuccessThreshold",
74  "Maximum value of the success threshold in the AARF algorithm.",
75  UintegerValue (60),
77  MakeUintegerChecker<uint32_t> ())
78  .AddAttribute ("MinTimerThreshold",
79  "The minimum value for the 'timer' threshold in the AARF algorithm.",
80  UintegerValue (15),
82  MakeUintegerChecker<uint32_t> ())
83  .AddAttribute ("MinSuccessThreshold",
84  "The minimum value for the success threshold in the AARF algorithm.",
85  UintegerValue (10),
87  MakeUintegerChecker<uint32_t> ())
88  ;
89  return tid;
90 }
91 
93 {
94  NS_LOG_FUNCTION (this);
95 }
97 {
98  NS_LOG_FUNCTION (this);
99 }
100 
103 {
104  NS_LOG_FUNCTION (this);
106 
109  station->m_rate = 0;
110  station->m_success = 0;
111  station->m_failed = 0;
112  station->m_recovery = false;
113  station->m_retry = 0;
114  station->m_timer = 0;
115 
116  return station;
117 }
118 
119 void
121 {
122  NS_LOG_FUNCTION (this << station);
123 }
135 void
137 {
138  NS_LOG_FUNCTION (this << st);
140  station->m_timer++;
141  station->m_failed++;
142  station->m_retry++;
143  station->m_success = 0;
144 
145  if (station->m_recovery)
146  {
147  NS_ASSERT (station->m_retry >= 1);
148  if (station->m_retry == 1)
149  {
150  // need recovery fallback
151  station->m_successThreshold = (int)(Min (station->m_successThreshold * m_successK,
153  station->m_timerTimeout = (int)(Max (station->m_timerTimeout * m_timerK,
155  if (station->m_rate != 0)
156  {
157  station->m_rate--;
158  }
159  }
160  station->m_timer = 0;
161  }
162  else
163  {
164  NS_ASSERT (station->m_retry >= 1);
165  if (((station->m_retry - 1) % 2) == 1)
166  {
167  // need normal fallback
170  if (station->m_rate != 0)
171  {
172  station->m_rate--;
173  }
174  }
175  if (station->m_retry >= 2)
176  {
177  station->m_timer = 0;
178  }
179  }
180 }
181 void
183  double rxSnr, WifiMode txMode)
184 {
185  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
186 }
187 void
189  double ctsSnr, WifiMode ctsMode, double rtsSnr)
190 {
191  NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
192  NS_LOG_DEBUG ("station=" << station << " rts ok");
193 }
194 void
196  double ackSnr, WifiMode ackMode, double dataSnr)
197 {
198  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
200  station->m_timer++;
201  station->m_success++;
202  station->m_failed = 0;
203  station->m_recovery = false;
204  station->m_retry = 0;
205  NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
206  if ((station->m_success == station->m_successThreshold
207  || station->m_timer == station->m_timerTimeout)
208  && (station->m_rate < (GetNSupported (station) - 1)))
209  {
210  NS_LOG_DEBUG ("station=" << station << " inc rate");
211  station->m_rate++;
212  station->m_timer = 0;
213  station->m_success = 0;
214  station->m_recovery = true;
215  }
216 }
217 void
219 {
220  NS_LOG_FUNCTION (this << station);
221 }
222 void
224 {
225  NS_LOG_FUNCTION (this << station);
226 }
227 
230 {
231  NS_LOG_FUNCTION (this << st << size);
233  return WifiTxVector (GetSupported (station, station->m_rate), GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetShortGuardInterval (station), Min (GetNumberOfReceiveAntennas (station),GetNumberOfTransmitAntennas()), GetNess (station), GetStbc (station));
234 }
237 {
238  NS_LOG_FUNCTION (this << st);
243 }
244 
245 bool
247 {
248  NS_LOG_FUNCTION (this);
249  return true;
250 }
251 
252 } // 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 an Object subclass with the TypeId system.
Definition: object-base.h:44
#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
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:93
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:197
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:44
virtual bool IsLowLatency(void) const
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:209
hold a list of per-remote-station state.
uint32_t GetNess(const WifiRemoteStation *station) const
AARF Rate control algorithmThis class implements the AARF rate control algorithm which was initially ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool GetShortGuardInterval(const WifiRemoteStation *station) const
Return whether the given station supports short guard interval.
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
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:236
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
virtual WifiRemoteStation * DoCreateStation(void) const
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:57
TypeId SetParent(TypeId tid)
Definition: type-id.cc:638
hold per-remote-station state.
static TypeId GetTypeId(void)