A Discrete-Event Network Simulator
API
wifi-phy-common.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006,2007 INRIA
4  * Copyright (c) 2020 Orange Labs
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Rediet <getachew.redieteab@orange.com>
21  */
22 
23 #ifndef WIFI_PHY_COMMON_H
24 #define WIFI_PHY_COMMON_H
25 
26 #include <ostream>
27 #include "ns3/fatal-error.h"
28 #include "ns3/ptr.h"
29 
41 namespace ns3 {
42 
43 class WifiNetDevice;
44 class WifiMode;
45 class Time;
46 
56 typedef uint16_t WifiCodeRate;
57 const uint16_t WIFI_CODE_RATE_UNDEFINED = 0;
58 const uint16_t WIFI_CODE_RATE_1_2 = 1;
59 const uint16_t WIFI_CODE_RATE_2_3 = 2;
60 const uint16_t WIFI_CODE_RATE_3_4 = 3;
61 const uint16_t WIFI_CODE_RATE_5_6 = 4;
62 
68 {
78 };
79 
87 inline std::ostream& operator<< (std::ostream &os, const WifiPreamble &preamble)
88 {
89  switch (preamble)
90  {
91  case WIFI_PREAMBLE_LONG:
92  return (os << "LONG");
94  return (os << "SHORT");
96  return (os << "HT_MF");
98  return (os << "VHT_SU");
100  return (os << "VHT_MU");
101  case WIFI_PREAMBLE_HE_SU:
102  return (os << "HE_SU");
104  return (os << "HE_ER_SU");
105  case WIFI_PREAMBLE_HE_MU:
106  return (os << "HE_MU");
107  case WIFI_PREAMBLE_HE_TB:
108  return (os << "HE_TB");
109  default:
110  NS_FATAL_ERROR ("Invalid preamble");
111  return (os << "INVALID");
112  }
113 }
114 
122 {
133 };
134 
142 inline std::ostream& operator<< (std::ostream &os, const WifiModulationClass &modulation)
143 {
144  switch (modulation)
145  {
146  case WIFI_MOD_CLASS_DSSS:
147  return (os << "DSSS");
149  return (os << "HR/DSSS");
151  return (os << "ERP-OFDM");
152  case WIFI_MOD_CLASS_OFDM:
153  return (os << "OFDM");
154  case WIFI_MOD_CLASS_HT:
155  return (os << "HT");
156  case WIFI_MOD_CLASS_VHT:
157  return (os << "VHT");
158  case WIFI_MOD_CLASS_HE:
159  return (os << "HE");
160  default:
161  NS_FATAL_ERROR ("Unknown modulation");
162  return (os << "unknown");
163  }
164 }
165 
171 {
191 };
192 
200 inline std::ostream& operator<< (std::ostream &os, const WifiPpduField &field)
201 {
202  switch (field)
203  {
205  return (os << "preamble");
207  return (os << "non-HT header");
209  return (os << "HT-SIG");
211  return (os << "training");
213  return (os << "SIG-A");
215  return (os << "SIG-B");
217  return (os << "data");
218  default:
219  NS_FATAL_ERROR ("Unknown field");
220  return (os << "unknown");
221  }
222 }
223 
229 {
233 };
234 
242 inline std::ostream& operator<< (std::ostream &os, const WifiPpduType &type)
243 {
244  switch (type)
245  {
246  case WIFI_PPDU_TYPE_SU:
247  return (os << "SU");
249  return (os << "DL MU");
251  return (os << "UL MU");
252  default:
253  NS_FATAL_ERROR ("Unknown type");
254  return (os << "unknown");
255  }
256 }
257 
263 {
264  UNKNOWN = 0,
281  FILTERED
282 };
283 
291 inline std::ostream& operator<< (std::ostream &os, const WifiPhyRxfailureReason &reason)
292 {
293  switch (reason)
294  {
296  return (os << "UNSUPPORTED_SETTINGS");
297  case CHANNEL_SWITCHING:
298  return (os << "CHANNEL_SWITCHING");
299  case RXING:
300  return (os << "RXING");
301  case TXING:
302  return (os << "TXING");
303  case SLEEPING:
304  return (os << "SLEEPING");
306  return (os << "BUSY_DECODING_PREAMBLE");
308  return (os << "PREAMBLE_DETECT_FAILURE");
310  return (os << "RECEPTION_ABORTED_BY_TX");
311  case L_SIG_FAILURE:
312  return (os << "L_SIG_FAILURE");
313  case HT_SIG_FAILURE:
314  return (os << "HT_SIG_FAILURE");
315  case SIG_A_FAILURE:
316  return (os << "SIG_A_FAILURE");
317  case SIG_B_FAILURE:
318  return (os << "SIG_B_FAILURE");
320  return (os << "PREAMBLE_DETECTION_PACKET_SWITCH");
322  return (os << "FRAME_CAPTURE_PACKET_SWITCH");
323  case OBSS_PD_CCA_RESET:
324  return (os << "OBSS_PD_CCA_RESET");
325  case HE_TB_PPDU_TOO_LATE:
326  return (os << "HE_TB_PPDU_TOO_LATE");
327  case FILTERED:
328  return (os << "FILTERED");
329  case UNKNOWN:
330  default:
331  NS_FATAL_ERROR ("Unknown reason");
332  return (os << "UNKNOWN");
333  }
334 }
335 
344 uint16_t ConvertGuardIntervalToNanoSeconds (WifiMode mode, const Ptr<WifiNetDevice> device);
345 
355 uint16_t ConvertGuardIntervalToNanoSeconds (WifiMode mode, bool htShortGuardInterval, Time heGuardInterval);
356 
365 WifiPreamble GetPreambleForTransmission (WifiModulationClass modulation, bool useShortPreamble);
366 
376 uint16_t GetChannelWidthForTransmission (WifiMode mode, uint16_t maxSupportedChannelWidth);
377 
389 
399 Time GetPpduMaxTime (WifiPreamble preamble);
400 
407 bool IsMu (WifiPreamble preamble);
408 
415 bool IsDlMu (WifiPreamble preamble);
416 
423 bool IsUlMu (WifiPreamble preamble);
424 
425 } //namespace ns3
426 
427 #endif /* WIFI_PHY_COMMON_H */
ns3::WIFI_MOD_CLASS_ERP_OFDM
@ WIFI_MOD_CLASS_ERP_OFDM
ERP-OFDM (18.4)
Definition: wifi-phy-common.h:128
ns3::HT_SIG_FAILURE
@ HT_SIG_FAILURE
Definition: wifi-phy-common.h:274
ns3::WIFI_PPDU_FIELD_HT_SIG
@ WIFI_PPDU_FIELD_HT_SIG
HT-SIG field.
Definition: wifi-phy-common.h:186
ns3::WIFI_PPDU_FIELD_SIG_A
@ WIFI_PPDU_FIELD_SIG_A
SIG-A field.
Definition: wifi-phy-common.h:188
ns3::WIFI_CODE_RATE_5_6
const uint16_t WIFI_CODE_RATE_5_6
5/6 coding rate
Definition: wifi-phy-common.h:61
ns3::IsMu
bool IsMu(WifiPreamble preamble)
Return true if a preamble corresponds to a multi-user transmission.
Definition: wifi-phy-common.cc:158
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WIFI_MOD_CLASS_HT
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
Definition: wifi-phy-common.h:130
ns3::WIFI_MOD_CLASS_HE
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
Definition: wifi-phy-common.h:132
ns3::BUSY_DECODING_PREAMBLE
@ BUSY_DECODING_PREAMBLE
Definition: wifi-phy-common.h:270
ns3::TXING
@ TXING
Definition: wifi-phy-common.h:268
ns3::WIFI_PREAMBLE_VHT_SU
@ WIFI_PREAMBLE_VHT_SU
Definition: wifi-phy-common.h:72
ns3::WIFI_CODE_RATE_UNDEFINED
const uint16_t WIFI_CODE_RATE_UNDEFINED
undefined coding rate
Definition: wifi-phy-common.h:57
ns3::OBSS_PD_CCA_RESET
@ OBSS_PD_CCA_RESET
Definition: wifi-phy-common.h:279
ns3::WIFI_MOD_CLASS_OFDM
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
Definition: wifi-phy-common.h:129
ns3::WIFI_PPDU_FIELD_PREAMBLE
@ WIFI_PPDU_FIELD_PREAMBLE
SYNC + SFD fields for DSSS or ERP, shortSYNC + shortSFD fields for HR/DSSS or ERP,...
Definition: wifi-phy-common.h:178
ns3::WIFI_PREAMBLE_HE_SU
@ WIFI_PREAMBLE_HE_SU
Definition: wifi-phy-common.h:74
ns3::PREAMBLE_DETECT_FAILURE
@ PREAMBLE_DETECT_FAILURE
Definition: wifi-phy-common.h:271
ns3::RXING
@ RXING
Definition: wifi-phy-common.h:267
ns3::FRAME_CAPTURE_PACKET_SWITCH
@ FRAME_CAPTURE_PACKET_SWITCH
Definition: wifi-phy-common.h:278
ns3::WIFI_MOD_CLASS_UNKNOWN
@ WIFI_MOD_CLASS_UNKNOWN
Modulation class unknown or unspecified.
Definition: wifi-phy-common.h:125
ns3::CHANNEL_SWITCHING
@ CHANNEL_SWITCHING
Definition: wifi-phy-common.h:266
ns3::GetPpduMaxTime
Time GetPpduMaxTime(WifiPreamble preamble)
Get the maximum PPDU duration (see Section 10.14 of 802.11-2016) for the PHY layers defining the aPPD...
Definition: wifi-phy-common.cc:135
ns3::PREAMBLE_DETECTION_PACKET_SWITCH
@ PREAMBLE_DETECTION_PACKET_SWITCH
Definition: wifi-phy-common.h:277
ns3::WIFI_MOD_CLASS_HR_DSSS
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
Definition: wifi-phy-common.h:127
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
ns3::WifiCodeRate
uint16_t WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
Definition: wifi-phy-common.h:45
ns3::RECEPTION_ABORTED_BY_TX
@ RECEPTION_ABORTED_BY_TX
Definition: wifi-phy-common.h:272
ns3::WifiPhyRxfailureReason
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
Definition: wifi-phy-common.h:263
ns3::FILTERED
@ FILTERED
Definition: wifi-phy-common.h:281
ns3::HE_TB_PPDU_TOO_LATE
@ HE_TB_PPDU_TOO_LATE
Definition: wifi-phy-common.h:280
ns3::WIFI_PREAMBLE_HE_ER_SU
@ WIFI_PREAMBLE_HE_ER_SU
Definition: wifi-phy-common.h:75
ns3::L_SIG_FAILURE
@ L_SIG_FAILURE
Definition: wifi-phy-common.h:273
ns3::ConvertGuardIntervalToNanoSeconds
uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode, const Ptr< WifiNetDevice > device)
Convert the guard interval to nanoseconds based on the WifiMode.
Definition: wifi-phy-common.cc:30
ns3::WIFI_CODE_RATE_2_3
const uint16_t WIFI_CODE_RATE_2_3
2/3 coding rate
Definition: wifi-phy-common.h:59
ns3::WIFI_PREAMBLE_HE_MU
@ WIFI_PREAMBLE_HE_MU
Definition: wifi-phy-common.h:76
ns3::GetChannelWidthForTransmission
uint16_t GetChannelWidthForTransmission(WifiMode mode, uint16_t maxSupportedChannelWidth)
Return the channel width that corresponds to the selected mode (instead of letting the PHY's default ...
Definition: wifi-phy-common.cc:68
ns3::WIFI_PREAMBLE_VHT_MU
@ WIFI_PREAMBLE_VHT_MU
Definition: wifi-phy-common.h:73
ns3::WifiPpduField
WifiPpduField
The type of PPDU field (grouped for convenience)
Definition: wifi-phy-common.h:171
ns3::WifiPreamble
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-phy-common.h:68
ns3::GetPreambleForTransmission
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
Definition: wifi-phy-common.cc:87
ns3::WIFI_PREAMBLE_LONG
@ WIFI_PREAMBLE_LONG
Definition: wifi-phy-common.h:69
ns3::WIFI_PPDU_TYPE_UL_MU
@ WIFI_PPDU_TYPE_UL_MU
Definition: wifi-phy-common.h:232
ns3::WIFI_CODE_RATE_1_2
const uint16_t WIFI_CODE_RATE_1_2
1/2 coding rate
Definition: wifi-phy-common.h:58
ns3::SLEEPING
@ SLEEPING
Definition: wifi-phy-common.h:269
ns3::SIG_A_FAILURE
@ SIG_A_FAILURE
Definition: wifi-phy-common.h:275
ns3::SIG_B_FAILURE
@ SIG_B_FAILURE
Definition: wifi-phy-common.h:276
ns3::WifiPpduType
WifiPpduType
The type of PPDU (SU, DL MU, or UL MU)
Definition: wifi-phy-common.h:229
ns3::WIFI_PPDU_TYPE_DL_MU
@ WIFI_PPDU_TYPE_DL_MU
Definition: wifi-phy-common.h:231
ns3::UNSUPPORTED_SETTINGS
@ UNSUPPORTED_SETTINGS
Definition: wifi-phy-common.h:265
ns3::UNKNOWN
@ UNKNOWN
Definition: wifi-phy-common.h:264
ns3::WIFI_PPDU_FIELD_DATA
@ WIFI_PPDU_FIELD_DATA
data field
Definition: wifi-phy-common.h:190
ns3::IsUlMu
bool IsUlMu(WifiPreamble preamble)
Return true if a preamble corresponds to a uplink multi-user transmission.
Definition: wifi-phy-common.cc:170
ns3::TracedValueCallback::Time
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:813
ns3::WIFI_PPDU_FIELD_TRAINING
@ WIFI_PPDU_FIELD_TRAINING
STF + LTF fields (excluding those in preamble for HT-GF)
Definition: wifi-phy-common.h:187
ns3::IsAllowedControlAnswerModulationClass
bool IsAllowedControlAnswerModulationClass(WifiModulationClass modClassReq, WifiModulationClass modClassAnswer)
Return whether the modulation class of the selected mode for the control answer frame is allowed.
Definition: wifi-phy-common.cc:112
ns3::WIFI_CODE_RATE_3_4
const uint16_t WIFI_CODE_RATE_3_4
3/4 coding rate
Definition: wifi-phy-common.h:60
ns3::WIFI_MOD_CLASS_VHT
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
Definition: wifi-phy-common.h:131
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
ns3::WIFI_PREAMBLE_HE_TB
@ WIFI_PREAMBLE_HE_TB
Definition: wifi-phy-common.h:77
ns3::WIFI_PREAMBLE_HT_MF
@ WIFI_PREAMBLE_HT_MF
Definition: wifi-phy-common.h:71
ns3::WIFI_PPDU_FIELD_SIG_B
@ WIFI_PPDU_FIELD_SIG_B
SIG-B field.
Definition: wifi-phy-common.h:189
ns3::WIFI_PPDU_TYPE_SU
@ WIFI_PPDU_TYPE_SU
Definition: wifi-phy-common.h:230
ns3::WIFI_PPDU_FIELD_NON_HT_HEADER
@ 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...
Definition: wifi-phy-common.h:185
ns3::WIFI_PREAMBLE_SHORT
@ WIFI_PREAMBLE_SHORT
Definition: wifi-phy-common.h:70
ns3::WIFI_MOD_CLASS_DSSS
@ WIFI_MOD_CLASS_DSSS
DSSS (Clause 15)
Definition: wifi-phy-common.h:126
ns3::WifiModulationClass
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
Definition: wifi-phy-common.h:122
ns3::IsDlMu
bool IsDlMu(WifiPreamble preamble)
Return true if a preamble corresponds to a downlink multi-user transmission.
Definition: wifi-phy-common.cc:164