wifi: (fixes #1055) Overload WifiHelper::SetStandard to take a string as an argument

This commit is contained in:
sanjaybhat2004
2024-08-31 19:22:08 +05:30
committed by Eduardo Almeida
parent 7837b7e9f8
commit 0f58f70d62
2 changed files with 58 additions and 0 deletions

View File

@@ -723,12 +723,59 @@ WifiHelper::WifiHelper()
m_ehtConfig.SetTypeId("ns3::EhtConfiguration");
}
namespace
{
/// Map strings to WifiStandard enum values
const std::unordered_map<std::string, WifiStandard> WIFI_STANDARDS_NAME_MAP{
// clang-format off
{"802.11a", WIFI_STANDARD_80211a},
{"11a", WIFI_STANDARD_80211a},
{"802.11b", WIFI_STANDARD_80211b},
{"11b", WIFI_STANDARD_80211b},
{"802.11g", WIFI_STANDARD_80211g},
{"11g", WIFI_STANDARD_80211g},
{"802.11p", WIFI_STANDARD_80211p},
{"11p", WIFI_STANDARD_80211p},
{"802.11n", WIFI_STANDARD_80211n},
{"11n", WIFI_STANDARD_80211n},
{"HT", WIFI_STANDARD_80211n},
{"802.11ac", WIFI_STANDARD_80211ac},
{"11ac", WIFI_STANDARD_80211ac},
{"VHT", WIFI_STANDARD_80211ac},
{"802.11ad", WIFI_STANDARD_80211ad},
{"11ad", WIFI_STANDARD_80211ad},
{"802.11ax", WIFI_STANDARD_80211ax},
{"11ax", WIFI_STANDARD_80211ax},
{"HE", WIFI_STANDARD_80211ax},
{"802.11be", WIFI_STANDARD_80211be},
{"11be", WIFI_STANDARD_80211be},
{"EHT", WIFI_STANDARD_80211be},
// clang-format on
};
} // namespace
void
WifiHelper::SetStandard(WifiStandard standard)
{
m_standard = standard;
}
void
WifiHelper::SetStandard(const std::string& standard)
{
NS_ABORT_MSG_IF(!WIFI_STANDARDS_NAME_MAP.contains(standard),
"Specified Wi-Fi standard " << standard << " is currently not supported");
SetStandard(WIFI_STANDARDS_NAME_MAP.at(standard));
}
void
WifiHelper::DisableFlowControl()
{

View File

@@ -444,6 +444,17 @@ class WifiHelper
*/
virtual void SetStandard(WifiStandard standard);
/**
* \param standard String representation of the Wi-Fi standard
*
* This method overloads WifiHelper::SetStandard(WifiStandard standard) by allowing
* selected string names. For example, the strings "802.11ax", "11ax", and "HE"
* are equivalent and map to WIFI_STANDARD_80211ax. See the documentation of the specified
* function to see how it interacts with attribute configuration.
* \sa WifiHelper::SetStandard(WifiStandard standard)
*/
void SetStandard(const std::string& standard);
/**
* Helper function used to configure the HT options listed as attributes of
* the HtConfiguration class.