A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rraa-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: Federico Maguolo <maguolof@dei.unipd.it>
19  */
20 
21 #include "rraa-wifi-manager.h"
22 #include "ns3/assert.h"
23 #include "ns3/log.h"
24 #include "ns3/boolean.h"
25 #include "ns3/double.h"
26 #include "ns3/uinteger.h"
27 #include "ns3/simulator.h"
28 
29 #define Min(a,b) ((a < b) ? a : b)
30 
31 NS_LOG_COMPONENT_DEFINE ("RraaWifiManager");
32 
33 namespace ns3 {
34 
42 {
43  uint32_t m_counter;
44  uint32_t m_failed;
45  uint32_t m_rtsWnd;
46  uint32_t m_rtsCounter;
48  bool m_rtsOn;
51 
52  uint32_t m_rate;
53 };
54 
56  ;
57 
58 TypeId
60 {
61  static TypeId tid = TypeId ("ns3::RraaWifiManager")
63  .AddConstructor<RraaWifiManager> ()
64  .AddAttribute ("Basic",
65  "If true the RRAA-BASIC algorithm will be used, otherwise the RRAA wil be used",
66  BooleanValue (false),
67  MakeBooleanAccessor (&RraaWifiManager::m_basic),
68  MakeBooleanChecker ())
69  .AddAttribute ("Timeout",
70  "Timeout for the RRAA BASIC loss estimaton block (s)",
71  TimeValue (Seconds (0.05)),
72  MakeTimeAccessor (&RraaWifiManager::m_timeout),
73  MakeTimeChecker ())
74  .AddAttribute ("ewndFor54mbps",
75  "ewnd parameter for 54 Mbs data mode",
76  UintegerValue (40),
77  MakeUintegerAccessor (&RraaWifiManager::m_ewndfor54),
78  MakeUintegerChecker<uint32_t> ())
79  .AddAttribute ("ewndFor48mbps",
80  "ewnd parameter for 48 Mbs data mode",
81  UintegerValue (40),
82  MakeUintegerAccessor (&RraaWifiManager::m_ewndfor48),
83  MakeUintegerChecker<uint32_t> ())
84  .AddAttribute ("ewndFor36mbps",
85  "ewnd parameter for 36 Mbs data mode",
86  UintegerValue (40),
87  MakeUintegerAccessor (&RraaWifiManager::m_ewndfor36),
88  MakeUintegerChecker<uint32_t> ())
89  .AddAttribute ("ewndFor24mbps",
90  "ewnd parameter for 24 Mbs data mode",
91  UintegerValue (40),
92  MakeUintegerAccessor (&RraaWifiManager::m_ewndfor24),
93  MakeUintegerChecker<uint32_t> ())
94  .AddAttribute ("ewndFor18mbps",
95  "ewnd parameter for 18 Mbs data mode",
96  UintegerValue (20),
97  MakeUintegerAccessor (&RraaWifiManager::m_ewndfor18),
98  MakeUintegerChecker<uint32_t> ())
99  .AddAttribute ("ewndFor12mbps",
100  "ewnd parameter for 12 Mbs data mode",
101  UintegerValue (20),
102  MakeUintegerAccessor (&RraaWifiManager::m_ewndfor12),
103  MakeUintegerChecker<uint32_t> ())
104  .AddAttribute ("ewndFor9mbps",
105  "ewnd parameter for 9 Mbs data mode",
106  UintegerValue (10),
107  MakeUintegerAccessor (&RraaWifiManager::m_ewndfor9),
108  MakeUintegerChecker<uint32_t> ())
109  .AddAttribute ("ewndFor6mbps",
110  "ewnd parameter for 6 Mbs data mode",
111  UintegerValue (6),
112  MakeUintegerAccessor (&RraaWifiManager::m_ewndfor6),
113  MakeUintegerChecker<uint32_t> ())
114  .AddAttribute ("poriFor48mbps",
115  "Pori parameter for 48 Mbs data mode",
116  DoubleValue (0.047),
117  MakeDoubleAccessor (&RraaWifiManager::m_porifor48),
118  MakeDoubleChecker<double> ())
119  .AddAttribute ("poriFor36mbps",
120  "Pori parameter for 36 Mbs data mode",
121  DoubleValue (0.115),
122  MakeDoubleAccessor (&RraaWifiManager::m_porifor36),
123  MakeDoubleChecker<double> ())
124  .AddAttribute ("poriFor24mbps",
125  "Pori parameter for 24 Mbs data mode",
126  DoubleValue (0.1681),
127  MakeDoubleAccessor (&RraaWifiManager::m_porifor24),
128  MakeDoubleChecker<double> ())
129  .AddAttribute ("poriFor18mbps",
130  "Pori parameter for 18 Mbs data mode",
131  DoubleValue (0.1325),
132  MakeDoubleAccessor (&RraaWifiManager::m_porifor18),
133  MakeDoubleChecker<double> ())
134  .AddAttribute ("poriFor12mbps",
135  "Pori parameter for 12 Mbs data mode",
136  DoubleValue (0.1861),
137  MakeDoubleAccessor (&RraaWifiManager::m_porifor12),
138  MakeDoubleChecker<double> ())
139  .AddAttribute ("poriFor9mbps",
140  "Pori parameter for 9 Mbs data mode",
141  DoubleValue (0.1434),
142  MakeDoubleAccessor (&RraaWifiManager::m_porifor9),
143  MakeDoubleChecker<double> ())
144  .AddAttribute ("poriFor6mbps",
145  "Pori parameter for 6 Mbs data mode",
146  DoubleValue (0.5),
147  MakeDoubleAccessor (&RraaWifiManager::m_porifor6),
148  MakeDoubleChecker<double> ())
149  .AddAttribute ("pmtlFor54mbps",
150  "Pmtl parameter for 54 Mbs data mode",
151  DoubleValue (0.094),
152  MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor54),
153  MakeDoubleChecker<double> ())
154  .AddAttribute ("pmtlFor48mbps",
155  "Pmtl parameter for 48 Mbs data mode",
156  DoubleValue (0.23),
157  MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor48),
158  MakeDoubleChecker<double> ())
159  .AddAttribute ("pmtlFor36mbps",
160  "Pmtl parameter for 36 Mbs data mode",
161  DoubleValue (0.3363),
162  MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor36),
163  MakeDoubleChecker<double> ())
164  .AddAttribute ("pmtlFor24mbps",
165  "Pmtl parameter for 24 Mbs data mode",
166  DoubleValue (0.265),
167  MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor24),
168  MakeDoubleChecker<double> ())
169  .AddAttribute ("pmtlFor18mbps",
170  "Pmtl parameter for 18 Mbs data mode",
171  DoubleValue (0.3722),
172  MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor18),
173  MakeDoubleChecker<double> ())
174  .AddAttribute ("pmtlFor12mbps",
175  "Pmtl parameter for 12 Mbs data mode",
176  DoubleValue (0.2868),
177  MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor12),
178  MakeDoubleChecker<double> ())
179  .AddAttribute ("pmtlFor9mbps",
180  "Pmtl parameter for 9 Mbs data mode",
181  DoubleValue (0.3932),
182  MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor9),
183  MakeDoubleChecker<double> ())
184  ;
185  return tid;
186 }
187 
188 
190 {
191 }
193 {
194 }
195 
196 
199 {
201  station->m_initialized = false;
202  station->m_rtsWnd = 0;
203  station->m_rtsCounter = 0;
204  station->m_rtsOn = false;
205  station->m_lastFrameFail = false;
206  return station;
207 }
208 
209 void
211 {
212  if (!station->m_initialized)
213  {
214  station->m_rate = GetMaxRate (station);
215  station->m_initialized = true;
216  }
217  station->m_failed = 0;
218  station->m_counter = GetThresholds (station, station->m_rate).ewnd;
219  station->m_lastReset = Simulator::Now ();
220 }
221 
222 uint32_t
224 {
225  return GetNSupported (station) - 1;
226 }
227 uint32_t
229 {
230  return 0;
231 }
232 
233 
234 void
236 {
237 }
238 
239 void
241 {
243  station->m_lastFrameFail = true;
244  CheckTimeout (station);
245  station->m_counter--;
246  station->m_failed++;
247  RunBasicAlgorithm (station);
248 }
249 void
251  double rxSnr, WifiMode txMode)
252 {
253 }
254 void
256  double ctsSnr, WifiMode ctsMode, double rtsSnr)
257 {
258  NS_LOG_DEBUG ("self=" << st << " rts ok");
259 }
260 void
262  double ackSnr, WifiMode ackMode, double dataSnr)
263 {
265  station->m_lastFrameFail = false;
266  CheckTimeout (station);
267  station->m_counter--;
268  RunBasicAlgorithm (station);
269 }
270 void
272 {
273 }
274 void
276 {
277 }
278 
281  uint32_t size)
282 {
284  if (!station->m_initialized)
285  {
286  ResetCountersBasic (station);
287  }
289 }
292 {
294 }
295 
296 bool
298  Ptr<const Packet> packet, bool normally)
299 {
301  if (m_basic)
302  {
303  return normally;
304  }
305  ARts (station);
306  return station->m_rtsOn;
307 }
308 
309 void
311 {
312  Time d = Simulator::Now () - station->m_lastReset;
313  if (station->m_counter == 0 || d > m_timeout)
314  {
315  ResetCountersBasic (station);
316  }
317 }
318 
319 void
321 {
322  ThresholdsItem thresholds = GetThresholds (station, station->m_rate);
323  double ploss = (double) station->m_failed / (double) thresholds.ewnd;
324  if (station->m_counter == 0
325  || ploss > thresholds.pmtl)
326  {
327  if (station->m_rate > GetMinRate (station)
328  && ploss > thresholds.pmtl)
329  {
330  station->m_rate--;
331  }
332  else if (station->m_rate < GetMaxRate (station)
333  && ploss < thresholds.pori)
334  {
335  station->m_rate++;
336  }
337  ResetCountersBasic (station);
338  }
339 }
340 
341 void
343 {
344  if (!station->m_rtsOn
345  && station->m_lastFrameFail)
346  {
347  station->m_rtsWnd++;
348  station->m_rtsCounter = station->m_rtsWnd;
349  }
350  else if ((station->m_rtsOn && station->m_lastFrameFail)
351  || (!station->m_rtsOn && !station->m_lastFrameFail))
352  {
353  station->m_rtsWnd = station->m_rtsWnd / 2;
354  station->m_rtsCounter = station->m_rtsWnd;
355  }
356  if (station->m_rtsCounter > 0)
357  {
358  station->m_rtsOn = true;
359  station->m_rtsCounter--;
360  }
361  else
362  {
363  station->m_rtsOn = false;
364  }
365 }
366 
368 RraaWifiManager::GetThresholds (RraaWifiRemoteStation *station,
369  uint32_t rate) const
370 {
371  WifiMode mode = GetSupported (station, rate);
372  return GetThresholds (mode);
373 }
374 
376 RraaWifiManager::GetThresholds (WifiMode mode) const
377 {
378  switch (mode.GetDataRate () / 1000000)
379  {
380  case 54:
381  {
382  ThresholdsItem mode54 = {
383  54000000,
384  0.0,
385  m_pmtlfor54,
387  };
388  return mode54;
389  } break;
390  case 48:
391  {
392  ThresholdsItem mode48 = {
393  48000000,
394  m_porifor48,
395  m_pmtlfor48,
397  };
398  return mode48;
399  } break;
400  case 36:
401  {
402  ThresholdsItem mode36 = {
403  36000000,
404  m_porifor36,
405  m_pmtlfor36,
407  };
408  return mode36;
409  } break;
410  case 24:
411  {
412  ThresholdsItem mode24 = {
413  24000000,
414  m_porifor24,
415  m_pmtlfor24,
417  };
418  return mode24;
419  } break;
420  case 18:
421  {
422  ThresholdsItem mode18 = {
423  18000000,
424  m_porifor18,
425  m_pmtlfor18,
427  };
428  return mode18;
429  } break;
430  case 12:
431  {
432  ThresholdsItem mode12 = {
433  12000000,
434  m_porifor12,
435  m_pmtlfor12,
437  };
438  return mode12;
439  } break;
440  case 9:
441  {
442  ThresholdsItem mode9 = {
443  9000000,
444  m_porifor9,
445  m_pmtlfor9,
446  m_ewndfor9
447  };
448  return mode9;
449  } break;
450  case 6:
451  {
452  ThresholdsItem mode6 = {
453  6000000,
454  m_porifor6,
455  1.0,
456  m_ewndfor6
457  };
458  return mode6;
459  } break;
460  }
461  NS_ASSERT_MSG (false, "Thresholds for an unknown mode are asked (" << mode << ")");
462  return ThresholdsItem ();
463 }
464 
465 bool
467 {
468  return true;
469 }
470 
471 } // namespace ns3
uint32_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
uint32_t GetMaxRate(RraaWifiRemoteStation *station)
Return the index for the maximum transmission rate for the given station.
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)
Hold a bool native type.
Definition: boolean.h:38
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
This method is a pure virtual method that must be implemented by the sub-class.
static TypeId GetTypeId(void)
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.
struct ThresholdsItem GetThresholds(WifiMode mode) const
Get a threshold for the given mode.
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
void RunBasicAlgorithm(RraaWifiRemoteStation *station)
Find an appropriate rate for the given station, using a basic algorithm.
virtual bool DoNeedRts(WifiRemoteStation *st, Ptr< const Packet > packet, bool normally)
virtual bool IsLowLatency(void) const
virtual void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
void ResetCountersBasic(RraaWifiRemoteStation *station)
Reset the counters of the given station.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:91
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. ...
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
virtual WifiRemoteStation * DoCreateStation(void) const
bool GetStbc(const WifiRemoteStation *station) const
Return whether the given station supports space-time block coding (STBC).
void CheckTimeout(RraaWifiRemoteStation *station)
Check if the counter should be resetted.
NS_LOG_COMPONENT_DEFINE("RraaWifiManager")
hold objects of type ns3::Time
Definition: nstime.h:961
virtual void DoReportDataFailed(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
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Definition: int64x64.h:90
hold a list of per-remote-station state.
Robust Rate Adaptation AlgorithmThis is an implementation of RRAA as described in "Robust rate adapta...
bool GetShortGuardInterval(const WifiRemoteStation *station) const
Return whether the given station supports short guard interval.
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
void ARts(RraaWifiRemoteStation *station)
Activate the use of RTS for the given station if the conditions are met.
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.
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
uint32_t GetLongRetryCount(const WifiRemoteStation *station) const
Return the long retry limit of the given station.
#define NS_LOG_DEBUG(msg)
Definition: log.h:289
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:452
hold per-remote-station state for RRAA Wifi manager.
uint32_t GetShortRetryCount(const WifiRemoteStation *station) const
Return the short retry limit of the given station.
uint32_t GetMinRate(RraaWifiRemoteStation *station)
Return the index for the minimum transmission rate for the given station.
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
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
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
hold per-remote-station state.