From 754a7533b1ac293cd75635936017e68ff5ec92ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Thu, 16 Jan 2025 10:03:52 +0100 Subject: [PATCH] wifi: Cleanup unused and minor improvements in HeRu --- src/wifi/model/he/he-ru.cc | 59 ++++++++++++++------------------------ src/wifi/model/he/he-ru.h | 47 ++++++++++++++---------------- 2 files changed, 43 insertions(+), 63 deletions(-) diff --git a/src/wifi/model/he/he-ru.cc b/src/wifi/model/he/he-ru.cc index 788cb06ad..02af73450 100644 --- a/src/wifi/model/he/he-ru.cc +++ b/src/wifi/model/he/he-ru.cc @@ -17,8 +17,8 @@ namespace ns3 { -const HeRu::SubcarrierGroups HeRu::m_heRuSubcarrierGroups = { - // RUs in a 20 MHz HE PPDU (Table 28-6) +const HeRu::SubcarrierGroups HeRu::m_heRuSubcarrierGroups{ + // RUs in a 20 MHz HE PPDU (Table 27-7 IEEE802.11ax-2021) {{MHz_u{20}, HeRu::RU_26_TONE}, {/* 1 */ {{-121, -96}}, /* 2 */ {{-95, -70}}, @@ -38,7 +38,7 @@ const HeRu::SubcarrierGroups HeRu::m_heRuSubcarrierGroups = { {/* 1 */ {{-122, -17}}, /* 2 */ {{17, 122}}}}, {{MHz_u{20}, HeRu::RU_242_TONE}, {/* 1 */ {{-122, -2}, {2, 122}}}}, - // RUs in a 40 MHz HE PPDU (Table 28-7) + // RUs in a 40 MHz HE PPDU (Table 27-8 IEEE802.11ax-2021) {{MHz_u{40}, HeRu::RU_26_TONE}, {/* 1 */ {{-243, -218}}, /* 2 */ {{-217, -192}}, @@ -76,7 +76,7 @@ const HeRu::SubcarrierGroups HeRu::m_heRuSubcarrierGroups = { {/* 1 */ {{-244, -3}}, /* 2 */ {{3, 244}}}}, {{MHz_u{40}, HeRu::RU_484_TONE}, {/* 1 */ {{-244, -3}, {3, 244}}}}, - // RUs in an 80 MHz HE PPDU (Table 28-8) + // RUs in an 80 MHz HE PPDU (Table 27-9 IEEE802.11ax-2021) {{MHz_u{80}, HeRu::RU_26_TONE}, {/* 1 */ {{-499, -474}}, /* 2 */ {{-473, -448}}, @@ -382,7 +382,7 @@ std::vector HeRu::GetRuSpecs(uint16_t ruAllocation) { std::optional idx; - if (((ruAllocation >= 0) && (ruAllocation <= 15)) || (ruAllocation == 112)) + if ((ruAllocation <= 15) || (ruAllocation == 112)) { idx = ruAllocation; } @@ -430,11 +430,6 @@ HeRu::GetEqualizedRuAllocation(RuType ruType, bool isOdd, bool hasUsers) } } -HeRu::RuSpec::RuSpec() - : m_index(0) // indicates undefined RU -{ -} - HeRu::RuSpec::RuSpec(RuType ruType, std::size_t index, bool primary80MHz) : m_ruType(ruType), m_index(index), @@ -469,8 +464,8 @@ HeRu::RuSpec::GetPhyIndex(MHz_u bw, uint8_t p20Index) const { bool primary80IsLower80 = (p20Index < bw / MHz_u{40}); - if (bw < MHz_u{160} || m_ruType == HeRu::RU_2x996_TONE || - (primary80IsLower80 && m_primary80MHz) || (!primary80IsLower80 && !m_primary80MHz)) + if (bw < MHz_u{160} || m_ruType == RU_2x996_TONE || (primary80IsLower80 && m_primary80MHz) || + (!primary80IsLower80 && !m_primary80MHz)) { return m_index; } @@ -503,7 +498,12 @@ HeRu::GetNRus(MHz_u bw, RuType ruType) std::vector HeRu::GetRusOfType(MHz_u bw, HeRu::RuType ruType) { - if (ruType == HeRu::RU_2x996_TONE) + if (GetNRus(bw, ruType) == 0) + { + return {}; + } + + if (ruType == RU_2x996_TONE) { NS_ASSERT(bw >= MHz_u{160}); return {{ruType, 1, true}}; @@ -657,29 +657,6 @@ HeRu::DoesOverlap(MHz_u bw, RuSpec ru, const std::vector& v) return false; } -bool -HeRu::DoesOverlap(MHz_u bw, RuSpec ru, const SubcarrierGroup& toneRanges, uint8_t p20Index) -{ - for (const auto& range : toneRanges) - { - if (bw == MHz_u{160} && ru.GetRuType() == RU_2x996_TONE) - { - return true; - } - - SubcarrierGroup rangesRu = - GetSubcarrierGroup(bw, ru.GetRuType(), ru.GetPhyIndex(bw, p20Index)); - for (auto& r : rangesRu) - { - if (range.second >= r.first && r.second >= range.first) - { - return true; - } - } - } - return false; -} - HeRu::RuSpec HeRu::FindOverlappingRu(MHz_u bw, RuSpec referenceRu, RuType searchedRuType) { @@ -841,7 +818,15 @@ HeRu::GetEqualSizedRusForStations(MHz_u bandwidth, } nStations = nRusAssigned; + nCentral26TonesRus = GetNumCentral26TonesRus(bandwidth, ruType); + return ruType; +} + +uint8_t +HeRu::GetNumCentral26TonesRus(MHz_u bandwidth, HeRu::RuType ruType) +{ + uint8_t nCentral26TonesRus{0}; switch (ruType) { case RU_52_TONE: @@ -872,7 +857,7 @@ HeRu::GetEqualSizedRusForStations(MHz_u bandwidth, nCentral26TonesRus *= 2; } - return ruType; + return nCentral26TonesRus; } bool diff --git a/src/wifi/model/he/he-ru.h b/src/wifi/model/he/he-ru.h index d73c7e389..5fada9904 100644 --- a/src/wifi/model/he/he-ru.h +++ b/src/wifi/model/he/he-ru.h @@ -41,10 +41,10 @@ class HeRu }; /// (lowest index, highest index) pair defining a subcarrier range - typedef std::pair SubcarrierRange; + using SubcarrierRange = std::pair; /// a vector of subcarrier ranges defining a subcarrier group - typedef std::vector SubcarrierGroup; + using SubcarrierGroup = std::vector; /** * RU Specification. Stores the information carried by the RU Allocation subfield @@ -60,7 +60,7 @@ class HeRu /** * Default constructor */ - RuSpec(); + RuSpec() = default; /** * Constructor * @@ -120,10 +120,10 @@ class HeRu bool operator<(const RuSpec& other) const; private: - RuType m_ruType; //!< RU type - std::size_t m_index; /**< RU index (starting at 1) as defined by Tables 27-7 + RuType m_ruType{}; //!< RU type + std::size_t m_index{}; /**< RU index (starting at 1) as defined by Tables 27-7 to 27-9 of 802.11ax D8.0 */ - bool m_primary80MHz; //!< true if the RU is allocated in the primary 80MHz channel + bool m_primary80MHz{}; //!< true if the RU is allocated in the primary 80MHz channel }; /** @@ -172,7 +172,7 @@ class HeRu * @param ruType the RU type (number of tones) * @return the set of distinct RUs available */ - static std::vector GetRusOfType(MHz_u bw, HeRu::RuType ruType); + static std::vector GetRusOfType(MHz_u bw, RuType ruType); /** * Get the set of 26-tone RUs that can be additionally allocated if the given @@ -182,7 +182,7 @@ class HeRu * @param ruType the RU type (number of tones) * @return the set of 26-tone RUs that can be additionally allocated */ - static std::vector GetCentral26TonesRus(MHz_u bw, HeRu::RuType ruType); + static std::vector GetCentral26TonesRus(MHz_u bw, RuType ruType); /** * Get the subcarrier group of the RU having the given PHY index among all the @@ -212,22 +212,6 @@ class HeRu */ static bool DoesOverlap(MHz_u bw, RuSpec ru, const std::vector& v); - /** - * Check whether the given RU overlaps with the given tone ranges. - * Note that for channel width of 160 MHz the returned range is relative to - * the 160 MHz channel (i.e. -1012 to 1012). - * - * @param bw the bandwidth of the HE PPDU (20, 40, 80, 160) - * @param ru the given RU allocation - * @param toneRanges the given set of tone ranges - * @param p20Index the index of the primary20 channel - * @return true if the given RU overlaps with the given set of tone ranges. - */ - static bool DoesOverlap(MHz_u bw, - RuSpec ru, - const SubcarrierGroup& toneRanges, - uint8_t p20Index); - /** * Find the RU allocation of the given RU type overlapping the given * reference RU allocation. @@ -274,10 +258,10 @@ class HeRu std::size_t& nCentral26TonesRus); /// (bandwidth, number of tones) pair - typedef std::pair BwTonesPair; + using BwTonesPair = std::pair; /// map (bandwidth, number of tones) pairs to the group of subcarrier ranges - typedef std::map> SubcarrierGroups; + using SubcarrierGroups = std::map>; /// Subcarrier groups for all RUs (with indices being applicable to primary 80 MHz channel) static const SubcarrierGroups m_heRuSubcarrierGroups; @@ -303,6 +287,17 @@ class HeRu /// Empty 242-tone RU identifier static constexpr uint8_t EMPTY_242_TONE_RU = 113; + + private: + /** + * Get the number of 26-tone RUs that can be allocated if returned RU size is greater than 26 + * tones. + * + * @param bw the bandwidth (MHz) of the HE PPDU (20, 40, 80, 160) + * @param ruType the RU type (number of tones) + * @return the number of 26-tone RUs that can be allocated + */ + static uint8_t GetNumCentral26TonesRus(MHz_u bw, RuType ruType); }; /**