From 79ea8d014f79de3d237d6e13098657f9613611d3 Mon Sep 17 00:00:00 2001 From: Sebastien Deronne Date: Thu, 21 Apr 2022 21:31:06 +0200 Subject: [PATCH] wifi: Add functions to retrieve the modulation class and PHY entity for a given standard --- src/wifi/model/wifi-phy-common.cc | 35 +++++++++++++++++++++++++++++++ src/wifi/model/wifi-phy-common.h | 9 ++++++++ src/wifi/model/wifi-phy.cc | 6 ++++++ src/wifi/model/wifi-phy.h | 10 +++++++-- 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/wifi/model/wifi-phy-common.cc b/src/wifi/model/wifi-phy-common.cc index ff308327f..d6c7a9616 100644 --- a/src/wifi/model/wifi-phy-common.cc +++ b/src/wifi/model/wifi-phy-common.cc @@ -187,4 +187,39 @@ IsUlMu (WifiPreamble preamble) return ((preamble == WIFI_PREAMBLE_HE_TB) || (preamble == WIFI_PREAMBLE_EHT_TB)); } +WifiModulationClass +GetModulationClassForStandard (WifiStandard standard) +{ + WifiModulationClass modulationClass {WIFI_MOD_CLASS_UNKNOWN}; + switch (standard) + { + case WIFI_STANDARD_80211a: + [[fallthrough]]; + case WIFI_STANDARD_80211p: + modulationClass = WIFI_MOD_CLASS_OFDM; + break; + case WIFI_STANDARD_80211b: + modulationClass = WIFI_MOD_CLASS_DSSS; + break; + case WIFI_STANDARD_80211g: + modulationClass = WIFI_MOD_CLASS_ERP_OFDM; + break; + case WIFI_STANDARD_80211n: + modulationClass = WIFI_MOD_CLASS_HT; + break; + case WIFI_STANDARD_80211ac: + modulationClass = WIFI_MOD_CLASS_VHT; + break; + case WIFI_STANDARD_80211ax: + modulationClass = WIFI_MOD_CLASS_HE; + break; + case WIFI_STANDARD_UNSPECIFIED: + [[fallthrough]]; + default: + NS_ASSERT_MSG (false, "Unsupported standard " << standard); + break; + } + return modulationClass; +} + } //namespace ns3 diff --git a/src/wifi/model/wifi-phy-common.h b/src/wifi/model/wifi-phy-common.h index c24dde06b..441807ad6 100644 --- a/src/wifi/model/wifi-phy-common.h +++ b/src/wifi/model/wifi-phy-common.h @@ -26,6 +26,7 @@ #include #include "ns3/fatal-error.h" #include "ns3/ptr.h" +#include "wifi-standards.h" /** * \file @@ -488,6 +489,14 @@ bool IsDlMu (WifiPreamble preamble); */ bool IsUlMu (WifiPreamble preamble); +/** + * Return the modulation class corresponding to a given standard. + * + * \param standard the standard + * \return the modulation class corresponding to the standard + */ +WifiModulationClass GetModulationClassForStandard (WifiStandard standard); + } //namespace ns3 #endif /* WIFI_PHY_COMMON_H */ diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 2dbff45c5..5446156d8 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -655,6 +655,12 @@ WifiPhy::GetPhyEntity (WifiModulationClass modulation) const return it->second; } +Ptr +WifiPhy::GetPhyEntity (WifiStandard standard) const +{ + return GetPhyEntity (GetModulationClassForStandard (standard)); +} + void WifiPhy::AddStaticPhyEntity (WifiModulationClass modulation, Ptr phyEntity) { diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 0e0b3f4c5..e848c1a60 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -1008,13 +1008,19 @@ public: static const Ptr GetStaticPhyEntity (WifiModulationClass modulation); /** - * Get the supported PHY entity corresponding to the modulation class, for - * the WifiPhy instance. + * Get the supported PHY entity corresponding to the modulation class. * * \param modulation the modulation class * \return the pointer to the supported PHY entity */ Ptr GetPhyEntity (WifiModulationClass modulation) const; + /** + * Get the supported PHY entity corresponding to the wifi standard. + * + * \param standard the wifi standard + * \return the pointer to the supported PHY entity + */ + Ptr GetPhyEntity (WifiStandard standard) const; /** * \return the UID of the previously received PPDU (reset to UINT64_MAX upon transmission)