author | Edvin Močibob <edvin.mocibob@gmail.com> |
Sat, 20 Apr 2013 00:30:06 +0200 | |
changeset 9705 | 43fa2408aa05 |
parent 7385 | 10beb0e53130 |
child 9894 | ac4e52a91d5d |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7141
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
4342 | 2 |
/* |
3 |
* Copyright (c) 2004,2005,2006 INRIA |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
4342 | 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" |
|
6065 | 24 |
#include "ns3/double.h" |
25 |
#include "ns3/uinteger.h" |
|
4342 | 26 |
#include "ns3/simulator.h" |
27 |
||
28 |
NS_LOG_COMPONENT_DEFINE ("Cara"); |
|
29 |
||
30 |
||
31 |
namespace ns3 { |
|
32 |
||
6065 | 33 |
struct CaraWifiRemoteStation : public WifiRemoteStation |
4342 | 34 |
{ |
6065 | 35 |
uint32_t m_timer; |
36 |
uint32_t m_success; |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
37 |
uint32_t m_failed; |
6065 | 38 |
uint32_t m_rate; |
39 |
}; |
|
4342 | 40 |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
41 |
NS_OBJECT_ENSURE_REGISTERED (CaraWifiManager); |
4342 | 42 |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
43 |
TypeId |
4342 | 44 |
CaraWifiManager::GetTypeId (void) |
45 |
{ |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
46 |
static TypeId tid = TypeId ("ns3::CaraWifiManager") |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
47 |
.SetParent<WifiRemoteStationManager> () |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
48 |
.AddConstructor<CaraWifiManager> () |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
49 |
.AddAttribute ("ProbeThreshold", |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
50 |
"The number of consecutive transmissions failure to activate the RTS probe.", |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
51 |
UintegerValue (1), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
52 |
MakeUintegerAccessor (&CaraWifiManager::m_probeThreshold), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
53 |
MakeUintegerChecker<uint32_t> ()) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
54 |
.AddAttribute ("FailureThreshold", |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
55 |
"The number of consecutive transmissions failure to decrease the rate.", |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
56 |
UintegerValue (2), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
57 |
MakeUintegerAccessor (&CaraWifiManager::m_failureThreshold), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
58 |
MakeUintegerChecker<uint32_t> ()) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
59 |
.AddAttribute ("SuccessThreshold", |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
60 |
"The minimum number of sucessfull transmissions to try a new rate.", |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
61 |
UintegerValue (10), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
62 |
MakeUintegerAccessor (&CaraWifiManager::m_successThreshold), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
63 |
MakeUintegerChecker<uint32_t> ()) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
64 |
.AddAttribute ("Timeout", |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
65 |
"The 'timer' in the CARA algorithm", |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
66 |
UintegerValue (15), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
67 |
MakeUintegerAccessor (&CaraWifiManager::m_timerTimeout), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
68 |
MakeUintegerChecker<uint32_t> ()) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
69 |
; |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
70 |
return tid; |
4342 | 71 |
} |
72 |
||
73 |
CaraWifiManager::CaraWifiManager () |
|
74 |
: WifiRemoteStationManager () |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
75 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
76 |
NS_LOG_FUNCTION (this); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
77 |
} |
4342 | 78 |
CaraWifiManager::~CaraWifiManager () |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
79 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
80 |
NS_LOG_FUNCTION (this); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
81 |
} |
4342 | 82 |
|
83 |
WifiRemoteStation * |
|
6065 | 84 |
CaraWifiManager::DoCreateStation (void) const |
85 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
86 |
NS_LOG_FUNCTION (this); |
6065 | 87 |
CaraWifiRemoteStation *station = new CaraWifiRemoteStation (); |
88 |
station->m_rate = 0; |
|
89 |
station->m_success = 0; |
|
90 |
station->m_failed = 0; |
|
91 |
station->m_timer = 0; |
|
92 |
return station; |
|
93 |
} |
|
94 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
95 |
void |
6065 | 96 |
CaraWifiManager::DoReportRtsFailed (WifiRemoteStation *st) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
97 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
98 |
NS_LOG_FUNCTION (this << st); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
99 |
} |
6065 | 100 |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
101 |
void |
6065 | 102 |
CaraWifiManager::DoReportDataFailed (WifiRemoteStation *st) |
103 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
104 |
NS_LOG_FUNCTION (this << st); |
6065 | 105 |
CaraWifiRemoteStation *station = (CaraWifiRemoteStation *) st; |
106 |
station->m_timer++; |
|
107 |
station->m_failed++; |
|
108 |
station->m_success = 0; |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
109 |
if (station->m_failed >= m_failureThreshold) |
6065 | 110 |
{ |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
111 |
NS_LOG_DEBUG ("self=" << station << " dec rate"); |
6065 | 112 |
if (station->m_rate != 0) |
113 |
{ |
|
114 |
station->m_rate--; |
|
115 |
} |
|
116 |
station->m_failed = 0; |
|
117 |
station->m_timer = 0; |
|
118 |
} |
|
119 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
120 |
void |
6065 | 121 |
CaraWifiManager::DoReportRxOk (WifiRemoteStation *st, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
122 |
double rxSnr, WifiMode txMode) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
123 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
124 |
NS_LOG_FUNCTION (this << st << rxSnr << txMode); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
125 |
} |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
126 |
void |
6065 | 127 |
CaraWifiManager::DoReportRtsOk (WifiRemoteStation *st, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
128 |
double ctsSnr, WifiMode ctsMode, double rtsSnr) |
6065 | 129 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
130 |
NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
131 |
NS_LOG_DEBUG ("self=" << st << " rts ok"); |
6065 | 132 |
} |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
133 |
void |
6065 | 134 |
CaraWifiManager::DoReportDataOk (WifiRemoteStation *st, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
135 |
double ackSnr, WifiMode ackMode, double dataSnr) |
4342 | 136 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
137 |
NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); |
6065 | 138 |
CaraWifiRemoteStation *station = (CaraWifiRemoteStation *) st; |
139 |
station->m_timer++; |
|
140 |
station->m_success++; |
|
141 |
station->m_failed = 0; |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
142 |
NS_LOG_DEBUG ("self=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer); |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
143 |
if ((station->m_success == m_successThreshold |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
144 |
|| station->m_timer >= m_timerTimeout)) |
6065 | 145 |
{ |
146 |
if (station->m_rate < GetNSupported (station) - 1) |
|
147 |
{ |
|
148 |
station->m_rate++; |
|
149 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
150 |
NS_LOG_DEBUG ("self=" << station << " inc rate=" << station->m_rate); |
6065 | 151 |
station->m_timer = 0; |
152 |
station->m_success = 0; |
|
153 |
} |
|
154 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
155 |
void |
6065 | 156 |
CaraWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
157 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
158 |
NS_LOG_FUNCTION (this << st); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
159 |
} |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
160 |
void |
6065 | 161 |
CaraWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
162 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
163 |
NS_LOG_FUNCTION (this << st); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
164 |
} |
6065 | 165 |
|
166 |
WifiMode |
|
167 |
CaraWifiManager::DoGetDataMode (WifiRemoteStation *st, |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
168 |
uint32_t size) |
6065 | 169 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
170 |
NS_LOG_FUNCTION (this << st << size); |
6065 | 171 |
CaraWifiRemoteStation *station = (CaraWifiRemoteStation *) st; |
172 |
return GetSupported (station, station->m_rate); |
|
173 |
} |
|
174 |
WifiMode |
|
175 |
CaraWifiManager::DoGetRtsMode (WifiRemoteStation *st) |
|
176 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
177 |
NS_LOG_FUNCTION (this << st); |
6065 | 178 |
// XXX: we could/should implement the Arf algorithm for |
179 |
// RTS only by picking a single rate within the BasicRateSet. |
|
180 |
return GetSupported (st, 0); |
|
181 |
} |
|
182 |
||
183 |
bool |
|
184 |
CaraWifiManager::DoNeedRts (WifiRemoteStation *st, |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
185 |
Ptr<const Packet> packet, bool normally) |
6065 | 186 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
187 |
NS_LOG_FUNCTION (this << st << normally); |
6065 | 188 |
CaraWifiRemoteStation *station = (CaraWifiRemoteStation *) st; |
189 |
return normally || station->m_failed >= m_probeThreshold; |
|
190 |
} |
|
191 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
192 |
bool |
6065 | 193 |
CaraWifiManager::IsLowLatency (void) const |
194 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
195 |
NS_LOG_FUNCTION (this); |
6065 | 196 |
return true; |
4342 | 197 |
} |
198 |
||
199 |
} // namespace ns3 |