A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
31 
32 
33 namespace ns3 {
34 
42 {
43  uint32_t m_timer;
44  uint32_t m_success;
45  uint32_t m_failed;
46  uint32_t m_rate;
47 };
48 
50 
51 TypeId
53 {
54  static TypeId tid = TypeId ("ns3::CaraWifiManager")
56  .AddConstructor<CaraWifiManager> ()
57  .AddAttribute ("ProbeThreshold",
58  "The number of consecutive transmissions failure to activate the RTS probe.",
59  UintegerValue (1),
60  MakeUintegerAccessor (&CaraWifiManager::m_probeThreshold),
61  MakeUintegerChecker<uint32_t> ())
62  .AddAttribute ("FailureThreshold",
63  "The number of consecutive transmissions failure to decrease the rate.",
64  UintegerValue (2),
65  MakeUintegerAccessor (&CaraWifiManager::m_failureThreshold),
66  MakeUintegerChecker<uint32_t> ())
67  .AddAttribute ("SuccessThreshold",
68  "The minimum number of sucessfull transmissions to try a new rate.",
69  UintegerValue (10),
70  MakeUintegerAccessor (&CaraWifiManager::m_successThreshold),
71  MakeUintegerChecker<uint32_t> ())
72  .AddAttribute ("Timeout",
73  "The 'timer' in the CARA algorithm",
74  UintegerValue (15),
75  MakeUintegerAccessor (&CaraWifiManager::m_timerTimeout),
76  MakeUintegerChecker<uint32_t> ())
77  ;
78  return tid;
79 }
80 
83 {
84  NS_LOG_FUNCTION (this);
85 }
87 {
88  NS_LOG_FUNCTION (this);
89 }
90 
93 {
94  NS_LOG_FUNCTION (this);
96  station->m_rate = 0;
97  station->m_success = 0;
98  station->m_failed = 0;
99  station->m_timer = 0;
100  return station;
101 }
102 
103 void
105 {
106  NS_LOG_FUNCTION (this << st);
107 }
108 
109 void
111 {
112  NS_LOG_FUNCTION (this << st);
114  station->m_timer++;
115  station->m_failed++;
116  station->m_success = 0;
117  if (station->m_failed >= m_failureThreshold)
118  {
119  NS_LOG_DEBUG ("self=" << station << " dec rate");
120  if (station->m_rate != 0)
121  {
122  station->m_rate--;
123  }
124  station->m_failed = 0;
125  station->m_timer = 0;
126  }
127 }
128 void
130  double rxSnr, WifiMode txMode)
131 {
132  NS_LOG_FUNCTION (this << st << rxSnr << txMode);
133 }
134 void
136  double ctsSnr, WifiMode ctsMode, double rtsSnr)
137 {
138  NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr);
139  NS_LOG_DEBUG ("self=" << st << " rts ok");
140 }
141 void
143  double ackSnr, WifiMode ackMode, double dataSnr)
144 {
145  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
147  station->m_timer++;
148  station->m_success++;
149  station->m_failed = 0;
150  NS_LOG_DEBUG ("self=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
151  if ((station->m_success == m_successThreshold
152  || station->m_timer >= m_timerTimeout))
153  {
154  if (station->m_rate < GetNSupported (station) - 1)
155  {
156  station->m_rate++;
157  }
158  NS_LOG_DEBUG ("self=" << station << " inc rate=" << station->m_rate);
159  station->m_timer = 0;
160  station->m_success = 0;
161  }
162 }
163 void
165 {
166  NS_LOG_FUNCTION (this << st);
167 }
168 void
170 {
171  NS_LOG_FUNCTION (this << st);
172 }
173 
176  uint32_t size)
177 {
178  NS_LOG_FUNCTION (this << st << size);
181 }
184 {
185  NS_LOG_FUNCTION (this << st);
189 }
190 
191 bool
193  Ptr<const Packet> packet, bool normally)
194 {
195  NS_LOG_FUNCTION (this << st << normally);
197  return normally || station->m_failed >= m_probeThreshold;
198 }
199 
200 bool
202 {
203  NS_LOG_FUNCTION (this);
204  return true;
205 }
206 
207 } // 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 the class in the ns-3 factory.
Definition: object-base.h:38
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:170
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:91
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:194
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:46
hold a list of per-remote-station state.
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:213
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.
virtual bool DoNeedRts(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
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.