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) 2004,2005,2006 INRIA | 3 * Copyright (c) 2004,2005,2006 INRIA |
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 |
(...skipping 30 matching lines...) Expand all Loading... |
41 struct RraaWifiRemoteStation : public WifiRemoteStation | 41 struct RraaWifiRemoteStation : public WifiRemoteStation |
42 { | 42 { |
43 uint32_t m_counter; //!< Counter for transmission attempts. | 43 uint32_t m_counter; //!< Counter for transmission attempts. |
44 uint32_t m_nFailed; //!< Number of failed transmission attempts. | 44 uint32_t m_nFailed; //!< Number of failed transmission attempts. |
45 uint32_t m_adaptiveRtsWnd; //!< Window size for the Adaptive RTS mechanism
. | 45 uint32_t m_adaptiveRtsWnd; //!< Window size for the Adaptive RTS mechanism
. |
46 uint32_t m_rtsCounter; //!< Counter for RTS transmission attempts. | 46 uint32_t m_rtsCounter; //!< Counter for RTS transmission attempts. |
47 Time m_lastReset; //!< Time of the last reset. | 47 Time m_lastReset; //!< Time of the last reset. |
48 bool m_adaptiveRtsOn; //!< Check if Adaptive RTS mechanism is on. | 48 bool m_adaptiveRtsOn; //!< Check if Adaptive RTS mechanism is on. |
49 bool m_lastFrameFail; //!< Flag if the last frame sent has failed. | 49 bool m_lastFrameFail; //!< Flag if the last frame sent has failed. |
50 bool m_initialized; //!< For initializing variables. | 50 bool m_initialized; //!< For initializing variables. |
51 | 51 uint8_t m_nRate; //!< Number of supported rates. |
52 uint32_t m_nRate; //!< Number of supported rates. | 52 uint8_t m_rateIndex; //!< Current rate index. |
53 | |
54 uint32_t m_rateIndex; //!< Current rate index. | |
55 | 53 |
56 RraaThresholdsTable m_thresholds; //!< RRAA thresholds for this station. | 54 RraaThresholdsTable m_thresholds; //!< RRAA thresholds for this station. |
57 }; | 55 }; |
58 | 56 |
59 NS_OBJECT_ENSURE_REGISTERED (RraaWifiManager); | 57 NS_OBJECT_ENSURE_REGISTERED (RraaWifiManager); |
60 | 58 |
61 TypeId | 59 TypeId |
62 RraaWifiManager::GetTypeId (void) | 60 RraaWifiManager::GetTypeId (void) |
63 { | 61 { |
64 static TypeId tid = TypeId ("ns3::RraaWifiManager") | 62 static TypeId tid = TypeId ("ns3::RraaWifiManager") |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 198 |
201 void | 199 void |
202 RraaWifiManager::CheckInit (RraaWifiRemoteStation *station) | 200 RraaWifiManager::CheckInit (RraaWifiRemoteStation *station) |
203 { | 201 { |
204 NS_LOG_FUNCTION (this << station); | 202 NS_LOG_FUNCTION (this << station); |
205 if (!station->m_initialized) | 203 if (!station->m_initialized) |
206 { | 204 { |
207 //Note: we appear to be doing late initialization of the table | 205 //Note: we appear to be doing late initialization of the table |
208 //to make sure that the set of supported rates has been initialized | 206 //to make sure that the set of supported rates has been initialized |
209 //before we perform our own initialization. | 207 //before we perform our own initialization. |
210 station->m_nRate = GetNSupported (station); | 208 station->m_nRate = static_cast<uint8_t>(GetNSupported (station)); |
211 //Initialize at maximal rate | 209 //Initialize at maximal rate |
212 station->m_rateIndex = GetMaxRate (station); | 210 station->m_rateIndex = GetMaxRate (station); |
213 | 211 |
214 station->m_initialized = true; | 212 station->m_initialized = true; |
215 | 213 |
216 station->m_thresholds = RraaThresholdsTable (station->m_nRate); | 214 station->m_thresholds = RraaThresholdsTable (station->m_nRate); |
217 InitThresholds (station); | 215 InitThresholds (station); |
218 ResetCountersBasic (station); | 216 ResetCountersBasic (station); |
219 } | 217 } |
220 } | 218 } |
221 | 219 |
222 void | 220 void |
223 RraaWifiManager::InitThresholds (RraaWifiRemoteStation *station) | 221 RraaWifiManager::InitThresholds (RraaWifiRemoteStation *station) |
224 { | 222 { |
225 NS_LOG_FUNCTION (this << station); | 223 NS_LOG_FUNCTION (this << station); |
226 NS_LOG_DEBUG ("InitThresholds = " << station); | 224 NS_LOG_DEBUG ("InitThresholds = " << station); |
227 | 225 |
228 double nextCritical = 0; | 226 double nextCritical = 0; |
229 double nextMtl = 0; | 227 double nextMtl = 0; |
230 double mtl = 0; | 228 double mtl = 0; |
231 double ori = 0; | 229 double ori = 0; |
232 for (uint32_t i = 0; i < station->m_nRate; i++) | 230 for (uint8_t i = 0; i < station->m_nRate; i++) |
233 { | 231 { |
234 WifiMode mode = GetSupported (station, i); | 232 WifiMode mode = GetSupported (station, i); |
235 Time totalTxTime = GetCalcTxTime (mode) + m_sifs + m_difs; | 233 Time totalTxTime = GetCalcTxTime (mode) + m_sifs + m_difs; |
236 if (i == GetMaxRate (station)) | 234 if (i == GetMaxRate (station)) |
237 { | 235 { |
238 ori = 0; | 236 ori = 0; |
239 } | 237 } |
240 else | 238 else |
241 { | 239 { |
242 WifiMode nextMode = GetSupported (station, i + 1); | 240 WifiMode nextMode = GetSupported (station, i + 1); |
(...skipping 18 matching lines...) Expand all Loading... |
261 | 259 |
262 void | 260 void |
263 RraaWifiManager::ResetCountersBasic (RraaWifiRemoteStation *station) | 261 RraaWifiManager::ResetCountersBasic (RraaWifiRemoteStation *station) |
264 { | 262 { |
265 NS_LOG_FUNCTION (this << station); | 263 NS_LOG_FUNCTION (this << station); |
266 station->m_nFailed = 0; | 264 station->m_nFailed = 0; |
267 station->m_counter = GetThresholds (station, station->m_rateIndex).m_ewnd; | 265 station->m_counter = GetThresholds (station, station->m_rateIndex).m_ewnd; |
268 station->m_lastReset = Simulator::Now (); | 266 station->m_lastReset = Simulator::Now (); |
269 } | 267 } |
270 | 268 |
271 uint32_t | 269 uint8_t |
272 RraaWifiManager::GetMaxRate (RraaWifiRemoteStation *station) | 270 RraaWifiManager::GetMaxRate (RraaWifiRemoteStation *station) const |
273 { | 271 { |
274 return station->m_nRate - 1; | 272 return station->m_nRate - 1; |
275 } | 273 } |
276 | 274 |
277 void | 275 void |
278 RraaWifiManager::DoReportRtsFailed (WifiRemoteStation *st) | 276 RraaWifiManager::DoReportRtsFailed (WifiRemoteStation *st) |
279 { | 277 { |
280 NS_LOG_FUNCTION (this << st); | 278 NS_LOG_FUNCTION (this << st); |
281 } | 279 } |
282 | 280 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 RraaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) | 327 RraaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) |
330 { | 328 { |
331 NS_LOG_FUNCTION (this << st); | 329 NS_LOG_FUNCTION (this << st); |
332 } | 330 } |
333 | 331 |
334 WifiTxVector | 332 WifiTxVector |
335 RraaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) | 333 RraaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) |
336 { | 334 { |
337 NS_LOG_FUNCTION (this << st); | 335 NS_LOG_FUNCTION (this << st); |
338 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; | 336 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; |
339 uint32_t channelWidth = GetChannelWidth (station); | 337 uint8_t channelWidth = GetChannelWidth (station); |
340 if (channelWidth > 20 && channelWidth != 22) | 338 if (channelWidth > 20 && channelWidth != 22) |
341 { | 339 { |
342 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 340 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
343 channelWidth = 20; | 341 channelWidth = 20; |
344 } | 342 } |
345 CheckInit (station); | 343 CheckInit (station); |
346 WifiMode mode = GetSupported (station, station->m_rateIndex); | 344 WifiMode mode = GetSupported (station, station->m_rateIndex); |
347 if (m_currentRate != mode.GetDataRate (static_cast<uint8_t>(channelWidth))) | 345 if (m_currentRate != mode.GetDataRate (static_cast<uint8_t>(channelWidth))) |
348 { | 346 { |
349 NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (static_cast<uint8_t>(c
hannelWidth))); | 347 NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (static_cast<uint8_t>(c
hannelWidth))); |
350 m_currentRate = mode.GetDataRate (static_cast<uint8_t>(channelWidth)); | 348 m_currentRate = mode.GetDataRate (static_cast<uint8_t>(channelWidth)); |
351 } | 349 } |
352 return WifiTxVector (mode, GetDefaultTxPowerLevel (), static_cast<uint8_t>(Get
LongRetryCount (station)), GetPreambleForTransmission (mode, GetAddress (station
)), 800, 1, 1, 0, (uint8_t)channelWidth, GetAggregation (station), false); | 350 return WifiTxVector (mode, GetDefaultTxPowerLevel (), static_cast<uint8_t>(Get
LongRetryCount (station)), GetPreambleForTransmission (mode, GetAddress (station
)), 800, 1, 1, 0, (uint8_t)channelWidth, GetAggregation (station), false); |
353 } | 351 } |
354 | 352 |
355 WifiTxVector | 353 WifiTxVector |
356 RraaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) | 354 RraaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) |
357 { | 355 { |
358 NS_LOG_FUNCTION (this << st); | 356 NS_LOG_FUNCTION (this << st); |
359 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; | 357 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; |
360 uint32_t channelWidth = GetChannelWidth (station); | 358 uint8_t channelWidth = GetChannelWidth (station); |
361 if (channelWidth > 20 && channelWidth != 22) | 359 if (channelWidth > 20 && channelWidth != 22) |
362 { | 360 { |
363 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 361 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
364 channelWidth = 20; | 362 channelWidth = 20; |
365 } | 363 } |
366 WifiTxVector rtsTxVector; | 364 WifiTxVector rtsTxVector; |
367 WifiMode mode; | 365 WifiMode mode; |
368 if (GetUseNonErpProtection () == false) | 366 if (GetUseNonErpProtection () == false) |
369 { | 367 { |
370 mode = GetSupported (station, 0); | 368 mode = GetSupported (station, 0); |
(...skipping 30 matching lines...) Expand all Loading... |
401 { | 399 { |
402 ResetCountersBasic (station); | 400 ResetCountersBasic (station); |
403 } | 401 } |
404 } | 402 } |
405 | 403 |
406 void | 404 void |
407 RraaWifiManager::RunBasicAlgorithm (RraaWifiRemoteStation *station) | 405 RraaWifiManager::RunBasicAlgorithm (RraaWifiRemoteStation *station) |
408 { | 406 { |
409 NS_LOG_FUNCTION (this << station); | 407 NS_LOG_FUNCTION (this << station); |
410 WifiRraaThresholds thresholds = GetThresholds (station, station->m_rateIndex); | 408 WifiRraaThresholds thresholds = GetThresholds (station, station->m_rateIndex); |
411 double ploss = (double) station->m_nFailed / (double) thresholds.m_ewnd; | 409 double ploss = (static_cast<double> (station->m_nFailed) / thresholds.m_ewnd); |
412 if (station->m_counter == 0 | 410 if (station->m_counter == 0 |
413 || ploss > thresholds.m_mtl) | 411 || ploss > thresholds.m_mtl) |
414 { | 412 { |
415 if (ploss > thresholds.m_mtl) | 413 if (ploss > thresholds.m_mtl) |
416 { | 414 { |
417 station->m_rateIndex--; | 415 station->m_rateIndex--; |
418 } | 416 } |
419 else if (station->m_rateIndex < GetMaxRate (station) | 417 else if (station->m_rateIndex < GetMaxRate (station) |
420 && ploss < thresholds.m_ori) | 418 && ploss < thresholds.m_ori) |
421 { | 419 { |
(...skipping 23 matching lines...) Expand all Loading... |
445 station->m_adaptiveRtsOn = true; | 443 station->m_adaptiveRtsOn = true; |
446 station->m_rtsCounter--; | 444 station->m_rtsCounter--; |
447 } | 445 } |
448 else | 446 else |
449 { | 447 { |
450 station->m_adaptiveRtsOn = false; | 448 station->m_adaptiveRtsOn = false; |
451 } | 449 } |
452 } | 450 } |
453 | 451 |
454 WifiRraaThresholds | 452 WifiRraaThresholds |
455 RraaWifiManager::GetThresholds (RraaWifiRemoteStation *station, | 453 RraaWifiManager::GetThresholds (RraaWifiRemoteStation *station, uint8_t rate) co
nst |
456 uint32_t rate) const | 454 { |
457 { | 455 NS_LOG_FUNCTION (this << station << static_cast<uint16_t>(rate)); |
458 NS_LOG_FUNCTION (this << station << rate); | |
459 WifiMode mode = GetSupported (station, rate); | 456 WifiMode mode = GetSupported (station, rate); |
460 return GetThresholds (station, mode); | 457 return GetThresholds (station, mode); |
461 } | 458 } |
462 | 459 |
463 bool | 460 bool |
464 RraaWifiManager::IsLowLatency (void) const | 461 RraaWifiManager::IsLowLatency (void) const |
465 { | 462 { |
466 return true; | 463 return true; |
467 } | 464 } |
468 | 465 |
(...skipping 21 matching lines...) Expand all Loading... |
490 RraaWifiManager::SetHeSupported (bool enable) | 487 RraaWifiManager::SetHeSupported (bool enable) |
491 { | 488 { |
492 //HE is not supported by this algorithm. | 489 //HE is not supported by this algorithm. |
493 if (enable) | 490 if (enable) |
494 { | 491 { |
495 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); | 492 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); |
496 } | 493 } |
497 } | 494 } |
498 | 495 |
499 } //namespace ns3 | 496 } //namespace ns3 |
LEFT | RIGHT |