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