22 #include "ns3/abort.h" 168 return (bw == 160 ? 2 : 1) * it->second.size ();
176 NS_ABORT_MSG_IF (bw != 160,
"2x996 tone RU can only be used on 160 MHz band");
177 return {{-1012, -3}, {3, 1012}};
183 std::size_t indexInPrimary80MHz = index;
184 std::size_t numRus =
GetNRus (bw, ruType);
185 int16_t shift = (bw == 160) ? -512 : 0;
186 if (bw == 160 && index > (numRus / 2))
189 indexInPrimary80MHz = index - (numRus / 2);
196 NS_ABORT_MSG_IF (!indexInPrimary80MHz || indexInPrimary80MHz > it->second.size (),
"RU index not available");
201 for (
auto & range : group)
203 range.first += shift;
204 range.second += shift;
214 HeRu::DoesOverlap (uint8_t bw, RuSpec ru,
const std::vector<RuSpec> &v)
225 if (ru.primary80MHz != p.primary80MHz)
230 if (DoesOverlap (bw, p, groups))
239 HeRu::DoesOverlap (uint8_t bw, RuSpec ru,
const SubcarrierGroup &toneRanges)
241 for (
const auto & range : toneRanges)
249 for (
auto& r : rangesRu)
251 if (range.second >= r.first && r.second >= range.first)
294 os <<
"RU{" << ru.
ruType <<
"/" << ru.
index <<
"/" << (ru.
primary80MHz ?
"primary80MHz" :
"secondary80MHz") <<
"}";
327 uint8_t nRusAssigned = 0;
332 if (ru.first.first == bandwidth && ru.second.size () <= nStations)
334 ruType = ru.first.second;
335 nRusAssigned = ru.second.size ();
338 else if (bandwidth == 160 && ru.first.first == 80 && (2 * ru.second.size () <= nStations))
340 ruType = ru.first.second;
341 nRusAssigned = 2 * ru.second.size ();
345 if (nRusAssigned == 0)
352 nStations = nRusAssigned;
std::vector< SubcarrierRange > SubcarrierGroup
a vector of subcarrier ranges defining a subcarrier group
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
bool primary80MHz
true if the RU is allocated in the primary 80MHz channel
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
std::map< BwTonesPair, std::vector< SubcarrierGroup > > SubcarrierGroups
map (bandwidth, number of tones) pairs to the group of subcarrier ranges
static uint16_t GetBandwidth(RuType ruType)
Get the approximate bandwidth occupied by a RU.
static const SubcarrierGroups m_heRuSubcarrierGroups
static RuType GetEqualSizedRusForStations(uint16_t bandwidth, std::size_t &nStations)
Given the channel bandwidth and the number of stations candidate for being assigned an RU...
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Every class exported by the ns3 library is enclosed in the ns3 namespace.
RuType
The different HE Resource Unit (RU) types.
static SubcarrierGroup GetSubcarrierGroup(uint8_t bw, RuType ruType, std::size_t index)
Get the subcarrier group of the RU having the given index among all the RUs of the given type (number...
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
std::size_t index
index (starting at 1)
static std::size_t GetNRus(uint8_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...