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 
40 {
41  uint32_t m_timer;
42  uint32_t m_success;
43  uint32_t m_failed;
44  bool m_recovery;
45  uint32_t m_retry;
46 
47  uint32_t m_timerTimeout;
49 
50  uint32_t m_rate;
51 };
52 
54 
55 TypeId
57 {
58  static TypeId tid = TypeId ("ns3::ArfWifiManager")
60  .AddConstructor<ArfWifiManager> ()
61  .AddAttribute ("TimerThreshold", "The 'timer' threshold in the ARF algorithm.",
62  UintegerValue (15),
63  MakeUintegerAccessor (&ArfWifiManager::m_timerThreshold),
64  MakeUintegerChecker<uint32_t> ())
65  .AddAttribute ("SuccessThreshold",
66  "The minimum number of sucessfull transmissions to try a new rate.",
67  UintegerValue (10),
68  MakeUintegerAccessor (&ArfWifiManager::m_successThreshold),
69  MakeUintegerChecker<uint32_t> ())
70  ;
71  return tid;
72 }
73 
75 {
76  NS_LOG_FUNCTION (this);
77 }
79 {
80  NS_LOG_FUNCTION (this);
81 }
84 {
85  NS_LOG_FUNCTION (this);
87 
90  station->m_rate = 0;
91  station->m_success = 0;
92  station->m_failed = 0;
93  station->m_recovery = false;
94  station->m_retry = 0;
95  station->m_timer = 0;
96 
97  return station;
98 }
99 
100 void
102 {
103  NS_LOG_FUNCTION (this << station);
104 }
116 void
118 {
119  NS_LOG_FUNCTION (this << st);
121  station->m_timer++;
122  station->m_failed++;
123  station->m_retry++;
124  station->m_success = 0;
125 
126  if (station->m_recovery)
127  {
128  NS_ASSERT (station->m_retry >= 1);
129  if (station->m_retry == 1)
130  {
131  // need recovery fallback
132  if (station->m_rate != 0)
133  {
134  station->m_rate--;
135  }
136  }
137  station->m_timer = 0;
138  }
139  else
140  {
141  NS_ASSERT (station->m_retry >= 1);
142  if (((station->m_retry - 1) % 2) == 1)
143  {
144  // need normal fallback
145  if (station->m_rate != 0)
146  {
147  station->m_rate--;
148  }
149  }
150  if (station->m_retry >= 2)
151  {
152  station->m_timer = 0;
153  }
154  }
155 }
156 void
158  double rxSnr, WifiMode txMode)
159 {
160  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
161 }
163  double ctsSnr, WifiMode ctsMode, double rtsSnr)
164 {
165  NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
166  NS_LOG_DEBUG ("station=" << station << " rts ok");
167 }
169  double ackSnr, WifiMode ackMode, double dataSnr)
170 {
171  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
172  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
173  station->m_timer++;
174  station->m_success++;
175  station->m_failed = 0;
176  station->m_recovery = false;
177  station->m_retry = 0;
178  NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
179  if ((station->m_success == m_successThreshold
180  || station->m_timer == m_timerThreshold)
181  && (station->m_rate < (station->m_state->m_operationalRateSet.size () - 1)))
182  {
183  NS_LOG_DEBUG ("station=" << station << " inc rate");
184  station->m_rate++;
185  station->m_timer = 0;
186  station->m_success = 0;
187  station->m_recovery = true;
188  }
189 }
190 void
192 {
193  NS_LOG_FUNCTION (this << station);
194 }
195 void
197 {
198  NS_LOG_FUNCTION (this << station);
199 }
200 
203 {
204  NS_LOG_FUNCTION (this << st << size);
205  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
207 }
210 {
211  NS_LOG_FUNCTION (this << st);
214  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
216 }
217 
218 bool
220 {
221  NS_LOG_FUNCTION (this);
222  return true;
223 }
224 
225 } // namespace ns3
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual WifiRemoteStation * DoCreateStation(void) const
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
virtual void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
#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
hold per-remote-station state for ARF Wifi manager.
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. ...
static TypeId GetTypeId(void)
WifiRemoteStationState * m_state
Remote station state.
virtual bool IsLowLatency(void) const
bool GetStbc(const WifiRemoteStation *station) const
Return whether the given station supports space-time block coding (STBC).
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:194
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
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.
Hold an unsigned integer type.
Definition: uinteger.h:46
hold a list of per-remote-station state.
virtual void DoReportDataFailed(WifiRemoteStation *station)
It is important to realize that "recovery" mode starts after failure of the first transmission after ...
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)
WifiModeList m_operationalRateSet
This member is the list of WifiMode objects that comprise the OperationalRateSet parameter for this r...
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
This method is a pure virtual method that must be implemented by the sub-class.
ARF Rate control algorithm.
bool GetShortGuardInterval(const WifiRemoteStation *station) const
Return whether the given station supports short guard interval.
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
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.
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)
This method is a pure virtual method that must be implemented by the sub-class.