A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-phy-common.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006,2007 INRIA
3 * Copyright (c) 2020 Orange Labs
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 * Rediet <getachew.redieteab@orange.com>
20 */
21
22#ifndef WIFI_PHY_COMMON_H
23#define WIFI_PHY_COMMON_H
24
25#include "wifi-standards.h"
26
27#include "ns3/fatal-error.h"
28#include "ns3/ptr.h"
29#include "ns3/wifi-spectrum-value-helper.h"
30
31#include <ostream>
32
44namespace ns3
45{
46
47class WifiNetDevice;
48class WifiMode;
49class Time;
50
54using WifiSpectrumBandFrequencies = std::pair<uint64_t, uint64_t>;
55
58{
61};
62
72inline bool
74{
75 return lhs.frequencies < rhs.frequencies;
76}
77
85inline std::ostream&
86operator<<(std::ostream& os, const WifiSpectrumBandInfo& band)
87{
88 os << "indices: [" << band.indices.first << "-" << band.indices.second << "], frequencies: ["
89 << band.frequencies.first << "Hz-" << band.frequencies.second << "Hz]";
90 return os;
91}
92
100enum WifiCodeRate : uint16_t
101{
115};
116
124inline std::ostream&
125operator<<(std::ostream& os, const WifiCodeRate& codeRate)
126{
127 switch (codeRate)
128 {
130 return (os << "Code rate undefined");
132 return (os << "Code rate 1/2");
134 return (os << "Code rate 2/3");
136 return (os << "Code rate 3/4");
138 return (os << "Code rate 5/6");
140 return (os << "Code rate 5/8");
142 return (os << "Code rate 13/16");
144 return (os << "Code rate 1/4");
146 return (os << "Code rate 13/28");
148 return (os << "Code rate 13/21");
150 return (os << "Code rate 52/63");
152 return (os << "Code rate 13/14");
154 return (os << "Code rate 7/8");
155 default:
156 NS_FATAL_ERROR("Unknown code rate");
157 return (os << "Unknown");
158 }
159}
160
166{
182
190inline std::ostream&
191operator<<(std::ostream& os, const WifiPreamble& preamble)
192{
193 switch (preamble)
194 {
196 return (os << "LONG");
198 return (os << "SHORT");
200 return (os << "HT_MF");
202 return (os << "VHT_SU");
204 return (os << "VHT_MU");
206 return (os << "DMG_CTRL");
208 return (os << "DMG_SC");
210 return (os << "DMG_OFDM");
212 return (os << "HE_SU");
214 return (os << "HE_ER_SU");
216 return (os << "HE_MU");
218 return (os << "HE_TB");
220 return (os << "EHT_MU");
222 return (os << "EHT_TB");
223 default:
224 NS_FATAL_ERROR("Invalid preamble");
225 return (os << "INVALID");
226 }
227}
228
236{
253
261inline std::ostream&
262operator<<(std::ostream& os, const WifiModulationClass& modulation)
263{
264 switch (modulation)
265 {
267 return (os << "DSSS");
269 return (os << "HR/DSSS");
271 return (os << "ERP-OFDM");
273 return (os << "OFDM");
275 return (os << "HT");
277 return (os << "VHT");
279 return (os << "DMG_CTRL");
281 return (os << "DMG_OFDM");
283 return (os << "DMG_SC");
285 return (os << "DMG_LP_SC");
287 return (os << "HE");
289 return (os << "EHT");
290 default:
291 NS_FATAL_ERROR("Unknown modulation");
292 return (os << "unknown");
293 }
294}
295
301{
324
332inline std::ostream&
333operator<<(std::ostream& os, const WifiPpduField& field)
334{
335 switch (field)
336 {
338 return (os << "preamble");
340 return (os << "non-HT header");
342 return (os << "HT-SIG");
344 return (os << "training");
346 return (os << "SIG-A");
348 return (os << "SIG-B");
350 return (os << "U-SIG");
352 return (os << "EHT-SIG");
354 return (os << "data");
355 default:
356 NS_FATAL_ERROR("Unknown field");
357 return (os << "unknown");
358 }
359}
360
366{
371
379inline std::ostream&
380operator<<(std::ostream& os, const WifiPpduType& type)
381{
382 switch (type)
383 {
385 return (os << "SU");
387 return (os << "DL MU");
389 return (os << "UL MU");
390 default:
391 NS_FATAL_ERROR("Unknown type");
392 return (os << "unknown");
393 }
394}
395
401{
427
435inline std::ostream&
436operator<<(std::ostream& os, const WifiPhyRxfailureReason& reason)
437{
438 switch (reason)
439 {
441 return (os << "UNSUPPORTED_SETTINGS");
443 return (os << "CHANNEL_SWITCHING");
444 case RXING:
445 return (os << "RXING");
446 case TXING:
447 return (os << "TXING");
448 case SLEEPING:
449 return (os << "SLEEPING");
450 case POWERED_OFF:
451 return (os << "OFF");
452 case TRUNCATED_TX:
453 return (os << "TRUNCATED_TX");
455 return (os << "BUSY_DECODING_PREAMBLE");
457 return (os << "PREAMBLE_DETECT_FAILURE");
459 return (os << "RECEPTION_ABORTED_BY_TX");
460 case L_SIG_FAILURE:
461 return (os << "L_SIG_FAILURE");
462 case HT_SIG_FAILURE:
463 return (os << "HT_SIG_FAILURE");
464 case SIG_A_FAILURE:
465 return (os << "SIG_A_FAILURE");
466 case SIG_B_FAILURE:
467 return (os << "SIG_B_FAILURE");
468 case U_SIG_FAILURE:
469 return (os << "U_SIG_FAILURE");
470 case EHT_SIG_FAILURE:
471 return (os << "EHT_SIG_FAILURE");
473 return (os << "PREAMBLE_DETECTION_PACKET_SWITCH");
475 return (os << "FRAME_CAPTURE_PACKET_SWITCH");
477 return (os << "OBSS_PD_CCA_RESET");
478 case PPDU_TOO_LATE:
479 return (os << "PPDU_TOO_LATE");
480 case FILTERED:
481 return (os << "FILTERED");
483 return (os << "DMG_HEADER_FAILURE");
485 return (os << "DMG_ALLOCATION_ENDED");
486 case UNKNOWN:
487 default:
488 NS_FATAL_ERROR("Unknown reason");
489 return (os << "UNKNOWN");
490 }
491}
492
499{
505
513inline std::ostream&
514operator<<(std::ostream& os, WifiChannelListType type)
515{
516 switch (type)
517 {
519 return (os << "PRIMARY");
521 return (os << "SECONDARY");
523 return (os << "SECONDARY40");
525 return (os << "SECONDARY80");
526 default:
527 NS_FATAL_ERROR("Unknown wifi channel type");
528 return (os << "UNKNOWN");
529 }
530}
531
540uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode, const Ptr<WifiNetDevice> device);
541
551uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode,
552 bool htShortGuardInterval,
553 Time heGuardInterval);
554
563WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble);
564
573
585 WifiModulationClass modClassAnswer);
586
596Time GetPpduMaxTime(WifiPreamble preamble);
597
604bool IsMu(WifiPreamble preamble);
605
612bool IsDlMu(WifiPreamble preamble);
613
620bool IsUlMu(WifiPreamble preamble);
621
629
637
644bool IsEht(WifiPreamble preamble);
645
646} // namespace ns3
647
648#endif /* WIFI_PHY_COMMON_H */
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiPpduType
The type of PPDU (SU, DL MU, or UL MU)
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
WifiChannelListType
Enumeration of the possible channel-list parameter elements defined in Table 8-5 of IEEE 802....
WifiPpduField
The type of PPDU field (grouped for convenience)
@ OBSS_PD_CCA_RESET
@ PREAMBLE_DETECT_FAILURE
@ TRUNCATED_TX
@ FRAME_CAPTURE_PACKET_SWITCH
@ POWERED_OFF
@ UNSUPPORTED_SETTINGS
@ L_SIG_FAILURE
@ DMG_HEADER_FAILURE
@ RECEPTION_ABORTED_BY_TX
@ SIG_A_FAILURE
@ CHANNEL_SWITCHING
@ DMG_ALLOCATION_ENDED
@ U_SIG_FAILURE
@ BUSY_DECODING_PREAMBLE
@ SIG_B_FAILURE
@ HT_SIG_FAILURE
@ PPDU_TOO_LATE
@ EHT_SIG_FAILURE
@ PREAMBLE_DETECTION_PACKET_SWITCH
@ WIFI_PREAMBLE_LONG
@ WIFI_PREAMBLE_EHT_TB
@ WIFI_PREAMBLE_HE_ER_SU
@ WIFI_PREAMBLE_HE_TB
@ WIFI_PREAMBLE_DMG_CTRL
@ WIFI_PREAMBLE_EHT_MU
@ WIFI_PREAMBLE_HE_MU
@ WIFI_PREAMBLE_HE_SU
@ WIFI_PREAMBLE_VHT_MU
@ WIFI_PREAMBLE_VHT_SU
@ WIFI_PREAMBLE_SHORT
@ WIFI_PREAMBLE_HT_MF
@ WIFI_PREAMBLE_DMG_SC
@ WIFI_PREAMBLE_DMG_OFDM
@ WIFI_PPDU_TYPE_DL_MU
@ WIFI_PPDU_TYPE_UL_MU
@ WIFI_PPDU_TYPE_SU
@ WIFI_MOD_CLASS_DMG_OFDM
DMG (Clause 21)
@ WIFI_MOD_CLASS_DMG_CTRL
DMG (Clause 21)
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
@ WIFI_MOD_CLASS_UNKNOWN
Modulation class unknown or unspecified.
@ WIFI_MOD_CLASS_DMG_SC
DMG (Clause 21)
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_EHT
EHT (Clause 36)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ WIFI_MOD_CLASS_DMG_LP_SC
DMG (Clause 21)
@ WIFI_MOD_CLASS_DSSS
DSSS (Clause 15)
@ WIFI_MOD_CLASS_ERP_OFDM
ERP-OFDM (18.4)
@ WIFI_CHANLIST_PRIMARY
@ WIFI_CHANLIST_SECONDARY40
@ WIFI_CHANLIST_SECONDARY
@ WIFI_CHANLIST_SECONDARY80
@ WIFI_PPDU_FIELD_SIG_B
SIG-B field.
@ WIFI_PPDU_FIELD_TRAINING
STF + LTF fields (excluding those in preamble for HT-GF)
@ WIFI_PPDU_FIELD_NON_HT_HEADER
PHY header field for DSSS or ERP, short PHY header field for HR/DSSS or ERP, field not present for HT...
@ WIFI_PPDU_FIELD_EHT_SIG
EHT-SIG field.
@ WIFI_PPDU_FIELD_HT_SIG
HT-SIG field.
@ WIFI_PPDU_FIELD_PREAMBLE
SYNC + SFD fields for DSSS or ERP, shortSYNC + shortSFD fields for HR/DSSS or ERP,...
@ WIFI_PPDU_FIELD_U_SIG
U-SIG field.
@ WIFI_PPDU_FIELD_DATA
data field
@ WIFI_PPDU_FIELD_SIG_A
SIG-A field.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:848
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time GetPpduMaxTime(WifiPreamble preamble)
Get the maximum PPDU duration (see Section 10.14 of 802.11-2016) for the PHY layers defining the aPPD...
uint16_t GetMaximumChannelWidth(WifiModulationClass modulation)
Get the maximum channel width in MHz allowed for the given modulation class.
std::pair< uint64_t, uint64_t > WifiSpectrumBandFrequencies
typedef for a pair of start and stop frequencies in Hz to represent a band
bool IsEht(WifiPreamble preamble)
Return true if a preamble corresponds to an EHT transmission.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129
bool IsAllowedControlAnswerModulationClass(WifiModulationClass modClassReq, WifiModulationClass modClassAnswer)
Return whether the modulation class of the selected mode for the control answer frame is allowed.
bool IsMu(WifiPreamble preamble)
Return true if a preamble corresponds to a multi-user transmission.
std::pair< uint32_t, uint32_t > WifiSpectrumBandIndices
typedef for a pair of start and stop sub-band indices
WifiModulationClass GetModulationClassForPreamble(WifiPreamble preamble)
Return the modulation class corresponding to the given preamble type.
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:170
uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode, const Ptr< WifiNetDevice > device)
Convert the guard interval to nanoseconds based on the WifiMode.
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
WifiModulationClass GetModulationClassForStandard(WifiStandard standard)
Return the modulation class corresponding to a given standard.
bool IsDlMu(WifiPreamble preamble)
Return true if a preamble corresponds to a downlink multi-user transmission.
bool IsUlMu(WifiPreamble preamble)
Return true if a preamble corresponds to a uplink multi-user transmission.
WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
@ WIFI_CODE_RATE_2_3
2/3 coding rate
@ WIFI_CODE_RATE_13_21
13/21 coding rate
@ WIFI_CODE_RATE_1_2
1/2 coding rate
@ WIFI_CODE_RATE_3_4
3/4 coding rate
@ WIFI_CODE_RATE_1_4
1/4 coding rate
@ WIFI_CODE_RATE_UNDEFINED
undefined coding rate
@ WIFI_CODE_RATE_7_8
7/8 coding rate
@ WIFI_CODE_RATE_52_63
52/63 coding rate
@ WIFI_CODE_RATE_13_14
13/14 coding rate
@ WIFI_CODE_RATE_13_28
13/28 coding rate
@ WIFI_CODE_RATE_5_6
5/6 coding rate
@ WIFI_CODE_RATE_5_8
5/8 coding rate
@ WIFI_CODE_RATE_13_16
13/16 coding rate
WifiSpectrumBandInfo structure containing info about a spectrum band.
WifiSpectrumBandFrequencies frequencies
the start and stop frequencies of the band
WifiSpectrumBandIndices indices
the start and stop indices of the band