diff --git a/src/wifi/model/wifi-phy-common.cc b/src/wifi/model/wifi-phy-common.cc index 5e70288e2..9c6b8be80 100644 --- a/src/wifi/model/wifi-phy-common.cc +++ b/src/wifi/model/wifi-phy-common.cc @@ -113,6 +113,30 @@ GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble } } +WifiModulationClass +GetModulationClassForPreamble(WifiPreamble preamble) +{ + switch (preamble) + { + case WIFI_PREAMBLE_HT_MF: + return WIFI_MOD_CLASS_HT; + case WIFI_PREAMBLE_VHT_SU: + case WIFI_PREAMBLE_VHT_MU: + return WIFI_MOD_CLASS_VHT; + case WIFI_PREAMBLE_HE_SU: + case WIFI_PREAMBLE_HE_ER_SU: + case WIFI_PREAMBLE_HE_MU: + case WIFI_PREAMBLE_HE_TB: + return WIFI_MOD_CLASS_HE; + case WIFI_PREAMBLE_EHT_MU: + case WIFI_PREAMBLE_EHT_TB: + return WIFI_MOD_CLASS_EHT; + default: + NS_ABORT_MSG("Unsupported preamble type: " << preamble); + } + return WIFI_MOD_CLASS_UNKNOWN; +} + bool IsAllowedControlAnswerModulationClass(WifiModulationClass modClassReq, WifiModulationClass modClassAnswer) diff --git a/src/wifi/model/wifi-phy-common.h b/src/wifi/model/wifi-phy-common.h index 103613d42..f48476f41 100644 --- a/src/wifi/model/wifi-phy-common.h +++ b/src/wifi/model/wifi-phy-common.h @@ -475,6 +475,15 @@ uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode, */ WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble); +/** + * Return the modulation class corresponding to the given preamble type. + * Only preamble types used by HT/VHT/HE/EHT can be passed to this function. + * + * \param preamble the given preamble type (must be one defined by HT standard or later) + * \return the modulation class corresponding to the given preamble type + */ +WifiModulationClass GetModulationClassForPreamble(WifiPreamble preamble); + /** * Return whether the modulation class of the selected mode for the * control answer frame is allowed.