LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2014 Universidad de la República - Uruguay | 3 * Copyright (c) 2014 Universidad de la República - Uruguay |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Matias Richart <mrichart@fing.edu.uy> | 18 * Author: Matias Richart <mrichart@fing.edu.uy> |
19 */ | 19 */ |
20 | 20 |
| 21 #include "ns3/log.h" |
| 22 #include "ns3/uinteger.h" |
| 23 #include "ns3/data-rate.h" |
21 #include "aparf-wifi-manager.h" | 24 #include "aparf-wifi-manager.h" |
22 #include "wifi-phy.h" | 25 #include "wifi-phy.h" |
23 #include "ns3/log.h" | |
24 #include "ns3/uinteger.h" | |
25 | 26 |
26 #define Min(a,b) ((a < b) ? a : b) | 27 #define Min(a,b) ((a < b) ? a : b) |
27 | 28 |
28 namespace ns3 { | 29 namespace ns3 { |
29 | 30 |
30 NS_LOG_COMPONENT_DEFINE ("AparfWifiManager"); | 31 NS_LOG_COMPONENT_DEFINE ("AparfWifiManager"); |
31 | 32 |
32 /** | 33 /** |
33 * Hold per-remote-station state for APARF Wifi manager. | 34 * Hold per-remote-station state for APARF Wifi manager. |
34 * | 35 * |
35 * This struct extends from WifiRemoteStation struct to hold additional | 36 * This struct extends from WifiRemoteStation struct to hold additional |
36 * information required by the APARF Wifi manager | 37 * information required by the APARF Wifi manager |
37 */ | 38 */ |
38 struct | 39 struct |
39 AparfWifiRemoteStation : public WifiRemoteStation | 40 AparfWifiRemoteStation : public WifiRemoteStation |
40 { | 41 { |
41 uint32_t m_nSuccess; //!< Number of successful transmission a
ttempts. | 42 uint32_t m_nSuccess; //!< Number of successful transmission a
ttempts. |
42 uint32_t m_nFailed; //!< Number of failed transmission attem
pts. | 43 uint32_t m_nFailed; //!< Number of failed transmission attem
pts. |
43 uint32_t m_pCount; //!< Number of power changes. | 44 uint32_t m_pCount; //!< Number of power changes. |
44 uint32_t m_successThreshold; //!< The minimum number of successful tr
ansmissions to try a new power or rate. | 45 uint32_t m_successThreshold; //!< The minimum number of successful tr
ansmissions to try a new power or rate. |
45 uint32_t m_failThreshold; //!< The minimum number of failed transm
issions to try a new power or rate. | 46 uint32_t m_failThreshold; //!< The minimum number of failed transm
issions to try a new power or rate. |
46 uint32_t m_prevRateIndex; //!< Rate index of the previous transmis
sion. | 47 uint8_t m_prevRateIndex; //!< Rate index of the previous transmis
sion. |
47 uint32_t m_rateIndex; //!< Current rate index. | 48 uint8_t m_rateIndex; //!< Current rate index. |
48 uint32_t m_critRateIndex; //!< Critical rate. | 49 uint8_t m_critRateIndex; //!< Critical rate. |
49 uint8_t m_prevPowerLevel; //!< Power level of the previous transmi
ssion. | 50 uint8_t m_prevPowerLevel; //!< Power level of the previous transmi
ssion. |
50 uint8_t m_powerLevel; //!< Current power level. | 51 uint8_t m_powerLevel; //!< Current power level. |
51 uint32_t m_nSupported; //!< Number of supported rates by the re
mote station. | 52 uint32_t m_nSupported; //!< Number of supported rates by the re
mote station. |
52 bool m_initialized; //!< For initializing variables. | 53 bool m_initialized; //!< For initializing variables. |
53 AparfWifiManager::State m_aparfState; //!< The estimated state of the channel. | 54 AparfWifiManager::State m_aparfState; //!< The estimated state of the channel. |
54 }; | 55 }; |
55 | 56 |
56 NS_OBJECT_ENSURE_REGISTERED (AparfWifiManager); | 57 NS_OBJECT_ENSURE_REGISTERED (AparfWifiManager); |
57 | 58 |
58 TypeId | 59 TypeId |
(...skipping 20 matching lines...) Expand all Loading... |
79 MakeUintegerChecker<uint32_t> ()) | 80 MakeUintegerChecker<uint32_t> ()) |
80 .AddAttribute ("PowerThreshold", | 81 .AddAttribute ("PowerThreshold", |
81 "The maximum number of power changes.", | 82 "The maximum number of power changes.", |
82 UintegerValue (10), | 83 UintegerValue (10), |
83 MakeUintegerAccessor (&AparfWifiManager::m_powerMax), | 84 MakeUintegerAccessor (&AparfWifiManager::m_powerMax), |
84 MakeUintegerChecker<uint32_t> ()) | 85 MakeUintegerChecker<uint32_t> ()) |
85 .AddAttribute ("PowerDecrementStep", | 86 .AddAttribute ("PowerDecrementStep", |
86 "Step size for decrement the power.", | 87 "Step size for decrement the power.", |
87 UintegerValue (1), | 88 UintegerValue (1), |
88 MakeUintegerAccessor (&AparfWifiManager::m_powerDec), | 89 MakeUintegerAccessor (&AparfWifiManager::m_powerDec), |
89 MakeUintegerChecker<uint32_t> ()) | 90 MakeUintegerChecker<uint8_t> ()) |
90 .AddAttribute ("PowerIncrementStep", | 91 .AddAttribute ("PowerIncrementStep", |
91 "Step size for increment the power.", | 92 "Step size for increment the power.", |
92 UintegerValue (1), | 93 UintegerValue (1), |
93 MakeUintegerAccessor (&AparfWifiManager::m_powerInc), | 94 MakeUintegerAccessor (&AparfWifiManager::m_powerInc), |
94 MakeUintegerChecker<uint32_t> ()) | 95 MakeUintegerChecker<uint8_t> ()) |
95 .AddAttribute ("RateDecrementStep", | 96 .AddAttribute ("RateDecrementStep", |
96 "Step size for decrement the rate.", | 97 "Step size for decrement the rate.", |
97 UintegerValue (1), | 98 UintegerValue (1), |
98 MakeUintegerAccessor (&AparfWifiManager::m_rateDec), | 99 MakeUintegerAccessor (&AparfWifiManager::m_rateDec), |
99 MakeUintegerChecker<uint32_t> ()) | 100 MakeUintegerChecker<uint8_t> ()) |
100 .AddAttribute ("RateIncrementStep", | 101 .AddAttribute ("RateIncrementStep", |
101 "Step size for increment the rate.", | 102 "Step size for increment the rate.", |
102 UintegerValue (1), | 103 UintegerValue (1), |
103 MakeUintegerAccessor (&AparfWifiManager::m_rateInc), | 104 MakeUintegerAccessor (&AparfWifiManager::m_rateInc), |
104 MakeUintegerChecker<uint32_t> ()) | 105 MakeUintegerChecker<uint8_t> ()) |
105 .AddTraceSource ("PowerChange", | 106 .AddTraceSource ("PowerChange", |
106 "The transmission power has change", | 107 "The transmission power has change", |
107 MakeTraceSourceAccessor (&AparfWifiManager::m_powerChange), | 108 MakeTraceSourceAccessor (&AparfWifiManager::m_powerChange), |
108 "ns3::WifiRemoteStationManager::PowerChangeTracedCallback") | 109 "ns3::WifiRemoteStationManager::PowerChangeTracedCallback") |
109 .AddTraceSource ("RateChange", | 110 .AddTraceSource ("RateChange", |
110 "The transmission rate has change", | 111 "The transmission rate has change", |
111 MakeTraceSourceAccessor (&AparfWifiManager::m_rateChange), | 112 MakeTraceSourceAccessor (&AparfWifiManager::m_rateChange), |
112 "ns3::WifiRemoteStationManager::RateChangeTracedCallback") | 113 "ns3::WifiRemoteStationManager::RateChangeTracedCallback") |
113 ; | 114 ; |
114 return tid; | 115 return tid; |
115 } | 116 } |
116 | 117 |
117 AparfWifiManager::AparfWifiManager () | 118 AparfWifiManager::AparfWifiManager () |
118 { | 119 { |
119 NS_LOG_FUNCTION (this); | 120 NS_LOG_FUNCTION (this); |
120 } | 121 } |
121 | 122 |
122 AparfWifiManager::~AparfWifiManager () | 123 AparfWifiManager::~AparfWifiManager () |
123 { | 124 { |
124 NS_LOG_FUNCTION (this); | 125 NS_LOG_FUNCTION (this); |
125 } | 126 } |
126 | 127 |
127 void | 128 void |
128 AparfWifiManager::SetupPhy (const Ptr<WifiPhy> phy) | 129 AparfWifiManager::SetupPhy (const Ptr<WifiPhy> phy) |
129 { | 130 { |
130 m_minPower = static_cast<uint32_t>(phy->GetTxPowerStart ()); | 131 NS_LOG_FUNCTION (this << phy); |
131 m_maxPower = static_cast<uint32_t>(phy->GetTxPowerEnd ()); | 132 m_minPower = static_cast<uint8_t> (phy->GetTxPowerStart ()); |
| 133 m_maxPower = static_cast<uint8_t> (phy->GetTxPowerEnd ()); |
132 WifiRemoteStationManager::SetupPhy (phy); | 134 WifiRemoteStationManager::SetupPhy (phy); |
133 } | 135 } |
134 | 136 |
135 WifiRemoteStation * | 137 WifiRemoteStation * |
136 AparfWifiManager::DoCreateStation (void) const | 138 AparfWifiManager::DoCreateStation (void) const |
137 { | 139 { |
138 NS_LOG_FUNCTION (this); | 140 NS_LOG_FUNCTION (this); |
139 AparfWifiRemoteStation *station = new AparfWifiRemoteStation (); | 141 AparfWifiRemoteStation *station = new AparfWifiRemoteStation (); |
140 | 142 |
141 station->m_successThreshold = m_succesMax1; | 143 station->m_successThreshold = m_succesMax1; |
142 station->m_failThreshold = m_failMax; | 144 station->m_failThreshold = m_failMax; |
143 station->m_nSuccess = 0; | 145 station->m_nSuccess = 0; |
144 station->m_nFailed = 0; | 146 station->m_nFailed = 0; |
145 station->m_pCount = 0; | 147 station->m_pCount = 0; |
146 station->m_aparfState = AparfWifiManager::High; | 148 station->m_aparfState = AparfWifiManager::High; |
147 station->m_initialized = false; | 149 station->m_initialized = false; |
148 | 150 |
149 NS_LOG_DEBUG ("create station=" << station << ", rate=" << station->m_rateInde
x | 151 NS_LOG_DEBUG ("create station=" << station << ", rate=" << +station->m_rateInd
ex |
150 << ", power=" << (int)station->m_powerLevel); | 152 << ", power=" << +station->m_powerLevel); |
151 | 153 |
152 return station; | 154 return station; |
153 } | 155 } |
154 | 156 |
155 void | 157 void |
156 AparfWifiManager::CheckInit (AparfWifiRemoteStation *station) | 158 AparfWifiManager::CheckInit (AparfWifiRemoteStation *station) |
157 { | 159 { |
158 if (!station->m_initialized) | 160 if (!station->m_initialized) |
159 { | 161 { |
160 station->m_nSupported = GetNSupported (station); | 162 station->m_nSupported = GetNSupported (station); |
161 station->m_rateIndex = station->m_nSupported - 1; | 163 station->m_rateIndex = static_cast<uint8_t> (station->m_nSupported - 1); |
162 station->m_prevRateIndex = station->m_nSupported - 1; | 164 station->m_prevRateIndex = static_cast<uint8_t> (station->m_nSupported - 1
); |
163 station->m_powerLevel = static_cast<uint8_t>(m_maxPower); | 165 station->m_powerLevel = m_maxPower; |
164 station->m_prevPowerLevel = static_cast<uint8_t>(m_maxPower); | 166 station->m_prevPowerLevel = m_maxPower; |
165 station->m_critRateIndex = 0; | 167 station->m_critRateIndex = 0; |
166 WifiMode mode = GetSupported (station, station->m_rateIndex); | 168 WifiMode mode = GetSupported (station, station->m_rateIndex); |
167 uint8_t channelWidth = GetChannelWidth (station); | 169 uint16_t channelWidth = GetChannelWidth (station); |
168 DataRate rate = DataRate (mode.GetDataRate (channelWidth)); | 170 DataRate rate = DataRate (mode.GetDataRate (channelWidth)); |
169 double power = GetPhy ()->GetPowerDbm (static_cast<uint8_t>(m_maxPower)); | 171 double power = GetPhy ()->GetPowerDbm (m_maxPower); |
170 m_powerChange (power, power, station->m_state->m_address); | 172 m_powerChange (power, power, station->m_state->m_address); |
171 m_rateChange (rate, rate, station->m_state->m_address); | 173 m_rateChange (rate, rate, station->m_state->m_address); |
172 station->m_initialized = true; | 174 station->m_initialized = true; |
173 } | 175 } |
174 } | 176 } |
175 | 177 |
176 void AparfWifiManager::DoReportRtsFailed (WifiRemoteStation *station) | 178 void AparfWifiManager::DoReportRtsFailed (WifiRemoteStation *station) |
177 { | 179 { |
178 NS_LOG_FUNCTION (this << station); | 180 NS_LOG_FUNCTION (this << station); |
179 } | 181 } |
(...skipping 29 matching lines...) Expand all Loading... |
209 station->m_critRateIndex = station->m_rateIndex; | 211 station->m_critRateIndex = station->m_rateIndex; |
210 if (station->m_rateIndex != 0) | 212 if (station->m_rateIndex != 0) |
211 { | 213 { |
212 NS_LOG_DEBUG ("station=" << station << " dec rate"); | 214 NS_LOG_DEBUG ("station=" << station << " dec rate"); |
213 station->m_rateIndex -= m_rateDec; | 215 station->m_rateIndex -= m_rateDec; |
214 } | 216 } |
215 } | 217 } |
216 else | 218 else |
217 { | 219 { |
218 NS_LOG_DEBUG ("station=" << station << " inc power"); | 220 NS_LOG_DEBUG ("station=" << station << " inc power"); |
219 station->m_powerLevel += static_cast<uint8_t>(m_powerInc); | 221 station->m_powerLevel += m_powerInc; |
220 } | 222 } |
221 } | 223 } |
222 } | 224 } |
223 | 225 |
224 void | 226 void |
225 AparfWifiManager::DoReportRxOk (WifiRemoteStation *station, double rxSnr, WifiMo
de txMode) | 227 AparfWifiManager::DoReportRxOk (WifiRemoteStation *station, double rxSnr, WifiMo
de txMode) |
226 { | 228 { |
227 NS_LOG_FUNCTION (this << station << rxSnr << txMode); | 229 NS_LOG_FUNCTION (this << station << rxSnr << txMode); |
228 } | 230 } |
229 | 231 |
230 void | 232 void |
231 AparfWifiManager::DoReportRtsOk (WifiRemoteStation *station, double ctsSnr, | 233 AparfWifiManager::DoReportRtsOk (WifiRemoteStation *station, double ctsSnr, |
232 WifiMode ctsMode, double rtsSnr) | 234 WifiMode ctsMode, double rtsSnr) |
233 { | 235 { |
234 NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr); | 236 NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr); |
235 NS_LOG_DEBUG ("station=" << station << " rts ok"); | |
236 } | 237 } |
237 | 238 |
238 void | 239 void |
239 AparfWifiManager::DoReportDataOk (WifiRemoteStation *st, double ackSnr, | 240 AparfWifiManager::DoReportDataOk (WifiRemoteStation *st, double ackSnr, |
240 WifiMode ackMode, double dataSnr) | 241 WifiMode ackMode, double dataSnr) |
241 { | 242 { |
242 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); | 243 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); |
243 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; | 244 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; |
244 CheckInit (station); | 245 CheckInit (station); |
245 station->m_nSuccess++; | 246 station->m_nSuccess++; |
246 station->m_nFailed = 0; | 247 station->m_nFailed = 0; |
247 NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_nSucc
ess << ", rate=" << station->m_rateIndex << ", power=" << (int)station->m_powerL
evel); | 248 NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_nSucc
ess << ", rate=" << +station->m_rateIndex << ", power=" << +station->m_powerLeve
l); |
248 | 249 |
249 if ((station->m_aparfState == AparfWifiManager::High) && (station->m_nSuccess
>= station->m_successThreshold)) | 250 if ((station->m_aparfState == AparfWifiManager::High) && (station->m_nSuccess
>= station->m_successThreshold)) |
250 { | 251 { |
251 station->m_aparfState = AparfWifiManager::Spread; | 252 station->m_aparfState = AparfWifiManager::Spread; |
252 } | 253 } |
253 else if ((station->m_aparfState == AparfWifiManager::Low) && (station->m_nSucc
ess >= station->m_successThreshold)) | 254 else if ((station->m_aparfState == AparfWifiManager::Low) && (station->m_nSucc
ess >= station->m_successThreshold)) |
254 { | 255 { |
255 station->m_aparfState = AparfWifiManager::Spread; | 256 station->m_aparfState = AparfWifiManager::Spread; |
256 } | 257 } |
257 else if (station->m_aparfState == AparfWifiManager::Spread) | 258 else if (station->m_aparfState == AparfWifiManager::Spread) |
258 { | 259 { |
259 station->m_aparfState = AparfWifiManager::High; | 260 station->m_aparfState = AparfWifiManager::High; |
260 station->m_successThreshold = m_succesMax1; | 261 station->m_successThreshold = m_succesMax1; |
261 } | 262 } |
262 | 263 |
263 if (station->m_nSuccess == station->m_successThreshold) | 264 if (station->m_nSuccess == station->m_successThreshold) |
264 { | 265 { |
265 station->m_nSuccess = 0; | 266 station->m_nSuccess = 0; |
266 station->m_nFailed = 0; | 267 station->m_nFailed = 0; |
267 if (station->m_rateIndex == (station->m_state->m_operationalRateSet.size (
) - 1)) | 268 if (station->m_rateIndex == (station->m_state->m_operationalRateSet.size (
) - 1)) |
268 { | 269 { |
269 if (station->m_powerLevel != m_minPower) | 270 if (station->m_powerLevel != m_minPower) |
270 { | 271 { |
271 NS_LOG_DEBUG ("station=" << station << " dec power"); | 272 NS_LOG_DEBUG ("station=" << station << " dec power"); |
272 station->m_powerLevel -= static_cast<uint8_t>(m_powerDec); | 273 station->m_powerLevel -= m_powerDec; |
273 } | 274 } |
274 } | 275 } |
275 else | 276 else |
276 { | 277 { |
277 if (station->m_critRateIndex == 0) | 278 if (station->m_critRateIndex == 0) |
278 { | 279 { |
279 if (station->m_rateIndex != (station->m_state->m_operationalRateSe
t.size () - 1)) | 280 if (station->m_rateIndex != (station->m_state->m_operationalRateSe
t.size () - 1)) |
280 { | 281 { |
281 NS_LOG_DEBUG ("station=" << station << " inc rate"); | 282 NS_LOG_DEBUG ("station=" << station << " inc rate"); |
282 station->m_rateIndex += m_rateInc; | 283 station->m_rateIndex += m_rateInc; |
283 } | 284 } |
284 } | 285 } |
285 else | 286 else |
286 { | 287 { |
287 if (station->m_pCount == m_powerMax) | 288 if (station->m_pCount == m_powerMax) |
288 { | 289 { |
289 station->m_powerLevel = static_cast<uint8_t>(m_maxPower); | 290 station->m_powerLevel = m_maxPower; |
290 station->m_rateIndex = station->m_critRateIndex; | 291 station->m_rateIndex = station->m_critRateIndex; |
291 station->m_pCount = 0; | 292 station->m_pCount = 0; |
292 station->m_critRateIndex = 0; | 293 station->m_critRateIndex = 0; |
293 } | 294 } |
294 else | 295 else |
295 { | 296 { |
296 if (station->m_powerLevel != m_minPower) | 297 if (station->m_powerLevel != m_minPower) |
297 { | 298 { |
298 station->m_powerLevel -= static_cast<uint8_t>(m_powerDec); | 299 station->m_powerLevel -= m_powerDec; |
299 station->m_pCount++; | 300 station->m_pCount++; |
300 } | 301 } |
301 } | 302 } |
302 } | 303 } |
303 } | 304 } |
304 } | 305 } |
305 } | 306 } |
306 | 307 |
307 void | 308 void |
308 AparfWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station) | 309 AparfWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station) |
309 { | 310 { |
310 NS_LOG_FUNCTION (this << station); | 311 NS_LOG_FUNCTION (this << station); |
311 } | 312 } |
312 | 313 |
313 void | 314 void |
314 AparfWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) | 315 AparfWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) |
315 { | 316 { |
316 NS_LOG_FUNCTION (this << station); | 317 NS_LOG_FUNCTION (this << station); |
317 } | 318 } |
318 | 319 |
319 WifiTxVector | 320 WifiTxVector |
320 AparfWifiManager::DoGetDataTxVector (WifiRemoteStation *st) | 321 AparfWifiManager::DoGetDataTxVector (WifiRemoteStation *st) |
321 { | 322 { |
322 NS_LOG_FUNCTION (this << st); | 323 NS_LOG_FUNCTION (this << st); |
323 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; | 324 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; |
324 uint32_t channelWidth = GetChannelWidth (station); | 325 uint16_t channelWidth = GetChannelWidth (station); |
325 if (channelWidth > 20 && channelWidth != 22) | 326 if (channelWidth > 20 && channelWidth != 22) |
326 { | 327 { |
327 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 328 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
328 channelWidth = 20; | 329 channelWidth = 20; |
329 } | 330 } |
330 CheckInit (station); | 331 CheckInit (station); |
331 WifiMode mode = GetSupported (station, station->m_rateIndex); | 332 WifiMode mode = GetSupported (station, station->m_rateIndex); |
332 DataRate rate = DataRate (mode.GetDataRate (static_cast<uint8_t>(channelWidth)
)); | 333 DataRate rate = DataRate (mode.GetDataRate (channelWidth)); |
333 DataRate prevRate = DataRate (GetSupported (station, station->m_prevRateIndex)
.GetDataRate (static_cast<uint8_t>(channelWidth))); | 334 DataRate prevRate = DataRate (GetSupported (station, station->m_prevRateIndex)
.GetDataRate (channelWidth)); |
334 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); | 335 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); |
335 double prevPower = GetPhy ()->GetPowerDbm (station->m_prevPowerLevel); | 336 double prevPower = GetPhy ()->GetPowerDbm (station->m_prevPowerLevel); |
336 if (station->m_prevPowerLevel != station->m_powerLevel) | 337 if (station->m_prevPowerLevel != station->m_powerLevel) |
337 { | 338 { |
338 m_powerChange (prevPower, power, station->m_state->m_address); | 339 m_powerChange (prevPower, power, station->m_state->m_address); |
339 station->m_prevPowerLevel = station->m_powerLevel; | 340 station->m_prevPowerLevel = station->m_powerLevel; |
340 } | 341 } |
341 if (station->m_prevRateIndex != station->m_rateIndex) | 342 if (station->m_prevRateIndex != station->m_rateIndex) |
342 { | 343 { |
343 m_rateChange (prevRate, rate, station->m_state->m_address); | 344 m_rateChange (prevRate, rate, station->m_state->m_address); |
344 station->m_prevRateIndex = station->m_rateIndex; | 345 station->m_prevRateIndex = station->m_rateIndex; |
345 } | 346 } |
346 return WifiTxVector (mode, station->m_powerLevel, static_cast<uint8_t>(GetLong
RetryCount (station)), GetPreambleForTransmission (mode, GetAddress (st)), 800,
1, 1, 0, (uint8_t)channelWidth, GetAggregation (station), false); | 347 return WifiTxVector (mode, station->m_powerLevel, GetPreambleForTransmission (
mode, GetAddress (st)), 800, 1, 1, 0, channelWidth, GetAggregation (station), fa
lse); |
347 } | 348 } |
348 | 349 |
349 WifiTxVector | 350 WifiTxVector |
350 AparfWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) | 351 AparfWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) |
351 { | 352 { |
352 NS_LOG_FUNCTION (this << st); | 353 NS_LOG_FUNCTION (this << st); |
353 /// \todo we could/should implement the Arf algorithm for | 354 /// \todo we could/should implement the Arf algorithm for |
354 /// RTS only by picking a single rate within the BasicRateSet. | 355 /// RTS only by picking a single rate within the BasicRateSet. |
355 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; | 356 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; |
356 uint32_t channelWidth = GetChannelWidth (station); | 357 uint16_t channelWidth = GetChannelWidth (station); |
357 if (channelWidth > 20 && channelWidth != 22) | 358 if (channelWidth > 20 && channelWidth != 22) |
358 { | 359 { |
359 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 360 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
360 channelWidth = 20; | 361 channelWidth = 20; |
361 } | 362 } |
362 WifiTxVector rtsTxVector; | 363 WifiTxVector rtsTxVector; |
363 WifiMode mode; | 364 WifiMode mode; |
364 if (GetUseNonErpProtection () == false) | 365 if (GetUseNonErpProtection () == false) |
365 { | 366 { |
366 mode = GetSupported (station, 0); | 367 mode = GetSupported (station, 0); |
367 } | 368 } |
368 else | 369 else |
369 { | 370 { |
370 mode = GetNonErpSupported (station, 0); | 371 mode = GetNonErpSupported (station, 0); |
371 } | 372 } |
372 rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), static_cast<uint8
_t>(GetShortRetryCount (station)), GetPreambleForTransmission (mode, GetAddress
(st)), 800, 1, 1, 0, (uint8_t)channelWidth, GetAggregation (station), false); | 373 rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTra
nsmission (mode, GetAddress (st)), 800, 1, 1, 0, channelWidth, GetAggregation (s
tation), false); |
373 return rtsTxVector; | 374 return rtsTxVector; |
374 } | 375 } |
375 | 376 |
376 bool | 377 bool |
377 AparfWifiManager::IsLowLatency (void) const | 378 AparfWifiManager::IsLowLatency (void) const |
378 { | 379 { |
379 NS_LOG_FUNCTION (this); | |
380 return true; | 380 return true; |
381 } | 381 } |
382 | 382 |
383 void | 383 void |
384 AparfWifiManager::SetHtSupported (bool enable) | 384 AparfWifiManager::SetHtSupported (bool enable) |
385 { | 385 { |
386 //HT is not supported by this algorithm. | 386 //HT is not supported by this algorithm. |
387 if (enable) | 387 if (enable) |
388 { | 388 { |
389 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HT rat
es"); | 389 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HT rat
es"); |
(...skipping 14 matching lines...) Expand all Loading... |
404 AparfWifiManager::SetHeSupported (bool enable) | 404 AparfWifiManager::SetHeSupported (bool enable) |
405 { | 405 { |
406 //HE is not supported by this algorithm. | 406 //HE is not supported by this algorithm. |
407 if (enable) | 407 if (enable) |
408 { | 408 { |
409 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); | 409 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); |
410 } | 410 } |
411 } | 411 } |
412 | 412 |
413 } //namespace ns3 | 413 } //namespace ns3 |
LEFT | RIGHT |