A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-types.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 DERONNE SOFTWARE ENGINEERING
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
7 */
8
9#ifndef WIFI_TYPES_H
10#define WIFI_TYPES_H
11
12#include "wifi-phy-band.h"
13#include "wifi-standards.h"
14#include "wifi-units.h"
15
16#include "ns3/fatal-error.h"
17
18#include <compare>
19#include <list>
20#include <map>
21#include <ostream>
22#include <tuple>
23#include <vector>
24
25namespace ns3
26{
27
28/**
29 * @ingroup wifi
30 * Enumeration of the possible channel widths
31 */
47
48/**
49 * @ingroup wifi
50 * The type of an MPDU.
51 */
53{
54 /** The MPDU is not part of an A-MPDU */
56 /** The MPDU is a single MPDU */
58 /** The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last
59 * aggregate */
61 /** The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last
62 * aggregate */
64 /** The MPDU is the last aggregate in an A-MPDU with multiple MPDUs */
66};
67
68/// SignalNoiseDbm structure
70{
71 dBm_u signal; ///< signal strength
72 dBm_u noise; ///< noise power
73};
74
75/// MpduInfo structure
77{
78 MpduType type; ///< type of MPDU
79 uint32_t mpduRefNumber; ///< MPDU ref number
80};
81
82/// RxSignalInfo structure containing info on the received signal
84{
85 double snr; ///< SNR in linear scale
86 dBm_u rssi; ///< RSSI
87};
88
89/**
90 * Struct defining the configuration of a wifi channel, which can be made of one or multiple
91 * channel segments.
92 */
94{
95 /// a channel segment, as a struct without units for channel width (to be deprecated when using
96 /// strong types)
98 {
99 uint8_t number{}; ///< channel number
100 double width{}; ///< channel width in MHz
102 uint8_t p20Index{}; ///< primary20 index
103
104 /**
105 * Constructor.
106 *
107 * @param n the channel number
108 * @param w the channel width
109 * @param b the PHY band
110 * @param i the primary20 index
111 */
112 SegmentWithoutUnits(uint8_t n, double w, WifiPhyBand b, uint8_t i)
113 : number(n),
114 width(w),
115 band(b),
116 p20Index(i)
117 {
118 }
119 };
120
121 /// a channel segment, as a struct with units for channel width
122 struct Segment
123 {
124 uint8_t number{}; ///< channel number
125 MHz_u width{}; ///< channel width
127 uint8_t p20Index{}; ///< primary20 index
128
129 /**
130 * Constructor.
131 *
132 * @param n the channel number
133 * @param w the channel width
134 * @param b the PHY band
135 * @param i the primary20 index
136 */
137 Segment(uint8_t n, MHz_u w, WifiPhyBand b, uint8_t i)
138 : number(n),
139 width(w),
140 band(b),
141 p20Index(i)
142 {
143 }
144
145 /**
146 * Converting constructor (to be deprecated when using strong types)
147 *
148 * @param s a channel segment as a struct without units for channel width
149 */
151 : number(s.number),
152 width(MHz_u{s.width}),
153 band(s.band),
155 {
156 }
157
158 /**
159 * Three-way comparison operator
160 *
161 * @param rhs right hand side
162 * @return deduced comparison type
163 */
164 auto operator<=>(const Segment& rhs) const = default;
165 };
166
167 std::vector<Segment> segments; ///< channel config
168
169 WifiChannelConfig() = default;
170
171 /**
172 * Construct a channel config from a channel segment
173 *
174 * @param segment the channel segment
175 */
177 : segments(std::vector<Segment>{segment})
178 {
179 }
180
181 /**
182 * Construct a channel config from a segment without units for channel width
183 *
184 * @param s the segment without units for channel width
185 */
190
191 /// a channel segment, as a tuple without units for channel width (to be deprecated when using
192 /// strong types)
193 using TupleWithoutUnits = std::tuple<uint64_t /* channel number */,
194 uint64_t /* channel width in MHz */,
195 WifiPhyBand /* PHY band */,
196 uint64_t /* primary20 index*/>;
197
198 /**
199 * Construct a channel config from a list of tuples without units for channel width
200 *
201 * @param tuples the list of tuples without units for channel width
202 */
203 WifiChannelConfig(const std::list<TupleWithoutUnits>& tuples);
204
205 /**
206 * Get the wifi channel config from a WifiPhy::ChannelSettings string
207 *
208 * @param settings the WifiPhy::ChannelSettings string
209 * @param standard the Wi-Fi standard
210 * @return the wifi channel config object
211 */
212 static WifiChannelConfig FromString(const std::string& settings,
214
215 /// @return a const reference to the first channel segment
216 const Segment& front() const
217 {
218 return segments.front();
219 }
220
221 /// @return a reference to the first channel segment
223 {
224 return segments.front();
225 }
226
227 /**
228 * Three-way comparison operator
229 *
230 * @param rhs right hand side
231 * @return deduced comparison type
232 */
233 auto operator<=>(const WifiChannelConfig& rhs) const = default;
234};
235
236/**
237 * The different Resource Unit (RU) types.
238 */
251
252/**
253 * @brief Stream insertion operator.
254 *
255 * @param os the stream
256 * @param ruType the RU type
257 * @returns a reference to the stream
258 */
259inline std::ostream&
260operator<<(std::ostream& os, const RuType& ruType)
261{
262 switch (ruType)
263 {
265 os << "26-tones";
266 break;
268 os << "52-tones";
269 break;
271 os << "106-tones";
272 break;
274 os << "242-tones";
275 break;
277 os << "484-tones";
278 break;
280 os << "996-tones";
281 break;
283 os << "2x996-tones";
284 break;
286 os << "4x996-tones";
287 break;
288 default:
289 NS_FATAL_ERROR("Unknown RU type");
290 }
291 return os;
292}
293
294/// (lowest index, highest index) pair defining a subcarrier range
295using SubcarrierRange = std::pair<int16_t, int16_t>;
296
297/// a vector of subcarrier ranges defining a subcarrier group
298using SubcarrierGroup = std::vector<SubcarrierRange>;
299
300/// (bandwidth, number of tones) pair
301using BwTonesPair = std::pair<MHz_u, RuType>;
302
303/// map (bandwidth, number of tones) pairs to the group of subcarrier ranges
304using SubcarrierGroups = std::map<BwTonesPair, std::vector<SubcarrierGroup>>;
305
306} // namespace ns3
307
308#endif /* WIFI_TYPES_H */
STL class.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiPhyBand
Identifies the PHY band.
WifiChannelWidthType
Enumeration of the possible channel widths.
Definition wifi-types.h:33
MpduType
The type of an MPDU.
Definition wifi-types.h:53
@ WIFI_STANDARD_UNSPECIFIED
@ WIFI_PHY_BAND_UNSPECIFIED
Unspecified.
@ LAST_MPDU_IN_AGGREGATE
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
Definition wifi-types.h:65
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
Definition wifi-types.h:55
@ FIRST_MPDU_IN_AGGREGATE
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate.
Definition wifi-types.h:60
@ SINGLE_MPDU
The MPDU is a single MPDU.
Definition wifi-types.h:57
@ MIDDLE_MPDU_IN_AGGREGATE
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate.
Definition wifi-types.h:63
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
Definition wifi-types.h:295
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148
RuType
The different Resource Unit (RU) types.
Definition wifi-types.h:240
std::vector< SubcarrierRange > SubcarrierGroup
a vector of subcarrier ranges defining a subcarrier group
Definition wifi-types.h:298
std::map< BwTonesPair, std::vector< SubcarrierGroup > > SubcarrierGroups
map (bandwidth, number of tones) pairs to the group of subcarrier ranges
Definition wifi-types.h:304
std::pair< MHz_u, RuType > BwTonesPair
(bandwidth, number of tones) pair
Definition wifi-types.h:301
double MHz_u
MHz weak type.
Definition wifi-units.h:31
double dBm_u
dBm weak type
Definition wifi-units.h:27
STL namespace.
MpduInfo structure.
Definition wifi-types.h:77
MpduType type
type of MPDU
Definition wifi-types.h:78
uint32_t mpduRefNumber
MPDU ref number.
Definition wifi-types.h:79
RxSignalInfo structure containing info on the received signal.
Definition wifi-types.h:84
double snr
SNR in linear scale.
Definition wifi-types.h:85
dBm_u rssi
RSSI.
Definition wifi-types.h:86
SignalNoiseDbm structure.
Definition wifi-types.h:70
dBm_u noise
noise power
Definition wifi-types.h:72
dBm_u signal
signal strength
Definition wifi-types.h:71
a channel segment, as a struct with units for channel width
Definition wifi-types.h:123
Segment(uint8_t n, MHz_u w, WifiPhyBand b, uint8_t i)
Constructor.
Definition wifi-types.h:137
uint8_t p20Index
primary20 index
Definition wifi-types.h:127
auto operator<=>(const Segment &rhs) const =default
Three-way comparison operator.
uint8_t number
channel number
Definition wifi-types.h:124
Segment(const SegmentWithoutUnits &s)
Converting constructor (to be deprecated when using strong types)
Definition wifi-types.h:150
WifiPhyBand band
PHY band.
Definition wifi-types.h:126
a channel segment, as a struct without units for channel width (to be deprecated when using strong ty...
Definition wifi-types.h:98
SegmentWithoutUnits(uint8_t n, double w, WifiPhyBand b, uint8_t i)
Constructor.
Definition wifi-types.h:112
static WifiChannelConfig FromString(const std::string &settings, WifiStandard standard=WIFI_STANDARD_UNSPECIFIED)
Get the wifi channel config from a WifiPhy::ChannelSettings string.
Definition wifi-types.cc:24
std::tuple< uint64_t, uint64_t, WifiPhyBand, uint64_t > TupleWithoutUnits
a channel segment, as a tuple without units for channel width (to be deprecated when using strong typ...
Definition wifi-types.h:193
std::vector< Segment > segments
channel config
Definition wifi-types.h:167
const Segment & front() const
Definition wifi-types.h:216
auto operator<=>(const WifiChannelConfig &rhs) const =default
Three-way comparison operator.
WifiChannelConfig(const SegmentWithoutUnits &s)
Construct a channel config from a segment without units for channel width.
Definition wifi-types.h:186
WifiChannelConfig(const Segment &segment)
Construct a channel config from a channel segment.
Definition wifi-types.h:176
Declaration of the SI units (as weak types aliases) used across wifi module.