A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
eht-ru.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
7 */
8
9#ifndef EHT_RU_H
10#define EHT_RU_H
11
12#include "ns3/wifi-phy-common.h"
13
14#include <cstdint>
15#include <map>
16#include <optional>
17#include <ostream>
18#include <utility>
19#include <vector>
20
21namespace ns3
22{
23
24/**
25 * This class stores the subcarrier groups of all the available EHT RUs.
26 */
27class EhtRu
28{
29 public:
30 /**
31 * RU Specification.
32 */
33 class RuSpec
34 {
35 public:
36 /**
37 * Default constructor
38 */
39 RuSpec() = default;
40 /**
41 * Constructor
42 *
43 * @param ruType the RU type
44 * @param index the RU index (starting at 1) within the 80 MHz segment
45 * @param primary160MHz whether the RU is allocated in the primary 160MHz channel
46 * @param primary80MHzOrLower80MHz if the RU is allocated in the primary 160MHz channel,
47 * whether the RU is allocated in the primary 80MHz channel, otherwise whether the RU is
48 * allocated in the lower 80MHz channel of the secondary 160 MHz channel
49 */
50 RuSpec(RuType ruType, std::size_t index, bool primary160MHz, bool primary80MHzOrLower80MHz);
51
52 /**
53 * Get the RU type
54 *
55 * @return the RU type
56 */
57 RuType GetRuType() const;
58
59 /**
60 * Get the RU index within the 80 MHz segment
61 *
62 * @return the RU index within the 80 MHz segment
63 */
64 std::size_t GetIndex() const;
65
66 /**
67 * Get the RU PHY index
68 *
69 * @param bw the width of the channel of which the RU is part
70 * @param p20Index the index of the primary20 channel
71 * @return the RU PHY index
72 */
73 std::size_t GetPhyIndex(MHz_u bw, uint8_t p20Index) const;
74
75 /**
76 * Get whether the RU is allocated in the primary 160MHz channel
77 *
78 * @return true if the RU is in the primary 160 MHz channel and false otherwise
79 */
80 bool GetPrimary160MHz() const;
81
82 /**
83 * @return if the RU is allocated in the primary 160MHz channel, true if the RU is allocated
84 * in the primary 80MHz channel, otherwise true if the RU is allocated in the lower 80MHz
85 * channel
86 */
87 bool GetPrimary80MHzOrLower80MHz() const;
88
89 /**
90 * Compare this RU to the given RU.
91 *
92 * @param other the given RU
93 * @return true if this RU compares equal to the given RU, false otherwise
94 */
95 bool operator==(const RuSpec& other) const;
96
97 /**
98 * Compare this RU to the given RU.
99 *
100 * @param other the given RU
101 * @return true if this RU differs from the given RU, false otherwise
102 */
103 bool operator!=(const RuSpec& other) const;
104
105 /**
106 * Compare this RU to the given RU.
107 *
108 * @param other the given RU
109 * @return true if this RU is smaller than the given RU, false otherwise
110 */
111 bool operator<(const RuSpec& other) const;
112
113 private:
114 RuType m_ruType{}; //!< RU type
115 std::size_t m_index{}; /**< RU index (starting at 1) within the 80 MHz segment */
116 bool m_primary160MHz{}; //!< true if the RU is allocated in the primary 160MHz channel
117 bool m_primary80MHzOrLower80MHz{}; //!< if the RU is allocated in the primary 160MHz
118 //!< channel, true if the RU is allocated in the primary
119 //!< 80MHz channel, otherwise true if the RU is allocated
120 //!< in the lower 80MHz channel
121 };
122
123 /**
124 * Get the primary flags of a given RU transmitted in a PPDU.
125 * The first flag identifies whether the RU is in the primary 160 MHz.
126 * The second flag identifies whether the RU is allocated in the primary 80MHz channel if the RU
127 * is allocated in the primary 160MHz channel, or whether the RU is allocated in the lower 80MHz
128 * channel if the RU is allocated in the secondary 160MHz channel
129 *
130 * @param bw the bandwidth of the PPDU (20, 40, 80, 160, 320)
131 * @param ruType the RU type (number of tones)
132 * @param phyIndex the PHY index (starting at 1) of the RU
133 * @param p20Index the index of the primary20 channel
134 * @return the primary flags
135 */
136 static std::pair<bool, bool> GetPrimaryFlags(MHz_u bw,
137 RuType ruType,
138 std::size_t phyIndex,
139 uint8_t p20Index);
140
141 /**
142 * Get the index of a given RU transmitted in a PPDU within its 80 MHz segment.
143 *
144 * @param bw the bandwidth of the PPDU (20, 40, 80, 160, 320)
145 * @param ruType the RU type (number of tones)
146 * @param phyIndex the PHY index (starting at 1) of the RU
147 * @return the index within the 80 MHz segment
148 */
149 static std::size_t GetIndexIn80MHzSegment(MHz_u bw, RuType ruType, std::size_t phyIndex);
150
151 /**
152 * Get the number of distinct RUs of the given type (number of tones)
153 * available in a PPDU of the given bandwidth.
154 *
155 * @param bw the bandwidth of the PPDU (20, 40, 80, 160, 320)
156 * @param ruType the RU type (number of tones)
157 * @param includeUndefinedRus whether undefined RUs should be taken account.
158 * @return the number of distinct RUs available
159 */
160 static std::size_t GetNRus(MHz_u bw, RuType ruType, bool includeUndefinedRus = false);
161
162 /**
163 * Get the set of distinct RUs of the given type (number of tones)
164 * available in an PPDU of the given bandwidth.
165 * This does not take undefined RUs into account.
166 *
167 * @param bw the bandwidth of the PPDU (20, 40, 80, 160, 320)
168 * @param ruType the RU type (number of tones)
169 * @return the set of distinct RUs available
170 */
171 static std::vector<RuSpec> GetRusOfType(MHz_u bw, RuType ruType);
172
173 /**
174 * Get the set of 26-tone RUs that can be additionally allocated if the given
175 * bandwidth is split in RUs of the given type.
176 *
177 * @param bw the bandwidth of the PPDU (20, 40, 80, 160, 320)
178 * @param ruType the RU type (number of tones)
179 * @return the set of 26-tone RUs that can be additionally allocated
180 */
181 static std::vector<RuSpec> GetCentral26TonesRus(MHz_u bw, RuType ruType);
182
183 /**
184 * Get the subcarrier group of the RU having the given PHY index among all the RUs of the given
185 * type (number of tones) available in an PPDU of the given bandwidth. A subcarrier group is
186 * defined as one or more pairs indicating the lowest frequency index and the highest frequency
187 * index.
188 *
189 * @param bw the bandwidth of the PPDU (20, 40, 80, 160, 320)
190 * @param ruType the RU type (number of tones)
191 * @param phyIndex the PHY index (starting at 1) of the RU
192 * @return the subcarrier range of the specified RU
193 */
194 static SubcarrierGroup GetSubcarrierGroup(MHz_u bw, RuType ruType, std::size_t phyIndex);
195
196 /**
197 * Check whether the given RU overlaps with the given set of RUs.
198 * Note that for channel width of 160 MHz the returned range is relative to
199 * the 160 MHz channel (i.e. -1012 to 1012).
200 *
201 * @param bw the bandwidth of the PPDU (20, 40, 80, 160, 320)
202 * @param ru the given RU allocation
203 * @param v the given set of RUs
204 * @return true if the given RU overlaps with the given set of RUs.
205 */
206 static bool DoesOverlap(MHz_u bw, RuSpec ru, const std::vector<RuSpec>& v);
207
208 /**
209 * Find the RU allocation of the given RU type overlapping the given
210 * reference RU allocation.
211 * Note that an assert is generated if the RU allocation is not found.
212 *
213 * @param bw the bandwidth of the PPDU (20, 40, 80, 160, 320)
214 * @param referenceRu the reference RU allocation
215 * @param searchedRuType the searched RU type
216 * @return the searched RU allocation.
217 */
218 static RuSpec FindOverlappingRu(MHz_u bw, RuSpec referenceRu, RuType searchedRuType);
219
220 /**
221 * Given the channel bandwidth and the number of stations candidate for being
222 * assigned an RU, maximize the number of candidate stations that can be assigned
223 * an RU subject to the constraint that all the stations must be assigned an RU
224 * of the same size (in terms of number of tones).
225 *
226 * @param bandwidth the channel bandwidth
227 * @param nStations the number of candidate stations. On return, it is set to
228 * the number of stations that are assigned an RU
229 * @param[out] nCentral26TonesRus the number of additional 26-tone RUs that can be
230 * allocated if the returned RU size is greater than 26 tones
231 * @return the RU type
232 */
234 std::size_t& nStations,
235 std::size_t& nCentral26TonesRus);
236
237 /// Get the RU specs based on RU_ALLOCATION
238 /// @param ruAllocation 9 bit RU_ALLOCATION value
239 /// @return RU spec associated with the RU_ALLOCATION
240 static std::vector<RuSpec> GetRuSpecs(uint16_t ruAllocation);
241
242 /// Get the RU_ALLOCATION value for equal size RUs
243 /// @param ruType equal size RU type (generated by GetEqualSizedRusForStations)
244 /// @param isOdd if number of stations is an odd number
245 /// @param hasUsers whether it contributes to User field(s) in the content channel this RU
246 /// Allocation belongs to;
247 /// @return RU_ALLOCATION value
248 static uint16_t GetEqualizedRuAllocation(RuType ruType, bool isOdd, bool hasUsers);
249
250 private:
251 /**
252 * Get the number of 26-tone RUs that can be allocated if returned RU size is greater than 26
253 * tones.
254 *
255 * @param bw the bandwidth of the PPDU (20, 40, 80, 160, 320)
256 * @param ruType the RU type (number of tones)
257 * @return the number of 26-tone RUs that can be allocated
258 */
259 static uint8_t GetNumCentral26TonesRus(MHz_u bw, RuType ruType);
260
261 /// Subcarrier groups for all EHT RUs
263
264 /// RU allocation map
265 using RuAllocationMap = std::map<uint8_t, std::vector<RuSpec>>;
266
267 /// Table 36-34 of IEEE802.11be-D7.0
269};
270
271/**
272 * @brief Stream insertion operator.
273 *
274 * @param os the stream
275 * @param ru the RU
276 * @returns a reference to the stream
277 */
278std::ostream& operator<<(std::ostream& os, const EhtRu::RuSpec& ru);
279
280} // namespace ns3
281
282#endif /* EHT_RU_H */
RU Specification.
Definition eht-ru.h:34
bool m_primary160MHz
true if the RU is allocated in the primary 160MHz channel
Definition eht-ru.h:116
std::size_t m_index
RU index (starting at 1) within the 80 MHz segment.
Definition eht-ru.h:115
bool operator!=(const RuSpec &other) const
Compare this RU to the given RU.
Definition eht-ru.cc:1189
bool GetPrimary80MHzOrLower80MHz() const
Definition eht-ru.cc:877
bool operator==(const RuSpec &other) const
Compare this RU to the given RU.
Definition eht-ru.cc:1179
bool m_primary80MHzOrLower80MHz
if the RU is allocated in the primary 160MHz channel, true if the RU is allocated in the primary 80MH...
Definition eht-ru.h:117
bool operator<(const RuSpec &other) const
Compare this RU to the given RU.
Definition eht-ru.cc:1195
RuSpec()=default
Default constructor.
RuType GetRuType() const
Get the RU type.
Definition eht-ru.cc:856
std::size_t GetPhyIndex(MHz_u bw, uint8_t p20Index) const
Get the RU PHY index.
Definition eht-ru.cc:884
std::size_t GetIndex() const
Get the RU index within the 80 MHz segment.
Definition eht-ru.cc:863
RuType m_ruType
RU type.
Definition eht-ru.h:114
bool GetPrimary160MHz() const
Get whether the RU is allocated in the primary 160MHz channel.
Definition eht-ru.cc:870
This class stores the subcarrier groups of all the available EHT RUs.
Definition eht-ru.h:28
static const RuAllocationMap m_ruAllocations
Table 36-34 of IEEE802.11be-D7.0.
Definition eht-ru.h:268
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 eht-ru.cc:1072
static std::pair< bool, bool > GetPrimaryFlags(MHz_u bw, RuType ruType, std::size_t phyIndex, uint8_t p20Index)
Get the primary flags of a given RU transmitted in a PPDU.
Definition eht-ru.cc:913
static uint16_t GetEqualizedRuAllocation(RuType ruType, bool isOdd, bool hasUsers)
Get the RU_ALLOCATION value for equal size RUs.
Definition eht-ru.cc:821
std::map< uint8_t, std::vector< RuSpec > > RuAllocationMap
RU allocation map.
Definition eht-ru.h:265
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 an PPDU of the given ban...
Definition eht-ru.cc:988
static std::vector< RuSpec > GetRuSpecs(uint16_t ruAllocation)
Get the RU specs based on RU_ALLOCATION.
Definition eht-ru.cc:798
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 eht-ru.cc:946
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 eht-ru.cc:1064
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 eht-ru.cc:1027
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 eht-ru.cc:1121
static const SubcarrierGroups m_ruSubcarrierGroups
Subcarrier groups for all EHT RUs.
Definition eht-ru.h:262
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 eht-ru.cc:1171
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 eht-ru.cc:1143
static std::size_t GetNRus(MHz_u bw, RuType ruType, bool includeUndefinedRus=false)
Get the number of distinct RUs of the given type (number of tones) available in a PPDU of the given b...
Definition eht-ru.cc:963
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