author | Peter D. Barnes, Jr. <barnes26@llnl.gov> |
Thu, 14 Nov 2013 16:58:28 -0800 | |
changeset 10410 | 4d4eb8097fa3 |
parent 10139 | 17a71cd49da3 |
child 10483 | e3a02ed14587 |
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 |
||
10139 | 28 |
#define Min(a,b) ((a < b) ? a : b) |
29 |
||
4342 | 30 |
NS_LOG_COMPONENT_DEFINE ("Cara"); |
31 |
||
32 |
||
33 |
namespace ns3 { |
|
34 |
||
6065 | 35 |
struct CaraWifiRemoteStation : public WifiRemoteStation |
4342 | 36 |
{ |
6065 | 37 |
uint32_t m_timer; |
38 |
uint32_t m_success; |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
39 |
uint32_t m_failed; |
6065 | 40 |
uint32_t m_rate; |
41 |
}; |
|
4342 | 42 |
|
10410
4d4eb8097fa3
doxygen] Suppress "warning: Member NS_OBJECT_ENSURE_REGISTERED is not documented"
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10139
diff
changeset
|
43 |
NS_OBJECT_ENSURE_REGISTERED (CaraWifiManager) |
4d4eb8097fa3
doxygen] Suppress "warning: Member NS_OBJECT_ENSURE_REGISTERED is not documented"
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10139
diff
changeset
|
44 |
; |
4342 | 45 |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
46 |
TypeId |
4342 | 47 |
CaraWifiManager::GetTypeId (void) |
48 |
{ |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
49 |
static TypeId tid = TypeId ("ns3::CaraWifiManager") |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
50 |
.SetParent<WifiRemoteStationManager> () |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
51 |
.AddConstructor<CaraWifiManager> () |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
52 |
.AddAttribute ("ProbeThreshold", |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
53 |
"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
|
54 |
UintegerValue (1), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
55 |
MakeUintegerAccessor (&CaraWifiManager::m_probeThreshold), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
56 |
MakeUintegerChecker<uint32_t> ()) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
57 |
.AddAttribute ("FailureThreshold", |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
58 |
"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
|
59 |
UintegerValue (2), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
60 |
MakeUintegerAccessor (&CaraWifiManager::m_failureThreshold), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
61 |
MakeUintegerChecker<uint32_t> ()) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
62 |
.AddAttribute ("SuccessThreshold", |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
63 |
"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
|
64 |
UintegerValue (10), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
65 |
MakeUintegerAccessor (&CaraWifiManager::m_successThreshold), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
66 |
MakeUintegerChecker<uint32_t> ()) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
67 |
.AddAttribute ("Timeout", |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
68 |
"The 'timer' in the CARA algorithm", |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
69 |
UintegerValue (15), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
70 |
MakeUintegerAccessor (&CaraWifiManager::m_timerTimeout), |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
71 |
MakeUintegerChecker<uint32_t> ()) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
72 |
; |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
73 |
return tid; |
4342 | 74 |
} |
75 |
||
76 |
CaraWifiManager::CaraWifiManager () |
|
77 |
: WifiRemoteStationManager () |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
78 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
79 |
NS_LOG_FUNCTION (this); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
80 |
} |
4342 | 81 |
CaraWifiManager::~CaraWifiManager () |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
82 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
83 |
NS_LOG_FUNCTION (this); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
84 |
} |
4342 | 85 |
|
86 |
WifiRemoteStation * |
|
6065 | 87 |
CaraWifiManager::DoCreateStation (void) const |
88 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
89 |
NS_LOG_FUNCTION (this); |
6065 | 90 |
CaraWifiRemoteStation *station = new CaraWifiRemoteStation (); |
91 |
station->m_rate = 0; |
|
92 |
station->m_success = 0; |
|
93 |
station->m_failed = 0; |
|
94 |
station->m_timer = 0; |
|
95 |
return station; |
|
96 |
} |
|
97 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
98 |
void |
6065 | 99 |
CaraWifiManager::DoReportRtsFailed (WifiRemoteStation *st) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
100 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
101 |
NS_LOG_FUNCTION (this << st); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
102 |
} |
6065 | 103 |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
104 |
void |
6065 | 105 |
CaraWifiManager::DoReportDataFailed (WifiRemoteStation *st) |
106 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
107 |
NS_LOG_FUNCTION (this << st); |
6065 | 108 |
CaraWifiRemoteStation *station = (CaraWifiRemoteStation *) st; |
109 |
station->m_timer++; |
|
110 |
station->m_failed++; |
|
111 |
station->m_success = 0; |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
112 |
if (station->m_failed >= m_failureThreshold) |
6065 | 113 |
{ |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
114 |
NS_LOG_DEBUG ("self=" << station << " dec rate"); |
6065 | 115 |
if (station->m_rate != 0) |
116 |
{ |
|
117 |
station->m_rate--; |
|
118 |
} |
|
119 |
station->m_failed = 0; |
|
120 |
station->m_timer = 0; |
|
121 |
} |
|
122 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
123 |
void |
6065 | 124 |
CaraWifiManager::DoReportRxOk (WifiRemoteStation *st, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
125 |
double rxSnr, WifiMode txMode) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
126 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
127 |
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
|
128 |
} |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
129 |
void |
6065 | 130 |
CaraWifiManager::DoReportRtsOk (WifiRemoteStation *st, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
131 |
double ctsSnr, WifiMode ctsMode, double rtsSnr) |
6065 | 132 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
133 |
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
|
134 |
NS_LOG_DEBUG ("self=" << st << " rts ok"); |
6065 | 135 |
} |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
136 |
void |
6065 | 137 |
CaraWifiManager::DoReportDataOk (WifiRemoteStation *st, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
138 |
double ackSnr, WifiMode ackMode, double dataSnr) |
4342 | 139 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
140 |
NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); |
6065 | 141 |
CaraWifiRemoteStation *station = (CaraWifiRemoteStation *) st; |
142 |
station->m_timer++; |
|
143 |
station->m_success++; |
|
144 |
station->m_failed = 0; |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
145 |
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
|
146 |
if ((station->m_success == m_successThreshold |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
147 |
|| station->m_timer >= m_timerTimeout)) |
6065 | 148 |
{ |
149 |
if (station->m_rate < GetNSupported (station) - 1) |
|
150 |
{ |
|
151 |
station->m_rate++; |
|
152 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
153 |
NS_LOG_DEBUG ("self=" << station << " inc rate=" << station->m_rate); |
6065 | 154 |
station->m_timer = 0; |
155 |
station->m_success = 0; |
|
156 |
} |
|
157 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
158 |
void |
6065 | 159 |
CaraWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
160 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
161 |
NS_LOG_FUNCTION (this << st); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
162 |
} |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
163 |
void |
6065 | 164 |
CaraWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
165 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
166 |
NS_LOG_FUNCTION (this << st); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
167 |
} |
6065 | 168 |
|
10139 | 169 |
WifiTxVector |
170 |
CaraWifiManager::DoGetDataTxVector (WifiRemoteStation *st, |
|
171 |
uint32_t size) |
|
6065 | 172 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
173 |
NS_LOG_FUNCTION (this << st << size); |
6065 | 174 |
CaraWifiRemoteStation *station = (CaraWifiRemoteStation *) st; |
10139 | 175 |
return WifiTxVector (GetSupported (station, station->m_rate), GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetShortGuardInterval (station), Min (GetNumberOfReceiveAntennas (station),GetNumberOfTransmitAntennas()), GetNumberOfTransmitAntennas (station), GetStbc (station)); |
6065 | 176 |
} |
10139 | 177 |
WifiTxVector |
178 |
CaraWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) |
|
6065 | 179 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
180 |
NS_LOG_FUNCTION (this << st); |
9894
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9705
diff
changeset
|
181 |
/// \todo we could/should implement the Arf algorithm for |
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9705
diff
changeset
|
182 |
/// RTS only by picking a single rate within the BasicRateSet. |
10139 | 183 |
return WifiTxVector (GetSupported (st, 0), GetDefaultTxPowerLevel (), GetLongRetryCount (st), GetShortGuardInterval (st), Min (GetNumberOfReceiveAntennas (st),GetNumberOfTransmitAntennas()), GetNumberOfTransmitAntennas (st), GetStbc (st)); |
6065 | 184 |
} |
185 |
||
186 |
bool |
|
187 |
CaraWifiManager::DoNeedRts (WifiRemoteStation *st, |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
188 |
Ptr<const Packet> packet, bool normally) |
6065 | 189 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
190 |
NS_LOG_FUNCTION (this << st << normally); |
6065 | 191 |
CaraWifiRemoteStation *station = (CaraWifiRemoteStation *) st; |
192 |
return normally || station->m_failed >= m_probeThreshold; |
|
193 |
} |
|
194 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
195 |
bool |
6065 | 196 |
CaraWifiManager::IsLowLatency (void) const |
197 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
198 |
NS_LOG_FUNCTION (this); |
6065 | 199 |
return true; |
4342 | 200 |
} |
201 |
||
202 |
} // namespace ns3 |