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 
36 {
37  uint32_t m_timer;
38  uint32_t m_success;
39  uint32_t m_failed;
40  uint32_t m_rate;
41 };
42 
44 
45 TypeId
47 {
48  static TypeId tid = TypeId ("ns3::CaraWifiManager")
50  .AddConstructor<CaraWifiManager> ()
51  .AddAttribute ("ProbeThreshold",
52  "The number of consecutive transmissions failure to activate the RTS probe.",
53  UintegerValue (1),
54  MakeUintegerAccessor (&CaraWifiManager::m_probeThreshold),
55  MakeUintegerChecker<uint32_t> ())
56  .AddAttribute ("FailureThreshold",
57  "The number of consecutive transmissions failure to decrease the rate.",
58  UintegerValue (2),
59  MakeUintegerAccessor (&CaraWifiManager::m_failureThreshold),
60  MakeUintegerChecker<uint32_t> ())
61  .AddAttribute ("SuccessThreshold",
62  "The minimum number of sucessfull transmissions to try a new rate.",
63  UintegerValue (10),
64  MakeUintegerAccessor (&CaraWifiManager::m_successThreshold),
65  MakeUintegerChecker<uint32_t> ())
66  .AddAttribute ("Timeout",
67  "The 'timer' in the CARA algorithm",
68  UintegerValue (15),
69  MakeUintegerAccessor (&CaraWifiManager::m_timerTimeout),
70  MakeUintegerChecker<uint32_t> ())
71  ;
72  return tid;
73 }
74 
77 {
78  NS_LOG_FUNCTION (this);
79 }
81 {
82  NS_LOG_FUNCTION (this);
83 }
84 
87 {
88  NS_LOG_FUNCTION (this);
90  station->m_rate = 0;
91  station->m_success = 0;
92  station->m_failed = 0;
93  station->m_timer = 0;
94  return station;
95 }
96 
97 void
99 {
100  NS_LOG_FUNCTION (this << st);
101 }
102 
103 void
105 {
106  NS_LOG_FUNCTION (this << st);
108  station->m_timer++;
109  station->m_failed++;
110  station->m_success = 0;
111  if (station->m_failed >= m_failureThreshold)
112  {
113  NS_LOG_DEBUG ("self=" << station << " dec rate");
114  if (station->m_rate != 0)
115  {
116  station->m_rate--;
117  }
118  station->m_failed = 0;
119  station->m_timer = 0;
120  }
121 }
122 void
124  double rxSnr, WifiMode txMode)
125 {
126  NS_LOG_FUNCTION (this << st << rxSnr << txMode);
127 }
128 void
130  double ctsSnr, WifiMode ctsMode, double rtsSnr)
131 {
132  NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr);
133  NS_LOG_DEBUG ("self=" << st << " rts ok");
134 }
135 void
137  double ackSnr, WifiMode ackMode, double dataSnr)
138 {
139  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
141  station->m_timer++;
142  station->m_success++;
143  station->m_failed = 0;
144  NS_LOG_DEBUG ("self=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer);
145  if ((station->m_success == m_successThreshold
146  || station->m_timer >= m_timerTimeout))
147  {
148  if (station->m_rate < GetNSupported (station) - 1)
149  {
150  station->m_rate++;
151  }
152  NS_LOG_DEBUG ("self=" << station << " inc rate=" << station->m_rate);
153  station->m_timer = 0;
154  station->m_success = 0;
155  }
156 }
157 void
159 {
160  NS_LOG_FUNCTION (this << st);
161 }
162 void
164 {
165  NS_LOG_FUNCTION (this << st);
166 }
167 
170  uint32_t size)
171 {
172  NS_LOG_FUNCTION (this << st << size);
175 }
178 {
179  NS_LOG_FUNCTION (this << st);
183 }
184 
185 bool
187  Ptr<const Packet> packet, bool normally)
188 {
189  NS_LOG_FUNCTION (this << st << normally);
191  return normally || station->m_failed >= m_probeThreshold;
192 }
193 
194 bool
196 {
197  NS_LOG_FUNCTION (this);
198  return true;
199 }
200 
201 } // namespace ns3
uint32_t GetNSupported(const WifiRemoteStation *station) const
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:311
virtual WifiRemoteStation * DoCreateStation(void) const
virtual bool IsLowLatency(void) const
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)
virtual void DoReportDataFailed(WifiRemoteStation *station)
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)
uint32_t GetNumberOfReceiveAntennas(const WifiRemoteStation *station) const
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
bool GetStbc(const WifiRemoteStation *station) const
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)
static TypeId GetTypeId(void)
Hold an unsigned integer type.
Definition: uinteger.h:46
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
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)
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)
bool GetShortGuardInterval(const WifiRemoteStation *station) const
virtual void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)
uint32_t GetLongRetryCount(const WifiRemoteStation *station) const
#define NS_LOG_DEBUG(msg)
Definition: log.h:255
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
implement the CARA rate control algorithmImplement the CARA algorithm from: J. Kim, S. Kim, S. Choi, and D. Qiao. "CARA: Collision-Aware Rate Adaptation for IEEE 802.11 WLANs."
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)
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.