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