From 544086503f45d1ecb54b0e41977a84aaef7dbef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sat, 7 Dec 2024 08:14:30 +0100 Subject: [PATCH] wifi: Specify units of magic numbers --- examples/wireless/wifi-80211n-mimo.cc | 2 +- .../wifi-spectrum-per-interference.cc | 8 +- src/wifi/examples/wifi-manager-example.cc | 191 +- src/wifi/examples/wifi-phy-configuration.cc | 88 +- .../examples/wifi-test-interference-helper.cc | 10 +- src/wifi/examples/wifi-trans-example.cc | 37 +- src/wifi/helper/wifi-helper.cc | 26 +- src/wifi/model/ap-wifi-mac.cc | 29 +- src/wifi/model/channel-access-manager.cc | 21 +- src/wifi/model/ctrl-headers.cc | 2 +- src/wifi/model/eht/advanced-emlsr-manager.cc | 2 +- src/wifi/model/eht/eht-phy.cc | 2 +- src/wifi/model/eht/eht-ppdu.cc | 22 +- src/wifi/model/eht/emlsr-manager.cc | 2 +- src/wifi/model/error-rate-model.cc | 2 +- .../model/he/he-frame-exchange-manager.cc | 8 +- src/wifi/model/he/he-phy.cc | 69 +- src/wifi/model/he/he-ppdu.cc | 47 +- src/wifi/model/he/he-ru.cc | 103 +- src/wifi/model/ht/ht-phy.cc | 8 +- src/wifi/model/ht/ht-ppdu.cc | 4 +- src/wifi/model/interference-helper.cc | 14 +- src/wifi/model/mgt-action-headers.cc | 20 +- src/wifi/model/non-ht/dsss-phy.cc | 15 +- src/wifi/model/non-ht/dsss-ppdu.cc | 4 +- src/wifi/model/non-ht/erp-ofdm-ppdu.cc | 2 +- src/wifi/model/non-ht/ofdm-phy.cc | 30 +- src/wifi/model/non-ht/ofdm-phy.h | 2 +- src/wifi/model/non-ht/ofdm-ppdu.cc | 12 +- src/wifi/model/non-ht/ofdm-ppdu.h | 4 +- src/wifi/model/phy-entity.cc | 10 +- src/wifi/model/qos-frame-exchange-manager.cc | 2 +- .../model/rate-control/aarf-wifi-manager.cc | 8 +- .../model/rate-control/aarfcd-wifi-manager.cc | 8 +- .../model/rate-control/amrr-wifi-manager.cc | 8 +- .../model/rate-control/aparf-wifi-manager.cc | 8 +- .../model/rate-control/arf-wifi-manager.cc | 8 +- .../model/rate-control/cara-wifi-manager.cc | 8 +- .../model/rate-control/ideal-wifi-manager.cc | 10 +- .../rate-control/minstrel-ht-wifi-manager.cc | 12 +- .../rate-control/minstrel-wifi-manager.cc | 8 +- .../model/rate-control/onoe-wifi-manager.cc | 8 +- .../model/rate-control/parf-wifi-manager.cc | 8 +- .../model/rate-control/rraa-wifi-manager.cc | 8 +- .../model/rate-control/rrpaa-wifi-manager.cc | 8 +- .../thompson-sampling-wifi-manager.cc | 4 +- src/wifi/model/reduced-neighbor-report.cc | 66 +- src/wifi/model/reference/error-rate-tables.cc | 806 ++++----- src/wifi/model/spectrum-wifi-phy.cc | 46 +- src/wifi/model/sta-wifi-mac.cc | 2 +- src/wifi/model/vht/vht-configuration.cc | 12 +- src/wifi/model/vht/vht-phy.cc | 50 +- src/wifi/model/vht/vht-ppdu.cc | 14 +- src/wifi/model/wifi-default-assoc-manager.cc | 4 +- .../model/wifi-default-protection-manager.cc | 2 +- src/wifi/model/wifi-mac.cc | 9 +- src/wifi/model/wifi-phy-common.cc | 33 +- src/wifi/model/wifi-phy-operating-channel.cc | 457 ++--- src/wifi/model/wifi-phy-state-helper.cc | 2 +- src/wifi/model/wifi-phy.cc | 28 +- src/wifi/model/wifi-phy.h | 4 +- src/wifi/model/wifi-protection-manager.cc | 7 +- src/wifi/model/wifi-remote-station-manager.cc | 18 +- src/wifi/model/wifi-spectrum-value-helper.cc | 48 +- src/wifi/model/wifi-spectrum-value-helper.h | 38 +- src/wifi/model/wifi-standards.h | 12 +- src/wifi/model/wifi-tx-vector.cc | 29 +- src/wifi/model/yans-error-rate-model.cc | 4 +- src/wifi/model/yans-wifi-channel.cc | 4 +- src/wifi/model/yans-wifi-phy.cc | 18 +- src/wifi/test/channel-access-manager-test.cc | 28 +- src/wifi/test/inter-bss-test-suite.cc | 28 +- src/wifi/test/power-rate-adaptation-test.cc | 4 +- src/wifi/test/spectrum-wifi-phy-test.cc | 162 +- src/wifi/test/tx-duration-test.cc | 418 ++--- src/wifi/test/wifi-dynamic-bw-op-test.cc | 15 +- src/wifi/test/wifi-eht-info-elems-test.cc | 51 +- src/wifi/test/wifi-emlsr-test.cc | 17 +- src/wifi/test/wifi-error-rate-models-test.cc | 679 +++---- src/wifi/test/wifi-fils-frame-test.cc | 12 +- src/wifi/test/wifi-mac-ofdma-test.cc | 14 +- src/wifi/test/wifi-mlo-test.cc | 14 +- src/wifi/test/wifi-non-ht-dup-test.cc | 75 +- src/wifi/test/wifi-operating-channel-test.cc | 363 ++-- src/wifi/test/wifi-phy-cca-test.cc | 1117 ++++++------ src/wifi/test/wifi-phy-mu-mimo-test.cc | 40 +- src/wifi/test/wifi-phy-ofdma-test.cc | 193 +- src/wifi/test/wifi-phy-reception-test.cc | 120 +- .../test/wifi-phy-rx-trace-helper-test.cc | 12 +- src/wifi/test/wifi-phy-thresholds-test.cc | 8 +- src/wifi/test/wifi-primary-channels-test.cc | 32 +- src/wifi/test/wifi-ru-allocation-test.cc | 8 +- src/wifi/test/wifi-test.cc | 112 +- src/wifi/test/wifi-transmit-mask-test.cc | 1564 ++++++++--------- src/wifi/test/wifi-txop-test.cc | 2 +- 95 files changed, 4043 insertions(+), 3670 deletions(-) diff --git a/examples/wireless/wifi-80211n-mimo.cc b/examples/wireless/wifi-80211n-mimo.cc index 09551e4ba..05c82dab2 100644 --- a/examples/wireless/wifi-80211n-mimo.cc +++ b/examples/wireless/wifi-80211n-mimo.cc @@ -204,7 +204,7 @@ main(int argc, char* argv[]) /* Setting applications */ const auto maxLoad = HtPhy::GetDataRate(i, - channelBonding ? 40 : 20, + channelBonding ? MHz_u{40} : MHz_u{20}, NanoSeconds(shortGuardInterval ? 400 : 800), nStreams); ApplicationContainer serverApp; diff --git a/examples/wireless/wifi-spectrum-per-interference.cc b/examples/wireless/wifi-spectrum-per-interference.cc index 7e90af689..f4072b83c 100644 --- a/examples/wireless/wifi-spectrum-per-interference.cc +++ b/examples/wireless/wifi-spectrum-per-interference.cc @@ -578,18 +578,18 @@ main(int argc, char* argv[]) Ptr wifiPhyPtr = staDevicePtr->GetObject()->GetPhy(); if (i <= 15) { - NS_ABORT_MSG_IF(wifiPhyPtr->GetChannelWidth() != 20, + NS_ABORT_MSG_IF(wifiPhyPtr->GetChannelWidth() != MHz_u{20}, "Error: Channel width must be 20 MHz if MCS index <= 15"); NS_ABORT_MSG_IF( - wifiPhyPtr->GetFrequency() != 5180, + wifiPhyPtr->GetFrequency() != MHz_u{5180}, "Error: Wi-Fi nodes must be tuned to 5180 MHz to match the waveform generator"); } else { - NS_ABORT_MSG_IF(wifiPhyPtr->GetChannelWidth() != 40, + NS_ABORT_MSG_IF(wifiPhyPtr->GetChannelWidth() != MHz_u{40}, "Error: Channel width must be 40 MHz if MCS index > 15"); NS_ABORT_MSG_IF( - wifiPhyPtr->GetFrequency() != 5190, + wifiPhyPtr->GetFrequency() != MHz_u{5190}, "Error: Wi-Fi nodes must be tuned to 5190 MHz to match the waveform generator"); } diff --git a/src/wifi/examples/wifi-manager-example.cc b/src/wifi/examples/wifi-manager-example.cc index 80fbfb320..14a6bc45d 100644 --- a/src/wifi/examples/wifi-manager-example.cc +++ b/src/wifi/examples/wifi-manager-example.cc @@ -274,35 +274,35 @@ main(int argc, char* argv[]) if (standard == "802.11b") { - if (serverChannelWidth == 0) + if (serverChannelWidth == MHz_u{0}) { serverChannelWidth = GetDefaultChannelWidth(WIFI_STANDARD_80211b, WIFI_PHY_BAND_2_4GHZ); } - NS_ABORT_MSG_IF(serverChannelWidth != 22, + NS_ABORT_MSG_IF(serverChannelWidth != MHz_u{22}, "Invalid channel width for standard " << standard); NS_ABORT_MSG_IF(serverNss != 1, "Invalid nss for standard " << standard); - if (clientChannelWidth == 0) + if (clientChannelWidth == MHz_u{0}) { clientChannelWidth = GetDefaultChannelWidth(WIFI_STANDARD_80211b, WIFI_PHY_BAND_2_4GHZ); } - NS_ABORT_MSG_IF(clientChannelWidth != 22, + NS_ABORT_MSG_IF(clientChannelWidth != MHz_u{22}, "Invalid channel width for standard " << standard); NS_ABORT_MSG_IF(clientNss != 1, "Invalid nss for standard " << standard); } else if (standard == "802.11a" || standard == "802.11g") { - if (serverChannelWidth == 0) + if (serverChannelWidth == MHz_u{0}) { serverChannelWidth = GetDefaultChannelWidth(WIFI_STANDARD_80211g, WIFI_PHY_BAND_2_4GHZ); } - NS_ABORT_MSG_IF(serverChannelWidth != 20, + NS_ABORT_MSG_IF(serverChannelWidth != MHz_u{20}, "Invalid channel width for standard " << standard); NS_ABORT_MSG_IF(serverNss != 1, "Invalid nss for standard " << standard); - if (clientChannelWidth == 0) + if (clientChannelWidth == MHz_u{0}) { clientChannelWidth = GetDefaultChannelWidth(WIFI_STANDARD_80211g, WIFI_PHY_BAND_2_4GHZ); } - NS_ABORT_MSG_IF(clientChannelWidth != 20, + NS_ABORT_MSG_IF(clientChannelWidth != MHz_u{20}, "Invalid channel width for standard " << standard); NS_ABORT_MSG_IF(clientNss != 1, "Invalid nss for standard " << standard); } @@ -310,40 +310,40 @@ main(int argc, char* argv[]) { WifiPhyBand band = (standard == "802.11n-2.4GHz" ? WIFI_PHY_BAND_2_4GHZ : WIFI_PHY_BAND_5GHZ); - if (serverChannelWidth == 0) + if (serverChannelWidth == MHz_u{0}) { serverChannelWidth = GetDefaultChannelWidth(WIFI_STANDARD_80211n, band); } - NS_ABORT_MSG_IF(serverChannelWidth != 20 && serverChannelWidth != 40, + NS_ABORT_MSG_IF(serverChannelWidth != MHz_u{20} && serverChannelWidth != MHz_u{40}, "Invalid channel width for standard " << standard); NS_ABORT_MSG_IF(serverNss == 0 || serverNss > 4, "Invalid nss " << serverNss << " for standard " << standard); - if (clientChannelWidth == 0) + if (clientChannelWidth == MHz_u{0}) { clientChannelWidth = GetDefaultChannelWidth(WIFI_STANDARD_80211n, band); } - NS_ABORT_MSG_IF(clientChannelWidth != 20 && clientChannelWidth != 40, + NS_ABORT_MSG_IF(clientChannelWidth != MHz_u{20} && clientChannelWidth != MHz_u{40}, "Invalid channel width for standard " << standard); NS_ABORT_MSG_IF(clientNss == 0 || clientNss > 4, "Invalid nss " << clientNss << " for standard " << standard); } else if (standard == "802.11ac") { - if (serverChannelWidth == 0) + if (serverChannelWidth == MHz_u{0}) { serverChannelWidth = GetDefaultChannelWidth(WIFI_STANDARD_80211ac, WIFI_PHY_BAND_5GHZ); } - NS_ABORT_MSG_IF(serverChannelWidth != 20 && serverChannelWidth != 40 && - serverChannelWidth != 80 && serverChannelWidth != 160, + NS_ABORT_MSG_IF(serverChannelWidth != MHz_u{20} && serverChannelWidth != MHz_u{40} && + serverChannelWidth != MHz_u{80} && serverChannelWidth != MHz_u{160}, "Invalid channel width for standard " << standard); NS_ABORT_MSG_IF(serverNss == 0 || serverNss > 4, "Invalid nss " << serverNss << " for standard " << standard); - if (clientChannelWidth == 0) + if (clientChannelWidth == MHz_u{0}) { clientChannelWidth = GetDefaultChannelWidth(WIFI_STANDARD_80211ac, WIFI_PHY_BAND_5GHZ); } - NS_ABORT_MSG_IF(clientChannelWidth != 20 && clientChannelWidth != 40 && - clientChannelWidth != 80 && clientChannelWidth != 160, + NS_ABORT_MSG_IF(clientChannelWidth != MHz_u{20} && clientChannelWidth != MHz_u{40} && + clientChannelWidth != MHz_u{80} && clientChannelWidth != MHz_u{160}, "Invalid channel width for standard " << standard); NS_ABORT_MSG_IF(clientNss == 0 || clientNss > 4, "Invalid nss " << clientNss << " for standard " << standard); @@ -354,43 +354,67 @@ main(int argc, char* argv[]) WifiPhyBand band = (standard == "802.11ax-2.4GHz" ? WIFI_PHY_BAND_2_4GHZ : standard == "802.11ax-6GHz" ? WIFI_PHY_BAND_6GHZ : WIFI_PHY_BAND_5GHZ); - if (serverChannelWidth == 0) + if (serverChannelWidth == MHz_u{0}) { serverChannelWidth = GetDefaultChannelWidth(WIFI_STANDARD_80211ax, band); } - NS_ABORT_MSG_IF(serverChannelWidth != 20 && serverChannelWidth != 40 && - serverChannelWidth != 80 && serverChannelWidth != 160, + NS_ABORT_MSG_IF(serverChannelWidth != MHz_u{20} && serverChannelWidth != MHz_u{40} && + serverChannelWidth != MHz_u{80} && serverChannelWidth != MHz_u{160}, "Invalid channel width for standard " << standard); NS_ABORT_MSG_IF(serverNss == 0 || serverNss > 4, "Invalid nss " << serverNss << " for standard " << standard); - if (clientChannelWidth == 0) + if (clientChannelWidth == MHz_u{0}) { clientChannelWidth = GetDefaultChannelWidth(WIFI_STANDARD_80211ax, band); } - NS_ABORT_MSG_IF(clientChannelWidth != 20 && clientChannelWidth != 40 && - clientChannelWidth != 80 && clientChannelWidth != 160, + NS_ABORT_MSG_IF(clientChannelWidth != MHz_u{20} && clientChannelWidth != MHz_u{40} && + clientChannelWidth != MHz_u{80} && clientChannelWidth != MHz_u{160}, "Invalid channel width for standard " << standard); NS_ABORT_MSG_IF(clientNss == 0 || clientNss > 4, "Invalid nss " << clientNss << " for standard " << standard); } // As channel width increases, scale up plot's yRange value - uint32_t channelRateFactor = std::max(clientChannelWidth, serverChannelWidth) / 20; + uint32_t channelRateFactor = std::max(clientChannelWidth, serverChannelWidth) / MHz_u{20}; channelRateFactor = channelRateFactor * std::max(clientNss, serverNss); // The first number is channel width, second is minimum SNR, third is maximum // SNR, fourth and fifth provide xrange axis limits, and sixth the yaxis // maximum serverStandards = { - StandardInfo("802.11a", WIFI_STANDARD_80211a, WIFI_PHY_BAND_5GHZ, 20, 3, 27, 0, 30, 60), - StandardInfo("802.11b", WIFI_STANDARD_80211b, WIFI_PHY_BAND_2_4GHZ, 22, -5, 11, -6, 15, 15), - StandardInfo("802.11g", WIFI_STANDARD_80211g, WIFI_PHY_BAND_2_4GHZ, 20, -5, 27, -6, 30, 60), + StandardInfo("802.11a", + WIFI_STANDARD_80211a, + WIFI_PHY_BAND_5GHZ, + MHz_u{20}, + dB_u{3}, + dB_u{27}, + 0, + 30, + 60), + StandardInfo("802.11b", + WIFI_STANDARD_80211b, + WIFI_PHY_BAND_2_4GHZ, + MHz_u{22}, + dB_u{-5}, + dB_u{11}, + -6, + 15, + 15), + StandardInfo("802.11g", + WIFI_STANDARD_80211g, + WIFI_PHY_BAND_2_4GHZ, + MHz_u{20}, + dB_u{-5}, + dB_u{27}, + -6, + 30, + 60), StandardInfo("802.11n-5GHz", WIFI_STANDARD_80211n, WIFI_PHY_BAND_5GHZ, serverChannelWidth, - 3, - 30, + dB_u{3}, + dB_u{30}, 0, 35, 80 * channelRateFactor), @@ -398,8 +422,8 @@ main(int argc, char* argv[]) WIFI_STANDARD_80211n, WIFI_PHY_BAND_2_4GHZ, serverChannelWidth, - 3, - 30, + dB_u{3}, + dB_u{30}, 0, 35, 80 * channelRateFactor), @@ -407,27 +431,35 @@ main(int argc, char* argv[]) WIFI_STANDARD_80211ac, WIFI_PHY_BAND_5GHZ, serverChannelWidth, - 5, - 50, + dB_u{5}, + dB_u{50}, 0, 55, 120 * channelRateFactor), StandardInfo("802.11p-10MHz", WIFI_STANDARD_80211p, WIFI_PHY_BAND_5GHZ, - 10, - 3, - 27, + MHz_u{10}, + dB_u{3}, + dB_u{27}, + 0, + 30, + 60), + StandardInfo("802.11p-5MHz", + WIFI_STANDARD_80211p, + WIFI_PHY_BAND_5GHZ, + MHz_u{5}, + dB_u{3}, + dB_u{27}, 0, 30, 60), - StandardInfo("802.11p-5MHz", WIFI_STANDARD_80211p, WIFI_PHY_BAND_5GHZ, 5, 3, 27, 0, 30, 60), StandardInfo("802.11ax-6GHz", WIFI_STANDARD_80211ax, WIFI_PHY_BAND_6GHZ, serverChannelWidth, - 5, - 55, + dB_u{5}, + dB_u{55}, 0, 60, 120 * channelRateFactor), @@ -435,8 +467,8 @@ main(int argc, char* argv[]) WIFI_STANDARD_80211ax, WIFI_PHY_BAND_5GHZ, serverChannelWidth, - 5, - 55, + dB_u{5}, + dB_u{55}, 0, 60, 120 * channelRateFactor), @@ -444,23 +476,47 @@ main(int argc, char* argv[]) WIFI_STANDARD_80211ax, WIFI_PHY_BAND_2_4GHZ, serverChannelWidth, - 5, - 55, + dB_u{5}, + dB_u{55}, 0, 60, 120 * channelRateFactor), }; clientStandards = { - StandardInfo("802.11a", WIFI_STANDARD_80211a, WIFI_PHY_BAND_5GHZ, 20, 3, 27, 0, 30, 60), - StandardInfo("802.11b", WIFI_STANDARD_80211b, WIFI_PHY_BAND_2_4GHZ, 22, -5, 11, -6, 15, 15), - StandardInfo("802.11g", WIFI_STANDARD_80211g, WIFI_PHY_BAND_2_4GHZ, 20, -5, 27, -6, 30, 60), + StandardInfo("802.11a", + WIFI_STANDARD_80211a, + WIFI_PHY_BAND_5GHZ, + MHz_u{20}, + dB_u{3}, + dB_u{27}, + 0, + 30, + 60), + StandardInfo("802.11b", + WIFI_STANDARD_80211b, + WIFI_PHY_BAND_2_4GHZ, + MHz_u{22}, + dB_u{-5}, + dB_u{11}, + -6, + 15, + 15), + StandardInfo("802.11g", + WIFI_STANDARD_80211g, + WIFI_PHY_BAND_2_4GHZ, + MHz_u{20}, + dB_u{-5}, + dB_u{27}, + -6, + 30, + 60), StandardInfo("802.11n-5GHz", WIFI_STANDARD_80211n, WIFI_PHY_BAND_5GHZ, clientChannelWidth, - 3, - 30, + dB_u{3}, + dB_u{30}, 0, 35, 80 * channelRateFactor), @@ -468,8 +524,8 @@ main(int argc, char* argv[]) WIFI_STANDARD_80211n, WIFI_PHY_BAND_2_4GHZ, clientChannelWidth, - 3, - 30, + dB_u{3}, + dB_u{30}, 0, 35, 80 * channelRateFactor), @@ -477,27 +533,35 @@ main(int argc, char* argv[]) WIFI_STANDARD_80211ac, WIFI_PHY_BAND_5GHZ, clientChannelWidth, - 5, - 50, + dB_u{5}, + dB_u{50}, 0, 55, 120 * channelRateFactor), StandardInfo("802.11p-10MHz", WIFI_STANDARD_80211p, WIFI_PHY_BAND_5GHZ, - 10, - 3, - 27, + MHz_u{10}, + dB_u{3}, + dB_u{27}, + 0, + 30, + 60), + StandardInfo("802.11p-5MHz", + WIFI_STANDARD_80211p, + WIFI_PHY_BAND_5GHZ, + MHz_u{5}, + dB_u{3}, + dB_u{27}, 0, 30, 60), - StandardInfo("802.11p-5MHz", WIFI_STANDARD_80211p, WIFI_PHY_BAND_5GHZ, 5, 3, 27, 0, 30, 60), StandardInfo("802.11ax-6GHz", WIFI_STANDARD_80211ax, WIFI_PHY_BAND_6GHZ, clientChannelWidth, - 5, - 55, + dB_u{5}, + dB_u{55}, 0, 60, 160 * channelRateFactor), @@ -505,8 +569,8 @@ main(int argc, char* argv[]) WIFI_STANDARD_80211ax, WIFI_PHY_BAND_5GHZ, clientChannelWidth, - 5, - 55, + dB_u{5}, + dB_u{55}, 0, 60, 160 * channelRateFactor), @@ -514,8 +578,8 @@ main(int argc, char* argv[]) WIFI_STANDARD_80211ax, WIFI_PHY_BAND_2_4GHZ, clientChannelWidth, - 5, - 55, + dB_u{5}, + dB_u{55}, 0, 60, 160 * channelRateFactor), @@ -588,7 +652,6 @@ main(int argc, char* argv[]) Config::SetDefault("ns3::MinstrelWifiManager::PrintStats", BooleanValue(true)); Config::SetDefault("ns3::MinstrelWifiManager::PrintSamples", BooleanValue(true)); Config::SetDefault("ns3::MinstrelHtWifiManager::PrintStats", BooleanValue(true)); - // Disable the default noise figure of 7 dBm in WifiPhy; the calculations // of SNR below assume that the only noise is thermal noise Config::SetDefault("ns3::WifiPhy::RxNoiseFigure", DoubleValue(0)); diff --git a/src/wifi/examples/wifi-phy-configuration.cc b/src/wifi/examples/wifi-phy-configuration.cc index 65d1e8fcd..ebcf0030e 100644 --- a/src/wifi/examples/wifi-phy-configuration.cc +++ b/src/wifi/examples/wifi-phy-configuration.cc @@ -124,8 +124,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); // We expect channel 36, width 20, frequency 5180 NS_ASSERT(phySta->GetChannelNumber() == 36); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 5180); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5180}); PrintAttributesIfEnabled(printAttributes); break; case 2: @@ -135,8 +135,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); // We expect channel 1, width 22, frequency 2412 NS_ASSERT(phySta->GetChannelNumber() == 1); - NS_ASSERT(phySta->GetChannelWidth() == 22); - NS_ASSERT(phySta->GetFrequency() == 2412); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{22}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{2412}); PrintAttributesIfEnabled(printAttributes); break; case 3: @@ -146,8 +146,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); // We expect channel 1, width 20, frequency 2412 NS_ASSERT(phySta->GetChannelNumber() == 1); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 2412); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{2412}); PrintAttributesIfEnabled(printAttributes); break; case 4: @@ -158,8 +158,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); // We expect channel 36, width 20, frequency 5180 NS_ASSERT(phySta->GetChannelNumber() == 36); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 5180); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5180}); PrintAttributesIfEnabled(printAttributes); break; case 5: @@ -169,8 +169,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); // We expect channel 1, width 20, frequency 2412 NS_ASSERT(phySta->GetChannelNumber() == 1); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 2412); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{2412}); PrintAttributesIfEnabled(printAttributes); break; case 6: @@ -180,8 +180,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); // We expect channel 42, width 80, frequency 5210 NS_ASSERT(phySta->GetChannelNumber() == 42); - NS_ASSERT(phySta->GetChannelWidth() == 80); - NS_ASSERT(phySta->GetFrequency() == 5210); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{80}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5210}); PrintAttributesIfEnabled(printAttributes); break; case 7: @@ -193,8 +193,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); // We expect channel 1, width 20, frequency 2412 NS_ASSERT(phySta->GetChannelNumber() == 1); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 2412); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{2412}); PrintAttributesIfEnabled(printAttributes); break; case 8: @@ -204,8 +204,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); // We expect channel 42, width 80, frequency 5210 NS_ASSERT(phySta->GetChannelNumber() == 42); - NS_ASSERT(phySta->GetChannelWidth() == 80); - NS_ASSERT(phySta->GetFrequency() == 5210); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{80}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5210}); PrintAttributesIfEnabled(printAttributes); break; case 9: @@ -216,8 +216,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); // We expect channel 7, width 80, frequency 5985 NS_ASSERT(phySta->GetChannelNumber() == 7); - NS_ASSERT(phySta->GetChannelWidth() == 80); - NS_ASSERT(phySta->GetFrequency() == 5985); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{80}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5985}); PrintAttributesIfEnabled(printAttributes); break; case 10: @@ -228,8 +228,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); // We expect channel 172, width 10, frequency 5860 NS_ASSERT(phySta->GetChannelNumber() == 172); - NS_ASSERT(phySta->GetChannelWidth() == 10); - NS_ASSERT(phySta->GetFrequency() == 5860); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{10}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5860}); PrintAttributesIfEnabled(printAttributes); break; case 11: @@ -240,8 +240,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); // We expect channel 171, width 5, frequency 5860 NS_ASSERT(phySta->GetChannelNumber() == 171); - NS_ASSERT(phySta->GetChannelWidth() == 5); - NS_ASSERT(phySta->GetFrequency() == 5860); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{5}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5860}); PrintAttributesIfEnabled(printAttributes); break; case 12: @@ -252,8 +252,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); // We expect channel 44, width 20, frequency 5220 NS_ASSERT(phySta->GetChannelNumber() == 44); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 5220); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5220}); PrintAttributesIfEnabled(printAttributes); break; case 13: @@ -271,8 +271,8 @@ main(int argc, char* argv[]) StringValue("{40, 0, BAND_5GHZ, 0}")); // We expect channel 40, width 20, frequency 5200 NS_ASSERT(phySta->GetChannelNumber() == 40); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 5200); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5200}); PrintAttributesIfEnabled(printAttributes); break; case 14: @@ -289,8 +289,8 @@ main(int argc, char* argv[]) "/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings", StringValue("{46, 0, BAND_5GHZ, 0}")); NS_ASSERT(phySta->GetChannelNumber() == 46); - NS_ASSERT(phySta->GetChannelWidth() == 40); - NS_ASSERT(phySta->GetFrequency() == 5230); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{40}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5230}); PrintAttributesIfEnabled(printAttributes); break; case 15: @@ -307,8 +307,8 @@ main(int argc, char* argv[]) "/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings", StringValue("{46, 0, BAND_5GHZ, 0}")); NS_ASSERT(phySta->GetChannelNumber() == 46); - NS_ASSERT(phySta->GetChannelWidth() == 40); - NS_ASSERT(phySta->GetFrequency() == 5230); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{40}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5230}); PrintAttributesIfEnabled(printAttributes); break; case 16: @@ -347,8 +347,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); // We expect channel number to be 100 due to frequency 5500 NS_ASSERT(phySta->GetChannelNumber() == 100); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 5500); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5500}); PrintAttributesIfEnabled(printAttributes); break; case 18: @@ -390,8 +390,8 @@ main(int argc, char* argv[]) phySta->SetAttribute("ChannelSettings", StringValue("{36, 0, BAND_5GHZ, 0}")); // We expect channel number to be 36 due to known center frequency 5180 NS_ASSERT(phySta->GetChannelNumber() == 36); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 5180); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5180}); exceptionThrown = false; try { @@ -405,8 +405,8 @@ main(int argc, char* argv[]) NS_ASSERT(exceptionThrown); phySta->SetAttribute("ChannelSettings", StringValue("{36, 0, BAND_5GHZ, 0}")); NS_ASSERT(phySta->GetChannelNumber() == 36); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 5180); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5180}); PrintAttributesIfEnabled(printAttributes); break; case 20: @@ -417,8 +417,8 @@ main(int argc, char* argv[]) apDevice = wifi.Install(phy, macAp, wifiApNode.Get(0)); phySta = GetYansWifiPhyPtr(staDevice); NS_ASSERT(phySta->GetChannelNumber() == 40); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 5200); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5200}); // Set both channel and frequency to consistent values after initialization wifi.SetStandard(WIFI_STANDARD_80211n); staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0)); @@ -426,8 +426,8 @@ main(int argc, char* argv[]) phySta = GetYansWifiPhyPtr(staDevice); phySta->SetAttribute("ChannelSettings", StringValue("{40, 0, BAND_5GHZ, 0}")); NS_ASSERT(phySta->GetChannelNumber() == 40); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 5200); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5200}); exceptionThrown = false; try { @@ -440,8 +440,8 @@ main(int argc, char* argv[]) phySta->SetAttribute("ChannelSettings", StringValue("{36, 0, BAND_5GHZ, 0}")); // We expect channel number to be 36 and an exception to be thrown NS_ASSERT(phySta->GetChannelNumber() == 36); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 5180); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5180}); NS_ASSERT(exceptionThrown); exceptionThrown = false; try @@ -455,8 +455,8 @@ main(int argc, char* argv[]) phySta->SetAttribute("ChannelSettings", StringValue("{36, 0, BAND_5GHZ, 0}")); // We expect channel number to be 36 and an exception to be thrown NS_ASSERT(phySta->GetChannelNumber() == 36); - NS_ASSERT(phySta->GetChannelWidth() == 20); - NS_ASSERT(phySta->GetFrequency() == 5180); + NS_ASSERT(phySta->GetChannelWidth() == MHz_u{20}); + NS_ASSERT(phySta->GetFrequency() == MHz_u{5180}); NS_ASSERT(exceptionThrown); PrintAttributesIfEnabled(printAttributes); break; diff --git a/src/wifi/examples/wifi-test-interference-helper.cc b/src/wifi/examples/wifi-test-interference-helper.cc index e5e421d1d..17a3c6761 100644 --- a/src/wifi/examples/wifi-test-interference-helper.cc +++ b/src/wifi/examples/wifi-test-interference-helper.cc @@ -185,19 +185,19 @@ InterferenceExperiment::Input::Input() xB(5), txModeA("OfdmRate54Mbps"), txModeB("OfdmRate54Mbps"), - txPowerLevelA(16.0206), - txPowerLevelB(16.0206), + txPowerLevelA(dBm_u{16.0206}), + txPowerLevelB(dBm_u{16.0206}), packetSizeA(1500), packetSizeB(1500), channelA(36), channelB(36), - widthA(20), - widthB(20), + widthA(MHz_u{20}), + widthB(MHz_u{20}), standard(WIFI_STANDARD_80211a), band(WIFI_PHY_BAND_5GHZ), preamble(WIFI_PREAMBLE_LONG), captureEnabled(false), - captureMargin(0) + captureMargin(dB_u{0}) { } diff --git a/src/wifi/examples/wifi-trans-example.cc b/src/wifi/examples/wifi-trans-example.cc index 57ea96fb8..7aa80f78e 100644 --- a/src/wifi/examples/wifi-trans-example.cc +++ b/src/wifi/examples/wifi-trans-example.cc @@ -77,8 +77,8 @@ main(int argc, char** argv) channelBand = "BAND_5GHZ"; ssid = Ssid("ns380211a"); dataRate = "OfdmRate6Mbps"; - freq = 5180; - if (bw != 20) + freq = MHz_u{5180}; + if (bw != MHz_u{20}) { std::cout << "Bandwidth is not compatible with standard" << std::endl; return 1; @@ -91,10 +91,10 @@ main(int argc, char** argv) channelBand = "BAND_5GHZ"; ssid = Ssid("ns380211p_10MHZ"); dataRate = "OfdmRate3MbpsBW10MHz"; - freq = 5860; + freq = MHz_u{5860}; dataStartTime = MicroSeconds(1400); dataDuration = MicroSeconds(600); - if (bw != 10) + if (bw != MHz_u{10}) { std::cout << "Bandwidth is not compatible with standard" << std::endl; return 1; @@ -107,10 +107,10 @@ main(int argc, char** argv) channelBand = "BAND_5GHZ"; ssid = Ssid("ns380211p_5MHZ"); dataRate = "OfdmRate1_5MbpsBW5MHz"; - freq = 5860; + freq = MHz_u{5860}; dataStartTime = MicroSeconds(2500); dataDuration = MicroSeconds(1200); - if (bw != 5) + if (bw != MHz_u{5}) { std::cout << "Bandwidth is not compatible with standard" << std::endl; return 1; @@ -123,10 +123,10 @@ main(int argc, char** argv) channelBand = "BAND_2_4GHZ"; ssid = Ssid("ns380211n_2_4GHZ"); dataRate = "HtMcs0"; - freq = 2402 + (bw / 2); // so as to have 2412/2422 for 20/40 + freq = MHz_u{2402} + (bw / 2); // so as to have 2412/2422 for 20/40 dataStartTime = MicroSeconds(4700); dataDuration = MicroSeconds(400); - if (bw != 20 && bw != 40) + if (bw != MHz_u{20} && bw != MHz_u{40}) { std::cout << "Bandwidth is not compatible with standard" << std::endl; return 1; @@ -139,9 +139,9 @@ main(int argc, char** argv) channelBand = "BAND_5GHZ"; ssid = Ssid("ns380211n_5GHZ"); dataRate = "HtMcs0"; - freq = 5170 + (bw / 2); // so as to have 5180/5190 for 20/40 + freq = MHz_u{5170} + (bw / 2); // so as to have 5180/5190 for 20/40 dataStartTime = MicroSeconds(1000); - if (bw != 20 && bw != 40) + if (bw != MHz_u{20} && bw != MHz_u{40}) { std::cout << "Bandwidth is not compatible with standard" << std::endl; return 1; @@ -154,10 +154,10 @@ main(int argc, char** argv) channelBand = "BAND_5GHZ"; ssid = Ssid("ns380211ac"); dataRate = "VhtMcs0"; - freq = 5170 + (bw / 2); // so as to have 5180/5190/5210/5250 for 20/40/80/160 + freq = MHz_u{5170} + (bw / 2); // so as to have 5180/5190/5210/5250 for 20/40/80/160 dataStartTime = MicroSeconds(1100); dataDuration += MicroSeconds(400); // account for ADDBA procedure - if (bw != 20 && bw != 40 && bw != 80 && bw != 160) + if (bw != MHz_u{20} && bw != MHz_u{40} && bw != MHz_u{80} && bw != MHz_u{160}) { std::cout << "Bandwidth is not compatible with standard" << std::endl; return 1; @@ -170,10 +170,10 @@ main(int argc, char** argv) channelBand = "BAND_2_4GHZ"; ssid = Ssid("ns380211ax_2_4GHZ"); dataRate = "HeMcs0"; - freq = 2402 + (bw / 2); // so as to have 2412/2422/2442 for 20/40/80 + freq = MHz_u{2402} + (bw / 2); // so as to have 2412/2422/2442 for 20/40/80 dataStartTime = MicroSeconds(5500); dataDuration += MicroSeconds(2000); // account for ADDBA procedure - if (bw != 20 && bw != 40 && bw != 80) + if (bw != MHz_u{20} && bw != MHz_u{40} && bw != MHz_u{80}) { std::cout << "Bandwidth is not compatible with standard" << std::endl; return 1; @@ -186,10 +186,10 @@ main(int argc, char** argv) channelBand = "BAND_5GHZ"; ssid = Ssid("ns380211ax_5GHZ"); dataRate = "HeMcs0"; - freq = 5170 + (bw / 2); // so as to have 5180/5190/5210/5250 for 20/40/80/160 + freq = MHz_u{5170} + (bw / 2); // so as to have 5180/5190/5210/5250 for 20/40/80/160 dataStartTime = MicroSeconds(1200); dataDuration += MicroSeconds(500); // account for ADDBA procedure - if (bw != 20 && bw != 40 && bw != 80 && bw != 160) + if (bw != MHz_u{20} && bw != MHz_u{40} && bw != MHz_u{80} && bw != MHz_u{160}) { std::cout << "Bandwidth is not compatible with standard" << std::endl; return 1; @@ -279,12 +279,13 @@ main(int argc, char** argv) /* frequency range for spectrum analyzer */ std::vector freqs; - int margin = 2; // 1MHz margin on each side + MHz_u margin = 2; // 1MHz margin on each side int band = (bw + margin); freqs.reserve(4 * 10 * band); + const MHz_u scale{0.1}; for (int i = 0; i < (4 * 10 * band); ++i) // conversion to 100kHz scale { - freqs.push_back(i * MHzToHz(0.1) + MHzToHz(freq - 2 * band)); + freqs.push_back(MHzToHz((i * scale) + (freq - 2 * band))); } Ptr spectrumAnalyzerFreqModel = Create(freqs); diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index d91fbb44e..4bfad7696 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -416,7 +416,7 @@ WifiPhyHelper::GetRadiotapHeader(RadiotapHeader& header, RadiotapHeader::MCS_KNOWN_HT_FORMAT | RadiotapHeader::MCS_KNOWN_NESS | RadiotapHeader::MCS_KNOWN_FEC_TYPE | RadiotapHeader::MCS_KNOWN_STBC; - if (channelWidth == 40) + if (channelWidth == MHz_u{40}) { mcsFields.flags |= RadiotapHeader::MCS_FLAGS_BANDWIDTH_40; } @@ -480,15 +480,15 @@ WifiPhyHelper::GetRadiotapHeader(RadiotapHeader& header, vhtFields.known |= RadiotapHeader::VHT_KNOWN_BEAMFORMED | RadiotapHeader::VHT_KNOWN_BANDWIDTH; // TODO: bandwidths can be provided with sideband info - if (channelWidth == 40) + if (channelWidth == MHz_u{40}) { vhtFields.bandwidth = 1; } - else if (channelWidth == 80) + else if (channelWidth == MHz_u{80}) { vhtFields.bandwidth = 4; } - else if (channelWidth == 160) + else if (channelWidth == MHz_u{160}) { vhtFields.bandwidth = 11; } @@ -570,15 +570,15 @@ WifiPhyHelper::GetRadiotapHeader(RadiotapHeader& header, NS_ABORT_MSG("Unexpected RU type"); } } - else if (channelWidth == 40) + else if (channelWidth == MHz_u{40}) { heFields.data5 |= RadiotapHeader::HE_DATA5_DATA_BW_RU_ALLOC_40MHZ; } - else if (channelWidth == 80) + else if (channelWidth == MHz_u{80}) { heFields.data5 |= RadiotapHeader::HE_DATA5_DATA_BW_RU_ALLOC_80MHZ; } - else if (channelWidth == 160) + else if (channelWidth == MHz_u{160}) { heFields.data5 |= RadiotapHeader::HE_DATA5_DATA_BW_RU_ALLOC_160MHZ; } @@ -644,9 +644,9 @@ WifiPhyHelper::GetRadiotapHeader(RadiotapHeader& header, GetRadiotapField(RadiotapHeader::USIG2_MU_B9_B10_SIG_MCS, txVector.GetSigBMode().GetMcsValue()); std::optional isLow80MHz; - if (txVector.IsDlMu() && channelWidth > 80) + if (txVector.IsDlMu() && channelWidth > MHz_u{80}) { - const auto isLowP80 = p20Index < (channelWidth / 40); + const auto isLowP80 = p20Index < (channelWidth / MHz_u{40}); const auto isP80 = txVector.GetHeMuUserInfo(staId).ru.GetPrimary80MHz(); isLow80MHz = (isLowP80 && isP80) || (!isLowP80 && !isP80); } @@ -732,13 +732,13 @@ WifiPhyHelper::GetRadiotapHeader(RadiotapHeader& header, ehtFields.data.at(1) |= GetRadiotapField(RadiotapHeader::EHT_DATA1_RU_MRU_INDEX, ruIndex) | GetRadiotapField(RadiotapHeader::EHT_DATA1_RU_ALLOC_CC_1_1_1, ruAllocation.at(0)); - if (channelWidth >= 40) + if (channelWidth >= MHz_u{40}) { ehtFields.data.at(2) = RadiotapHeader::EHT_DATA2_RU_ALLOC_CC_2_1_1_KNOWN | GetRadiotapField(RadiotapHeader::EHT_DATA2_RU_ALLOC_CC_2_1_1, ruAllocation.at(1)); } - if (channelWidth >= 80) + if (channelWidth >= MHz_u{80}) { ehtFields.data.at(2) |= RadiotapHeader::EHT_DATA2_RU_ALLOC_CC_1_1_2_KNOWN | @@ -746,7 +746,7 @@ WifiPhyHelper::GetRadiotapHeader(RadiotapHeader& header, GetRadiotapField(RadiotapHeader::EHT_DATA2_RU_ALLOC_CC_1_1_2, ruAllocation.at(2)) | GetRadiotapField(RadiotapHeader::EHT_DATA2_RU_ALLOC_CC_2_1_2, ruAllocation.at(3)); } - if (channelWidth >= 160) + if (channelWidth >= MHz_u{160}) { ehtFields.data.at(3) = RadiotapHeader::EHT_DATA3_RU_ALLOC_CC_1_2_1_KNOWN | @@ -759,7 +759,7 @@ WifiPhyHelper::GetRadiotapHeader(RadiotapHeader& header, RadiotapHeader::EHT_DATA4_RU_ALLOC_CC_2_2_2_KNOWN | GetRadiotapField(RadiotapHeader::EHT_DATA4_RU_ALLOC_CC_2_2_2, ruAllocation.at(7)); ehtFields.known |= RadiotapHeader::EHT_KNOWN_PRIMARY_80; - const auto isLowP80 = p20Index < (channelWidth / 40); + const auto isLowP80 = p20Index < (channelWidth / MHz_u{40}); ehtFields.data.at(1) |= GetRadiotapField(RadiotapHeader::EHT_DATA1_PRIMARY_80, (isLowP80 ? RadiotapHeader::EHT_DATA1_PRIMARY_80_LOWEST diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index a4843375e..a7ae0a310 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -798,10 +798,10 @@ ApWifiMac::GetHtOperation(uint8_t linkId) const auto phy = GetWifiPhy(linkId); auto remoteStationManager = GetWifiRemoteStationManager(linkId); - operation.SetPrimaryChannel(phy->GetPrimaryChannelNumber(20)); + operation.SetPrimaryChannel(phy->GetPrimaryChannelNumber(MHz_u{20})); operation.SetRifsMode(false); operation.SetNonGfHtStasPresent(true); - if (phy->GetChannelWidth() > 20) + if (phy->GetChannelWidth() > MHz_u{20}) { operation.SetSecondaryChannelOffset(1); operation.SetStaChannelWidth(1); @@ -902,7 +902,7 @@ ApWifiMac::GetVhtOperation(uint8_t linkId) const const auto bssBandwidth = phy->GetChannelWidth(); // Set to 0 for 20 MHz or 40 MHz BSS bandwidth. // Set to 1 for 80 MHz, 160 MHz or 80+80 MHz BSS bandwidth. - operation.SetChannelWidth((bssBandwidth > 40) ? 1 : 0); + operation.SetChannelWidth((bssBandwidth > MHz_u{40}) ? 1 : 0); // For 20, 40, or 80 MHz BSS bandwidth, indicates the channel center frequency // index for the 20, 40, or 80 MHz channel on which the VHT BSS operates. // For 160 MHz BSS bandwidth and the Channel Width subfield equal to 1, @@ -910,8 +910,9 @@ ApWifiMac::GetVhtOperation(uint8_t linkId) const // segment that contains the primary channel. // For 80+80 MHz BSS bandwidth and the Channel Width subfield equal to 1 or 3, // indicates the channel center frequency index for the primary 80 MHz channel of the VHT BSS. - operation.SetChannelCenterFrequencySegment0( - (bssBandwidth == 160) ? phy->GetPrimaryChannelNumber(80) : phy->GetChannelNumber()); + operation.SetChannelCenterFrequencySegment0((bssBandwidth == MHz_u{160}) + ? phy->GetPrimaryChannelNumber(MHz_u{80}) + : phy->GetChannelNumber()); // For a 20, 40, or 80 MHz BSS bandwidth, this subfield is set to 0. // For a 160 MHz BSS bandwidth and the Channel Width subfield equal to 1, // indicates the channel center frequency index of the 160 MHz channel on @@ -921,9 +922,10 @@ ApWifiMac::GetVhtOperation(uint8_t linkId) const const auto& operatingChannel = phy->GetOperatingChannel(); const auto is80Plus80 = operatingChannel.GetWidthType() == WifiChannelWidthType::CW_80_PLUS_80MHZ; - operation.SetChannelCenterFrequencySegment1( - (bssBandwidth == 160) ? is80Plus80 ? operatingChannel.GetNumber(1) : phy->GetChannelNumber() - : 0); + operation.SetChannelCenterFrequencySegment1((bssBandwidth == MHz_u{160}) + ? is80Plus80 ? operatingChannel.GetNumber(1) + : phy->GetChannelNumber() + : 0); uint8_t maxSpatialStream = phy->GetMaxSupportedRxSpatialStreams(); for (const auto& sta : GetLink(linkId).staList) { @@ -977,12 +979,13 @@ ApWifiMac::GetHeOperation(uint8_t linkId) const HeOperation::OpInfo6GHz op6Ghz; const auto bw = phy->GetChannelWidth(); const auto ch = phy->GetOperatingChannel(); - op6Ghz.m_chWid = (bw == 20) ? 0 : (bw == 40) ? 1 : (bw == 80) ? 2 : 3; - op6Ghz.m_primCh = ch.GetPrimaryChannelNumber(20, WIFI_STANDARD_80211ax); - op6Ghz.m_chCntrFreqSeg0 = - (bw == 160) ? ch.GetPrimaryChannelNumber(80, WIFI_STANDARD_80211ax) : ch.GetNumber(); + op6Ghz.m_chWid = (bw == MHz_u{20}) ? 0 : (bw == MHz_u{40}) ? 1 : (bw == MHz_u{80}) ? 2 : 3; + op6Ghz.m_primCh = ch.GetPrimaryChannelNumber(MHz_u{20}, WIFI_STANDARD_80211ax); + op6Ghz.m_chCntrFreqSeg0 = (bw == MHz_u{160}) + ? ch.GetPrimaryChannelNumber(MHz_u{80}, WIFI_STANDARD_80211ax) + : ch.GetNumber(); // TODO: for 80+80 MHz channels, set this field to the secondary 80 MHz segment number - op6Ghz.m_chCntrFreqSeg1 = (bw == 160) ? ch.GetNumber() : 0; + op6Ghz.m_chCntrFreqSeg1 = (bw == MHz_u{160}) ? ch.GetNumber() : 0; operation.m_6GHzOpInfo = op6Ghz; } diff --git a/src/wifi/model/channel-access-manager.cc b/src/wifi/model/channel-access-manager.cc index 584891c0b..5bcc59053 100644 --- a/src/wifi/model/channel-access-manager.cc +++ b/src/wifi/model/channel-access-manager.cc @@ -382,8 +382,8 @@ ChannelAccessManager::ResizeLastBusyStructs() m_lastBusyEnd.emplace(WIFI_CHANLIST_PRIMARY, now); m_lastIdle.emplace(WIFI_CHANLIST_PRIMARY, Timespan{now, now}); - const auto width = m_phy ? m_phy->GetChannelWidth() : 0; - std::size_t size = (width > 20 && m_phy->GetStandard() >= WIFI_STANDARD_80211ax) + const auto width = m_phy ? m_phy->GetChannelWidth() : MHz_u{0}; + std::size_t size = (width > MHz_u{20} && m_phy->GetStandard() >= WIFI_STANDARD_80211ax) ? Count20MHzSubchannels(width) : 0; m_lastPer20MHzBusyEnd.resize(size, now); @@ -393,7 +393,7 @@ ChannelAccessManager::ResizeLastBusyStructs() return; } - if (width >= 40) + if (width >= MHz_u{40}) { m_lastBusyEnd.emplace(WIFI_CHANLIST_SECONDARY, now); m_lastIdle.emplace(WIFI_CHANLIST_SECONDARY, Timespan{now, now}); @@ -404,7 +404,7 @@ ChannelAccessManager::ResizeLastBusyStructs() m_lastIdle.erase(WIFI_CHANLIST_SECONDARY); } - if (width >= 80) + if (width >= MHz_u{80}) { m_lastBusyEnd.emplace(WIFI_CHANLIST_SECONDARY40, now); m_lastIdle.emplace(WIFI_CHANLIST_SECONDARY40, Timespan{now, now}); @@ -415,7 +415,7 @@ ChannelAccessManager::ResizeLastBusyStructs() m_lastIdle.erase(WIFI_CHANLIST_SECONDARY40); } - if (width >= 160) + if (width >= MHz_u{160}) { m_lastBusyEnd.emplace(WIFI_CHANLIST_SECONDARY80, now); m_lastIdle.emplace(WIFI_CHANLIST_SECONDARY80, Timespan{now, now}); @@ -620,9 +620,10 @@ ChannelAccessManager::DoGrantDcfAccess() auto interval = (m_phy->GetPhyBand() == WIFI_PHY_BAND_2_4GHZ) ? GetSifs() + 2 * GetSlot() : m_phy->GetPifs(); - auto width = (m_phy->GetOperatingChannel().IsOfdm() && m_phy->GetChannelWidth() > 20) - ? GetLargestIdlePrimaryChannel(interval, now) - : m_phy->GetChannelWidth(); + auto width = + (m_phy->GetOperatingChannel().IsOfdm() && m_phy->GetChannelWidth() > MHz_u{20}) + ? GetLargestIdlePrimaryChannel(interval, now) + : m_phy->GetChannelWidth(); if (m_feManager->StartTransmission(txop, width)) { for (auto& collidingTxop : internalCollisionTxops) @@ -848,7 +849,7 @@ ChannelAccessManager::GetLargestIdlePrimaryChannel(Time interval, Time end) if (lastIdle.second.start <= end - interval && lastIdle.second.end >= end) { // channel idle, update width - width = (width == 0) ? 20 : (2 * width); + width = (width == MHz_u{0}) ? MHz_u{20} : (2 * width); } else { @@ -863,7 +864,7 @@ ChannelAccessManager::GetPer20MHzBusy(const std::set& indices) const { const auto now = Simulator::Now(); - if (m_phy->GetChannelWidth() < 40) + if (m_phy->GetChannelWidth() < MHz_u{40}) { NS_ASSERT_MSG(indices.size() == 1 && *indices.cbegin() == 0, "Index 0 only can be specified if the channel width is less than 40 MHz"); diff --git a/src/wifi/model/ctrl-headers.cc b/src/wifi/model/ctrl-headers.cc index bf83e1d19..2e4884916 100644 --- a/src/wifi/model/ctrl-headers.cc +++ b/src/wifi/model/ctrl-headers.cc @@ -2136,7 +2136,7 @@ CtrlTriggerHeader::SetUlBandwidth(MHz_u bw) MHz_u CtrlTriggerHeader::GetUlBandwidth() const { - return (1 << m_ulBandwidth) * 20; + return (1 << m_ulBandwidth) * MHz_u{20}; } void diff --git a/src/wifi/model/eht/advanced-emlsr-manager.cc b/src/wifi/model/eht/advanced-emlsr-manager.cc index e16f48ccb..37428bea2 100644 --- a/src/wifi/model/eht/advanced-emlsr-manager.cc +++ b/src/wifi/model/eht/advanced-emlsr-manager.cc @@ -379,7 +379,7 @@ AdvancedEmlsrManager::CheckNavAndCcaLastPifs(Ptr phy, uint8_t linkId, P // check CCA on the entire channel auto width = caManager->GetLargestIdlePrimaryChannel(pifs, Simulator::Now()); - if (!isBusy && width > 0) + if (!isBusy && width > MHz_u{0}) { // medium idle, start TXOP width = std::min(width, GetChannelForMainPhy(linkId).GetTotalWidth()); diff --git a/src/wifi/model/eht/eht-phy.cc b/src/wifi/model/eht/eht-phy.cc index f5bb05af4..39c7eef0b 100644 --- a/src/wifi/model/eht/eht-phy.cc +++ b/src/wifi/model/eht/eht-phy.cc @@ -129,7 +129,7 @@ EhtPhy::GetSigBSize(const WifiTxVector& txVector) const return EhtPpdu::GetEhtSigFieldSize( txVector.GetChannelWidth(), txVector.GetRuAllocation( - m_wifiPhy ? m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20) : 0), + m_wifiPhy ? m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(MHz_u{20}) : 0), txVector.GetEhtPpduType(), txVector.IsSigBCompression(), txVector.IsSigBCompression() ? txVector.GetHeMuUserInfoMap().size() : 0); diff --git a/src/wifi/model/eht/eht-ppdu.cc b/src/wifi/model/eht/eht-ppdu.cc index f2fdd323a..75fa83432 100644 --- a/src/wifi/model/eht/eht-ppdu.cc +++ b/src/wifi/model/eht/eht-ppdu.cc @@ -48,18 +48,19 @@ EhtPpdu::SetEhtPhyHeader(const WifiTxVector& txVector) NS_ASSERT(bssColor < 64); if (ns3::IsDlMu(m_preamble)) { - const auto p20Index = m_operatingChannel.GetPrimaryChannelIndex(20); + const auto p20Index = m_operatingChannel.GetPrimaryChannelIndex(MHz_u{20}); m_ehtPhyHeader.emplace(EhtMuPhyHeader{ .m_bandwidth = GetChannelWidthEncodingFromMhz(txVector.GetChannelWidth()), .m_bssColor = bssColor, .m_ppduType = txVector.GetEhtPpduType(), // TODO: EHT PPDU should store U-SIG per 20 MHz band, assume it is the lowest 20 MHz // band for now - .m_puncturedChannelInfo = GetPuncturedInfo( - txVector.GetInactiveSubchannels(), - txVector.GetEhtPpduType(), - (txVector.IsDlMu() && (txVector.GetChannelWidth() > 80)) ? std::optional{true} - : std::nullopt), + .m_puncturedChannelInfo = + GetPuncturedInfo(txVector.GetInactiveSubchannels(), + txVector.GetEhtPpduType(), + (txVector.IsDlMu() && (txVector.GetChannelWidth() > MHz_u{80})) + ? std::optional{true} + : std::nullopt), .m_ehtSigMcs = txVector.GetSigBMode().GetMcsValue(), .m_giLtfSize = GetGuardIntervalAndNltfEncoding(txVector.GetGuardInterval(), 2 /*NLTF currently unused*/), @@ -127,7 +128,7 @@ EhtPpdu::SetTxVectorFromPhyHeaders(WifiTxVector& txVector) const txVector.SetChannelWidth(bw); txVector.SetBssColor(ehtPhyHeader->m_bssColor); txVector.SetEhtPpduType(ehtPhyHeader->m_ppduType); - if (bw > 80) + if (bw > MHz_u{80}) { // TODO: use punctured channel information } @@ -135,7 +136,7 @@ EhtPpdu::SetTxVectorFromPhyHeaders(WifiTxVector& txVector) const txVector.SetGuardInterval(GetGuardIntervalFromEncoding(ehtPhyHeader->m_giLtfSize)); const auto ruAllocation = ehtPhyHeader->m_ruAllocationA; // RU Allocation-B not supported // yet - if (const auto p20Index = m_operatingChannel.GetPrimaryChannelIndex(20); + if (const auto p20Index = m_operatingChannel.GetPrimaryChannelIndex(MHz_u{20}); ruAllocation.has_value()) { txVector.SetRuAllocation(ruAllocation.value(), p20Index); @@ -213,14 +214,15 @@ EhtPpdu::GetEhtSigFieldSize(MHz_u channelWidth, if (!compression) { commonFieldSize = 4 /* CRC */ + 6 /* tail */; - if (channelWidth <= 40) + if (channelWidth <= MHz_u{40}) { commonFieldSize += 8; // only one allocation subfield } else { commonFieldSize += - 8 * (channelWidth / 40) /* one allocation field per 40 MHz */ + 1 /* center RU */; + 8 * (channelWidth / MHz_u{40}) /* one allocation field per 40 MHz */ + + 1 /* center RU */; } } diff --git a/src/wifi/model/eht/emlsr-manager.cc b/src/wifi/model/eht/emlsr-manager.cc index 8884c2c99..a3cc8bcde 100644 --- a/src/wifi/model/eht/emlsr-manager.cc +++ b/src/wifi/model/eht/emlsr-manager.cc @@ -1181,7 +1181,7 @@ EmlsrManager::ComputeOperatingChannels() "Primary" << auxPhyMaxWidth << " channel not found"); m_auxPhyChannels.emplace(linkId, chIt); // find the P20 index for the channel used by the aux PHYs - auto p20Index = channel.GetPrimaryChannelIndex(20); + auto p20Index = channel.GetPrimaryChannelIndex(MHz_u{20}); while (mainPhyChWidth > auxPhyMaxWidth) { mainPhyChWidth /= 2; diff --git a/src/wifi/model/error-rate-model.cc b/src/wifi/model/error-rate-model.cc index b8a47b107..c9b7cc23b 100644 --- a/src/wifi/model/error-rate-model.cc +++ b/src/wifi/model/error-rate-model.cc @@ -62,7 +62,7 @@ ErrorRateModel::GetChunkSuccessRate(WifiMode mode, if (mode.GetModulationClass() == WIFI_MOD_CLASS_DSSS || mode.GetModulationClass() == WIFI_MOD_CLASS_HR_DSSS) { - switch (mode.GetDataRate(22)) + switch (mode.GetDataRate(MHz_u{22})) { case 1000000: return DsssErrorRateModel::GetDsssDbpskSuccessRate(snr, nbits); diff --git a/src/wifi/model/he/he-frame-exchange-manager.cc b/src/wifi/model/he/he-frame-exchange-manager.cc index 1a109645a..1f13f8d1e 100644 --- a/src/wifi/model/he/he-frame-exchange-manager.cc +++ b/src/wifi/model/he/he-frame-exchange-manager.cc @@ -1260,20 +1260,20 @@ HeFrameExchangeManager::GetCtsTxVectorAfterMuRts(const CtrlTriggerHeader& trigge if (uint8_t ru = userInfoIt->GetMuRtsRuAllocation(); ru < 65) { - bw = 20; + bw = MHz_u{20}; } else if (ru < 67) { - bw = 40; + bw = MHz_u{40}; } else if (ru == 67) { - bw = 80; + bw = MHz_u{80}; } else { NS_ASSERT(ru == 68); - bw = 160; + bw = MHz_u{160}; } auto txVector = GetWifiRemoteStationManager()->GetCtsTxVector(m_bssid, GetCtsModeAfterMuRts()); diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index 3f0a5c209..29b442429 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -217,7 +217,7 @@ HePhy::GetSigBSize(const WifiTxVector& txVector) const return HePpdu::GetSigBFieldSize( txVector.GetChannelWidth(), txVector.GetRuAllocation( - m_wifiPhy ? m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20) : 0), + m_wifiPhy ? m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(MHz_u{20}) : 0), txVector.IsSigBCompression(), txVector.IsSigBCompression() ? txVector.GetHeMuUserInfoMap().size() : 0); } @@ -232,7 +232,7 @@ HePhy::GetSigBDuration(const WifiTxVector& txVector) const const auto symbolDuration = MicroSeconds(4); // Number of data bits per symbol const auto ndbps = - GetSigBMode(txVector).GetDataRate(20) * symbolDuration.GetNanoSeconds() / 1e9; + GetSigBMode(txVector).GetDataRate(MHz_u{20}) * symbolDuration.GetNanoSeconds() / 1e9; const auto numSymbols = ceil((sigBSize) / ndbps); return FemtoSeconds(static_cast(numSymbols * symbolDuration.GetFemtoSeconds())); @@ -985,7 +985,8 @@ HePhy::GetRuBandForTx(const WifiTxVector& txVector, uint16_t staId) const HeRu::SubcarrierGroup group = HeRu::GetSubcarrierGroup( channelWidth, ru.GetRuType(), - ru.GetPhyIndex(channelWidth, m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20))); + ru.GetPhyIndex(channelWidth, + m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(MHz_u{20}))); // for a TX spectrum, the guard bandwidth is a function of the transmission channel width // and the spectrum width equals the transmission channel width (hence bandIndex equals 0) const auto indices = ConvertHeRuSubcarriers(channelWidth, @@ -1015,7 +1016,8 @@ HePhy::GetRuBandForRx(const WifiTxVector& txVector, uint16_t staId) const HeRu::SubcarrierGroup group = HeRu::GetSubcarrierGroup( channelWidth, ru.GetRuType(), - ru.GetPhyIndex(channelWidth, m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20))); + ru.GetPhyIndex(channelWidth, + m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(MHz_u{20}))); // for an RX spectrum, the guard bandwidth is a function of the operating channel width // and the spectrum width equals the operating channel width const auto indices = ConvertHeRuSubcarriers( @@ -1054,7 +1056,7 @@ HePhy::GetNonOfdmaBand(const WifiTxVector& txVector, uint16_t staId) const channelWidth, nonOfdmaRu.GetRuType(), nonOfdmaRu.GetPhyIndex(channelWidth, - m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20))); + m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(MHz_u{20}))); const auto indices = ConvertHeRuSubcarriers( channelWidth, GetGuardBandwidth(m_wifiPhy->GetChannelWidth()), @@ -1080,9 +1082,9 @@ HePhy::GetNonOfdmaWidth(HeRu::RuSpec ru) const { // the center 26-tone RU in an 80 MHz channel is not fully covered by // any 20 MHz channel, but only by an 80 MHz channel - return 80; + return MHz_u{80}; } - return std::max(HeRu::GetBandwidth(ru.GetRuType()), 20); + return std::max(HeRu::GetBandwidth(ru.GetRuType()), MHz_u{20}); } uint64_t @@ -1102,9 +1104,9 @@ HePhy::GetMeasurementChannelWidth(const Ptr ppdu) const * primitive for a PPDU received in the primary or at the secondary 20 MHz channel, the * secondary 40 MHz channel, or the secondary 80 MHz channel. */ - if (channelWidth >= 40 && ppdu->GetUid() != m_previouslyTxPpduUid) + if (channelWidth >= MHz_u{40} && ppdu->GetUid() != m_previouslyTxPpduUid) { - channelWidth = 20; + channelWidth = MHz_u{20}; } return channelWidth; } @@ -1130,9 +1132,9 @@ HePhy::GetCcaThreshold(const Ptr ppdu, WifiChannelListType chann const auto ppduBw = ppdu->GetTxVector().GetChannelWidth(); auto obssPdLevel = m_obssPdAlgorithm->GetObssPdLevel(); auto bw = ppduBw; - while (bw > 20) + while (bw > MHz_u{20}) { - obssPdLevel += 3; + obssPdLevel += dB_u{3}; bw /= 2; } @@ -1198,7 +1200,7 @@ HePhy::GetPer20MHzDurations(const Ptr ppdu) * primitive, the PHY shall set the per20bitmap to indicate the busy/idle status of each 20 MHz * subchannel. */ - if (m_wifiPhy->GetChannelWidth() < 40) + if (m_wifiPhy->GetChannelWidth() < MHz_u{40}) { return {}; } @@ -1208,7 +1210,7 @@ HePhy::GetPer20MHzDurations(const Ptr ppdu) m_wifiPhy->GetChannelWidth()); for (auto index : indices) { - auto band = m_wifiPhy->GetBand(20, index); + auto band = m_wifiPhy->GetBand(MHz_u{20}, index); /** * A signal is present on the 20 MHz subchannel at or above a threshold of –62 dBm at the * receiver's antenna(s). The PHY shall indicate that the 20 MHz subchannel is busy a period @@ -1220,9 +1222,10 @@ HePhy::GetPer20MHzDurations(const Ptr ppdu) if (ppdu) { - const MHz_u subchannelMinFreq = - m_wifiPhy->GetFrequency() - (m_wifiPhy->GetChannelWidth() / 2) + (index * 20); - const MHz_u subchannelMaxFreq = subchannelMinFreq + 20; + const MHz_u subchannelMinFreq = m_wifiPhy->GetFrequency() - + (m_wifiPhy->GetChannelWidth() / 2) + + (index * MHz_u{20}); + const MHz_u subchannelMaxFreq = subchannelMinFreq + MHz_u{20}; const auto ppduBw = ppdu->GetTxVector().GetChannelWidth(); if (ppduBw <= m_wifiPhy->GetChannelWidth() && @@ -1243,9 +1246,10 @@ HePhy::GetPer20MHzDurations(const Ptr ppdu) * The PHY shall indicate that the 20 MHz subchannel is busy with > 90% * probability within a period aCCAMidTime. */ - ccaThreshold = - obssPdLevel.has_value() ? std::max(-72.0, obssPdLevel.value()) : -72.0; - band = m_wifiPhy->GetBand(20, index); + ccaThreshold = obssPdLevel.has_value() + ? std::max(dBm_u{-72.0}, obssPdLevel.value()) + : dBm_u{-72.0}; + band = m_wifiPhy->GetBand(MHz_u{20}, index); break; case 40: /** @@ -1254,9 +1258,10 @@ HePhy::GetPer20MHzDurations(const Ptr ppdu) * the receiver's antenna(s) is present. The PHY shall indicate that the 20 MHz * subchannel is busy with > 90% probability within a period aCCAMidTime. */ - ccaThreshold = - obssPdLevel.has_value() ? std::max(-72.0, obssPdLevel.value() + 3) : -72.0; - band = m_wifiPhy->GetBand(40, std::floor(index / 2)); + ccaThreshold = obssPdLevel.has_value() + ? std::max(dBm_u{-72.0}, obssPdLevel.value() + dB_u{3}) + : dBm_u{-72.0}; + band = m_wifiPhy->GetBand(MHz_u{40}, std::floor(index / 2)); break; case 80: /** @@ -1265,9 +1270,10 @@ HePhy::GetPer20MHzDurations(const Ptr ppdu) * receiver's antenna(s) is present. The PHY shall indicate that the 20 MHz * subchannel is busy with > 90% probability within a period aCCAMidTime. */ - ccaThreshold = - obssPdLevel.has_value() ? std::max(-69.0, obssPdLevel.value() + 6) : -69.0; - band = m_wifiPhy->GetBand(80, std::floor(index / 4)); + ccaThreshold = obssPdLevel.has_value() + ? std::max(dBm_u{-69.0}, obssPdLevel.value() + dB_u{6}) + : dBm_u{-69.0}; + band = m_wifiPhy->GetBand(MHz_u{80}, std::floor(index / 4)); break; case 160: // Not defined in the standard: keep -62 dBm @@ -1354,7 +1360,7 @@ HePhy::GetTxPowerSpectralDensity(Watt_u txPower, const auto& puncturedSubchannels = txVector.GetInactiveSubchannels(); if (!puncturedSubchannels.empty()) { - const auto p20Index = m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20); + const auto p20Index = m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(MHz_u{20}); const auto& indices = m_wifiPhy->GetOperatingChannel().GetAll20MHzChannelIndicesInPrimary(channelWidth); const auto p20IndexInBitmap = p20Index - *(indices.cbegin()); @@ -1370,7 +1376,7 @@ HePhy::GetTxPowerSpectralDensity(Watt_u txPower, // non-HE portion is sent only on the 20 MHz channels covering the RU const auto staId = GetStaId(ppdu); const auto ruWidth = HeRu::GetBandwidth(txVector.GetRu(staId).GetRuType()); - channelWidth = (ruWidth < 20) ? 20 : ruWidth; + channelWidth = (ruWidth < MHz_u{20}) ? MHz_u{20} : ruWidth; return WifiSpectrumValueHelper::CreateDuplicated20MhzTxPowerSpectralDensity( GetCenterFrequenciesForNonHePart(ppdu, staId), channelWidth, @@ -1453,10 +1459,11 @@ HePhy::GetCenterFrequenciesForNonHePart(Ptr ppdu, uint16_t staId const MHz_u startingFrequency = centerFrequencies.front() - (currentWidth / 2); centerFrequencies.front() = startingFrequency + - nonOfdmaWidth * (nonOfdmaRu.GetPhyIndex( - currentWidth, - m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20)) - - 1) + + nonOfdmaWidth * + (nonOfdmaRu.GetPhyIndex( + currentWidth, + m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(MHz_u{20})) - + 1) + nonOfdmaWidth / 2; } return centerFrequencies; diff --git a/src/wifi/model/he/he-ppdu.cc b/src/wifi/model/he/he-ppdu.cc index e1fb1f770..b8420b869 100644 --- a/src/wifi/model/he/he-ppdu.cc +++ b/src/wifi/model/he/he-ppdu.cc @@ -119,7 +119,7 @@ HePpdu::SetHeSigHeader(const WifiTxVector& txVector) } else if (ns3::IsDlMu(m_preamble)) { - const auto p20Index = m_operatingChannel.GetPrimaryChannelIndex(20); + const auto p20Index = m_operatingChannel.GetPrimaryChannelIndex(MHz_u{20}); const uint8_t noMuMimoUsers{0}; m_heSig.emplace(HeMuSigHeader{ .m_bssColor = bssColor, @@ -134,7 +134,7 @@ HePpdu::SetHeSigHeader(const WifiTxVector& txVector) .m_ruAllocation = txVector.GetRuAllocation(p20Index), .m_contentChannels = GetHeSigBContentChannels(txVector, p20Index), .m_center26ToneRuIndication = - (txVector.GetChannelWidth() >= 80) + (txVector.GetChannelWidth() >= MHz_u{80}) ? std::optional{txVector.GetCenter26ToneRuIndication()} : std::nullopt}); } @@ -196,7 +196,7 @@ HePpdu::SetTxVectorFromPhyHeaders(WifiTxVector& txVector) const heSigHeader->m_sigBCompression, GetMuMimoUsersFromEncoding(heSigHeader->m_muMimoUsers)); txVector.SetSigBMode(HePhy::GetVhtMcs(heSigHeader->m_sigBMcs)); - const auto p20Index = m_operatingChannel.GetPrimaryChannelIndex(20); + const auto p20Index = m_operatingChannel.GetPrimaryChannelIndex(MHz_u{20}); txVector.SetRuAllocation(heSigHeader->m_ruAllocation, p20Index); if (heSigHeader->m_center26ToneRuIndication.has_value()) { @@ -258,7 +258,7 @@ HePpdu::SetHeMuUserInfos(WifiTxVector& txVector, auto ruSpec = ruSpecs.at(ruIndex); auto ruType = ruSpec.GetRuType(); if ((ruAllocation.size() == 8) && (ruType == HeRu::RU_996_TONE) && - (((txVector.GetChannelWidth() == 160) && sigBcompression) || + (((txVector.GetChannelWidth() == MHz_u{160}) && sigBcompression) || std::all_of( contentChannel.cbegin(), contentChannel.cend(), @@ -268,13 +268,14 @@ HePpdu::SetHeMuUserInfos(WifiTxVector& txVector, } const auto ruBw = HeRu::GetBandwidth(ruType); auto primary80 = ruAllocIndex < 4; - const uint8_t num20MhzSubchannelsInRu = (ruBw < 20) ? 1 : Count20MHzSubchannels(ruBw); + const uint8_t num20MhzSubchannelsInRu = + (ruBw < MHz_u{20}) ? 1 : Count20MHzSubchannels(ruBw); auto numRuAllocsInContentChannel = std::max(1, num20MhzSubchannelsInRu / 2); - auto ruIndexOffset = (ruBw < 20) ? (ruSpecs.size() * ruAllocIndex) - : (ruAllocIndex / num20MhzSubchannelsInRu); + auto ruIndexOffset = (ruBw < MHz_u{20}) ? (ruSpecs.size() * ruAllocIndex) + : (ruAllocIndex / num20MhzSubchannelsInRu); if (!primary80) { - ruIndexOffset -= HeRu::GetRusOfType(80, ruType).size(); + ruIndexOffset -= HeRu::GetRusOfType(MHz_u{80}, ruType).size(); } if (!txVector.IsAllocated(userInfo.staId)) { @@ -410,7 +411,8 @@ HePpdu::GetTxChannelWidth() const { TxPsdFlag flag = GetTxPsdFlag(); const auto ruWidth = HeRu::GetBandwidth(txVector.GetRu(GetStaId()).GetRuType()); - MHz_u channelWidth = (flag == PSD_NON_HE_PORTION && ruWidth < 20) ? 20 : ruWidth; + MHz_u channelWidth = + (flag == PSD_NON_HE_PORTION && ruWidth < MHz_u{20}) ? MHz_u{20} : ruWidth; NS_LOG_INFO("Use channelWidth=" << channelWidth << " MHz for HE TB from " << GetStaId() << " for " << flag); return channelWidth; @@ -485,7 +487,7 @@ HePpdu::GetNumRusPerHeSigBContentChannel(MHz_u channelWidth, // If the HE-SIG-B Compression field in the HE-SIG-A field of an HE MU PPDU is 1, // for bandwidths larger than 20 MHz, the AP performs an equitable split of // the User fields between two HE-SIG-B content channels - if (channelWidth == 20) + if (channelWidth == MHz_u{20}) { return {numMuMimoUsers, 0}; } @@ -544,7 +546,7 @@ HePpdu::GetHeSigBContentChannels(const WifiTxVector& txVector, uint8_t p20Index) HeSigBContentChannels contentChannels{{}}; const auto channelWidth = txVector.GetChannelWidth(); - if (channelWidth > 20) + if (channelWidth > MHz_u{20}) { contentChannels.emplace_back(); } @@ -570,14 +572,14 @@ HePpdu::GetHeSigBContentChannels(const WifiTxVector& txVector, uint8_t p20Index) std::size_t numRus = (ruType >= HeRu::RU_242_TONE) ? 1 - : HeRu::m_heRuSubcarrierGroups.at({20, ruType}).size(); + : HeRu::m_heRuSubcarrierGroups.at({MHz_u{20}, ruType}).size(); const auto ruIdx = ru.GetIndex(); for (auto staId : staIds) { const auto& userInfo = txVector.GetHeMuUserInfo(staId); NS_ASSERT(ru == userInfo.ru); std::size_t ccIndex{0}; - if (channelWidth < 40) + if (channelWidth < MHz_u{40}) { // only one content channel ccIndex = 0; @@ -634,14 +636,15 @@ HePpdu::GetSigBFieldSize(MHz_u channelWidth, if (!sigBCompression) { commonFieldSize = 4 /* CRC */ + 6 /* tail */; - if (channelWidth <= 40) + if (channelWidth <= MHz_u{40}) { commonFieldSize += 8; // only one allocation subfield } else { commonFieldSize += - 8 * (channelWidth / 40) /* one allocation field per 40 MHz */ + 1 /* center RU */; + 8 * (channelWidth / MHz_u{40}) /* one allocation field per 40 MHz */ + + 1 /* center RU */; } } @@ -682,15 +685,15 @@ HePpdu::PrintPayload() const uint8_t HePpdu::GetChannelWidthEncodingFromMhz(MHz_u channelWidth) { - if (channelWidth == 160) + if (channelWidth == MHz_u{160}) { return 3; } - else if (channelWidth == 80) + else if (channelWidth == MHz_u{80}) { return 2; } - else if (channelWidth == 40) + else if (channelWidth == MHz_u{40}) { return 1; } @@ -705,19 +708,19 @@ HePpdu::GetChannelWidthMhzFromEncoding(uint8_t bandwidth) { if (bandwidth == 3) { - return 160; + return MHz_u{160}; } else if (bandwidth == 2) { - return 80; + return MHz_u{80}; } else if (bandwidth == 1) { - return 40; + return MHz_u{40}; } else { - return 20; + return MHz_u{20}; } } diff --git a/src/wifi/model/he/he-ru.cc b/src/wifi/model/he/he-ru.cc index a2a6db74c..b5a18908c 100644 --- a/src/wifi/model/he/he-ru.cc +++ b/src/wifi/model/he/he-ru.cc @@ -19,7 +19,7 @@ namespace ns3 const HeRu::SubcarrierGroups HeRu::m_heRuSubcarrierGroups = { // RUs in a 20 MHz HE PPDU (Table 28-6) - {{20, HeRu::RU_26_TONE}, + {{MHz_u{20}, HeRu::RU_26_TONE}, {/* 1 */ {{-121, -96}}, /* 2 */ {{-95, -70}}, /* 3 */ {{-68, -43}}, @@ -29,17 +29,17 @@ const HeRu::SubcarrierGroups HeRu::m_heRuSubcarrierGroups = { /* 7 */ {{43, 68}}, /* 8 */ {{70, 95}}, /* 9 */ {{96, 121}}}}, - {{20, HeRu::RU_52_TONE}, + {{MHz_u{20}, HeRu::RU_52_TONE}, {/* 1 */ {{-121, -70}}, /* 2 */ {{-68, -17}}, /* 3 */ {{17, 68}}, /* 4 */ {{70, 121}}}}, - {{20, HeRu::RU_106_TONE}, + {{MHz_u{20}, HeRu::RU_106_TONE}, {/* 1 */ {{-122, -17}}, /* 2 */ {{17, 122}}}}, - {{20, HeRu::RU_242_TONE}, {/* 1 */ {{-122, -2}, {2, 122}}}}, + {{MHz_u{20}, HeRu::RU_242_TONE}, {/* 1 */ {{-122, -2}, {2, 122}}}}, // RUs in a 40 MHz HE PPDU (Table 28-7) - {{40, HeRu::RU_26_TONE}, + {{MHz_u{40}, HeRu::RU_26_TONE}, {/* 1 */ {{-243, -218}}, /* 2 */ {{-217, -192}}, /* 3 */ {{-189, -164}}, @@ -58,7 +58,7 @@ const HeRu::SubcarrierGroups HeRu::m_heRuSubcarrierGroups = { /* 16 */ {{164, 189}}, /* 17 */ {{192, 217}}, /* 18 */ {{218, 243}}}}, - {{40, HeRu::RU_52_TONE}, + {{MHz_u{40}, HeRu::RU_52_TONE}, {/* 1 */ {{-243, -192}}, /* 2 */ {{-189, -138}}, /* 3 */ {{-109, -58}}, @@ -67,17 +67,17 @@ const HeRu::SubcarrierGroups HeRu::m_heRuSubcarrierGroups = { /* 6 */ {{58, 109}}, /* 7 */ {{138, 189}}, /* 8 */ {{192, 243}}}}, - {{40, HeRu::RU_106_TONE}, + {{MHz_u{40}, HeRu::RU_106_TONE}, {/* 1 */ {{-243, -138}}, /* 2 */ {{-109, -4}}, /* 3 */ {{4, 109}}, /* 4 */ {{138, 243}}}}, - {{40, HeRu::RU_242_TONE}, + {{MHz_u{40}, HeRu::RU_242_TONE}, {/* 1 */ {{-244, -3}}, /* 2 */ {{3, 244}}}}, - {{40, HeRu::RU_484_TONE}, {/* 1 */ {{-244, -3}, {3, 244}}}}, + {{MHz_u{40}, HeRu::RU_484_TONE}, {/* 1 */ {{-244, -3}, {3, 244}}}}, // RUs in an 80 MHz HE PPDU (Table 28-8) - {{80, HeRu::RU_26_TONE}, + {{MHz_u{80}, HeRu::RU_26_TONE}, {/* 1 */ {{-499, -474}}, /* 2 */ {{-473, -448}}, /* 3 */ {{-445, -420}}, @@ -115,7 +115,7 @@ const HeRu::SubcarrierGroups HeRu::m_heRuSubcarrierGroups = { /* 35 */ {{420, 445}}, /* 36 */ {{448, 473}}, /* 37 */ {{474, 499}}}}, - {{80, HeRu::RU_52_TONE}, + {{MHz_u{80}, HeRu::RU_52_TONE}, {/* 1 */ {{-499, -448}}, /* 2 */ {{-445, -394}}, /* 3 */ {{-365, -314}}, @@ -132,7 +132,7 @@ const HeRu::SubcarrierGroups HeRu::m_heRuSubcarrierGroups = { /* 14 */ {{314, 365}}, /* 15 */ {{394, 445}}, /* 16 */ {{448, 499}}}}, - {{80, HeRu::RU_106_TONE}, + {{MHz_u{80}, HeRu::RU_106_TONE}, {/* 1 */ {{-499, -394}}, /* 2 */ {{-365, -260}}, /* 3 */ {{-257, -152}}, @@ -141,15 +141,15 @@ const HeRu::SubcarrierGroups HeRu::m_heRuSubcarrierGroups = { /* 6 */ {{152, 257}}, /* 7 */ {{260, 365}}, /* 8 */ {{394, 499}}}}, - {{80, HeRu::RU_242_TONE}, + {{MHz_u{80}, HeRu::RU_242_TONE}, {/* 1 */ {{-500, -259}}, /* 2 */ {{-258, -17}}, /* 3 */ {{17, 258}}, /* 4 */ {{259, 500}}}}, - {{80, HeRu::RU_484_TONE}, + {{MHz_u{80}, HeRu::RU_484_TONE}, {/* 1 */ {{-500, -17}}, /* 2 */ {{17, 500}}}}, - {{80, HeRu::RU_996_TONE}, {/* 1 */ {{-500, -3}, {3, 500}}}}, + {{MHz_u{80}, HeRu::RU_996_TONE}, {/* 1 */ {{-500, -3}, {3, 500}}}}, }; // Table 27-26 IEEE802.11ax-2021 @@ -467,10 +467,10 @@ HeRu::RuSpec::GetPrimary80MHz() const std::size_t HeRu::RuSpec::GetPhyIndex(MHz_u bw, uint8_t p20Index) const { - bool primary80IsLower80 = (p20Index < bw / 40); + bool primary80IsLower80 = (p20Index < bw / MHz_u{40}); - if (bw < 160 || m_ruType == HeRu::RU_2x996_TONE || (primary80IsLower80 && m_primary80MHz) || - (!primary80IsLower80 && !m_primary80MHz)) + if (bw < MHz_u{160} || m_ruType == HeRu::RU_2x996_TONE || + (primary80IsLower80 && m_primary80MHz) || (!primary80IsLower80 && !m_primary80MHz)) { return m_index; } @@ -483,21 +483,21 @@ HeRu::RuSpec::GetPhyIndex(MHz_u bw, uint8_t p20Index) const std::size_t HeRu::GetNRus(MHz_u bw, RuType ruType) { - if (bw == 160 && ruType == RU_2x996_TONE) + if (bw == MHz_u{160} && ruType == RU_2x996_TONE) { return 1; } // if the bandwidth is 160MHz, search for the number of RUs available // in 80MHz and double the result. - auto it = m_heRuSubcarrierGroups.find({(bw == 160 ? 80 : bw), ruType}); + auto it = m_heRuSubcarrierGroups.find({(bw == MHz_u{160} ? MHz_u{80} : bw), ruType}); if (it == m_heRuSubcarrierGroups.end()) { return 0; } - return (bw == 160 ? 2 : 1) * it->second.size(); + return (bw == MHz_u{160} ? 2 : 1) * it->second.size(); } std::vector @@ -505,17 +505,17 @@ HeRu::GetRusOfType(MHz_u bw, HeRu::RuType ruType) { if (ruType == HeRu::RU_2x996_TONE) { - NS_ASSERT(bw >= 160); + NS_ASSERT(bw >= MHz_u{160}); return {{ruType, 1, true}}; } std::vector ret; std::vector primary80MHzSet{true}; - if (bw == 160) + if (bw == MHz_u{160}) { primary80MHzSet.push_back(false); - bw = 80; + bw = MHz_u{80}; } for (auto primary80MHz : primary80MHzSet) @@ -537,22 +537,22 @@ HeRu::GetCentral26TonesRus(MHz_u bw, HeRu::RuType ruType) if (ruType == HeRu::RU_52_TONE || ruType == HeRu::RU_106_TONE) { - if (bw == 20) + if (bw == MHz_u{20}) { indices.push_back(5); } - else if (bw == 40) + else if (bw == MHz_u{40}) { indices.insert(indices.end(), {5, 14}); } - else if (bw >= 80) + else if (bw >= MHz_u{80}) { indices.insert(indices.end(), {5, 14, 19, 24, 33}); } } else if (ruType == HeRu::RU_242_TONE || ruType == HeRu::RU_484_TONE) { - if (bw >= 80) + if (bw >= MHz_u{80}) { indices.push_back(19); } @@ -561,7 +561,7 @@ HeRu::GetCentral26TonesRus(MHz_u bw, HeRu::RuType ruType) std::vector ret; std::vector primary80MHzSet{true}; - if (bw == 160) + if (bw == MHz_u{160}) { primary80MHzSet.push_back(false); } @@ -581,7 +581,7 @@ HeRu::GetSubcarrierGroup(MHz_u bw, RuType ruType, std::size_t phyIndex) { if (ruType == HeRu::RU_2x996_TONE) // handle special case of RU covering 160 MHz channel { - NS_ABORT_MSG_IF(bw != 160, "2x996 tone RU can only be used on 160 MHz band"); + NS_ABORT_MSG_IF(bw != MHz_u{160}, "2x996 tone RU can only be used on 160 MHz band"); return {{-1012, -3}, {3, 1012}}; } @@ -590,21 +590,21 @@ HeRu::GetSubcarrierGroup(MHz_u bw, RuType ruType, std::size_t phyIndex) // The phyIndex is used to that aim. std::size_t indexInLower80MHz = phyIndex; std::size_t numRus = GetNRus(bw, ruType); - int16_t shift = (bw == 160) ? -512 : 0; - if (bw == 160 && phyIndex > (numRus / 2)) + int16_t shift = (bw == MHz_u{160}) ? -512 : 0; + if (bw == MHz_u{160} && phyIndex > (numRus / 2)) { // The provided index is that of the upper 80 MHz subchannel indexInLower80MHz = phyIndex - (numRus / 2); shift = 512; } - auto it = m_heRuSubcarrierGroups.find({(bw == 160 ? 80 : bw), ruType}); + auto it = m_heRuSubcarrierGroups.find({(bw == MHz_u{160} ? MHz_u{80} : bw), ruType}); NS_ABORT_MSG_IF(it == m_heRuSubcarrierGroups.end(), "RU not found"); NS_ABORT_MSG_IF(indexInLower80MHz > it->second.size(), "RU index not available"); SubcarrierGroup group = it->second.at(indexInLower80MHz - 1); - if (bw == 160) + if (bw == MHz_u{160}) { for (auto& range : group) { @@ -619,7 +619,7 @@ bool HeRu::DoesOverlap(MHz_u bw, RuSpec ru, const std::vector& v) { // A 2x996-tone RU spans 160 MHz, hence it overlaps with any other RU - if (bw == 160 && ru.GetRuType() == RU_2x996_TONE && !v.empty()) + if (bw == MHz_u{160} && ru.GetRuType() == RU_2x996_TONE && !v.empty()) { return true; } @@ -656,7 +656,7 @@ HeRu::DoesOverlap(MHz_u bw, RuSpec ru, const SubcarrierGroup& toneRanges, uint8_ { for (const auto& range : toneRanges) { - if (bw == 160 && ru.GetRuType() == RU_2x996_TONE) + if (bw == MHz_u{160} && ru.GetRuType() == RU_2x996_TONE) { return true; } @@ -681,7 +681,7 @@ HeRu::FindOverlappingRu(MHz_u bw, RuSpec referenceRu, RuType searchedRuType) std::size_t numRusPer80Mhz; std::vector primary80MhzFlags; - if (bw == 160) + if (bw == MHz_u{160}) { primary80MhzFlags.push_back(true); primary80MhzFlags.push_back(false); @@ -758,22 +758,22 @@ HeRu::GetBandwidth(RuType ruType) switch (ruType) { case RU_26_TONE: - return 2; + return MHz_u{2}; case RU_52_TONE: - return 4; + return MHz_u{4}; case RU_106_TONE: - return 8; + return MHz_u{8}; case RU_242_TONE: - return 20; + return MHz_u{20}; case RU_484_TONE: - return 40; + return MHz_u{40}; case RU_996_TONE: - return 80; + return MHz_u{80}; case RU_2x996_TONE: - return 160; + return MHz_u{160}; default: NS_ABORT_MSG("RU type " << ruType << " not found"); - return 0; + return MHz_u{0}; } } @@ -819,7 +819,8 @@ HeRu::GetEqualSizedRusForStations(MHz_u bandwidth, nRusAssigned = ru.second.size(); break; } - else if (bandwidth == 160 && ru.first.first == 80 && (2 * ru.second.size() <= nStations)) + else if (bandwidth == MHz_u{160} && ru.first.first == MHz_u{80} && + (2 * ru.second.size() <= nStations)) { ruType = ru.first.second; nRusAssigned = 2 * ru.second.size(); @@ -828,7 +829,7 @@ HeRu::GetEqualSizedRusForStations(MHz_u bandwidth, } if (nRusAssigned == 0) { - NS_ABORT_IF(bandwidth != 160 || nStations != 1); + NS_ABORT_IF(bandwidth != MHz_u{160} || nStations != 1); nRusAssigned = 1; ruType = RU_2x996_TONE; } @@ -839,11 +840,11 @@ HeRu::GetEqualSizedRusForStations(MHz_u bandwidth, { case RU_52_TONE: case RU_106_TONE: - if (bandwidth == 20) + if (bandwidth == MHz_u{20}) { nCentral26TonesRus = 1; } - else if (bandwidth == 40) + else if (bandwidth == MHz_u{40}) { nCentral26TonesRus = 2; } @@ -854,13 +855,13 @@ HeRu::GetEqualSizedRusForStations(MHz_u bandwidth, break; case RU_242_TONE: case RU_484_TONE: - nCentral26TonesRus = (bandwidth >= 80 ? 1 : 0); + nCentral26TonesRus = (bandwidth >= MHz_u{80} ? 1 : 0); break; default: nCentral26TonesRus = 0; } - if (bandwidth == 160) + if (bandwidth == MHz_u{160}) { nCentral26TonesRus *= 2; } diff --git a/src/wifi/model/ht/ht-phy.cc b/src/wifi/model/ht/ht-phy.cc index 81e423731..9e2c71caf 100644 --- a/src/wifi/model/ht/ht-phy.cc +++ b/src/wifi/model/ht/ht-phy.cc @@ -712,7 +712,7 @@ HtPhy::CalculateDataRate(Time symbolDuration, uint16_t HtPhy::GetUsableSubcarriers(MHz_u channelWidth) { - return (channelWidth == 40) ? 108 : 52; + return (channelWidth == MHz_u{40}) ? 108 : 52; } Time @@ -816,12 +816,12 @@ HtPhy::GetMaxPsduSize() const PhyEntity::CcaIndication HtPhy::GetCcaIndication(const Ptr ppdu) { - if (m_wifiPhy->GetChannelWidth() < 40) + if (m_wifiPhy->GetChannelWidth() < MHz_u{40}) { return OfdmPhy::GetCcaIndication(ppdu); } auto ccaThreshold = GetCcaThreshold(ppdu, WIFI_CHANLIST_PRIMARY); - auto delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThreshold, GetPrimaryBand(20)); + auto delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThreshold, GetPrimaryBand(MHz_u{20})); if (delayUntilCcaEnd.IsStrictlyPositive()) { return std::make_pair( @@ -857,7 +857,7 @@ HtPhy::GetCcaIndication(const Ptr ppdu) if (!ppdu || ppdu->DoesOverlapChannel(s20MinFreq, s20MaxFreq)) { ccaThreshold = GetCcaThreshold(ppdu, WIFI_CHANLIST_SECONDARY); - delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThreshold, GetSecondaryBand(20)); + delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThreshold, GetSecondaryBand(MHz_u{20})); if (delayUntilCcaEnd.IsStrictlyPositive()) { return std::make_pair(delayUntilCcaEnd, WIFI_CHANLIST_SECONDARY); diff --git a/src/wifi/model/ht/ht-ppdu.cc b/src/wifi/model/ht/ht-ppdu.cc index dfc59c90d..7bcc0eb94 100644 --- a/src/wifi/model/ht/ht-ppdu.cc +++ b/src/wifi/model/ht/ht-ppdu.cc @@ -135,13 +135,13 @@ HtPpdu::HtSigHeader::GetMcs() const void HtPpdu::HtSigHeader::SetChannelWidth(MHz_u channelWidth) { - m_cbw20_40 = (channelWidth > 20) ? 1 : 0; + m_cbw20_40 = (channelWidth > MHz_u{20}) ? 1 : 0; } MHz_u HtPpdu::HtSigHeader::GetChannelWidth() const { - return m_cbw20_40 ? 40 : 20; + return m_cbw20_40 ? MHz_u{40} : MHz_u{20}; } void diff --git a/src/wifi/model/interference-helper.cc b/src/wifi/model/interference-helper.cc index 2a891537d..d009501bd 100644 --- a/src/wifi/model/interference-helper.cc +++ b/src/wifi/model/interference-helper.cc @@ -246,8 +246,8 @@ InterferenceHelper::AddBand(const WifiSpectrumBandInfo& band) auto result = m_niChanges.insert({band, niChanges}); NS_ASSERT(result.second); // Always have a zero power noise event in the list - AddNiChangeEvent(Time(0), NiChange(0.0, nullptr), result.first); - m_firstPowers.insert({band, 0.0}); + AddNiChangeEvent(Time(0), NiChange(Watt_u{0}, nullptr), result.first); + m_firstPowers.insert({band, Watt_u{0}}); } void @@ -448,7 +448,7 @@ InterferenceHelper::CalculateNoiseInterferenceW(Ptr event, auto it = niIt->second.find(event->GetStartTime()); const auto muMimoPower = (event->GetPpdu()->GetType() == WIFI_PPDU_TYPE_UL_MU) ? CalculateMuMimoPowerW(event, band) - : 0.0; + : Watt_u{0.0}; for (; it != niIt->second.end() && it->first < now; ++it) { if (IsSameMuMimoTransmission(event, it->second.GetEvent()) && @@ -462,7 +462,7 @@ InterferenceHelper::CalculateNoiseInterferenceW(Ptr event, if (std::abs(noiseInterference) < std::numeric_limits::epsilon()) { // fix some possible rounding issues with double values - noiseInterference = 0.0; + noiseInterference = Watt_u{0.0}; } } it = niIt->second.find(event->GetStartTime()); @@ -472,14 +472,14 @@ InterferenceHelper::CalculateNoiseInterferenceW(Ptr event, ; } NiChanges ni; - ni.emplace(event->GetStartTime(), NiChange(0, event)); + ni.emplace(event->GetStartTime(), NiChange(Watt_u{0}, event)); while (++it != niIt->second.end() && it->second.GetEvent() != event) { ni.insert(*it); } - ni.emplace(event->GetEndTime(), NiChange(0, event)); + ni.emplace(event->GetEndTime(), NiChange(Watt_u{0}, event)); nis.insert({band, ni}); - NS_ASSERT_MSG(noiseInterference >= 0.0, + NS_ASSERT_MSG(noiseInterference >= Watt_u{0.0}, "CalculateNoiseInterferenceW returns negative value " << noiseInterference); return noiseInterference; } diff --git a/src/wifi/model/mgt-action-headers.cc b/src/wifi/model/mgt-action-headers.cc index f03876f67..5c114adb6 100644 --- a/src/wifi/model/mgt-action-headers.cc +++ b/src/wifi/model/mgt-action-headers.cc @@ -1763,11 +1763,11 @@ FilsDiscHeader::FdCapability::Deserialize(Buffer::Iterator start) void FilsDiscHeader::FdCapability::SetOpChannelWidth(MHz_u width) { - m_chWidth = (width == 20 || width == 22) ? 0 - : (width == 40) ? 1 - : (width == 80) ? 2 - : (width == 160) ? 3 - : 4; + m_chWidth = (width == MHz_u{20} || width == MHz_u{22}) ? 0 + : (width == MHz_u{40}) ? 1 + : (width == MHz_u{80}) ? 2 + : (width == MHz_u{160}) ? 3 + : 4; } MHz_u @@ -1776,17 +1776,17 @@ FilsDiscHeader::FdCapability::GetOpChannelWidth() const switch (m_chWidth) { case 0: - return m_phyIdx == 0 ? 22 : 20; // PHY Index 0 indicates 802.11b + return m_phyIdx == 0 ? MHz_u{22} : MHz_u{20}; // PHY Index 0 indicates 802.11b case 1: - return 40; + return MHz_u{40}; case 2: - return 80; + return MHz_u{80}; case 3: - return 160; + return MHz_u{160}; default: NS_ABORT_MSG("Reserved value: " << +m_chWidth); } - return 0; + return MHz_u{0}; } void diff --git a/src/wifi/model/non-ht/dsss-phy.cc b/src/wifi/model/non-ht/dsss-phy.cc index 8a8afc4b7..a76354b08 100644 --- a/src/wifi/model/non-ht/dsss-phy.cc +++ b/src/wifi/model/non-ht/dsss-phy.cc @@ -142,7 +142,7 @@ Time DsssPhy::GetPreambleDuration(const WifiTxVector& txVector) const { if (txVector.GetPreambleType() == WIFI_PREAMBLE_SHORT && - (txVector.GetMode().GetDataRate(22) > 1000000)) + (txVector.GetMode().GetDataRate(MHz_u{22}) > 1000000)) { // Section 16.2.2.3 "Short PPDU format" Figure 16-2 "Short PPDU format"; IEEE Std // 802.11-2016 @@ -159,7 +159,7 @@ Time DsssPhy::GetHeaderDuration(const WifiTxVector& txVector) const { if (txVector.GetPreambleType() == WIFI_PREAMBLE_SHORT && - (txVector.GetMode().GetDataRate(22) > 1000000)) + (txVector.GetMode().GetDataRate(MHz_u{22}) > 1000000)) { // Section 16.2.2.3 "Short PPDU format" and Figure 16-2 "Short PPDU format"; IEEE Std // 802.11-2016 @@ -183,7 +183,8 @@ DsssPhy::GetPayloadDuration(uint32_t size, double& /* totalAmpduNumSymbols */, uint16_t /* staId */) const { - return MicroSeconds(lrint(ceil((size * 8.0) / (txVector.GetMode().GetDataRate(22) / 1.0e6)))); + return MicroSeconds( + lrint(ceil((size * 8.0) / (txVector.GetMode().GetDataRate(MHz_u{22}) / 1.0e6)))); } Ptr @@ -236,7 +237,7 @@ DsssPhy::EndReceiveHeader(Ptr event) MHz_u DsssPhy::GetRxChannelWidth(const WifiTxVector& txVector) const { - if (m_wifiPhy->GetChannelWidth() > 20) + if (m_wifiPhy->GetChannelWidth() > MHz_u{20}) { /* * This is a workaround necessary with HE-capable PHYs, @@ -244,7 +245,7 @@ DsssPhy::GetRxChannelWidth(const WifiTxVector& txVector) const * Without this hack, SpectrumWifiPhy::GetBand will crash. * FIXME: see issue #402 for a better solution. */ - return 20; + return MHz_u{20}; } return PhyEntity::GetRxChannelWidth(txVector); } @@ -252,7 +253,7 @@ DsssPhy::GetRxChannelWidth(const WifiTxVector& txVector) const MHz_u DsssPhy::GetMeasurementChannelWidth(const Ptr ppdu) const { - return ppdu ? GetRxChannelWidth(ppdu->GetTxVector()) : 22; + return ppdu ? GetRxChannelWidth(ppdu->GetTxVector()) : MHz_u{22}; } Ptr @@ -263,7 +264,7 @@ DsssPhy::GetTxPowerSpectralDensity(Watt_u txPower, Ptr ppdu) con const auto& txVector = ppdu->GetTxVector(); const auto channelWidth = txVector.GetChannelWidth(); NS_LOG_FUNCTION(this << centerFrequencies.front() << channelWidth << txPower); - NS_ABORT_MSG_IF(channelWidth != 22, "Invalid channel width for DSSS"); + NS_ABORT_MSG_IF(channelWidth != MHz_u{22}, "Invalid channel width for DSSS"); auto v = WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity(centerFrequencies.front(), txPower, diff --git a/src/wifi/model/non-ht/dsss-ppdu.cc b/src/wifi/model/non-ht/dsss-ppdu.cc index 533432dbd..dacd8fc5c 100644 --- a/src/wifi/model/non-ht/dsss-ppdu.cc +++ b/src/wifi/model/non-ht/dsss-ppdu.cc @@ -45,7 +45,7 @@ DsssPpdu::SetDsssHeader(DsssSigHeader& dsssSig, const WifiTxVector& txVector, Time ppduDuration) const { - dsssSig.SetRate(txVector.GetMode().GetDataRate(22)); + dsssSig.SetRate(txVector.GetMode().GetDataRate(MHz_u{22})); Time psduDuration = ppduDuration - WifiPhy::CalculatePhyPreambleAndHeaderDuration(txVector); dsssSig.SetLength(psduDuration.GetMicroSeconds()); } @@ -55,7 +55,7 @@ DsssPpdu::DoGetTxVector() const { WifiTxVector txVector; txVector.SetPreambleType(m_preamble); - txVector.SetChannelWidth(22); + txVector.SetChannelWidth(MHz_u{22}); SetTxVectorFromDsssHeader(txVector, m_dsssSig); return txVector; } diff --git a/src/wifi/model/non-ht/erp-ofdm-ppdu.cc b/src/wifi/model/non-ht/erp-ofdm-ppdu.cc index 9584b5275..386534c47 100644 --- a/src/wifi/model/non-ht/erp-ofdm-ppdu.cc +++ b/src/wifi/model/non-ht/erp-ofdm-ppdu.cc @@ -33,7 +33,7 @@ void ErpOfdmPpdu::SetTxVectorFromLSigHeader(WifiTxVector& txVector, const LSigHeader& lSig) const { txVector.SetMode(ErpOfdmPhy::GetErpOfdmRate(lSig.GetRate())); - txVector.SetChannelWidth(20); + txVector.SetChannelWidth(MHz_u{20}); } Ptr diff --git a/src/wifi/model/non-ht/ofdm-phy.cc b/src/wifi/model/non-ht/ofdm-phy.cc index bcd3fadc2..9e83a360a 100644 --- a/src/wifi/model/non-ht/ofdm-phy.cc +++ b/src/wifi/model/non-ht/ofdm-phy.cc @@ -71,13 +71,13 @@ const PhyEntity::ModulationLookupTable OfdmPhy::m_ofdmModulationLookupTable { /// OFDM rates in bits per second for each bandwidth const std::map > s_ofdmRatesBpsList = - {{ 20, // MHz + {{ MHz_u{20}, { 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000 }}, - { 10, // MHz + { MHz_u{10}, { 3000000, 4500000, 6000000, 9000000, 12000000, 18000000, 24000000, 27000000 }}, - { 5, // MHz + { MHz_u{5}, { 1500000, 2250000, 3000000, 4500000, 6000000, 9000000, 12000000, 13500000 }}, }; @@ -106,25 +106,25 @@ OfdmPhy::OfdmPhy(OfdmPhyVariant variant /* = OFDM_PHY_DEFAULT */, bool buildMode switch (variant) { case OFDM_PHY_DEFAULT: - for (const auto& rate : bwRatesMap.at(20)) + for (const auto& rate : bwRatesMap.at(MHz_u{20})) { - WifiMode mode = GetOfdmRate(rate, 20); + WifiMode mode = GetOfdmRate(rate, MHz_u{20}); NS_LOG_LOGIC("Add " << mode << " to list"); m_modeList.emplace_back(mode); } break; case OFDM_PHY_10_MHZ: - for (const auto& rate : bwRatesMap.at(10)) + for (const auto& rate : bwRatesMap.at(MHz_u{10})) { - WifiMode mode = GetOfdmRate(rate, 10); + WifiMode mode = GetOfdmRate(rate, MHz_u{10}); NS_LOG_LOGIC("Add " << mode << " to list"); m_modeList.emplace_back(mode); } break; case OFDM_PHY_5_MHZ: - for (const auto& rate : bwRatesMap.at(5)) + for (const auto& rate : bwRatesMap.at(MHz_u{5})) { - WifiMode mode = GetOfdmRate(rate, 5); + WifiMode mode = GetOfdmRate(rate, MHz_u{5}); NS_LOG_LOGIC("Add " << mode << " to list"); m_modeList.emplace_back(mode); } @@ -334,7 +334,7 @@ bool OfdmPhy::IsChannelWidthSupported(Ptr ppdu) const { const auto channelWidth = ppdu->GetTxVector().GetChannelWidth(); - if ((channelWidth >= 40) && (channelWidth > m_wifiPhy->GetChannelWidth())) + if ((channelWidth >= MHz_u{40}) && (channelWidth > m_wifiPhy->GetChannelWidth())) { NS_LOG_DEBUG("Packet reception could not be started because not enough channel width (" << channelWidth << " vs " << m_wifiPhy->GetChannelWidth() << ")"); @@ -631,11 +631,11 @@ OfdmPhy::GetSymbolDuration(MHz_u channelWidth) { Time symbolDuration = MicroSeconds(4); uint8_t bwFactor = 1; - if (channelWidth == 10) + if (channelWidth == MHz_u{10}) { bwFactor = 2; } - else if (channelWidth == 5) + else if (channelWidth == MHz_u{5}) { bwFactor = 4; } @@ -659,7 +659,7 @@ OfdmPhy::GetMeasurementChannelWidth(const Ptr ppdu) const { if (!ppdu) { - return std::min(m_wifiPhy->GetChannelWidth(), 20); + return std::min(m_wifiPhy->GetChannelWidth(), MHz_u{20}); } return GetRxChannelWidth(ppdu->GetTxVector()); } @@ -667,11 +667,11 @@ OfdmPhy::GetMeasurementChannelWidth(const Ptr ppdu) const dBm_u OfdmPhy::GetCcaThreshold(const Ptr ppdu, WifiChannelListType channelType) const { - if (ppdu && ppdu->GetTxVector().GetChannelWidth() < 20) + if (ppdu && ppdu->GetTxVector().GetChannelWidth() < MHz_u{20}) { // scale CCA sensitivity threshold for BW of 5 and 10 MHz const auto bw = GetRxChannelWidth(ppdu->GetTxVector()); - const auto thresholdW = DbmToW(m_wifiPhy->GetCcaSensitivityThreshold()) * (bw / 20.0); + const auto thresholdW = DbmToW(m_wifiPhy->GetCcaSensitivityThreshold()) * (bw / MHz_u{20}); return WToDbm(thresholdW); } return PhyEntity::GetCcaThreshold(ppdu, channelType); diff --git a/src/wifi/model/non-ht/ofdm-phy.h b/src/wifi/model/non-ht/ofdm-phy.h index eb6c3992e..e60b424e0 100644 --- a/src/wifi/model/non-ht/ofdm-phy.h +++ b/src/wifi/model/non-ht/ofdm-phy.h @@ -93,7 +93,7 @@ class OfdmPhy : public PhyEntity * @param bw the bandwidth * @return a WifiMode for OFDM */ - static WifiMode GetOfdmRate(uint64_t rate, MHz_u bw = 20); + static WifiMode GetOfdmRate(uint64_t rate, MHz_u bw = MHz_u{20}); /** * Return a WifiMode for OFDM at 6 Mbps. * diff --git a/src/wifi/model/non-ht/ofdm-ppdu.cc b/src/wifi/model/non-ht/ofdm-ppdu.cc index 6ec351905..ccc82d9ec 100644 --- a/src/wifi/model/non-ht/ofdm-ppdu.cc +++ b/src/wifi/model/non-ht/ofdm-ppdu.cc @@ -28,7 +28,7 @@ OfdmPpdu::OfdmPpdu(Ptr psdu, uint64_t uid, bool instantiateLSig /* = true */) : WifiPpdu(psdu, txVector, channel, uid), - m_channelWidth(txVector.IsNonHtDuplicate() ? 20 : txVector.GetChannelWidth()) + m_channelWidth(txVector.IsNonHtDuplicate() ? MHz_u{20} : txVector.GetChannelWidth()) { NS_LOG_FUNCTION(this << psdu << txVector << channel << uid); if (instantiateLSig) @@ -63,7 +63,7 @@ OfdmPpdu::DoGetTxVector() const void OfdmPpdu::SetTxVectorFromLSigHeader(WifiTxVector& txVector, const LSigHeader& lSig) const { - NS_ASSERT(m_channelWidth <= 20); + NS_ASSERT(m_channelWidth <= MHz_u{20}); // OFDM uses 20 MHz, unless PHY channel width is 5 MHz or 10 MHz txVector.SetMode(OfdmPhy::GetOfdmRate(lSig.GetRate(m_channelWidth), m_channelWidth)); txVector.SetChannelWidth(m_channelWidth); @@ -93,11 +93,11 @@ OfdmPpdu::LSigHeader::LSigHeader() void OfdmPpdu::LSigHeader::SetRate(uint64_t rate, MHz_u channelWidth) { - if (channelWidth == 5) + if (channelWidth == MHz_u{5}) { rate *= 4; // corresponding 20 MHz rate if 5 MHz is used } - else if (channelWidth == 10) + else if (channelWidth == MHz_u{10}) { rate *= 2; // corresponding 20 MHz rate if 10 MHz is used } @@ -177,11 +177,11 @@ OfdmPpdu::LSigHeader::GetRate(MHz_u channelWidth) const NS_ASSERT_MSG(false, "Invalid rate"); break; } - if (channelWidth == 5) + if (channelWidth == MHz_u{5}) { rate /= 4; // compute corresponding 5 MHz rate } - else if (channelWidth == 10) + else if (channelWidth == MHz_u{10}) { rate /= 2; // compute corresponding 10 MHz rate } diff --git a/src/wifi/model/non-ht/ofdm-ppdu.h b/src/wifi/model/non-ht/ofdm-ppdu.h index 88a9a90d1..bcf3d8372 100644 --- a/src/wifi/model/non-ht/ofdm-ppdu.h +++ b/src/wifi/model/non-ht/ofdm-ppdu.h @@ -50,14 +50,14 @@ class OfdmPpdu : public WifiPpdu * @param rate the RATE field of L-SIG expressed in bit/s * @param channelWidth the channel width */ - void SetRate(uint64_t rate, MHz_u channelWidth = 20); + void SetRate(uint64_t rate, MHz_u channelWidth = MHz_u{20}); /** * Return the RATE field of L-SIG (in bit/s). * * @param channelWidth the channel width * @return the RATE field of L-SIG expressed in bit/s */ - uint64_t GetRate(MHz_u channelWidth = 20) const; + uint64_t GetRate(MHz_u channelWidth = MHz_u{20}) const; /** * Fill the LENGTH field of L-SIG (in bytes). * diff --git a/src/wifi/model/phy-entity.cc b/src/wifi/model/phy-entity.cc index 874c92f24..c5d026d65 100644 --- a/src/wifi/model/phy-entity.cc +++ b/src/wifi/model/phy-entity.cc @@ -968,7 +968,7 @@ PhyEntity::StartPreambleDetectionPeriod(Ptr event) { NS_LOG_FUNCTION(this << *event); const auto rxPower = GetRxPowerForPpdu(event); - NS_LOG_DEBUG("Sync to signal (power=" << (rxPower > 0.0 + NS_LOG_DEBUG("Sync to signal (power=" << (rxPower > Watt_u{0.0} ? std::to_string(WToDbm(rxPower)) + "dBm)" : std::to_string(rxPower) + "W)")); m_wifiPhy->m_interference->NotifyRxStart( @@ -1036,8 +1036,8 @@ PhyEntity::EndPreambleDetectionPeriod(Ptr event) NS_LOG_DEBUG("SNR(dB)=" << RatioToDb(snr) << " at end of preamble detection period"); if (const auto power = m_wifiPhy->m_currentEvent->GetRxPower(measurementBand); - (!m_wifiPhy->m_preambleDetectionModel && maxRxPower && (*maxRxPower > 0.0)) || - (m_wifiPhy->m_preambleDetectionModel && power > 0.0 && + (!m_wifiPhy->m_preambleDetectionModel && maxRxPower && (*maxRxPower > Watt_u{0.0})) || + (m_wifiPhy->m_preambleDetectionModel && power > Watt_u{0.0} && m_wifiPhy->m_preambleDetectionModel->IsPreambleDetected(WToDbm(power), snr, measurementChannelWidth))) @@ -1251,7 +1251,7 @@ PhyEntity::GetPrimaryBand(MHz_u bandWidth) const WifiSpectrumBandInfo PhyEntity::GetSecondaryBand(MHz_u bandWidth) const { - NS_ASSERT(m_wifiPhy->GetChannelWidth() >= 40); + NS_ASSERT(m_wifiPhy->GetChannelWidth() >= MHz_u{40}); return m_wifiPhy->GetBand(bandWidth, m_wifiPhy->GetOperatingChannel().GetSecondaryChannelIndex(bandWidth)); } @@ -1404,7 +1404,7 @@ PhyEntity::CanStartRx(Ptr ppdu) const // not overlap the primary channel const auto channelWidth = m_wifiPhy->GetChannelWidth(); const auto primaryWidth = ((static_cast(channelWidth) % 20 == 0) - ? 20 + ? MHz_u{20} : channelWidth); // if the channel width is a multiple of 20 MHz, // then we consider the primary20 channel const auto p20CenterFreq = diff --git a/src/wifi/model/qos-frame-exchange-manager.cc b/src/wifi/model/qos-frame-exchange-manager.cc index 13f9ea9c2..34510fff7 100644 --- a/src/wifi/model/qos-frame-exchange-manager.cc +++ b/src/wifi/model/qos-frame-exchange-manager.cc @@ -121,7 +121,7 @@ QosFrameExchangeManager::PifsRecovery(bool forceCurrentCw) m_allowedWidth, m_channelAccessManager->GetLargestIdlePrimaryChannel(m_phy->GetPifs(), Simulator::Now())); - if (m_allowedWidth == 0) + if (m_allowedWidth == MHz_u{0}) { // PIFS recovery failed, TXOP is terminated NotifyChannelReleased(m_edca); diff --git a/src/wifi/model/rate-control/aarf-wifi-manager.cc b/src/wifi/model/rate-control/aarf-wifi-manager.cc index 8e9c760b2..c145ba709 100644 --- a/src/wifi/model/rate-control/aarf-wifi-manager.cc +++ b/src/wifi/model/rate-control/aarf-wifi-manager.cc @@ -250,9 +250,9 @@ AarfWifiManager::DoGetDataTxVector(WifiRemoteStation* st, MHz_u allowedWidth) NS_LOG_FUNCTION(this << st << allowedWidth); auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode = GetSupported(station, station->m_rate); uint64_t rate = mode.GetDataRate(channelWidth); @@ -281,9 +281,9 @@ AarfWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) /// RTS only by picking a single rate within the BasicRateSet. auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode; if (!GetUseNonErpProtection()) diff --git a/src/wifi/model/rate-control/aarfcd-wifi-manager.cc b/src/wifi/model/rate-control/aarfcd-wifi-manager.cc index a6fe8153e..e314b2b86 100644 --- a/src/wifi/model/rate-control/aarfcd-wifi-manager.cc +++ b/src/wifi/model/rate-control/aarfcd-wifi-manager.cc @@ -319,9 +319,9 @@ AarfcdWifiManager::DoGetDataTxVector(WifiRemoteStation* st, MHz_u allowedWidth) NS_LOG_FUNCTION(this << st << allowedWidth); auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode = GetSupported(station, station->m_rate); uint64_t rate = mode.GetDataRate(channelWidth); @@ -350,9 +350,9 @@ AarfcdWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) /// RTS only by picking a single rate within the BasicRateSet. auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode; if (!GetUseNonErpProtection()) diff --git a/src/wifi/model/rate-control/amrr-wifi-manager.cc b/src/wifi/model/rate-control/amrr-wifi-manager.cc index 9729e4766..9a54b8276 100644 --- a/src/wifi/model/rate-control/amrr-wifi-manager.cc +++ b/src/wifi/model/rate-control/amrr-wifi-manager.cc @@ -365,9 +365,9 @@ AmrrWifiManager::DoGetDataTxVector(WifiRemoteStation* st, MHz_u allowedWidth) } } auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode = GetSupported(station, rateIndex); uint64_t rate = mode.GetDataRate(channelWidth); @@ -394,9 +394,9 @@ AmrrWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) NS_LOG_FUNCTION(this << st); auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } UpdateMode(station); WifiMode mode; diff --git a/src/wifi/model/rate-control/aparf-wifi-manager.cc b/src/wifi/model/rate-control/aparf-wifi-manager.cc index 39b3f8392..512a58486 100644 --- a/src/wifi/model/rate-control/aparf-wifi-manager.cc +++ b/src/wifi/model/rate-control/aparf-wifi-manager.cc @@ -342,9 +342,9 @@ AparfWifiManager::DoGetDataTxVector(WifiRemoteStation* st, MHz_u allowedWidth) NS_LOG_FUNCTION(this << st << allowedWidth); auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } CheckInit(station); WifiMode mode = GetSupported(station, station->m_rateIndex); @@ -382,9 +382,9 @@ AparfWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) /// RTS only by picking a single rate within the BasicRateSet. auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode; if (!GetUseNonErpProtection()) diff --git a/src/wifi/model/rate-control/arf-wifi-manager.cc b/src/wifi/model/rate-control/arf-wifi-manager.cc index 9700b3996..e4604fd7f 100644 --- a/src/wifi/model/rate-control/arf-wifi-manager.cc +++ b/src/wifi/model/rate-control/arf-wifi-manager.cc @@ -227,9 +227,9 @@ ArfWifiManager::DoGetDataTxVector(WifiRemoteStation* st, MHz_u allowedWidth) NS_LOG_FUNCTION(this << st << allowedWidth); auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode = GetSupported(station, station->m_rate); uint64_t rate = mode.GetDataRate(channelWidth); @@ -258,9 +258,9 @@ ArfWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) /// RTS only by picking a single rate within the BasicRateSet. auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode; if (!GetUseNonErpProtection()) diff --git a/src/wifi/model/rate-control/cara-wifi-manager.cc b/src/wifi/model/rate-control/cara-wifi-manager.cc index 635146b89..a61d56ec3 100644 --- a/src/wifi/model/rate-control/cara-wifi-manager.cc +++ b/src/wifi/model/rate-control/cara-wifi-manager.cc @@ -198,9 +198,9 @@ CaraWifiManager::DoGetDataTxVector(WifiRemoteStation* st, MHz_u allowedWidth) NS_LOG_FUNCTION(this << st << allowedWidth); auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode = GetSupported(station, station->m_rate); uint64_t rate = mode.GetDataRate(channelWidth); @@ -229,9 +229,9 @@ CaraWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) /// @todo we could/should implement the Arf algorithm for /// RTS only by picking a single rate within the BasicRateSet. auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode; if (!GetUseNonErpProtection()) diff --git a/src/wifi/model/rate-control/ideal-wifi-manager.cc b/src/wifi/model/rate-control/ideal-wifi-manager.cc index 81eb459c7..3d3a76cb1 100644 --- a/src/wifi/model/rate-control/ideal-wifi-manager.cc +++ b/src/wifi/model/rate-control/ideal-wifi-manager.cc @@ -89,11 +89,11 @@ IdealWifiManager::GetChannelWidthForNonHtMode(WifiMode mode) const if (mode.GetModulationClass() == WIFI_MOD_CLASS_DSSS || mode.GetModulationClass() == WIFI_MOD_CLASS_HR_DSSS) { - return 22; + return MHz_u{22}; } else { - return 20; + return MHz_u{20}; } } @@ -243,11 +243,11 @@ IdealWifiManager::Reset(WifiRemoteStation* station) const NS_LOG_FUNCTION(this << station); auto st = static_cast(station); st->m_lastSnrObserved = 0.0; - st->m_lastChannelWidthObserved = 0; + st->m_lastChannelWidthObserved = MHz_u{0}; st->m_lastNssObserved = 1; st->m_lastSnrCached = CACHE_INITIAL_VALUE; st->m_lastMode = GetDefaultMode(); - st->m_lastChannelWidth = 0; + st->m_lastChannelWidth = MHz_u{0}; st->m_lastNss = 1; } @@ -279,7 +279,7 @@ IdealWifiManager::DoReportRtsOk(WifiRemoteStation* st, auto station = static_cast(st); station->m_lastSnrObserved = rtsSnr; station->m_lastChannelWidthObserved = - GetPhy()->GetChannelWidth() >= 40 ? 20 : GetPhy()->GetChannelWidth(); + GetPhy()->GetChannelWidth() >= MHz_u{42} ? MHz_u{20} : GetPhy()->GetChannelWidth(); station->m_lastNssObserved = 1; } diff --git a/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc b/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc index 6c1f7ffce..d86836702 100644 --- a/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc +++ b/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc @@ -939,7 +939,7 @@ MinstrelHtWifiManager::UpdateRateAfterAllowedWidth(uint16_t txRate, MHz_u allowe // the width becomes lower than 20 MHz auto width = group.chWidth / 2; - while (width >= 20) + while (width >= MHz_u{20}) { if (width > allowedWidth) { @@ -955,7 +955,7 @@ MinstrelHtWifiManager::UpdateRateAfterAllowedWidth(uint16_t txRate, MHz_u allowe width /= 2; } - NS_ABORT_MSG_IF(width < 20, "No rate compatible with the allowed width found"); + NS_ABORT_MSG_IF(width < MHz_u{20}, "No rate compatible with the allowed width found"); return GetIndex(groupId, GetRateId(txRate)); } @@ -1076,7 +1076,7 @@ MinstrelHtWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) for (uint8_t i = 0; i < nBasicRates; i++) { - const auto rate = GetBasicMode(i).GetDataRate(20); + const auto rate = GetBasicMode(i).GetDataRate(MHz_u{20}); if (rate <= lastDataRate) { rtsRate = GetBasicMode(i); @@ -1088,7 +1088,7 @@ MinstrelHtWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) { for (const auto& mode : GetPhy()->GetModeList()) { - const auto rate = mode.GetDataRate(20); + const auto rate = mode.GetDataRate(MHz_u{20}); if (rate <= lastDataRate) { rtsRate = mode; @@ -2057,7 +2057,7 @@ MinstrelHtWifiManager::GetIdInGroup(WifiModulationClass mc, standardInfos.guardIntervals.cend(), guardInterval); const auto giIndex = std::distance(standardInfos.guardIntervals.cbegin(), it); - const auto widthIndex = std::log2(chWidth / 20); + const auto widthIndex = std::log2(chWidth / MHz_u{20}); return (standardInfos.maxStreams * standardInfos.guardIntervals.size() * widthIndex) + (standardInfos.maxStreams * giIndex) + streams - 1; } @@ -2066,7 +2066,7 @@ std::size_t MinstrelHtWifiManager::GetNumGroups(WifiModulationClass mc) { const auto& standardInfos = minstrelHtStandardInfos.at(mc); - const auto numWidths = std::log2(standardInfos.maxWidth / 20) + 1; + const auto numWidths = std::log2(standardInfos.maxWidth / MHz_u{20}) + 1; return numWidths * standardInfos.guardIntervals.size() * standardInfos.maxStreams; } diff --git a/src/wifi/model/rate-control/minstrel-wifi-manager.cc b/src/wifi/model/rate-control/minstrel-wifi-manager.cc index d58ba0d53..8f2215c7c 100644 --- a/src/wifi/model/rate-control/minstrel-wifi-manager.cc +++ b/src/wifi/model/rate-control/minstrel-wifi-manager.cc @@ -377,9 +377,9 @@ MinstrelWifiManager::GetDataTxVector(MinstrelWifiRemoteStation* station) { NS_LOG_FUNCTION(this << station); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } if (!station->m_initialized) { @@ -410,9 +410,9 @@ MinstrelWifiManager::GetRtsTxVector(MinstrelWifiRemoteStation* station) NS_LOG_FUNCTION(this << station); NS_LOG_DEBUG("DoGetRtsMode m_txrate=" << station->m_txrate); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode; if (!GetUseNonErpProtection()) diff --git a/src/wifi/model/rate-control/onoe-wifi-manager.cc b/src/wifi/model/rate-control/onoe-wifi-manager.cc index 158395cb5..bab3cfbae 100644 --- a/src/wifi/model/rate-control/onoe-wifi-manager.cc +++ b/src/wifi/model/rate-control/onoe-wifi-manager.cc @@ -324,9 +324,9 @@ OnoeWifiManager::DoGetDataTxVector(WifiRemoteStation* st, MHz_u allowedWidth) } } auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode = GetSupported(station, rateIndex); uint64_t rate = mode.GetDataRate(channelWidth); @@ -353,9 +353,9 @@ OnoeWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) NS_LOG_FUNCTION(this << st); auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } UpdateMode(station); WifiMode mode; diff --git a/src/wifi/model/rate-control/parf-wifi-manager.cc b/src/wifi/model/rate-control/parf-wifi-manager.cc index 41ce34667..02d47bf51 100644 --- a/src/wifi/model/rate-control/parf-wifi-manager.cc +++ b/src/wifi/model/rate-control/parf-wifi-manager.cc @@ -314,9 +314,9 @@ ParfWifiManager::DoGetDataTxVector(WifiRemoteStation* st, MHz_u allowedWidth) NS_LOG_FUNCTION(this << st << allowedWidth); auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } CheckInit(station); WifiMode mode = GetSupported(station, station->m_rateIndex); @@ -354,9 +354,9 @@ ParfWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) /// RTS only by picking a single rate within the BasicRateSet. auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode; if (!GetUseNonErpProtection()) diff --git a/src/wifi/model/rate-control/rraa-wifi-manager.cc b/src/wifi/model/rate-control/rraa-wifi-manager.cc index 326caadaf..dd502f30b 100644 --- a/src/wifi/model/rate-control/rraa-wifi-manager.cc +++ b/src/wifi/model/rate-control/rraa-wifi-manager.cc @@ -347,9 +347,9 @@ RraaWifiManager::DoGetDataTxVector(WifiRemoteStation* st, MHz_u allowedWidth) NS_LOG_FUNCTION(this << st << allowedWidth); auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } CheckInit(station); WifiMode mode = GetSupported(station, station->m_rateIndex); @@ -377,9 +377,9 @@ RraaWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) NS_LOG_FUNCTION(this << st); auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode; if (!GetUseNonErpProtection()) diff --git a/src/wifi/model/rate-control/rrpaa-wifi-manager.cc b/src/wifi/model/rate-control/rrpaa-wifi-manager.cc index f8ba97bb5..c94822a10 100644 --- a/src/wifi/model/rate-control/rrpaa-wifi-manager.cc +++ b/src/wifi/model/rate-control/rrpaa-wifi-manager.cc @@ -391,9 +391,9 @@ RrpaaWifiManager::DoGetDataTxVector(WifiRemoteStation* st, MHz_u allowedWidth) NS_LOG_FUNCTION(this << st << allowedWidth); auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } CheckInit(station); WifiMode mode = GetSupported(station, station->m_rateIndex); @@ -429,9 +429,9 @@ RrpaaWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) NS_LOG_FUNCTION(this << st); auto station = static_cast(st); auto channelWidth = GetChannelWidth(station); - if (channelWidth > 20 && channelWidth != 22) + if (channelWidth > MHz_u{20} && channelWidth != MHz_u{22}) { - channelWidth = 20; + channelWidth = MHz_u{20}; } WifiMode mode; if (!GetUseNonErpProtection()) diff --git a/src/wifi/model/rate-control/thompson-sampling-wifi-manager.cc b/src/wifi/model/rate-control/thompson-sampling-wifi-manager.cc index d44d933df..74b0d1a60 100644 --- a/src/wifi/model/rate-control/thompson-sampling-wifi-manager.cc +++ b/src/wifi/model/rate-control/thompson-sampling-wifi-manager.cc @@ -151,11 +151,11 @@ ThompsonSamplingWifiManager::InitializeStation(WifiRemoteStation* st) const if (stats.mode.GetModulationClass() == WIFI_MOD_CLASS_DSSS || stats.mode.GetModulationClass() == WIFI_MOD_CLASS_HR_DSSS) { - stats.channelWidth = 22; + stats.channelWidth = MHz_u{22}; } else { - stats.channelWidth = 20; + stats.channelWidth = MHz_u{20}; } stats.nss = 1; station->m_mcsStats.push_back(stats); diff --git a/src/wifi/model/reduced-neighbor-report.cc b/src/wifi/model/reduced-neighbor-report.cc index 43bc92352..90fca09cd 100644 --- a/src/wifi/model/reduced-neighbor-report.cc +++ b/src/wifi/model/reduced-neighbor-report.cc @@ -54,17 +54,17 @@ ReducedNeighborReport::SetOperatingChannel(std::size_t nbrApInfoId, switch (channel.GetPhyBand()) { case WIFI_PHY_BAND_2_4GHZ: - if (channel.GetWidth() == 20) + if (channel.GetWidth() == MHz_u{20}) { operatingClass = 81; } - else if (channel.GetWidth() == 40) + else if (channel.GetWidth() == MHz_u{40}) { operatingClass = 83; } break; case WIFI_PHY_BAND_5GHZ: - if (channel.GetWidth() == 20) + if (channel.GetWidth() == MHz_u{20}) { if (channelNumber == 36 || channelNumber == 40 || channelNumber == 44 || channelNumber == 48) @@ -90,7 +90,7 @@ ReducedNeighborReport::SetOperatingChannel(std::size_t nbrApInfoId, operatingClass = 125; } } - else if (channel.GetWidth() == 40) + else if (channel.GetWidth() == MHz_u{40}) { if (channelNumber == 38 || channelNumber == 46) { @@ -111,7 +111,7 @@ ReducedNeighborReport::SetOperatingChannel(std::size_t nbrApInfoId, operatingClass = 126; } } - else if (channel.GetWidth() == 80) + else if (channel.GetWidth() == MHz_u{80}) { if (channelNumber == 42 || channelNumber == 58 || channelNumber == 106 || channelNumber == 122 || channelNumber == 138 || channelNumber == 155 || @@ -120,7 +120,7 @@ ReducedNeighborReport::SetOperatingChannel(std::size_t nbrApInfoId, operatingClass = 128; } } - else if (channel.GetWidth() == 160) + else if (channel.GetWidth() == MHz_u{160}) { if (channelNumber == 50 || channelNumber == 114 || channelNumber == 163) { @@ -129,19 +129,19 @@ ReducedNeighborReport::SetOperatingChannel(std::size_t nbrApInfoId, } break; case WIFI_PHY_BAND_6GHZ: - if (channel.GetWidth() == 20) + if (channel.GetWidth() == MHz_u{20}) { operatingClass = 131; } - else if (channel.GetWidth() == 40) + else if (channel.GetWidth() == MHz_u{40}) { operatingClass = 132; } - else if (channel.GetWidth() == 80) + else if (channel.GetWidth() == MHz_u{80}) { operatingClass = 133; } - else if (channel.GetWidth() == 160) + else if (channel.GetWidth() == MHz_u{160}) { operatingClass = 134; } @@ -163,13 +163,13 @@ ReducedNeighborReport::SetOperatingChannel(std::size_t nbrApInfoId, switch (channel.GetPhyBand()) { case WIFI_PHY_BAND_2_4GHZ: - startingFreq = 2407; + startingFreq = MHz_u{2407}; break; case WIFI_PHY_BAND_5GHZ: - startingFreq = 5000; + startingFreq = MHz_u{5000}; break; case WIFI_PHY_BAND_6GHZ: - startingFreq = 5950; + startingFreq = MHz_u{5950}; break; case WIFI_PHY_BAND_UNSPECIFIED: default: @@ -178,7 +178,7 @@ ReducedNeighborReport::SetOperatingChannel(std::size_t nbrApInfoId, } uint8_t primaryChannelNumber = - (channel.GetPrimaryChannelCenterFrequency(20) - startingFreq) / 5; + (channel.GetPrimaryChannelCenterFrequency(MHz_u{20}) - startingFreq) / MHz_u{5}; m_nbrApInfoFields.at(nbrApInfoId).operatingClass = operatingClass; m_nbrApInfoFields.at(nbrApInfoId).channelNumber = primaryChannelNumber; @@ -196,68 +196,68 @@ ReducedNeighborReport::GetOperatingChannel(std::size_t nbrApInfoId) const { case 81: band = WIFI_PHY_BAND_2_4GHZ; - width = 20; + width = MHz_u{20}; break; case 83: band = WIFI_PHY_BAND_2_4GHZ; - width = 40; + width = MHz_u{40}; break; case 115: case 118: case 121: case 125: band = WIFI_PHY_BAND_5GHZ; - width = 20; + width = MHz_u{20}; break; case 116: case 119: case 122: case 126: band = WIFI_PHY_BAND_5GHZ; - width = 40; + width = MHz_u{40}; break; case 128: band = WIFI_PHY_BAND_5GHZ; - width = 80; + width = MHz_u{80}; break; case 129: band = WIFI_PHY_BAND_5GHZ; - width = 160; + width = MHz_u{160}; break; case 131: band = WIFI_PHY_BAND_6GHZ; - width = 20; + width = MHz_u{20}; break; case 132: band = WIFI_PHY_BAND_6GHZ; - width = 40; + width = MHz_u{40}; break; case 133: band = WIFI_PHY_BAND_6GHZ; - width = 80; + width = MHz_u{80}; break; case 134: band = WIFI_PHY_BAND_6GHZ; - width = 160; + width = MHz_u{160}; break; default: break; } - NS_ABORT_IF(band == WIFI_PHY_BAND_UNSPECIFIED || width == 0); + NS_ABORT_IF(band == WIFI_PHY_BAND_UNSPECIFIED || width == MHz_u{0}); MHz_u startingFreq = 0; switch (band) { case WIFI_PHY_BAND_2_4GHZ: - startingFreq = 2407; + startingFreq = MHz_u{2407}; break; case WIFI_PHY_BAND_5GHZ: - startingFreq = 5000; + startingFreq = MHz_u{5000}; break; case WIFI_PHY_BAND_6GHZ: - startingFreq = 5950; + startingFreq = MHz_u{5950}; break; case WIFI_PHY_BAND_UNSPECIFIED: default: @@ -266,7 +266,7 @@ ReducedNeighborReport::GetOperatingChannel(std::size_t nbrApInfoId) const } uint8_t primaryChannelNumber = m_nbrApInfoFields.at(nbrApInfoId).channelNumber; - MHz_u primaryChannelCenterFrequency = startingFreq + primaryChannelNumber * 5; + MHz_u primaryChannelCenterFrequency = startingFreq + primaryChannelNumber * MHz_u{5}; uint8_t channelNumber = 0; MHz_u frequency = 0; @@ -300,8 +300,8 @@ ReducedNeighborReport::GetOperatingChannel(std::size_t nbrApInfoId) const } break; case 40: - if ((channel.frequency == primaryChannelCenterFrequency + 10) || - (channel.frequency == primaryChannelCenterFrequency - 10)) + if ((channel.frequency == primaryChannelCenterFrequency + MHz_u{10}) || + (channel.frequency == primaryChannelCenterFrequency - MHz_u{10})) { found = true; } @@ -320,13 +320,13 @@ ReducedNeighborReport::GetOperatingChannel(std::size_t nbrApInfoId) const } } - NS_ABORT_IF(channelNumber == 0 || frequency == 0); + NS_ABORT_IF(channelNumber == 0 || frequency == MHz_u{0}); WifiPhyOperatingChannel channel; channel.Set({{channelNumber, frequency, width, band}}, WIFI_STANDARD_UNSPECIFIED); MHz_u channelLowestFreq = frequency - width / 2; - MHz_u primaryChannelLowestFreq = primaryChannelCenterFrequency - 10; + MHz_u primaryChannelLowestFreq = primaryChannelCenterFrequency - MHz_u{10}; channel.SetPrimary20Index(Count20MHzSubchannels(channelLowestFreq, primaryChannelLowestFreq)); return channel; diff --git a/src/wifi/model/reference/error-rate-tables.cc b/src/wifi/model/reference/error-rate-tables.cc index 8760b829c..0fd231a6c 100644 --- a/src/wifi/model/reference/error-rate-tables.cc +++ b/src/wifi/model/reference/error-rate-tables.cc @@ -20,188 +20,188 @@ namespace ns3 const SnrPerTable AwgnErrorTableBcc32[ERROR_TABLE_BCC_MAX_NUM_MCS] = { // MCS-0 { - {-3.50000, 1.00000}, - {-3.00000, 0.99500}, - {-2.50000, 0.94080}, - {-2.00000, 0.82590}, - {-1.50000, 0.58950}, - {-1.00000, 0.30830}, - {-0.50000, 0.12540}, - {0.00000, 0.03440}, - {0.50000, 0.00850}, - {1.00000, 0.00150}, - {1.50000, 0.00024}, - {2.00000, 0.00009}, - {2.50000, 0.00000}, + {dB_u{-3.50000}, 1.00000}, + {dB_u{-3.00000}, 0.99500}, + {dB_u{-2.50000}, 0.94080}, + {dB_u{-2.00000}, 0.82590}, + {dB_u{-1.50000}, 0.58950}, + {dB_u{-1.00000}, 0.30830}, + {dB_u{-0.50000}, 0.12540}, + {dB_u{0.00000}, 0.03440}, + {dB_u{0.50000}, 0.00850}, + {dB_u{1.00000}, 0.00150}, + {dB_u{1.50000}, 0.00024}, + {dB_u{2.00000}, 0.00009}, + {dB_u{2.50000}, 0.00000}, }, // MCS-1 { - {-0.50000, 1.00000}, - {0.00000, 0.99210}, - {0.50000, 0.96710}, - {1.00000, 0.83490}, - {1.50000, 0.58740}, - {2.00000, 0.31690}, - {2.50000, 0.11820}, - {3.00000, 0.03640}, - {3.50000, 0.00850}, - {4.00000, 0.00160}, - {4.50000, 0.00026}, - {5.00000, 0.00003}, - {5.50000, 0.00000}, + {dB_u{-0.50000}, 1.00000}, + {dB_u{0.00000}, 0.99210}, + {dB_u{0.50000}, 0.96710}, + {dB_u{1.00000}, 0.83490}, + {dB_u{1.50000}, 0.58740}, + {dB_u{2.00000}, 0.31690}, + {dB_u{2.50000}, 0.11820}, + {dB_u{3.00000}, 0.03640}, + {dB_u{3.50000}, 0.00850}, + {dB_u{4.00000}, 0.00160}, + {dB_u{4.50000}, 0.00026}, + {dB_u{5.00000}, 0.00003}, + {dB_u{5.50000}, 0.00000}, }, // MCS-2 { - {2.00000, 1.00000}, - {2.50000, 0.99400}, - {3.00000, 0.95880}, - {3.50000, 0.85120}, - {4.00000, 0.59900}, - {4.50000, 0.31250}, - {5.00000, 0.11710}, - {5.50000, 0.03390}, - {6.00000, 0.00780}, - {6.50000, 0.00160}, - {7.00000, 0.00028}, - {7.50000, 0.00008}, - {8.00000, 0.00000}, + {dB_u{2.00000}, 1.00000}, + {dB_u{2.50000}, 0.99400}, + {dB_u{3.00000}, 0.95880}, + {dB_u{3.50000}, 0.85120}, + {dB_u{4.00000}, 0.59900}, + {dB_u{4.50000}, 0.31250}, + {dB_u{5.00000}, 0.11710}, + {dB_u{5.50000}, 0.03390}, + {dB_u{6.00000}, 0.00780}, + {dB_u{6.50000}, 0.00160}, + {dB_u{7.00000}, 0.00028}, + {dB_u{7.50000}, 0.00008}, + {dB_u{8.00000}, 0.00000}, }, // MCS-3 { - {4.00000, 1.00000}, - {4.50000, 0.99900}, - {5.00000, 0.99800}, - {5.50000, 0.96900}, - {6.00000, 0.88430}, - {6.50000, 0.74090}, - {7.00000, 0.46510}, - {7.50000, 0.25710}, - {8.00000, 0.10800}, - {8.50000, 0.03810}, - {9.00000, 0.01190}, - {9.50000, 0.00320}, - {10.00000, 0.00076}, - {10.50000, 0.00017}, - {11.00000, 0.00003}, - {11.50000, 0.00000}, + {dB_u{4.00000}, 1.00000}, + {dB_u{4.50000}, 0.99900}, + {dB_u{5.00000}, 0.99800}, + {dB_u{5.50000}, 0.96900}, + {dB_u{6.00000}, 0.88430}, + {dB_u{6.50000}, 0.74090}, + {dB_u{7.00000}, 0.46510}, + {dB_u{7.50000}, 0.25710}, + {dB_u{8.00000}, 0.10800}, + {dB_u{8.50000}, 0.03810}, + {dB_u{9.00000}, 0.01190}, + {dB_u{9.50000}, 0.00320}, + {dB_u{10.00000}, 0.00076}, + {dB_u{10.50000}, 0.00017}, + {dB_u{11.00000}, 0.00003}, + {dB_u{11.50000}, 0.00000}, }, // MCS-4 { - {8.00000, 1.00000}, - {8.50000, 0.99900}, - {9.00000, 0.94790}, - {9.50000, 0.79890}, - {10.00000, 0.59230}, - {10.50000, 0.33700}, - {11.00000, 0.15720}, - {11.50000, 0.05420}, - {12.00000, 0.01580}, - {12.50000, 0.00400}, - {13.00000, 0.00110}, - {13.50000, 0.00027}, - {14.00000, 0.00009}, - {14.50000, 0.00000}, + {dB_u{8.00000}, 1.00000}, + {dB_u{8.50000}, 0.99900}, + {dB_u{9.00000}, 0.94790}, + {dB_u{9.50000}, 0.79890}, + {dB_u{10.00000}, 0.59230}, + {dB_u{10.50000}, 0.33700}, + {dB_u{11.00000}, 0.15720}, + {dB_u{11.50000}, 0.05420}, + {dB_u{12.00000}, 0.01580}, + {dB_u{12.50000}, 0.00400}, + {dB_u{13.00000}, 0.00110}, + {dB_u{13.50000}, 0.00027}, + {dB_u{14.00000}, 0.00009}, + {dB_u{14.50000}, 0.00000}, }, // MCS-5 { - {11.50000, 1.00000}, - {12.00000, 0.99800}, - {12.50000, 0.96530}, - {13.00000, 0.89700}, - {13.50000, 0.73010}, - {14.00000, 0.52570}, - {14.50000, 0.30580}, - {15.00000, 0.15750}, - {15.50000, 0.06460}, - {16.00000, 0.02410}, - {16.50000, 0.00790}, - {17.00000, 0.00230}, - {17.50000, 0.00069}, - {18.00000, 0.00018}, - {18.50000, 0.00004}, - {19.00000, 0.00002}, - {19.50000, 0.00000}, + {dB_u{11.50000}, 1.00000}, + {dB_u{12.00000}, 0.99800}, + {dB_u{12.50000}, 0.96530}, + {dB_u{13.00000}, 0.89700}, + {dB_u{13.50000}, 0.73010}, + {dB_u{14.00000}, 0.52570}, + {dB_u{14.50000}, 0.30580}, + {dB_u{15.00000}, 0.15750}, + {dB_u{15.50000}, 0.06460}, + {dB_u{16.00000}, 0.02410}, + {dB_u{16.50000}, 0.00790}, + {dB_u{17.00000}, 0.00230}, + {dB_u{17.50000}, 0.00069}, + {dB_u{18.00000}, 0.00018}, + {dB_u{18.50000}, 0.00004}, + {dB_u{19.00000}, 0.00002}, + {dB_u{19.50000}, 0.00000}, }, // MCS-6 { - {13.00000, 1.00000}, - {13.50000, 0.99010}, - {14.00000, 0.96250}, - {14.50000, 0.83980}, - {15.00000, 0.68660}, - {15.50000, 0.46340}, - {16.00000, 0.25200}, - {16.50000, 0.11450}, - {17.00000, 0.04610}, - {17.50000, 0.01580}, - {18.00000, 0.00490}, - {18.50000, 0.00160}, - {19.00000, 0.00039}, - {19.50000, 0.00011}, - {20.00000, 0.00002}, - {20.50000, 0.00000}, + {dB_u{13.00000}, 1.00000}, + {dB_u{13.50000}, 0.99010}, + {dB_u{14.00000}, 0.96250}, + {dB_u{14.50000}, 0.83980}, + {dB_u{15.00000}, 0.68660}, + {dB_u{15.50000}, 0.46340}, + {dB_u{16.00000}, 0.25200}, + {dB_u{16.50000}, 0.11450}, + {dB_u{17.00000}, 0.04610}, + {dB_u{17.50000}, 0.01580}, + {dB_u{18.00000}, 0.00490}, + {dB_u{18.50000}, 0.00160}, + {dB_u{19.00000}, 0.00039}, + {dB_u{19.50000}, 0.00011}, + {dB_u{20.00000}, 0.00002}, + {dB_u{20.50000}, 0.00000}, }, // MCS-7 { - {14.00000, 1.00000}, - {14.50000, 0.99700}, - {15.00000, 0.98330}, - {15.50000, 0.94260}, - {16.00000, 0.84830}, - {16.50000, 0.63470}, - {17.00000, 0.43770}, - {17.50000, 0.22260}, - {18.00000, 0.11110}, - {18.50000, 0.04400}, - {19.00000, 0.01730}, - {19.50000, 0.00530}, - {20.00000, 0.00190}, - {20.50000, 0.00052}, - {21.00000, 0.00016}, - {21.50000, 0.00004}, - {22.00000, 0.00000}, + {dB_u{14.00000}, 1.00000}, + {dB_u{14.50000}, 0.99700}, + {dB_u{15.00000}, 0.98330}, + {dB_u{15.50000}, 0.94260}, + {dB_u{16.00000}, 0.84830}, + {dB_u{16.50000}, 0.63470}, + {dB_u{17.00000}, 0.43770}, + {dB_u{17.50000}, 0.22260}, + {dB_u{18.00000}, 0.11110}, + {dB_u{18.50000}, 0.04400}, + {dB_u{19.00000}, 0.01730}, + {dB_u{19.50000}, 0.00530}, + {dB_u{20.00000}, 0.00190}, + {dB_u{20.50000}, 0.00052}, + {dB_u{21.00000}, 0.00016}, + {dB_u{21.50000}, 0.00004}, + {dB_u{22.00000}, 0.00000}, }, // MCS-8 { - {17.50000, 1.00000}, - {18.00000, 0.99600}, - {18.50000, 0.98040}, - {19.00000, 0.92860}, - {19.50000, 0.82250}, - {20.00000, 0.67500}, - {20.50000, 0.44140}, - {21.00000, 0.26660}, - {21.50000, 0.13380}, - {22.00000, 0.05950}, - {22.50000, 0.02450}, - {23.00000, 0.00910}, - {23.50000, 0.00320}, - {24.00000, 0.00098}, - {24.50000, 0.00033}, - {25.00000, 0.00014}, - {25.50000, 0.00004}, - {26.00000, 0.00000}, + {dB_u{17.50000}, 1.00000}, + {dB_u{18.00000}, 0.99600}, + {dB_u{18.50000}, 0.98040}, + {dB_u{19.00000}, 0.92860}, + {dB_u{19.50000}, 0.82250}, + {dB_u{20.00000}, 0.67500}, + {dB_u{20.50000}, 0.44140}, + {dB_u{21.00000}, 0.26660}, + {dB_u{21.50000}, 0.13380}, + {dB_u{22.00000}, 0.05950}, + {dB_u{22.50000}, 0.02450}, + {dB_u{23.00000}, 0.00910}, + {dB_u{23.50000}, 0.00320}, + {dB_u{24.00000}, 0.00098}, + {dB_u{24.50000}, 0.00033}, + {dB_u{25.00000}, 0.00014}, + {dB_u{25.50000}, 0.00004}, + {dB_u{26.00000}, 0.00000}, }, // MCS-9 { - {19.00000, 1.00000}, - {19.50000, 0.99800}, - {20.00000, 0.98910}, - {20.50000, 0.95970}, - {21.00000, 0.87500}, - {21.50000, 0.73170}, - {22.00000, 0.51540}, - {22.50000, 0.30380}, - {23.00000, 0.15240}, - {23.50000, 0.06340}, - {24.00000, 0.02470}, - {24.50000, 0.00850}, - {25.00000, 0.00290}, - {25.50000, 0.00100}, - {26.00000, 0.00017}, - {26.50000, 0.00014}, - {27.00000, 0.00002}, - {27.50000, 0.00000}, + {dB_u{19.00000}, 1.00000}, + {dB_u{19.50000}, 0.99800}, + {dB_u{20.00000}, 0.98910}, + {dB_u{20.50000}, 0.95970}, + {dB_u{21.00000}, 0.87500}, + {dB_u{21.50000}, 0.73170}, + {dB_u{22.00000}, 0.51540}, + {dB_u{22.50000}, 0.30380}, + {dB_u{23.00000}, 0.15240}, + {dB_u{23.50000}, 0.06340}, + {dB_u{24.00000}, 0.02470}, + {dB_u{24.50000}, 0.00850}, + {dB_u{25.00000}, 0.00290}, + {dB_u{25.50000}, 0.00100}, + {dB_u{26.00000}, 0.00017}, + {dB_u{26.50000}, 0.00014}, + {dB_u{27.00000}, 0.00002}, + {dB_u{27.50000}, 0.00000}, }, }; @@ -209,147 +209,147 @@ const SnrPerTable AwgnErrorTableBcc32[ERROR_TABLE_BCC_MAX_NUM_MCS] = { const SnrPerTable AwgnErrorTableBcc1458[ERROR_TABLE_BCC_MAX_NUM_MCS] = { // MCS-0 { - {-1.00000, 1.00000}, - {-0.50000, 0.99400}, - {0.00000, 0.81850}, - {0.50000, 0.29080}, - {1.00000, 0.06630}, - {1.50000, 0.01120}, - {2.00000, 0.00150}, - {2.50000, 0.00015}, - {3.00000, 0.00001}, - {3.50000, 0.00000}, + {dB_u{-1.00000}, 1.00000}, + {dB_u{-0.50000}, 0.99400}, + {dB_u{0.00000}, 0.81850}, + {dB_u{0.50000}, 0.29080}, + {dB_u{1.00000}, 0.06630}, + {dB_u{1.50000}, 0.01120}, + {dB_u{2.00000}, 0.00150}, + {dB_u{2.50000}, 0.00015}, + {dB_u{3.00000}, 0.00001}, + {dB_u{3.50000}, 0.00000}, }, // MCS-1 { - {2.00000, 1.00000}, - {2.50000, 0.99700}, - {3.00000, 0.79440}, - {3.50000, 0.30080}, - {4.00000, 0.07280}, - {4.50000, 0.01200}, - {5.00000, 0.00150}, - {5.50000, 0.00023}, - {6.00000, 0.00000}, + {dB_u{2.00000}, 1.00000}, + {dB_u{2.50000}, 0.99700}, + {dB_u{3.00000}, 0.79440}, + {dB_u{3.50000}, 0.30080}, + {dB_u{4.00000}, 0.07280}, + {dB_u{4.50000}, 0.01200}, + {dB_u{5.00000}, 0.00150}, + {dB_u{5.50000}, 0.00023}, + {dB_u{6.00000}, 0.00000}, }, // MCS-2 { - {4.50000, 1.00000}, - {5.00000, 0.99800}, - {5.50000, 0.75780}, - {6.00000, 0.30100}, - {6.50000, 0.06760}, - {7.00000, 0.01220}, - {7.50000, 0.00230}, - {8.00000, 0.00035}, - {8.50000, 0.00004}, - {9.00000, 0.00000}, + {dB_u{4.50000}, 1.00000}, + {dB_u{5.00000}, 0.99800}, + {dB_u{5.50000}, 0.75780}, + {dB_u{6.00000}, 0.30100}, + {dB_u{6.50000}, 0.06760}, + {dB_u{7.00000}, 0.01220}, + {dB_u{7.50000}, 0.00230}, + {dB_u{8.00000}, 0.00035}, + {dB_u{8.50000}, 0.00004}, + {dB_u{9.00000}, 0.00000}, }, // MCS-3 { - {7.50000, 1.00000}, - {8.00000, 0.99400}, - {8.50000, 0.84050}, - {9.00000, 0.43410}, - {9.50000, 0.14190}, - {10.00000, 0.03740}, - {10.50000, 0.00860}, - {11.00000, 0.00190}, - {11.50000, 0.00036}, - {12.00000, 0.00005}, - {12.50000, 0.00000}, + {dB_u{7.50000}, 1.00000}, + {dB_u{8.00000}, 0.99400}, + {dB_u{8.50000}, 0.84050}, + {dB_u{9.00000}, 0.43410}, + {dB_u{9.50000}, 0.14190}, + {dB_u{10.00000}, 0.03740}, + {dB_u{10.50000}, 0.00860}, + {dB_u{11.00000}, 0.00190}, + {dB_u{11.50000}, 0.00036}, + {dB_u{12.00000}, 0.00005}, + {dB_u{12.50000}, 0.00000}, }, // MCS-4 { - {11.00000, 1.00000}, - {11.50000, 0.92690}, - {12.00000, 0.51390}, - {12.50000, 0.18260}, - {13.00000, 0.04650}, - {13.50000, 0.01100}, - {14.00000, 0.00260}, - {14.50000, 0.00041}, - {15.00000, 0.00010}, - {15.50000, 0.00000}, + {dB_u{11.00000}, 1.00000}, + {dB_u{11.50000}, 0.92690}, + {dB_u{12.00000}, 0.51390}, + {dB_u{12.50000}, 0.18260}, + {dB_u{13.00000}, 0.04650}, + {dB_u{13.50000}, 0.01100}, + {dB_u{14.00000}, 0.00260}, + {dB_u{14.50000}, 0.00041}, + {dB_u{15.00000}, 0.00010}, + {dB_u{15.50000}, 0.00000}, }, // MCS-5 { - {14.50000, 1.00000}, - {15.00000, 0.99900}, - {15.50000, 0.94790}, - {16.00000, 0.66250}, - {16.50000, 0.29780}, - {17.00000, 0.10580}, - {17.50000, 0.03340}, - {18.00000, 0.00910}, - {18.50000, 0.00230}, - {19.00000, 0.00064}, - {19.50000, 0.00017}, - {20.00000, 0.00002}, - {20.50000, 0.00000}, + {dB_u{14.50000}, 1.00000}, + {dB_u{15.00000}, 0.99900}, + {dB_u{15.50000}, 0.94790}, + {dB_u{16.00000}, 0.66250}, + {dB_u{16.50000}, 0.29780}, + {dB_u{17.00000}, 0.10580}, + {dB_u{17.50000}, 0.03340}, + {dB_u{18.00000}, 0.00910}, + {dB_u{18.50000}, 0.00230}, + {dB_u{19.00000}, 0.00064}, + {dB_u{19.50000}, 0.00017}, + {dB_u{20.00000}, 0.00002}, + {dB_u{20.50000}, 0.00000}, }, // MCS-6 { - {16.00000, 1.00000}, - {16.50000, 0.99500}, - {17.00000, 0.87960}, - {17.50000, 0.51390}, - {18.00000, 0.20910}, - {18.50000, 0.06390}, - {19.00000, 0.01860}, - {19.50000, 0.00460}, - {20.00000, 0.00130}, - {20.50000, 0.00023}, - {21.00000, 0.00002}, - {21.50000, 0.00000}, + {dB_u{16.00000}, 1.00000}, + {dB_u{16.50000}, 0.99500}, + {dB_u{17.00000}, 0.87960}, + {dB_u{17.50000}, 0.51390}, + {dB_u{18.00000}, 0.20910}, + {dB_u{18.50000}, 0.06390}, + {dB_u{19.00000}, 0.01860}, + {dB_u{19.50000}, 0.00460}, + {dB_u{20.00000}, 0.00130}, + {dB_u{20.50000}, 0.00023}, + {dB_u{21.00000}, 0.00002}, + {dB_u{21.50000}, 0.00000}, }, // MCS-7 { - {17.50000, 1.00000}, - {18.00000, 0.97850}, - {18.50000, 0.73930}, - {19.00000, 0.33750}, - {19.50000, 0.12340}, - {20.00000, 0.03550}, - {20.50000, 0.01000}, - {21.00000, 0.00270}, - {21.50000, 0.00050}, - {22.00000, 0.00009}, - {22.50000, 0.00001}, - {23.00000, 0.00000}, + {dB_u{17.50000}, 1.00000}, + {dB_u{18.00000}, 0.97850}, + {dB_u{18.50000}, 0.73930}, + {dB_u{19.00000}, 0.33750}, + {dB_u{19.50000}, 0.12340}, + {dB_u{20.00000}, 0.03550}, + {dB_u{20.50000}, 0.01000}, + {dB_u{21.00000}, 0.00270}, + {dB_u{21.50000}, 0.00050}, + {dB_u{22.00000}, 0.00009}, + {dB_u{22.50000}, 0.00001}, + {dB_u{23.00000}, 0.00000}, }, // MCS-8 { - {21.00000, 1.00000}, - {21.50000, 0.99800}, - {22.00000, 0.93990}, - {22.50000, 0.67090}, - {23.00000, 0.35250}, - {23.50000, 0.13760}, - {24.00000, 0.04750}, - {24.50000, 0.01540}, - {25.00000, 0.00520}, - {25.50000, 0.00150}, - {26.00000, 0.00036}, - {26.50000, 0.00007}, - {27.00000, 0.00000}, + {dB_u{21.00000}, 1.00000}, + {dB_u{21.50000}, 0.99800}, + {dB_u{22.00000}, 0.93990}, + {dB_u{22.50000}, 0.67090}, + {dB_u{23.00000}, 0.35250}, + {dB_u{23.50000}, 0.13760}, + {dB_u{24.00000}, 0.04750}, + {dB_u{24.50000}, 0.01540}, + {dB_u{25.00000}, 0.00520}, + {dB_u{25.50000}, 0.00150}, + {dB_u{26.00000}, 0.00036}, + {dB_u{26.50000}, 0.00007}, + {dB_u{27.00000}, 0.00000}, }, // MCS-9 { - {22.50000, 1.00000}, - {23.00000, 0.99900}, - {23.50000, 0.95060}, - {24.00000, 0.68470}, - {24.50000, 0.32610}, - {25.00000, 0.12480}, - {25.50000, 0.04090}, - {26.00000, 0.01300}, - {26.50000, 0.00360}, - {27.00000, 0.00082}, - {27.50000, 0.00010}, - {28.00000, 0.00002}, - {28.50000, 0.00001}, - {29.00000, 0.00000}, + {dB_u{22.50000}, 1.00000}, + {dB_u{23.00000}, 0.99900}, + {dB_u{23.50000}, 0.95060}, + {dB_u{24.00000}, 0.68470}, + {dB_u{24.50000}, 0.32610}, + {dB_u{25.00000}, 0.12480}, + {dB_u{25.50000}, 0.04090}, + {dB_u{26.00000}, 0.01300}, + {dB_u{26.50000}, 0.00360}, + {dB_u{27.00000}, 0.00082}, + {dB_u{27.50000}, 0.00010}, + {dB_u{28.00000}, 0.00002}, + {dB_u{28.50000}, 0.00001}, + {dB_u{29.00000}, 0.00000}, }, }; @@ -357,170 +357,172 @@ const SnrPerTable AwgnErrorTableBcc1458[ERROR_TABLE_BCC_MAX_NUM_MCS] = { const SnrPerTable AwgnErrorTableLdpc1458[ERROR_TABLE_LDPC_MAX_NUM_MCS] = { // MCS-0 { - {-1.50000, 1.00000}, - {-1.25000, 0.97950}, - {-1.00000, 0.60480}, - {-0.75000, 0.17050}, - {-0.50000, 0.03320}, - {-0.25000, 0.00530}, - {0.00000, 0.00085}, - {0.25000, 0.00022}, - {0.50000, 0.00004}, - {0.75000, 0.00000}, + {dB_u{-1.50000}, 1.00000}, + {dB_u{-1.25000}, 0.97950}, + {dB_u{-1.00000}, 0.60480}, + {dB_u{-0.75000}, 0.17050}, + {dB_u{-0.50000}, 0.03320}, + {dB_u{-0.25000}, 0.00530}, + {dB_u{0.00000}, 0.00085}, + {dB_u{0.25000}, 0.00022}, + {dB_u{0.50000}, 0.00004}, + {dB_u{0.75000}, 0.00000}, }, // MCS-1 { - {1.50000, 1.00000}, - {1.75000, 0.97470}, - {2.00000, 0.62330}, - {2.25000, 0.18590}, - {2.50000, 0.03400}, - {2.75000, 0.00550}, - {3.00000, 0.00083}, - {3.25000, 0.00015}, - {3.50000, 0.00003}, - {3.75000, 0.00000}, + {dB_u{1.50000}, 1.00000}, + {dB_u{1.75000}, 0.97470}, + {dB_u{2.00000}, 0.62330}, + {dB_u{2.25000}, 0.18590}, + {dB_u{2.50000}, 0.03400}, + {dB_u{2.75000}, 0.00550}, + {dB_u{3.00000}, 0.00083}, + {dB_u{3.25000}, 0.00015}, + {dB_u{3.50000}, 0.00003}, + {dB_u{3.75000}, 0.00000}, }, // MCS-2 { - {4.00000, 1.00000}, - {4.25000, 0.98720}, - {4.50000, 0.62560}, - {4.75000, 0.15800}, - {5.00000, 0.02090}, - {5.25000, 0.00250}, - {5.50000, 0.00034}, - {5.75000, 0.00003}, - {6.00000, 0.00000}, + {dB_u{4.00000}, 1.00000}, + {dB_u{4.25000}, 0.98720}, + {dB_u{4.50000}, 0.62560}, + {dB_u{4.75000}, 0.15800}, + {dB_u{5.00000}, 0.02090}, + {dB_u{5.25000}, 0.00250}, + {dB_u{5.50000}, 0.00034}, + {dB_u{5.75000}, 0.00003}, + {dB_u{6.00000}, 0.00000}, }, // MCS-3 { - {6.75000, 1.00000}, - {7.00000, 0.99800}, - {7.25000, 0.94340}, - {7.50000, 0.57890}, - {7.75000, 0.20640}, - {8.00000, 0.04840}, - {8.25000, 0.00930}, - {8.50000, 0.00180}, - {8.75000, 0.00040}, - {9.00000, 0.00011}, - {9.25000, 0.00002}, - {9.50000, 0.00000}, + {dB_u{6.75000}, 1.00000}, + {dB_u{7.00000}, 0.99800}, + {dB_u{7.25000}, 0.94340}, + {dB_u{7.50000}, 0.57890}, + {dB_u{7.75000}, 0.20640}, + {dB_u{8.00000}, 0.04840}, + {dB_u{8.25000}, 0.00930}, + {dB_u{8.50000}, 0.00180}, + {dB_u{8.75000}, 0.00040}, + {dB_u{9.00000}, 0.00011}, + {dB_u{9.25000}, 0.00002}, + {dB_u{9.50000}, 0.00000}, }, // MCS-4 - {{10.00000, 1.00000}, - {10.25000, 0.99310}, - {10.50000, 0.70890}, - {10.75000, 0.24720}, - {11.00000, 0.04700}, - {11.25000, 0.00590}, - {11.50000, 0.00091}, - {11.75000, 0.00016}, - {12.00000, 0.00003}, - {12.25000, 0.00000}}, + { + {dB_u{10.00000}, 1.00000}, + {dB_u{10.25000}, 0.99310}, + {dB_u{10.50000}, 0.70890}, + {dB_u{10.75000}, 0.24720}, + {dB_u{11.00000}, 0.04700}, + {dB_u{11.25000}, 0.00590}, + {dB_u{11.50000}, 0.00091}, + {dB_u{11.75000}, 0.00016}, + {dB_u{12.00000}, 0.00003}, + {dB_u{12.25000}, 0.00000}, + }, // MCS-5 { - {14.00000, 1.00000}, - {14.25000, 0.99700}, - {14.50000, 0.91830}, - {14.75000, 0.53790}, - {15.00000, 0.16610}, - {15.25000, 0.03690}, - {15.50000, 0.00650}, - {15.75000, 0.00100}, - {16.00000, 0.00031}, - {16.25000, 0.00005}, - {16.50000, 0.00000}, + {dB_u{14.00000}, 1.00000}, + {dB_u{14.25000}, 0.99700}, + {dB_u{14.50000}, 0.91830}, + {dB_u{14.75000}, 0.53790}, + {dB_u{15.00000}, 0.16610}, + {dB_u{15.25000}, 0.03690}, + {dB_u{15.50000}, 0.00650}, + {dB_u{15.75000}, 0.00100}, + {dB_u{16.00000}, 0.00031}, + {dB_u{16.25000}, 0.00005}, + {dB_u{16.50000}, 0.00000}, }, // MCS-6 { - {15.50000, 1.00000}, - {15.75000, 0.98140}, - {16.00000, 0.73930}, - {16.25000, 0.33110}, - {16.50000, 0.08150}, - {16.75000, 0.01620}, - {17.00000, 0.00270}, - {17.25000, 0.00052}, - {17.50000, 0.00005}, - {17.75000, 0.00003}, - {18.00000, 0.00000}, + {dB_u{15.50000}, 1.00000}, + {dB_u{15.75000}, 0.98140}, + {dB_u{16.00000}, 0.73930}, + {dB_u{16.25000}, 0.33110}, + {dB_u{16.50000}, 0.08150}, + {dB_u{16.75000}, 0.01620}, + {dB_u{17.00000}, 0.00270}, + {dB_u{17.25000}, 0.00052}, + {dB_u{17.50000}, 0.00005}, + {dB_u{17.75000}, 0.00003}, + {dB_u{18.00000}, 0.00000}, }, // MCS-7 { - {17.00000, 1.00000}, - {17.25000, 0.97750}, - {17.50000, 0.73980}, - {17.75000, 0.33190}, - {18.00000, 0.09640}, - {18.25000, 0.02180}, - {18.50000, 0.00470}, - {18.75000, 0.00087}, - {19.00000, 0.00018}, - {19.25000, 0.00003}, - {19.50000, 0.00000}, + {dB_u{17.00000}, 1.00000}, + {dB_u{17.25000}, 0.97750}, + {dB_u{17.50000}, 0.73980}, + {dB_u{17.75000}, 0.33190}, + {dB_u{18.00000}, 0.09640}, + {dB_u{18.25000}, 0.02180}, + {dB_u{18.50000}, 0.00470}, + {dB_u{18.75000}, 0.00087}, + {dB_u{19.00000}, 0.00018}, + {dB_u{19.25000}, 0.00003}, + {dB_u{19.50000}, 0.00000}, }, // MCS-8 { - {20.50000, 1.00000}, - {20.75000, 0.99500}, - {21.00000, 0.89700}, - {21.25000, 0.56270}, - {21.50000, 0.20920}, - {21.75000, 0.05600}, - {22.00000, 0.01170}, - {22.25000, 0.00250}, - {22.50000, 0.00038}, - {22.75000, 0.00013}, - {23.00000, 0.00004}, - {23.25000, 0.00001}, - {23.50000, 0.00000}, + {dB_u{20.50000}, 1.00000}, + {dB_u{20.75000}, 0.99500}, + {dB_u{21.00000}, 0.89700}, + {dB_u{21.25000}, 0.56270}, + {dB_u{21.50000}, 0.20920}, + {dB_u{21.75000}, 0.05600}, + {dB_u{22.00000}, 0.01170}, + {dB_u{22.25000}, 0.00250}, + {dB_u{22.50000}, 0.00038}, + {dB_u{22.75000}, 0.00013}, + {dB_u{23.00000}, 0.00004}, + {dB_u{23.25000}, 0.00001}, + {dB_u{23.50000}, 0.00000}, }, // MCS-9 { - {22.25000, 1.00000}, - {22.50000, 0.99900}, - {22.75000, 0.94080}, - {23.00000, 0.63600}, - {23.25000, 0.27190}, - {23.50000, 0.08700}, - {23.75000, 0.02210}, - {24.00000, 0.00500}, - {24.25000, 0.00110}, - {24.50000, 0.00032}, - {24.75000, 0.00004}, - {25.00000, 0.00000}, + {dB_u{22.25000}, 1.00000}, + {dB_u{22.50000}, 0.99900}, + {dB_u{22.75000}, 0.94080}, + {dB_u{23.00000}, 0.63600}, + {dB_u{23.25000}, 0.27190}, + {dB_u{23.50000}, 0.08700}, + {dB_u{23.75000}, 0.02210}, + {dB_u{24.00000}, 0.00500}, + {dB_u{24.25000}, 0.00110}, + {dB_u{24.50000}, 0.00032}, + {dB_u{24.75000}, 0.00004}, + {dB_u{25.00000}, 0.00000}, }, // MCS-10 { - {25.75000, 1.00000}, - {26.00000, 0.94970}, - {26.25000, 0.68660}, - {26.50000, 0.32940}, - {26.75000, 0.11620}, - {27.00000, 0.03440}, - {27.25000, 0.00880}, - {27.50000, 0.00210}, - {27.75000, 0.00054}, - {28.00000, 0.00009}, - {28.25000, 0.00002}, - {28.50000, 0.00000}, + {dB_u{25.75000}, 1.00000}, + {dB_u{26.00000}, 0.94970}, + {dB_u{26.25000}, 0.68660}, + {dB_u{26.50000}, 0.32940}, + {dB_u{26.75000}, 0.11620}, + {dB_u{27.00000}, 0.03440}, + {dB_u{27.25000}, 0.00880}, + {dB_u{27.50000}, 0.00210}, + {dB_u{27.75000}, 0.00054}, + {dB_u{28.00000}, 0.00009}, + {dB_u{28.25000}, 0.00002}, + {dB_u{28.50000}, 0.00000}, }, // MCS-11 { - {27.75000, 1.00000}, - {28.00000, 0.94880}, - {28.25000, 0.75260}, - {28.50000, 0.40230}, - {28.75000, 0.16210}, - {29.00000, 0.05150}, - {29.25000, 0.01310}, - {29.50000, 0.00360}, - {29.75000, 0.00100}, - {30.00000, 0.00022}, - {30.25000, 0.00006}, - {30.50000, 0.00000}, + {dB_u{27.75000}, 1.00000}, + {dB_u{28.00000}, 0.94880}, + {dB_u{28.25000}, 0.75260}, + {dB_u{28.50000}, 0.40230}, + {dB_u{28.75000}, 0.16210}, + {dB_u{29.00000}, 0.05150}, + {dB_u{29.25000}, 0.01310}, + {dB_u{29.50000}, 0.00360}, + {dB_u{29.75000}, 0.00100}, + {dB_u{30.00000}, 0.00022}, + {dB_u{30.25000}, 0.00006}, + {dB_u{30.50000}, 0.00000}, }, }; diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index d1d15b28a..289104386 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -124,13 +124,13 @@ SpectrumWifiPhy::ComputeBands(Ptr spectrumPhyInterface NS_LOG_FUNCTION(this << spectrumPhyInterface); WifiSpectrumBands bands{}; const auto channelWidth = spectrumPhyInterface->GetChannelWidth(); - if (channelWidth < 20) + if (channelWidth < MHz_u{20}) { bands.push_back(GetBandForInterface(spectrumPhyInterface, channelWidth)); } else { - for (MHz_u bw = channelWidth; bw >= 20; bw = bw / 2) + for (MHz_u bw = channelWidth; bw >= MHz_u{20}; bw = bw / 2) { for (uint16_t i = 0; i < (channelWidth / bw); ++i) { @@ -147,7 +147,7 @@ SpectrumWifiPhy::GetHeRuBands(Ptr spectrumPhyInterface { HeRuBands heRuBands{}; const auto channelWidth = spectrumPhyInterface->GetChannelWidth(); - for (MHz_u bw = channelWidth; bw >= 20; bw = bw / 2) + for (MHz_u bw = channelWidth; bw >= MHz_u{20}; bw = bw / 2) { for (uint32_t i = 0; i < (channelWidth / bw); ++i) { @@ -178,10 +178,10 @@ SpectrumWifiPhy::GetHeRuBands(Ptr spectrumPhyInterface indicesPerSegment)); } std::size_t index = - (bw == 160 && phyIndex > nRus / 2 ? phyIndex - nRus / 2 : phyIndex); - const auto p20Index = GetOperatingChannel().GetPrimaryChannelIndex(20); - bool primary80IsLower80 = (p20Index < bw / 40); - bool primary80 = (bw < 160 || ruType == HeRu::RU_2x996_TONE || + (bw == MHz_u{160} && phyIndex > nRus / 2 ? phyIndex - nRus / 2 : phyIndex); + const auto p20Index = GetOperatingChannel().GetPrimaryChannelIndex(MHz_u{20}); + bool primary80IsLower80 = (p20Index < bw / MHz_u{40}); + bool primary80 = (bw < MHz_u{160} || ruType == HeRu::RU_2x996_TONE || (primary80IsLower80 && phyIndex <= nRus / 2) || (!primary80IsLower80 && phyIndex > nRus / 2)); HeRu::RuSpec ru(ruType, index, primary80); @@ -501,7 +501,7 @@ SpectrumWifiPhy::StartRx(Ptr rxParams, const auto bw = std::accumulate(band.frequencies.cbegin(), band.frequencies.cend(), - 0, + MHz_u{0}, [](MHz_u sum, const auto& startStopFreqs) { return sum + HzToMHz(startStopFreqs.second - startStopFreqs.first); }); @@ -515,10 +515,10 @@ SpectrumWifiPhy::StartRx(Ptr rxParams, rxPowers.insert({band, rxPowerPerBand}); NS_LOG_DEBUG("Signal power received after antenna gain for " << bw << " MHz channel band " << index << ": " << rxPowerPerBand << " W" - << (rxPowerPerBand > 0.0 + << (rxPowerPerBand > Watt_u{0.0} ? " (" + std::to_string(WToDbm(rxPowerPerBand)) + " dBm)" : "")); - if (bw <= 20) + if (bw <= MHz_u{20}) { totalRxPower += rxPowerPerBand; } @@ -539,17 +539,18 @@ SpectrumWifiPhy::StartRx(Ptr rxParams, } } - NS_ASSERT_MSG(totalRxPower >= 0.0, "Negative RX power"); - NS_LOG_DEBUG( - "Total signal power received after antenna gain: " - << totalRxPower << " W" - << (totalRxPower > 0.0 ? " (" + std::to_string(WToDbm(totalRxPower)) + " dBm)" : "")); + NS_ASSERT_MSG(totalRxPower >= Watt_u{0.0}, "Negative RX power"); + NS_LOG_DEBUG("Total signal power received after antenna gain: " + << totalRxPower << " W" + << (totalRxPower > Watt_u{0.0} + ? " (" + std::to_string(WToDbm(totalRxPower)) + " dBm)" + : "")); Ptr wifiRxParams = DynamicCast(rxParams); // Log the signal arrival to the trace source - if (totalRxPower > 0.0) + if (totalRxPower > Watt_u{0.0}) { m_signalCb(rxParams, senderNodeId, WToDbm(totalRxPower), rxDuration); } @@ -589,10 +590,11 @@ SpectrumWifiPhy::StartRx(Ptr rxParams, const auto ppdu = GetRxPpduFromTxPpdu(wifiRxParams->ppdu); if (totalRxPower < DbmToW(GetRxSensitivity()) * (ppdu->GetTxChannelWidth() / MHz_u{20})) { - NS_LOG_INFO( - "Received signal too weak to process: " - << totalRxPower << " W" - << (totalRxPower > 0.0 ? " (" + std::to_string(WToDbm(totalRxPower)) + " dBm)" : "")); + NS_LOG_INFO("Received signal too weak to process: " + << totalRxPower << " W" + << (totalRxPower > Watt_u{0.0} + ? " (" + std::to_string(WToDbm(totalRxPower)) + " dBm)" + : "")); m_interference->Add(ppdu, rxDuration, rxPowers, GetCurrentFrequencyRange()); SwitchMaybeToCcaBusy(nullptr); return; @@ -663,10 +665,10 @@ MHz_u SpectrumWifiPhy::GetGuardBandwidth(MHz_u currentChannelWidth) const { MHz_u guardBandwidth = 0; - if (currentChannelWidth == 22) + if (currentChannelWidth == MHz_u{22}) { // handle case of DSSS transmission - guardBandwidth = 10; + guardBandwidth = MHz_u{10}; } else { diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index c106a83f3..ca69bc438 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -306,7 +306,7 @@ WifiScanParams::Channel StaWifiMac::GetCurrentChannel(uint8_t linkId) const { auto phy = GetWifiPhy(linkId); - const auto width = phy->GetOperatingChannel().IsOfdm() ? 20 : phy->GetChannelWidth(); + const auto width = phy->GetOperatingChannel().IsOfdm() ? MHz_u{20} : phy->GetChannelWidth(); uint8_t ch = phy->GetPrimaryChannelNumber(width); return {ch, phy->GetPhyBand()}; } diff --git a/src/wifi/model/vht/vht-configuration.cc b/src/wifi/model/vht/vht-configuration.cc index d3583eb17..94abecad5 100644 --- a/src/wifi/model/vht/vht-configuration.cc +++ b/src/wifi/model/vht/vht-configuration.cc @@ -82,17 +82,17 @@ VhtConfiguration::SetSecondaryCcaSensitivityThresholds( const SecondaryCcaSensitivityThresholds& thresholds) { NS_LOG_FUNCTION(this); - m_secondaryCcaSensitivityThresholds[20] = std::get<0>(thresholds); - m_secondaryCcaSensitivityThresholds[40] = std::get<1>(thresholds); - m_secondaryCcaSensitivityThresholds[80] = std::get<2>(thresholds); + m_secondaryCcaSensitivityThresholds[MHz_u{20}] = std::get<0>(thresholds); + m_secondaryCcaSensitivityThresholds[MHz_u{40}] = std::get<1>(thresholds); + m_secondaryCcaSensitivityThresholds[MHz_u{80}] = std::get<2>(thresholds); } VhtConfiguration::SecondaryCcaSensitivityThresholds VhtConfiguration::GetSecondaryCcaSensitivityThresholds() const { - return {m_secondaryCcaSensitivityThresholds.at(20), - m_secondaryCcaSensitivityThresholds.at(40), - m_secondaryCcaSensitivityThresholds.at(80)}; + return {m_secondaryCcaSensitivityThresholds.at(MHz_u{20}), + m_secondaryCcaSensitivityThresholds.at(MHz_u{40}), + m_secondaryCcaSensitivityThresholds.at(MHz_u{80})}; } const std::map& diff --git a/src/wifi/model/vht/vht-phy.cc b/src/wifi/model/vht/vht-phy.cc index fc3410f83..5695c26db 100644 --- a/src/wifi/model/vht/vht-phy.cc +++ b/src/wifi/model/vht/vht-phy.cc @@ -50,19 +50,19 @@ const PhyEntity::PpduFormats VhtPhy::m_vhtPpduFormats { const VhtPhy::NesExceptionMap VhtPhy::m_exceptionsMap { /* {BW,Nss,MCS} Nes */ - { std::make_tuple ( 80, 7, 2), 3 }, // instead of 2 - { std::make_tuple ( 80, 7, 7), 6 }, // instead of 4 - { std::make_tuple ( 80, 7, 8), 6 }, // instead of 5 - { std::make_tuple ( 80, 8, 7), 6 }, // instead of 5 - { std::make_tuple (160, 4, 7), 6 }, // instead of 5 - { std::make_tuple (160, 5, 8), 8 }, // instead of 7 - { std::make_tuple (160, 6, 7), 8 }, // instead of 7 - { std::make_tuple (160, 7, 3), 4 }, // instead of 3 - { std::make_tuple (160, 7, 4), 6 }, // instead of 5 - { std::make_tuple (160, 7, 5), 7 }, // instead of 6 - { std::make_tuple (160, 7, 7), 9 }, // instead of 8 - { std::make_tuple (160, 7, 8), 12 }, // instead of 9 - { std::make_tuple (160, 7, 9), 12 }, // instead of 10 + { std::make_tuple (MHz_u{80}, 7, 2), 3 }, // instead of 2 + { std::make_tuple (MHz_u{80}, 7, 7), 6 }, // instead of 4 + { std::make_tuple (MHz_u{80}, 7, 8), 6 }, // instead of 5 + { std::make_tuple (MHz_u{80}, 8, 7), 6 }, // instead of 5 + { std::make_tuple (MHz_u{160}, 4, 7), 6 }, // instead of 5 + { std::make_tuple (MHz_u{160}, 5, 8), 8 }, // instead of 7 + { std::make_tuple (MHz_u{160}, 6, 7), 8 }, // instead of 7 + { std::make_tuple (MHz_u{160}, 7, 3), 4 }, // instead of 3 + { std::make_tuple (MHz_u{160}, 7, 4), 6 }, // instead of 5 + { std::make_tuple (MHz_u{160}, 7, 5), 7 }, // instead of 6 + { std::make_tuple (MHz_u{160}, 7, 7), 9 }, // instead of 8 + { std::make_tuple (MHz_u{160}, 7, 8), 12 }, // instead of 9 + { std::make_tuple (MHz_u{160}, 7, 9), 12 }, // instead of 10 }; // clang-format on @@ -71,19 +71,19 @@ const VhtPhy::NesExceptionMap VhtPhy::m_exceptionsMap { * @brief map a given channel list type to the corresponding scaling factor */ const std::map channelTypeToScalingFactor{ - {WIFI_CHANLIST_PRIMARY, 0.0}, - {WIFI_CHANLIST_SECONDARY, 0.0}, - {WIFI_CHANLIST_SECONDARY40, 3.0}, - {WIFI_CHANLIST_SECONDARY80, 6.0}, + {WIFI_CHANLIST_PRIMARY, dBm_u{0.0}}, + {WIFI_CHANLIST_SECONDARY, dBm_u{0.0}}, + {WIFI_CHANLIST_SECONDARY40, dBm_u{3.0}}, + {WIFI_CHANLIST_SECONDARY80, dBm_u{6.0}}, }; /** * @brief map a given secondary channel width to its channel list type */ const std::map secondaryChannels{ - {20, WIFI_CHANLIST_SECONDARY}, - {40, WIFI_CHANLIST_SECONDARY40}, - {80, WIFI_CHANLIST_SECONDARY80}, + {MHz_u{20}, WIFI_CHANLIST_SECONDARY}, + {MHz_u{40}, WIFI_CHANLIST_SECONDARY40}, + {MHz_u{80}, WIFI_CHANLIST_SECONDARY80}, }; VhtPhy::VhtPhy(bool buildModeList /* = true */) @@ -516,11 +516,11 @@ VhtPhy::IsAllowed(const WifiTxVector& txVector) bool VhtPhy::IsCombinationAllowed(uint8_t mcsValue, MHz_u channelWidth, uint8_t nss) { - if (mcsValue == 9 && channelWidth == 20 && nss != 3) + if (mcsValue == 9 && channelWidth == MHz_u{20} && nss != 3) { return false; } - if (mcsValue == 6 && channelWidth == 80 && nss == 3) + if (mcsValue == 6 && channelWidth == MHz_u{80} && nss == 3) { return false; } @@ -547,13 +547,13 @@ VhtPhy::GetCcaThreshold(const Ptr ppdu, WifiChannelListType chan return m_wifiPhy->GetCcaSensitivityThreshold(); } case WIFI_CHANLIST_SECONDARY: - NS_ASSERT_MSG(ppduBw == 20, "Invalid channel width " << ppduBw); + NS_ASSERT_MSG(ppduBw == MHz_u{20}, "Invalid channel width " << ppduBw); break; case WIFI_CHANLIST_SECONDARY40: - NS_ASSERT_MSG(ppduBw <= 40, "Invalid channel width " << ppduBw); + NS_ASSERT_MSG(ppduBw <= MHz_u{40}, "Invalid channel width " << ppduBw); break; case WIFI_CHANLIST_SECONDARY80: - NS_ASSERT_MSG(ppduBw <= 80, "Invalid channel width " << ppduBw); + NS_ASSERT_MSG(ppduBw <= MHz_u{80}, "Invalid channel width " << ppduBw); break; default: NS_ASSERT_MSG(false, "Invalid channel list type"); diff --git a/src/wifi/model/vht/vht-ppdu.cc b/src/wifi/model/vht/vht-ppdu.cc index 3d0748c3e..c47eed3a8 100644 --- a/src/wifi/model/vht/vht-ppdu.cc +++ b/src/wifi/model/vht/vht-ppdu.cc @@ -150,15 +150,15 @@ VhtPpdu::VhtSigHeader::SetMuFlag(bool mu) void VhtPpdu::VhtSigHeader::SetChannelWidth(MHz_u channelWidth) { - if (channelWidth == 160) + if (channelWidth == MHz_u{160}) { m_bw = 3; } - else if (channelWidth == 80) + else if (channelWidth == MHz_u{80}) { m_bw = 2; } - else if (channelWidth == 40) + else if (channelWidth == MHz_u{40}) { m_bw = 1; } @@ -173,19 +173,19 @@ VhtPpdu::VhtSigHeader::GetChannelWidth() const { if (m_bw == 3) { - return 160; + return MHz_u{160}; } else if (m_bw == 2) { - return 80; + return MHz_u{80}; } else if (m_bw == 1) { - return 40; + return MHz_u{40}; } else { - return 20; + return MHz_u{20}; } } diff --git a/src/wifi/model/wifi-default-assoc-manager.cc b/src/wifi/model/wifi-default-assoc-manager.cc index 418515432..e05e3b6d1 100644 --- a/src/wifi/model/wifi-default-assoc-manager.cc +++ b/src/wifi/model/wifi-default-assoc-manager.cc @@ -206,10 +206,10 @@ WifiDefaultAssocManager::EndScanning() // switch this link to using the channel used by a reported AP (or its primary80 // in case the reported AP is using a 160 MHz and the non-AP MLD does not support // 160 MHz operations) - if (apChannel.GetTotalWidth() > 80 && + if (apChannel.GetTotalWidth() > MHz_u{80} && !phy->GetDevice()->GetVhtConfiguration()->m_160MHzSupported) { - apChannel = apChannel.GetPrimaryChannel(80); + apChannel = apChannel.GetPrimaryChannel(MHz_u{80}); } NS_LOG_DEBUG("Switch link " << +linkId << " to using " << apChannel); diff --git a/src/wifi/model/wifi-default-protection-manager.cc b/src/wifi/model/wifi-default-protection-manager.cc index e3849e97a..a44b89c07 100644 --- a/src/wifi/model/wifi-default-protection-manager.cc +++ b/src/wifi/model/wifi-default-protection-manager.cc @@ -266,7 +266,7 @@ WifiDefaultProtectionManager::TryAddMpduToMuPpdu(Ptr mpdu, NS_ABORT_MSG_IF(m_mac->GetTypeOfStation() != AP, "HE APs only can send DL MU PPDUs"); auto modClass = txParams.m_txVector.GetModulationClass(); auto txWidth = modClass == WIFI_MOD_CLASS_DSSS || modClass == WIFI_MOD_CLASS_HR_DSSS - ? 20 + ? MHz_u{20} : txParams.m_txVector.GetChannelWidth(); if (protection != nullptr) diff --git a/src/wifi/model/wifi-mac.cc b/src/wifi/model/wifi-mac.cc index dadb5c26c..0e709ba4a 100644 --- a/src/wifi/model/wifi-mac.cc +++ b/src/wifi/model/wifi-mac.cc @@ -2223,9 +2223,10 @@ WifiMac::GetHtCapabilities(uint8_t linkId) const capabilities.SetRxMcsBitmask(mcs.GetMcsValue()); uint8_t nss = (mcs.GetMcsValue() / 8) + 1; NS_ASSERT(nss > 0 && nss < 5); - uint64_t dataRate = mcs.GetDataRate(htConfiguration->m_40MHzSupported ? 40 : 20, - NanoSeconds(sgiSupported ? 400 : 800), - nss); + uint64_t dataRate = + mcs.GetDataRate(htConfiguration->m_40MHzSupported ? MHz_u{40} : MHz_u{20}, + NanoSeconds(sgiSupported ? 400 : 800), + nss); if (dataRate > maxSupportedRate) { maxSupportedRate = dataRate; @@ -2299,7 +2300,7 @@ WifiMac::GetVhtCapabilities(uint8_t linkId) const capabilities.SetTxMcsMap(maxMcs, nss); } uint64_t maxSupportedRateLGI = 0; // in bit/s - MHz_u maxWidth = vhtConfiguration->m_160MHzSupported ? 160 : 80; + const auto maxWidth = vhtConfiguration->m_160MHzSupported ? MHz_u{160} : MHz_u{80}; for (const auto& mcs : phy->GetMcsList(WIFI_MOD_CLASS_VHT)) { if (!mcs.IsAllowed(maxWidth, 1)) diff --git a/src/wifi/model/wifi-phy-common.cc b/src/wifi/model/wifi-phy-common.cc index 12b341a4b..1703d2933 100644 --- a/src/wifi/model/wifi-phy-common.cc +++ b/src/wifi/model/wifi-phy-common.cc @@ -239,22 +239,23 @@ GetMaximumChannelWidth(WifiModulationClass modulation) { case WIFI_MOD_CLASS_DSSS: case WIFI_MOD_CLASS_HR_DSSS: - return 22; + return MHz_u{22}; case WIFI_MOD_CLASS_OFDM: case WIFI_MOD_CLASS_ERP_OFDM: - return 20; + return MHz_u{20}; case WIFI_MOD_CLASS_HT: - return 40; + return MHz_u{40}; // NOLINTBEGIN(bugprone-branch-clone) case WIFI_MOD_CLASS_VHT: case WIFI_MOD_CLASS_HE: - return 160; + return MHz_u{160}; case WIFI_MOD_CLASS_EHT: - return 160; // TODO update when 320 MHz channels are supported and remove clang-tidy guards + return MHz_u{ + 160}; // TODO update when 320 MHz channels are supported and remove clang-tidy guards // NOLINTEND(bugprone-branch-clone) default: NS_ABORT_MSG("Unknown modulation class: " << modulation); - return 0; + return MHz_u{0}; } } @@ -264,27 +265,27 @@ GetChannelWidthInMhz(WifiChannelWidthType width) switch (width) { case WifiChannelWidthType::UNKNOWN: - return 0; + return MHz_u{0}; case WifiChannelWidthType::CW_20MHZ: - return 20; + return MHz_u{20}; case WifiChannelWidthType::CW_22MHZ: - return 22; + return MHz_u{22}; case WifiChannelWidthType::CW_5MHZ: - return 5; + return MHz_u{5}; case WifiChannelWidthType::CW_10MHZ: - return 10; + return MHz_u{10}; case WifiChannelWidthType::CW_40MHZ: - return 40; + return MHz_u{40}; case WifiChannelWidthType::CW_80MHZ: - return 80; + return MHz_u{80}; case WifiChannelWidthType::CW_160MHZ: case WifiChannelWidthType::CW_80_PLUS_80MHZ: - return 160; + return MHz_u{160}; case WifiChannelWidthType::CW_2160MHZ: - return 2160; + return MHz_u{2160}; default: NS_FATAL_ERROR("Unknown wifi channel width type " << width); - return 0; + return MHz_u{0}; } } diff --git a/src/wifi/model/wifi-phy-operating-channel.cc b/src/wifi/model/wifi-phy-operating-channel.cc index df9394e55..168e9070c 100644 --- a/src/wifi/model/wifi-phy-operating-channel.cc +++ b/src/wifi/model/wifi-phy-operating-channel.cc @@ -27,237 +27,237 @@ NS_LOG_COMPONENT_DEFINE("WifiPhyOperatingChannel"); const std::set WifiPhyOperatingChannel::m_frequencyChannels = {{ // 2.4 GHz channels // 802.11b uses width of 22, while OFDM modes use width of 20 - {1, 2412, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, - {1, 2412, 20, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {2, 2417, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, - {2, 2417, 20, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {3, 2422, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, - {3, 2422, 20, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {4, 2427, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, - {4, 2427, 20, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {5, 2432, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, - {5, 2432, 20, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {6, 2437, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, - {6, 2437, 20, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {7, 2442, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, - {7, 2442, 20, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {8, 2447, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, - {8, 2447, 20, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {9, 2452, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, - {9, 2452, 20, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {10, 2457, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, - {10, 2457, 20, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {11, 2462, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, - {11, 2462, 20, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {12, 2467, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, - {12, 2467, 20, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {13, 2472, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, - {13, 2472, 20, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {1, MHz_u{2412}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {1, MHz_u{2412}, MHz_u{20}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {2, MHz_u{2417}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {2, MHz_u{2417}, MHz_u{20}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {3, MHz_u{2422}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {3, MHz_u{2422}, MHz_u{20}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {4, MHz_u{2427}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {4, MHz_u{2427}, MHz_u{20}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {5, MHz_u{2432}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {5, MHz_u{2432}, MHz_u{20}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {6, MHz_u{2437}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {6, MHz_u{2437}, MHz_u{20}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {7, MHz_u{2442}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {7, MHz_u{2442}, MHz_u{20}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {8, MHz_u{2447}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {8, MHz_u{2447}, MHz_u{20}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {9, MHz_u{2452}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {9, MHz_u{2452}, MHz_u{20}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {10, MHz_u{2457}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {10, MHz_u{2457}, MHz_u{20}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {11, MHz_u{2462}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {11, MHz_u{2462}, MHz_u{20}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {12, MHz_u{2467}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {12, MHz_u{2467}, MHz_u{20}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {13, MHz_u{2472}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {13, MHz_u{2472}, MHz_u{20}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, // Only defined for 802.11b - {14, 2484, 22, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, + {14, MHz_u{2484}, MHz_u{22}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::DSSS}, // 40 MHz channels - {3, 2422, 40, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {4, 2427, 40, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {5, 2432, 40, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {6, 2437, 40, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {7, 2442, 40, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {8, 2447, 40, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {9, 2452, 40, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {10, 2457, 40, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, - {11, 2462, 40, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {3, MHz_u{2422}, MHz_u{40}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {4, MHz_u{2427}, MHz_u{40}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {5, MHz_u{2432}, MHz_u{40}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {6, MHz_u{2437}, MHz_u{40}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {7, MHz_u{2442}, MHz_u{40}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {8, MHz_u{2447}, MHz_u{40}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {9, MHz_u{2452}, MHz_u{40}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {10, MHz_u{2457}, MHz_u{40}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, + {11, MHz_u{2462}, MHz_u{40}, WIFI_PHY_BAND_2_4GHZ, FrequencyChannelType::OFDM}, // Now the 5 GHz channels used for 802.11a/n/ac/ax/be // 20 MHz channels - {36, 5180, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {40, 5200, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {44, 5220, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {48, 5240, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {52, 5260, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {56, 5280, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {60, 5300, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {64, 5320, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {100, 5500, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {104, 5520, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {108, 5540, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {112, 5560, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {116, 5580, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {120, 5600, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {124, 5620, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {128, 5640, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {132, 5660, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {136, 5680, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {140, 5700, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {144, 5720, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {149, 5745, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {153, 5765, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {157, 5785, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {161, 5805, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {165, 5825, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {169, 5845, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {173, 5865, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {177, 5885, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {181, 5905, 20, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {36, MHz_u{5180}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {40, MHz_u{5200}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {44, MHz_u{5220}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {48, MHz_u{5240}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {52, MHz_u{5260}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {56, MHz_u{5280}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {60, MHz_u{5300}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {64, MHz_u{5320}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {100, MHz_u{5500}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {104, MHz_u{5520}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {108, MHz_u{5540}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {112, MHz_u{5560}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {116, MHz_u{5580}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {120, MHz_u{5600}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {124, MHz_u{5620}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {128, MHz_u{5640}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {132, MHz_u{5660}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {136, MHz_u{5680}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {140, MHz_u{5700}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {144, MHz_u{5720}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {149, MHz_u{5745}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {153, MHz_u{5765}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {157, MHz_u{5785}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {161, MHz_u{5805}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {165, MHz_u{5825}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {169, MHz_u{5845}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {173, MHz_u{5865}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {177, MHz_u{5885}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {181, MHz_u{5905}, MHz_u{20}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, // 40 MHz channels - {38, 5190, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {46, 5230, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {54, 5270, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {62, 5310, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {102, 5510, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {110, 5550, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {118, 5590, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {126, 5630, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {134, 5670, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {142, 5710, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {151, 5755, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {159, 5795, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {167, 5835, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {175, 5875, 40, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {38, MHz_u{5190}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {46, MHz_u{5230}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {54, MHz_u{5270}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {62, MHz_u{5310}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {102, MHz_u{5510}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {110, MHz_u{5550}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {118, MHz_u{5590}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {126, MHz_u{5630}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {134, MHz_u{5670}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {142, MHz_u{5710}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {151, MHz_u{5755}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {159, MHz_u{5795}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {167, MHz_u{5835}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {175, MHz_u{5875}, MHz_u{40}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, // 80 MHz channels - {42, 5210, 80, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {58, 5290, 80, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {106, 5530, 80, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {122, 5610, 80, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {138, 5690, 80, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {155, 5775, 80, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {171, 5855, 80, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {42, MHz_u{5210}, MHz_u{80}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {58, MHz_u{5290}, MHz_u{80}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {106, MHz_u{5530}, MHz_u{80}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {122, MHz_u{5610}, MHz_u{80}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {138, MHz_u{5690}, MHz_u{80}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {155, MHz_u{5775}, MHz_u{80}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {171, MHz_u{5855}, MHz_u{80}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, // 160 MHz channels - {50, 5250, 160, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {114, 5570, 160, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, - {163, 5815, 160, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {50, MHz_u{5250}, MHz_u{160}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {114, MHz_u{5570}, MHz_u{160}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, + {163, MHz_u{5815}, MHz_u{160}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::OFDM}, // 802.11p 10 MHz channels at the 5.855-5.925 band - {172, 5860, 10, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, - {174, 5870, 10, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, - {176, 5880, 10, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, - {178, 5890, 10, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, - {180, 5900, 10, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, - {182, 5910, 10, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, - {184, 5920, 10, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {172, MHz_u{5860}, MHz_u{10}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {174, MHz_u{5870}, MHz_u{10}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {176, MHz_u{5880}, MHz_u{10}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {178, MHz_u{5890}, MHz_u{10}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {180, MHz_u{5900}, MHz_u{10}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {182, MHz_u{5910}, MHz_u{10}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {184, MHz_u{5920}, MHz_u{10}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, // 802.11p 5 MHz channels at the 5.855-5.925 band (for simplification, we consider the same // center frequencies as the 10 MHz channels) - {171, 5860, 5, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, - {173, 5870, 5, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, - {175, 5880, 5, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, - {177, 5890, 5, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, - {179, 5900, 5, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, - {181, 5910, 5, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, - {183, 5920, 5, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {171, MHz_u{5860}, MHz_u{5}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {173, MHz_u{5870}, MHz_u{5}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {175, MHz_u{5880}, MHz_u{5}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {177, MHz_u{5890}, MHz_u{5}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {179, MHz_u{5900}, MHz_u{5}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {181, MHz_u{5910}, MHz_u{5}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, + {183, MHz_u{5920}, MHz_u{5}, WIFI_PHY_BAND_5GHZ, FrequencyChannelType::CH_80211P}, // Now the 6 GHz channels for 802.11ax/be // 20 MHz channels - {1, 5955, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {5, 5975, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {9, 5995, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {13, 6015, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {17, 6035, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {21, 6055, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {25, 6075, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {29, 6095, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {33, 6115, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {37, 6135, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {41, 6155, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {45, 6175, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {49, 6195, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {53, 6215, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {57, 6235, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {61, 6255, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {65, 6275, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {69, 6295, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {73, 6315, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {77, 6335, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {81, 6355, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {85, 6375, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {89, 6395, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {93, 6415, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {97, 6435, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {101, 6455, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {105, 6475, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {109, 6495, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {113, 6515, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {117, 6535, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {121, 6555, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {125, 6575, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {129, 6595, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {133, 6615, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {137, 6635, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {141, 6655, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {145, 6675, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {149, 6695, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {153, 6715, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {157, 6735, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {161, 6755, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {165, 6775, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {169, 6795, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {173, 6815, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {177, 6835, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {181, 6855, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {185, 6875, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {189, 6895, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {193, 6915, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {197, 6935, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {201, 6955, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {205, 6975, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {209, 6995, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {213, 7015, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {217, 7035, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {221, 7055, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {225, 7075, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {229, 7095, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {233, 7115, 20, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {1, MHz_u{5955}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {5, MHz_u{5975}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {9, MHz_u{5995}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {13, MHz_u{6015}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {17, MHz_u{6035}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {21, MHz_u{6055}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {25, MHz_u{6075}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {29, MHz_u{6095}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {33, MHz_u{6115}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {37, MHz_u{6135}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {41, MHz_u{6155}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {45, MHz_u{6175}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {49, MHz_u{6195}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {53, MHz_u{6215}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {57, MHz_u{6235}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {61, MHz_u{6255}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {65, MHz_u{6275}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {69, MHz_u{6295}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {73, MHz_u{6315}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {77, MHz_u{6335}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {81, MHz_u{6355}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {85, MHz_u{6375}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {89, MHz_u{6395}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {93, MHz_u{6415}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {97, MHz_u{6435}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {101, MHz_u{6455}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {105, MHz_u{6475}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {109, MHz_u{6495}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {113, MHz_u{6515}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {117, MHz_u{6535}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {121, MHz_u{6555}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {125, MHz_u{6575}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {129, MHz_u{6595}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {133, MHz_u{6615}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {137, MHz_u{6635}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {141, MHz_u{6655}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {145, MHz_u{6675}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {149, MHz_u{6695}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {153, MHz_u{6715}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {157, MHz_u{6735}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {161, MHz_u{6755}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {165, MHz_u{6775}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {169, MHz_u{6795}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {173, MHz_u{6815}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {177, MHz_u{6835}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {181, MHz_u{6855}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {185, MHz_u{6875}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {189, MHz_u{6895}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {193, MHz_u{6915}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {197, MHz_u{6935}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {201, MHz_u{6955}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {205, MHz_u{6975}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {209, MHz_u{6995}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {213, MHz_u{7015}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {217, MHz_u{7035}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {221, MHz_u{7055}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {225, MHz_u{7075}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {229, MHz_u{7095}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {233, MHz_u{7115}, MHz_u{20}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, // 40 MHz channels - {3, 5965, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {11, 6005, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {19, 6045, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {27, 6085, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {35, 6125, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {43, 6165, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {51, 6205, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {59, 6245, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {67, 6285, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {75, 6325, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {83, 6365, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {91, 6405, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {99, 6445, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {107, 6485, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {115, 6525, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {123, 6565, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {131, 6605, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {139, 6645, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {147, 6685, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {155, 6725, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {163, 6765, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {171, 6805, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {179, 6845, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {187, 6885, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {195, 6925, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {203, 6965, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {211, 7005, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {219, 7045, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {227, 7085, 40, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {3, MHz_u{5965}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {11, MHz_u{6005}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {19, MHz_u{6045}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {27, MHz_u{6085}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {35, MHz_u{6125}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {43, MHz_u{6165}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {51, MHz_u{6205}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {59, MHz_u{6245}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {67, MHz_u{6285}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {75, MHz_u{6325}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {83, MHz_u{6365}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {91, MHz_u{6405}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {99, MHz_u{6445}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {107, MHz_u{6485}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {115, MHz_u{6525}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {123, MHz_u{6565}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {131, MHz_u{6605}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {139, MHz_u{6645}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {147, MHz_u{6685}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {155, MHz_u{6725}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {163, MHz_u{6765}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {171, MHz_u{6805}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {179, MHz_u{6845}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {187, MHz_u{6885}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {195, MHz_u{6925}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {203, MHz_u{6965}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {211, MHz_u{7005}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {219, MHz_u{7045}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {227, MHz_u{7085}, MHz_u{40}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, // 80 MHz channels - {7, 5985, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {23, 6065, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {39, 6145, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {55, 6225, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {71, 6305, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {87, 6385, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {103, 6465, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {119, 6545, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {135, 6625, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {151, 6705, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {167, 6785, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {183, 6865, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {199, 6945, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {215, 7025, 80, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {7, MHz_u{5985}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {23, MHz_u{6065}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {39, MHz_u{6145}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {55, MHz_u{6225}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {71, MHz_u{6305}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {87, MHz_u{6385}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {103, MHz_u{6465}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {119, MHz_u{6545}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {135, MHz_u{6625}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {151, MHz_u{6705}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {167, MHz_u{6785}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {183, MHz_u{6865}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {199, MHz_u{6945}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {215, MHz_u{7025}, MHz_u{80}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, // 160 MHz channels - {15, 6025, 160, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {47, 6185, 160, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {79, 6345, 160, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {111, 6505, 160, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {143, 6665, 160, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {175, 6825, 160, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, - {207, 6985, 160, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {15, MHz_u{6025}, MHz_u{160}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {47, MHz_u{6185}, MHz_u{160}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {79, MHz_u{6345}, MHz_u{160}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {111, MHz_u{6505}, MHz_u{160}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {143, MHz_u{6665}, MHz_u{160}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {175, MHz_u{6825}, MHz_u{160}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, + {207, MHz_u{6985}, MHz_u{160}, WIFI_PHY_BAND_6GHZ, FrequencyChannelType::OFDM}, }}; std::ostream& @@ -370,7 +370,7 @@ WifiPhyOperatingChannel::Set(const std::vector& segments, if ((channelIts.size() > 2) || ((channelIts.size() == 2) && !std::all_of(channelIts.cbegin(), channelIts.cend(), [](const auto& channel) { - return channel->width == 80; + return channel->width == MHz_u{80}; }))) { throw std::runtime_error("WifiPhyOperatingChannel is invalid: only 80+80MHz is " @@ -385,7 +385,7 @@ void WifiPhyOperatingChannel::SetDefault(MHz_u width, WifiStandard standard, WifiPhyBand band) { NS_LOG_FUNCTION(this << width << standard << band); - Set({{GetDefaultChannelNumber(width, standard, band), 0, width, band}}, standard); + Set({{GetDefaultChannelNumber(width, standard, band), MHz_u{0}, width, band}}, standard); } uint8_t @@ -399,13 +399,14 @@ WifiPhyOperatingChannel::GetDefaultChannelNumber( auto prevSegmentChannelIt = m_frequencyChannels.end(); if (previousChannelNumber) { - prevSegmentChannelIt = FindFirst(*previousChannelNumber, 0, width, standard, band, start); + prevSegmentChannelIt = + FindFirst(*previousChannelNumber, MHz_u{0}, width, standard, band, start); if (prevSegmentChannelIt != m_frequencyChannels.end()) { start = std::next(prevSegmentChannelIt); } } - auto channelIt = FindFirst(0, 0, width, standard, band, start); + auto channelIt = FindFirst(0, MHz_u{0}, width, standard, band, start); if (prevSegmentChannelIt != m_frequencyChannels.end() && channelIt != m_frequencyChannels.end()) { const auto prevFreq = prevSegmentChannelIt->frequency; @@ -418,7 +419,7 @@ WifiPhyOperatingChannel::GetDefaultChannelNumber( { // segments are contiguous to each others, find next segment to make sure they are // not contiguous - channelIt = FindFirst(0, 0, width, standard, band, std::next(channelIt)); + channelIt = FindFirst(0, MHz_u{0}, width, standard, band, std::next(channelIt)); } } if (channelIt != m_frequencyChannels.end()) @@ -446,11 +447,11 @@ WifiPhyOperatingChannel::FindFirst(uint8_t number, { return false; } - if (frequency != 0 && channel.frequency != frequency) + if (frequency != MHz_u{0} && channel.frequency != frequency) { return false; } - if (width != 0 && channel.width != width) + if (width != MHz_u{0} && channel.width != width) { return false; } @@ -574,7 +575,7 @@ WifiPhyOperatingChannel::GetTotalWidth() const NS_ASSERT(IsSet()); return std::accumulate(m_channelIts.cbegin(), m_channelIts.cend(), - 0, + MHz_u{0}, [](MHz_u sum, const auto& channel) { return sum + channel->width; }); } @@ -777,7 +778,7 @@ std::set WifiPhyOperatingChannel::GetAll20MHzChannelIndicesInSecondary( const std::set& primaryIndices) const { - if (primaryIndices.empty() || GetTotalWidth() == 20) + if (primaryIndices.empty() || GetTotalWidth() == MHz_u{20}) { return {}; } @@ -828,12 +829,12 @@ WifiPhyOperatingChannel::Get20MHzIndicesCoveringRu(HeRu::RuSpec ru, MHz_u width) // handle first the special case of center 26-tone RUs if (ruType == HeRu::RU_26_TONE && ru.GetIndex() == 19) { - NS_ASSERT_MSG(width >= 80, + NS_ASSERT_MSG(width >= MHz_u{80}, "26-tone RU with index 19 is only present in channels of at least 80 MHz"); // the center 26-tone RU in an 80 MHz channel is not fully covered by // any 20 MHz channel, but by the two central 20 MHz channels in the 80 MHz channel - auto indices = ru.GetPrimary80MHz() ? GetAll20MHzChannelIndicesInPrimary(80) - : GetAll20MHzChannelIndicesInSecondary(80); + auto indices = ru.GetPrimary80MHz() ? GetAll20MHzChannelIndicesInPrimary(MHz_u{80}) + : GetAll20MHzChannelIndicesInSecondary(MHz_u{80}); indices.erase(indices.begin()); indices.erase(std::prev(indices.end())); return indices; @@ -849,12 +850,12 @@ WifiPhyOperatingChannel::Get20MHzIndicesCoveringRu(HeRu::RuSpec ru, MHz_u width) // if the RU refers to a 160 MHz channel, we have to update the RU index (which // refers to an 80 MHz channel) if the RU is not in the lower 80 MHz channel - if (width == 160) + if (width == MHz_u{160}) { bool primary80IsLower80 = (m_primary20Index < 4); if (primary80IsLower80 != ru.GetPrimary80MHz()) { - auto nRusIn80MHz = HeRu::GetNRus(80, ruType); + auto nRusIn80MHz = HeRu::GetNRus(MHz_u{80}, ruType); // "ignore" the center 26-tone RU in an 80 MHz channel if (ruType == HeRu::RU_26_TONE) { @@ -884,7 +885,7 @@ WifiPhyOperatingChannel::Get20MHzIndicesCoveringRu(HeRu::RuSpec ru, MHz_u width) NS_ABORT_MSG("Unhandled RU type: " << ruType); } - auto nRusInCoveringChannel = HeRu::GetNRus(n20MHzChannels * 20, ruType); + auto nRusInCoveringChannel = HeRu::GetNRus(n20MHzChannels * MHz_u{20}, ruType); // compute the index (starting at 0) of the covering channel within the given width std::size_t indexOfCoveringChannelInGivenWidth = (ruIndex - 1) / nRusInCoveringChannel; @@ -955,7 +956,7 @@ operator<<(std::ostream& os, const WifiPhyOperatingChannel& channel) << " width " << channel.GetWidth() << " band " << channel.GetPhyBand(); if ((segmentId == 0) && (static_cast(channel.GetTotalWidth()) % 20 == 0)) { - os << " primary20 " << +channel.GetPrimaryChannelIndex(20); + os << " primary20 " << +channel.GetPrimaryChannelIndex(MHz_u{20}); } if (segmentId < numSegments - 1) { diff --git a/src/wifi/model/wifi-phy-state-helper.cc b/src/wifi/model/wifi-phy-state-helper.cc index 493d4b085..86038a329 100644 --- a/src/wifi/model/wifi-phy-state-helper.cc +++ b/src/wifi/model/wifi-phy-state-helper.cc @@ -578,7 +578,7 @@ WifiPhyStateHelper::SwitchFromRxAbort(MHz_u operatingWidth) DoSwitchFromRx(); m_endCcaBusy = Simulator::Now(); std::vector