A Discrete-Event Network Simulator
API
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 namespace ns3 {
29 
30 NS_LOG_COMPONENT_DEFINE ("ArfWifiManager");
31 
39 {
40  uint32_t m_timer;
41  uint32_t m_success;
42  uint32_t m_failed;
43  bool m_recovery;
44  uint32_t m_retry;
45 
46  uint32_t m_timerTimeout;
48 
49  uint32_t m_rate;
50 };
51 
53 
54 TypeId
56 {
57  static TypeId tid = TypeId ("ns3::ArfWifiManager")
59  .AddConstructor<ArfWifiManager> ()
60  .AddAttribute ("TimerThreshold", "The 'timer' threshold in the ARF algorithm.",
61  UintegerValue (15),
63  MakeUintegerChecker<uint32_t> ())
64  .AddAttribute ("SuccessThreshold",
65  "The minimum number of sucessfull transmissions to try a new rate.",
66  UintegerValue (10),
68  MakeUintegerChecker<uint32_t> ())
69  ;
70  return tid;
71 }
72 
74 {
75  NS_LOG_FUNCTION (this);
76 }
78 {
79  NS_LOG_FUNCTION (this);
80 }
83 {
84  NS_LOG_FUNCTION (this);
86 
89  station->m_rate = 0;
90  station->m_success = 0;
91  station->m_failed = 0;
92  station->m_recovery = false;
93  station->m_retry = 0;
94  station->m_timer = 0;
95 
96  return station;
97 }
98 
99 void
101 {
102  NS_LOG_FUNCTION (this << station);
103 }
115 void
117 {
118  NS_LOG_FUNCTION (this << st);
120  station->m_timer++;
121  station->m_failed++;
122  station->m_retry++;
123  station->m_success = 0;
124 
125  if (station->m_recovery)
126  {
127  NS_ASSERT (station->m_retry >= 1);
128  if (station->m_retry == 1)
129  {
130  // need recovery fallback
131  if (station->m_rate != 0)
132  {
133  station->m_rate--;
134  }
135  }
136  station->m_timer = 0;
137  }
138  else
139  {
140  NS_ASSERT (station->m_retry >= 1);
141  if (((station->m_retry - 1) % 2) == 1)
142  {
143  // need normal fallback
144  if (station->m_rate != 0)
145  {
146  station->m_rate--;
147  }
148  }
149  if (station->m_retry >= 2)
150  {
151  station->m_timer = 0;
152  }
153  }
154 }
155 void
157  double rxSnr, WifiMode txMode)
158 {
159  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
160 }
162  double ctsSnr, WifiMode ctsMode, double rtsSnr)
163 {
164  NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
165  NS_LOG_DEBUG ("station=" << station << " rts ok");
166 }
168  double ackSnr, WifiMode ackMode, double dataSnr)
169 {
170  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
171  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
172  station->m_timer++;
173  station->m_success++;
174  station->m_failed = 0;
175  station->m_recovery = false;
176  station->m_retry = 0;
177  NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
178  if ((station->m_success == m_successThreshold
179  || station->m_timer == m_timerThreshold)
180  && (station->m_rate < (station->m_state->m_operationalRateSet.size () - 1)))
181  {
182  NS_LOG_DEBUG ("station=" << station << " inc rate");
183  station->m_rate++;
184  station->m_timer = 0;
185  station->m_success = 0;
186  station->m_recovery = true;
187  }
188 }
189 void
191 {
192  NS_LOG_FUNCTION (this << station);
193 }
194 void
196 {
197  NS_LOG_FUNCTION (this << station);
198 }
199 
202 {
203  NS_LOG_FUNCTION (this << st << size);
204  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
205  return WifiTxVector (GetSupported (station, station->m_rate), GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetShortGuardInterval (station), Min (GetNumberOfReceiveAntennas (station),GetNumberOfTransmitAntennas()), GetNess (station), GetStbc (station));
206 }
209 {
210  NS_LOG_FUNCTION (this << st);
213  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
215 }
216 
217 bool
219 {
220  NS_LOG_FUNCTION (this);
221  return true;
222 }
223 
224 } // 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 an Object subclass with the TypeId system.
Definition: object-base.h:44
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:201
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:93
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:191
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:44
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 ...
uint32_t GetNess(const WifiRemoteStation *station) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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:236
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
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:51
TypeId SetParent(TypeId tid)
Definition: type-id.cc:631
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.