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 
56 TypeId
58 {
59  static TypeId tid = TypeId ("ns3::ArfWifiManager")
61  .AddConstructor<ArfWifiManager> ()
62  .AddAttribute ("TimerThreshold", "The 'timer' threshold in the ARF algorithm.",
63  UintegerValue (15),
64  MakeUintegerAccessor (&ArfWifiManager::m_timerThreshold),
65  MakeUintegerChecker<uint32_t> ())
66  .AddAttribute ("SuccessThreshold",
67  "The minimum number of sucessfull transmissions to try a new rate.",
68  UintegerValue (10),
69  MakeUintegerAccessor (&ArfWifiManager::m_successThreshold),
70  MakeUintegerChecker<uint32_t> ())
71  ;
72  return tid;
73 }
74 
76 {
77  NS_LOG_FUNCTION (this);
78 }
80 {
81  NS_LOG_FUNCTION (this);
82 }
85 {
86  NS_LOG_FUNCTION (this);
88 
91  station->m_rate = 0;
92  station->m_success = 0;
93  station->m_failed = 0;
94  station->m_recovery = false;
95  station->m_retry = 0;
96  station->m_timer = 0;
97 
98  return station;
99 }
100 
101 void
103 {
104  NS_LOG_FUNCTION (this << station);
105 }
117 void
119 {
120  NS_LOG_FUNCTION (this << st);
122  station->m_timer++;
123  station->m_failed++;
124  station->m_retry++;
125  station->m_success = 0;
126 
127  if (station->m_recovery)
128  {
129  NS_ASSERT (station->m_retry >= 1);
130  if (station->m_retry == 1)
131  {
132  // need recovery fallback
133  if (station->m_rate != 0)
134  {
135  station->m_rate--;
136  }
137  }
138  station->m_timer = 0;
139  }
140  else
141  {
142  NS_ASSERT (station->m_retry >= 1);
143  if (((station->m_retry - 1) % 2) == 1)
144  {
145  // need normal fallback
146  if (station->m_rate != 0)
147  {
148  station->m_rate--;
149  }
150  }
151  if (station->m_retry >= 2)
152  {
153  station->m_timer = 0;
154  }
155  }
156 }
157 void
159  double rxSnr, WifiMode txMode)
160 {
161  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
162 }
164  double ctsSnr, WifiMode ctsMode, double rtsSnr)
165 {
166  NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr);
167  NS_LOG_DEBUG ("station=" << station << " rts ok");
168 }
170  double ackSnr, WifiMode ackMode, double dataSnr)
171 {
172  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
173  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
174  station->m_timer++;
175  station->m_success++;
176  station->m_failed = 0;
177  station->m_recovery = false;
178  station->m_retry = 0;
179  NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
180  if ((station->m_success == m_successThreshold
181  || station->m_timer == m_timerThreshold)
182  && (station->m_rate < (station->m_state->m_operationalRateSet.size () - 1)))
183  {
184  NS_LOG_DEBUG ("station=" << station << " inc rate");
185  station->m_rate++;
186  station->m_timer = 0;
187  station->m_success = 0;
188  station->m_recovery = true;
189  }
190 }
191 void
193 {
194  NS_LOG_FUNCTION (this << station);
195 }
196 void
198 {
199  NS_LOG_FUNCTION (this << station);
200 }
201 
204 {
205  NS_LOG_FUNCTION (this << st << size);
206  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
208 }
211 {
212  NS_LOG_FUNCTION (this << st);
215  ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st;
217 }
218 
219 bool
221 {
222  NS_LOG_FUNCTION (this);
223  return true;
224 }
225 
226 } // namespace ns3
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
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...
virtual void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
#define NS_ASSERT(condition)
Definition: assert.h:64
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
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).
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
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)
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)
NS_LOG_COMPONENT_DEFINE("ns3::ArfWifiManager")
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
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:611
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.