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