A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-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 WIFI_RU_H
10#define WIFI_RU_H
11
12#include "ns3/eht-ru.h"
13#include "ns3/he-ru.h"
14
15#include <variant>
16
17namespace ns3
18{
19
20/**
21 * This class handles RU variants.
22 */
23class WifiRu
24{
25 public:
26 /// variant of the RU specification
27 using RuSpec = std::variant<HeRu::RuSpec, EhtRu::RuSpec>;
28
29 /**
30 * Struct providing a function call operator to compare two RUs.
31 */
33 {
34 /**
35 * Constructor.
36 *
37 * @param channelWidth the channel width
38 * @param p20Index the index of the primary20 channel
39 */
40 RuSpecCompare(MHz_u channelWidth, uint8_t p20Index);
41 /**
42 * Function call operator.
43 *
44 * @param lhs left hand side RU
45 * @param rhs right hand side RU
46 * @return true if the left hand side RU has its leftmost tone at a lower
47 * frequency than the leftmost tone of the right hand side RU,
48 * false otherwise
49 */
50 bool operator()(const RuSpec& lhs, const RuSpec& rhs) const;
51
52 private:
53 MHz_u m_channelWidth; ///< The channel width
54 uint8_t m_p20Index; ///< Primary20 channel index
55 };
56
57 /**
58 * Get the type of a given RU
59 *
60 * @param ru the RU variant
61 * @return the RU type
62 */
63 static RuType GetRuType(RuSpec ru);
64
65 /**
66 * Get the index of a given RU
67 *
68 * @param ru the RU variant
69 * @return the RU index
70 */
71 static std::size_t GetIndex(RuSpec ru);
72
73 /**
74 * Get the RU PHY index
75 *
76 * @param ru the RU variant
77 * @param bw the width of the channel of which the RU is part
78 * @param p20Index the index of the primary20 channel
79 * @return the RU PHY index
80 */
81 static std::size_t GetPhyIndex(RuSpec ru, MHz_u bw, uint8_t p20Index);
82
83 /**
84 * Get the approximate bandwidth occupied by a RU.
85 *
86 * @param ruType the RU type
87 * @return the approximate bandwidth occupied by the RU
88 */
89 static MHz_u GetBandwidth(RuType ruType);
90
91 /**
92 * Get the RU corresponding to the approximate bandwidth.
93 *
94 * @param bandwidth the approximate bandwidth occupied by the RU
95 * @return the RU type
96 */
97 static RuType GetRuType(MHz_u bandwidth);
98
99 /**
100 * Get the number of distinct RUs of the given type (number of tones)
101 * available in a PPDU of the given bandwidth.
102 *
103 * @param bw the bandwidth of the PPDU
104 * @param ruType the RU type (number of tones)
105 * @param mc the modulation class of the PPDU
106 * @return the number of distinct RUs available
107 */
108 static std::size_t GetNRus(MHz_u bw, RuType ruType, WifiModulationClass mc);
109
110 /**
111 * Get the subcarrier group of the RU having the given PHY index among all the
112 * RUs of the given type (number of tones) available in a PPDU of the
113 * given bandwidth. A subcarrier group is defined as one or more pairs
114 * indicating the lowest frequency index and the highest frequency index.
115 *
116 * @param bw the bandwidth of the PPDU
117 * @param ruType the RU type (number of tones)
118 * @param phyIndex the PHY index (starting at 1) of the RU
119 * @param mc the modulation class of the PPDU
120 * @return the subcarrier range of the specified RU
121 */
123 RuType ruType,
124 std::size_t phyIndex,
126
127 /**
128 * Get the RU_ALLOCATION value for equal size RUs
129 *
130 * @param ruType equal size RU type (generated by GetEqualSizedRusForStations)
131 * @param isOdd if number of stations is an odd number
132 * @param hasUsers whether it contributes to User field(s) in the content channel this RU
133 * Allocation belongs to
134 * @param mc the modulation class of the PPDU
135 * @return RU_ALLOCATION value
136 */
137 static uint16_t GetEqualizedRuAllocation(RuType ruType,
138 bool isOdd,
139 bool hasUsers,
141
142 /**
143 * Get the RU specs based on RU_ALLOCATION
144 *
145 * @param ruAllocation 9 bit RU_ALLOCATION value
146 * @param mc the modulation class of the PPDU
147 * @return RU spec associated with the RU_ALLOCATION
148 */
149 static std::vector<RuSpec> GetRuSpecs(uint16_t ruAllocation, WifiModulationClass mc);
150
151 /**
152 * Get the set of distinct RUs of the given type (number of tones)
153 * available in an MU PPDU of the given bandwidth.
154 *
155 * @param bw the bandwidth of the PPDU
156 * @param ruType the RU type (number of tones)
157 * @param mc the modulation class of the PPDU
158 * @return the set of distinct RUs available
159 */
160 static std::vector<RuSpec> GetRusOfType(MHz_u bw, RuType ruType, WifiModulationClass mc);
161
162 /**
163 * Get the set of 26-tone RUs that can be additionally allocated if the given
164 * bandwidth is split in RUs of the given type.
165 *
166 * @param bw the bandwidth of the PPDU
167 * @param ruType the RU type (number of tones)
168 * @param mc the modulation class of the PPDU
169 * @return the set of 26-tone RUs that can be additionally allocated
170 */
171 static std::vector<RuSpec> GetCentral26TonesRus(MHz_u bw,
172 RuType ruType,
174
175 /**
176 * Check whether the given RU overlaps with the given set of RUs.
177 *
178 * @param bw the bandwidth of the PPDU
179 * @param ru the given RU allocation
180 * @param v the given set of RUs
181 * @return true if the given RU overlaps with the given set of RUs.
182 */
183 static bool DoesOverlap(MHz_u bw, RuSpec ru, const std::vector<RuSpec>& v);
184
185 /**
186 * Given the channel bandwidth and the number of stations candidate for being
187 * assigned an RU, maximize the number of candidate stations that can be assigned
188 * an RU subject to the constraint that all the stations must be assigned an RU
189 * of the same size (in terms of number of tones).
190 *
191 * @param bandwidth the channel bandwidth
192 * @param nStations the number of candidate stations. On return, it is set to
193 * the number of stations that are assigned an RU
194 * @param nCentral26TonesRus the number of additional 26-tone RUs that can be allocated if the
195 * returned RU size is greater than 26 tones
196 * @param mc the modulation class of the PPDU
197 * @return the RU type
198 */
200 std::size_t& nStations,
201 std::size_t& nCentral26TonesRus,
203
204 /**
205 * Find the RU allocation of the given RU type overlapping the given
206 * reference RU allocation.
207 *
208 * @param bw the bandwidth of the PPDU
209 * @param referenceRu the reference RU allocation
210 * @param searchedRuType the searched RU type
211 * @return the searched RU allocation.
212 */
213 static RuSpec FindOverlappingRu(MHz_u bw, RuSpec referenceRu, RuType searchedRuType);
214
215 /**
216 * Get whether a given RU variant is a HE RU
217 *
218 * @param ru the RU variant
219 * @return true if the RU is a HE RU, false otherwise
220 */
221 static bool IsHe(RuSpec ru);
222
223 /**
224 * Get whether a given RU variant is a EHT RU
225 *
226 * @param ru the RU variant
227 * @return true if the RU is a EHT RU, false otherwise
228 */
229 static bool IsEht(RuSpec ru);
230
231 /**
232 * Get the maximum RU type supported by a given modulation class.
233 *
234 * @param mc the modulation class
235 * @return the RU type
236 */
238};
239
240/**
241 * @brief Stream insertion operator.
242 *
243 * @param os the stream
244 * @param ru the RU variant
245 * @returns a reference to the stream
246 */
247std::ostream& operator<<(std::ostream& os, const WifiRu::RuSpec& ru);
248
249} // namespace ns3
250
251#endif /* WIFI_RU_H */
This class handles RU variants.
Definition wifi-ru.h:24
static std::vector< RuSpec > GetRuSpecs(uint16_t ruAllocation, WifiModulationClass mc)
Get the RU specs based on RU_ALLOCATION.
Definition wifi-ru.cc:156
static std::size_t GetNRus(MHz_u bw, RuType ruType, WifiModulationClass mc)
Get the number of distinct RUs of the given type (number of tones) available in a PPDU of the given b...
Definition wifi-ru.cc:132
std::variant< HeRu::RuSpec, EhtRu::RuSpec > RuSpec
variant of the RU specification
Definition wifi-ru.h:27
static std::vector< RuSpec > GetRusOfType(MHz_u bw, RuType ruType, WifiModulationClass mc)
Get the set of distinct RUs of the given type (number of tones) available in an MU PPDU of the given ...
Definition wifi-ru.cc:173
static bool IsHe(RuSpec ru)
Get whether a given RU variant is a HE RU.
Definition wifi-ru.cc:248
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 wifi-ru.cc:226
static MHz_u GetBandwidth(RuType ruType)
Get the approximate bandwidth occupied by a RU.
Definition wifi-ru.cc:78
static RuType GetEqualSizedRusForStations(MHz_u bandwidth, std::size_t &nStations, std::size_t &nCentral26TonesRus, WifiModulationClass mc)
Given the channel bandwidth and the number of stations candidate for being assigned an RU,...
Definition wifi-ru.cc:237
static RuType GetRuType(RuSpec ru)
Get the type of a given RU.
Definition wifi-ru.cc:45
static SubcarrierGroup GetSubcarrierGroup(MHz_u bw, RuType ruType, std::size_t phyIndex, WifiModulationClass mc)
Get the subcarrier group of the RU having the given PHY index among all the RUs of the given type (nu...
Definition wifi-ru.cc:142
static std::vector< RuSpec > GetCentral26TonesRus(MHz_u bw, RuType ruType, WifiModulationClass mc)
Get the set of 26-tone RUs that can be additionally allocated if the given bandwidth is split in RUs ...
Definition wifi-ru.cc:190
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 wifi-ru.cc:207
static uint16_t GetEqualizedRuAllocation(RuType ruType, bool isOdd, bool hasUsers, WifiModulationClass mc)
Get the RU_ALLOCATION value for equal size RUs.
Definition wifi-ru.cc:149
static std::size_t GetPhyIndex(RuSpec ru, MHz_u bw, uint8_t p20Index)
Get the RU PHY index.
Definition wifi-ru.cc:57
static std::size_t GetIndex(RuSpec ru)
Get the index of a given RU.
Definition wifi-ru.cc:51
static bool IsEht(RuSpec ru)
Get whether a given RU variant is a EHT RU.
Definition wifi-ru.cc:254
static RuType GetMaxRuType(WifiModulationClass mc)
Get the maximum RU type supported by a given modulation class.
Definition wifi-ru.cc:63
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
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
Struct providing a function call operator to compare two RUs.
Definition wifi-ru.h:33
RuSpecCompare(MHz_u channelWidth, uint8_t p20Index)
Constructor.
Definition wifi-ru.cc:16
bool operator()(const RuSpec &lhs, const RuSpec &rhs) const
Function call operator.
Definition wifi-ru.cc:23
uint8_t m_p20Index
Primary20 channel index.
Definition wifi-ru.h:54
MHz_u m_channelWidth
The channel width.
Definition wifi-ru.h:53