A Discrete-Event Network Simulator
API
wifi-phy-operating-channel.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Stefano Avallone <stavallo@unina.it>
18 * Sébastien Deronne <sebastien.deronne@gmail.com>
19 */
20
22
23#include "ns3/assert.h"
24#include "ns3/log.h"
25
26#include <algorithm>
27
28namespace ns3
29{
30
31NS_LOG_COMPONENT_DEFINE("WifiPhyOperatingChannel");
32
33const std::set<FrequencyChannelInfo> WifiPhyOperatingChannel::m_frequencyChannels = {
34 // 2.4 GHz channels
35 // 802.11b uses width of 22, while OFDM modes use width of 20
36 {std::make_tuple(1, 2412, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
37 {std::make_tuple(1, 2412, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
38 {std::make_tuple(2, 2417, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
39 {std::make_tuple(2, 2417, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
40 {std::make_tuple(3, 2422, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
41 {std::make_tuple(3, 2422, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
42 {std::make_tuple(4, 2427, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
43 {std::make_tuple(4, 2427, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
44 {std::make_tuple(5, 2432, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
45 {std::make_tuple(5, 2432, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
46 {std::make_tuple(6, 2437, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
47 {std::make_tuple(6, 2437, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
48 {std::make_tuple(7, 2442, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
49 {std::make_tuple(7, 2442, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
50 {std::make_tuple(8, 2447, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
51 {std::make_tuple(8, 2447, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
52 {std::make_tuple(9, 2452, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
53 {std::make_tuple(9, 2452, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
54 {std::make_tuple(10, 2457, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
55 {std::make_tuple(10, 2457, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
56 {std::make_tuple(11, 2462, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
57 {std::make_tuple(11, 2462, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
58 {std::make_tuple(12, 2467, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
59 {std::make_tuple(12, 2467, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
60 {std::make_tuple(13, 2472, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
61 {std::make_tuple(13, 2472, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
62 // Only defined for 802.11b
63 {std::make_tuple(14, 2484, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
64 // 40 MHz channels
65 {std::make_tuple(3, 2422, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
66 {std::make_tuple(4, 2427, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
67 {std::make_tuple(5, 2432, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
68 {std::make_tuple(6, 2437, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
69 {std::make_tuple(7, 2442, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
70 {std::make_tuple(8, 2447, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
71 {std::make_tuple(9, 2452, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
72 {std::make_tuple(10, 2457, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
73 {std::make_tuple(11, 2462, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ)},
74
75 // Now the 5 GHz channels used for 802.11a/n/ac/ax/be
76 // 20 MHz channels
77 {std::make_tuple(36, 5180, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
78 {std::make_tuple(40, 5200, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
79 {std::make_tuple(44, 5220, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
80 {std::make_tuple(48, 5240, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
81 {std::make_tuple(52, 5260, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
82 {std::make_tuple(56, 5280, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
83 {std::make_tuple(60, 5300, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
84 {std::make_tuple(64, 5320, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
85 {std::make_tuple(100, 5500, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
86 {std::make_tuple(104, 5520, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
87 {std::make_tuple(108, 5540, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
88 {std::make_tuple(112, 5560, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
89 {std::make_tuple(116, 5580, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
90 {std::make_tuple(120, 5600, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
91 {std::make_tuple(124, 5620, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
92 {std::make_tuple(128, 5640, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
93 {std::make_tuple(132, 5660, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
94 {std::make_tuple(136, 5680, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
95 {std::make_tuple(140, 5700, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
96 {std::make_tuple(144, 5720, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
97 {std::make_tuple(149, 5745, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
98 {std::make_tuple(153, 5765, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
99 {std::make_tuple(157, 5785, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
100 {std::make_tuple(161, 5805, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
101 {std::make_tuple(165, 5825, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
102 {std::make_tuple(169, 5845, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
103 {std::make_tuple(173, 5865, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
104 {std::make_tuple(177, 5885, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
105 {std::make_tuple(181, 5905, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
106 // 40 MHz channels
107 {std::make_tuple(38, 5190, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
108 {std::make_tuple(46, 5230, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
109 {std::make_tuple(54, 5270, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
110 {std::make_tuple(62, 5310, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
111 {std::make_tuple(102, 5510, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
112 {std::make_tuple(110, 5550, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
113 {std::make_tuple(118, 5590, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
114 {std::make_tuple(126, 5630, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
115 {std::make_tuple(134, 5670, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
116 {std::make_tuple(142, 5710, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
117 {std::make_tuple(151, 5755, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
118 {std::make_tuple(159, 5795, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
119 {std::make_tuple(167, 5835, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
120 {std::make_tuple(175, 5875, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
121 // 80 MHz channels
122 {std::make_tuple(42, 5210, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
123 {std::make_tuple(58, 5290, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
124 {std::make_tuple(106, 5530, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
125 {std::make_tuple(122, 5610, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
126 {std::make_tuple(138, 5690, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
127 {std::make_tuple(155, 5775, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
128 {std::make_tuple(171, 5855, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
129 // 160 MHz channels
130 {std::make_tuple(50, 5250, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
131 {std::make_tuple(114, 5570, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
132 {std::make_tuple(163, 5815, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ)},
133
134 // 802.11p 10 MHz channels at the 5.855-5.925 band
135 {std::make_tuple(172, 5860, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
136 {std::make_tuple(174, 5870, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
137 {std::make_tuple(176, 5880, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
138 {std::make_tuple(178, 5890, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
139 {std::make_tuple(180, 5900, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
140 {std::make_tuple(182, 5910, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
141 {std::make_tuple(184, 5920, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
142
143 // 802.11p 5 MHz channels at the 5.855-5.925 band (for simplification, we consider the same
144 // center frequencies as the 10 MHz channels)
145 {std::make_tuple(171, 5860, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
146 {std::make_tuple(173, 5870, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
147 {std::make_tuple(175, 5880, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
148 {std::make_tuple(177, 5890, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
149 {std::make_tuple(179, 5900, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
150 {std::make_tuple(181, 5910, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
151 {std::make_tuple(183, 5920, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ)},
152
153 // Now the 6 GHz channels for 802.11ax/be
154 // 20 MHz channels
155 {std::make_tuple(1, 5945, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
156 {std::make_tuple(5, 5965, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
157 {std::make_tuple(9, 5985, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
158 {std::make_tuple(13, 6005, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
159 {std::make_tuple(17, 6025, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
160 {std::make_tuple(21, 6045, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
161 {std::make_tuple(25, 6065, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
162 {std::make_tuple(29, 6085, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
163 {std::make_tuple(33, 6105, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
164 {std::make_tuple(37, 6125, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
165 {std::make_tuple(41, 6145, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
166 {std::make_tuple(45, 6165, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
167 {std::make_tuple(49, 6185, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
168 {std::make_tuple(53, 6205, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
169 {std::make_tuple(57, 6225, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
170 {std::make_tuple(61, 6245, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
171 {std::make_tuple(65, 6265, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
172 {std::make_tuple(69, 6285, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
173 {std::make_tuple(73, 6305, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
174 {std::make_tuple(77, 6325, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
175 {std::make_tuple(81, 6345, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
176 {std::make_tuple(85, 6365, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
177 {std::make_tuple(89, 6385, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
178 {std::make_tuple(93, 6405, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
179 {std::make_tuple(97, 6425, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
180 {std::make_tuple(101, 6445, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
181 {std::make_tuple(105, 6465, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
182 {std::make_tuple(109, 6485, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
183 {std::make_tuple(113, 6505, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
184 {std::make_tuple(117, 6525, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
185 {std::make_tuple(121, 6545, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
186 {std::make_tuple(125, 6565, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
187 {std::make_tuple(129, 6585, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
188 {std::make_tuple(133, 6605, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
189 {std::make_tuple(137, 6625, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
190 {std::make_tuple(141, 6645, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
191 {std::make_tuple(145, 6665, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
192 {std::make_tuple(149, 6685, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
193 {std::make_tuple(153, 6705, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
194 {std::make_tuple(157, 6725, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
195 {std::make_tuple(161, 6745, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
196 {std::make_tuple(165, 6765, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
197 {std::make_tuple(169, 6785, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
198 {std::make_tuple(173, 6805, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
199 {std::make_tuple(177, 6825, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
200 {std::make_tuple(181, 6845, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
201 {std::make_tuple(185, 6865, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
202 {std::make_tuple(189, 6885, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
203 {std::make_tuple(193, 6905, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
204 {std::make_tuple(197, 6925, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
205 {std::make_tuple(201, 6945, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
206 {std::make_tuple(205, 6965, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
207 {std::make_tuple(209, 6985, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
208 {std::make_tuple(213, 7005, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
209 {std::make_tuple(217, 7025, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
210 {std::make_tuple(221, 7045, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
211 {std::make_tuple(225, 7065, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
212 {std::make_tuple(229, 7085, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
213 {std::make_tuple(233, 7105, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
214 // 40 MHz channels
215 {std::make_tuple(3, 5955, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
216 {std::make_tuple(11, 5995, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
217 {std::make_tuple(19, 6035, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
218 {std::make_tuple(27, 6075, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
219 {std::make_tuple(35, 6115, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
220 {std::make_tuple(43, 6155, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
221 {std::make_tuple(51, 6195, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
222 {std::make_tuple(59, 6235, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
223 {std::make_tuple(67, 6275, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
224 {std::make_tuple(75, 6315, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
225 {std::make_tuple(83, 6355, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
226 {std::make_tuple(91, 6395, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
227 {std::make_tuple(99, 6435, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
228 {std::make_tuple(107, 6475, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
229 {std::make_tuple(115, 6515, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
230 {std::make_tuple(123, 6555, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
231 {std::make_tuple(131, 6595, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
232 {std::make_tuple(139, 6635, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
233 {std::make_tuple(147, 6675, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
234 {std::make_tuple(155, 6715, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
235 {std::make_tuple(163, 6755, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
236 {std::make_tuple(171, 6795, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
237 {std::make_tuple(179, 6835, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
238 {std::make_tuple(187, 6875, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
239 {std::make_tuple(195, 6915, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
240 {std::make_tuple(203, 6955, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
241 {std::make_tuple(211, 6995, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
242 {std::make_tuple(219, 7035, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
243 {std::make_tuple(227, 7075, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
244 // 80 MHz channels
245 {std::make_tuple(7, 5975, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
246 {std::make_tuple(23, 6055, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
247 {std::make_tuple(39, 6135, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
248 {std::make_tuple(55, 6215, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
249 {std::make_tuple(71, 6295, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
250 {std::make_tuple(87, 6375, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
251 {std::make_tuple(103, 6455, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
252 {std::make_tuple(119, 6535, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
253 {std::make_tuple(135, 6615, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
254 {std::make_tuple(151, 6695, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
255 {std::make_tuple(167, 6775, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
256 {std::make_tuple(183, 6855, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
257 {std::make_tuple(199, 6935, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
258 {std::make_tuple(215, 7015, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
259 // 160 MHz channels
260 {std::make_tuple(15, 6015, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
261 {std::make_tuple(47, 6175, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
262 {std::make_tuple(79, 6335, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
263 {std::make_tuple(111, 6495, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
264 {std::make_tuple(143, 6655, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
265 {std::make_tuple(175, 6815, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)},
266 {std::make_tuple(207, 6975, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}};
267
269 : WifiPhyOperatingChannel(m_frequencyChannels.end())
270{
271}
272
274 : m_channelIt(it),
275 m_primary20Index(0)
276{
277 NS_LOG_FUNCTION(this);
278}
279
281{
283}
284
285bool
287{
288 return m_channelIt != m_frequencyChannels.end();
289}
290
291void
293 uint16_t frequency,
294 uint16_t width,
295 WifiStandard standard,
296 WifiPhyBand band)
297{
298 NS_LOG_FUNCTION(this << +number << frequency << width << standard << band);
299
300 auto channelIt = FindFirst(number, frequency, width, standard, band);
301
302 if (channelIt != m_frequencyChannels.end() &&
303 FindFirst(number, frequency, width, standard, band, std::next(channelIt)) ==
305 {
306 // a unique channel matches the specified criteria
307 m_channelIt = channelIt;
309 return;
310 }
311
312 // if a unique channel was not found, throw an exception (mainly for unit testing this code)
313 throw std::runtime_error(
314 "WifiPhyOperatingChannel: No unique channel found given the specified criteria");
315}
316
317void
319{
320 NS_LOG_FUNCTION(this << width << standard << band);
321
322 Set(GetDefaultChannelNumber(width, standard, band), 0, width, standard, band);
323}
324
325uint8_t
327 WifiStandard standard,
328 WifiPhyBand band)
329{
330 auto channelIt = FindFirst(0, 0, width, standard, band);
331
332 if (channelIt != m_frequencyChannels.end())
333 {
334 // a channel matches the specified criteria
335 return std::get<0>(*channelIt);
336 }
337
338 // if a default channel was not found, throw an exception (mainly for unit testing this code)
339 throw std::runtime_error("WifiPhyOperatingChannel: No default channel found of the given width "
340 "and for the given PHY standard and band");
341}
342
345 uint16_t frequency,
346 uint16_t width,
347 WifiStandard standard,
348 WifiPhyBand band,
350{
351 // lambda used to match channels against the specified criteria
352 auto predicate = [&](const FrequencyChannelInfo& channel) {
353 if (number != 0 && std::get<0>(channel) != number)
354 {
355 return false;
356 }
357 if (frequency != 0 && std::get<1>(channel) != frequency)
358 {
359 return false;
360 }
361 if (width != 0 && std::get<2>(channel) != width)
362 {
363 return false;
364 }
365 if (standard != WIFI_STANDARD_UNSPECIFIED &&
366 std::get<3>(channel) != GetFrequencyChannelType(standard))
367 {
368 return false;
369 }
370 if (std::get<4>(channel) != band)
371 {
372 return false;
373 }
374 return true;
375 };
376
377 // Do not search for a channel matching the specified criteria if the given PHY band
378 // is not allowed for the given standard (if any) or the given channel width is not
379 // allowed for the given standard (if any)
380 if (const auto standardIt = wifiStandards.find(standard);
381 standardIt != wifiStandards.cend() &&
382 (std::find(standardIt->second.cbegin(), standardIt->second.cend(), band) ==
383 standardIt->second.cend() ||
384 width > GetMaximumChannelWidth(standard)))
385 {
386 return m_frequencyChannels.cend();
387 }
388
389 return std::find_if(start, m_frequencyChannels.cend(), predicate);
390}
391
392uint8_t
394{
395 NS_ASSERT(IsSet());
396 return std::get<0>(*m_channelIt);
397}
398
399uint16_t
401{
402 NS_ASSERT(IsSet());
403 return std::get<1>(*m_channelIt);
404}
405
406uint16_t
408{
409 NS_ASSERT(IsSet());
410 return std::get<2>(*m_channelIt);
411}
412
415{
416 NS_ASSERT(IsSet());
417 return std::get<4>(*m_channelIt);
418}
419
420bool
422{
423 NS_ASSERT(IsSet());
424 return std::get<FrequencyChannelType>(*m_channelIt) == WIFI_PHY_OFDM_CHANNEL;
425}
426
427bool
429{
430 NS_ASSERT(IsSet());
431 return std::get<FrequencyChannelType>(*m_channelIt) == WIFI_PHY_DSSS_CHANNEL;
432}
433
434bool
436{
437 NS_ASSERT(IsSet());
438 return std::get<FrequencyChannelType>(*m_channelIt) == WIFI_PHY_80211p_CHANNEL;
439}
440
441uint8_t
442WifiPhyOperatingChannel::GetPrimaryChannelIndex(uint16_t primaryChannelWidth) const
443{
444 NS_LOG_FUNCTION(this << primaryChannelWidth);
445
446 if (primaryChannelWidth % 20 != 0)
447 {
448 NS_LOG_DEBUG("The operating channel width is not a multiple of 20 MHz; return 0");
449 return 0;
450 }
451
452 NS_ASSERT(primaryChannelWidth <= GetWidth());
453
454 // the index of primary40 is half the index of primary20; the index of
455 // primary80 is half the index of primary40, ...
456 uint16_t width = 20;
457 uint8_t index = m_primary20Index;
458
459 while (width < primaryChannelWidth)
460 {
461 index /= 2;
462 width *= 2;
463 }
464 NS_LOG_LOGIC("Return primary index " << +index);
465 return index;
466}
467
468uint8_t
469WifiPhyOperatingChannel::GetSecondaryChannelIndex(uint16_t secondaryChannelWidth) const
470{
471 NS_LOG_FUNCTION(this << secondaryChannelWidth);
472 const uint8_t primaryIndex = GetPrimaryChannelIndex(secondaryChannelWidth);
473 const uint8_t secondaryIndex =
474 (primaryIndex % 2 == 0) ? (primaryIndex + 1) : (primaryIndex - 1);
475 NS_LOG_LOGIC("Return secondary index " << +secondaryIndex);
476 return secondaryIndex;
477}
478
479void
481{
482 NS_LOG_FUNCTION(this << +index);
483
484 NS_ABORT_MSG_IF(index > 0 && index >= GetWidth() / 20, "Primary20 index out of range");
485 m_primary20Index = index;
486}
487
488uint16_t
490{
491 uint16_t freq = GetFrequency() - GetWidth() / 2. +
492 (GetPrimaryChannelIndex(primaryChannelWidth) + 0.5) * primaryChannelWidth;
493
494 NS_LOG_FUNCTION(this << primaryChannelWidth << freq);
495 return freq;
496}
497
498uint16_t
500{
501 const uint8_t primaryIndex = GetPrimaryChannelIndex(secondaryChannelWidth);
502 const uint16_t primaryCenterFrequency = GetPrimaryChannelCenterFrequency(secondaryChannelWidth);
503 return (primaryIndex % 2 == 0) ? (primaryCenterFrequency + secondaryChannelWidth)
504 : (primaryCenterFrequency - secondaryChannelWidth);
505}
506
507uint8_t
509 WifiStandard standard) const
510{
511 auto frequency = GetPrimaryChannelCenterFrequency(primaryChannelWidth);
512 auto& [chanNumber, centerFreq, channelWidth, channelType, band] = *m_channelIt;
513 auto primaryChanIt = FindFirst(0, frequency, primaryChannelWidth, standard, band);
514 return std::get<0>(*primaryChanIt);
515}
516
517std::set<uint8_t>
519{
520 if (width > GetWidth())
521 {
522 // a primary channel of the given width does not exist
523 return {};
524 }
525
526 uint16_t currWidth = 20; // MHz
527 std::set<uint8_t> indices;
528 indices.insert(m_primary20Index);
529
530 while (currWidth < width)
531 {
532 indices.merge(GetAll20MHzChannelIndicesInSecondary(indices));
533 currWidth <<= 1;
534 }
535
536 return indices;
537}
538
539std::set<uint8_t>
541{
543}
544
545std::set<uint8_t>
547 const std::set<uint8_t>& primaryIndices) const
548{
549 if (primaryIndices.empty() || GetWidth() == 20)
550 {
551 return {};
552 }
553
554 uint8_t size = 1;
555 uint16_t primaryWidth = 20; // MHz
556
557 // find the width of the primary channel corresponding to the size of the given set
558 while (size != primaryIndices.size())
559 {
560 size <<= 1;
561 primaryWidth <<= 1;
562
563 if (primaryWidth >= GetWidth())
564 {
565 // the width of the primary channel resulting from the given indices
566 // exceeds the width of the operating channel
567 return {};
568 }
569 }
570
571 std::set<uint8_t> secondaryIndices;
572 for (const auto& index : primaryIndices)
573 {
574 secondaryIndices.insert(index ^ size);
575 }
576
577 return secondaryIndices;
578}
579
580} // namespace ns3
Class that keeps track of all information about the current PHY operating channel.
bool IsSet() const
Return true if a valid channel has been set, false otherwise.
WifiPhyOperatingChannel()
Create an uninitialized PHY operating channel.
static const std::set< FrequencyChannelInfo > m_frequencyChannels
Available frequency channels.
uint16_t GetSecondaryChannelCenterFrequency(uint16_t secondaryChannelWidth) const
Get the center frequency of the secondary channel of the given width.
bool IsDsss() const
Return whether the operating channel is a DSSS channel.
uint8_t GetPrimaryChannelIndex(uint16_t primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
ConstIterator m_channelIt
const iterator pointing to the configured frequency channel
static ConstIterator FindFirst(uint8_t number, uint16_t frequency, uint16_t width, WifiStandard standard, WifiPhyBand band, ConstIterator start=m_frequencyChannels.begin())
Find the first channel matching the specified parameters.
void Set(uint8_t number, uint16_t frequency, uint16_t width, WifiStandard standard, WifiPhyBand band)
Set the channel according to the specified parameters if a unique frequency channel matches the speci...
bool Is80211p() const
Return whether the operating channel is an 802.11p channel.
uint8_t GetPrimaryChannelNumber(uint16_t primaryChannelWidth, WifiStandard standard) const
Get channel number of the primary channel.
void SetDefault(uint16_t width, WifiStandard standard, WifiPhyBand band)
Set the default channel of the given width and for the given standard and band.
bool IsOfdm() const
Return whether the operating channel is an OFDM channel.
uint16_t GetWidth() const
Return the width of the whole operating channel (in MHz).
static uint8_t GetDefaultChannelNumber(uint16_t width, WifiStandard standard, WifiPhyBand band)
Get the default channel number of the given width and for the given standard and band.
std::set< uint8_t > GetAll20MHzChannelIndicesInSecondary(uint16_t width) const
Get the channel indices of all the 20 MHz channels included in the secondary channel of the given wid...
uint8_t GetSecondaryChannelIndex(uint16_t secondaryChannelWidth) const
If the operating channel width is made of a multiple of 20 MHz, return the index of the secondary cha...
uint8_t m_primary20Index
index of the primary20 channel (0 indicates the 20 MHz subchannel with the lowest center frequency)
std::set< uint8_t > GetAll20MHzChannelIndicesInPrimary(uint16_t width) const
Get the channel indices of all the 20 MHz channels included in the primary channel of the given width...
WifiPhyBand GetPhyBand() const
Return the PHY band of the operating channel.
uint8_t GetNumber() const
Return the channel number identifying the whole operating channel.
uint16_t GetPrimaryChannelCenterFrequency(uint16_t primaryChannelWidth) const
Get the center frequency of the primary channel of the given width.
std::set< FrequencyChannelInfo >::const_iterator ConstIterator
Typedef for a const iterator pointing to a channel in the set of available channels.
uint16_t GetFrequency() const
Return the center frequency of the operating channel (in MHz).
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:33
@ WIFI_STANDARD_UNSPECIFIED
@ WIFI_PHY_80211p_CHANNEL
@ WIFI_PHY_OFDM_CHANNEL
@ WIFI_PHY_DSSS_CHANNEL
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
Definition: wifi-phy-band.h:39
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
Definition: wifi-phy-band.h:35
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Definition: wifi-phy-band.h:37
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::tuple< uint8_t, uint16_t, uint16_t, FrequencyChannelType, WifiPhyBand > FrequencyChannelInfo
A tuple (number, frequency, width, type, band) identifying a frequency channel.
const std::map< WifiStandard, std::list< WifiPhyBand > > wifiStandards
map a given standard configured by the user to the allowed PHY bands
FrequencyChannelType GetFrequencyChannelType(WifiStandard standard)
Get the type of the frequency channel for the given standard.
uint16_t GetMaximumChannelWidth(WifiStandard standard)
Get the maximum channel width in MHz allowed for the given standard.
channel
Definition: third.py:81
def start()
Definition: core.py:1861