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 
35 {
36  uint32_t m_timer;
37  uint32_t m_success;
38  uint32_t m_failed;
39  bool m_recovery;
40  uint32_t m_retry;
41 
42  uint32_t m_timerTimeout;
44 
45  uint32_t m_rate;
46 };
47 
48 
50 
51 TypeId
53 {
54  static TypeId tid = TypeId ("ns3::AarfWifiManager")
56  .AddConstructor<AarfWifiManager> ()
57  .AddAttribute ("SuccessK", "Multiplication factor for the success threshold in the AARF algorithm.",
58  DoubleValue (2.0),
59  MakeDoubleAccessor (&AarfWifiManager::m_successK),
60  MakeDoubleChecker<double> ())
61  .AddAttribute ("TimerK",
62  "Multiplication factor for the timer threshold in the AARF algorithm.",
63  DoubleValue (2.0),
64  MakeDoubleAccessor (&AarfWifiManager::m_timerK),
65  MakeDoubleChecker<double> ())
66  .AddAttribute ("MaxSuccessThreshold",
67  "Maximum value of the success threshold in the AARF algorithm.",
68  UintegerValue (60),
69  MakeUintegerAccessor (&AarfWifiManager::m_maxSuccessThreshold),
70  MakeUintegerChecker<uint32_t> ())
71  .AddAttribute ("MinTimerThreshold",
72  "The minimum value for the 'timer' threshold in the AARF algorithm.",
73  UintegerValue (15),
74  MakeUintegerAccessor (&AarfWifiManager::m_minTimerThreshold),
75  MakeUintegerChecker<uint32_t> ())
76  .AddAttribute ("MinSuccessThreshold",
77  "The minimum value for the success threshold in the AARF algorithm.",
78  UintegerValue (10),
79  MakeUintegerAccessor (&AarfWifiManager::m_minSuccessThreshold),
80  MakeUintegerChecker<uint32_t> ())
81  ;
82  return tid;
83 }
84 
86 {
87  NS_LOG_FUNCTION (this);
88 }
90 {
91  NS_LOG_FUNCTION (this);
92 }
93 
96 {
97  NS_LOG_FUNCTION (this);
99 
102  station->m_rate = 0;
103  station->m_success = 0;
104  station->m_failed = 0;
105  station->m_recovery = false;
106  station->m_retry = 0;
107  station->m_timer = 0;
108 
109  return station;
110 }
111 
112 void
114 {
115  NS_LOG_FUNCTION (this << station);
116 }
126 void
128 {
129  NS_LOG_FUNCTION (this << st);
131  station->m_timer++;
132  station->m_failed++;
133  station->m_retry++;
134  station->m_success = 0;
135 
136  if (station->m_recovery)
137  {
138  NS_ASSERT (station->m_retry >= 1);
139  if (station->m_retry == 1)
140  {
141  // need recovery fallback
142  station->m_successThreshold = (int)(Min (station->m_successThreshold * m_successK,
144  station->m_timerTimeout = (int)(Max (station->m_timerTimeout * m_timerK,
146  if (station->m_rate != 0)
147  {
148  station->m_rate--;
149  }
150  }
151  station->m_timer = 0;
152  }
153  else
154  {
155  NS_ASSERT (station->m_retry >= 1);
156  if (((station->m_retry - 1) % 2) == 1)
157  {
158  // need normal fallback
161  if (station->m_rate != 0)
162  {
163  station->m_rate--;
164  }
165  }
166  if (station->m_retry >= 2)
167  {
168  station->m_timer = 0;
169  }
170  }
171 }
172 void
174  double rxSnr, WifiMode txMode)
175 {
176  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
177 }
178 void
180  double ctsSnr, WifiMode ctsMode, double rtsSnr)
181 {
182  NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
183  NS_LOG_DEBUG ("station=" << station << " rts ok");
184 }
185 void
187  double ackSnr, WifiMode ackMode, double dataSnr)
188 {
189  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
191  station->m_timer++;
192  station->m_success++;
193  station->m_failed = 0;
194  station->m_recovery = false;
195  station->m_retry = 0;
196  NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
197  if ((station->m_success == station->m_successThreshold
198  || station->m_timer == station->m_timerTimeout)
199  && (station->m_rate < (GetNSupported (station) - 1)))
200  {
201  NS_LOG_DEBUG ("station=" << station << " inc rate");
202  station->m_rate++;
203  station->m_timer = 0;
204  station->m_success = 0;
205  station->m_recovery = true;
206  }
207 }
208 void
210 {
211  NS_LOG_FUNCTION (this << station);
212 }
213 void
215 {
216  NS_LOG_FUNCTION (this << station);
217 }
218 
221 {
222  NS_LOG_FUNCTION (this << st << size);
225 }
228 {
229  NS_LOG_FUNCTION (this << st);
234 }
235 
236 bool
238 {
239  NS_LOG_FUNCTION (this);
240  return true;
241 }
242 
243 } // namespace ns3
uint32_t GetNSupported(const WifiRemoteStation *station) const
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:311
#define NS_ASSERT(condition)
Definition: assert.h:64
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)
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
uint32_t GetNumberOfReceiveAntennas(const WifiRemoteStation *station) const
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
bool GetStbc(const WifiRemoteStation *station) const
virtual void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)
virtual void DoReportRtsFailed(WifiRemoteStation *station)
Hold an unsigned integer type.
Definition: uinteger.h:46
virtual bool IsLowLatency(void) const
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Definition: int64x64.h:90
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Definition: int64x64.h:95
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
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)
uint32_t GetLongRetryCount(const WifiRemoteStation *station) const
#define NS_LOG_DEBUG(msg)
Definition: log.h:255
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)
Hold an floating point type.
Definition: double.h:41
virtual WifiRemoteStation * DoCreateStation(void) const
a unique identifier for an interface.
Definition: type-id.h:49
NS_LOG_COMPONENT_DEFINE("AarfWifiManager")
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
hold per-remote-station state.
static TypeId GetTypeId(void)