A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
he-ru.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
9#ifndef HE_RU_H
10#define HE_RU_H
11
12#include "ns3/wifi-phy-common.h"
13
14#include <cstdint>
15#include <map>
16#include <ostream>
17#include <vector>
18
19namespace ns3
20{
21
22/**
23 * This class stores the subcarrier groups of all the available HE RUs.
24 */
25class HeRu
26{
27 public:
28 /**
29 * The different HE Resource Unit (RU) types.
30 */
41
42 /// (lowest index, highest index) pair defining a subcarrier range
43 typedef std::pair<int16_t, int16_t> SubcarrierRange;
44
45 /// a vector of subcarrier ranges defining a subcarrier group
46 typedef std::vector<SubcarrierRange> SubcarrierGroup;
47
48 /**
49 * RU Specification. Stores the information carried by the RU Allocation subfield
50 * of the User Info field of Trigger frames (see 9.3.1.22.1 of 802.11ax D8.0).
51 * Note that primary80MHz must be true if ruType is RU_2x996_TONE.
52 * Internally, this class also stores the RU PHY index (ranging from 1 to the number
53 * of RUs of the given type in a channel of the considered width), so that this class
54 * contains all the information needed to locate the RU in a 160 MHz channel.
55 */
56 class RuSpec
57 {
58 public:
59 /**
60 * Default constructor
61 */
62 RuSpec();
63 /**
64 * Constructor
65 *
66 * \param ruType the RU type
67 * \param index the RU index (starting at 1)
68 * \param primary80MHz whether the RU is allocated in the primary 80MHz channel
69 */
70 RuSpec(RuType ruType, std::size_t index, bool primary80MHz);
71
72 /**
73 * Get the RU type
74 *
75 * \return the RU type
76 */
77 RuType GetRuType() const;
78 /**
79 * Get the RU index
80 *
81 * \return the RU index
82 */
83 std::size_t GetIndex() const;
84 /**
85 * Get the primary 80 MHz flag
86 *
87 * \return true if the RU is in the primary 80 MHz channel and false otherwise
88 */
89 bool GetPrimary80MHz() const;
90 /**
91 * Get the RU PHY index
92 *
93 * \param bw the width of the channel of which the RU is part
94 * \param p20Index the index of the primary20 channel
95 * \return the RU PHY index
96 */
97 std::size_t GetPhyIndex(MHz_u bw, uint8_t p20Index) const;
98
99 /**
100 * Compare this RU to the given RU.
101 *
102 * \param other the given RU
103 * \return true if this RU compares equal to the given RU, false otherwise
104 */
105 bool operator==(const RuSpec& other) const;
106 /**
107 * Compare this RU to the given RU.
108 *
109 * \param other the given RU
110 * \return true if this RU differs from the given RU, false otherwise
111 */
112 bool operator!=(const RuSpec& other) const;
113 /**
114 * Compare this RU to the given RU.
115 *
116 * \param other the given RU
117 * \return true if this RU is smaller than the given RU, false otherwise
118 */
119 bool operator<(const RuSpec& other) const;
120
121 private:
122 RuType m_ruType; //!< RU type
123 std::size_t m_index; /**< RU index (starting at 1) as defined by Tables 27-7
124 to 27-9 of 802.11ax D8.0 */
125 bool m_primary80MHz; //!< true if the RU is allocated in the primary 80MHz channel
126 };
127
128 /**
129 * Struct providing a function call operator to compare two RUs.
130 */
132 {
133 /**
134 * Constructor.
135 *
136 * \param channelWidth the channel width
137 * \param p20Index the index of the primary20 channel
138 */
139 RuSpecCompare(MHz_u channelWidth, uint8_t p20Index);
140 /**
141 * Function call operator.
142 *
143 * \param lhs left hand side RU
144 * \param rhs right hand side RU
145 * \return true if the left hand side RU has its leftmost tone at a lower
146 * frequency than the leftmost tone of the right hand side RU,
147 * false otherwise
148 */
149 bool operator()(const RuSpec& lhs, const RuSpec& rhs) const;
150
151 private:
152 MHz_u m_channelWidth; ///< The channel width
153 uint8_t m_p20Index; ///< Primary20 channel index
154 };
155
156 /**
157 * Get the number of distinct RUs of the given type (number of tones)
158 * available in a HE PPDU of the given bandwidth.
159 *
160 * \param bw the bandwidth of the HE PPDU (20, 40, 80, 160)
161 * \param ruType the RU type (number of tones)
162 * \return the number of distinct RUs available
163 */
164 static std::size_t GetNRus(MHz_u bw, RuType ruType);
165
166 /**
167 * Get the set of distinct RUs of the given type (number of tones)
168 * available in a HE PPDU of the given bandwidth.
169 *
170 * \param bw the bandwidth of the HE PPDU (20, 40, 80, 160)
171 * \param ruType the RU type (number of tones)
172 * \return the set of distinct RUs available
173 */
174 static std::vector<HeRu::RuSpec> GetRusOfType(MHz_u bw, HeRu::RuType ruType);
175
176 /**
177 * Get the set of 26-tone RUs that can be additionally allocated if the given
178 * bandwidth is split in RUs of the given type.
179 *
180 * \param bw the bandwidth of the HE PPDU (20, 40, 80, 160)
181 * \param ruType the RU type (number of tones)
182 * \return the set of 26-tone RUs that can be additionally allocated
183 */
184 static std::vector<HeRu::RuSpec> GetCentral26TonesRus(MHz_u bw, HeRu::RuType ruType);
185
186 /**
187 * Get the subcarrier group of the RU having the given PHY index among all the
188 * RUs of the given type (number of tones) available in a HE PPDU of the
189 * given bandwidth. A subcarrier group is defined as one or more pairs
190 * indicating the lowest frequency index and the highest frequency index.
191 * Note that for channel width of 160 MHz the returned range is relative to
192 * the 160 MHz channel (i.e. -1012 to 1012). The PHY index parameter is used to
193 * distinguish between lower and higher 80 MHz subchannels.
194 *
195 * \param bw the bandwidth of the HE PPDU (20, 40, 80, 160)
196 * \param ruType the RU type (number of tones)
197 * \param phyIndex the PHY index (starting at 1) of the RU
198 * \return the subcarrier range of the specified RU
199 */
200 static SubcarrierGroup GetSubcarrierGroup(MHz_u bw, RuType ruType, std::size_t phyIndex);
201
202 /**
203 * Check whether the given RU overlaps with the given set of RUs.
204 * Note that for channel width of 160 MHz the returned range is relative to
205 * the 160 MHz channel (i.e. -1012 to 1012).
206 *
207 * \param bw the bandwidth of the HE PPDU (20, 40, 80, 160)
208 * \param ru the given RU allocation
209 * \param v the given set of RUs
210 * \return true if the given RU overlaps with the given set of RUs.
211 */
212 static bool DoesOverlap(MHz_u bw, RuSpec ru, const std::vector<RuSpec>& v);
213
214 /**
215 * Check whether the given RU overlaps with the given tone ranges.
216 * Note that for channel width of 160 MHz the returned range is relative to
217 * the 160 MHz channel (i.e. -1012 to 1012).
218 *
219 * \param bw the bandwidth of the HE PPDU (20, 40, 80, 160)
220 * \param ru the given RU allocation
221 * \param toneRanges the given set of tone ranges
222 * \param p20Index the index of the primary20 channel
223 * \return true if the given RU overlaps with the given set of tone ranges.
224 */
225 static bool DoesOverlap(MHz_u bw,
226 RuSpec ru,
227 const SubcarrierGroup& toneRanges,
228 uint8_t p20Index);
229
230 /**
231 * Find the RU allocation of the given RU type overlapping the given
232 * reference RU allocation.
233 * Note that an assert is generated if the RU allocation is not found.
234 *
235 * \param bw the bandwidth of the HE PPDU (20, 40, 80, 160)
236 * \param referenceRu the reference RU allocation
237 * \param searchedRuType the searched RU type
238 * \return the searched RU allocation.
239 */
240 static RuSpec FindOverlappingRu(MHz_u bw, RuSpec referenceRu, RuType searchedRuType);
241
242 /**
243 * Get the approximate bandwidth occupied by a RU.
244 *
245 * \param ruType the RU type
246 * \return the approximate bandwidth occupied by the RU
247 */
248 static MHz_u GetBandwidth(RuType ruType);
249
250 /**
251 * Get the RU corresponding to the approximate bandwidth.
252 *
253 * \param bandwidth the approximate bandwidth occupied by the RU
254 * \return the RU type
255 */
256 static RuType GetRuType(MHz_u bandwidth);
257
258 /**
259 * Given the channel bandwidth and the number of stations candidate for being
260 * assigned an RU, maximize the number of candidate stations that can be assigned
261 * an RU subject to the constraint that all the stations must be assigned an RU
262 * of the same size (in terms of number of tones).
263 *
264 * \param bandwidth the channel bandwidth
265 * \param nStations the number of candidate stations. On return, it is set to
266 * the number of stations that are assigned an RU
267 * \param[out] nCentral26TonesRus the number of additional 26-tone RUs that can be
268 * allocated if the returned RU size is greater than 26 tones
269 * \return the RU type
270 */
272 std::size_t& nStations,
273 std::size_t& nCentral26TonesRus);
274
275 /// (bandwidth, number of tones) pair
276 typedef std::pair<MHz_u, RuType> BwTonesPair;
277
278 /// map (bandwidth, number of tones) pairs to the group of subcarrier ranges
279 typedef std::map<BwTonesPair, std::vector<SubcarrierGroup>> SubcarrierGroups;
280
281 /// Subcarrier groups for all RUs (with indices being applicable to primary 80 MHz channel)
283
284 /// RU allocation map
285 using RuAllocationMap = std::map<uint8_t, std::vector<RuSpec>>;
286
287 /// Table 27-26 of IEEE 802.11ax-2021
289
290 /// Get the RU specs based on RU_ALLOCATION
291 /// \param ruAllocation 8 bit RU_ALLOCATION value
292 /// \return RU spec associated with the RU_ALLOCATION
293 static std::vector<RuSpec> GetRuSpecs(uint8_t ruAllocation);
294
295 /// Get the RU_ALLOCATION value for equal size RUs
296 /// \param ruType equal size RU type (generated by GetEqualSizedRusForStations)
297 /// \param isOdd if number of stations is an odd number
298 /// \return RU_ALLOCATION value
299 static uint8_t GetEqualizedRuAllocation(RuType ruType, bool isOdd);
300
301 /// Empty 242-tone RU identifier
302 static constexpr uint8_t EMPTY_242_TONE_RU = 113;
303};
304
305/**
306 * \brief Stream insertion operator.
307 *
308 * \param os the stream
309 * \param ruType the RU type
310 * \returns a reference to the stream
311 */
312std::ostream& operator<<(std::ostream& os, const HeRu::RuType& ruType);
313
314/**
315 * \brief Stream insertion operator.
316 *
317 * \param os the stream
318 * \param ru the RU
319 * \returns a reference to the stream
320 */
321std::ostream& operator<<(std::ostream& os, const HeRu::RuSpec& ru);
322
323} // namespace ns3
324
325#endif /* HE_RU_H */
RU Specification.
Definition he-ru.h:57
std::size_t GetIndex() const
Get the RU index.
Definition he-ru.cc:454
std::size_t m_index
RU index (starting at 1) as defined by Tables 27-7 to 27-9 of 802.11ax D8.0.
Definition he-ru.h:123
RuType GetRuType() const
Get the RU type.
Definition he-ru.cc:447
bool operator<(const RuSpec &other) const
Compare this RU to the given RU.
Definition he-ru.cc:888
RuSpec()
Default constructor.
Definition he-ru.cc:433
bool m_primary80MHz
true if the RU is allocated in the primary 80MHz channel
Definition he-ru.h:125
std::size_t GetPhyIndex(MHz_u bw, uint8_t p20Index) const
Get the RU PHY index.
Definition he-ru.cc:468
RuType m_ruType
RU type.
Definition he-ru.h:122
bool operator==(const RuSpec &other) const
Compare this RU to the given RU.
Definition he-ru.cc:872
bool GetPrimary80MHz() const
Get the primary 80 MHz flag.
Definition he-ru.cc:461
bool operator!=(const RuSpec &other) const
Compare this RU to the given RU.
Definition he-ru.cc:882
This class stores the subcarrier groups of all the available HE RUs.
Definition he-ru.h:26
static std::vector< HeRu::RuSpec > GetCentral26TonesRus(MHz_u bw, HeRu::RuType ruType)
Get the set of 26-tone RUs that can be additionally allocated if the given bandwidth is split in RUs ...
Definition he-ru.cc:534
static std::vector< RuSpec > GetRuSpecs(uint8_t ruAllocation)
Get the RU specs based on RU_ALLOCATION.
Definition he-ru.cc:382
static bool DoesOverlap(MHz_u bw, RuSpec ru, const std::vector< RuSpec > &v)
Check whether the given RU overlaps with the given set of RUs.
Definition he-ru.cc:619
static MHz_u GetBandwidth(RuType ruType)
Get the approximate bandwidth occupied by a RU.
Definition he-ru.cc:756
std::map< uint8_t, std::vector< RuSpec > > RuAllocationMap
RU allocation map.
Definition he-ru.h:285
static RuType GetRuType(MHz_u bandwidth)
Get the RU corresponding to the approximate bandwidth.
Definition he-ru.cc:781
static constexpr uint8_t EMPTY_242_TONE_RU
Empty 242-tone RU identifier.
Definition he-ru.h:302
std::pair< MHz_u, RuType > BwTonesPair
(bandwidth, number of tones) pair
Definition he-ru.h:276
static std::vector< HeRu::RuSpec > GetRusOfType(MHz_u 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...
Definition he-ru.cc:504
static RuType GetEqualSizedRusForStations(MHz_u bandwidth, std::size_t &nStations, std::size_t &nCentral26TonesRus)
Given the channel bandwidth and the number of stations candidate for being assigned an RU,...
Definition he-ru.cc:806
static SubcarrierGroup GetSubcarrierGroup(MHz_u 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...
Definition he-ru.cc:580
std::vector< SubcarrierRange > SubcarrierGroup
a vector of subcarrier ranges defining a subcarrier group
Definition he-ru.h:46
static RuSpec FindOverlappingRu(MHz_u bw, RuSpec referenceRu, RuType searchedRuType)
Find the RU allocation of the given RU type overlapping the given reference RU allocation.
Definition he-ru.cc:678
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
Definition he-ru.h:43
static const SubcarrierGroups m_heRuSubcarrierGroups
Subcarrier groups for all RUs (with indices being applicable to primary 80 MHz channel)
Definition he-ru.h:282
static uint8_t GetEqualizedRuAllocation(RuType ruType, bool isOdd)
Get the RU_ALLOCATION value for equal size RUs.
Definition he-ru.cc:414
static std::size_t GetNRus(MHz_u bw, RuType ruType)
Get the number of distinct RUs of the given type (number of tones) available in a HE PPDU of the give...
Definition he-ru.cc:484
RuType
The different HE Resource Unit (RU) types.
Definition he-ru.h:32
@ RU_26_TONE
Definition he-ru.h:33
@ RU_484_TONE
Definition he-ru.h:37
@ RU_996_TONE
Definition he-ru.h:38
@ RU_106_TONE
Definition he-ru.h:35
@ RU_52_TONE
Definition he-ru.h:34
@ RU_242_TONE
Definition he-ru.h:36
@ RU_2x996_TONE
Definition he-ru.h:39
static const RuAllocationMap m_heRuAllocations
Table 27-26 of IEEE 802.11ax-2021.
Definition he-ru.h:288
std::map< BwTonesPair, std::vector< SubcarrierGroup > > SubcarrierGroups
map (bandwidth, number of tones) pairs to the group of subcarrier ranges
Definition he-ru.h:279
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148
Struct providing a function call operator to compare two RUs.
Definition he-ru.h:132
MHz_u m_channelWidth
The channel width.
Definition he-ru.h:152
RuSpecCompare(MHz_u channelWidth, uint8_t p20Index)
Constructor.
Definition he-ru.cc:363
uint8_t m_p20Index
Primary20 channel index.
Definition he-ru.h:153
bool operator()(const RuSpec &lhs, const RuSpec &rhs) const
Function call operator.
Definition he-ru.cc:370