A Discrete-Event Network Simulator
API
wifi-phy.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 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  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * S├ębastien Deronne <sebastien.deronne@gmail.com>
20  */
21 
22 #include <algorithm>
23 #include "ns3/simulator.h"
24 #include "ns3/log.h"
25 #include "ns3/pointer.h"
26 #include "ns3/mobility-model.h"
27 #include "ns3/random-variable-stream.h"
28 #include "ns3/error-model.h"
29 #include "wifi-phy.h"
30 #include "ampdu-tag.h"
31 #include "wifi-utils.h"
32 #include "sta-wifi-mac.h"
33 #include "frame-capture-model.h"
36 #include "error-rate-model.h"
37 #include "wifi-net-device.h"
38 #include "ns3/ht-configuration.h"
39 #include "ns3/he-configuration.h"
40 #include "mpdu-aggregator.h"
41 #include "wifi-psdu.h"
42 #include "wifi-ppdu.h"
43 #include "ap-wifi-mac.h"
44 #include "ns3/dsss-phy.h"
45 #include "ns3/erp-ofdm-phy.h"
46 #include "ns3/he-phy.h" //includes OFDM, HT, and VHT
47 
48 namespace ns3 {
49 
50 NS_LOG_COMPONENT_DEFINE ("WifiPhy");
51 
52 /****************************************************************
53  * The actual WifiPhy class
54  ****************************************************************/
55 
57 
58 const std::set<FrequencyChannelInfo> WifiPhy::m_frequencyChannels =
59 {
60  //2.4 GHz channels
61  // 802.11b uses width of 22, while OFDM modes use width of 20
62  { std::make_tuple (1, 2412, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
63  { std::make_tuple (1, 2412, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
64  { std::make_tuple (2, 2417, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
65  { std::make_tuple (2, 2417, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
66  { std::make_tuple (3, 2422, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
67  { std::make_tuple (3, 2422, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
68  { std::make_tuple (4, 2427, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
69  { std::make_tuple (4, 2427, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
70  { std::make_tuple (5, 2432, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
71  { std::make_tuple (5, 2432, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
72  { std::make_tuple (6, 2437, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
73  { std::make_tuple (6, 2437, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
74  { std::make_tuple (7, 2442, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
75  { std::make_tuple (7, 2442, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
76  { std::make_tuple (8, 2447, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
77  { std::make_tuple (8, 2447, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
78  { std::make_tuple (9, 2452, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
79  { std::make_tuple (9, 2452, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
80  { std::make_tuple (10, 2457, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
81  { std::make_tuple (10, 2457, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
82  { std::make_tuple (11, 2462, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
83  { std::make_tuple (11, 2462, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
84  { std::make_tuple (12, 2467, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
85  { std::make_tuple (12, 2467, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
86  { std::make_tuple (13, 2472, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
87  { std::make_tuple (13, 2472, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
88  // Only defined for 802.11b
89  { std::make_tuple (14, 2484, 22, WIFI_PHY_DSSS_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
90  // 40 MHz channels
91  { std::make_tuple (3, 2422, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
92  { std::make_tuple (4, 2427, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
93  { std::make_tuple (5, 2432, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
94  { std::make_tuple (6, 2437, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
95  { std::make_tuple (7, 2442, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
96  { std::make_tuple (8, 2447, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
97  { std::make_tuple (9, 2452, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
98  { std::make_tuple (10, 2457, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
99  { std::make_tuple (11, 2462, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_2_4GHZ) },
100 
101  // Now the 5 GHz channels used for 802.11a/n/ac/ax
102  // 20 MHz channels
103  { std::make_tuple (36, 5180, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
104  { std::make_tuple (40, 5200, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
105  { std::make_tuple (44, 5220, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
106  { std::make_tuple (48, 5240, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
107  { std::make_tuple (52, 5260, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
108  { std::make_tuple (56, 5280, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
109  { std::make_tuple (60, 5300, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
110  { std::make_tuple (64, 5320, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
111  { std::make_tuple (100, 5500, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
112  { std::make_tuple (104, 5520, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
113  { std::make_tuple (108, 5540, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
114  { std::make_tuple (112, 5560, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
115  { std::make_tuple (116, 5580, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
116  { std::make_tuple (120, 5600, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
117  { std::make_tuple (124, 5620, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
118  { std::make_tuple (128, 5640, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
119  { std::make_tuple (132, 5660, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
120  { std::make_tuple (136, 5680, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
121  { std::make_tuple (140, 5700, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
122  { std::make_tuple (144, 5720, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
123  { std::make_tuple (149, 5745, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
124  { std::make_tuple (153, 5765, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
125  { std::make_tuple (157, 5785, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
126  { std::make_tuple (161, 5805, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
127  { std::make_tuple (165, 5825, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
128  { std::make_tuple (169, 5845, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
129  { std::make_tuple (173, 5865, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
130  { std::make_tuple (177, 5885, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
131  { std::make_tuple (181, 5905, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
132  // 40 MHz channels
133  { std::make_tuple (38, 5190, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
134  { std::make_tuple (46, 5230, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
135  { std::make_tuple (54, 5270, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
136  { std::make_tuple (62, 5310, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
137  { std::make_tuple (102, 5510, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
138  { std::make_tuple (110, 5550, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
139  { std::make_tuple (118, 5590, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
140  { std::make_tuple (126, 5630, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
141  { std::make_tuple (134, 5670, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
142  { std::make_tuple (142, 5710, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
143  { std::make_tuple (151, 5755, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
144  { std::make_tuple (159, 5795, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
145  { std::make_tuple (167, 5835, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
146  { std::make_tuple (175, 5875, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
147  // 80 MHz channels
148  { std::make_tuple (42, 5210, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
149  { std::make_tuple (58, 5290, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
150  { std::make_tuple (106, 5530, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
151  { std::make_tuple (122, 5610, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
152  { std::make_tuple (138, 5690, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
153  { std::make_tuple (155, 5775, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
154  { std::make_tuple (171, 5855, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
155  // 160 MHz channels
156  { std::make_tuple (50, 5250, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
157  { std::make_tuple (114, 5570, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
158  { std::make_tuple (163, 5815, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_5GHZ) },
159 
160  // 802.11p 10 MHz channels at the 5.855-5.925 band
161  { std::make_tuple (172, 5860, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
162  { std::make_tuple (174, 5870, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
163  { std::make_tuple (176, 5880, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
164  { std::make_tuple (178, 5890, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
165  { std::make_tuple (180, 5900, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
166  { std::make_tuple (182, 5910, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
167  { std::make_tuple (184, 5920, 10, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
168 
169  // 802.11p 5 MHz channels at the 5.855-5.925 band (for simplification, we consider the same center frequencies as the 10 MHz channels)
170  { std::make_tuple (171, 5860, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
171  { std::make_tuple (173, 5870, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
172  { std::make_tuple (175, 5880, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
173  { std::make_tuple (177, 5890, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
174  { std::make_tuple (179, 5900, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
175  { std::make_tuple (181, 5910, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
176  { std::make_tuple (183, 5920, 5, WIFI_PHY_80211p_CHANNEL, WIFI_PHY_BAND_5GHZ) },
177 
178  // Now the 6 GHz channels (802.11ax only)
179  // 20 MHz channels
180  { std::make_tuple (1, 5945, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
181  { std::make_tuple (5, 5965, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
182  { std::make_tuple (9, 5985, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
183  { std::make_tuple (13, 6005, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
184  { std::make_tuple (17, 6025, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
185  { std::make_tuple (21, 6045, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
186  { std::make_tuple (25, 6065, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
187  { std::make_tuple (29, 6085, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
188  { std::make_tuple (33, 6105, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
189  { std::make_tuple (37, 6125, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
190  { std::make_tuple (41, 6145, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
191  { std::make_tuple (45, 6165, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
192  { std::make_tuple (49, 6185, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
193  { std::make_tuple (53, 6205, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
194  { std::make_tuple (57, 6225, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
195  { std::make_tuple (61, 6245, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
196  { std::make_tuple (65, 6265, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
197  { std::make_tuple (69, 6285, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
198  { std::make_tuple (73, 6305, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
199  { std::make_tuple (77, 6325, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
200  { std::make_tuple (81, 6345, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
201  { std::make_tuple (85, 6365, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
202  { std::make_tuple (89, 6385, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
203  { std::make_tuple (93, 6405, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
204  { std::make_tuple (97, 6425, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
205  { std::make_tuple (101, 6445, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
206  { std::make_tuple (105, 6465, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
207  { std::make_tuple (109, 6485, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
208  { std::make_tuple (113, 6505, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
209  { std::make_tuple (117, 6525, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
210  { std::make_tuple (121, 6545, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
211  { std::make_tuple (125, 6565, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
212  { std::make_tuple (129, 6585, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
213  { std::make_tuple (133, 6605, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
214  { std::make_tuple (137, 6625, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
215  { std::make_tuple (141, 6645, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
216  { std::make_tuple (145, 6665, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
217  { std::make_tuple (149, 6685, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
218  { std::make_tuple (153, 6705, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
219  { std::make_tuple (157, 6725, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
220  { std::make_tuple (161, 6745, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
221  { std::make_tuple (165, 6765, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
222  { std::make_tuple (169, 6785, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
223  { std::make_tuple (173, 6805, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
224  { std::make_tuple (177, 6825, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
225  { std::make_tuple (181, 6845, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
226  { std::make_tuple (185, 6865, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
227  { std::make_tuple (189, 6885, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
228  { std::make_tuple (193, 6905, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
229  { std::make_tuple (197, 6925, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
230  { std::make_tuple (201, 6945, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
231  { std::make_tuple (205, 6965, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
232  { std::make_tuple (209, 6985, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
233  { std::make_tuple (213, 7005, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
234  { std::make_tuple (217, 7025, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
235  { std::make_tuple (221, 7045, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
236  { std::make_tuple (225, 7065, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
237  { std::make_tuple (229, 7085, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
238  { std::make_tuple (233, 7105, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
239  // 40 MHz channels
240  { std::make_tuple (3, 5955, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
241  { std::make_tuple (11, 5995, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
242  { std::make_tuple (19, 6035, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
243  { std::make_tuple (27, 6075, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
244  { std::make_tuple (35, 6115, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
245  { std::make_tuple (43, 6155, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
246  { std::make_tuple (51, 6195, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
247  { std::make_tuple (59, 6235, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
248  { std::make_tuple (67, 6275, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
249  { std::make_tuple (75, 6315, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
250  { std::make_tuple (83, 6355, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
251  { std::make_tuple (91, 6395, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
252  { std::make_tuple (99, 6435, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
253  { std::make_tuple (107, 6475, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
254  { std::make_tuple (115, 6515, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
255  { std::make_tuple (123, 6555, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
256  { std::make_tuple (131, 6595, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
257  { std::make_tuple (139, 6635, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
258  { std::make_tuple (147, 6675, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
259  { std::make_tuple (155, 6715, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
260  { std::make_tuple (163, 6755, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
261  { std::make_tuple (171, 6795, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
262  { std::make_tuple (179, 6835, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
263  { std::make_tuple (187, 6875, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
264  { std::make_tuple (195, 6915, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
265  { std::make_tuple (203, 6955, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
266  { std::make_tuple (211, 6995, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
267  { std::make_tuple (219, 7035, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
268  { std::make_tuple (227, 7075, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
269  // 80 MHz channels
270  { std::make_tuple (7, 5975, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
271  { std::make_tuple (23, 6055, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
272  { std::make_tuple (39, 6135, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
273  { std::make_tuple (55, 6215, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
274  { std::make_tuple (71, 6295, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
275  { std::make_tuple (87, 6375, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
276  { std::make_tuple (103, 6455, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
277  { std::make_tuple (119, 6535, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
278  { std::make_tuple (135, 6615, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
279  { std::make_tuple (151, 6695, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
280  { std::make_tuple (167, 6775, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
281  { std::make_tuple (183, 6855, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
282  { std::make_tuple (199, 6935, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
283  { std::make_tuple (215, 7015, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
284  // 160 MHz channels
285  { std::make_tuple (15, 6015, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
286  { std::make_tuple (47, 6175, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
287  { std::make_tuple (79, 6335, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
288  { std::make_tuple (111, 6495, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
289  { std::make_tuple (143, 6655, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
290  { std::make_tuple (175, 6815, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) },
291  { std::make_tuple (207, 6975, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ) }
292 };
293 
294 std::map<WifiModulationClass, Ptr<PhyEntity> > WifiPhy::m_staticPhyEntities; //will be filled by g_constructor_XXX
295 
296 TypeId
298 {
299  static TypeId tid = TypeId ("ns3::WifiPhy")
300  .SetParent<Object> ()
301  .SetGroupName ("Wifi")
302  .AddAttribute ("Frequency",
303  "The center frequency (MHz) of the operating channel. "
304  "If the operating channel for this object has not been set yet, the "
305  "value of this attribute is saved and will be used, along with the channel "
306  "number and width configured via other attributes, to set the operating "
307  "channel when the standard and band are configured. The default value of "
308  "this attribute is 0, which means unspecified center frequency. Note that "
309  "if center frequency and channel number are both 0 when the standard and "
310  "band are configured, a default channel (of the configured width, if any, "
311  "or the default width for the current standard and band, otherwise) is set. "
312  "If the operating channel for this object has been already set, the "
313  "specified center frequency must uniquely identify a channel in the "
314  "band being used.",
315  UintegerValue (0),
318  MakeUintegerChecker<uint16_t> ())
319  .AddAttribute ("ChannelNumber",
320  "The channel number of the operating channel. "
321  "If the operating channel for this object has not been set yet, the "
322  "value of this attribute is saved and will be used, along with the center "
323  "frequency and width configured via other attributes, to set the operating "
324  "channel when the standard and band are configured. The default value of "
325  "this attribute is 0, which means unspecified channel number. Note that "
326  "if center frequency and channel number are both 0 when the standard and "
327  "band are configured, a default channel (of the configured width, if any, "
328  "or the default width for the current standard and band, otherwise) is set. "
329  "If the operating channel for this object has been already set, the "
330  "specified channel number must uniquely identify a channel in the "
331  "band being used.",
332  UintegerValue (0),
335  MakeUintegerChecker<uint8_t> (0, 233))
336  .AddAttribute ("ChannelWidth",
337  "The width in MHz of the operating channel (5, 10, 20, 22, 40, 80 or 160). "
338  "If the operating channel for this object has not been set yet, the "
339  "value of this attribute is saved and will be used, along with the center "
340  "frequency and channel number configured via other attributes, to set the "
341  "operating channel when the standard and band are configured. The default value "
342  "of this attribute is 0, which means unspecified channel width. Note that "
343  "if center frequency and channel number are both 0 when the standard and "
344  "band are configured, a default channel (of the configured width, if any, "
345  "or the default width for the current standard and band, otherwise) is set. "
346  "Do not set this attribute when the standard and band of this object have "
347  "been already configured, because it cannot uniquely identify a channel in "
348  "the band being used.",
349  UintegerValue (0),
352  MakeUintegerChecker<uint16_t> (5, 160))
353  .AddAttribute ("Primary20MHzIndex",
354  "The index of the primary 20 MHz channel within the operating channel "
355  "(0 indicates the 20 MHz subchannel with the lowest center frequency). "
356  "This attribute is only valid if the width of the operating channel is "
357  "a multiple of 20 MHz.",
358  UintegerValue (0),
360  MakeUintegerChecker<uint8_t> (0, 7))
361  .AddAttribute ("RxSensitivity",
362  "The energy of a received signal should be higher than "
363  "this threshold (dBm) for the PHY to detect the signal. "
364  "This threshold refers to a width of 20 MHz and will be "
365  "scaled to match the width of the received signal.",
366  DoubleValue (-101.0),
369  MakeDoubleChecker<double> ())
370  .AddAttribute ("CcaEdThreshold",
371  "The energy of a non Wi-Fi received signal should be higher than "
372  "this threshold (dBm) to allow the PHY layer to declare CCA BUSY state. "
373  "This check is performed on the 20 MHz primary channel only.",
374  DoubleValue (-62.0),
377  MakeDoubleChecker<double> ())
378  .AddAttribute ("TxGain",
379  "Transmission gain (dB).",
380  DoubleValue (0.0),
383  MakeDoubleChecker<double> ())
384  .AddAttribute ("RxGain",
385  "Reception gain (dB).",
386  DoubleValue (0.0),
389  MakeDoubleChecker<double> ())
390  .AddAttribute ("TxPowerLevels",
391  "Number of transmission power levels available between "
392  "TxPowerStart and TxPowerEnd included.",
393  UintegerValue (1),
395  MakeUintegerChecker<uint8_t> ())
396  .AddAttribute ("TxPowerEnd",
397  "Maximum available transmission level (dBm).",
398  DoubleValue (16.0206),
401  MakeDoubleChecker<double> ())
402  .AddAttribute ("TxPowerStart",
403  "Minimum available transmission level (dBm).",
404  DoubleValue (16.0206),
407  MakeDoubleChecker<double> ())
408  .AddAttribute ("RxNoiseFigure",
409  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
410  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
411  "\"the difference in decibels (dB) between"
412  " the noise output of the actual receiver to the noise output of an "
413  " ideal receiver with the same overall gain and bandwidth when the receivers "
414  " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
415  DoubleValue (7),
417  MakeDoubleChecker<double> ())
418  .AddAttribute ("State",
419  "The state of the PHY layer.",
420  PointerValue (),
422  MakePointerChecker<WifiPhyStateHelper> ())
423  .AddAttribute ("ChannelSwitchDelay",
424  "Delay between two short frames transmitted on different frequencies.",
425  TimeValue (MicroSeconds (250)),
427  MakeTimeChecker ())
428  .AddAttribute ("Antennas",
429  "The number of antennas on the device.",
430  UintegerValue (1),
433  MakeUintegerChecker<uint8_t> (1, 8))
434  .AddAttribute ("MaxSupportedTxSpatialStreams",
435  "The maximum number of supported TX spatial streams."
436  "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
437  UintegerValue (1),
440  MakeUintegerChecker<uint8_t> (1, 8))
441  .AddAttribute ("MaxSupportedRxSpatialStreams",
442  "The maximum number of supported RX spatial streams."
443  "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
444  UintegerValue (1),
447  MakeUintegerChecker<uint8_t> (1, 8))
448  .AddAttribute ("ShortPlcpPreambleSupported",
449  "Whether or not short PHY preamble is supported."
450  "This parameter is only valuable for 802.11b STAs and APs."
451  "Note: 802.11g APs and STAs always support short PHY preamble.",
452  BooleanValue (false),
456  .AddAttribute ("FrameCaptureModel",
457  "Ptr to an object that implements the frame capture model",
458  PointerValue (),
460  MakePointerChecker <FrameCaptureModel> ())
461  .AddAttribute ("PreambleDetectionModel",
462  "Ptr to an object that implements the preamble detection model",
463  PointerValue (),
465  MakePointerChecker <PreambleDetectionModel> ())
466  .AddAttribute ("PostReceptionErrorModel",
467  "An optional packet error model can be added to the receive "
468  "packet process after any propagation-based (SNR-based) error "
469  "models have been applied. Typically this is used to force "
470  "specific packet drops, for testing purposes.",
471  PointerValue (),
473  MakePointerChecker<ErrorModel> ())
474  .AddAttribute ("Sifs",
475  "The duration of the Short Interframe Space. "
476  "NOTE that the default value is overwritten by the value defined "
477  "by the standard; if you want to set this attribute, you have to "
478  "do it after that the PHY object is initialized.",
479  TimeValue (MicroSeconds (0)),
481  MakeTimeChecker ())
482  .AddAttribute ("Slot",
483  "The duration of a slot. "
484  "NOTE that the default value is overwritten by the value defined "
485  "by the standard; if you want to set this attribute, you have to "
486  "do it after that the PHY object is initialized.",
487  TimeValue (MicroSeconds (0)),
489  MakeTimeChecker ())
490  .AddAttribute ("Pifs",
491  "The duration of the PCF Interframe Space. "
492  "NOTE that the default value is overwritten by the value defined "
493  "by the standard; if you want to set this attribute, you have to "
494  "do it after that the PHY object is initialized.",
495  TimeValue (MicroSeconds (0)),
497  MakeTimeChecker ())
498  .AddAttribute ("PowerDensityLimit",
499  "The mean equivalent isotropically radiated power density"
500  "limit (in dBm/MHz) set by regulators.",
501  DoubleValue (100.0), //set to a high value so as to have no effect
503  MakeDoubleChecker<double> ())
504  .AddTraceSource ("PhyTxBegin",
505  "Trace source indicating a packet "
506  "has begun transmitting over the channel medium",
508  "ns3::Packet::TracedCallback")
509  .AddTraceSource ("PhyTxPsduBegin",
510  "Trace source indicating a PSDU "
511  "has begun transmitting over the channel medium",
513  "ns3::WifiPhy::PsduTxBeginCallback")
514  .AddTraceSource ("PhyTxEnd",
515  "Trace source indicating a packet "
516  "has been completely transmitted over the channel.",
518  "ns3::Packet::TracedCallback")
519  .AddTraceSource ("PhyTxDrop",
520  "Trace source indicating a packet "
521  "has been dropped by the device during transmission",
523  "ns3::Packet::TracedCallback")
524  .AddTraceSource ("PhyRxBegin",
525  "Trace source indicating a packet "
526  "has begun being received from the channel medium "
527  "by the device",
529  "ns3::Packet::TracedCallback")
530  .AddTraceSource ("PhyRxPayloadBegin",
531  "Trace source indicating the reception of the "
532  "payload of a PPDU has begun",
534  "ns3::WifiPhy::PhyRxPayloadBeginTracedCallback")
535  .AddTraceSource ("PhyRxEnd",
536  "Trace source indicating a packet "
537  "has been completely received from the channel medium "
538  "by the device",
540  "ns3::Packet::TracedCallback")
541  .AddTraceSource ("PhyRxDrop",
542  "Trace source indicating a packet "
543  "has been dropped by the device during reception",
545  "ns3::Packet::TracedCallback")
546  .AddTraceSource ("MonitorSnifferRx",
547  "Trace source simulating a wifi device in monitor mode "
548  "sniffing all received frames",
550  "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
551  .AddTraceSource ("MonitorSnifferTx",
552  "Trace source simulating the capability of a wifi device "
553  "in monitor mode to sniff all frames being transmitted",
555  "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
556  ;
557  return tid;
558 }
559 
561  : m_txMpduReferenceNumber (0xffffffff),
562  m_rxMpduReferenceNumber (0xffffffff),
563  m_endPhyRxEvent (),
564  m_endTxEvent (),
565  m_currentEvent (0),
566  m_previouslyRxPpduUid (UINT64_MAX),
567  m_standard (WIFI_PHY_STANDARD_UNSPECIFIED),
568  m_band (WIFI_PHY_BAND_UNSPECIFIED),
569  m_initialFrequency (0),
570  m_initialChannelNumber (0),
571  m_initialChannelWidth (0),
572  m_initialPrimary20Index (0),
573  m_sifs (Seconds (0)),
574  m_slot (Seconds (0)),
575  m_pifs (Seconds (0)),
576  m_ackTxTime (Seconds (0)),
577  m_blockAckTxTime (Seconds (0)),
578  m_powerRestricted (false),
579  m_channelAccessRequested (false),
580  m_txSpatialStreams (0),
581  m_rxSpatialStreams (0),
582  m_wifiRadioEnergyModel (0),
583  m_timeLastPreambleDetected (Seconds (0))
584 {
585  NS_LOG_FUNCTION (this);
586  m_random = CreateObject<UniformRandomVariable> ();
587  m_state = CreateObject<WifiPhyStateHelper> ();
588 }
589 
591 {
592  NS_LOG_FUNCTION (this);
593 }
594 
595 void
597 {
598  NS_LOG_FUNCTION (this);
599  m_endTxEvent.Cancel ();
601  for (auto & phyEntity : m_phyEntities)
602  {
603  phyEntity.second->CancelAllEvents ();
604  }
605  m_device = 0;
606  m_mobility = 0;
612  m_random = 0;
613  m_state = 0;
614  m_currentEvent = 0;
615  for (auto & preambleEvent : m_currentPreambleEvents)
616  {
617  preambleEvent.second = 0;
618  }
619  m_currentPreambleEvents.clear ();
620 
621  for (auto & phyEntity : m_phyEntities)
622  {
623  phyEntity.second = 0;
624  }
625  m_phyEntities.clear ();
626 }
627 
629 WifiPhy::GetState (void) const
630 {
631  return m_state;
632 }
633 
634 void
636 {
637  m_state->SetReceiveOkCallback (callback);
638 }
639 
640 void
642 {
643  m_state->SetReceiveErrorCallback (callback);
644 }
645 
646 void
648 {
649  m_state->RegisterListener (listener);
650 }
651 
652 void
654 {
655  m_state->UnregisterListener (listener);
656 }
657 
658 void
660 {
662 }
663 
664 void
665 WifiPhy::SetRxSensitivity (double threshold)
666 {
667  NS_LOG_FUNCTION (this << threshold);
668  m_rxSensitivityW = DbmToW (threshold);
669 }
670 
671 double
673 {
674  return WToDbm (m_rxSensitivityW);
675 }
676 
677 void
678 WifiPhy::SetCcaEdThreshold (double threshold)
679 {
680  NS_LOG_FUNCTION (this << threshold);
681  m_ccaEdThresholdW = DbmToW (threshold);
682 }
683 
684 double
686 {
687  return WToDbm (m_ccaEdThresholdW);
688 }
689 
690 void
691 WifiPhy::SetRxNoiseFigure (double noiseFigureDb)
692 {
693  NS_LOG_FUNCTION (this << noiseFigureDb);
694  m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
696 }
697 
698 void
700 {
701  NS_LOG_FUNCTION (this << start);
703 }
704 
705 double
707 {
708  return m_txPowerBaseDbm;
709 }
710 
711 void
713 {
714  NS_LOG_FUNCTION (this << end);
715  m_txPowerEndDbm = end;
716 }
717 
718 double
720 {
721  return m_txPowerEndDbm;
722 }
723 
724 void
726 {
727  NS_LOG_FUNCTION (this << +n);
728  m_nTxPower = n;
729 }
730 
731 uint8_t
733 {
734  return m_nTxPower;
735 }
736 
737 void
738 WifiPhy::SetTxGain (double gain)
739 {
740  NS_LOG_FUNCTION (this << gain);
741  m_txGainDb = gain;
742 }
743 
744 double
745 WifiPhy::GetTxGain (void) const
746 {
747  return m_txGainDb;
748 }
749 
750 void
751 WifiPhy::SetRxGain (double gain)
752 {
753  NS_LOG_FUNCTION (this << gain);
754  m_rxGainDb = gain;
755 }
756 
757 double
758 WifiPhy::GetRxGain (void) const
759 {
760  return m_rxGainDb;
761 }
762 
763 void
765 {
766  NS_LOG_FUNCTION (this << enable);
767  m_shortPreamble = enable;
768 }
769 
770 bool
772 {
773  return m_shortPreamble;
774 }
775 
776 void
778 {
779  m_device = device;
780 }
781 
783 WifiPhy::GetDevice (void) const
784 {
785  return m_device;
786 }
787 
788 void
790 {
792 }
793 
796 {
797  if (m_mobility != 0)
798  {
799  return m_mobility;
800  }
801  else
802  {
803  return m_device->GetNode ()->GetObject<MobilityModel> ();
804  }
805 }
806 
807 void
809 {
812 }
813 
814 void
816 {
817  NS_LOG_FUNCTION (this << em);
819 }
820 
821 void
823 {
824  m_frameCaptureModel = model;
825 }
826 
827 void
829 {
830  m_preambleDetectionModel = model;
831 }
832 
833 void
835 {
836  m_wifiRadioEnergyModel = wifiRadioEnergyModel;
837 }
838 
839 double
840 WifiPhy::GetPowerDbm (uint8_t power) const
841 {
843  NS_ASSERT (m_nTxPower > 0);
844  double dbm;
845  if (m_nTxPower > 1)
846  {
847  dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / (m_nTxPower - 1);
848  }
849  else
850  {
851  NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
852  dbm = m_txPowerBaseDbm;
853  }
854  return dbm;
855 }
856 
857 Time
859 {
860  return m_channelSwitchDelay;
861 }
862 
863 double
864 WifiPhy::CalculateSnr (const WifiTxVector& txVector, double ber) const
865 {
866  return m_interference.GetErrorRateModel ()->CalculateSnr (txVector, ber);
867 }
868 
871 {
872  const auto it = m_staticPhyEntities.find (modulation);
873  NS_ABORT_MSG_IF (it == m_staticPhyEntities.end (), "Unimplemented Wi-Fi modulation class");
874  return it->second;
875 }
876 
879 {
880  const auto it = m_phyEntities.find (modulation);
881  NS_ABORT_MSG_IF (it == m_phyEntities.end (), "Unsupported Wi-Fi modulation class");
882  return it->second;
883 }
884 
885 void
887 {
888  NS_LOG_FUNCTION (modulation);
889  NS_ASSERT_MSG (m_staticPhyEntities.find (modulation) == m_staticPhyEntities.end (), "The PHY entity has already been added. The setting should only be done once per modulation class");
890  m_staticPhyEntities[modulation] = phyEntity;
891 }
892 
893 void
895 {
896  NS_LOG_FUNCTION (this << modulation);
897  NS_ABORT_MSG_IF (m_staticPhyEntities.find (modulation) == m_staticPhyEntities.end (), "Cannot add an unimplemented PHY to supported list. Update the former first.");
898  NS_ASSERT_MSG (m_phyEntities.find (modulation) == m_phyEntities.end (), "The PHY entity has already been added. The setting should only be done once per modulation class");
899  phyEntity->SetOwner (this);
900  m_phyEntities[modulation] = phyEntity;
901 }
902 
903 void
905 {
906  m_sifs = sifs;
907 }
908 
909 Time
910 WifiPhy::GetSifs (void) const
911 {
912  return m_sifs;
913 }
914 
915 void
917 {
918  m_slot = slot;
919 }
920 
921 Time
922 WifiPhy::GetSlot (void) const
923 {
924  return m_slot;
925 }
926 
927 void
929 {
930  m_pifs = pifs;
931 }
932 
933 Time
934 WifiPhy::GetPifs (void) const
935 {
936  return m_pifs;
937 }
938 
939 Time
941 {
942  return m_ackTxTime;
943 }
944 
945 Time
947 {
948  return m_blockAckTxTime;
949 }
950 
951 void
953 {
954  NS_LOG_FUNCTION (this);
955  AddPhyEntity (WIFI_MOD_CLASS_OFDM, Create<OfdmPhy> ());
956 
957  // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
958  SetSifs (MicroSeconds (16));
959  SetSlot (MicroSeconds (9));
960  SetPifs (GetSifs () + GetSlot ());
961  // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
962  // of the PPDU causing the EIFS" of 802.11-2016
963  m_ackTxTime = MicroSeconds (44);
964 }
965 
966 void
968 {
969  NS_LOG_FUNCTION (this);
970  Ptr<DsssPhy> phyEntity = Create<DsssPhy> ();
972  AddPhyEntity (WIFI_MOD_CLASS_DSSS, phyEntity); //when plain DSSS modes are used
973 
974  // See Table 16-4 "HR/DSSS PHY characteristics" of 802.11-2016
975  SetSifs (MicroSeconds (10));
976  SetSlot (MicroSeconds (20));
977  SetPifs (GetSifs () + GetSlot ());
978  // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
979  // of the PPDU causing the EIFS" of 802.11-2016
980  m_ackTxTime = MicroSeconds (304);
981 }
982 
983 void
985 {
986  NS_LOG_FUNCTION (this);
987  // See Table 18-5 "ERP characteristics" of 802.11-2016
988  // Slot time defaults to the "long slot time" of 20 us in the standard
989  // according to mixed 802.11b/g deployments. Short slot time is enabled
990  // if the user sets the ShortSlotTimeSupported flag to true and when the BSS
991  // consists of only ERP STAs capable of supporting this option.
992  Configure80211b ();
993  AddPhyEntity (WIFI_MOD_CLASS_ERP_OFDM, Create<ErpOfdmPhy> ());
994 }
995 
996 void
998 {
999  NS_LOG_FUNCTION (this);
1000  if (GetChannelWidth () == 10)
1001  {
1002  AddPhyEntity (WIFI_MOD_CLASS_OFDM, Create<OfdmPhy> (OFDM_PHY_10_MHZ));
1003 
1004  // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
1005  SetSifs (MicroSeconds (32));
1006  SetSlot (MicroSeconds (13));
1007  SetPifs (GetSifs () + GetSlot ());
1008  m_ackTxTime = MicroSeconds (88);
1009  }
1010  else if (GetChannelWidth () == 5)
1011  {
1012  AddPhyEntity (WIFI_MOD_CLASS_OFDM, Create<OfdmPhy> (OFDM_PHY_5_MHZ));
1013 
1014  // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
1015  SetSifs (MicroSeconds (64));
1016  SetSlot (MicroSeconds (21));
1017  SetPifs (GetSifs () + GetSlot ());
1018  m_ackTxTime = MicroSeconds (176);
1019  }
1020  else
1021  {
1022  NS_FATAL_ERROR ("802.11p configured with a wrong channel width!");
1023  }
1024 }
1025 
1026 void
1028 {
1029  NS_LOG_FUNCTION (this);
1031  {
1032  Configure80211g ();
1033  }
1034  else
1035  {
1036  Configure80211a ();
1037  }
1039 
1040  // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
1041  // of the PPDU causing the EIFS" of 802.11-2016
1043 }
1044 
1045 void
1047 {
1048  NS_LOG_FUNCTION (this);
1049  Configure80211n ();
1050  AddPhyEntity (WIFI_MOD_CLASS_VHT, Create<VhtPhy> ());
1051 }
1052 
1053 void
1055 {
1056  NS_LOG_FUNCTION (this);
1058  {
1059  Configure80211n ();
1060  }
1061  else
1062  {
1063  Configure80211ac ();
1064  }
1065  AddPhyEntity (WIFI_MOD_CLASS_HE, Create<HePhy> ());
1066 }
1067 
1068 void
1070 {
1071  NS_LOG_FUNCTION (this << standard << band);
1072  m_standard = standard;
1073  m_band = band;
1074 
1075  if (m_initialFrequency == 0 && m_initialChannelNumber == 0)
1076  {
1077  // set a default channel if the user did not specify anything
1078  if (m_initialChannelWidth == 0)
1079  {
1080  // set a default channel width
1082  }
1083 
1085  }
1086  else
1087  {
1089  m_standard, m_band);
1090  }
1092 
1093  switch (standard)
1094  {
1096  Configure80211a ();
1097  break;
1099  Configure80211b ();
1100  break;
1102  Configure80211g ();
1103  break;
1105  Configure80211p ();
1106  break;
1108  Configure80211n ();
1109  break;
1111  Configure80211ac ();
1112  break;
1114  Configure80211ax ();
1115  break;
1117  default:
1118  NS_ASSERT_MSG (false, "Unsupported standard");
1119  break;
1120  }
1121 }
1122 
1125 {
1126  return m_band;
1127 }
1128 
1129 
1132 {
1133  return m_standard;
1134 }
1135 
1138 {
1139  return m_operatingChannel;
1140 }
1141 
1142 void
1143 WifiPhy::SetFrequency (uint16_t frequency)
1144 {
1145  NS_LOG_FUNCTION (this << frequency);
1146 
1147  if (!m_operatingChannel.IsSet ())
1148  {
1149  // ConfigureStandardAndBand has not been called yet, so store the frequency
1150  // into m_initialFrequency
1151  NS_LOG_DEBUG ("Saving frequency configuration for initialization");
1152  m_initialFrequency = frequency;
1153  return;
1154  }
1155 
1156  if (GetFrequency () == frequency)
1157  {
1158  NS_LOG_DEBUG ("No frequency change requested");
1159  return;
1160  }
1161 
1162  // if the frequency does not uniquely identify an operating channel,
1163  // the simulation aborts
1164  SetOperatingChannel (0, frequency, 0);
1165 }
1166 
1167 uint16_t
1169 {
1170  return m_operatingChannel.GetFrequency ();
1171 }
1172 
1173 void
1175 {
1176  NS_LOG_FUNCTION (this << +nch);
1177 
1178  if (!m_operatingChannel.IsSet ())
1179  {
1180  // ConfigureStandardAndBand has not been called yet, so store the channel
1181  // into m_initialChannelNumber
1182  NS_LOG_DEBUG ("Saving channel number configuration for initialization");
1183  m_initialChannelNumber = nch;
1184  return;
1185  }
1186 
1187  if (GetChannelNumber () == nch)
1188  {
1189  NS_LOG_DEBUG ("No channel change requested");
1190  return;
1191  }
1192 
1193  // if the channel number does not uniquely identify an operating channel,
1194  // the simulation aborts
1195  SetOperatingChannel (nch, 0, 0);
1196 }
1197 
1198 uint8_t
1200 {
1201  return m_operatingChannel.GetNumber ();
1202 }
1203 
1204 void
1205 WifiPhy::SetChannelWidth (uint16_t channelWidth)
1206 {
1207  NS_LOG_FUNCTION (this << channelWidth);
1208 
1209  if (channelWidth != 0)
1210  {
1211  AddSupportedChannelWidth (channelWidth);
1212  }
1213 
1214  if (!m_operatingChannel.IsSet ())
1215  {
1216  // ConfigureStandardAndBand has not been called yet, so store the channel width
1217  // into m_initialChannelWidth
1218  NS_LOG_DEBUG ("Saving channel width configuration for initialization");
1219  m_initialChannelWidth = channelWidth;
1220  return;
1221  }
1222 
1223  if (GetChannelWidth () == channelWidth)
1224  {
1225  NS_LOG_DEBUG ("No channel width change requested");
1226  return;
1227  }
1228 
1229  NS_ABORT_MSG ("The channel width does not uniquely identify an operating channel.");
1230 }
1231 
1232 uint16_t
1234 {
1235  return m_operatingChannel.GetWidth ();
1236 }
1237 
1238 void
1240 {
1241  NS_LOG_FUNCTION (this << +index);
1242 
1243  if (!m_operatingChannel.IsSet ())
1244  {
1245  // ConfigureStandardAndBand has not been called yet, so store the primary20
1246  // index into m_initialPrimary20Index
1247  NS_LOG_DEBUG ("Saving primary20 index configuration for initialization");
1248  m_initialPrimary20Index = index;
1249  return;
1250  }
1251 
1253 }
1254 
1255 void
1256 WifiPhy::SetOperatingChannel (uint8_t number, uint16_t frequency, uint16_t width)
1257 {
1258  Time delay = Seconds (0);
1259 
1260  if (IsInitialized ())
1261  {
1262  delay = DoChannelSwitch ();
1263  }
1264 
1265  if (delay.IsStrictlyNegative ())
1266  {
1267  // switching channel is not possible now
1268  return;
1269  }
1270  if (delay.IsStrictlyPositive ())
1271  {
1272  // switching channel has been postponed
1273  Simulator::Schedule (delay, &WifiPhy::SetOperatingChannel, this, number, frequency, width);
1274  return;
1275  }
1276 
1277  // channel can be switched now.
1278  uint16_t prevChannelWidth = 0;
1279  if (m_operatingChannel.IsSet ())
1280  {
1281  prevChannelWidth = GetChannelWidth ();
1282  }
1283 
1284  m_operatingChannel.Set (number, frequency, width, m_standard, m_band);
1285 
1286  if (GetChannelWidth () != prevChannelWidth)
1287  {
1289 
1290  // If channel width changed after initialization, invoke the capabilities changed callback
1292  {
1294  }
1295  }
1296 }
1297 
1298 Time
1300 {
1301  m_powerRestricted = false;
1302  m_channelAccessRequested = false;
1303  m_currentEvent = 0;
1304  m_currentPreambleEvents.clear ();
1305  if (!IsInitialized ())
1306  {
1307  //this is not channel switch, this is initialization
1308  NS_LOG_DEBUG ("Before initialization, nothing to do");
1309  return Seconds (0);
1310  }
1311 
1312  Time delay = Seconds (0);
1313 
1315  switch (m_state->GetState ())
1316  {
1317  case WifiPhyState::RX:
1318  NS_LOG_DEBUG ("drop packet because of channel switching while reception");
1320  for (auto & phyEntity : m_phyEntities)
1321  {
1322  phyEntity.second->CancelAllEvents ();
1323  }
1324  break;
1325  case WifiPhyState::TX:
1326  NS_LOG_DEBUG ("channel switching postponed until end of current transmission");
1327  delay = GetDelayUntilIdle ();
1328  break;
1330  case WifiPhyState::IDLE:
1331  for (auto & phyEntity : m_phyEntities)
1332  {
1333  phyEntity.second->CancelAllEvents ();
1334  }
1335  break;
1336  case WifiPhyState::SLEEP:
1337  NS_LOG_DEBUG ("channel switching ignored in sleep mode");
1338  delay = Seconds (-1); // negative value to indicate switching not possible
1339  break;
1340  default:
1341  NS_ASSERT (false);
1342  break;
1343  }
1344 
1345  if (delay.IsZero ())
1346  {
1347  // channel switch can be done now
1348  NS_LOG_DEBUG ("switching channel");
1349  m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ());
1351  /*
1352  * Needed here to be able to correctly sensed the medium for the first
1353  * time after the switching. The actual switching is not performed until
1354  * after m_channelSwitchDelay. Packets received during the switching
1355  * state are added to the event list and are employed later to figure
1356  * out the state of the medium after the switching.
1357  */
1358  }
1359 
1360  return delay;
1361 }
1362 
1363 void
1365 {
1366  NS_ASSERT_MSG (antennas > 0 && antennas <= 4, "unsupported number of antennas");
1367  m_numberOfAntennas = antennas;
1369 }
1370 
1371 uint8_t
1373 {
1374  return m_numberOfAntennas;
1375 }
1376 
1377 void
1379 {
1380  NS_ASSERT (streams <= GetNumberOfAntennas ());
1381  bool changed = (m_txSpatialStreams != streams);
1382  m_txSpatialStreams = streams;
1383  if (changed)
1384  {
1385  auto phyEntity = m_phyEntities.find (WIFI_MOD_CLASS_HT);
1386  if (phyEntity != m_phyEntities.end ())
1387  {
1388  Ptr<HtPhy> htPhy = DynamicCast<HtPhy> (phyEntity->second);
1389  if (htPhy)
1390  {
1391  htPhy->SetMaxSupportedNss (m_txSpatialStreams); //this is essential to have the right MCSs configured
1392  }
1393 
1395  {
1397  }
1398  }
1399  }
1400 }
1401 
1402 uint8_t
1404 {
1405  return m_txSpatialStreams;
1406 }
1407 
1408 void
1410 {
1411  NS_ASSERT (streams <= GetNumberOfAntennas ());
1412  bool changed = (m_rxSpatialStreams != streams);
1413  m_rxSpatialStreams = streams;
1414  if (changed && !m_capabilitiesChangedCallback.IsNull ())
1415  {
1417  }
1418 }
1419 
1420 uint8_t
1422 {
1423  return m_rxSpatialStreams;
1424 }
1425 
1426 std::list<uint8_t>
1428 {
1429  std::list<uint8_t> list;
1430  for (const auto & phyEntity : m_phyEntities)
1431  {
1432  Ptr<HtPhy> htPhy = DynamicCast<HtPhy> (phyEntity.second);
1433  if (htPhy)
1434  {
1435  list.emplace_back (htPhy->GetBssMembershipSelector ());
1436  }
1437  }
1438  return list;
1439 }
1440 
1441 void
1443 {
1444  NS_LOG_FUNCTION (this << width);
1445  for (std::vector<uint32_t>::size_type i = 0; i != m_supportedChannelWidthSet.size (); i++)
1446  {
1447  if (m_supportedChannelWidthSet[i] == width)
1448  {
1449  return;
1450  }
1451  }
1452  NS_LOG_FUNCTION ("Adding " << width << " to supported channel width set");
1453  m_supportedChannelWidthSet.push_back (width);
1454 }
1455 
1456 std::vector<uint16_t>
1458 {
1460 }
1461 
1462 void
1464 {
1465  NS_LOG_FUNCTION (this);
1466  m_powerRestricted = false;
1467  m_channelAccessRequested = false;
1468  switch (m_state->GetState ())
1469  {
1470  case WifiPhyState::TX:
1471  NS_LOG_DEBUG ("setting sleep mode postponed until end of current transmission");
1473  break;
1474  case WifiPhyState::RX:
1475  NS_LOG_DEBUG ("setting sleep mode postponed until end of current reception");
1477  break;
1479  NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching");
1481  break;
1483  case WifiPhyState::IDLE:
1484  NS_LOG_DEBUG ("setting sleep mode");
1485  m_state->SwitchToSleep ();
1486  break;
1487  case WifiPhyState::SLEEP:
1488  NS_LOG_DEBUG ("already in sleep mode");
1489  break;
1490  default:
1491  NS_ASSERT (false);
1492  break;
1493  }
1494 }
1495 
1496 void
1498 {
1499  NS_LOG_FUNCTION (this);
1500  m_powerRestricted = false;
1501  m_channelAccessRequested = false;
1503  m_endTxEvent.Cancel ();
1504  for (auto & phyEntity : m_phyEntities)
1505  {
1506  phyEntity.second->CancelAllEvents ();
1507  }
1508  m_state->SwitchToOff ();
1509 }
1510 
1511 void
1513 {
1514  NS_LOG_FUNCTION (this);
1515  m_currentPreambleEvents.clear ();
1516  switch (m_state->GetState ())
1517  {
1518  case WifiPhyState::TX:
1519  case WifiPhyState::RX:
1520  case WifiPhyState::IDLE:
1523  {
1524  NS_LOG_DEBUG ("not in sleep mode, there is nothing to resume");
1525  break;
1526  }
1527  case WifiPhyState::SLEEP:
1528  {
1529  NS_LOG_DEBUG ("resuming from sleep mode");
1531  m_state->SwitchFromSleep (delayUntilCcaEnd);
1532  break;
1533  }
1534  default:
1535  {
1536  NS_ASSERT (false);
1537  break;
1538  }
1539  }
1540 }
1541 
1542 void
1544 {
1545  NS_LOG_FUNCTION (this);
1546  switch (m_state->GetState ())
1547  {
1548  case WifiPhyState::TX:
1549  case WifiPhyState::RX:
1550  case WifiPhyState::IDLE:
1553  case WifiPhyState::SLEEP:
1554  {
1555  NS_LOG_DEBUG ("not in off mode, there is nothing to resume");
1556  break;
1557  }
1558  case WifiPhyState::OFF:
1559  {
1560  NS_LOG_DEBUG ("resuming from off mode");
1562  m_state->SwitchFromOff (delayUntilCcaEnd);
1563  break;
1564  }
1565  default:
1566  {
1567  NS_ASSERT (false);
1568  break;
1569  }
1570  }
1571 }
1572 
1573 Time
1575 {
1576  return MicroSeconds (4);
1577 }
1578 
1579 Time
1581 {
1582  return MicroSeconds (4);
1583 }
1584 
1585 Time
1586 WifiPhy::GetPayloadDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, MpduType mpdutype, uint16_t staId)
1587 {
1588  uint32_t totalAmpduSize;
1589  double totalAmpduNumSymbols;
1590  return GetPayloadDuration (size, txVector, band, mpdutype, false, totalAmpduSize, totalAmpduNumSymbols, staId);
1591 }
1592 
1593 Time
1594 WifiPhy::GetPayloadDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, MpduType mpdutype,
1595  bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols,
1596  uint16_t staId)
1597 {
1598  return GetStaticPhyEntity (txVector.GetModulationClass ())->GetPayloadDuration (size, txVector, band, mpdutype,
1599  incFlag, totalAmpduSize, totalAmpduNumSymbols,
1600  staId);
1601 }
1602 
1603 Time
1605 {
1607 }
1608 
1609 Time
1611 {
1612  return GetStaticPhyEntity (txVector.GetModulationClass ())->GetDuration (field, txVector);
1613 }
1614 
1615 Time
1616 WifiPhy::CalculateTxDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, uint16_t staId)
1617 {
1618  Time duration = CalculatePhyPreambleAndHeaderDuration (txVector)
1619  + GetPayloadDuration (size, txVector, band, NORMAL_MPDU, staId);
1620  NS_ASSERT (duration.IsStrictlyPositive ());
1621  return duration;
1622 }
1623 
1624 Time
1626 {
1627  return CalculateTxDuration (GetWifiConstPsduMap (psdu, txVector), txVector, band);
1628 }
1629 
1630 Time
1632 {
1633  return GetStaticPhyEntity (txVector.GetModulationClass ())->CalculateTxDuration (psduMap, txVector, band);
1634 }
1635 
1636 uint32_t
1638 {
1639  return GetStaticPhyEntity (modulation)->GetMaxPsduSize ();
1640 }
1641 
1642 void
1644 {
1645  for (auto const& psdu : psdus)
1646  {
1647  for (auto& mpdu : *PeekPointer (psdu.second))
1648  {
1649  m_phyTxBeginTrace (mpdu->GetProtocolDataUnit (), txPowerW);
1650  }
1651  }
1652 }
1653 
1654 void
1656 {
1657  for (auto const& psdu : psdus)
1658  {
1659  for (auto& mpdu : *PeekPointer (psdu.second))
1660  {
1661  m_phyTxEndTrace (mpdu->GetProtocolDataUnit ());
1662  }
1663  }
1664 }
1665 
1666 void
1668 {
1669  for (auto& mpdu : *PeekPointer (psdu))
1670  {
1671  m_phyTxDropTrace (mpdu->GetProtocolDataUnit ());
1672  }
1673 }
1674 
1675 void
1677 {
1678  if (psdu)
1679  {
1680  for (auto& mpdu : *PeekPointer (psdu))
1681  {
1682  m_phyRxBeginTrace (mpdu->GetProtocolDataUnit (), rxPowersW);
1683  }
1684  }
1685 }
1686 
1687 void
1689 {
1690  if (psdu)
1691  {
1692  for (auto& mpdu : *PeekPointer (psdu))
1693  {
1694  m_phyRxEndTrace (mpdu->GetProtocolDataUnit ());
1695  }
1696  }
1697 }
1698 
1699 void
1701 {
1702  if (psdu)
1703  {
1704  for (auto& mpdu : *PeekPointer (psdu))
1705  {
1706  m_phyRxDropTrace (mpdu->GetProtocolDataUnit (), reason);
1707  }
1708  }
1709 }
1710 
1711 void
1712 WifiPhy::NotifyMonitorSniffRx (Ptr<const WifiPsdu> psdu, uint16_t channelFreqMhz, WifiTxVector txVector,
1713  SignalNoiseDbm signalNoise, std::vector<bool> statusPerMpdu, uint16_t staId)
1714 {
1715  MpduInfo aMpdu;
1716  if (psdu->IsAggregate ())
1717  {
1718  //Expand A-MPDU
1719  NS_ASSERT_MSG (txVector.IsAggregation (), "TxVector with aggregate flag expected here according to PSDU");
1721  size_t nMpdus = psdu->GetNMpdus ();
1722  NS_ASSERT_MSG (statusPerMpdu.size () == nMpdus, "Should have one reception status per MPDU");
1723  aMpdu.type = (psdu->IsSingle ()) ? SINGLE_MPDU : FIRST_MPDU_IN_AGGREGATE;
1724  for (size_t i = 0; i < nMpdus;)
1725  {
1726  if (statusPerMpdu.at (i)) //packet received without error, hand over to sniffer
1727  {
1728  m_phyMonitorSniffRxTrace (psdu->GetAmpduSubframe (i), channelFreqMhz, txVector, aMpdu, signalNoise, staId);
1729  }
1730  ++i;
1731  aMpdu.type = (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1732  }
1733  }
1734  else
1735  {
1736  aMpdu.type = NORMAL_MPDU;
1737  NS_ASSERT_MSG (statusPerMpdu.size () == 1, "Should have one reception status for normal MPDU");
1738  m_phyMonitorSniffRxTrace (psdu->GetPacket (), channelFreqMhz, txVector, aMpdu, signalNoise, staId);
1739  }
1740 }
1741 
1742 void
1743 WifiPhy::NotifyMonitorSniffTx (Ptr<const WifiPsdu> psdu, uint16_t channelFreqMhz, WifiTxVector txVector, uint16_t staId)
1744 {
1745  MpduInfo aMpdu;
1746  if (psdu->IsAggregate ())
1747  {
1748  //Expand A-MPDU
1749  NS_ASSERT_MSG (txVector.IsAggregation (), "TxVector with aggregate flag expected here according to PSDU");
1751  size_t nMpdus = psdu->GetNMpdus ();
1752  aMpdu.type = (psdu->IsSingle ()) ? SINGLE_MPDU: FIRST_MPDU_IN_AGGREGATE;
1753  for (size_t i = 0; i < nMpdus;)
1754  {
1755  m_phyMonitorSniffTxTrace (psdu->GetAmpduSubframe (i), channelFreqMhz, txVector, aMpdu, staId);
1756  ++i;
1757  aMpdu.type = (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1758  }
1759  }
1760  else
1761  {
1762  aMpdu.type = NORMAL_MPDU;
1763  m_phyMonitorSniffTxTrace (psdu->GetPacket (), channelFreqMhz, txVector, aMpdu, staId);
1764  }
1765 }
1766 
1769 {
1770  return GetStaticPhyEntity (txVector.GetModulationClass ())->GetWifiConstPsduMap (psdu, txVector);
1771 }
1772 
1773 void
1775 {
1776  NS_LOG_FUNCTION (this << *psdu << txVector);
1777  Send (GetWifiConstPsduMap (psdu, txVector), txVector);
1778 }
1779 
1780 void
1782 {
1783  NS_LOG_FUNCTION (this << psdus << txVector);
1784  /* Transmission can happen if:
1785  * - we are syncing on a packet. It is the responsibility of the
1786  * MAC layer to avoid doing this but the PHY does nothing to
1787  * prevent it.
1788  * - we are idle
1789  */
1790  NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
1792 
1793  if (txVector.GetNssMax () > GetMaxSupportedTxSpatialStreams ())
1794  {
1795  NS_FATAL_ERROR ("Unsupported number of spatial streams!");
1796  }
1797 
1798  if (m_state->IsStateSleep ())
1799  {
1800  NS_LOG_DEBUG ("Dropping packet because in sleep mode");
1801  for (auto const& psdu : psdus)
1802  {
1803  NotifyTxDrop (psdu.second);
1804  }
1805  return;
1806  }
1807 
1808  Time txDuration = CalculateTxDuration (psdus, txVector, GetPhyBand ());
1809 
1810  bool noEndPreambleDetectionEvent = true;
1811  for (const auto & it : m_phyEntities)
1812  {
1813  noEndPreambleDetectionEvent &= it.second->NoEndPreambleDetectionEvents ();
1814  }
1815  if (!noEndPreambleDetectionEvent || ((m_currentEvent != 0) && (m_currentEvent->GetEndTime () > (Simulator::Now () + m_state->GetDelayUntilIdle ()))))
1816  {
1818  //that packet will be noise _after_ the transmission.
1820  }
1821 
1822  for (auto & it : m_phyEntities)
1823  {
1824  it.second->CancelRunningEndPreambleDetectionEvents ();
1825  }
1826  m_currentPreambleEvents.clear ();
1828 
1829  if (m_powerRestricted)
1830  {
1831  NS_LOG_DEBUG ("Transmitting with power restriction for " << txDuration.As (Time::NS));
1832  }
1833  else
1834  {
1835  NS_LOG_DEBUG ("Transmitting without power restriction for " << txDuration.As (Time::NS));
1836  }
1837 
1838  if (m_state->GetState () == WifiPhyState::OFF)
1839  {
1840  NS_LOG_DEBUG ("Transmission canceled because device is OFF");
1841  return;
1842  }
1843 
1844  Ptr<WifiPpdu> ppdu = GetPhyEntity (txVector.GetModulationClass ())->BuildPpdu (psdus, txVector, txDuration);
1845  m_previouslyRxPpduUid = UINT64_MAX; //reset (after creation of PPDU) to use it only once
1846 
1847  double txPowerW = DbmToW (GetTxPowerForTransmission (ppdu) + GetTxGain ());
1848  NotifyTxBegin (psdus, txPowerW);
1849  m_phyTxPsduBeginTrace (psdus, txVector, txPowerW);
1850  for (auto const& psdu : psdus)
1851  {
1852  NotifyMonitorSniffTx (psdu.second, GetFrequency (), txVector, psdu.first);
1853  }
1854  m_state->SwitchToTx (txDuration, psdus, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector);
1855 
1856  if (m_wifiRadioEnergyModel != 0 && m_wifiRadioEnergyModel->GetMaximumTimeInState (WifiPhyState::TX) < txDuration)
1857  {
1858  ppdu->SetTruncatedTx ();
1859  }
1860 
1861  m_endTxEvent = Simulator::Schedule (txDuration, &WifiPhy::NotifyTxEnd, this, psdus); //TODO: fix for MU
1862 
1863  StartTx (ppdu);
1864 
1865  m_channelAccessRequested = false;
1866  m_powerRestricted = false;
1867 
1868  Simulator::Schedule (txDuration, &WifiPhy::Reset, this);
1869 }
1870 
1871 uint64_t
1873 {
1874  return m_previouslyRxPpduUid;
1875 }
1876 
1877 void
1879 {
1880  NS_LOG_FUNCTION (this);
1881  m_currentPreambleEvents.clear ();
1882  m_currentEvent = 0;
1883  for (auto & phyEntity : m_phyEntities)
1884  {
1885  phyEntity.second->CancelAllEvents ();
1886  }
1887 }
1888 
1889 void
1891 {
1892  WifiModulationClass modulation = ppdu->GetTxVector ().GetModulationClass ();
1893  auto it = m_phyEntities.find (modulation);
1894  if (it != m_phyEntities.end ())
1895  {
1896  it->second->StartReceivePreamble (ppdu, rxPowersW, rxDuration);
1897  }
1898  else
1899  {
1900  //TODO find a fallback PHY for receiving the PPDU (e.g. 11a for 11ax due to preamble structure)
1901  NS_LOG_DEBUG ("Unsupported modulation received (" << modulation << "), consider as noise");
1902  if (ppdu->GetTxDuration () > m_state->GetDelayUntilIdle ())
1903  {
1905  }
1906  }
1907 }
1908 
1909 void
1910 WifiPhy::MaybeCcaBusyDuration (uint16_t channelWidth)
1911 {
1912  //We are here because we have received the first bit of a packet and we are
1913  //not going to be able to synchronize on it
1914  //In this model, CCA becomes busy when the aggregation of all signals as
1915  //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
1916  Time delayUntilCcaEnd = m_interference.GetEnergyDuration (m_ccaEdThresholdW, GetPrimaryBand (channelWidth));
1917  if (!delayUntilCcaEnd.IsZero ())
1918  {
1919  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
1920  }
1921 }
1922 
1924 WifiPhy::ConvertHeRuSubcarriers (uint16_t bandWidth, uint16_t guardBandwidth,
1925  HeRu::SubcarrierRange range, uint8_t bandIndex) const
1926 {
1927  NS_ASSERT_MSG (false, "802.11ax can only be used with SpectrumWifiPhy");
1928  WifiSpectrumBand convertedSubcarriers;
1929  return convertedSubcarriers;
1930 }
1931 
1932 void
1934 {
1935  NS_LOG_FUNCTION (this);
1937  {
1938  m_powerRestricted = false;
1939  }
1940 }
1941 
1942 void
1944 {
1945  NS_LOG_FUNCTION (this << *event);
1946  NS_ASSERT (!IsStateRx ());
1948  m_currentEvent = 0;
1949  m_currentPreambleEvents.clear ();
1950  MaybeCcaBusyDuration (GetMeasurementChannelWidth (event->GetPpdu ()));
1951 }
1952 
1953 void
1955 {
1956  NS_LOG_FUNCTION (this);
1957  m_channelAccessRequested = true;
1958 }
1959 
1960 bool
1962 {
1963  for (const auto & phyEntity : m_phyEntities)
1964  {
1965  if (phyEntity.second->IsModeSupported (mode))
1966  {
1967  return true;
1968  }
1969  }
1970  return false;
1971 }
1972 
1973 WifiMode
1975 {
1976  //Start from oldest standards and move up (guaranteed by fact that WifModulationClass is ordered)
1977  for (const auto & phyEntity : m_phyEntities)
1978  {
1979  for (const auto & mode : *(phyEntity.second))
1980  {
1981  return mode;
1982  }
1983  }
1984  NS_ASSERT_MSG (false, "Should have found at least one default mode");
1985  return WifiMode ();
1986 }
1987 
1988 bool
1989 WifiPhy::IsMcsSupported (WifiModulationClass modulation, uint8_t mcs) const
1990 {
1991  const auto phyEntity = m_phyEntities.find (modulation);
1992  if (phyEntity == m_phyEntities.end ())
1993  {
1994  return false;
1995  }
1996  return phyEntity->second->IsMcsSupported (mcs);
1997 }
1998 
1999 std::list<WifiMode>
2001 {
2002  std::list<WifiMode> list;
2003  for (const auto & phyEntity : m_phyEntities)
2004  {
2005  if (!phyEntity.second->HandlesMcsModes ()) //to exclude MCSs from search
2006  {
2007  for (const auto & mode : *(phyEntity.second))
2008  {
2009  list.emplace_back (mode);
2010  }
2011  }
2012  }
2013  return list;
2014 }
2015 
2016 std::list<WifiMode>
2018 {
2019  std::list<WifiMode> list;
2020  const auto phyEntity = m_phyEntities.find (modulation);
2021  if (phyEntity != m_phyEntities.end ())
2022  {
2023  if (!phyEntity->second->HandlesMcsModes ()) //to exclude MCSs from search
2024  {
2025  for (const auto & mode : *(phyEntity->second))
2026  {
2027  list.emplace_back (mode);
2028  }
2029  }
2030  }
2031  return list;
2032 }
2033 
2034 uint16_t
2035 WifiPhy::GetNMcs (void) const
2036 {
2037  uint16_t numMcs = 0;
2038  for (const auto & phyEntity : m_phyEntities)
2039  {
2040  if (phyEntity.second->HandlesMcsModes ()) //to exclude non-MCS modes from search
2041  {
2042  numMcs += phyEntity.second->GetNumModes ();
2043  }
2044  }
2045  return numMcs;
2046 }
2047 
2048 std::list<WifiMode>
2050 {
2051  std::list<WifiMode> list;
2052  for (const auto & phyEntity : m_phyEntities)
2053  {
2054  if (phyEntity.second->HandlesMcsModes ()) //to exclude non-MCS modes from search
2055  {
2056  for (const auto & mode : *(phyEntity.second))
2057  {
2058  list.emplace_back (mode);
2059  }
2060  }
2061  }
2062  return list;
2063 }
2064 
2065 std::list<WifiMode>
2067 {
2068  std::list<WifiMode> list;
2069  auto phyEntity = m_phyEntities.find (modulation);
2070  if (phyEntity != m_phyEntities.end ())
2071  {
2072  if (phyEntity->second->HandlesMcsModes ()) //to exclude non-MCS modes from search
2073  {
2074  for (const auto & mode : *(phyEntity->second))
2075  {
2076  list.emplace_back (mode);
2077  }
2078  }
2079  }
2080  return list;
2081 }
2082 
2083 WifiMode
2084 WifiPhy::GetMcs (WifiModulationClass modulation, uint8_t mcs) const
2085 {
2086  NS_ASSERT_MSG (IsMcsSupported (modulation, mcs), "Unsupported MCS");
2087  return m_phyEntities.at (modulation)->GetMcs (mcs);
2088 }
2089 
2090 bool
2092 {
2093  return m_state->IsStateCcaBusy ();
2094 }
2095 
2096 bool
2098 {
2099  return m_state->IsStateIdle ();
2100 }
2101 
2102 bool
2104 {
2105  return m_state->IsStateRx ();
2106 }
2107 
2108 bool
2110 {
2111  return m_state->IsStateTx ();
2112 }
2113 
2114 bool
2116 {
2117  return m_state->IsStateSwitching ();
2118 }
2119 
2120 bool
2122 {
2123  return m_state->IsStateSleep ();
2124 }
2125 
2126 bool
2128 {
2129  return m_state->IsStateOff ();
2130 }
2131 
2132 Time
2134 {
2135  return m_state->GetDelayUntilIdle ();
2136 }
2137 
2138 Time
2140 {
2141  return m_state->GetLastRxStartTime ();
2142 }
2143 
2144 Time
2146 {
2147  return m_state->GetLastRxEndTime ();
2148 }
2149 
2150 void
2151 WifiPhy::SwitchMaybeToCcaBusy (uint16_t channelWidth)
2152 {
2153  NS_LOG_FUNCTION (this << channelWidth);
2154  //We are here because we have received the first bit of a packet and we are
2155  //not going to be able to synchronize on it
2156  //In this model, CCA becomes busy when the aggregation of all signals as
2157  //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
2158  Time delayUntilCcaEnd = m_interference.GetEnergyDuration (m_ccaEdThresholdW, GetPrimaryBand (channelWidth));
2159  if (!delayUntilCcaEnd.IsZero ())
2160  {
2161  NS_LOG_DEBUG ("Calling SwitchMaybeToCcaBusy for " << delayUntilCcaEnd.As (Time::S));
2162  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
2163  }
2164 }
2165 
2166 void
2168 {
2169  NS_LOG_FUNCTION (this << reason);
2170  if (reason != OBSS_PD_CCA_RESET || m_currentEvent) //Otherwise abort has already been called previously
2171  {
2172  for (auto & phyEntity : m_phyEntities)
2173  {
2174  phyEntity.second->CancelAllEvents ();
2175  }
2176  if (m_endPhyRxEvent.IsRunning ())
2177  {
2179  }
2181  if (!m_currentEvent)
2182  {
2183  return;
2184  }
2185  NotifyRxDrop (GetAddressedPsduInPpdu (m_currentEvent->GetPpdu ()), reason);
2186  if (reason == OBSS_PD_CCA_RESET)
2187  {
2188  m_state->SwitchFromRxAbort ();
2189  }
2190  for (auto it = m_currentPreambleEvents.begin (); it != m_currentPreambleEvents.end (); ++it)
2191  {
2192  if (it->second == m_currentEvent)
2193  {
2194  it = m_currentPreambleEvents.erase (it);
2195  break;
2196  }
2197  }
2198  m_currentEvent = 0;
2199  }
2200 }
2201 
2202 void
2203 WifiPhy::ResetCca (bool powerRestricted, double txPowerMaxSiso, double txPowerMaxMimo)
2204 {
2205  NS_LOG_FUNCTION (this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
2206  // This method might be called multiple times when receiving TB PPDUs with a BSS color
2207  // different than the one of the receiver. The first time this method is called, the call
2208  // to AbortCurrentReception sets m_currentEvent to 0. Therefore, we need to check whether
2209  // m_currentEvent is not 0 before executing the instructions below.
2210  if (m_currentEvent != 0)
2211  {
2212  m_powerRestricted = powerRestricted;
2213  m_txPowerMaxSiso = txPowerMaxSiso;
2214  m_txPowerMaxMimo = txPowerMaxMimo;
2215  NS_ASSERT ((m_currentEvent->GetEndTime () - Simulator::Now ()).IsPositive ());
2217  Simulator::ScheduleNow (&WifiPhy::AbortCurrentReception, this, OBSS_PD_CCA_RESET); //finish processing field first
2218  }
2219 }
2220 
2221 double
2223 {
2224  NS_LOG_FUNCTION (this << m_powerRestricted << ppdu);
2225  const WifiTxVector& txVector = ppdu->GetTxVector ();
2226  // Get transmit power before antenna gain
2227  double txPowerDbm;
2228  if (!m_powerRestricted)
2229  {
2230  txPowerDbm = GetPowerDbm (txVector.GetTxPowerLevel ());
2231  }
2232  else
2233  {
2234  if (txVector.GetNssMax () > 1)
2235  {
2236  txPowerDbm = std::min (m_txPowerMaxMimo, GetPowerDbm (txVector.GetTxPowerLevel ()));
2237  }
2238  else
2239  {
2240  txPowerDbm = std::min (m_txPowerMaxSiso, GetPowerDbm (txVector.GetTxPowerLevel ()));
2241  }
2242  }
2243 
2244  //Apply power density constraint on EIRP
2245  uint16_t channelWidth = GetPhyEntity (txVector.GetModulationClass ())->GetTransmissionChannelWidth (ppdu);
2246  double txPowerDbmPerMhz = (txPowerDbm + GetTxGain ()) - RatioToDb (channelWidth); //account for antenna gain since EIRP
2247  NS_LOG_INFO ("txPowerDbm=" << txPowerDbm << " with txPowerDbmPerMhz=" << txPowerDbmPerMhz << " over " << channelWidth << " MHz");
2248  txPowerDbm = std::min (txPowerDbmPerMhz, m_powerDensityLimit) + RatioToDb (channelWidth);
2249  txPowerDbm -= GetTxGain (); //remove antenna gain since will be added right afterwards
2250  NS_LOG_INFO ("txPowerDbm=" << txPowerDbm << " after applying m_powerDensityLimit=" << m_powerDensityLimit);
2251  return txPowerDbm;
2252 }
2253 
2256 {
2257  //TODO: wrapper. See if still needed
2258  return GetPhyEntity (ppdu->GetModulation ())->GetAddressedPsduInPpdu (ppdu);
2259 }
2260 
2261 uint16_t
2263 {
2264  if (ppdu == nullptr)
2265  {
2266  // Here because PHY was not receiving anything (e.g. resuming from OFF) nor expecting anything (e.g. sleep)
2267  // nor processing a Wi-Fi signal.
2268  return GetChannelWidth () >= 40 ? 20 : GetChannelWidth ();
2269  }
2270  return GetPhyEntity (ppdu->GetModulation ())->GetMeasurementChannelWidth (ppdu);
2271 }
2272 
2274 WifiPhy::GetBand (uint16_t /*bandWidth*/, uint8_t /*bandIndex*/)
2275 {
2276  WifiSpectrumBand band;
2277  band.first = 0;
2278  band.second = 0;
2279  return band;
2280 }
2281 
2283 WifiPhy::GetPrimaryBand (uint16_t bandWidth)
2284 {
2285  if (GetChannelWidth () % 20 != 0)
2286  {
2287  return GetBand (bandWidth);
2288  }
2289 
2290  return GetBand (bandWidth, m_operatingChannel.GetPrimaryChannelIndex (bandWidth));
2291 }
2292 
2293 int64_t
2294 WifiPhy::AssignStreams (int64_t stream)
2295 {
2296  NS_LOG_FUNCTION (this << stream);
2297  int64_t currentStream = stream;
2298  m_random->SetStream (currentStream++);
2299  currentStream += m_interference.GetErrorRateModel ()->AssignStreams (currentStream);
2300  return (currentStream - stream);
2301 }
2302 
2303 std::ostream& operator<< (std::ostream& os, RxSignalInfo rxSignalInfo)
2304 {
2305  os << "SNR:" << RatioToDb (rxSignalInfo.snr) << " dB"
2306  << ", RSSI:" << rxSignalInfo.rssi << " dBm";
2307  return os;
2308 }
2309 
2310 } //namespace ns3
ERP-OFDM PHY (Clause 19, Section 19.5)
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802...
MpduInfo structure.
Definition: phy-entity.h:59
void NotifyRxDrop(Ptr< const WifiPsdu > psdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxDrop trace.
Definition: wifi-phy.cc:1700
Ptr< NetDevice > m_device
Pointer to the device.
Definition: wifi-phy.h:1423
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:557
void NotifyRxEnd(Time endTime)
Notify that RX has ended.
uint8_t GetNTxPower(void) const
Return the number of available transmission power levels.
Definition: wifi-phy.cc:732
bool IsStateSwitching(void) const
Definition: wifi-phy.cc:2115
void SetPifs(Time pifs)
Set the PCF Interframe Space (PIFS) for this PHY.
Definition: wifi-phy.cc:928
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:429
bool IsStateOff(void) const
Definition: wifi-phy.cc:2127
TracedCallback< Ptr< const Packet >, RxPowerWattPerChannelBand > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
Definition: wifi-phy.h:1317
static Time GetStartOfPacketDuration(const WifiTxVector &txVector)
Definition: wifi-phy.cc:1580
nanosecond
Definition: nstime.h:118
Declaration of ns3::WifiPpdu class and ns3::WifiConstPsduMap.
uint8_t GetNssMax(void) const
bool IsAggregation(void) const
Checks whether the PSDU contains A-MPDU.
bool IsSingle(void) const
Return true if the PSDU is an S-MPDU.
Definition: wifi-psdu.cc:75
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
void NotifyTxBegin(WifiConstPsduMap psdus, double txPowerW)
Public method used to fire a PhyTxBegin trace.
Definition: wifi-phy.cc:1643
Time GetEnergyDuration(double energyW, WifiSpectrumBand band)
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class, for the WifiPhy instance...
Definition: wifi-phy.cc:878
Ptr< Packet > GetAmpduSubframe(std::size_t i) const
Get a copy of the i-th A-MPDU subframe (includes subframe header, MPDU, and possibly padding) ...
Definition: wifi-psdu.cc:290
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
void SetNTxPower(uint8_t n)
Sets the number of transmission power levels available between the minimum level and the maximum leve...
Definition: wifi-phy.cc:725
double m_rxGainDb
Reception gain (dB)
Definition: wifi-phy.h:1405
AttributeValue implementation for Boolean.
Definition: boolean.h:36
void SetNumberOfReceiveAntennas(uint8_t rx)
Set the number of RX antennas in the receiver corresponding to this interference helper.
double GetRxGain(void) const
Return the reception gain (dB).
Definition: wifi-phy.cc:758
static std::map< WifiModulationClass, Ptr< PhyEntity > > m_staticPhyEntities
Map of implemented PHY entities.
Definition: wifi-phy.h:1384
bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
Definition: wifi-phy.cc:1961
void AddSupportedChannelWidth(uint16_t width)
Definition: wifi-phy.cc:1442
double GetCcaEdThreshold(void) const
Return the CCA threshold (dBm).
Definition: wifi-phy.cc:685
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
void NotifyTxEnd(WifiConstPsduMap psdus)
Public method used to fire a PhyTxEnd trace.
Definition: wifi-phy.cc:1655
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
double m_txGainDb
Transmission gain (dB)
Definition: wifi-phy.h:1404
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void AbortCurrentReception(WifiPhyRxfailureReason reason)
Due to newly arrived signal, the current reception cannot be continued and has to be aborted...
Definition: wifi-phy.cc:2167
virtual ~WifiPhy()
Definition: wifi-phy.cc:590
Time DoChannelSwitch(void)
Perform any actions necessary when user changes operating channel after initialization.
Definition: wifi-phy.cc:1299
void ResumeFromOff(void)
Resume from off mode.
Definition: wifi-phy.cc:1543
Ptr< WifiPhyStateHelper > GetState(void) const
Return the WifiPhyStateHelper of this PHY.
Definition: wifi-phy.cc:629
void ResumeFromSleep(void)
Resume from sleep mode.
Definition: wifi-phy.cc:1512
#define min(a, b)
Definition: 80211b.c:42
double m_rxSensitivityW
Receive sensitivity threshold in watts.
Definition: wifi-phy.h:1402
void SetOperatingChannel(uint8_t number, uint16_t frequency, uint16_t width)
Set the operating channel according to the specified parameters.
Definition: wifi-phy.cc:1256
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:1124
Ptr< const WifiPsdu > GetAddressedPsduInPpdu(Ptr< const WifiPpdu > ppdu) const
Get the PSDU addressed to that PHY in a PPDU (useful for MU PPDU).
Definition: wifi-phy.cc:2255
void SetTxGain(double gain)
Sets the transmission gain (dB).
Definition: wifi-phy.cc:738
void Configure80211ax(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ax standard...
Definition: wifi-phy.cc:1054
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: wifi-utils.cc:41
void SetRxSensitivity(double threshold)
Sets the receive sensitivity threshold (dBm).
Definition: wifi-phy.cc:665
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: boolean.h:85
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1069
virtual void DoDispose(void)
Destructor implementation.
Definition: wifi-phy.cc:596
def start()
Definition: core.py:1855
double m_powerDensityLimit
the power density limit (dBm/MHz)
Definition: wifi-phy.h:1409
The PHY layer is sleeping.
std::list< WifiMode > GetModeList(void) const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition: wifi-phy.cc:2000
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Definition: wifi-phy.h:1341
WifiSpectrumBand GetPrimaryBand(uint16_t bandWidth)
If the operating channel width is a multiple of 20 MHz, return the start band index and the stop band...
Definition: wifi-phy.cc:2283
bool IsStateCcaBusy(void) const
Definition: wifi-phy.cc:2091
void SetReceiveErrorCallback(RxErrorCallback callback)
Definition: wifi-phy.cc:641
WifiModulationClass GetModulationClass(void) const
Get the modulation class specified by this TXVECTOR.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
bool IsInitialized(void) const
Check if the object has been initialized.
Definition: object.cc:208
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:411
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
void SetSlot(Time slot)
Set the slot duration for this PHY.
Definition: wifi-phy.cc:916
void SetShortPhyPreambleSupported(bool preamble)
Enable or disable short PHY preamble.
Definition: wifi-phy.cc:764
TracedCallback< WifiTxVector, Time > m_phyRxPayloadBeginTrace
The trace source fired when the reception of the PHY payload (PSDU) begins.
Definition: wifi-phy.h:1333
uint16_t GetFrequency(void) const
Return the center frequency of the operating channel (in MHz).
EventId m_endPhyRxEvent
the end of PHY receive event
Definition: wifi-phy.h:1179
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:789
void UnregisterListener(WifiPhyListener *listener)
Definition: wifi-phy.cc:653
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
void SetRxNoiseFigure(double noiseFigureDb)
Sets the RX loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
Definition: wifi-phy.cc:691
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
bool IsStrictlyPositive(void) const
Exactly equivalent to t > 0.
Definition: nstime.h:333
bool IsStateIdle(void) const
Definition: wifi-phy.cc:2097
Class that keeps track of all information about the current PHY operating channel.
void Reset(void)
Reset data upon end of TX or RX.
Definition: wifi-phy.cc:1878
The 5 GHz band.
Definition: wifi-phy-band.h:37
TracedCallback< Ptr< const Packet >, WifiPhyRxfailureReason > m_phyRxDropTrace
The trace source fired when the PHY layer drops a packet it has received.
Definition: wifi-phy.h:1348
virtual WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, HeRu::SubcarrierRange range, uint8_t bandIndex=0) const
Definition: wifi-phy.cc:1924
uint8_t m_nTxPower
Number of available transmission power levels.
Definition: wifi-phy.h:1408
TracedCallback< Ptr< const Packet >, uint16_t, WifiTxVector, MpduInfo, SignalNoiseDbm, uint16_t > m_phyMonitorSniffRxTrace
A trace source that emulates a Wi-Fi device in monitor mode sniffing a packet being received...
Definition: wifi-phy.h:1362
std::list< WifiMode > GetMcsList(void) const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
Definition: wifi-phy.cc:2049
virtual void SetFrequency(uint16_t freq)
If the operating channel for this object has not been set yet, the given center frequency is saved an...
Definition: wifi-phy.cc:1143
double CalculateSnr(const WifiTxVector &txVector, double ber) const
Definition: wifi-phy.cc:864
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
Definition: wifi-phy.cc:822
void ResetCca(bool powerRestricted, double txPowerMaxSiso=0, double txPowerMaxMimo=0)
Reset PHY to IDLE, with some potential TX power restrictions for the next transmission.
Definition: wifi-phy.cc:2203
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:47
uint8_t m_initialChannelNumber
Store channel number until initialization.
Definition: wifi-phy.h:1389
void NotifyRxEnd(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyRxEnd trace.
Definition: wifi-phy.cc:1688
bool IsStateSleep(void) const
Definition: wifi-phy.cc:2121
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:65
MpduType
The type of an MPDU.
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
Definition: he-ru.h:53
double GetRxSensitivity(void) const
Return the receive sensitivity threshold (dBm).
Definition: wifi-phy.cc:672
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
mobility
Definition: third.py:108
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:777
HR/DSSS (Clause 16)
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1233
bool m_powerRestricted
Flag whether transmit power is restricted by OBSS PD SR.
Definition: wifi-phy.h:1411
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Definition: wifi-phy.cc:1616
void SwitchMaybeToCcaBusy(uint16_t channelWidth)
Check if PHY state should move to CCA busy state based on current state of interference tracker...
Definition: wifi-phy.cc:2151
Keep track of the current position and velocity of an object.
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
The MPDU is not part of an A-MPDU.
Ptr< const Packet > GetPacket(void) const
Get the PSDU as a single packet.
Definition: wifi-psdu.cc:87
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:66
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate...
static const Ptr< const PhyEntity > GetStaticPhyEntity(WifiModulationClass modulation)
Get the implemented PHY entity corresponding to the modulation class.
Definition: wifi-phy.cc:870
WifiMode GetMcs(WifiModulationClass modulation, uint8_t mcs) const
Get the WifiMode object corresponding to the given MCS of the given modulation class.
Definition: wifi-phy.cc:2084
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:227
Time m_slot
Slot duration.
Definition: wifi-phy.h:1397
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
Definition: wifi-phy.h:1424
bool IsZero(void) const
Exactly equivalent to t == 0.
Definition: nstime.h:301
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:588
AttributeValue implementation for Time.
Definition: nstime.h:1353
double rssi
RSSI in dBm.
Definition: phy-entity.h:69
void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
Definition: wifi-phy.cc:1239
Time m_blockAckTxTime
estimated BlockAck TX time
Definition: wifi-phy.h:1400
receive notifications about PHY events.
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the PHY layer drops a packet as it tries to transmit it.
Definition: wifi-phy.h:1309
double m_txPowerMaxMimo
MIMO maximum transmit power due to OBSS PD SR power restriction (dBm)
Definition: wifi-phy.h:1413
bool m_shortPreamble
Flag if short PHY preamble is supported.
Definition: wifi-phy.h:1416
uint16_t GetWidth(void) const
Return the width of the whole operating channel (in MHz).
static WifiConstPsduMap GetWifiConstPsduMap(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
Get a WifiConstPsduMap from a PSDU and the TXVECTOR to use to send the PSDU.
Definition: wifi-phy.cc:1768
Hold an unsigned integer type.
Definition: uinteger.h:44
EventId m_endTxEvent
the end of transmit event
Definition: wifi-phy.h:1180
Ptr< WifiRadioEnergyModel > m_wifiRadioEnergyModel
Wifi radio energy model.
Definition: wifi-phy.h:1428
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:712
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
Definition: wifi-phy.cc:828
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate...
void NotifyChannelAccessRequested(void)
Notify the PHY that an access to the channel was requested.
Definition: wifi-phy.cc:1954
uint64_t m_previouslyRxPpduUid
UID of the previously received PPDU, reset to UINT64_MAX upon transmission.
Definition: wifi-phy.h:1185
void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
WifiPpduField
The type of PPDU field (grouped for convenience)
uint16_t GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const
Return the channel width used to measure the RSSI.
Definition: wifi-phy.cc:2262
The PHY layer has sense the medium busy through the CCA mechanism.
Time GetDelayUntilIdle(void)
Definition: wifi-phy.cc:2133
OFDM PHY (Clause 17 - amendment for 10 MHz and 5 MHz channels)
uint8_t m_initialPrimary20Index
Store the index of primary20 until initialization.
Definition: wifi-phy.h:1391
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU...
Definition: wifi-phy.h:1177
std::list< uint8_t > GetBssMembershipSelectorList(void) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1427
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
void SetCapabilitiesChangedCallback(Callback< void > callback)
Definition: wifi-phy.cc:659
void SetOffMode(void)
Put in off mode.
Definition: wifi-phy.cc:1497
void AddPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of supported PHY entities for the given modulation class for the WifiPh...
Definition: wifi-phy.cc:894
#define list
Ptr< PreambleDetectionModel > m_preambleDetectionModel
Preamble detection model.
Definition: wifi-phy.h:1427
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
Definition: wifi-phy.cc:840
WifiPhyStandard GetPhyStandard(void) const
Get the configured Wi-Fi standard.
Definition: wifi-phy.cc:1131
Time GetBlockAckTxTime(void) const
Return the estimated BlockAck TX time for this PHY.
Definition: wifi-phy.cc:946
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:808
TracedCallback< WifiConstPsduMap, WifiTxVector, double > m_phyTxPsduBeginTrace
The trace source fired when a PSDU map begins the transmission process on the medium.
Definition: wifi-phy.h:1293
Ptr< MobilityModel > GetMobility(void) const
Return the mobility model this PHY is associated with.
Definition: wifi-phy.cc:795
static Time GetPreambleDetectionDuration(void)
Definition: wifi-phy.cc:1574
Time m_pifs
PCF Interframe Space (PIFS) duration.
Definition: wifi-phy.h:1398
void Set(uint8_t number, uint16_t frequency, uint16_t width, WifiPhyStandard standard, WifiPhyBand band)
Set the channel according to the specified parameters if a unique frequency channel matches the speci...
void SetPostReceptionErrorModel(const Ptr< ErrorModel > em)
Attach a receive ErrorModel to the WifiPhy.
Definition: wifi-phy.cc:815
static TypeId GetTypeId(void)
Get the type ID.
Definition: wifi-phy.cc:297
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
Definition: wifi-psdu.cc:319
Time GetChannelSwitchDelay(void) const
Definition: wifi-phy.cc:858
OFDM PHY (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiPhyBand m_band
WifiPhyBand.
Definition: wifi-phy.h:1387
Hold objects of type Ptr<T>.
Definition: pointer.h:36
static const std::set< FrequencyChannelInfo > m_frequencyChannels
Available frequency channels.
Definition: wifi-phy.h:61
void SetWifiRadioEnergyModel(const Ptr< WifiRadioEnergyModel > wifiRadioEnergyModel)
Sets the wifi radio energy model.
Definition: wifi-phy.cc:834
void EraseEvents(void)
Erase all events.
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1168
The PHY layer is IDLE.
uint8_t GetNumberOfAntennas(void) const
Definition: wifi-phy.cc:1372
static uint32_t GetMaxPsduSize(WifiModulationClass modulation)
Get the maximum PSDU size in bytes for the given modulation class.
Definition: wifi-phy.cc:1637
void NotifyTxDrop(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyTxDrop trace.
Definition: wifi-phy.cc:1667
Time m_sifs
Short Interframe Space (SIFS) duration.
Definition: wifi-phy.h:1396
TracedCallback< Ptr< const Packet >, double > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
Definition: wifi-phy.h:1286
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
virtual void StartTx(Ptr< WifiPpdu > ppdu)=0
uint8_t GetNumber(void) const
Return the channel number identifying the whole operating channel.
void SetDefault(uint16_t width, WifiPhyStandard standard, WifiPhyBand band)
Set the default channel of the given width and for the given PHY standard and band.
void StartReceivePreamble(Ptr< WifiPpdu > ppdu, RxPowerWattPerChannelBand rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Definition: wifi-phy.cc:1890
std::map< std::pair< uint64_t, WifiPreamble >, Ptr< Event > > m_currentPreambleEvents
store event associated to a PPDU (that has a unique ID and preamble combination) whose preamble is be...
Definition: wifi-phy.h:1183
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
Definition: wifi-phy.cc:1409
bool GetShortPhyPreambleSupported(void) const
Return whether short PHY preamble is supported.
Definition: wifi-phy.cc:771
double m_ccaEdThresholdW
Clear channel assessment (CCA) threshold in watts.
Definition: wifi-phy.h:1403
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1174
Time GetPifs(void) const
Return the PCF Interframe Space (PIFS) for this PHY.
Definition: wifi-phy.cc:934
Time GetAckTxTime(void) const
Return the estimated Ack TX time for this PHY.
Definition: wifi-phy.cc:940
void Configure80211ac(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ac standard...
Definition: wifi-phy.cc:1046
WifiMode GetDefaultMode(void) const
Get the default WifiMode supported by the PHY.
Definition: wifi-phy.cc:1974
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:1354
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:47
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class...
Definition: wifi-phy.cc:886
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1199
The 2.4 GHz band.
Definition: wifi-phy-band.h:35
WifiPhyStandard m_standard
WifiPhyStandard.
Definition: wifi-phy.h:1386
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
bool m_channelAccessRequested
Flag if channels access has been requested (used for OBSS_PD SR)
Definition: wifi-phy.h:1414
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Definition: wifi-phy.h:1173
double DbToRatio(double dB)
Convert from dB to ratio.
Definition: wifi-utils.cc:35
uint64_t GetPreviouslyRxPpduUid(void) const
Definition: wifi-phy.cc:1872
bool IsSet(void) const
Return true if a valid channel has been set, false otherwise.
uint8_t m_txSpatialStreams
Number of supported TX spatial streams.
Definition: wifi-phy.h:1418
double GetTxPowerStart(void) const
Return the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:706
Time m_ackTxTime
estimated Ack TX time
Definition: wifi-phy.h:1399
double RatioToDb(double ratio)
Convert from ratio to dB.
Definition: wifi-utils.cc:53
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
Definition: wifi-phy.h:1429
std::vector< uint16_t > GetSupportedChannelWidthSet(void) const
Definition: wifi-phy.cc:1457
Ptr< FrameCaptureModel > m_frameCaptureModel
Frame capture model.
Definition: wifi-phy.h:1426
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
void SetRxGain(double gain)
Sets the reception gain (dB).
Definition: wifi-phy.cc:751
void Configure80211b(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard...
Definition: wifi-phy.cc:967
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:32
void SetSifs(Time sifs)
Set the Short Interframe Space (SIFS) for this PHY.
Definition: wifi-phy.cc:904
void SetReceiveOkCallback(RxOkCallback callback)
Definition: wifi-phy.cc:635
void RegisterListener(WifiPhyListener *listener)
Definition: wifi-phy.cc:647
bool IsStateTx(void) const
Definition: wifi-phy.cc:2109
void NotifyRxBegin(Ptr< const WifiPsdu > psdu, RxPowerWattPerChannelBand rxPowersW)
Public method used to fire a PhyRxBegin trace.
Definition: wifi-phy.cc:1676
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
Definition: wifi-phy.cc:1378
The PHY layer is sending a packet.
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Definition: wifi-phy.h:1174
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
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 Configure80211n(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard...
Definition: wifi-phy.cc:1027
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:699
double m_txPowerBaseDbm
Minimum transmission power (dBm)
Definition: wifi-phy.h:1406
Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
Definition: wifi-phy.cc:910
uint16_t GetDefaultChannelWidth(WifiPhyStandard standard, WifiPhyBand band)
Get the default channel width for the given PHY standard and band.
void SetNoiseFigure(double value)
Set the noise figure.
void ResetReceive(Ptr< Event > event)
Reset PHY at the end of the packet under reception after it has failed the PHY header.
Definition: wifi-phy.cc:1943
double GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
Definition: wifi-phy.cc:2222
SignalNoiseDbm structure.
Definition: phy-entity.h:52
uint32_t mpduRefNumber
MPDU ref number.
Definition: phy-entity.h:62
InterferenceHelper m_interference
the class handling interference computations
Definition: wifi-phy.h:1172
double snr
SNR in linear scale.
Definition: phy-entity.h:68
virtual void SetChannelWidth(uint16_t channelWidth)
If the operating channel for this object has not been set yet, the given channel width is saved and w...
Definition: wifi-phy.cc:1205
bool IsStrictlyNegative(void) const
Exactly equivalent to t < 0.
Definition: nstime.h:325
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
The PHY layer is receiving a packet.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
WifiPhyOperatingChannel m_operatingChannel
Operating channel.
Definition: wifi-phy.h:1393
static Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype=NORMAL_MPDU, uint16_t staId=SU_STA_ID)
Definition: wifi-phy.cc:1586
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:71
double GetTxPowerEnd(void) const
Return the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:719
Time GetSlot(void) const
Return the slot duration for this PHY.
Definition: wifi-phy.cc:922
void EndReceiveInterBss(void)
For HE receptions only, check and possibly modify the transmit power restriction state at the end of ...
Definition: wifi-phy.cc:1933
void NotifyMonitorSniffTx(Ptr< const WifiPsdu > psdu, uint16_t channelFreqMhz, WifiTxVector txVector, uint16_t staId=SU_STA_ID)
Public method used to fire a MonitorSniffer trace for a wifi PSDU being transmitted.
Definition: wifi-phy.cc:1743
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
Definition: wifi-phy.cc:1604
void Send(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
This function is a wrapper for the Send variant that accepts a WifiConstPsduMap as first argument...
Definition: wifi-phy.cc:1774
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
The PHY layer is switched off.
void Configure80211g(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11g standard...
Definition: wifi-phy.cc:984
Ptr< NetDevice > GetDevice(void) const
Return the device this PHY is associated with.
Definition: wifi-phy.cc:783
uint8_t GetTxPowerLevel(void) const
double GetTxGain(void) const
Return the transmission gain (dB).
Definition: wifi-phy.cc:745
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:533
The PHY layer is switching to other channel.
void SetSleepMode(void)
Put in sleep mode.
Definition: wifi-phy.cc:1463
void NotifyMonitorSniffRx(Ptr< const WifiPsdu > psdu, uint16_t channelFreqMhz, WifiTxVector txVector, SignalNoiseDbm signalNoise, std::vector< bool > statusPerMpdu, uint16_t staId=SU_STA_ID)
Public method used to fire a MonitorSniffer trace for a wifi PSDU being received. ...
Definition: wifi-phy.cc:1712
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1305
The 6 GHz band.
Definition: wifi-phy-band.h:39
void SetNumberOfAntennas(uint8_t antennas)
Definition: wifi-phy.cc:1364
uint16_t m_initialChannelWidth
Store channel width (MHz) until initialization.
Definition: wifi-phy.h:1390
const WifiPhyOperatingChannel & GetOperatingChannel(void) const
Get a const reference to the operating channel.
Definition: wifi-phy.cc:1137
second
Definition: nstime.h:115
A base class which provides memory management and object aggregation.
Definition: object.h:87
double m_txPowerEndDbm
Maximum transmission power (dBm)
Definition: wifi-phy.h:1407
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1386
void Configure80211p(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11p standard...
Definition: wifi-phy.cc:997
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
std::map< WifiModulationClass, Ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
Definition: wifi-phy.h:1204
The MPDU is a single MPDU.
MpduType type
type of MPDU
Definition: phy-entity.h:61
Time m_channelSwitchDelay
Time required to switch between channel.
Definition: wifi-phy.h:1421
Time GetLastRxEndTime(void) const
Return the end time of the last received packet.
Definition: wifi-phy.cc:2145
void MaybeCcaBusyDuration(uint16_t channelWidth)
Eventually switch to CCA busy.
Definition: wifi-phy.cc:1910
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
uint8_t m_numberOfAntennas
Number of transmitters.
Definition: wifi-phy.h:1417
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1403
a unique identifier for an interface.
Definition: type-id.h:58
uint16_t GetNMcs(void) const
Definition: wifi-phy.cc:2035
Ptr< Event > m_currentEvent
Hold the current event.
Definition: wifi-phy.h:1182
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
Time GetLastRxStartTime(void) const
Return the start time of the last received packet.
Definition: wifi-phy.cc:2139
double m_txPowerMaxSiso
SISO maximum transmit power due to OBSS PD SR power restriction (dBm)
Definition: wifi-phy.h:1412
bool IsStateRx(void) const
Definition: wifi-phy.cc:2103
bool IsMcsSupported(WifiModulationClass modulation, uint8_t mcs) const
Check if the given MCS of the given modulation class is supported by the PHY.
Definition: wifi-phy.cc:1989
uint8_t m_rxSpatialStreams
Number of supported RX spatial streams.
Definition: wifi-phy.h:1419
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
std::vector< uint16_t > m_supportedChannelWidthSet
Supported channel width set (MHz)
Definition: wifi-phy.h:1394
TracedCallback< Ptr< const Packet >, uint16_t, WifiTxVector, MpduInfo, uint16_t > m_phyMonitorSniffTxTrace
A trace source that emulates a Wi-Fi device in monitor mode sniffing a packet being transmitted...
Definition: wifi-phy.h:1376
void SetCcaEdThreshold(double threshold)
Sets the CCA threshold (dBm).
Definition: wifi-phy.cc:678
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: wifi-phy.cc:2294
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:75
static Time GetPpduFieldDuration(WifiPpduField field, const WifiTxVector &txVector)
Get the duration of the PPDU field (or group of fields) for the given transmission parameters...
Definition: wifi-phy.cc:1610
Callback< void > m_capabilitiesChangedCallback
Callback when PHY capabilities changed.
Definition: wifi-phy.h:1432
void Configure80211a(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard...
Definition: wifi-phy.cc:952
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1421
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium. ...
Definition: wifi-phy.h:1301
uint16_t m_initialFrequency
Store frequency until initialization (MHz)
Definition: wifi-phy.h:1388
bool IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.
Definition: wifi-psdu.cc:81
virtual WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0)
Get the start band index and the stop band index for a given band.
Definition: wifi-phy.cc:2274