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 
52 TypeId
54 {
55  static TypeId tid = TypeId ("ns3::CaraWifiManager")
57  .AddConstructor<CaraWifiManager> ()
58  .AddAttribute ("ProbeThreshold",
59  "The number of consecutive transmissions failure to activate the RTS probe.",
60  UintegerValue (1),
61  MakeUintegerAccessor (&CaraWifiManager::m_probeThreshold),
62  MakeUintegerChecker<uint32_t> ())
63  .AddAttribute ("FailureThreshold",
64  "The number of consecutive transmissions failure to decrease the rate.",
65  UintegerValue (2),
66  MakeUintegerAccessor (&CaraWifiManager::m_failureThreshold),
67  MakeUintegerChecker<uint32_t> ())
68  .AddAttribute ("SuccessThreshold",
69  "The minimum number of sucessfull transmissions to try a new rate.",
70  UintegerValue (10),
71  MakeUintegerAccessor (&CaraWifiManager::m_successThreshold),
72  MakeUintegerChecker<uint32_t> ())
73  .AddAttribute ("Timeout",
74  "The 'timer' in the CARA algorithm",
75  UintegerValue (15),
76  MakeUintegerAccessor (&CaraWifiManager::m_timerTimeout),
77  MakeUintegerChecker<uint32_t> ())
78  ;
79  return tid;
80 }
81 
84 {
85  NS_LOG_FUNCTION (this);
86 }
88 {
89  NS_LOG_FUNCTION (this);
90 }
91 
94 {
95  NS_LOG_FUNCTION (this);
97  station->m_rate = 0;
98  station->m_success = 0;
99  station->m_failed = 0;
100  station->m_timer = 0;
101  return station;
102 }
103 
104 void
106 {
107  NS_LOG_FUNCTION (this << st);
108 }
109 
110 void
112 {
113  NS_LOG_FUNCTION (this << st);
115  station->m_timer++;
116  station->m_failed++;
117  station->m_success = 0;
118  if (station->m_failed >= m_failureThreshold)
119  {
120  NS_LOG_DEBUG ("self=" << station << " dec rate");
121  if (station->m_rate != 0)
122  {
123  station->m_rate--;
124  }
125  station->m_failed = 0;
126  station->m_timer = 0;
127  }
128 }
129 void
131  double rxSnr, WifiMode txMode)
132 {
133  NS_LOG_FUNCTION (this << st << rxSnr << txMode);
134 }
135 void
137  double ctsSnr, WifiMode ctsMode, double rtsSnr)
138 {
139  NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr);
140  NS_LOG_DEBUG ("self=" << st << " rts ok");
141 }
142 void
144  double ackSnr, WifiMode ackMode, double dataSnr)
145 {
146  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
148  station->m_timer++;
149  station->m_success++;
150  station->m_failed = 0;
151  NS_LOG_DEBUG ("self=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
152  if ((station->m_success == m_successThreshold
153  || station->m_timer >= m_timerTimeout))
154  {
155  if (station->m_rate < GetNSupported (station) - 1)
156  {
157  station->m_rate++;
158  }
159  NS_LOG_DEBUG ("self=" << station << " inc rate=" << station->m_rate);
160  station->m_timer = 0;
161  station->m_success = 0;
162  }
163 }
164 void
166 {
167  NS_LOG_FUNCTION (this << st);
168 }
169 void
171 {
172  NS_LOG_FUNCTION (this << st);
173 }
174 
177  uint32_t size)
178 {
179  NS_LOG_FUNCTION (this << st << size);
182 }
185 {
186  NS_LOG_FUNCTION (this << st);
190 }
191 
192 bool
194  Ptr<const Packet> packet, bool normally)
195 {
196  NS_LOG_FUNCTION (this << st << normally);
198  return normally || station->m_failed >= m_probeThreshold;
199 }
200 
201 bool
203 {
204  NS_LOG_FUNCTION (this);
205  return true;
206 }
207 
208 } // namespace ns3
uint32_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
virtual WifiRemoteStation * DoCreateStation(void) const
virtual bool IsLowLatency(void) const
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
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.
NS_LOG_COMPONENT_DEFINE("Cara")
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).
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
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 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)
Definition: log.h:289
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:611
hold per-remote-station state.