A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "arf-wifi-manager.h"
22 #include "ns3/assert.h"
23 #include "ns3/log.h"
24 #include "ns3/uinteger.h"
25 
26 #define Min(a,b) ((a < b) ? a : b)
27 
28 NS_LOG_COMPONENT_DEFINE ("ns3::ArfWifiManager");
29 
30 
31 namespace ns3 {
32 
34 {
35  uint32_t m_timer;
36  uint32_t m_success;
37  uint32_t m_failed;
38  bool m_recovery;
39  uint32_t m_retry;
40 
41  uint32_t m_timerTimeout;
43 
44  uint32_t m_rate;
45 };
46 
48 
49 TypeId
51 {
52  static TypeId tid = TypeId ("ns3::ArfWifiManager")
54  .AddConstructor<ArfWifiManager> ()
55  .AddAttribute ("TimerThreshold", "The 'timer' threshold in the ARF algorithm.",
56  UintegerValue (15),
57  MakeUintegerAccessor (&ArfWifiManager::m_timerThreshold),
58  MakeUintegerChecker<uint32_t> ())
59  .AddAttribute ("SuccessThreshold",
60  "The minimum number of sucessfull transmissions to try a new rate.",
61  UintegerValue (10),
62  MakeUintegerAccessor (&ArfWifiManager::m_successThreshold),
63  MakeUintegerChecker<uint32_t> ())
64  ;
65  return tid;
66 }
67 
69 {
70  NS_LOG_FUNCTION (this);
71 }
73 {
74  NS_LOG_FUNCTION (this);
75 }
78 {
79  NS_LOG_FUNCTION (this);
81 
84  station->m_rate = 0;
85  station->m_success = 0;
86  station->m_failed = 0;
87  station->m_recovery = false;
88  station->m_retry = 0;
89  station->m_timer = 0;
90 
91  return station;
92 }
93 
94 void
96 {
97  NS_LOG_FUNCTION (this << station);
98 }
108 void
110 {
111  NS_LOG_FUNCTION (this << st);
113  station->m_timer++;
114  station->m_failed++;
115  station->m_retry++;
116  station->m_success = 0;
117 
118  if (station->m_recovery)
119  {
120  NS_ASSERT (station->m_retry >= 1);
121  if (station->m_retry == 1)
122  {
123  // need recovery fallback
124  if (station->m_rate != 0)
125  {
126  station->m_rate--;
127  }
128  }
129  station->m_timer = 0;
130  }
131  else
132  {
133  NS_ASSERT (station->m_retry >= 1);
134  if (((station->m_retry - 1) % 2) == 1)
135  {
136  // need normal fallback
137  if (station->m_rate != 0)
138  {
139  station->m_rate--;
140  }
141  }
142  if (station->m_retry >= 2)
143  {
144  station->m_timer = 0;
145  }
146  }
147 }
148 void
150  double rxSnr, WifiMode txMode)
151 {
152  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
153 }
155  double ctsSnr, WifiMode ctsMode, double rtsSnr)
156 {
157  NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
158  NS_LOG_DEBUG ("station=" << station << " rts ok");
159 }
161  double ackSnr, WifiMode ackMode, double dataSnr)
162 {
163  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
164  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
165  station->m_timer++;
166  station->m_success++;
167  station->m_failed = 0;
168  station->m_recovery = false;
169  station->m_retry = 0;
170  NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
171  if ((station->m_success == m_successThreshold
172  || station->m_timer == m_timerThreshold)
173  && (station->m_rate < (station->m_state->m_operationalRateSet.size () - 1)))
174  {
175  NS_LOG_DEBUG ("station=" << station << " inc rate");
176  station->m_rate++;
177  station->m_timer = 0;
178  station->m_success = 0;
179  station->m_recovery = true;
180  }
181 }
182 void
184 {
185  NS_LOG_FUNCTION (this << station);
186 }
187 void
189 {
190  NS_LOG_FUNCTION (this << station);
191 }
192 
195 {
196  NS_LOG_FUNCTION (this << st << size);
197  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
199 }
202 {
203  NS_LOG_FUNCTION (this << st);
206  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
208 }
209 
210 bool
212 {
213  NS_LOG_FUNCTION (this);
214  return true;
215 }
216 
217 } // namespace ns3
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:311
virtual WifiRemoteStation * DoCreateStation(void) const
virtual void DoReportRtsFailed(WifiRemoteStation *station)
#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
uint32_t GetNumberOfReceiveAntennas(const WifiRemoteStation *station) const
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
static TypeId GetTypeId(void)
WifiRemoteStationState * m_state
virtual bool IsLowLatency(void) const
bool GetStbc(const WifiRemoteStation *station) const
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)
Hold an unsigned integer type.
Definition: uinteger.h:46
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Definition: int64x64.h:90
hold a list of per-remote-station state.
virtual void DoReportDataFailed(WifiRemoteStation *station)
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
ARF Rate control algorithm.
bool GetShortGuardInterval(const WifiRemoteStation *station) const
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
NS_LOG_COMPONENT_DEFINE("ns3::ArfWifiManager")
uint32_t GetLongRetryCount(const WifiRemoteStation *station) const
#define NS_LOG_DEBUG(msg)
Definition: log.h:255
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)
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.
virtual void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)