23#include "ns3/assert.h" 
  109       {{-16, -4}, {4, 16}},
 
  374    : m_channelWidth(channelWidth),
 
  382    const auto lhsIndex = lhs.
GetPhyIndex(m_channelWidth, m_p20Index);
 
  383    const auto rhsIndex = rhs.
GetPhyIndex(m_channelWidth, m_p20Index);
 
  384    const auto lhsStartTone =
 
  386    const auto rhsStartTone =
 
  388    return lhsStartTone < rhsStartTone;
 
  391std::vector<HeRu::RuSpec>
 
  394    std::optional<std::size_t> idx;
 
  395    switch (ruAllocation)
 
  403        idx = ruAllocation & 0xF8;
 
  406        idx = ruAllocation & 0xF0;
 
  411        idx = ruAllocation & 0xC0;
 
  416    return idx.has_value() ? 
m_heRuAllocations.at(idx.value()) : std::vector<HeRu::RuSpec>{};
 
  427        return isOdd ? 15 : 112;
 
  429        return isOdd ? 128 : 96;
 
  447      m_primary80MHz(primary80MHz)
 
  470    return m_primary80MHz;
 
  476    bool primary80IsLower80 = (p20Index < bw / 40);
 
  478    if (bw < 160 || m_ruType == 
HeRu::RU_2x996_TONE || (primary80IsLower80 && m_primary80MHz) ||
 
  479        (!primary80IsLower80 && !m_primary80MHz))
 
  485        return m_index + 
GetNRus(bw, m_ruType) / 2;
 
  506    return (bw == 160 ? 2 : 1) * it->second.size();
 
  509std::vector<HeRu::RuSpec>
 
  515        return {{ruType, 1, 
true}};
 
  518    std::vector<HeRu::RuSpec> ret;
 
  519    std::vector<bool> primary80MHzSet{
true};
 
  523        primary80MHzSet.push_back(
false);
 
  527    for (
auto primary80MHz : primary80MHzSet)
 
  529        for (std::size_t ruIndex = 1;
 
  533            ret.emplace_back(ruType, ruIndex, primary80MHz);
 
  539std::vector<HeRu::RuSpec>
 
  542    std::vector<std::size_t> indices;
 
  548            indices.push_back(5);
 
  552            indices.insert(indices.end(), {5, 14});
 
  556            indices.insert(indices.end(), {5, 14, 19, 24, 33});
 
  563            indices.push_back(19);
 
  567    std::vector<HeRu::RuSpec> ret;
 
  568    std::vector<bool> primary80MHzSet{
true};
 
  572        primary80MHzSet.push_back(
false);
 
  575    for (
auto primary80MHz : primary80MHzSet)
 
  577        for (
const auto& index : indices)
 
  590        NS_ABORT_MSG_IF(bw != 160, 
"2x996 tone RU can only be used on 160 MHz band");
 
  591        return {{-1012, -3}, {3, 1012}};
 
  597    std::size_t indexInLower80MHz = phyIndex;
 
  598    std::size_t numRus = 
GetNRus(bw, ruType);
 
  599    int16_t shift = (bw == 160) ? -512 : 0;
 
  600    if (bw == 160 && phyIndex > (numRus / 2))
 
  603        indexInLower80MHz = phyIndex - (numRus / 2);
 
  610    NS_ABORT_MSG_IF(indexInLower80MHz > it->second.size(), 
"RU index not available");
 
  615        for (
auto& range : group)
 
  617            range.first += shift;
 
  618            range.second += shift;
 
  645        for (
const auto& rangeRu : rangesRu)
 
  648            for (
auto& rangeP : rangesP)
 
  650                if (rangeP.second >= rangeRu.first && rangeRu.second >= rangeP.first)
 
  663    for (
const auto& range : toneRanges)
 
  672        for (
auto& r : rangesRu)
 
  674            if (range.second >= r.first && r.second >= range.first)
 
  688    std::size_t numRusPer80Mhz;
 
  689    std::vector<bool> primary80MhzFlags;
 
  692        primary80MhzFlags.push_back(
true);
 
  693        primary80MhzFlags.push_back(
false);
 
  699        numRusPer80Mhz = numRus;
 
  702    for (
const auto primary80MHz : primary80MhzFlags)
 
  704        std::size_t index = 1;
 
  705        for (std::size_t indexPer80Mhz = 1; indexPer80Mhz <= numRusPer80Mhz;
 
  706             ++indexPer80Mhz, ++index)
 
  708            RuSpec searchedRu(searchedRuType, index, primary80MHz);
 
  715    NS_ABORT_MSG(
"The searched RU type " << searchedRuType << 
" was not found for bw=" << bw
 
  716                                         << 
" and referenceRu=" << referenceRu);
 
  813                                  std::size_t& nStations,
 
  814                                  std::size_t& nCentral26TonesRus)
 
  817    uint8_t nRusAssigned = 0;
 
  822        if (ru.first.first == bandwidth && ru.second.size() <= nStations)
 
  824            ruType = ru.first.second;
 
  825            nRusAssigned = ru.second.size();
 
  828        else if (bandwidth == 160 && ru.first.first == 80 && (2 * ru.second.size() <= nStations))
 
  830            ruType = ru.first.second;
 
  831            nRusAssigned = 2 * ru.second.size();
 
  835    if (nRusAssigned == 0)
 
  842    nStations = nRusAssigned;
 
  850            nCentral26TonesRus = 1;
 
  852        else if (bandwidth == 40)
 
  854            nCentral26TonesRus = 2;
 
  858            nCentral26TonesRus = 5;
 
  863        nCentral26TonesRus = (bandwidth >= 80 ? 1 : 0);
 
  866        nCentral26TonesRus = 0;
 
  869    if (bandwidth == 160)
 
  871        nCentral26TonesRus *= 2;
 
  890    return !(*
this == other);
 
std::size_t GetIndex() const
Get the RU index.
 
std::size_t m_index
RU index (starting at 1) as defined by Tables 27-7 to 27-9 of 802.11ax D8.0.
 
RuType GetRuType() const
Get the RU type.
 
RuSpec()
Default constructor.
 
bool m_primary80MHz
true if the RU is allocated in the primary 80MHz channel
 
std::size_t GetPhyIndex(uint16_t bw, uint8_t p20Index) const
Get the RU PHY index.
 
bool operator==(const RuSpec &other) const
Compare this RU to the given RU.
 
bool GetPrimary80MHz() const
Get the primary 80 MHz flag.
 
bool operator!=(const RuSpec &other) const
Compare this RU to the given RU.
 
static RuSpec FindOverlappingRu(uint16_t bw, RuSpec referenceRu, RuType searchedRuType)
Find the RU allocation of the given RU type overlapping the given reference RU allocation.
 
static bool DoesOverlap(uint16_t bw, RuSpec ru, const std::vector< RuSpec > &v)
Check whether the given RU overlaps with the given set of RUs.
 
static std::vector< RuSpec > GetRuSpecs(uint8_t ruAllocation)
Get the RU specs based on RU_ALLOCATION.
 
static uint16_t GetBandwidth(RuType ruType)
Get the approximate bandwidth occupied by a RU.
 
static SubcarrierGroup GetSubcarrierGroup(uint16_t bw, RuType ruType, std::size_t phyIndex)
Get the subcarrier group of the RU having the given PHY index among all the RUs of the given type (nu...
 
static std::size_t GetNRus(uint16_t bw, RuType ruType)
Get the number of distinct RUs of the given type (number of tones) available in a HE PPDU of the give...
 
static std::vector< HeRu::RuSpec > GetRusOfType(uint16_t bw, HeRu::RuType ruType)
Get the set of distinct RUs of the given type (number of tones) available in a HE PPDU of the given b...
 
std::vector< SubcarrierRange > SubcarrierGroup
a vector of subcarrier ranges defining a subcarrier group
 
std::map< uint8_t, std::vector< RuSpec > > RuAllocationMap
RU allocation map.
 
static std::vector< HeRu::RuSpec > GetCentral26TonesRus(uint16_t bw, HeRu::RuType ruType)
Get the set of 26-tone RUs that can be additionally allocated if the given bandwidth is split in RUs ...
 
static const SubcarrierGroups m_heRuSubcarrierGroups
Subcarrier groups for all RUs (with indices being applicable to primary 80 MHz channel)
 
static uint8_t GetEqualizedRuAllocation(RuType ruType, bool isOdd)
Get the RU_ALLOCATION value for equal size RUs.
 
RuType
The different HE Resource Unit (RU) types.
 
static RuType GetEqualSizedRusForStations(uint16_t bandwidth, std::size_t &nStations, std::size_t &nCentral26TonesRus)
Given the channel bandwidth and the number of stations candidate for being assigned an RU,...
 
static RuType GetRuType(uint16_t bandwidth)
Get the RU corresponding to the approximate bandwidth.
 
static const RuAllocationMap m_heRuAllocations
Table 27-26 of IEEE 802.11ax-2021.
 
std::map< BwTonesPair, std::vector< SubcarrierGroup > > SubcarrierGroups
map (bandwidth, number of tones) pairs to the group of subcarrier ranges
 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
 
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
 
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
 
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
 
Every class exported by the ns3 library is enclosed in the ns3 namespace.
 
std::ostream & operator<<(std::ostream &os, const Angles &a)
 
RuSpecCompare(uint16_t channelWidth, uint8_t p20Index)
Constructor.
 
bool operator()(const RuSpec &lhs, const RuSpec &rhs) const
Function call operator.