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 * RU Specification. Stores the information carried by the RU Allocation subfield
30 * of the User Info field of Trigger frames (see 9.3.1.22.1 of 802.11ax D8.0).
31 * Note that primary80MHz must be true if ruType is RU_2x996_TONE.
32 * Internally, this class also stores the RU PHY index (ranging from 1 to the number
33 * of RUs of the given type in a channel of the considered width), so that this class
34 * contains all the information needed to locate the RU in a 160 MHz channel.
35 */
36 class RuSpec
37 {
38 public:
39 /**
40 * Default constructor
41 */
42 RuSpec() = default;
43 /**
44 * Constructor
45 *
46 * @param ruType the RU type
47 * @param index the RU index (starting at 1)
48 * @param primary80MHz whether the RU is allocated in the primary 80MHz channel
49 */
50 RuSpec(RuType ruType, std::size_t index, bool primary80MHz);
51
52 /**
53 * Get the RU type
54 *
55 * @return the RU type
56 */
57 RuType GetRuType() const;
58 /**
59 * Get the RU index
60 *
61 * @return the RU index
62 */
63 std::size_t GetIndex() const;
64 /**
65 * Get the primary 80 MHz flag
66 *
67 * @return true if the RU is in the primary 80 MHz channel and false otherwise
68 */
69 bool GetPrimary80MHz() const;
70 /**
71 * Get the RU PHY index
72 *
73 * @param bw the width of the channel of which the RU is part
74 * @param p20Index the index of the primary20 channel
75 * @return the RU PHY index
76 */
77 std::size_t GetPhyIndex(MHz_u bw, uint8_t p20Index) const;
78
79 /**
80 * Compare this RU to the given RU.
81 *
82 * @param other the given RU
83 * @return true if this RU compares equal to the given RU, false otherwise
84 */
85 bool operator==(const RuSpec& other) const;
86 /**
87 * Compare this RU to the given RU.
88 *
89 * @param other the given RU
90 * @return true if this RU differs from the given RU, false otherwise
91 */
92 bool operator!=(const RuSpec& other) const;
93 /**
94 * Compare this RU to the given RU.
95 *
96 * @param other the given RU
97 * @return true if this RU is smaller than the given RU, false otherwise
98 */
99 bool operator<(const RuSpec& other) const;
100
101 private:
102 RuType m_ruType{}; //!< RU type
103 std::size_t m_index{}; /**< RU index (starting at 1) as defined by Tables 27-7
104 to 27-9 of 802.11ax D8.0 */
105 bool m_primary80MHz{}; //!< true if the RU is allocated in the primary 80MHz channel
106 };
107
108 /**
109 * Get the primary 80 MHz flag of a given RU transmitted in a PPDU.
110 * The flag identifies whether the RU is in the primary 80 MHz.
111 *
112 * @param bw the bandwidth of the PPDU (20, 40, 80, 160)
113 * @param ruType the RU type (number of tones)
114 * @param phyIndex the PHY index (starting at 1) of the RU
115 * @param p20Index the index of the primary20 channel
116 * @return the primary 80 MHz flag
117 */
118 static bool GetPrimary80MHzFlag(MHz_u bw,
119 RuType ruType,
120 std::size_t phyIndex,
121 uint8_t p20Index);
122
123 /**
124 * Get the index of a given RU transmitted in a PPDU within its 80 MHz segment.
125 *
126 * @param bw the bandwidth of the PPDU (20, 40, 80, 160)
127 * @param ruType the RU type (number of tones)
128 * @param phyIndex the PHY index (starting at 1) of the RU
129 * @return the index within the 80 MHz segment
130 */
131 static std::size_t GetIndexIn80MHzSegment(MHz_u bw, RuType ruType, std::size_t phyIndex);
132
133 /**
134 * Get the number of distinct RUs of the given type (number of tones)
135 * available in a HE PPDU of the given bandwidth.
136 *
137 * @param bw the bandwidth of the HE PPDU (20, 40, 80, 160)
138 * @param ruType the RU type (number of tones)
139 * @return the number of distinct RUs available
140 */
141 static std::size_t GetNRus(MHz_u bw, RuType ruType);
142
143 /**
144 * Get the set of distinct RUs of the given type (number of tones)
145 * available in a HE PPDU of the given bandwidth.
146 *
147 * @param bw the bandwidth of the HE PPDU (20, 40, 80, 160)
148 * @param ruType the RU type (number of tones)
149 * @return the set of distinct RUs available
150 */
151 static std::vector<RuSpec> GetRusOfType(MHz_u bw, RuType ruType);
152
153 /**
154 * Get the set of 26-tone RUs that can be additionally allocated if the given
155 * bandwidth is split in RUs of the given type.
156 *
157 * @param bw the bandwidth of the HE PPDU (20, 40, 80, 160)
158 * @param ruType the RU type (number of tones)
159 * @return the set of 26-tone RUs that can be additionally allocated
160 */
161 static std::vector<RuSpec> GetCentral26TonesRus(MHz_u bw, RuType ruType);
162
163 /**
164 * Get the subcarrier group of the RU having the given PHY index among all the
165 * RUs of the given type (number of tones) available in a HE PPDU of the
166 * given bandwidth. A subcarrier group is defined as one or more pairs
167 * indicating the lowest frequency index and the highest frequency index.
168 * Note that for channel width of 160 MHz the returned range is relative to
169 * the 160 MHz channel (i.e. -1012 to 1012). The PHY index parameter is used to
170 * distinguish between lower and higher 80 MHz subchannels.
171 *
172 * @param bw the bandwidth of the HE PPDU (20, 40, 80, 160)
173 * @param ruType the RU type (number of tones)
174 * @param phyIndex the PHY index (starting at 1) of the RU
175 * @return the subcarrier range of the specified RU
176 */
177 static SubcarrierGroup GetSubcarrierGroup(MHz_u bw, RuType ruType, std::size_t phyIndex);
178
179 /**
180 * Check whether the given RU overlaps with the given set of RUs.
181 * Note that for channel width of 160 MHz the returned range is relative to
182 * the 160 MHz channel (i.e. -1012 to 1012).
183 *
184 * @param bw the bandwidth of the HE PPDU (20, 40, 80, 160)
185 * @param ru the given RU allocation
186 * @param v the given set of RUs
187 * @return true if the given RU overlaps with the given set of RUs.
188 */
189 static bool DoesOverlap(MHz_u bw, RuSpec ru, const std::vector<RuSpec>& v);
190
191 /**
192 * Find the RU allocation of the given RU type overlapping the given
193 * reference RU allocation.
194 * Note that an assert is generated if the RU allocation is not found.
195 *
196 * @param bw the bandwidth of the HE PPDU (20, 40, 80, 160)
197 * @param referenceRu the reference RU allocation
198 * @param searchedRuType the searched RU type
199 * @return the searched RU allocation.
200 */
201 static RuSpec FindOverlappingRu(MHz_u bw, RuSpec referenceRu, RuType searchedRuType);
202
203 /**
204 * Given the channel bandwidth and the number of stations candidate for being
205 * assigned an RU, maximize the number of candidate stations that can be assigned
206 * an RU subject to the constraint that all the stations must be assigned an RU
207 * of the same size (in terms of number of tones).
208 *
209 * @param bandwidth the channel bandwidth
210 * @param nStations the number of candidate stations. On return, it is set to
211 * the number of stations that are assigned an RU
212 * \param[out] nCentral26TonesRus the number of additional 26-tone RUs that can be
213 * allocated if the returned RU size is greater than 26 tones
214 * @return the RU type
215 */
217 std::size_t& nStations,
218 std::size_t& nCentral26TonesRus);
219
220 /// Subcarrier groups for all RUs (with indices being applicable to primary 80 MHz channel)
222
223 /// RU allocation map
224 using RuAllocationMap = std::map<uint8_t, std::vector<RuSpec>>;
225
226 /// Table 27-26 of IEEE 802.11ax-2021
228
229 /// Get the RU specs based on RU_ALLOCATION
230 /// @param ruAllocation 9 bit RU_ALLOCATION value
231 /// @return RU spec associated with the RU_ALLOCATION
232 static std::vector<RuSpec> GetRuSpecs(uint16_t ruAllocation);
233
234 /// Get the RU_ALLOCATION value for equal size RUs
235 /// @param ruType equal size RU type (generated by GetEqualSizedRusForStations)
236 /// @param isOdd if number of stations is an odd number
237 /// @param hasUsers whether it contributes to User field(s) in the content channel this RU
238 /// Allocation belongs to
239 /// @return RU_ALLOCATION value
240 static uint16_t GetEqualizedRuAllocation(RuType ruType, bool isOdd, bool hasUsers);
241
242 /// Empty 242-tone RU identifier
243 static constexpr uint8_t EMPTY_242_TONE_RU = 113;
244
245 private:
246 /**
247 * Get the number of 26-tone RUs that can be allocated if returned RU size is greater than 26
248 * tones.
249 *
250 * @param bw the bandwidth (MHz) of the HE PPDU (20, 40, 80, 160)
251 * @param ruType the RU type (number of tones)
252 * @return the number of 26-tone RUs that can be allocated
253 */
254 static uint8_t GetNumCentral26TonesRus(MHz_u bw, RuType ruType);
255};
256
257/**
258 * @brief Stream insertion operator.
259 *
260 * @param os the stream
261 * @param ru the RU
262 * @returns a reference to the stream
263 */
264std::ostream& operator<<(std::ostream& os, const HeRu::RuSpec& ru);
265
266} // namespace ns3
267
268#endif /* HE_RU_H */
RU Specification.
Definition he-ru.h:37
std::size_t GetIndex() const
Get the RU index.
Definition he-ru.cc:432
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:103
RuSpec()=default
Default constructor.
RuType GetRuType() const
Get the RU type.
Definition he-ru.cc:425
bool operator<(const RuSpec &other) const
Compare this RU to the given RU.
Definition he-ru.cc:810
bool m_primary80MHz
true if the RU is allocated in the primary 80MHz channel
Definition he-ru.h:105
std::size_t GetPhyIndex(MHz_u bw, uint8_t p20Index) const
Get the RU PHY index.
Definition he-ru.cc:446
RuType m_ruType
RU type.
Definition he-ru.h:102
bool operator==(const RuSpec &other) const
Compare this RU to the given RU.
Definition he-ru.cc:794
bool GetPrimary80MHz() const
Get the primary 80 MHz flag.
Definition he-ru.cc:439
bool operator!=(const RuSpec &other) const
Compare this RU to the given RU.
Definition he-ru.cc:804
This class stores the subcarrier groups of all the available HE RUs.
Definition he-ru.h:26
static std::vector< RuSpec > GetRuSpecs(uint16_t ruAllocation)
Get the RU specs based on RU_ALLOCATION.
Definition he-ru.cc:365
static std::size_t GetIndexIn80MHzSegment(MHz_u bw, RuType ruType, std::size_t phyIndex)
Get the index of a given RU transmitted in a PPDU within its 80 MHz segment.
Definition he-ru.cc:475
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:631
static std::vector< RuSpec > GetRusOfType(MHz_u bw, 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:511
std::map< uint8_t, std::vector< RuSpec > > RuAllocationMap
RU allocation map.
Definition he-ru.h:224
static constexpr uint8_t EMPTY_242_TONE_RU
Empty 242-tone RU identifier.
Definition he-ru.h:243
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:592
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:673
static const SubcarrierGroups m_heRuSubcarrierGroups
Subcarrier groups for all RUs (with indices being applicable to primary 80 MHz channel)
Definition he-ru.h:221
static uint8_t GetNumCentral26TonesRus(MHz_u bw, RuType ruType)
Get the number of 26-tone RUs that can be allocated if returned RU size is greater than 26 tones.
Definition he-ru.cc:757
static bool GetPrimary80MHzFlag(MHz_u bw, RuType ruType, std::size_t phyIndex, uint8_t p20Index)
Get the primary 80 MHz flag of a given RU transmitted in a PPDU.
Definition he-ru.cc:462
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:491
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:719
static std::vector< RuSpec > GetCentral26TonesRus(MHz_u bw, 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:546
static uint16_t GetEqualizedRuAllocation(RuType ruType, bool isOdd, bool hasUsers)
Get the RU_ALLOCATION value for equal size RUs.
Definition he-ru.cc:397
static const RuAllocationMap m_heRuAllocations
Table 27-26 of IEEE 802.11ax-2021.
Definition he-ru.h:227
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
RuType
The different Resource Unit (RU) types.
Definition wifi-types.h:98
std::vector< SubcarrierRange > SubcarrierGroup
a vector of subcarrier ranges defining a subcarrier group
Definition wifi-types.h:156
std::map< BwTonesPair, std::vector< SubcarrierGroup > > SubcarrierGroups
map (bandwidth, number of tones) pairs to the group of subcarrier ranges
Definition wifi-types.h:162
double MHz_u
MHz weak type.
Definition wifi-units.h:31