1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3 * Copyright (c) 2007 INRIA
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 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 */
20
21 #ifndef WIFI_STANDARD_H
22 #define WIFI_STANDARD_H
23
24 #include <map>
25 #include "wifi-phy-band.h"
26 #include "ns3/abort.h"
27
28 namespace ns3 {
29
30 /**
31 * \ingroup wifi
32 * Identifies the PHY specification that a Wifi device is configured to use.
33 */
34 enum WifiPhyStandard
35 {
36 /** OFDM PHY (Clause 17) */
37 WIFI_PHY_STANDARD_80211a,
38 /** DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18) */
39 WIFI_PHY_STANDARD_80211b,
40 /** ERP-OFDM PHY (Clause 19, Section 19.5) */
41 WIFI_PHY_STANDARD_80211g,
42 /** OFDM PHY (Clause 17 - amendment for 10 MHz and 5 MHz channels) */
43 WIFI_PHY_STANDARD_80211p,
44 /** HT PHY (clause 20) */
45 WIFI_PHY_STANDARD_80211n,
46 /** VHT PHY (clause 22) */
47 WIFI_PHY_STANDARD_80211ac,
48 /** HE PHY (clause 26) */
49 WIFI_PHY_STANDARD_80211ax,
50 /** Unspecified */
51 WIFI_PHY_STANDARD_UNSPECIFIED
52 };
53
54 /**
55 * \brief Stream insertion operator.
56 *
57 * \param os the stream
58 * \param standard the PHY standard
59 * \returns a reference to the stream
60 */
61 inline std::ostream& operator<< (std::ostream& os, WifiPhyStandard standard)
62 {
63 switch (standard)
64 {
65 case WIFI_PHY_STANDARD_80211a:
66 return (os << "802.11a");
67 case WIFI_PHY_STANDARD_80211b:
68 return (os << "802.11b");
69 case WIFI_PHY_STANDARD_80211g:
70 return (os << "802.11g");
71 case WIFI_PHY_STANDARD_80211p:
72 return (os << "802.11p");
73 case WIFI_PHY_STANDARD_80211n:
74 return (os << "802.11n");
75 case WIFI_PHY_STANDARD_80211ac:
76 return (os << "802.11ac");
77 case WIFI_PHY_STANDARD_80211ax:
78 return (os << "802.11ax");
79 case WIFI_PHY_STANDARD_UNSPECIFIED:
80 default:
81 return (os << "UNSPECIFIED");
82 }
83 }
84
85 /**
86 * \ingroup wifi
87 * Identifies the MAC specification that a Wifi device is configured to use.
88 */
89 enum WifiMacStandard
90 {
91 WIFI_MAC_STANDARD_80211,
92 WIFI_MAC_STANDARD_80211n,
93 WIFI_MAC_STANDARD_80211ac,
94 WIFI_MAC_STANDARD_80211ax
95 };
96
97 /**
98 * \brief Stream insertion operator.
99 *
100 * \param os the stream
101 * \param standard the MAC standard
102 * \returns a reference to the stream
103 */
104 inline std::ostream& operator<< (std::ostream& os, WifiMacStandard standard)
105 {
106 switch (standard)
107 {
108 case WIFI_MAC_STANDARD_80211:
109 return (os << "802.11");
110 case WIFI_MAC_STANDARD_80211n:
111 return (os << "802.11n");
112 case WIFI_MAC_STANDARD_80211ac:
113 return (os << "802.11ac");
114 case WIFI_MAC_STANDARD_80211ax:
115 return (os << "802.11ax");
116 default:
117 return (os << "UNSPECIFIED");
118 }
119 }
120
121 /**
122 * \ingroup wifi
123 * Identifies the allowed configurations that a Wifi device is configured to use.
124 */
125 enum WifiStandard
126 {
127 WIFI_STANDARD_80211a,
128 WIFI_STANDARD_80211b,
129 WIFI_STANDARD_80211g,
130 WIFI_STANDARD_80211p,
131 WIFI_STANDARD_80211n_2_4GHZ,
132 WIFI_STANDARD_80211n_5GHZ,
133 WIFI_STANDARD_80211ac,
134 WIFI_STANDARD_80211ax_2_4GHZ,
135 WIFI_STANDARD_80211ax_5GHZ,
136 WIFI_STANDARD_80211ax_6GHZ
137 };
138
139 /**
140 * \brief Stream insertion operator.
141 *
142 * \param os the stream
143 * \param standard the standard
144 * \returns a reference to the stream
145 */
146 inline std::ostream& operator<< (std::ostream& os, WifiStandard standard)
147 {
148 switch (standard)
149 {
150 case WIFI_STANDARD_80211a:
151 return (os << "802.11a");
152 case WIFI_STANDARD_80211b:
153 return (os << "802.11b");
154 case WIFI_STANDARD_80211g:
155 return (os << "802.11g");
156 case WIFI_STANDARD_80211p:
157 return (os << "802.11p");
158 case WIFI_STANDARD_80211n_2_4GHZ:
159 return (os << "802.11n-2.4GHz");
160 case WIFI_STANDARD_80211n_5GHZ:
161 return (os << "802.11n-5GHz");
162 case WIFI_STANDARD_80211ac:
163 return (os << "802.11ac");
164 case WIFI_STANDARD_80211ax_2_4GHZ:
165 return (os << "802.11ax-2.4GHz");
166 case WIFI_STANDARD_80211ax_5GHZ:
167 return (os << "802.11ax-5GHz");
168 case WIFI_STANDARD_80211ax_6GHZ:
169 return (os << "802.11ax-6GHz");
170 default:
171 return (os << "UNSPECIFIED");
172 }
173 }
174
175 /**
176 * \brief hold PHY and MAC information based on the selected standard.
177 */
178 struct WifiStandardInfo
179 {
180 WifiPhyStandard phyStandard; //!< the PHY standard
181 WifiPhyBand phyBand; //!< the PHY band
182 WifiMacStandard macStandard; //!< the MAC standard
183 };
184
185 /**
186 * \brief map a given standard configured by the user to the corresponding WifiStandardInfo
187 */
188 const std::map<WifiStandard, WifiStandardInfo> wifiStandards =
189 {
190 { WIFI_STANDARD_80211a, { WIFI_PHY_STANDARD_80211a, WIFI_PHY_BAND_5GHZ, WIFI_MAC_STANDARD_80211 } },
191 { WIFI_STANDARD_80211b, { WIFI_PHY_STANDARD_80211b, WIFI_PHY_BAND_2_4GHZ, WIFI_MAC_STANDARD_80211 } },
192 { WIFI_STANDARD_80211g, { WIFI_PHY_STANDARD_80211g, WIFI_PHY_BAND_2_4GHZ, WIFI_MAC_STANDARD_80211 } },
193 { WIFI_STANDARD_80211p, { WIFI_PHY_STANDARD_80211p, WIFI_PHY_BAND_5GHZ, WIFI_MAC_STANDARD_80211 } },
194 { WIFI_STANDARD_80211n_2_4GHZ, { WIFI_PHY_STANDARD_80211n, WIFI_PHY_BAND_2_4GHZ, WIFI_MAC_STANDARD_80211n } },
195 { WIFI_STANDARD_80211n_5GHZ, { WIFI_PHY_STANDARD_80211n, WIFI_PHY_BAND_5GHZ, WIFI_MAC_STANDARD_80211n } },
196 { WIFI_STANDARD_80211ac, { WIFI_PHY_STANDARD_80211ac, WIFI_PHY_BAND_5GHZ, WIFI_MAC_STANDARD_80211ac } },
197 { WIFI_STANDARD_80211ax_2_4GHZ, { WIFI_PHY_STANDARD_80211ax, WIFI_PHY_BAND_2_4GHZ, WIFI_MAC_STANDARD_80211ax } },
198 { WIFI_STANDARD_80211ax_5GHZ, { WIFI_PHY_STANDARD_80211ax, WIFI_PHY_BAND_5GHZ, WIFI_MAC_STANDARD_80211ax } },
199 { WIFI_STANDARD_80211ax_6GHZ, { WIFI_PHY_STANDARD_80211ax, WIFI_PHY_BAND_6GHZ, WIFI_MAC_STANDARD_80211ax } }
200 };
201
202 /**
203 * \ingroup wifi
204 * \brief Enumeration of frequency channel types
205 */
206 enum FrequencyChannelType : uint8_t
207 {
208 WIFI_PHY_DSSS_CHANNEL = 0,
209 WIFI_PHY_OFDM_CHANNEL,
210 WIFI_PHY_80211p_CHANNEL
211 };
212
213 /**
214 * Get the type of the frequency channel for the given PHY standard
215 *
216 * \param standard the PHY standard
217 * \return the type of the frequency channel for the given PHY standard
218 */
GetFrequencyChannelType(WifiPhyStandard standard)219 inline FrequencyChannelType GetFrequencyChannelType (WifiPhyStandard standard)
220 {
221 switch (standard)
222 {
223 case WIFI_PHY_STANDARD_80211b:
224 return WIFI_PHY_DSSS_CHANNEL;
225 case WIFI_PHY_STANDARD_80211p:
226 return WIFI_PHY_80211p_CHANNEL;
227 default:
228 return WIFI_PHY_OFDM_CHANNEL;
229 }
230 }
231
232 /**
233 * Get the maximum channel width in MHz allowed for the given PHY standard.
234 *
235 * \param standard the PHY standard
236 * \return the maximum channel width in MHz allowed for the given PHY standard
237 */
GetMaximumChannelWidth(WifiPhyStandard standard)238 inline uint16_t GetMaximumChannelWidth (WifiPhyStandard standard)
239 {
240 switch (standard)
241 {
242 case WIFI_PHY_STANDARD_80211b:
243 return 22;
244 case WIFI_PHY_STANDARD_80211p:
245 return 10;
246 case WIFI_PHY_STANDARD_80211a:
247 case WIFI_PHY_STANDARD_80211g:
248 return 20;
249 case WIFI_PHY_STANDARD_80211n:
250 return 40;
251 case WIFI_PHY_STANDARD_80211ac:
252 case WIFI_PHY_STANDARD_80211ax:
253 return 160;
254 default:
255 NS_ABORT_MSG ("Unknown standard: " << standard);
256 return 0;
257 }
258 }
259
260 /**
261 * Get the default channel width for the given PHY standard and band.
262 *
263 * \param standard the given PHY standard
264 * \param band the given PHY band
265 * \return the default channel width (MHz) for the given PHY standard
266 */
GetDefaultChannelWidth(WifiPhyStandard standard,WifiPhyBand band)267 inline uint16_t GetDefaultChannelWidth (WifiPhyStandard standard, WifiPhyBand band)
268 {
269 switch (standard)
270 {
271 case WIFI_PHY_STANDARD_80211b:
272 return 22;
273 case WIFI_PHY_STANDARD_80211p:
274 return 10;
275 case WIFI_PHY_STANDARD_80211ac:
276 return 80;
277 case WIFI_PHY_STANDARD_80211ax:
278 return (band == WIFI_PHY_BAND_2_4GHZ ? 20 : 80);
279 default:
280 return 20;
281 }
282 }
283
284 } //namespace ns3
285
286 #endif /* WIFI_STANDARD_H */
287