A Discrete-Event Network Simulator
API
cara-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 "cara-wifi-manager.h"
22 #include "ns3/assert.h"
23 #include "ns3/log.h"
24 #include "ns3/double.h"
25 #include "ns3/uinteger.h"
26 #include "ns3/simulator.h"
27 
28 #define Min(a,b) ((a < b) ? a : b)
29 
30 namespace ns3 {
31 
33 
41 {
42  uint32_t m_timer;
43  uint32_t m_success;
44  uint32_t m_failed;
45  uint32_t m_rate;
46 };
47 
49 
50 TypeId
52 {
53  static TypeId tid = TypeId ("ns3::CaraWifiManager")
55  .AddConstructor<CaraWifiManager> ()
56  .AddAttribute ("ProbeThreshold",
57  "The number of consecutive transmissions failure to activate the RTS probe.",
58  UintegerValue (1),
60  MakeUintegerChecker<uint32_t> ())
61  .AddAttribute ("FailureThreshold",
62  "The number of consecutive transmissions failure to decrease the rate.",
63  UintegerValue (2),
65  MakeUintegerChecker<uint32_t> ())
66  .AddAttribute ("SuccessThreshold",
67  "The minimum number of sucessfull transmissions to try a new rate.",
68  UintegerValue (10),
70  MakeUintegerChecker<uint32_t> ())
71  .AddAttribute ("Timeout",
72  "The 'timer' in the CARA algorithm",
73  UintegerValue (15),
75  MakeUintegerChecker<uint32_t> ())
76  ;
77  return tid;
78 }
79 
82 {
83  NS_LOG_FUNCTION (this);
84 }
86 {
87  NS_LOG_FUNCTION (this);
88 }
89 
92 {
93  NS_LOG_FUNCTION (this);
95  station->m_rate = 0;
96  station->m_success = 0;
97  station->m_failed = 0;
98  station->m_timer = 0;
99  return station;
100 }
101 
102 void
104 {
105  NS_LOG_FUNCTION (this << st);
106 }
107 
108 void
110 {
111  NS_LOG_FUNCTION (this << st);
113  station->m_timer++;
114  station->m_failed++;
115  station->m_success = 0;
116  if (station->m_failed >= m_failureThreshold)
117  {
118  NS_LOG_DEBUG ("self=" << station << " dec rate");
119  if (station->m_rate != 0)
120  {
121  station->m_rate--;
122  }
123  station->m_failed = 0;
124  station->m_timer = 0;
125  }
126 }
127 void
129  double rxSnr, WifiMode txMode)
130 {
131  NS_LOG_FUNCTION (this << st << rxSnr << txMode);
132 }
133 void
135  double ctsSnr, WifiMode ctsMode, double rtsSnr)
136 {
137  NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr);
138  NS_LOG_DEBUG ("self=" << st << " rts ok");
139 }
140 void
142  double ackSnr, WifiMode ackMode, double dataSnr)
143 {
144  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
146  station->m_timer++;
147  station->m_success++;
148  station->m_failed = 0;
149  NS_LOG_DEBUG ("self=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
150  if ((station->m_success == m_successThreshold
151  || station->m_timer >= m_timerTimeout))
152  {
153  if (station->m_rate < GetNSupported (station) - 1)
154  {
155  station->m_rate++;
156  }
157  NS_LOG_DEBUG ("self=" << station << " inc rate=" << station->m_rate);
158  station->m_timer = 0;
159  station->m_success = 0;
160  }
161 }
162 void
164 {
165  NS_LOG_FUNCTION (this << st);
166 }
167 void
169 {
170  NS_LOG_FUNCTION (this << st);
171 }
172 
175  uint32_t size)
176 {
177  NS_LOG_FUNCTION (this << st << size);
179  return WifiTxVector (GetSupported (station, station->m_rate), GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetShortGuardInterval (station), Min (GetNumberOfReceiveAntennas (station),GetNumberOfTransmitAntennas()), GetNess (station), GetStbc (station));
180 }
183 {
184  NS_LOG_FUNCTION (this << st);
188 }
189 
190 bool
192  Ptr<const Packet> packet, bool normally)
193 {
194  NS_LOG_FUNCTION (this << st << normally);
196  return normally || station->m_failed >= m_probeThreshold;
197 }
198 
199 bool
201 {
202  NS_LOG_FUNCTION (this);
203  return true;
204 }
205 
206 } // namespace ns3
uint32_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
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 WifiRemoteStation * DoCreateStation(void) const
virtual bool IsLowLatency(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
virtual void DoReportDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:93
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
This method is a pure virtual method that must be implemented by the sub-class.
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. ...
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 DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)
This method is a pure virtual method that must be implemented by the sub-class.
static TypeId GetTypeId(void)
Hold an unsigned integer type.
Definition: uinteger.h:44
hold a list of per-remote-station state.
uint32_t GetNess(const WifiRemoteStation *station) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)
bool GetShortGuardInterval(const WifiRemoteStation *station) const
Return whether the given station supports short guard interval.
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.
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 WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
hold per-remote-station state for CARA Wifi manager.
implement the CARA rate control algorithmImplement the CARA algorithm from: J.
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
virtual bool DoNeedRts(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
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.