diff --git a/RELEASE_NOTES b/RELEASE_NOTES index bc9f763b6..4f906d32f 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -88,6 +88,7 @@ Bugs fixed - Bug 2628 - Simulation crashes because of an out of range TID - Bug 2629 - Assert failure in MinstrelHtWifiManager::GetLowestIndex - Bug 2647 - ideal-wifi-manager-example crashes when NSS > 1 +- Bug 2654 - Rraa wifi manager cannot be used with 802.11b - Bug 2655 - A-MPDU simulation using TCP sometimes fails with message "Packet has no Traffic ID" - Bug 2660 - TrafficControlHelper::Default should not configure internal queue sizes diff --git a/src/wifi/model/rraa-wifi-manager.cc b/src/wifi/model/rraa-wifi-manager.cc index 451672beb..cb3319faf 100644 --- a/src/wifi/model/rraa-wifi-manager.cc +++ b/src/wifi/model/rraa-wifi-manager.cc @@ -19,6 +19,9 @@ */ #include "rraa-wifi-manager.h" +#include "yans-wifi-phy.h" +#include "wifi-phy.h" +#include "wifi-mac.h" #include "ns3/log.h" #include "ns3/boolean.h" #include "ns3/double.h" @@ -39,15 +42,20 @@ NS_LOG_COMPONENT_DEFINE ("RraaWifiManager"); */ struct RraaWifiRemoteStation : public WifiRemoteStation { - uint32_t m_counter; ///< counter - uint32_t m_failed; ///< failed - uint32_t m_rtsWnd; ///< RTS windows - uint32_t m_rtsCounter; ///< RTS counter - Time m_lastReset; ///< last reset - bool m_rtsOn; ///< RTS on - bool m_lastFrameFail; ///< last frame fail - bool m_initialized; ///< initialized - uint32_t m_rate; ///< rate + uint32_t m_counter; //!< Counter for transmission attempts. + uint32_t m_nFailed; //!< Number of failed transmission attempts. + uint32_t m_adaptiveRtsWnd; //!< Window size for the Adaptive RTS mechanism. + uint32_t m_rtsCounter; //!< Counter for RTS transmission attempts. + Time m_lastReset; //!< Time of the last reset. + bool m_adaptiveRtsOn; //!< Check if Adaptive RTS mechanism is on. + bool m_lastFrameFail; //!< Flag if the last frame sent has failed. + bool m_initialized; //!< For initializing variables. + + uint32_t m_nRate; //!< Number of supported rates. + + uint32_t m_rateIndex; //!< Current rate index. + + RraaThresholdsTable m_thresholds; //!< RRAA thresholds for this station. }; NS_OBJECT_ENSURE_REGISTERED (RraaWifiManager); @@ -65,120 +73,35 @@ RraaWifiManager::GetTypeId (void) MakeBooleanAccessor (&RraaWifiManager::m_basic), MakeBooleanChecker ()) .AddAttribute ("Timeout", - "Timeout for the RRAA BASIC loss estimaton block (s)", + "Timeout for the RRAA BASIC loss estimation block (s)", TimeValue (Seconds (0.05)), MakeTimeAccessor (&RraaWifiManager::m_timeout), MakeTimeChecker ()) - .AddAttribute ("ewndFor54mbps", - "ewnd parameter for 54 Mbs data mode", - UintegerValue (40), - MakeUintegerAccessor (&RraaWifiManager::m_ewndfor54), - MakeUintegerChecker ()) - .AddAttribute ("ewndFor48mbps", - "ewnd parameter for 48 Mbs data mode", - UintegerValue (40), - MakeUintegerAccessor (&RraaWifiManager::m_ewndfor48), - MakeUintegerChecker ()) - .AddAttribute ("ewndFor36mbps", - "ewnd parameter for 36 Mbs data mode", - UintegerValue (40), - MakeUintegerAccessor (&RraaWifiManager::m_ewndfor36), - MakeUintegerChecker ()) - .AddAttribute ("ewndFor24mbps", - "ewnd parameter for 24 Mbs data mode", - UintegerValue (40), - MakeUintegerAccessor (&RraaWifiManager::m_ewndfor24), - MakeUintegerChecker ()) - .AddAttribute ("ewndFor18mbps", - "ewnd parameter for 18 Mbs data mode", - UintegerValue (20), - MakeUintegerAccessor (&RraaWifiManager::m_ewndfor18), - MakeUintegerChecker ()) - .AddAttribute ("ewndFor12mbps", - "ewnd parameter for 12 Mbs data mode", - UintegerValue (20), - MakeUintegerAccessor (&RraaWifiManager::m_ewndfor12), - MakeUintegerChecker ()) - .AddAttribute ("ewndFor9mbps", - "ewnd parameter for 9 Mbs data mode", - UintegerValue (10), - MakeUintegerAccessor (&RraaWifiManager::m_ewndfor9), - MakeUintegerChecker ()) - .AddAttribute ("ewndFor6mbps", - "ewnd parameter for 6 Mbs data mode", - UintegerValue (6), - MakeUintegerAccessor (&RraaWifiManager::m_ewndfor6), - MakeUintegerChecker ()) - .AddAttribute ("poriFor48mbps", - "Pori parameter for 48 Mbs data mode", - DoubleValue (0.047), - MakeDoubleAccessor (&RraaWifiManager::m_porifor48), - MakeDoubleChecker ()) - .AddAttribute ("poriFor36mbps", - "Pori parameter for 36 Mbs data mode", - DoubleValue (0.115), - MakeDoubleAccessor (&RraaWifiManager::m_porifor36), - MakeDoubleChecker ()) - .AddAttribute ("poriFor24mbps", - "Pori parameter for 24 Mbs data mode", - DoubleValue (0.1681), - MakeDoubleAccessor (&RraaWifiManager::m_porifor24), - MakeDoubleChecker ()) - .AddAttribute ("poriFor18mbps", - "Pori parameter for 18 Mbs data mode", - DoubleValue (0.1325), - MakeDoubleAccessor (&RraaWifiManager::m_porifor18), - MakeDoubleChecker ()) - .AddAttribute ("poriFor12mbps", - "Pori parameter for 12 Mbs data mode", - DoubleValue (0.1861), - MakeDoubleAccessor (&RraaWifiManager::m_porifor12), - MakeDoubleChecker ()) - .AddAttribute ("poriFor9mbps", - "Pori parameter for 9 Mbs data mode", - DoubleValue (0.1434), - MakeDoubleAccessor (&RraaWifiManager::m_porifor9), - MakeDoubleChecker ()) - .AddAttribute ("poriFor6mbps", - "Pori parameter for 6 Mbs data mode", - DoubleValue (0.5), - MakeDoubleAccessor (&RraaWifiManager::m_porifor6), - MakeDoubleChecker ()) - .AddAttribute ("pmtlFor54mbps", - "Pmtl parameter for 54 Mbs data mode", - DoubleValue (0.094), - MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor54), - MakeDoubleChecker ()) - .AddAttribute ("pmtlFor48mbps", - "Pmtl parameter for 48 Mbs data mode", - DoubleValue (0.23), - MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor48), - MakeDoubleChecker ()) - .AddAttribute ("pmtlFor36mbps", - "Pmtl parameter for 36 Mbs data mode", - DoubleValue (0.3363), - MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor36), - MakeDoubleChecker ()) - .AddAttribute ("pmtlFor24mbps", - "Pmtl parameter for 24 Mbs data mode", - DoubleValue (0.265), - MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor24), - MakeDoubleChecker ()) - .AddAttribute ("pmtlFor18mbps", - "Pmtl parameter for 18 Mbs data mode", - DoubleValue (0.3722), - MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor18), - MakeDoubleChecker ()) - .AddAttribute ("pmtlFor12mbps", - "Pmtl parameter for 12 Mbs data mode", - DoubleValue (0.2868), - MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor12), - MakeDoubleChecker ()) - .AddAttribute ("pmtlFor9mbps", - "Pmtl parameter for 9 Mbs data mode", - DoubleValue (0.3932), - MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor9), - MakeDoubleChecker ()) + .AddAttribute ("FrameLength", + "The data frame length (in bytes) used for calculating mode TxTime.", + UintegerValue (1420), + MakeUintegerAccessor (&RraaWifiManager::m_frameLength), + MakeUintegerChecker ()) + .AddAttribute ("AckFrameLength", + "The ACK frame length (in bytes) used for calculating mode TxTime.", + UintegerValue (14), + MakeUintegerAccessor (&RraaWifiManager::m_ackLength), + MakeUintegerChecker ()) + .AddAttribute ("Alpha", + "Constant for calculating the MTL threshold.", + DoubleValue (1.25), + MakeDoubleAccessor (&RraaWifiManager::m_alpha), + MakeDoubleChecker (1)) + .AddAttribute ("Beta", + "Constant for calculating the ORI threshold.", + DoubleValue (2), + MakeDoubleAccessor (&RraaWifiManager::m_beta), + MakeDoubleChecker (1)) + .AddAttribute ("Tau", + "Constant for calculating the EWND size.", + DoubleValue (0.012), + MakeDoubleAccessor (&RraaWifiManager::m_tau), + MakeDoubleChecker (0)) .AddTraceSource ("Rate", "Traced value for rate changes (b/s)", MakeTraceSourceAccessor (&RraaWifiManager::m_currentRate), @@ -198,35 +121,157 @@ RraaWifiManager::~RraaWifiManager () { } +void +RraaWifiManager::SetupPhy (Ptr phy) +{ + NS_LOG_FUNCTION (this); + uint32_t nModes = phy->GetNModes (); + for (uint32_t i = 0; i < nModes; i++) + { + WifiMode mode = phy->GetMode (i); + WifiTxVector txVector; + txVector.SetMode (mode); + txVector.SetPreambleType (WIFI_PREAMBLE_LONG); + /* Calculate the TX Time of the data and the corresponding ACK*/ + Time dataTxTime = phy->CalculateTxDuration (m_frameLength, txVector, phy->GetFrequency ()); + Time ackTxTime = phy->CalculateTxDuration (m_ackLength, txVector, phy->GetFrequency ()); + NS_LOG_DEBUG ("Calculating TX times: Mode= " << mode << " DataTxTime= " << dataTxTime << " AckTxTime= " << ackTxTime); + AddCalcTxTime (mode, dataTxTime + ackTxTime); + } + WifiRemoteStationManager::SetupPhy (phy); +} + +void +RraaWifiManager::SetupMac (Ptr mac) +{ + NS_LOG_FUNCTION (this); + m_sifs = mac->GetSifs (); + m_difs = m_sifs + 2 * mac->GetSlot (); + WifiRemoteStationManager::SetupMac (mac); +} + +Time +RraaWifiManager::GetCalcTxTime (WifiMode mode) const +{ + NS_LOG_FUNCTION (this << mode); + for (TxTime::const_iterator i = m_calcTxTime.begin (); i != m_calcTxTime.end (); i++) + { + if (mode == i->second) + { + return i->first; + } + } + NS_ASSERT (false); + return Seconds (0); +} + +void +RraaWifiManager::AddCalcTxTime (WifiMode mode, Time t) +{ + NS_LOG_FUNCTION (this << mode << t); + m_calcTxTime.push_back (std::make_pair (t, mode)); +} + +WifiRraaThresholds +RraaWifiManager::GetThresholds (RraaWifiRemoteStation *station, WifiMode mode) const +{ + NS_LOG_FUNCTION (this << station << mode); + for (RraaThresholdsTable::const_iterator i = station->m_thresholds.begin (); i != station->m_thresholds.end (); i++) + { + if (mode == i->second) + { + return i->first; + } + } + NS_ASSERT (false); +} + WifiRemoteStation * RraaWifiManager::DoCreateStation (void) const { RraaWifiRemoteStation *station = new RraaWifiRemoteStation (); station->m_initialized = false; - station->m_rtsWnd = 0; + station->m_adaptiveRtsWnd = 0; station->m_rtsCounter = 0; - station->m_rtsOn = false; + station->m_adaptiveRtsOn = false; station->m_lastFrameFail = false; return station; } void -RraaWifiManager::ResetCountersBasic (RraaWifiRemoteStation *station) +RraaWifiManager::CheckInit (RraaWifiRemoteStation *station) { + NS_LOG_FUNCTION (this << station); if (!station->m_initialized) { - station->m_rate = GetMaxRate (station); + //Note: we appear to be doing late initialization of the table + //to make sure that the set of supported rates has been initialized + //before we perform our own initialization. + station->m_nRate = GetNSupported (station); + //Initialize at maximal rate + station->m_rateIndex = GetMaxRate(station); + station->m_initialized = true; + + station->m_thresholds = RraaThresholdsTable (station->m_nRate); + InitThresholds (station); + ResetCountersBasic (station); } - station->m_failed = 0; - station->m_counter = GetThresholds (station, station->m_rate).ewnd; +} + +void +RraaWifiManager::InitThresholds (RraaWifiRemoteStation *station) +{ + NS_LOG_FUNCTION (this << station); + NS_LOG_DEBUG ("InitThresholds = " << station); + + double nextCritical = 0; + double nextMtl = 0; + double mtl = 0; + double ori = 0; + for (uint32_t i = 0; i < station->m_nRate; i++) + { + WifiMode mode = GetSupported (station, i); + Time totalTxTime = GetCalcTxTime (mode) + m_sifs + m_difs; + if (i == GetMaxRate (station)) + { + ori = 0; + } + else + { + WifiMode nextMode = GetSupported (station, i + 1); + Time nextTotalTxTime = GetCalcTxTime (nextMode) + m_sifs + m_difs; + nextCritical = 1 - (nextTotalTxTime.GetSeconds () / totalTxTime.GetSeconds ()); + nextMtl = m_alpha * nextCritical; + ori = nextMtl / m_beta; + } + if (i == GetMinRate (station)) + { + mtl = 1; + } + WifiRraaThresholds th; + th.m_ewnd = ceil (m_tau / totalTxTime.GetSeconds ()); + th.m_ori = ori; + th.m_mtl = mtl; + station->m_thresholds.push_back (std::make_pair (th, mode)); + mtl = nextMtl; + NS_LOG_DEBUG (mode << " " << th.m_ewnd << " " << th.m_mtl << " " << th.m_ori); + } +} + +void +RraaWifiManager::ResetCountersBasic (RraaWifiRemoteStation *station) +{ + NS_LOG_FUNCTION (this << station); + station->m_nFailed = 0; + station->m_counter = GetThresholds (station, station->m_rateIndex).m_ewnd; station->m_lastReset = Simulator::Now (); } uint32_t RraaWifiManager::GetMaxRate (RraaWifiRemoteStation *station) { - return GetNSupported (station) - 1; + return station->m_nRate - 1; } uint32_t @@ -238,16 +283,18 @@ RraaWifiManager::GetMinRate (RraaWifiRemoteStation *station) void RraaWifiManager::DoReportRtsFailed (WifiRemoteStation *st) { + NS_LOG_FUNCTION (this << st); } void RraaWifiManager::DoReportDataFailed (WifiRemoteStation *st) { + NS_LOG_FUNCTION (this << st); RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; station->m_lastFrameFail = true; CheckTimeout (station); station->m_counter--; - station->m_failed++; + station->m_nFailed++; RunBasicAlgorithm (station); } @@ -255,12 +302,14 @@ void RraaWifiManager::DoReportRxOk (WifiRemoteStation *st, double rxSnr, WifiMode txMode) { + NS_LOG_FUNCTION (this << st << rxSnr << txMode); } void RraaWifiManager::DoReportRtsOk (WifiRemoteStation *st, double ctsSnr, WifiMode ctsMode, double rtsSnr) { + NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr); NS_LOG_DEBUG ("self=" << st << " rts ok"); } @@ -268,6 +317,7 @@ void RraaWifiManager::DoReportDataOk (WifiRemoteStation *st, double ackSnr, WifiMode ackMode, double dataSnr) { + NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; station->m_lastFrameFail = false; CheckTimeout (station); @@ -278,16 +328,19 @@ RraaWifiManager::DoReportDataOk (WifiRemoteStation *st, void RraaWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st) { + NS_LOG_FUNCTION (this << st); } void RraaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) { + NS_LOG_FUNCTION (this << st); } WifiTxVector RraaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) { + NS_LOG_FUNCTION (this << st); RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; uint32_t channelWidth = GetChannelWidth (station); if (channelWidth > 20 && channelWidth != 22) @@ -295,11 +348,8 @@ RraaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac channelWidth = 20; } - if (!station->m_initialized) - { - ResetCountersBasic (station); - } - WifiMode mode = GetSupported (station, station->m_rate); + CheckInit (station); + WifiMode mode = GetSupported (station, station->m_rateIndex); if (m_currentRate != mode.GetDataRate (channelWidth)) { NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (channelWidth)); @@ -311,6 +361,7 @@ RraaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) WifiTxVector RraaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) { + NS_LOG_FUNCTION (this << st); RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; uint32_t channelWidth = GetChannelWidth (station); if (channelWidth > 20 && channelWidth != 22) @@ -322,13 +373,13 @@ RraaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) WifiMode mode; if (GetUseNonErpProtection () == false) { - mode = GetSupported (st, 0); + mode = GetSupported (station, 0); } else { - mode = GetNonErpSupported (st, 0); + mode = GetNonErpSupported (station, 0); } - rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetShortRetryCount (st), GetPreambleForTransmission (mode, GetAddress (st)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false); + rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetShortRetryCount (station), GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false); return rtsTxVector; } @@ -336,18 +387,21 @@ bool RraaWifiManager::DoNeedRts (WifiRemoteStation *st, Ptr packet, bool normally) { + NS_LOG_FUNCTION (this << st << packet << normally); RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; + CheckInit (station); if (m_basic) { return normally; } ARts (station); - return station->m_rtsOn; + return station->m_adaptiveRtsOn; } void RraaWifiManager::CheckTimeout (RraaWifiRemoteStation *station) { + NS_LOG_FUNCTION (this << station); Time d = Simulator::Now () - station->m_lastReset; if (station->m_counter == 0 || d > m_timeout) { @@ -358,20 +412,21 @@ RraaWifiManager::CheckTimeout (RraaWifiRemoteStation *station) void RraaWifiManager::RunBasicAlgorithm (RraaWifiRemoteStation *station) { - ThresholdsItem thresholds = GetThresholds (station, station->m_rate); - double ploss = (double) station->m_failed / (double) thresholds.ewnd; + NS_LOG_FUNCTION (this << station); + WifiRraaThresholds thresholds = GetThresholds (station, station->m_rateIndex); + double ploss = (double) station->m_nFailed / (double) thresholds.m_ewnd; if (station->m_counter == 0 - || ploss > thresholds.pmtl) + || ploss > thresholds.m_mtl) { - if (station->m_rate > GetMinRate (station) - && ploss > thresholds.pmtl) + if (station->m_rateIndex > GetMinRate (station) + && ploss > thresholds.m_mtl) { - station->m_rate--; + station->m_rateIndex--; } - else if (station->m_rate < GetMaxRate (station) - && ploss < thresholds.pori) + else if (station->m_rateIndex < GetMaxRate (station) + && ploss < thresholds.m_ori) { - station->m_rate++; + station->m_rateIndex++; } ResetCountersBasic (station); } @@ -380,125 +435,36 @@ RraaWifiManager::RunBasicAlgorithm (RraaWifiRemoteStation *station) void RraaWifiManager::ARts (RraaWifiRemoteStation *station) { - if (!station->m_rtsOn + if (!station->m_adaptiveRtsOn && station->m_lastFrameFail) { - station->m_rtsWnd++; - station->m_rtsCounter = station->m_rtsWnd; + station->m_adaptiveRtsWnd++; + station->m_rtsCounter = station->m_adaptiveRtsWnd; } - else if ((station->m_rtsOn && station->m_lastFrameFail) - || (!station->m_rtsOn && !station->m_lastFrameFail)) + else if ((station->m_adaptiveRtsOn && station->m_lastFrameFail) + || (!station->m_adaptiveRtsOn && !station->m_lastFrameFail)) { - station->m_rtsWnd = station->m_rtsWnd / 2; - station->m_rtsCounter = station->m_rtsWnd; + station->m_adaptiveRtsWnd = station->m_adaptiveRtsWnd / 2; + station->m_rtsCounter = station->m_adaptiveRtsWnd; } if (station->m_rtsCounter > 0) { - station->m_rtsOn = true; + station->m_adaptiveRtsOn = true; station->m_rtsCounter--; } else { - station->m_rtsOn = false; + station->m_adaptiveRtsOn = false; } } -RraaWifiManager::ThresholdsItem +WifiRraaThresholds RraaWifiManager::GetThresholds (RraaWifiRemoteStation *station, - uint32_t rate) const + uint32_t rate) const { + NS_LOG_FUNCTION (this << station << rate); WifiMode mode = GetSupported (station, rate); - return GetThresholds (mode, station); -} - -RraaWifiManager::ThresholdsItem -RraaWifiManager::GetThresholds (WifiMode mode, RraaWifiRemoteStation *station) const -{ - switch (mode.GetDataRate (GetChannelWidth (station)) / 1000000) - { - case 54: - { - ThresholdsItem mode54 = { - 54000000, - 0.0, - m_pmtlfor54, - m_ewndfor54 - }; - return mode54; - } break; - case 48: - { - ThresholdsItem mode48 = { - 48000000, - m_porifor48, - m_pmtlfor48, - m_ewndfor48 - }; - return mode48; - } break; - case 36: - { - ThresholdsItem mode36 = { - 36000000, - m_porifor36, - m_pmtlfor36, - m_ewndfor36 - }; - return mode36; - } break; - case 24: - { - ThresholdsItem mode24 = { - 24000000, - m_porifor24, - m_pmtlfor24, - m_ewndfor24 - }; - return mode24; - } break; - case 18: - { - ThresholdsItem mode18 = { - 18000000, - m_porifor18, - m_pmtlfor18, - m_ewndfor18 - }; - return mode18; - } break; - case 12: - { - ThresholdsItem mode12 = { - 12000000, - m_porifor12, - m_pmtlfor12, - m_ewndfor12 - }; - return mode12; - } break; - case 9: - { - ThresholdsItem mode9 = { - 9000000, - m_porifor9, - m_pmtlfor9, - m_ewndfor9 - }; - return mode9; - } break; - case 6: - { - ThresholdsItem mode6 = { - 6000000, - m_porifor6, - 1.0, - m_ewndfor6 - }; - return mode6; - } break; - } - NS_ASSERT_MSG (false, "Thresholds for an unknown mode are asked (" << mode << ")"); - return ThresholdsItem (); + return GetThresholds (station, mode); } bool diff --git a/src/wifi/model/rraa-wifi-manager.h b/src/wifi/model/rraa-wifi-manager.h index 44a938fdb..fe619df7e 100644 --- a/src/wifi/model/rraa-wifi-manager.h +++ b/src/wifi/model/rraa-wifi-manager.h @@ -21,6 +21,7 @@ #ifndef RRAA_WIFI_MANAGER_H #define RRAA_WIFI_MANAGER_H +#include "ns3/nstime.h" #include "ns3/traced-value.h" #include "wifi-remote-station-manager.h" @@ -41,6 +42,24 @@ struct RraaWifiRemoteStation; * exit if the user tries to configure this RAA with a Wi-Fi MAC * that has VhtSupported, HtSupported or HeSupported set. */ + +/** + * For each rate there is a Opportunistic Rate Increase threshold, + * a Maximum Tolerable Loss threshold and an Evaluation Window. + */ +struct WifiRraaThresholds +{ + double m_ori; + double m_mtl; + uint32_t m_ewnd; +}; + +/** + * List of thresholds for each mode. + */ +typedef std::vector > RraaThresholdsTable; + + class RraaWifiManager : public WifiRemoteStationManager { public: @@ -54,20 +73,14 @@ public: virtual ~RraaWifiManager (); // Inherited from WifiRemoteStationManager + virtual void SetupPhy (Ptr phy); + virtual void SetupMac (Ptr mac); void SetHtSupported (bool enable); void SetVhtSupported (bool enable); void SetHeSupported (bool enable); private: - /// ThresholdsItem structure - struct ThresholdsItem - { - uint32_t datarate; ///< data rate - double pori; ///< PORI - double pmtl; ///< PMTL - uint32_t ewnd; ///< EWND - }; //overriden from base class WifiRemoteStation * DoCreateStation (void) const; @@ -87,6 +100,11 @@ private: Ptr packet, bool normally); bool IsLowLatency (void) const; + /** + * Check for initializations. + * \param station The remote station. + */ + void CheckInit (RraaWifiRemoteStation *station); /** * Return the index for the maximum transmission rate for * the given station. @@ -131,48 +149,63 @@ private: */ void ResetCountersBasic (RraaWifiRemoteStation *station); /** - * Get a threshold for the given mode. + * Initialize the thresholds internal list for the given station. * - * \param mode * \param station + */ + void InitThresholds (RraaWifiRemoteStation *station); + /** + * Get the thresholds for the given station and mode. + * + * \param station + * \param mode * * \return threshold */ - ThresholdsItem GetThresholds (WifiMode mode, RraaWifiRemoteStation *station) const; + WifiRraaThresholds GetThresholds (RraaWifiRemoteStation *station, WifiMode mode) const; /** - * Get a threshold for the given station and mode index. + * Get the thresholds for the given station and mode index. * * \param station * \param rate * * \return threshold */ - ThresholdsItem GetThresholds (RraaWifiRemoteStation *station, uint32_t rate) const; + WifiRraaThresholds GetThresholds (RraaWifiRemoteStation *station, uint32_t rate) const; + /** + * Get the estimated TxTime of a packet with a given mode. + * + * \param mode + * + * \return time + */ + Time GetCalcTxTime (WifiMode mode) const; + /** + * Add transmission time for the given mode to an internal list. + * + * \param mode Wi-Fi mode + * \param t transmission time + */ + void AddCalcTxTime (WifiMode mode, Time t); + /** + * typedef for a vector of a pair of Time, WifiMode. + * Essentially a list for WifiMode and its corresponding transmission time + * to transmit a reference packet. + */ + typedef std::vector > TxTime; - bool m_basic; ///< basic - Time m_timeout; ///< timeout - uint32_t m_ewndfor54; ///< ewndfor54 - uint32_t m_ewndfor48; ///< ewndfor48 - uint32_t m_ewndfor36; ///< ewndfor36 - uint32_t m_ewndfor24; ///< ewndfor24 - uint32_t m_ewndfor18; ///< ewndfor18 - uint32_t m_ewndfor12; ///< ewndfor12 - uint32_t m_ewndfor9; ///< ewndfor9 - uint32_t m_ewndfor6; ///< ewndfor6 - double m_porifor48; ///< porifor48 - double m_porifor36; ///< porifor36 - double m_porifor24; ///< porifor24 - double m_porifor18; ///< porifor18 - double m_porifor12; ///< porifor12 - double m_porifor9; ///< porifor9 - double m_porifor6; ///< porifor6 - double m_pmtlfor54; ///< pmtlfor54 - double m_pmtlfor48; ///< pmtlfor48 - double m_pmtlfor36; ///< pmtlfor36 - double m_pmtlfor24; ///< pmtlfor24 - double m_pmtlfor18; ///< pmtlfor18 - double m_pmtlfor12; ///< pmtlfor12 - double m_pmtlfor9; ///< pmtlfor9 + TxTime m_calcTxTime; //!< To hold all the calculated TxTime for all modes. + Time m_sifs; //!< Value of SIFS configured in the device. + Time m_difs; //!< Value of DIFS configured in the device. + + uint32_t m_frameLength; //!< Data frame length used for calculate mode TxTime. + uint32_t m_ackLength; //!< Ack frame length used for calculate mode TxTime. + + bool m_basic; ///< basic + Time m_timeout; ///< timeout + double m_alpha; //!< Alpha value for RRAA (value for calculating MTL threshold) + double m_beta; //!< Beta value for RRAA (value for calculating ORI threshold). + double m_tau; //!< Tau value for RRAA (value for calculating EWND size). TracedValue m_currentRate; //!< Trace rate changes };