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) 2017 Universidad de la República - Uruguay | 3 * Copyright (c) 2017 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 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 struct RrpaaWifiRemoteStation : public WifiRemoteStation | 43 struct RrpaaWifiRemoteStation : public WifiRemoteStation |
44 { | 44 { |
45 uint32_t m_counter; //!< Counter for transmission attempts. | 45 uint32_t m_counter; //!< Counter for transmission attempts. |
46 uint32_t m_nFailed; //!< Number of failed transmission attempts. | 46 uint32_t m_nFailed; //!< Number of failed transmission attempts. |
47 uint32_t m_adaptiveRtsWnd; //!< Window size for the Adaptive RTS mechanism
. | 47 uint32_t m_adaptiveRtsWnd; //!< Window size for the Adaptive RTS mechanism
. |
48 uint32_t m_rtsCounter; //!< Counter for RTS transmission attempts. | 48 uint32_t m_rtsCounter; //!< Counter for RTS transmission attempts. |
49 Time m_lastReset; //!< Time of the last reset. | 49 Time m_lastReset; //!< Time of the last reset. |
50 bool m_adaptiveRtsOn; //!< Check if Adaptive RTS mechanism is on. | 50 bool m_adaptiveRtsOn; //!< Check if Adaptive RTS mechanism is on. |
51 bool m_lastFrameFail; //!< Flag if the last frame sent has failed. | 51 bool m_lastFrameFail; //!< Flag if the last frame sent has failed. |
52 bool m_initialized; //!< For initializing variables. | 52 bool m_initialized; //!< For initializing variables. |
53 | |
54 uint8_t m_nRate; //!< Number of supported rates. | 53 uint8_t m_nRate; //!< Number of supported rates. |
55 | |
56 uint8_t m_prevRateIndex; //!< Rate index of the previous transmission. | 54 uint8_t m_prevRateIndex; //!< Rate index of the previous transmission. |
57 uint8_t m_rateIndex; //!< Current rate index. | 55 uint8_t m_rateIndex; //!< Current rate index. |
58 uint8_t m_prevPowerLevel; //!< Power level of the previous transmission. | 56 uint8_t m_prevPowerLevel; //!< Power level of the previous transmission. |
59 uint8_t m_powerLevel; //!< Current power level. | 57 uint8_t m_powerLevel; //!< Current power level. |
60 | |
61 | |
62 RrpaaThresholdsTable m_thresholds; //!< Rrpaa thresholds for this station. | 58 RrpaaThresholdsTable m_thresholds; //!< Rrpaa thresholds for this station. |
63 | |
64 RrpaaProbabilitiesTable m_pdTable; //!< Probability table for power and rate
changes. | 59 RrpaaProbabilitiesTable m_pdTable; //!< Probability table for power and rate
changes. |
65 }; | 60 }; |
66 | 61 |
67 NS_OBJECT_ENSURE_REGISTERED (RrpaaWifiManager); | 62 NS_OBJECT_ENSURE_REGISTERED (RrpaaWifiManager); |
68 | 63 |
69 TypeId | 64 TypeId |
70 RrpaaWifiManager::GetTypeId (void) | 65 RrpaaWifiManager::GetTypeId (void) |
71 { | 66 { |
72 static TypeId tid = TypeId ("ns3::RrpaaWifiManager") | 67 static TypeId tid = TypeId ("ns3::RrpaaWifiManager") |
73 .SetParent<WifiRemoteStationManager> () | 68 .SetParent<WifiRemoteStationManager> () |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 230 |
236 void | 231 void |
237 RrpaaWifiManager::CheckInit (RrpaaWifiRemoteStation *station) | 232 RrpaaWifiManager::CheckInit (RrpaaWifiRemoteStation *station) |
238 { | 233 { |
239 NS_LOG_FUNCTION (this << station); | 234 NS_LOG_FUNCTION (this << station); |
240 if (!station->m_initialized) | 235 if (!station->m_initialized) |
241 { | 236 { |
242 //Note: we appear to be doing late initialization of the table | 237 //Note: we appear to be doing late initialization of the table |
243 //to make sure that the set of supported rates has been initialized | 238 //to make sure that the set of supported rates has been initialized |
244 //before we perform our own initialization. | 239 //before we perform our own initialization. |
245 station->m_nRate = static_cast<uint8_t>(GetNSupported (station)); | 240 station->m_nRate = GetNSupported (station); |
246 //Initialize at minimal rate and maximal power. | 241 //Initialize at minimal rate and maximal power. |
247 station->m_prevRateIndex = 0; | 242 station->m_prevRateIndex = 0; |
248 station->m_rateIndex = 0; | 243 station->m_rateIndex = 0; |
249 station->m_prevPowerLevel = m_maxPowerLevel; | 244 station->m_prevPowerLevel = m_maxPowerLevel; |
250 station->m_powerLevel = m_maxPowerLevel; | 245 station->m_powerLevel = m_maxPowerLevel; |
251 WifiMode mode = GetSupported (station, 0); | 246 WifiMode mode = GetSupported (station, 0); |
252 uint8_t channelWidth = GetChannelWidth (station); | 247 uint8_t channelWidth = GetChannelWidth (station); |
253 DataRate rate = DataRate (mode.GetDataRate (channelWidth)); | 248 DataRate rate = DataRate (mode.GetDataRate (channelWidth)); |
254 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); | 249 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); |
255 m_rateChange (rate, rate, station->m_state->m_address); | 250 m_rateChange (rate, rate, station->m_state->m_address); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 RrpaaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) | 372 RrpaaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) |
378 { | 373 { |
379 NS_LOG_FUNCTION (this << st); | 374 NS_LOG_FUNCTION (this << st); |
380 } | 375 } |
381 | 376 |
382 WifiTxVector | 377 WifiTxVector |
383 RrpaaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) | 378 RrpaaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) |
384 { | 379 { |
385 NS_LOG_FUNCTION (this << st); | 380 NS_LOG_FUNCTION (this << st); |
386 RrpaaWifiRemoteStation *station = (RrpaaWifiRemoteStation *) st; | 381 RrpaaWifiRemoteStation *station = (RrpaaWifiRemoteStation *) st; |
387 uint32_t channelWidth = GetChannelWidth (station); | 382 uint8_t channelWidth = GetChannelWidth (station); |
388 if (channelWidth > 20 && channelWidth != 22) | 383 if (channelWidth > 20 && channelWidth != 22) |
389 { | 384 { |
390 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 385 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
391 channelWidth = 20; | 386 channelWidth = 20; |
392 } | 387 } |
393 CheckInit (station); | 388 CheckInit (station); |
394 WifiMode mode = GetSupported (station, station->m_rateIndex); | 389 WifiMode mode = GetSupported (station, station->m_rateIndex); |
395 DataRate rate = DataRate (mode.GetDataRate (static_cast<uint8_t>(channelWidth)
)); | 390 DataRate rate = DataRate (mode.GetDataRate (static_cast<uint8_t>(channelWidth)
)); |
396 DataRate prevRate = DataRate (GetSupported (station, station->m_prevRateIndex)
.GetDataRate (static_cast<uint8_t>(channelWidth))); | 391 DataRate prevRate = DataRate (GetSupported (station, station->m_prevRateIndex)
.GetDataRate (static_cast<uint8_t>(channelWidth))); |
397 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); | 392 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); |
398 double prevPower = GetPhy ()->GetPowerDbm (station->m_prevPowerLevel); | 393 double prevPower = GetPhy ()->GetPowerDbm (station->m_prevPowerLevel); |
399 if (station->m_prevRateIndex != station->m_rateIndex) | 394 if (station->m_prevRateIndex != station->m_rateIndex) |
400 { | 395 { |
401 m_rateChange (prevRate, rate, station->m_state->m_address); | 396 m_rateChange (prevRate, rate, station->m_state->m_address); |
402 station->m_prevRateIndex = station->m_rateIndex; | 397 station->m_prevRateIndex = station->m_rateIndex; |
403 } | 398 } |
404 if (station->m_prevPowerLevel != station->m_powerLevel) | 399 if (station->m_prevPowerLevel != station->m_powerLevel) |
405 { | 400 { |
406 m_powerChange (prevPower, power, station->m_state->m_address); | 401 m_powerChange (prevPower, power, station->m_state->m_address); |
407 station->m_prevPowerLevel = station->m_powerLevel; | 402 station->m_prevPowerLevel = station->m_powerLevel; |
408 } | 403 } |
409 return WifiTxVector (mode, station->m_powerLevel, static_cast<uint8_t>(GetLong
RetryCount (station)), GetPreambleForTransmission (mode, GetAddress (station)),
800, 1, 1, 0, (uint8_t)channelWidth, GetAggregation (station), false); | 404 return WifiTxVector (mode, station->m_powerLevel, static_cast<uint8_t>(GetLong
RetryCount (station)), GetPreambleForTransmission (mode, GetAddress (station)),
800, 1, 1, 0, (uint8_t)channelWidth, GetAggregation (station), false); |
410 } | 405 } |
411 WifiTxVector | 406 WifiTxVector |
412 RrpaaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) | 407 RrpaaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) |
413 { | 408 { |
414 NS_LOG_FUNCTION (this << st); | 409 NS_LOG_FUNCTION (this << st); |
415 RrpaaWifiRemoteStation *station = (RrpaaWifiRemoteStation *) st; | 410 RrpaaWifiRemoteStation *station = (RrpaaWifiRemoteStation *) st; |
416 uint32_t channelWidth = GetChannelWidth (station); | 411 uint8_t channelWidth = GetChannelWidth (station); |
417 if (channelWidth > 20 && channelWidth != 22) | 412 if (channelWidth > 20 && channelWidth != 22) |
418 { | 413 { |
419 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 414 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
420 channelWidth = 20; | 415 channelWidth = 20; |
421 } | 416 } |
422 WifiTxVector rtsTxVector; | 417 WifiTxVector rtsTxVector; |
423 WifiMode mode; | 418 WifiMode mode; |
424 if (GetUseNonErpProtection () == false) | 419 if (GetUseNonErpProtection () == false) |
425 { | 420 { |
426 mode = GetSupported (station, 0); | 421 mode = GetSupported (station, 0); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 station->m_adaptiveRtsOn = true; | 584 station->m_adaptiveRtsOn = true; |
590 station->m_rtsCounter--; | 585 station->m_rtsCounter--; |
591 } | 586 } |
592 else | 587 else |
593 { | 588 { |
594 station->m_adaptiveRtsOn = false; | 589 station->m_adaptiveRtsOn = false; |
595 } | 590 } |
596 } | 591 } |
597 | 592 |
598 WifiRrpaaThresholds | 593 WifiRrpaaThresholds |
599 RrpaaWifiManager::GetThresholds (RrpaaWifiRemoteStation *station, | 594 RrpaaWifiManager::GetThresholds (RrpaaWifiRemoteStation *station, uint8_t rate)
const |
600 uint32_t rate) const | 595 { |
601 { | 596 NS_LOG_FUNCTION (this << station << static_cast<uint16_t>(rate)); |
602 NS_LOG_FUNCTION (this << station << rate); | |
603 WifiMode mode = GetSupported (station, rate); | 597 WifiMode mode = GetSupported (station, rate); |
604 return GetThresholds (station, mode); | 598 return GetThresholds (station, mode); |
605 } | 599 } |
606 | 600 |
607 bool | 601 bool |
608 RrpaaWifiManager::IsLowLatency (void) const | 602 RrpaaWifiManager::IsLowLatency (void) const |
609 { | 603 { |
610 NS_LOG_FUNCTION (this); | 604 NS_LOG_FUNCTION (this); |
611 return true; | 605 return true; |
612 } | 606 } |
(...skipping 24 matching lines...) Expand all Loading... |
637 RrpaaWifiManager::SetHeSupported (bool enable) | 631 RrpaaWifiManager::SetHeSupported (bool enable) |
638 { | 632 { |
639 //HE is not supported by this algorithm. | 633 //HE is not supported by this algorithm. |
640 if (enable) | 634 if (enable) |
641 { | 635 { |
642 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); | 636 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); |
643 } | 637 } |
644 } | 638 } |
645 | 639 |
646 } // namespace ns3 | 640 } // namespace ns3 |
LEFT | RIGHT |