From 5bbb3d60013307669ef9140474e6ce1937511914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Richart?= Date: Wed, 9 Mar 2016 20:41:21 +0100 Subject: [PATCH] wifi: (fixes #2317) Add method to convert a HT MCS to a non-HT rate --- RELEASE_NOTES | 1 + src/wifi/model/wifi-mode.cc | 94 +++++++++++++++++++++++++++++++++++++ src/wifi/model/wifi-mode.h | 11 ++++- 3 files changed, 105 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index e735eb07a..aac00e651 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -120,6 +120,7 @@ Bugs fixed - Bug 2313 - Assert failed when using aggregation and RTS/CTS - Bug 2315 - Problem when BACK Request is part of an A-MPDU - Bug 2316 - MacLow shall use a single TXVECTOR for all MPDUs belonging to a same A-MPDU +- Bug 2317 - Get the non-HT reference rate of a HT MCS - Bug 2318 - MPDU Aggregation fails with TCP - Bug 2319 - BlockAckTimeout value is too low for 802.11n operating at 2.4 GHz - Bug 2320 - Add method to check whether a WifiTxVector contains a valid combination of WifiMode, number of spatial streams and channel width diff --git a/src/wifi/model/wifi-mode.cc b/src/wifi/model/wifi-mode.cc index 5525a6a69..efe904e8b 100644 --- a/src/wifi/model/wifi-mode.cc +++ b/src/wifi/model/wifi-mode.cc @@ -390,6 +390,100 @@ WifiMode::GetModulationClass () const return item->modClass; } +WifiMode +WifiMode::GetNonHtReferenceRate (uint8_t nss) const +{ + WifiMode mode; + struct WifiModeFactory::WifiModeItem *item = WifiModeFactory::GetFactory ()->Get (m_uid); + if (item->modClass == WIFI_MOD_CLASS_HT || item->modClass == WIFI_MOD_CLASS_VHT) + { + WifiCodeRate codeRate = GetCodeRate(nss); + switch(GetConstellationSize(nss)) + { + case 2: + if (codeRate == WIFI_CODE_RATE_1_2) + mode = WifiModeFactory::CreateWifiMode ("OfdmRate6Mbps", + WIFI_MOD_CLASS_OFDM, + true, + WIFI_CODE_RATE_1_2, + 2); + else if (codeRate == WIFI_CODE_RATE_3_4) + mode = WifiModeFactory::CreateWifiMode ("OfdmRate9Mbps", + WIFI_MOD_CLASS_OFDM, + false, + WIFI_CODE_RATE_3_4, + 2); + else + NS_FATAL_ERROR ("Trying to get reference rate for a MCS with wrong combination of coding rate and modulation"); + break; + case 4: + if (codeRate == WIFI_CODE_RATE_1_2) + mode = WifiModeFactory::CreateWifiMode ("OfdmRate12Mbps", + WIFI_MOD_CLASS_OFDM, + true, + WIFI_CODE_RATE_1_2, + 4); + else if (codeRate == WIFI_CODE_RATE_3_4) + mode = WifiModeFactory::CreateWifiMode ("OfdmRate18Mbps", + WIFI_MOD_CLASS_OFDM, + false, + WIFI_CODE_RATE_3_4, + 4); + else + NS_FATAL_ERROR ("Trying to get reference rate for a MCS with wrong combination of coding rate and modulation"); + break; + case 16: + if (codeRate == WIFI_CODE_RATE_1_2) + mode = WifiModeFactory::CreateWifiMode ("OfdmRate24Mbps", + WIFI_MOD_CLASS_OFDM, + true, + WIFI_CODE_RATE_1_2, + 16); + else if (codeRate == WIFI_CODE_RATE_3_4) + mode = WifiModeFactory::CreateWifiMode ("OfdmRate36Mbps", + WIFI_MOD_CLASS_OFDM, + false, + WIFI_CODE_RATE_3_4, + 16); + else + NS_FATAL_ERROR ("Trying to get reference rate for a MCS with wrong combination of coding rate and modulation"); + break; + case 64: + if (codeRate == WIFI_CODE_RATE_1_2 || codeRate == WIFI_CODE_RATE_2_3) + mode = WifiModeFactory::CreateWifiMode ("OfdmRate48Mbps", + WIFI_MOD_CLASS_OFDM, + false, + WIFI_CODE_RATE_2_3, + 64); + else if (codeRate == WIFI_CODE_RATE_3_4 || codeRate == WIFI_CODE_RATE_5_6) + mode = WifiModeFactory::CreateWifiMode ("OfdmRate54Mbps", + WIFI_MOD_CLASS_OFDM, + false, + WIFI_CODE_RATE_3_4, + 64); + else + NS_FATAL_ERROR ("Trying to get reference rate for a MCS with wrong combination of coding rate and modulation"); + break; + case 256: + if (codeRate == WIFI_CODE_RATE_3_4 || codeRate == WIFI_CODE_RATE_5_6) + mode = WifiModeFactory::CreateWifiMode ("OfdmRate54Mbps", + WIFI_MOD_CLASS_OFDM, + false, + WIFI_CODE_RATE_3_4, + 64); + else + NS_FATAL_ERROR ("Trying to get reference rate for a MCS with wrong combination of coding rate and modulation"); + break; + default: + NS_FATAL_ERROR ("Wrong constellation size"); + } + } + else + mode = *this; + + return mode; +} + WifiMode::WifiMode () : m_uid (0) { diff --git a/src/wifi/model/wifi-mode.h b/src/wifi/model/wifi-mode.h index db49a26b0..e37b469ce 100644 --- a/src/wifi/model/wifi-mode.h +++ b/src/wifi/model/wifi-mode.h @@ -176,7 +176,16 @@ public: * \returns the Modulation Class (Section 9.7.8 "Modulation classes"; IEEE 802.11-2012) * to which this WifiMode belongs. */ - enum WifiModulationClass GetModulationClass () const; + enum WifiModulationClass GetModulationClass () const; + /** + * \returns the WifiMode which represents the non-HT Reference Rate + * which corresponds to the HT MCS of this WifiMode. + * + * To convert an HT MCS to is corresponding non-HT Reference Rate + * use the modulation and coding rate determined by the HT MCS + * and get the non-HT reference rate by lookup into Table 9-5 of IEEE 802.11-2012. + */ + WifiMode GetNonHtReferenceRate (uint8_t nss) const; /** * Create an invalid WifiMode. Calling any method on the