LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2005,2006 INRIA | 3 * Copyright (c) 2005,2006 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 18 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
19 * Sébastien Deronne <sebastien.deronne@gmail.com> | 19 * Sébastien Deronne <sebastien.deronne@gmail.com> |
20 */ | 20 */ |
21 | 21 |
22 #include "wifi-phy.h" | |
23 #include "wifi-phy-state-helper.h" | |
24 #include "ns3/simulator.h" | 22 #include "ns3/simulator.h" |
25 #include "ns3/log.h" | 23 #include "ns3/log.h" |
26 #include "ns3/boolean.h" | |
27 #include "ns3/double.h" | |
28 #include "ns3/uinteger.h" | |
29 #include "ns3/pointer.h" | 24 #include "ns3/pointer.h" |
| 25 #include "ns3/mobility-model.h" |
| 26 #include "ns3/random-variable-stream.h" |
| 27 #include "wifi-phy.h" |
30 #include "wifi-phy-tag.h" | 28 #include "wifi-phy-tag.h" |
31 #include "ampdu-tag.h" | 29 #include "ampdu-tag.h" |
32 #include "wifi-utils.h" | 30 #include "wifi-utils.h" |
33 #include "frame-capture-model.h" | 31 #include "frame-capture-model.h" |
34 #include "wifi-radio-energy-model.h" | 32 #include "wifi-radio-energy-model.h" |
| 33 #include "error-rate-model.h" |
35 | 34 |
36 namespace ns3 { | 35 namespace ns3 { |
37 | 36 |
38 NS_LOG_COMPONENT_DEFINE ("WifiPhy"); | 37 NS_LOG_COMPONENT_DEFINE ("WifiPhy"); |
39 | |
40 /**************************************************************** | |
41 * This destructor is needed. | |
42 ****************************************************************/ | |
43 | |
44 WifiPhyListener::~WifiPhyListener () | |
45 { | |
46 } | |
47 | 38 |
48 /**************************************************************** | 39 /**************************************************************** |
49 * The actual WifiPhy class | 40 * The actual WifiPhy class |
50 ****************************************************************/ | 41 ****************************************************************/ |
51 | 42 |
52 NS_OBJECT_ENSURE_REGISTERED (WifiPhy); | 43 NS_OBJECT_ENSURE_REGISTERED (WifiPhy); |
53 | 44 |
54 /** | 45 /** |
55 * This table maintains the mapping of valid ChannelNumber to | 46 * This table maintains the mapping of valid ChannelNumber to |
56 * Frequency/ChannelWidth pairs. If you want to make a channel applicable | 47 * Frequency/ChannelWidth pairs. If you want to make a channel applicable |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 "The operating center frequency (MHz)", | 153 "The operating center frequency (MHz)", |
163 UintegerValue (0), | 154 UintegerValue (0), |
164 MakeUintegerAccessor (&WifiPhy::GetFrequency, | 155 MakeUintegerAccessor (&WifiPhy::GetFrequency, |
165 &WifiPhy::SetFrequency), | 156 &WifiPhy::SetFrequency), |
166 MakeUintegerChecker<uint16_t> ()) | 157 MakeUintegerChecker<uint16_t> ()) |
167 .AddAttribute ("ChannelWidth", | 158 .AddAttribute ("ChannelWidth", |
168 "Whether 5MHz, 10MHz, 20MHz, 22MHz, 40MHz, 80 MHz or 160 MHz.
", | 159 "Whether 5MHz, 10MHz, 20MHz, 22MHz, 40MHz, 80 MHz or 160 MHz.
", |
169 UintegerValue (20), | 160 UintegerValue (20), |
170 MakeUintegerAccessor (&WifiPhy::GetChannelWidth, | 161 MakeUintegerAccessor (&WifiPhy::GetChannelWidth, |
171 &WifiPhy::SetChannelWidth), | 162 &WifiPhy::SetChannelWidth), |
172 MakeUintegerChecker<uint8_t> (5, 160)) | 163 MakeUintegerChecker<uint16_t> (5, 160)) |
173 .AddAttribute ("ChannelNumber", | 164 .AddAttribute ("ChannelNumber", |
174 "If set to non-zero defined value, will control Frequency and
ChannelWidth assignment", | 165 "If set to non-zero defined value, will control Frequency and
ChannelWidth assignment", |
175 UintegerValue (0), | 166 UintegerValue (0), |
176 MakeUintegerAccessor (&WifiPhy::SetChannelNumber, | 167 MakeUintegerAccessor (&WifiPhy::SetChannelNumber, |
177 &WifiPhy::GetChannelNumber), | 168 &WifiPhy::GetChannelNumber), |
178 MakeUintegerChecker<uint8_t> (0, 196)) | 169 MakeUintegerChecker<uint8_t> (0, 196)) |
179 .AddAttribute ("EnergyDetectionThreshold", | 170 .AddAttribute ("EnergyDetectionThreshold", |
180 "The energy of a received signal should be higher than " | 171 "The energy of a received signal should be higher than " |
181 "this threshold (dbm) to allow the PHY layer to detect the si
gnal.", | 172 "this threshold (dbm) to allow the PHY layer to detect the si
gnal.", |
182 DoubleValue (-96.0), | 173 DoubleValue (-96.0), |
183 MakeDoubleAccessor (&WifiPhy::SetEdThreshold, | 174 MakeDoubleAccessor (&WifiPhy::SetEdThreshold), |
184 &WifiPhy::GetEdThreshold), | |
185 MakeDoubleChecker<double> ()) | 175 MakeDoubleChecker<double> ()) |
186 .AddAttribute ("CcaMode1Threshold", | 176 .AddAttribute ("CcaMode1Threshold", |
187 "The energy of a received signal should be higher than " | 177 "The energy of a received signal should be higher than " |
188 "this threshold (dbm) to allow the PHY layer to declare CCA B
USY state.", | 178 "this threshold (dbm) to allow the PHY layer to declare CCA B
USY state.", |
189 DoubleValue (-99.0), | 179 DoubleValue (-99.0), |
190 MakeDoubleAccessor (&WifiPhy::SetCcaMode1Threshold, | 180 MakeDoubleAccessor (&WifiPhy::SetCcaMode1Threshold, |
191 &WifiPhy::GetCcaMode1Threshold), | 181 &WifiPhy::GetCcaMode1Threshold), |
192 MakeDoubleChecker<double> ()) | 182 MakeDoubleChecker<double> ()) |
193 .AddAttribute ("TxGain", | 183 .AddAttribute ("TxGain", |
194 "Transmission gain (dB).", | 184 "Transmission gain (dB).", |
195 DoubleValue (0.0), | 185 DoubleValue (0.0), |
196 MakeDoubleAccessor (&WifiPhy::SetTxGain, | 186 MakeDoubleAccessor (&WifiPhy::SetTxGain, |
197 &WifiPhy::GetTxGain), | 187 &WifiPhy::GetTxGain), |
198 MakeDoubleChecker<double> ()) | 188 MakeDoubleChecker<double> ()) |
199 .AddAttribute ("RxGain", | 189 .AddAttribute ("RxGain", |
200 "Reception gain (dB).", | 190 "Reception gain (dB).", |
201 DoubleValue (0.0), | 191 DoubleValue (0.0), |
202 MakeDoubleAccessor (&WifiPhy::SetRxGain, | 192 MakeDoubleAccessor (&WifiPhy::SetRxGain, |
203 &WifiPhy::GetRxGain), | 193 &WifiPhy::GetRxGain), |
204 MakeDoubleChecker<double> ()) | 194 MakeDoubleChecker<double> ()) |
205 .AddAttribute ("TxPowerLevels", | 195 .AddAttribute ("TxPowerLevels", |
206 "Number of transmission power levels available between " | 196 "Number of transmission power levels available between " |
207 "TxPowerStart and TxPowerEnd included.", | 197 "TxPowerStart and TxPowerEnd included.", |
208 UintegerValue (1), | 198 UintegerValue (1), |
209 MakeUintegerAccessor (&WifiPhy::m_nTxPower), | 199 MakeUintegerAccessor (&WifiPhy::m_nTxPower), |
210 MakeUintegerChecker<uint32_t> ()) | 200 MakeUintegerChecker<uint8_t> ()) |
211 .AddAttribute ("TxPowerEnd", | 201 .AddAttribute ("TxPowerEnd", |
212 "Maximum available transmission level (dbm).", | 202 "Maximum available transmission level (dbm).", |
213 DoubleValue (16.0206), | 203 DoubleValue (16.0206), |
214 MakeDoubleAccessor (&WifiPhy::SetTxPowerEnd, | 204 MakeDoubleAccessor (&WifiPhy::SetTxPowerEnd, |
215 &WifiPhy::GetTxPowerEnd), | 205 &WifiPhy::GetTxPowerEnd), |
216 MakeDoubleChecker<double> ()) | 206 MakeDoubleChecker<double> ()) |
217 .AddAttribute ("TxPowerStart", | 207 .AddAttribute ("TxPowerStart", |
218 "Minimum available transmission level (dbm).", | 208 "Minimum available transmission level (dbm).", |
219 DoubleValue (16.0206), | 209 DoubleValue (16.0206), |
220 MakeDoubleAccessor (&WifiPhy::SetTxPowerStart, | 210 MakeDoubleAccessor (&WifiPhy::SetTxPowerStart, |
221 &WifiPhy::GetTxPowerStart), | 211 &WifiPhy::GetTxPowerStart), |
222 MakeDoubleChecker<double> ()) | 212 MakeDoubleChecker<double> ()) |
223 .AddAttribute ("RxNoiseFigure", | 213 .AddAttribute ("RxNoiseFigure", |
224 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities
in the receiver." | 214 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities
in the receiver." |
225 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_
figure), this is " | 215 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_
figure), this is " |
226 "\"the difference in decibels (dB) between" | 216 "\"the difference in decibels (dB) between" |
227 " the noise output of the actual receiver to the noise output
of an " | 217 " the noise output of the actual receiver to the noise output
of an " |
228 " ideal receiver with the same overall gain and bandwidth whe
n the receivers " | 218 " ideal receiver with the same overall gain and bandwidth whe
n the receivers " |
229 " are connected to sources at the standard noise temperature
T0 (usually 290 K)\".", | 219 " are connected to sources at the standard noise temperature
T0 (usually 290 K)\".", |
230 DoubleValue (7), | 220 DoubleValue (7), |
231 MakeDoubleAccessor (&WifiPhy::SetRxNoiseFigure, | 221 MakeDoubleAccessor (&WifiPhy::SetRxNoiseFigure), |
232 &WifiPhy::GetRxNoiseFigure), | |
233 MakeDoubleChecker<double> ()) | 222 MakeDoubleChecker<double> ()) |
234 .AddAttribute ("State", | 223 .AddAttribute ("State", |
235 "The state of the PHY layer.", | 224 "The state of the PHY layer.", |
236 PointerValue (), | 225 PointerValue (), |
237 MakePointerAccessor (&WifiPhy::m_state), | 226 MakePointerAccessor (&WifiPhy::m_state), |
238 MakePointerChecker<WifiPhyStateHelper> ()) | 227 MakePointerChecker<WifiPhyStateHelper> ()) |
239 .AddAttribute ("ChannelSwitchDelay", | 228 .AddAttribute ("ChannelSwitchDelay", |
240 "Delay between two short frames transmitted on different freq
uencies.", | 229 "Delay between two short frames transmitted on different freq
uencies.", |
241 TimeValue (MicroSeconds (250)), | 230 TimeValue (MicroSeconds (250)), |
242 MakeTimeAccessor (&WifiPhy::m_channelSwitchDelay), | 231 MakeTimeAccessor (&WifiPhy::m_channelSwitchDelay), |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 .AddAttribute ("ShortPlcpPreambleSupported", | 286 .AddAttribute ("ShortPlcpPreambleSupported", |
298 "Whether or not short PLCP preamble is supported." | 287 "Whether or not short PLCP preamble is supported." |
299 "This parameter is only valuable for 802.11b STAs and APs." | 288 "This parameter is only valuable for 802.11b STAs and APs." |
300 "Note: 802.11g APs and STAs always support short PLCP preambl
e.", | 289 "Note: 802.11g APs and STAs always support short PLCP preambl
e.", |
301 BooleanValue (false), | 290 BooleanValue (false), |
302 MakeBooleanAccessor (&WifiPhy::GetShortPlcpPreambleSupported, | 291 MakeBooleanAccessor (&WifiPhy::GetShortPlcpPreambleSupported, |
303 &WifiPhy::SetShortPlcpPreambleSupported)
, | 292 &WifiPhy::SetShortPlcpPreambleSupported)
, |
304 MakeBooleanChecker ()) | 293 MakeBooleanChecker ()) |
305 .AddAttribute ("FrameCaptureModel", | 294 .AddAttribute ("FrameCaptureModel", |
306 "Ptr to an object that implements the frame capture model", | 295 "Ptr to an object that implements the frame capture model", |
307 PointerValue (0), //StringValue ("ns3::SimpleFrameCaptureMode
l"), | 296 PointerValue (), |
308 MakePointerAccessor (&WifiPhy::GetFrameCaptureModel, | 297 MakePointerAccessor (&WifiPhy::m_frameCaptureModel), |
309 &WifiPhy::SetFrameCaptureModel), | |
310 MakePointerChecker <FrameCaptureModel> ()) | 298 MakePointerChecker <FrameCaptureModel> ()) |
311 .AddTraceSource ("PhyTxBegin", | 299 .AddTraceSource ("PhyTxBegin", |
312 "Trace source indicating a packet " | 300 "Trace source indicating a packet " |
313 "has begun transmitting over the channel medium", | 301 "has begun transmitting over the channel medium", |
314 MakeTraceSourceAccessor (&WifiPhy::m_phyTxBeginTrace), | 302 MakeTraceSourceAccessor (&WifiPhy::m_phyTxBeginTrace), |
315 "ns3::Packet::TracedCallback") | 303 "ns3::Packet::TracedCallback") |
316 .AddTraceSource ("PhyTxEnd", | 304 .AddTraceSource ("PhyTxEnd", |
317 "Trace source indicating a packet " | 305 "Trace source indicating a packet " |
318 "has been completely transmitted over the channel. " | 306 "has been completely transmitted over the channel. " |
319 "NOTE: the only official WifiPhy implementation " | 307 "NOTE: the only official WifiPhy implementation " |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 m_plcpSuccess (false), | 350 m_plcpSuccess (false), |
363 m_txMpduReferenceNumber (0xffffffff), | 351 m_txMpduReferenceNumber (0xffffffff), |
364 m_rxMpduReferenceNumber (0xffffffff), | 352 m_rxMpduReferenceNumber (0xffffffff), |
365 m_endRxEvent (), | 353 m_endRxEvent (), |
366 m_endPlcpRxEvent (), | 354 m_endPlcpRxEvent (), |
367 m_standard (WIFI_PHY_STANDARD_UNSPECIFIED), | 355 m_standard (WIFI_PHY_STANDARD_UNSPECIFIED), |
368 m_isConstructed (false), | 356 m_isConstructed (false), |
369 m_channelCenterFrequency (0), | 357 m_channelCenterFrequency (0), |
370 m_initialFrequency (0), | 358 m_initialFrequency (0), |
371 m_frequencyChannelNumberInitialized (false), | 359 m_frequencyChannelNumberInitialized (false), |
| 360 m_channelWidth (0), |
| 361 m_txSpatialStreams (0), |
| 362 m_rxSpatialStreams (0), |
372 m_channelNumber (0), | 363 m_channelNumber (0), |
373 m_initialChannelNumber (0), | 364 m_initialChannelNumber (0), |
374 m_totalAmpduSize (0), | 365 m_totalAmpduSize (0), |
375 m_totalAmpduNumSymbols (0), | 366 m_totalAmpduNumSymbols (0), |
376 m_currentEvent (0), | 367 m_currentEvent (0), |
377 m_wifiRadioEnergyModel (0) | 368 m_wifiRadioEnergyModel (0) |
378 { | 369 { |
379 NS_LOG_FUNCTION (this); | 370 NS_LOG_FUNCTION (this); |
380 m_random = CreateObject<UniformRandomVariable> (); | 371 m_random = CreateObject<UniformRandomVariable> (); |
381 m_state = CreateObject<WifiPhyStateHelper> (); | 372 m_state = CreateObject<WifiPhyStateHelper> (); |
382 } | 373 } |
383 | 374 |
384 WifiPhy::~WifiPhy () | 375 WifiPhy::~WifiPhy () |
385 { | 376 { |
386 NS_LOG_FUNCTION (this); | 377 NS_LOG_FUNCTION (this); |
387 } | 378 } |
388 | 379 |
389 void | 380 void |
390 WifiPhy::DoDispose (void) | 381 WifiPhy::DoDispose (void) |
391 { | 382 { |
392 NS_LOG_FUNCTION (this); | 383 NS_LOG_FUNCTION (this); |
393 m_device = 0; | 384 m_device = 0; |
394 m_mobility = 0; | 385 m_mobility = 0; |
395 m_state = 0; | 386 m_state = 0; |
| 387 m_wifiRadioEnergyModel = 0; |
396 m_deviceRateSet.clear (); | 388 m_deviceRateSet.clear (); |
397 m_deviceMcsSet.clear (); | 389 m_deviceMcsSet.clear (); |
398 } | 390 } |
399 | 391 |
400 void | 392 void |
401 WifiPhy::DoInitialize (void) | 393 WifiPhy::DoInitialize (void) |
402 { | 394 { |
403 NS_LOG_FUNCTION (this); | 395 NS_LOG_FUNCTION (this); |
404 m_isConstructed = true; | 396 m_isConstructed = true; |
405 if (m_frequencyChannelNumberInitialized == true) | 397 if (m_frequencyChannelNumberInitialized == true) |
(...skipping 19 matching lines...) Expand all Loading... |
425 void | 417 void |
426 WifiPhy::RegisterListener (WifiPhyListener *listener) | 418 WifiPhy::RegisterListener (WifiPhyListener *listener) |
427 { | 419 { |
428 m_state->RegisterListener (listener); | 420 m_state->RegisterListener (listener); |
429 } | 421 } |
430 | 422 |
431 void | 423 void |
432 WifiPhy::UnregisterListener (WifiPhyListener *listener) | 424 WifiPhy::UnregisterListener (WifiPhyListener *listener) |
433 { | 425 { |
434 m_state->UnregisterListener (listener); | 426 m_state->UnregisterListener (listener); |
| 427 } |
| 428 |
| 429 void |
| 430 WifiPhy::SetCapabilitiesChangedCallback (Callback<void> callback) |
| 431 { |
| 432 m_capabilitiesChangedCallback = callback; |
435 } | 433 } |
436 | 434 |
437 void | 435 void |
438 WifiPhy::InitializeFrequencyChannelNumber (void) | 436 WifiPhy::InitializeFrequencyChannelNumber (void) |
439 { | 437 { |
440 NS_LOG_FUNCTION (this); | 438 NS_LOG_FUNCTION (this); |
441 | 439 |
442 NS_ASSERT_MSG (m_frequencyChannelNumberInitialized == false, "Initialization c
alled twice"); | 440 NS_ASSERT_MSG (m_frequencyChannelNumberInitialized == false, "Initialization c
alled twice"); |
443 | 441 |
444 // If frequency has been set to a non-zero value during attribute | 442 // If frequency has been set to a non-zero value during attribute |
445 // construction phase, the frequency and channel width will drive the | 443 // construction phase, the frequency and channel width will drive the |
446 // initial configuration. If frequency has not been set, but both | 444 // initial configuration. If frequency has not been set, but both |
447 // standard and channel number have been set, that pair will instead | 445 // standard and channel number have been set, that pair will instead |
448 // drive the configuration, and frequency and channel number will be | 446 // drive the configuration, and frequency and channel number will be |
449 // aligned | 447 // aligned |
450 if (m_initialFrequency != 0) | 448 if (m_initialFrequency != 0) |
451 { | 449 { |
452 SetFrequency (m_initialFrequency); | 450 SetFrequency (m_initialFrequency); |
453 } | 451 } |
454 else if (m_initialChannelNumber != 0 && GetStandard () != WIFI_PHY_STANDARD_UN
SPECIFIED) | 452 else if (m_initialChannelNumber != 0 && GetStandard () != WIFI_PHY_STANDARD_UN
SPECIFIED) |
455 { | 453 { |
456 SetChannelNumber (m_initialChannelNumber); | 454 SetChannelNumber (m_initialChannelNumber); |
457 } | 455 } |
458 else if (m_initialChannelNumber != 0 && GetStandard () == WIFI_PHY_STANDARD_UN
SPECIFIED) | 456 else if (m_initialChannelNumber != 0 && GetStandard () == WIFI_PHY_STANDARD_UN
SPECIFIED) |
459 { | 457 { |
460 NS_FATAL_ERROR ("Error, ChannelNumber " << static_cast<uint16_t> (GetChann
elNumber ()) << " was set by user, but neither a standard nor a frequency"); | 458 NS_FATAL_ERROR ("Error, ChannelNumber " << +GetChannelNumber () << " was s
et by user, but neither a standard nor a frequency"); |
461 } | 459 } |
462 m_frequencyChannelNumberInitialized = true; | 460 m_frequencyChannelNumberInitialized = true; |
463 } | 461 } |
464 | 462 |
465 void | 463 void |
466 WifiPhy::SetEdThreshold (double threshold) | 464 WifiPhy::SetEdThreshold (double threshold) |
467 { | 465 { |
468 NS_LOG_FUNCTION (this << threshold); | 466 NS_LOG_FUNCTION (this << threshold); |
469 m_edThresholdW = DbmToW (threshold); | 467 m_edThresholdW = DbmToW (threshold); |
470 } | |
471 | |
472 double | |
473 WifiPhy::GetEdThresholdW (void) const | |
474 { | |
475 return m_edThresholdW; | |
476 } | 468 } |
477 | 469 |
478 double | 470 double |
479 WifiPhy::GetEdThreshold (void) const | 471 WifiPhy::GetEdThreshold (void) const |
480 { | 472 { |
481 return WToDbm (m_edThresholdW); | 473 return WToDbm (m_edThresholdW); |
482 } | 474 } |
483 | 475 |
484 void | 476 void |
485 WifiPhy::SetCcaMode1Threshold (double threshold) | 477 WifiPhy::SetCcaMode1Threshold (double threshold) |
486 { | 478 { |
487 NS_LOG_FUNCTION (this << threshold); | 479 NS_LOG_FUNCTION (this << threshold); |
488 m_ccaMode1ThresholdW = DbmToW (threshold); | 480 m_ccaMode1ThresholdW = DbmToW (threshold); |
489 } | 481 } |
490 | 482 |
491 double | 483 double |
492 WifiPhy::GetCcaMode1Threshold (void) const | 484 WifiPhy::GetCcaMode1Threshold (void) const |
493 { | 485 { |
494 return WToDbm (m_ccaMode1ThresholdW); | 486 return WToDbm (m_ccaMode1ThresholdW); |
495 } | 487 } |
496 | 488 |
497 void | 489 void |
498 WifiPhy::SetRxNoiseFigure (double noiseFigureDb) | 490 WifiPhy::SetRxNoiseFigure (double noiseFigureDb) |
499 { | 491 { |
500 NS_LOG_FUNCTION (this << noiseFigureDb); | 492 NS_LOG_FUNCTION (this << noiseFigureDb); |
501 m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb)); | 493 m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb)); |
502 m_interference.SetNumberOfReceiveAntennas (GetNumberOfAntennas ()); | 494 m_interference.SetNumberOfReceiveAntennas (GetNumberOfAntennas ()); |
503 } | 495 } |
504 | 496 |
505 double | |
506 WifiPhy::GetRxNoiseFigure (void) const | |
507 { | |
508 return RatioToDb (m_interference.GetNoiseFigure ()); | |
509 } | |
510 | |
511 void | 497 void |
512 WifiPhy::SetTxPowerStart (double start) | 498 WifiPhy::SetTxPowerStart (double start) |
513 { | 499 { |
514 NS_LOG_FUNCTION (this << start); | 500 NS_LOG_FUNCTION (this << start); |
515 m_txPowerBaseDbm = start; | 501 m_txPowerBaseDbm = start; |
516 } | 502 } |
517 | 503 |
518 double | 504 double |
519 WifiPhy::GetTxPowerStart (void) const | 505 WifiPhy::GetTxPowerStart (void) const |
520 { | 506 { |
521 return m_txPowerBaseDbm; | 507 return m_txPowerBaseDbm; |
522 } | 508 } |
523 | 509 |
524 void | 510 void |
525 WifiPhy::SetTxPowerEnd (double end) | 511 WifiPhy::SetTxPowerEnd (double end) |
526 { | 512 { |
527 NS_LOG_FUNCTION (this << end); | 513 NS_LOG_FUNCTION (this << end); |
528 m_txPowerEndDbm = end; | 514 m_txPowerEndDbm = end; |
529 } | 515 } |
530 | 516 |
531 double | 517 double |
532 WifiPhy::GetTxPowerEnd (void) const | 518 WifiPhy::GetTxPowerEnd (void) const |
533 { | 519 { |
534 return m_txPowerEndDbm; | 520 return m_txPowerEndDbm; |
535 } | 521 } |
536 | 522 |
537 void | 523 void |
538 WifiPhy::SetNTxPower (uint8_t n) | 524 WifiPhy::SetNTxPower (uint8_t n) |
539 { | 525 { |
540 NS_LOG_FUNCTION (this << n); | 526 NS_LOG_FUNCTION (this << +n); |
541 m_nTxPower = n; | 527 m_nTxPower = n; |
542 } | 528 } |
543 | 529 |
544 uint8_t | 530 uint8_t |
545 WifiPhy::GetNTxPower (void) const | 531 WifiPhy::GetNTxPower (void) const |
546 { | 532 { |
547 return m_nTxPower; | 533 return m_nTxPower; |
548 } | 534 } |
549 | 535 |
550 void | 536 void |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 } | 669 } |
684 } | 670 } |
685 | 671 |
686 void | 672 void |
687 WifiPhy::SetErrorRateModel (const Ptr<ErrorRateModel> rate) | 673 WifiPhy::SetErrorRateModel (const Ptr<ErrorRateModel> rate) |
688 { | 674 { |
689 m_interference.SetErrorRateModel (rate); | 675 m_interference.SetErrorRateModel (rate); |
690 m_interference.SetNumberOfReceiveAntennas (GetNumberOfAntennas ()); | 676 m_interference.SetNumberOfReceiveAntennas (GetNumberOfAntennas ()); |
691 } | 677 } |
692 | 678 |
693 Ptr<ErrorRateModel> | |
694 WifiPhy::GetErrorRateModel (void) const | |
695 { | |
696 return m_interference.GetErrorRateModel (); | |
697 } | |
698 | |
699 void | 679 void |
700 WifiPhy::SetFrameCaptureModel (const Ptr<FrameCaptureModel> model) | 680 WifiPhy::SetFrameCaptureModel (const Ptr<FrameCaptureModel> model) |
701 { | 681 { |
702 m_frameCaptureModel = model; | 682 m_frameCaptureModel = model; |
703 } | 683 } |
704 | 684 |
705 Ptr<FrameCaptureModel> | |
706 WifiPhy::GetFrameCaptureModel (void) const | |
707 { | |
708 return m_frameCaptureModel; | |
709 } | |
710 ···· | |
711 void | 685 void |
712 WifiPhy::SetWifiRadioEnergyModel (const Ptr<WifiRadioEnergyModel> wifiRadioEnerg
yModel) | 686 WifiPhy::SetWifiRadioEnergyModel (const Ptr<WifiRadioEnergyModel> wifiRadioEnerg
yModel) |
713 { | 687 { |
714 m_wifiRadioEnergyModel = wifiRadioEnergyModel; | 688 m_wifiRadioEnergyModel = wifiRadioEnergyModel; |
715 } | 689 } |
716 | 690 |
717 double | 691 double |
718 WifiPhy::GetPowerDbm (uint8_t power) const | 692 WifiPhy::GetPowerDbm (uint8_t power) const |
719 { | 693 { |
720 NS_ASSERT (m_txPowerBaseDbm <= m_txPowerEndDbm); | 694 NS_ASSERT (m_txPowerBaseDbm <= m_txPowerEndDbm); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 // Channel number should be aligned by SetFrequency () to 1 | 784 // Channel number should be aligned by SetFrequency () to 1 |
811 NS_ASSERT (GetChannelNumber () == 1); | 785 NS_ASSERT (GetChannelNumber () == 1); |
812 break; | 786 break; |
813 case WIFI_PHY_STANDARD_80211ax_5GHZ: | 787 case WIFI_PHY_STANDARD_80211ax_5GHZ: |
814 SetChannelWidth (80); | 788 SetChannelWidth (80); |
815 SetFrequency (5210); | 789 SetFrequency (5210); |
816 // Channel number should be aligned by SetFrequency () to 42 | 790 // Channel number should be aligned by SetFrequency () to 42 |
817 NS_ASSERT (GetChannelNumber () == 42); | 791 NS_ASSERT (GetChannelNumber () == 42); |
818 break; | 792 break; |
819 case WIFI_PHY_STANDARD_UNSPECIFIED: | 793 case WIFI_PHY_STANDARD_UNSPECIFIED: |
| 794 default: |
820 NS_LOG_WARN ("Configuring unspecified standard; performing no action"); | 795 NS_LOG_WARN ("Configuring unspecified standard; performing no action"); |
821 break; | |
822 default: | |
823 NS_ASSERT (false); | |
824 break; | 796 break; |
825 } | 797 } |
826 } | 798 } |
827 | 799 |
828 void | 800 void |
829 WifiPhy::Configure80211a (void) | 801 WifiPhy::Configure80211a (void) |
830 { | 802 { |
831 NS_LOG_FUNCTION (this); | 803 NS_LOG_FUNCTION (this); |
832 | 804 |
833 m_deviceRateSet.push_back (WifiPhy::GetOfdmRate6Mbps ()); | 805 m_deviceRateSet.push_back (WifiPhy::GetOfdmRate6Mbps ()); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs7 ()); | 1006 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs7 ()); |
1035 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs8 ()); | 1007 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs8 ()); |
1036 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs9 ()); | 1008 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs9 ()); |
1037 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs10 ()); | 1009 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs10 ()); |
1038 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs11 ()); | 1010 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs11 ()); |
1039 | 1011 |
1040 m_bssMembershipSelectorSet.push_back (HE_PHY); | 1012 m_bssMembershipSelectorSet.push_back (HE_PHY); |
1041 } | 1013 } |
1042 | 1014 |
1043 bool | 1015 bool |
1044 WifiPhy::DefineChannelNumber (uint8_t channelNumber, WifiPhyStandard standard, u
int16_t frequency, uint8_t channelWidth) | 1016 WifiPhy::DefineChannelNumber (uint8_t channelNumber, WifiPhyStandard standard, u
int16_t frequency, uint16_t channelWidth) |
1045 { | 1017 { |
1046 NS_LOG_FUNCTION (this << static_cast<uint16_t> (channelNumber) << standard <<
frequency << static_cast<uint16_t> (channelWidth)); | 1018 NS_LOG_FUNCTION (this << +channelNumber << standard << frequency << channelWid
th); |
1047 ChannelNumberStandardPair p = std::make_pair (channelNumber, standard); | 1019 ChannelNumberStandardPair p = std::make_pair (channelNumber, standard); |
1048 ChannelToFrequencyWidthMap::const_iterator it; | 1020 ChannelToFrequencyWidthMap::const_iterator it; |
1049 it = m_channelToFrequencyWidth.find (p); | 1021 it = m_channelToFrequencyWidth.find (p); |
1050 if (it != m_channelToFrequencyWidth.end ()) | 1022 if (it != m_channelToFrequencyWidth.end ()) |
1051 { | 1023 { |
1052 NS_LOG_DEBUG ("channel number/standard already defined; returning false"); | 1024 NS_LOG_DEBUG ("channel number/standard already defined; returning false"); |
1053 return false; | 1025 return false; |
1054 } | 1026 } |
1055 FrequencyWidthPair f = std::make_pair (frequency, channelWidth); | 1027 FrequencyWidthPair f = std::make_pair (frequency, channelWidth); |
1056 m_channelToFrequencyWidth[p] = f; | 1028 m_channelToFrequencyWidth[p] = f; |
1057 return true; | 1029 return true; |
1058 } | 1030 } |
1059 | 1031 |
1060 uint8_t | 1032 uint8_t |
1061 WifiPhy::FindChannelNumberForFrequencyWidth (uint16_t frequency, uint8_t width)
const | 1033 WifiPhy::FindChannelNumberForFrequencyWidth (uint16_t frequency, uint16_t width)
const |
1062 { | 1034 { |
1063 NS_LOG_FUNCTION (this << frequency << static_cast<uint16_t> (width)); | 1035 NS_LOG_FUNCTION (this << frequency << width); |
1064 bool found = false; | 1036 bool found = false; |
1065 FrequencyWidthPair f = std::make_pair (frequency, width); | 1037 FrequencyWidthPair f = std::make_pair (frequency, width); |
1066 ChannelToFrequencyWidthMap::const_iterator it = m_channelToFrequencyWidth.begi
n (); | 1038 ChannelToFrequencyWidthMap::const_iterator it = m_channelToFrequencyWidth.begi
n (); |
1067 while (it != m_channelToFrequencyWidth.end ()) | 1039 while (it != m_channelToFrequencyWidth.end ()) |
1068 { | 1040 { |
1069 if (it->second == f) | 1041 if (it->second == f) |
1070 { | 1042 { |
1071 found = true; | 1043 found = true; |
1072 break; | 1044 break; |
1073 } | 1045 } |
1074 ++it; | 1046 ++it; |
1075 } | 1047 } |
1076 if (found) | 1048 if (found) |
1077 { | 1049 { |
1078 NS_LOG_DEBUG ("Found, returning " << static_cast<uint16_t> (it->first.firs
t)); | 1050 NS_LOG_DEBUG ("Found, returning " << +it->first.first); |
1079 return (it->first.first); | 1051 return (it->first.first); |
1080 } | 1052 } |
1081 else | 1053 else |
1082 { | 1054 { |
1083 NS_LOG_DEBUG ("Not found, returning 0"); | 1055 NS_LOG_DEBUG ("Not found, returning 0"); |
1084 return 0; | 1056 return 0; |
1085 } | 1057 } |
1086 } | 1058 } |
1087 | 1059 |
1088 void | 1060 void |
1089 WifiPhy::ConfigureChannelForStandard (WifiPhyStandard standard) | 1061 WifiPhy::ConfigureChannelForStandard (WifiPhyStandard standard) |
1090 { | 1062 { |
1091 NS_LOG_FUNCTION (this << standard); | 1063 NS_LOG_FUNCTION (this << standard); |
1092 // If the user has configured both Frequency and ChannelNumber, Frequency | 1064 // If the user has configured both Frequency and ChannelNumber, Frequency |
1093 // takes precedence | 1065 // takes precedence |
1094 if (GetFrequency () != 0) | 1066 if (GetFrequency () != 0) |
1095 { | 1067 { |
1096 // If Frequency is already set, then see whether a ChannelNumber can | 1068 // If Frequency is already set, then see whether a ChannelNumber can |
1097 // be found that matches Frequency and ChannelWidth. If so, configure | 1069 // be found that matches Frequency and ChannelWidth. If so, configure |
1098 // the ChannelNumber to that channel number. If not, set ChannelNumber to
zero. | 1070 // the ChannelNumber to that channel number. If not, set ChannelNumber to
zero. |
1099 NS_LOG_DEBUG ("Frequency set; checking whether a channel number correspond
s"); | 1071 NS_LOG_DEBUG ("Frequency set; checking whether a channel number correspond
s"); |
1100 uint8_t channelNumberSearched = FindChannelNumberForFrequencyWidth (GetFre
quency (), GetChannelWidth ()); | 1072 uint8_t channelNumberSearched = FindChannelNumberForFrequencyWidth (GetFre
quency (), GetChannelWidth ()); |
1101 if (channelNumberSearched) | 1073 if (channelNumberSearched) |
1102 { | 1074 { |
1103 NS_LOG_DEBUG ("Channel number found; setting to " << static_cast<uint1
6_t> (channelNumberSearched)); | 1075 NS_LOG_DEBUG ("Channel number found; setting to " << +channelNumberSea
rched); |
1104 SetChannelNumber (channelNumberSearched); | 1076 SetChannelNumber (channelNumberSearched); |
1105 } | 1077 } |
1106 else | 1078 else |
1107 { | 1079 { |
1108 NS_LOG_DEBUG ("Channel number not found; setting to zero"); | 1080 NS_LOG_DEBUG ("Channel number not found; setting to zero"); |
1109 SetChannelNumber (0); | 1081 SetChannelNumber (0); |
1110 } | 1082 } |
1111 } | 1083 } |
1112 else if (GetChannelNumber () != 0) | 1084 else if (GetChannelNumber () != 0) |
1113 { | 1085 { |
1114 // If the channel number is known for this particular standard or for | 1086 // If the channel number is known for this particular standard or for |
1115 // the unspecified standard, configure using the known values; | 1087 // the unspecified standard, configure using the known values; |
1116 // otherwise, this is a configuration error | 1088 // otherwise, this is a configuration error |
1117 NS_LOG_DEBUG ("Configuring for channel number " << static_cast<uint16_t> (
GetChannelNumber ())); | 1089 NS_LOG_DEBUG ("Configuring for channel number " << +GetChannelNumber ()); |
1118 FrequencyWidthPair f = GetFrequencyWidthForChannelNumberStandard (GetChann
elNumber (), standard); | 1090 FrequencyWidthPair f = GetFrequencyWidthForChannelNumberStandard (GetChann
elNumber (), standard); |
1119 if (f.first == 0) | 1091 if (f.first == 0) |
1120 { | 1092 { |
1121 // the specific pair of number/standard is not known | 1093 // the specific pair of number/standard is not known |
1122 NS_LOG_DEBUG ("Falling back to check WIFI_PHY_STANDARD_UNSPECIFIED"); | 1094 NS_LOG_DEBUG ("Falling back to check WIFI_PHY_STANDARD_UNSPECIFIED"); |
1123 f = GetFrequencyWidthForChannelNumberStandard (GetChannelNumber (), WI
FI_PHY_STANDARD_UNSPECIFIED); | 1095 f = GetFrequencyWidthForChannelNumberStandard (GetChannelNumber (), WI
FI_PHY_STANDARD_UNSPECIFIED); |
1124 } | 1096 } |
1125 if (f.first == 0) | 1097 if (f.first == 0) |
1126 { | 1098 { |
1127 NS_FATAL_ERROR ("Error, ChannelNumber " << static_cast<uint16_t> (GetC
hannelNumber ()) << " is unknown for this standard"); | 1099 NS_FATAL_ERROR ("Error, ChannelNumber " << +GetChannelNumber () << " i
s unknown for this standard"); |
1128 } | 1100 } |
1129 else | 1101 else |
1130 { | 1102 { |
1131 NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << s
tatic_cast<uint16_t> (f.second)); | 1103 NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << +
f.second); |
1132 SetFrequency (f.first); | 1104 SetFrequency (f.first); |
1133 SetChannelWidth (f.second); | 1105 SetChannelWidth (f.second); |
1134 } | 1106 } |
1135 } | 1107 } |
1136 } | 1108 } |
1137 | 1109 |
1138 void | 1110 void |
1139 WifiPhy::ConfigureStandard (WifiPhyStandard standard) | 1111 WifiPhy::ConfigureStandard (WifiPhyStandard standard) |
1140 { | 1112 { |
1141 NS_LOG_FUNCTION (this << standard); | 1113 NS_LOG_FUNCTION (this << standard); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 break; | 1154 break; |
1183 case WIFI_PHY_STANDARD_80211ac: | 1155 case WIFI_PHY_STANDARD_80211ac: |
1184 Configure80211ac (); | 1156 Configure80211ac (); |
1185 break; | 1157 break; |
1186 case WIFI_PHY_STANDARD_80211ax_2_4GHZ: | 1158 case WIFI_PHY_STANDARD_80211ax_2_4GHZ: |
1187 Configure80211ax (); | 1159 Configure80211ax (); |
1188 break; | 1160 break; |
1189 case WIFI_PHY_STANDARD_80211ax_5GHZ: | 1161 case WIFI_PHY_STANDARD_80211ax_5GHZ: |
1190 Configure80211ax (); | 1162 Configure80211ax (); |
1191 break; | 1163 break; |
| 1164 case WIFI_PHY_STANDARD_UNSPECIFIED: |
1192 default: | 1165 default: |
1193 NS_ASSERT (false); | 1166 NS_ASSERT (false); |
1194 break; | 1167 break; |
1195 } | 1168 } |
1196 } | 1169 } |
1197 | 1170 |
1198 WifiPhyStandard | 1171 WifiPhyStandard |
1199 WifiPhy::GetStandard (void) const | 1172 WifiPhy::GetStandard (void) const |
1200 { | 1173 { |
1201 return m_standard; | 1174 return m_standard; |
(...skipping 21 matching lines...) Expand all Loading... |
1223 m_channelCenterFrequency = 0; | 1196 m_channelCenterFrequency = 0; |
1224 m_channelNumber = 0; | 1197 m_channelNumber = 0; |
1225 return; | 1198 return; |
1226 } | 1199 } |
1227 // If the user has configured both Frequency and ChannelNumber, Frequency | 1200 // If the user has configured both Frequency and ChannelNumber, Frequency |
1228 // takes precedence. Lookup the channel number corresponding to the | 1201 // takes precedence. Lookup the channel number corresponding to the |
1229 // requested frequency. | 1202 // requested frequency. |
1230 uint8_t nch = FindChannelNumberForFrequencyWidth (frequency, GetChannelWidth (
)); | 1203 uint8_t nch = FindChannelNumberForFrequencyWidth (frequency, GetChannelWidth (
)); |
1231 if (nch != 0) | 1204 if (nch != 0) |
1232 { | 1205 { |
1233 NS_LOG_DEBUG ("Setting frequency " << frequency << " corresponds to channe
l " << static_cast<uint16_t> (nch)); | 1206 NS_LOG_DEBUG ("Setting frequency " << frequency << " corresponds to channe
l " << +nch); |
1234 if (DoFrequencySwitch (frequency)) | 1207 if (DoFrequencySwitch (frequency)) |
1235 { | 1208 { |
1236 NS_LOG_DEBUG ("Channel frequency switched to " << frequency << "; chan
nel number to " << static_cast<uint16_t> (nch)); | 1209 NS_LOG_DEBUG ("Channel frequency switched to " << frequency << "; chan
nel number to " << +nch); |
1237 m_channelCenterFrequency = frequency; | 1210 m_channelCenterFrequency = frequency; |
1238 m_channelNumber = nch; | 1211 m_channelNumber = nch; |
1239 } | 1212 } |
1240 else | 1213 else |
1241 { | 1214 { |
1242 NS_LOG_DEBUG ("Suppressing reassignment of frequency"); | 1215 NS_LOG_DEBUG ("Suppressing reassignment of frequency"); |
1243 } | 1216 } |
1244 } | 1217 } |
1245 else | 1218 else |
1246 { | 1219 { |
(...skipping 11 matching lines...) Expand all Loading... |
1258 } | 1231 } |
1259 } | 1232 } |
1260 | 1233 |
1261 uint16_t | 1234 uint16_t |
1262 WifiPhy::GetFrequency (void) const | 1235 WifiPhy::GetFrequency (void) const |
1263 { | 1236 { |
1264 return m_channelCenterFrequency; | 1237 return m_channelCenterFrequency; |
1265 } | 1238 } |
1266 | 1239 |
1267 void | 1240 void |
1268 WifiPhy::SetChannelWidth (uint8_t channelwidth) | 1241 WifiPhy::SetChannelWidth (uint16_t channelwidth) |
1269 { | 1242 { |
| 1243 NS_LOG_FUNCTION (this << channelwidth); |
1270 NS_ASSERT_MSG (channelwidth == 5 || channelwidth == 10 || channelwidth == 20 |
| channelwidth == 22 || channelwidth == 40 || channelwidth == 80 || channelwidth
== 160, "wrong channel width value"); | 1244 NS_ASSERT_MSG (channelwidth == 5 || channelwidth == 10 || channelwidth == 20 |
| channelwidth == 22 || channelwidth == 40 || channelwidth == 80 || channelwidth
== 160, "wrong channel width value"); |
| 1245 bool changed = (m_channelWidth == channelwidth); |
1271 m_channelWidth = channelwidth; | 1246 m_channelWidth = channelwidth; |
1272 AddSupportedChannelWidth (channelwidth); | 1247 AddSupportedChannelWidth (channelwidth); |
1273 } | 1248 if (changed && !m_capabilitiesChangedCallback.IsNull ()) |
1274 | 1249 { |
1275 uint8_t | 1250 m_capabilitiesChangedCallback (); |
| 1251 } |
| 1252 } |
| 1253 |
| 1254 uint16_t |
1276 WifiPhy::GetChannelWidth (void) const | 1255 WifiPhy::GetChannelWidth (void) const |
1277 { | 1256 { |
1278 return m_channelWidth; | 1257 return m_channelWidth; |
1279 } | 1258 } |
1280 | 1259 |
1281 void | 1260 void |
1282 WifiPhy::SetNumberOfAntennas (uint8_t antennas) | 1261 WifiPhy::SetNumberOfAntennas (uint8_t antennas) |
1283 { | 1262 { |
1284 NS_ASSERT_MSG (antennas > 0 && antennas <= 4, "unsupported number of antennas"
); | 1263 NS_ASSERT_MSG (antennas > 0 && antennas <= 4, "unsupported number of antennas"
); |
1285 m_numberOfAntennas = antennas; | 1264 m_numberOfAntennas = antennas; |
1286 m_interference.SetNumberOfReceiveAntennas (antennas); | 1265 m_interference.SetNumberOfReceiveAntennas (antennas); |
1287 } | 1266 } |
1288 | 1267 |
1289 uint8_t | 1268 uint8_t |
1290 WifiPhy::GetNumberOfAntennas (void) const | 1269 WifiPhy::GetNumberOfAntennas (void) const |
1291 { | 1270 { |
1292 return m_numberOfAntennas; | 1271 return m_numberOfAntennas; |
1293 } | 1272 } |
1294 | 1273 |
1295 void | 1274 void |
1296 WifiPhy::SetMaxSupportedTxSpatialStreams (uint8_t streams) | 1275 WifiPhy::SetMaxSupportedTxSpatialStreams (uint8_t streams) |
1297 { | 1276 { |
1298 NS_ASSERT (streams <= GetNumberOfAntennas ()); | 1277 NS_ASSERT (streams <= GetNumberOfAntennas ()); |
| 1278 bool changed = (m_txSpatialStreams == streams); |
1299 m_txSpatialStreams = streams; | 1279 m_txSpatialStreams = streams; |
1300 ConfigureHtDeviceMcsSet (); | 1280 ConfigureHtDeviceMcsSet (); |
| 1281 if (changed && !m_capabilitiesChangedCallback.IsNull ()) |
| 1282 { |
| 1283 m_capabilitiesChangedCallback (); |
| 1284 } |
1301 } | 1285 } |
1302 | 1286 |
1303 uint8_t | 1287 uint8_t |
1304 WifiPhy::GetMaxSupportedTxSpatialStreams (void) const | 1288 WifiPhy::GetMaxSupportedTxSpatialStreams (void) const |
1305 { | 1289 { |
1306 return m_txSpatialStreams; | 1290 return m_txSpatialStreams; |
1307 } | 1291 } |
1308 | 1292 |
1309 void | 1293 void |
1310 WifiPhy::SetMaxSupportedRxSpatialStreams (uint8_t streams) | 1294 WifiPhy::SetMaxSupportedRxSpatialStreams (uint8_t streams) |
1311 { | 1295 { |
1312 NS_ASSERT (streams <= GetNumberOfAntennas ()); | 1296 NS_ASSERT (streams <= GetNumberOfAntennas ()); |
| 1297 bool changed = (m_rxSpatialStreams == streams); |
1313 m_rxSpatialStreams = streams; | 1298 m_rxSpatialStreams = streams; |
| 1299 if (changed && !m_capabilitiesChangedCallback.IsNull ()) |
| 1300 { |
| 1301 m_capabilitiesChangedCallback (); |
| 1302 } |
1314 } | 1303 } |
1315 | 1304 |
1316 uint8_t | 1305 uint8_t |
1317 WifiPhy::GetMaxSupportedRxSpatialStreams (void) const | 1306 WifiPhy::GetMaxSupportedRxSpatialStreams (void) const |
1318 { | 1307 { |
1319 return m_rxSpatialStreams; | 1308 return m_rxSpatialStreams; |
1320 } | 1309 } |
1321 | 1310 |
1322 uint8_t | 1311 uint8_t |
1323 WifiPhy::GetNBssMembershipSelectors (void) const | 1312 WifiPhy::GetNBssMembershipSelectors (void) const |
1324 { | 1313 { |
1325 return static_cast<uint8_t>(m_bssMembershipSelectorSet.size ()); | 1314 return static_cast<uint8_t> (m_bssMembershipSelectorSet.size ()); |
1326 } | 1315 } |
1327 | 1316 |
1328 uint8_t | 1317 uint8_t |
1329 WifiPhy::GetBssMembershipSelector (uint8_t selector) const | 1318 WifiPhy::GetBssMembershipSelector (uint8_t selector) const |
1330 { | 1319 { |
1331 return m_bssMembershipSelectorSet[selector]; | 1320 return m_bssMembershipSelectorSet[selector]; |
1332 } | 1321 } |
1333 | 1322 |
1334 WifiModeList | 1323 void |
1335 WifiPhy::GetMembershipSelectorModes (uint32_t selector) | 1324 WifiPhy::AddSupportedChannelWidth (uint16_t width) |
1336 { | 1325 { |
1337 uint32_t id = GetBssMembershipSelector (static_cast<uint8_t>(selector)); | 1326 NS_LOG_FUNCTION (this << width); |
1338 WifiModeList supportedmodes; | |
1339 if (id == HT_PHY || id == VHT_PHY || id == HE_PHY) | |
1340 { | |
1341 //mandatory MCS 0 to 7 | |
1342 supportedmodes.push_back (WifiPhy::GetHtMcs0 ()); | |
1343 supportedmodes.push_back (WifiPhy::GetHtMcs1 ()); | |
1344 supportedmodes.push_back (WifiPhy::GetHtMcs2 ()); | |
1345 supportedmodes.push_back (WifiPhy::GetHtMcs3 ()); | |
1346 supportedmodes.push_back (WifiPhy::GetHtMcs4 ()); | |
1347 supportedmodes.push_back (WifiPhy::GetHtMcs5 ()); | |
1348 supportedmodes.push_back (WifiPhy::GetHtMcs6 ()); | |
1349 supportedmodes.push_back (WifiPhy::GetHtMcs7 ()); | |
1350 } | |
1351 if (id == VHT_PHY || id == HE_PHY) | |
1352 { | |
1353 //mandatory MCS 0 to 9 | |
1354 supportedmodes.push_back (WifiPhy::GetVhtMcs0 ()); | |
1355 supportedmodes.push_back (WifiPhy::GetVhtMcs1 ()); | |
1356 supportedmodes.push_back (WifiPhy::GetVhtMcs2 ()); | |
1357 supportedmodes.push_back (WifiPhy::GetVhtMcs3 ()); | |
1358 supportedmodes.push_back (WifiPhy::GetVhtMcs4 ()); | |
1359 supportedmodes.push_back (WifiPhy::GetVhtMcs5 ()); | |
1360 supportedmodes.push_back (WifiPhy::GetVhtMcs6 ()); | |
1361 supportedmodes.push_back (WifiPhy::GetVhtMcs7 ()); | |
1362 supportedmodes.push_back (WifiPhy::GetVhtMcs8 ()); | |
1363 supportedmodes.push_back (WifiPhy::GetVhtMcs9 ()); | |
1364 } | |
1365 if (id == HE_PHY) | |
1366 { | |
1367 //mandatory MCS 0 to 11 | |
1368 supportedmodes.push_back (WifiPhy::GetHeMcs0 ()); | |
1369 supportedmodes.push_back (WifiPhy::GetHeMcs1 ()); | |
1370 supportedmodes.push_back (WifiPhy::GetHeMcs2 ()); | |
1371 supportedmodes.push_back (WifiPhy::GetHeMcs3 ()); | |
1372 supportedmodes.push_back (WifiPhy::GetHeMcs4 ()); | |
1373 supportedmodes.push_back (WifiPhy::GetHeMcs5 ()); | |
1374 supportedmodes.push_back (WifiPhy::GetHeMcs6 ()); | |
1375 supportedmodes.push_back (WifiPhy::GetHeMcs7 ()); | |
1376 supportedmodes.push_back (WifiPhy::GetHeMcs8 ()); | |
1377 supportedmodes.push_back (WifiPhy::GetHeMcs9 ()); | |
1378 supportedmodes.push_back (WifiPhy::GetHeMcs10 ()); | |
1379 supportedmodes.push_back (WifiPhy::GetHeMcs11 ()); | |
1380 } | |
1381 return supportedmodes; | |
1382 } | |
1383 | |
1384 void | |
1385 WifiPhy::AddSupportedChannelWidth (uint8_t width) | |
1386 { | |
1387 NS_LOG_FUNCTION (this << static_cast<uint16_t> (width)); | |
1388 for (std::vector<uint32_t>::size_type i = 0; i != m_supportedChannelWidthSet.s
ize (); i++) | 1327 for (std::vector<uint32_t>::size_type i = 0; i != m_supportedChannelWidthSet.s
ize (); i++) |
1389 { | 1328 { |
1390 if (m_supportedChannelWidthSet[i] == width) | 1329 if (m_supportedChannelWidthSet[i] == width) |
1391 { | 1330 { |
1392 return; | 1331 return; |
1393 } | 1332 } |
1394 } | 1333 } |
1395 NS_LOG_FUNCTION ("Adding " << static_cast<uint16_t> (width) << " to supported
channel width set"); | 1334 NS_LOG_FUNCTION ("Adding " << width << " to supported channel width set"); |
1396 m_supportedChannelWidthSet.push_back (width); | 1335 m_supportedChannelWidthSet.push_back (width); |
1397 } | 1336 } |
1398 | 1337 |
1399 std::vector<uint8_t> | 1338 std::vector<uint16_t> |
1400 WifiPhy::GetSupportedChannelWidthSet (void) const | 1339 WifiPhy::GetSupportedChannelWidthSet (void) const |
1401 { | 1340 { |
1402 return m_supportedChannelWidthSet; | 1341 return m_supportedChannelWidthSet; |
1403 } | 1342 } |
1404 | 1343 |
1405 WifiPhy::FrequencyWidthPair | 1344 WifiPhy::FrequencyWidthPair |
1406 WifiPhy::GetFrequencyWidthForChannelNumberStandard (uint8_t channelNumber, WifiP
hyStandard standard) const | 1345 WifiPhy::GetFrequencyWidthForChannelNumberStandard (uint8_t channelNumber, WifiP
hyStandard standard) const |
1407 { | 1346 { |
1408 ChannelNumberStandardPair p = std::make_pair (channelNumber, standard); | 1347 ChannelNumberStandardPair p = std::make_pair (channelNumber, standard); |
1409 FrequencyWidthPair f = m_channelToFrequencyWidth[p]; | 1348 FrequencyWidthPair f = m_channelToFrequencyWidth[p]; |
1410 return f; | 1349 return f; |
1411 } | 1350 } |
1412 | 1351 |
1413 void | 1352 void |
1414 WifiPhy::SetChannelNumber (uint8_t nch) | 1353 WifiPhy::SetChannelNumber (uint8_t nch) |
1415 { | 1354 { |
1416 NS_LOG_FUNCTION (this << static_cast<uint16_t> (nch)); | 1355 NS_LOG_FUNCTION (this << +nch); |
1417 if (m_isConstructed == false) | 1356 if (m_isConstructed == false) |
1418 { | 1357 { |
1419 NS_LOG_DEBUG ("Saving channel number configuration for initialization"); | 1358 NS_LOG_DEBUG ("Saving channel number configuration for initialization"); |
1420 m_initialChannelNumber = nch; | 1359 m_initialChannelNumber = nch; |
1421 return; | 1360 return; |
1422 } | 1361 } |
1423 if (GetChannelNumber () == nch) | 1362 if (GetChannelNumber () == nch) |
1424 { | 1363 { |
1425 NS_LOG_DEBUG ("No channel change requested"); | 1364 NS_LOG_DEBUG ("No channel change requested"); |
1426 return; | 1365 return; |
(...skipping 13 matching lines...) Expand all Loading... |
1440 // in use | 1379 // in use |
1441 FrequencyWidthPair f = GetFrequencyWidthForChannelNumberStandard (nch, GetStan
dard ()); | 1380 FrequencyWidthPair f = GetFrequencyWidthForChannelNumberStandard (nch, GetStan
dard ()); |
1442 if (f.first == 0) | 1381 if (f.first == 0) |
1443 { | 1382 { |
1444 f = GetFrequencyWidthForChannelNumberStandard (nch, WIFI_PHY_STANDARD_UNSP
ECIFIED); | 1383 f = GetFrequencyWidthForChannelNumberStandard (nch, WIFI_PHY_STANDARD_UNSP
ECIFIED); |
1445 } | 1384 } |
1446 if (f.first != 0) | 1385 if (f.first != 0) |
1447 { | 1386 { |
1448 if (DoChannelSwitch (nch)) | 1387 if (DoChannelSwitch (nch)) |
1449 { | 1388 { |
1450 NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << s
tatic_cast<uint16_t> (f.second)); | 1389 NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << +
f.second); |
1451 m_channelCenterFrequency = f.first; | 1390 m_channelCenterFrequency = f.first; |
1452 SetChannelWidth (f.second); | 1391 SetChannelWidth (f.second); |
1453 m_channelNumber = nch; | 1392 m_channelNumber = nch; |
1454 } | 1393 } |
1455 else | 1394 else |
1456 { | 1395 { |
1457 // Subclass may have suppressed (e.g. waiting for state change) | 1396 // Subclass may have suppressed (e.g. waiting for state change) |
1458 NS_LOG_DEBUG ("Channel switch suppressed"); | 1397 NS_LOG_DEBUG ("Channel switch suppressed"); |
1459 } | 1398 } |
1460 } | 1399 } |
1461 else | 1400 else |
1462 { | 1401 { |
1463 NS_FATAL_ERROR ("Frequency not found for channel number " << nch); | 1402 NS_FATAL_ERROR ("Frequency not found for channel number " << nch); |
1464 } | 1403 } |
1465 } | 1404 } |
1466 | 1405 |
1467 uint8_t | 1406 uint8_t |
1468 WifiPhy::GetChannelNumber (void) const | 1407 WifiPhy::GetChannelNumber (void) const |
1469 { | 1408 { |
1470 return m_channelNumber; | 1409 return m_channelNumber; |
1471 } | 1410 } |
1472 | 1411 |
1473 bool | 1412 bool |
1474 WifiPhy::DoChannelSwitch (uint8_t nch) | 1413 WifiPhy::DoChannelSwitch (uint8_t nch) |
1475 { | 1414 { |
1476 if (!IsInitialized ()) | 1415 if (!IsInitialized ()) |
1477 { | 1416 { |
1478 //this is not channel switch, this is initialization | 1417 //this is not channel switch, this is initialization |
1479 NS_LOG_DEBUG ("initialize to channel " << static_cast<uint16_t> (nch)); | 1418 NS_LOG_DEBUG ("initialize to channel " << +nch); |
1480 return true; | 1419 return true; |
1481 } | 1420 } |
1482 | 1421 |
1483 NS_ASSERT (!IsStateSwitching ()); | 1422 NS_ASSERT (!IsStateSwitching ()); |
1484 switch (m_state->GetState ()) | 1423 switch (m_state->GetState ()) |
1485 { | 1424 { |
1486 case WifiPhy::RX: | 1425 case WifiPhyState::RX: |
1487 NS_LOG_DEBUG ("drop packet because of channel switching while reception"); | 1426 NS_LOG_DEBUG ("drop packet because of channel switching while reception"); |
1488 m_endPlcpRxEvent.Cancel (); | 1427 m_endPlcpRxEvent.Cancel (); |
1489 m_endRxEvent.Cancel (); | 1428 m_endRxEvent.Cancel (); |
1490 goto switchChannel; | 1429 goto switchChannel; |
1491 break; | 1430 break; |
1492 case WifiPhy::TX: | 1431 case WifiPhyState::TX: |
1493 NS_LOG_DEBUG ("channel switching postponed until end of current transmissi
on"); | 1432 NS_LOG_DEBUG ("channel switching postponed until end of current transmissi
on"); |
1494 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetChannelNumber, thi
s, nch); | 1433 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetChannelNumber, thi
s, nch); |
1495 break; | 1434 break; |
1496 case WifiPhy::CCA_BUSY: | 1435 case WifiPhyState::CCA_BUSY: |
1497 case WifiPhy::IDLE: | 1436 case WifiPhyState::IDLE: |
1498 goto switchChannel; | 1437 goto switchChannel; |
1499 break; | 1438 break; |
1500 case WifiPhy::SLEEP: | 1439 case WifiPhyState::SLEEP: |
1501 NS_LOG_DEBUG ("channel switching ignored in sleep mode"); | 1440 NS_LOG_DEBUG ("channel switching ignored in sleep mode"); |
1502 break; | 1441 break; |
1503 default: | 1442 default: |
1504 NS_ASSERT (false); | 1443 NS_ASSERT (false); |
1505 break; | 1444 break; |
1506 } | 1445 } |
1507 | 1446 |
1508 return false; | 1447 return false; |
1509 | 1448 |
1510 switchChannel: | 1449 switchChannel: |
1511 | 1450 |
1512 NS_LOG_DEBUG ("switching channel " << static_cast<uint16_t> (GetChannelNumber
()) << " -> " << static_cast<uint16_t> (nch)); | 1451 NS_LOG_DEBUG ("switching channel " << +GetChannelNumber () << " -> " << +nch); |
1513 m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ()); | 1452 m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ()); |
1514 m_interference.EraseEvents (); | 1453 m_interference.EraseEvents (); |
1515 /* | 1454 /* |
1516 * Needed here to be able to correctly sensed the medium for the first | 1455 * Needed here to be able to correctly sensed the medium for the first |
1517 * time after the switching. The actual switching is not performed until | 1456 * time after the switching. The actual switching is not performed until |
1518 * after m_channelSwitchDelay. Packets received during the switching | 1457 * after m_channelSwitchDelay. Packets received during the switching |
1519 * state are added to the event list and are employed later to figure | 1458 * state are added to the event list and are employed later to figure |
1520 * out the state of the medium after the switching. | 1459 * out the state of the medium after the switching. |
1521 */ | 1460 */ |
1522 return true; | 1461 return true; |
1523 } | 1462 } |
1524 | 1463 |
1525 bool | 1464 bool |
1526 WifiPhy::DoFrequencySwitch (uint16_t frequency) | 1465 WifiPhy::DoFrequencySwitch (uint16_t frequency) |
1527 { | 1466 { |
1528 if (!IsInitialized ()) | 1467 if (!IsInitialized ()) |
1529 { | 1468 { |
1530 //this is not channel switch, this is initialization | 1469 //this is not channel switch, this is initialization |
1531 NS_LOG_DEBUG ("start at frequency " << frequency); | 1470 NS_LOG_DEBUG ("start at frequency " << frequency); |
1532 return true; | 1471 return true; |
1533 } | 1472 } |
1534 | 1473 |
1535 NS_ASSERT (!IsStateSwitching ()); | 1474 NS_ASSERT (!IsStateSwitching ()); |
1536 switch (m_state->GetState ()) | 1475 switch (m_state->GetState ()) |
1537 { | 1476 { |
1538 case WifiPhy::RX: | 1477 case WifiPhyState::RX: |
1539 NS_LOG_DEBUG ("drop packet because of channel/frequency switching while re
ception"); | 1478 NS_LOG_DEBUG ("drop packet because of channel/frequency switching while re
ception"); |
1540 m_endPlcpRxEvent.Cancel (); | 1479 m_endPlcpRxEvent.Cancel (); |
1541 m_endRxEvent.Cancel (); | 1480 m_endRxEvent.Cancel (); |
1542 goto switchFrequency; | 1481 goto switchFrequency; |
1543 break; | 1482 break; |
1544 case WifiPhy::TX: | 1483 case WifiPhyState::TX: |
1545 NS_LOG_DEBUG ("channel/frequency switching postponed until end of current
transmission"); | 1484 NS_LOG_DEBUG ("channel/frequency switching postponed until end of current
transmission"); |
1546 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetFrequency, this, f
requency); | 1485 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetFrequency, this, f
requency); |
1547 break; | 1486 break; |
1548 case WifiPhy::CCA_BUSY: | 1487 case WifiPhyState::CCA_BUSY: |
1549 case WifiPhy::IDLE: | 1488 case WifiPhyState::IDLE: |
1550 goto switchFrequency; | 1489 goto switchFrequency; |
1551 break; | 1490 break; |
1552 case WifiPhy::SLEEP: | 1491 case WifiPhyState::SLEEP: |
1553 NS_LOG_DEBUG ("frequency switching ignored in sleep mode"); | 1492 NS_LOG_DEBUG ("frequency switching ignored in sleep mode"); |
1554 break; | 1493 break; |
1555 default: | 1494 default: |
1556 NS_ASSERT (false); | 1495 NS_ASSERT (false); |
1557 break; | 1496 break; |
1558 } | 1497 } |
1559 | 1498 |
1560 return false; | 1499 return false; |
1561 | 1500 |
1562 switchFrequency: | 1501 switchFrequency: |
(...skipping 10 matching lines...) Expand all Loading... |
1573 */ | 1512 */ |
1574 return true; | 1513 return true; |
1575 } | 1514 } |
1576 | 1515 |
1577 void | 1516 void |
1578 WifiPhy::SetSleepMode (void) | 1517 WifiPhy::SetSleepMode (void) |
1579 { | 1518 { |
1580 NS_LOG_FUNCTION (this); | 1519 NS_LOG_FUNCTION (this); |
1581 switch (m_state->GetState ()) | 1520 switch (m_state->GetState ()) |
1582 { | 1521 { |
1583 case WifiPhy::TX: | 1522 case WifiPhyState::TX: |
1584 NS_LOG_DEBUG ("setting sleep mode postponed until end of current transmiss
ion"); | 1523 NS_LOG_DEBUG ("setting sleep mode postponed until end of current transmiss
ion"); |
1585 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetSleepMode, this); | 1524 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetSleepMode, this); |
1586 break; | 1525 break; |
1587 case WifiPhy::RX: | 1526 case WifiPhyState::RX: |
1588 NS_LOG_DEBUG ("setting sleep mode postponed until end of current reception
"); | 1527 NS_LOG_DEBUG ("setting sleep mode postponed until end of current reception
"); |
1589 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetSleepMode, this); | 1528 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetSleepMode, this); |
1590 break; | 1529 break; |
1591 case WifiPhy::SWITCHING: | 1530 case WifiPhyState::SWITCHING: |
1592 NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching
"); | 1531 NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching
"); |
1593 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetSleepMode, this); | 1532 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetSleepMode, this); |
1594 break; | 1533 break; |
1595 case WifiPhy::CCA_BUSY: | 1534 case WifiPhyState::CCA_BUSY: |
1596 case WifiPhy::IDLE: | 1535 case WifiPhyState::IDLE: |
1597 NS_LOG_DEBUG ("setting sleep mode"); | 1536 NS_LOG_DEBUG ("setting sleep mode"); |
1598 m_state->SwitchToSleep (); | 1537 m_state->SwitchToSleep (); |
1599 break; | 1538 break; |
1600 case WifiPhy::SLEEP: | 1539 case WifiPhyState::SLEEP: |
1601 NS_LOG_DEBUG ("already in sleep mode"); | 1540 NS_LOG_DEBUG ("already in sleep mode"); |
1602 break; | 1541 break; |
1603 default: | 1542 default: |
1604 NS_ASSERT (false); | 1543 NS_ASSERT (false); |
1605 break; | 1544 break; |
1606 } | 1545 } |
1607 } | 1546 } |
1608 | 1547 |
1609 void | 1548 void |
1610 WifiPhy::SetOffMode (void) | 1549 WifiPhy::SetOffMode (void) |
1611 { | 1550 { |
1612 NS_LOG_FUNCTION (this); | 1551 NS_LOG_FUNCTION (this); |
1613 switch (m_state->GetState ()) | 1552 switch (m_state->GetState ()) |
1614 { | 1553 { |
1615 case WifiPhy::RX: | 1554 case WifiPhyState::RX: |
1616 m_endPlcpRxEvent.Cancel (); | 1555 m_endPlcpRxEvent.Cancel (); |
1617 m_endRxEvent.Cancel (); | 1556 m_endRxEvent.Cancel (); |
1618 case WifiPhy::TX: | 1557 case WifiPhyState::TX: |
1619 case WifiPhy::SWITCHING: | 1558 case WifiPhyState::SWITCHING: |
1620 case WifiPhy::CCA_BUSY: | 1559 case WifiPhyState::CCA_BUSY: |
1621 case WifiPhy::IDLE: | 1560 case WifiPhyState::IDLE: |
1622 case WifiPhy::SLEEP: | 1561 case WifiPhyState::SLEEP: |
1623 m_state->SwitchToOff (); | 1562 m_state->SwitchToOff (); |
1624 break; | 1563 break; |
1625 default: | 1564 default: |
1626 NS_ASSERT (false); | 1565 NS_ASSERT (false); |
1627 break; | 1566 break; |
1628 } | 1567 } |
1629 } | 1568 } |
1630 | 1569 |
1631 void | 1570 void |
1632 WifiPhy::ResumeFromSleep (void) | 1571 WifiPhy::ResumeFromSleep (void) |
1633 { | 1572 { |
1634 NS_LOG_FUNCTION (this); | 1573 NS_LOG_FUNCTION (this); |
1635 switch (m_state->GetState ()) | 1574 switch (m_state->GetState ()) |
1636 { | 1575 { |
1637 case WifiPhy::TX: | 1576 case WifiPhyState::TX: |
1638 case WifiPhy::RX: | 1577 case WifiPhyState::RX: |
1639 case WifiPhy::IDLE: | 1578 case WifiPhyState::IDLE: |
1640 case WifiPhy::CCA_BUSY: | 1579 case WifiPhyState::CCA_BUSY: |
1641 case WifiPhy::SWITCHING: | 1580 case WifiPhyState::SWITCHING: |
1642 { | 1581 { |
1643 NS_LOG_DEBUG ("not in sleep mode, there is nothing to resume"); | 1582 NS_LOG_DEBUG ("not in sleep mode, there is nothing to resume"); |
1644 break; | 1583 break; |
1645 } | 1584 } |
1646 case WifiPhy::SLEEP: | 1585 case WifiPhyState::SLEEP: |
1647 { | 1586 { |
1648 NS_LOG_DEBUG ("resuming from sleep mode"); | 1587 NS_LOG_DEBUG ("resuming from sleep mode"); |
1649 Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCca
Mode1Threshold ())); | 1588 Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCca
Mode1Threshold ())); |
1650 m_state->SwitchFromSleep (delayUntilCcaEnd); | 1589 m_state->SwitchFromSleep (delayUntilCcaEnd); |
| 1590 break; |
| 1591 } |
| 1592 default: |
| 1593 { |
| 1594 NS_ASSERT (false); |
| 1595 break; |
| 1596 } |
| 1597 } |
| 1598 } |
| 1599 |
| 1600 void |
| 1601 WifiPhy::ResumeFromOff (void) |
| 1602 { |
| 1603 NS_LOG_FUNCTION (this); |
| 1604 switch (m_state->GetState ()) |
| 1605 { |
| 1606 case WifiPhyState::TX: |
| 1607 case WifiPhyState::RX: |
| 1608 case WifiPhyState::IDLE: |
| 1609 case WifiPhyState::CCA_BUSY: |
| 1610 case WifiPhyState::SWITCHING: |
| 1611 case WifiPhyState::SLEEP: |
| 1612 { |
| 1613 NS_LOG_DEBUG ("not in off mode, there is nothing to resume"); |
| 1614 break; |
| 1615 } |
| 1616 case WifiPhyState::OFF: |
| 1617 { |
| 1618 NS_LOG_DEBUG ("resuming from off mode"); |
| 1619 Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCca
Mode1Threshold ())); |
| 1620 m_state->SwitchFromOff (delayUntilCcaEnd); |
1651 break; | 1621 break; |
1652 } | 1622 } |
1653 default: | 1623 default: |
1654 { | 1624 { |
1655 NS_ASSERT (false); | 1625 NS_ASSERT (false); |
1656 break; | 1626 break; |
1657 } | 1627 } |
1658 } | 1628 } |
1659 } | 1629 } |
1660 | 1630 |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2180 } | 2150 } |
2181 | 2151 |
2182 switch (payloadMode.GetModulationClass ()) | 2152 switch (payloadMode.GetModulationClass ()) |
2183 { | 2153 { |
2184 case WIFI_MOD_CLASS_OFDM: | 2154 case WIFI_MOD_CLASS_OFDM: |
2185 case WIFI_MOD_CLASS_ERP_OFDM: | 2155 case WIFI_MOD_CLASS_ERP_OFDM: |
2186 { | 2156 { |
2187 //Add signal extension for ERP PHY | 2157 //Add signal extension for ERP PHY |
2188 if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM) | 2158 if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM) |
2189 { | 2159 { |
2190 return FemtoSeconds (static_cast<uint64_t>(numSymbols * symbolDurati
on.GetFemtoSeconds ())) + MicroSeconds (6); | 2160 return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDurat
ion.GetFemtoSeconds ())) + MicroSeconds (6); |
2191 } | 2161 } |
2192 else | 2162 else |
2193 { | 2163 { |
2194 return FemtoSeconds (static_cast<uint64_t>(numSymbols * symbolDurati
on.GetFemtoSeconds ())); | 2164 return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDurat
ion.GetFemtoSeconds ())); |
2195 } | 2165 } |
2196 } | 2166 } |
2197 case WIFI_MOD_CLASS_HT: | 2167 case WIFI_MOD_CLASS_HT: |
2198 case WIFI_MOD_CLASS_VHT: | 2168 case WIFI_MOD_CLASS_VHT: |
2199 { | 2169 { |
2200 if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_HT && Is2_4Ghz (
frequency) | 2170 if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_HT && Is2_4Ghz (
frequency) |
2201 && ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE) | 2171 && ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE) |
2202 || (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAM
BLE_NONE))) //at 2.4 GHz | 2172 || (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAM
BLE_NONE))) //at 2.4 GHz |
2203 { | 2173 { |
2204 return FemtoSeconds (static_cast<uint64_t>(numSymbols * symbolDurati
on.GetFemtoSeconds ())) + MicroSeconds (6); | 2174 return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDurat
ion.GetFemtoSeconds ())) + MicroSeconds (6); |
2205 } | 2175 } |
2206 else //at 5 GHz | 2176 else //at 5 GHz |
2207 { | 2177 { |
2208 return FemtoSeconds (static_cast<uint64_t>(numSymbols * symbolDurati
on.GetFemtoSeconds ())); | 2178 return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDurat
ion.GetFemtoSeconds ())); |
2209 } | 2179 } |
2210 } | 2180 } |
2211 case WIFI_MOD_CLASS_HE: | 2181 case WIFI_MOD_CLASS_HE: |
2212 { | 2182 { |
2213 if (Is2_4Ghz (frequency) | 2183 if (Is2_4Ghz (frequency) |
2214 && ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE) | 2184 && ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE) |
2215 || (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAM
BLE_NONE))) //at 2.4 GHz | 2185 || (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAM
BLE_NONE))) //at 2.4 GHz |
2216 { | 2186 { |
2217 return FemtoSeconds (static_cast<uint64_t>(numSymbols * symbolDurati
on.GetFemtoSeconds ())) + MicroSeconds (6); | 2187 return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDurat
ion.GetFemtoSeconds ())) + MicroSeconds (6); |
2218 } | 2188 } |
2219 else //at 5 GHz | 2189 else //at 5 GHz |
2220 { | 2190 { |
2221 return FemtoSeconds (static_cast<uint64_t>(numSymbols * symbolDurati
on.GetFemtoSeconds ())); | 2191 return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDurat
ion.GetFemtoSeconds ())); |
2222 } | 2192 } |
2223 } | 2193 } |
2224 case WIFI_MOD_CLASS_DSSS: | 2194 case WIFI_MOD_CLASS_DSSS: |
2225 case WIFI_MOD_CLASS_HR_DSSS: | 2195 case WIFI_MOD_CLASS_HR_DSSS: |
2226 return MicroSeconds (lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate
(22) / 1.0e6)))); | 2196 return MicroSeconds (lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate
(22) / 1.0e6)))); |
2227 default: | 2197 default: |
2228 NS_FATAL_ERROR ("unsupported modulation class"); | 2198 NS_FATAL_ERROR ("unsupported modulation class"); |
2229 return MicroSeconds (0); | 2199 return MicroSeconds (0); |
2230 } | 2200 } |
2231 } | 2201 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2305 { | 2275 { |
2306 m_phyMonitorSniffTxTrace (packet, channelFreqMhz, txVector, aMpdu); | 2276 m_phyMonitorSniffTxTrace (packet, channelFreqMhz, txVector, aMpdu); |
2307 } | 2277 } |
2308 | 2278 |
2309 void | 2279 void |
2310 WifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, MpduType m
pdutype) | 2280 WifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, MpduType m
pdutype) |
2311 { | 2281 { |
2312 NS_LOG_FUNCTION (this << packet << txVector.GetMode () | 2282 NS_LOG_FUNCTION (this << packet << txVector.GetMode () |
2313 << txVector.GetMode ().GetDataRate (txVector) | 2283 << txVector.GetMode ().GetDataRate (txVector) |
2314 << txVector.GetPreambleType () | 2284 << txVector.GetPreambleType () |
2315 << static_cast<uint16_t> (txVector.GetTxPowerLevel ()) | 2285 << +txVector.GetTxPowerLevel () |
2316 << static_cast<uint16_t> (mpdutype)); | 2286 << +mpdutype); |
2317 /* Transmission can happen if: | 2287 /* Transmission can happen if: |
2318 * - we are syncing on a packet. It is the responsability of the | 2288 * - we are syncing on a packet. It is the responsability of the |
2319 * MAC layer to avoid doing this but the PHY does nothing to | 2289 * MAC layer to avoid doing this but the PHY does nothing to |
2320 * prevent it. | 2290 * prevent it. |
2321 * - we are idle | 2291 * - we are idle |
2322 */ | 2292 */ |
2323 NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ()); | 2293 NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ()); |
2324 | 2294 |
2325 if (txVector.GetNss () > GetMaxSupportedTxSpatialStreams ()) | 2295 if (txVector.GetNss () > GetMaxSupportedTxSpatialStreams ()) |
2326 { | 2296 { |
(...skipping 24 matching lines...) Expand all Loading... |
2351 } | 2321 } |
2352 MpduInfo aMpdu; | 2322 MpduInfo aMpdu; |
2353 aMpdu.type = mpdutype; | 2323 aMpdu.type = mpdutype; |
2354 aMpdu.mpduRefNumber = m_txMpduReferenceNumber; | 2324 aMpdu.mpduRefNumber = m_txMpduReferenceNumber; |
2355 NotifyMonitorSniffTx (packet, GetFrequency (), txVector, aMpdu); | 2325 NotifyMonitorSniffTx (packet, GetFrequency (), txVector, aMpdu); |
2356 m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel
()), txVector); | 2326 m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel
()), txVector); |
2357 | 2327 |
2358 Ptr<Packet> newPacket = packet->Copy (); // obtain non-const Packet | 2328 Ptr<Packet> newPacket = packet->Copy (); // obtain non-const Packet |
2359 WifiPhyTag oldtag; | 2329 WifiPhyTag oldtag; |
2360 newPacket->RemovePacketTag (oldtag); | 2330 newPacket->RemovePacketTag (oldtag); |
2361 if (m_state->GetState () == WifiPhy::OFF) | 2331 if (m_state->GetState () == WifiPhyState::OFF) |
2362 { | 2332 { |
2363 NS_LOG_DEBUG ("Transmission canceled because device is OFF"); | 2333 NS_LOG_DEBUG ("Transmission canceled because device is OFF"); |
2364 return; | 2334 return; |
2365 } | 2335 } |
2366 uint8_t isFrameComplete = 1; | 2336 uint8_t isFrameComplete = 1; |
2367 if (m_wifiRadioEnergyModel != 0 && m_wifiRadioEnergyModel->GetMaximumTimeInSta
te (WifiPhy::TX) < txDuration) | 2337 if (m_wifiRadioEnergyModel != 0 && m_wifiRadioEnergyModel->GetMaximumTimeInSta
te (WifiPhyState::TX) < txDuration) |
2368 { | 2338 { |
2369 isFrameComplete = 0; | 2339 isFrameComplete = 0; |
2370 } | 2340 } |
2371 WifiPhyTag tag (txVector, mpdutype, isFrameComplete); | 2341 WifiPhyTag tag (txVector, mpdutype, isFrameComplete); |
2372 newPacket->AddPacketTag (tag); | 2342 newPacket->AddPacketTag (tag); |
2373 | 2343 |
2374 StartTx (newPacket, txVector, txDuration); | 2344 StartTx (newPacket, txVector, txDuration); |
2375 } | 2345 } |
2376 | 2346 |
2377 void | 2347 void |
2378 WifiPhy::StartReceivePreambleAndHeader (Ptr<Packet> packet, double rxPowerW, Tim
e rxDuration) | 2348 WifiPhy::StartReceivePreambleAndHeader (Ptr<Packet> packet, double rxPowerW, Tim
e rxDuration) |
2379 { | 2349 { |
2380 //This function should be later split to check separately whether plcp preambl
e and plcp header can be successfully received. | |
2381 //Note: plcp preamble reception is not yet modeled. | |
2382 if (m_state->GetState () == WifiPhy::OFF) | |
2383 { | |
2384 NS_LOG_DEBUG ("Cannot start RX because device is OFF"); | |
2385 return; | |
2386 } | |
2387 | |
2388 NS_LOG_FUNCTION (this << packet << WToDbm (rxPowerW) << rxDuration); | |
2389 Time endRx = Simulator::Now () + rxDuration; | |
2390 | |
2391 WifiPhyTag tag; | 2350 WifiPhyTag tag; |
2392 bool found = packet->RemovePacketTag (tag); | 2351 bool found = packet->RemovePacketTag (tag); |
2393 if (!found) | 2352 if (!found) |
2394 { | 2353 { |
2395 NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag"); | 2354 NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag"); |
2396 return; | 2355 return; |
2397 } | 2356 } |
2398 | 2357 |
2399 if (tag.GetFrameComplete () == 0) | |
2400 { | |
2401 NS_LOG_DEBUG ("drop packet because of incomplete frame"); | |
2402 NotifyRxDrop (packet); | |
2403 m_plcpSuccess = false; | |
2404 return; | |
2405 } | |
2406 | |
2407 WifiTxVector txVector = tag.GetWifiTxVector (); | 2358 WifiTxVector txVector = tag.GetWifiTxVector (); |
2408 | 2359 Ptr<Event> event; |
2409 if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT | |
2410 && (txVector.GetNss () != (1 + (txVector.GetMode ().GetMcsValue () / 8)))) | |
2411 { | |
2412 NS_FATAL_ERROR ("MCS value does not match NSS value: MCS = " << static_cas
t<uint16_t> (txVector.GetMode ().GetMcsValue ()) << ", NSS = " << static_cast<ui
nt16_t> (txVector.GetNss ())); | |
2413 } | |
2414 | |
2415 Ptr<InterferenceHelper::Event> event; | |
2416 event = m_interference.Add (packet, | 2360 event = m_interference.Add (packet, |
2417 txVector, | 2361 txVector, |
2418 rxDuration, | 2362 rxDuration, |
2419 rxPowerW); | 2363 rxPowerW); |
2420 | 2364 |
| 2365 //This function should be later split to check separately whether plcp preambl
e and plcp header can be successfully received. |
| 2366 //Note: plcp preamble reception is not yet modeled. |
| 2367 if (m_state->GetState () == WifiPhyState::OFF) |
| 2368 { |
| 2369 NS_LOG_DEBUG ("Cannot start RX because device is OFF"); |
| 2370 return; |
| 2371 } |
| 2372 |
| 2373 NS_LOG_FUNCTION (this << packet << WToDbm (rxPowerW) << rxDuration); |
| 2374 |
| 2375 if (tag.GetFrameComplete () == 0) |
| 2376 { |
| 2377 NS_LOG_DEBUG ("drop packet because of incomplete frame"); |
| 2378 NotifyRxDrop (packet); |
| 2379 m_plcpSuccess = false; |
| 2380 return; |
| 2381 } |
| 2382 |
| 2383 if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT |
| 2384 && (txVector.GetNss () != (1 + (txVector.GetMode ().GetMcsValue () / 8)))) |
| 2385 { |
| 2386 NS_FATAL_ERROR ("MCS value does not match NSS value: MCS = " << +txVector.
GetMode ().GetMcsValue () << ", NSS = " << +txVector.GetNss ()); |
| 2387 } |
| 2388 |
| 2389 Time endRx = Simulator::Now () + rxDuration; |
2421 if (txVector.GetNss () > GetMaxSupportedRxSpatialStreams ()) | 2390 if (txVector.GetNss () > GetMaxSupportedRxSpatialStreams ()) |
2422 { | 2391 { |
2423 NS_LOG_DEBUG ("drop packet because not enough RX antennas"); | 2392 NS_LOG_DEBUG ("drop packet because not enough RX antennas"); |
2424 NotifyRxDrop (packet); | 2393 NotifyRxDrop (packet); |
2425 m_plcpSuccess = false; | 2394 m_plcpSuccess = false; |
2426 if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) | 2395 if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) |
2427 { | 2396 { |
2428 //that packet will be noise _after_ the transmission of the | 2397 //that packet will be noise _after_ the transmission of the |
2429 //currently-transmitted packet. | 2398 //currently-transmitted packet. |
2430 MaybeCcaBusyDuration (); | 2399 MaybeCcaBusyDuration (); |
2431 return; | 2400 return; |
2432 } | 2401 } |
2433 } | 2402 } |
2434 | 2403 |
2435 MpduType mpdutype = tag.GetMpduType (); | 2404 MpduType mpdutype = tag.GetMpduType (); |
2436 switch (m_state->GetState ()) | 2405 switch (m_state->GetState ()) |
2437 { | 2406 { |
2438 case WifiPhy::SWITCHING: | 2407 case WifiPhyState::SWITCHING: |
2439 NS_LOG_DEBUG ("drop packet because of channel switching"); | 2408 NS_LOG_DEBUG ("drop packet because of channel switching"); |
2440 NotifyRxDrop (packet); | 2409 NotifyRxDrop (packet); |
2441 m_plcpSuccess = false; | 2410 m_plcpSuccess = false; |
2442 /* | 2411 /* |
2443 * Packets received on the upcoming channel are added to the event list | 2412 * Packets received on the upcoming channel are added to the event list |
2444 * during the switching state. This way the medium can be correctly sensed | 2413 * during the switching state. This way the medium can be correctly sensed |
2445 * when the device listens to the channel for the first time after the | 2414 * when the device listens to the channel for the first time after the |
2446 * switching e.g. after channel switching, the channel may be sensed as | 2415 * switching e.g. after channel switching, the channel may be sensed as |
2447 * busy due to other devices' tramissions started before the end of | 2416 * busy due to other devices' tramissions started before the end of |
2448 * the switching. | 2417 * the switching. |
2449 */ | 2418 */ |
2450 if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) | 2419 if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) |
2451 { | 2420 { |
2452 //that packet will be noise _after_ the completion of the | 2421 //that packet will be noise _after_ the completion of the |
2453 //channel switching. | 2422 //channel switching. |
2454 MaybeCcaBusyDuration (); | 2423 MaybeCcaBusyDuration (); |
2455 return; | 2424 return; |
2456 } | 2425 } |
2457 break; | 2426 break; |
2458 case WifiPhy::RX: | 2427 case WifiPhyState::RX: |
2459 NS_ASSERT (m_currentEvent != 0); | 2428 NS_ASSERT (m_currentEvent != 0); |
2460 if (m_frameCaptureModel != 0 | 2429 if (m_frameCaptureModel != 0 |
2461 && m_frameCaptureModel->CaptureNewFrame (m_currentEvent, event)) | 2430 && m_frameCaptureModel->CaptureNewFrame (m_currentEvent, event)) |
2462 { | 2431 { |
2463 AbortCurrentReception (); | 2432 AbortCurrentReception (); |
2464 NS_LOG_DEBUG ("Switch to new packet"); | 2433 NS_LOG_DEBUG ("Switch to new packet"); |
2465 StartRx (packet, txVector, mpdutype, rxPowerW, rxDuration, event); | 2434 StartRx (packet, txVector, mpdutype, rxPowerW, rxDuration, event); |
2466 } | 2435 } |
2467 else | 2436 else |
2468 { | 2437 { |
2469 NS_LOG_DEBUG ("drop packet because already in Rx (power=" << | 2438 NS_LOG_DEBUG ("drop packet because already in Rx (power=" << |
2470 rxPowerW << "W)"); | 2439 rxPowerW << "W)"); |
2471 NotifyRxDrop (packet); | 2440 NotifyRxDrop (packet); |
2472 if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) | 2441 if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) |
2473 { | 2442 { |
2474 //that packet will be noise _after_ the reception of the | 2443 //that packet will be noise _after_ the reception of the |
2475 //currently-received packet. | 2444 //currently-received packet. |
2476 MaybeCcaBusyDuration (); | 2445 MaybeCcaBusyDuration (); |
2477 return; | 2446 return; |
2478 } | 2447 } |
2479 } | 2448 } |
2480 break; | 2449 break; |
2481 case WifiPhy::TX: | 2450 case WifiPhyState::TX: |
2482 NS_LOG_DEBUG ("drop packet because already in Tx (power=" << | 2451 NS_LOG_DEBUG ("drop packet because already in Tx (power=" << |
2483 rxPowerW << "W)"); | 2452 rxPowerW << "W)"); |
2484 NotifyRxDrop (packet); | 2453 NotifyRxDrop (packet); |
2485 if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) | 2454 if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) |
2486 { | 2455 { |
2487 //that packet will be noise _after_ the transmission of the | 2456 //that packet will be noise _after_ the transmission of the |
2488 //currently-transmitted packet. | 2457 //currently-transmitted packet. |
2489 MaybeCcaBusyDuration (); | 2458 MaybeCcaBusyDuration (); |
2490 return; | 2459 return; |
2491 } | 2460 } |
2492 break; | 2461 break; |
2493 case WifiPhy::CCA_BUSY: | 2462 case WifiPhyState::CCA_BUSY: |
2494 case WifiPhy::IDLE: | 2463 case WifiPhyState::IDLE: |
2495 StartRx (packet, txVector, mpdutype, rxPowerW, rxDuration, event); | 2464 StartRx (packet, txVector, mpdutype, rxPowerW, rxDuration, event); |
2496 break; | 2465 break; |
2497 case WifiPhy::SLEEP: | 2466 case WifiPhyState::SLEEP: |
2498 NS_LOG_DEBUG ("drop packet because in sleep mode"); | 2467 NS_LOG_DEBUG ("drop packet because in sleep mode"); |
2499 NotifyRxDrop (packet); | 2468 NotifyRxDrop (packet); |
2500 m_plcpSuccess = false; | 2469 m_plcpSuccess = false; |
2501 break; | 2470 break; |
2502 default: | 2471 default: |
2503 NS_FATAL_ERROR ("Invalid WifiPhy state."); | 2472 NS_FATAL_ERROR ("Invalid WifiPhy state."); |
2504 break; | 2473 break; |
2505 } | 2474 } |
2506 } | 2475 } |
2507 | 2476 |
2508 void | 2477 void |
2509 WifiPhy::MaybeCcaBusyDuration () | 2478 WifiPhy::MaybeCcaBusyDuration () |
2510 { | 2479 { |
2511 //We are here because we have received the first bit of a packet and we are | 2480 //We are here because we have received the first bit of a packet and we are |
2512 //not going to be able to synchronize on it | 2481 //not going to be able to synchronize on it |
2513 //In this model, CCA becomes busy when the aggregation of all signals as | 2482 //In this model, CCA becomes busy when the aggregation of all signals as |
2514 //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold | 2483 //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold |
2515 | 2484 |
2516 Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaMode1T
hreshold ())); | 2485 Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaMode1T
hreshold ())); |
2517 if (!delayUntilCcaEnd.IsZero ()) | 2486 if (!delayUntilCcaEnd.IsZero ()) |
2518 { | 2487 { |
2519 m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd); | 2488 m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd); |
2520 } | 2489 } |
2521 } | 2490 } |
2522 | 2491 |
2523 void | 2492 void |
2524 WifiPhy::StartReceivePacket (Ptr<Packet> packet, | 2493 WifiPhy::StartReceivePacket (Ptr<Packet> packet, |
2525 WifiTxVector txVector, | 2494 WifiTxVector txVector, |
2526 MpduType mpdutype, | 2495 MpduType mpdutype, |
2527 Ptr<InterferenceHelper::Event> event) | 2496 Ptr<Event> event) |
2528 { | 2497 { |
2529 NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetPreamble
Type () << static_cast<uint16_t> (mpdutype)); | 2498 NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetPreamble
Type () << +mpdutype); |
2530 NS_ASSERT (IsStateRx ()); | 2499 NS_ASSERT (IsStateRx ()); |
2531 NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); | 2500 NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
2532 WifiMode txMode = txVector.GetMode (); | 2501 WifiMode txMode = txVector.GetMode (); |
2533 | 2502 |
2534 InterferenceHelper::SnrPer snrPer; | 2503 InterferenceHelper::SnrPer snrPer; |
2535 snrPer = m_interference.CalculatePlcpHeaderSnrPer (event); | 2504 snrPer = m_interference.CalculatePlcpHeaderSnrPer (event); |
2536 | 2505 |
2537 NS_LOG_DEBUG ("snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per); | 2506 NS_LOG_DEBUG ("snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per); |
2538 | 2507 |
2539 if (m_random->GetValue () > snrPer.per) //plcp reception succeeded | 2508 if (m_random->GetValue () > snrPer.per) //plcp reception succeeded |
(...skipping 12 matching lines...) Expand all Loading... |
2552 } | 2521 } |
2553 else //plcp reception failed | 2522 else //plcp reception failed |
2554 { | 2523 { |
2555 NS_LOG_DEBUG ("drop packet because plcp preamble/header reception failed")
; | 2524 NS_LOG_DEBUG ("drop packet because plcp preamble/header reception failed")
; |
2556 NotifyRxDrop (packet); | 2525 NotifyRxDrop (packet); |
2557 m_plcpSuccess = false; | 2526 m_plcpSuccess = false; |
2558 } | 2527 } |
2559 } | 2528 } |
2560 | 2529 |
2561 void | 2530 void |
2562 WifiPhy::EndReceive (Ptr<Packet> packet, WifiPreamble preamble, MpduType mpdutyp
e, Ptr<InterferenceHelper::Event> event) | 2531 WifiPhy::EndReceive (Ptr<Packet> packet, WifiPreamble preamble, MpduType mpdutyp
e, Ptr<Event> event) |
2563 { | 2532 { |
2564 NS_LOG_FUNCTION (this << packet << event); | 2533 NS_LOG_FUNCTION (this << packet << event); |
2565 NS_ASSERT (IsStateRx ()); | 2534 NS_ASSERT (IsStateRx ()); |
2566 NS_ASSERT (event->GetEndTime () == Simulator::Now ()); | 2535 NS_ASSERT (event->GetEndTime () == Simulator::Now ()); |
2567 | 2536 |
2568 InterferenceHelper::SnrPer snrPer; | 2537 InterferenceHelper::SnrPer snrPer; |
2569 snrPer = m_interference.CalculatePlcpPayloadSnrPer (event); | 2538 snrPer = m_interference.CalculatePlcpPayloadSnrPer (event); |
2570 m_interference.NotifyRxEnd (); | 2539 m_interference.NotifyRxEnd (); |
2571 m_currentEvent = 0; | 2540 m_currentEvent = 0; |
2572 | 2541 |
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3518 { | 3487 { |
3519 return true; | 3488 return true; |
3520 } | 3489 } |
3521 } | 3490 } |
3522 return false; | 3491 return false; |
3523 } | 3492 } |
3524 | 3493 |
3525 uint8_t | 3494 uint8_t |
3526 WifiPhy::GetNModes (void) const | 3495 WifiPhy::GetNModes (void) const |
3527 { | 3496 { |
3528 return static_cast<uint8_t>(m_deviceRateSet.size ()); | 3497 return static_cast<uint8_t> (m_deviceRateSet.size ()); |
3529 } | 3498 } |
3530 | 3499 |
3531 WifiMode | 3500 WifiMode |
3532 WifiPhy::GetMode (uint8_t mode) const | 3501 WifiPhy::GetMode (uint8_t mode) const |
3533 { | 3502 { |
3534 return m_deviceRateSet[mode]; | 3503 return m_deviceRateSet[mode]; |
3535 } | 3504 } |
3536 | 3505 |
3537 uint8_t | 3506 uint8_t |
3538 WifiPhy::GetNMcs (void) const | 3507 WifiPhy::GetNMcs (void) const |
3539 { | 3508 { |
3540 return static_cast<uint8_t>(m_deviceMcsSet.size ()); | 3509 return static_cast<uint8_t> (m_deviceMcsSet.size ()); |
3541 } | 3510 } |
3542 | 3511 |
3543 WifiMode | 3512 WifiMode |
3544 WifiPhy::GetMcs (uint8_t mcs) const | 3513 WifiPhy::GetMcs (uint8_t mcs) const |
3545 { | 3514 { |
3546 return m_deviceMcsSet[mcs]; | 3515 return m_deviceMcsSet[mcs]; |
3547 } | 3516 } |
3548 | 3517 |
3549 bool | 3518 bool |
3550 WifiPhy::IsStateCcaBusy (void) const | 3519 WifiPhy::IsStateCcaBusy (void) const |
3551 { | 3520 { |
3552 return m_state->IsStateCcaBusy (); | 3521 return m_state->IsStateCcaBusy (); |
3553 } | 3522 } |
3554 | 3523 |
3555 bool | 3524 bool |
3556 WifiPhy::IsStateIdle (void) const | 3525 WifiPhy::IsStateIdle (void) const |
3557 { | 3526 { |
3558 return m_state->IsStateIdle (); | 3527 return m_state->IsStateIdle (); |
3559 } | 3528 } |
3560 | 3529 |
3561 bool | 3530 bool |
3562 WifiPhy::IsStateBusy (void) const | |
3563 { | |
3564 return m_state->IsStateBusy (); | |
3565 } | |
3566 | |
3567 bool | |
3568 WifiPhy::IsStateRx (void) const | 3531 WifiPhy::IsStateRx (void) const |
3569 { | 3532 { |
3570 return m_state->IsStateRx (); | 3533 return m_state->IsStateRx (); |
3571 } | 3534 } |
3572 | 3535 |
3573 bool | 3536 bool |
3574 WifiPhy::IsStateTx (void) const | 3537 WifiPhy::IsStateTx (void) const |
3575 { | 3538 { |
3576 return m_state->IsStateTx (); | 3539 return m_state->IsStateTx (); |
3577 } | 3540 } |
3578 | 3541 |
3579 bool | 3542 bool |
3580 WifiPhy::IsStateSwitching (void) const | 3543 WifiPhy::IsStateSwitching (void) const |
3581 { | 3544 { |
3582 return m_state->IsStateSwitching (); | 3545 return m_state->IsStateSwitching (); |
3583 } | 3546 } |
3584 | 3547 |
3585 bool | 3548 bool |
3586 WifiPhy::IsStateSleep (void) const | 3549 WifiPhy::IsStateSleep (void) const |
3587 { | 3550 { |
3588 return m_state->IsStateSleep (); | 3551 return m_state->IsStateSleep (); |
3589 } | 3552 } |
3590 | 3553 |
3591 bool | 3554 bool |
3592 WifiPhy::IsStateOff (void) const | 3555 WifiPhy::IsStateOff (void) const |
3593 { | 3556 { |
3594 return m_state->IsStateOff (); | 3557 return m_state->IsStateOff (); |
3595 } | |
3596 | |
3597 Time | |
3598 WifiPhy::GetStateDuration (void) | |
3599 { | |
3600 return m_state->GetStateDuration (); | |
3601 } | 3558 } |
3602 | 3559 |
3603 Time | 3560 Time |
3604 WifiPhy::GetDelayUntilIdle (void) | 3561 WifiPhy::GetDelayUntilIdle (void) |
3605 { | 3562 { |
3606 return m_state->GetDelayUntilIdle (); | 3563 return m_state->GetDelayUntilIdle (); |
3607 } | 3564 } |
3608 | 3565 |
3609 Time | 3566 Time |
3610 WifiPhy::GetLastRxStartTime (void) const | 3567 WifiPhy::GetLastRxStartTime (void) const |
(...skipping 30 matching lines...) Expand all Loading... |
3641 { | 3598 { |
3642 m_endRxEvent.Cancel (); | 3599 m_endRxEvent.Cancel (); |
3643 } | 3600 } |
3644 NotifyRxDrop (m_currentEvent->GetPacket ()); | 3601 NotifyRxDrop (m_currentEvent->GetPacket ()); |
3645 m_interference.NotifyRxEnd (); | 3602 m_interference.NotifyRxEnd (); |
3646 m_state->SwitchFromRxAbort (); | 3603 m_state->SwitchFromRxAbort (); |
3647 m_currentEvent = 0; | 3604 m_currentEvent = 0; |
3648 } | 3605 } |
3649 | 3606 |
3650 void | 3607 void |
3651 WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype,
double rxPowerW, Time rxDuration, Ptr<InterferenceHelper::Event> event) | 3608 WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype,
double rxPowerW, Time rxDuration, Ptr<Event> event) |
3652 { | 3609 { |
3653 NS_LOG_FUNCTION (this << packet << txVector << static_cast<uint16_t> (mpdutype
) << rxPowerW << rxDuration); | 3610 NS_LOG_FUNCTION (this << packet << txVector << +mpdutype << rxPowerW << rxDura
tion); |
3654 if (rxPowerW > GetEdThresholdW ()) //checked here, no need to check in the pay
load reception (current implementation assumes constant rx power over the packet
duration) | 3611 if (rxPowerW > DbmToW (GetEdThreshold ())) //checked here, no need to check in
the payload reception (current implementation assumes constant rx power over th
e packet duration) |
3655 { | 3612 { |
3656 AmpduTag ampduTag; | 3613 AmpduTag ampduTag; |
3657 WifiPreamble preamble = txVector.GetPreambleType (); | 3614 WifiPreamble preamble = txVector.GetPreambleType (); |
3658 if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess ==
false)) | 3615 if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess ==
false)) |
3659 { | 3616 { |
3660 m_plcpSuccess = false; | 3617 m_plcpSuccess = false; |
3661 m_mpdusNum = 0; | 3618 m_mpdusNum = 0; |
3662 NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been re
ceived"); | 3619 NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been re
ceived"); |
3663 NotifyRxDrop (packet); | 3620 NotifyRxDrop (packet); |
3664 MaybeCcaBusyDuration (); | 3621 MaybeCcaBusyDuration (); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3709 packet, txVector, mpdutype, ev
ent); | 3666 packet, txVector, mpdutype, ev
ent); |
3710 } | 3667 } |
3711 | 3668 |
3712 NS_ASSERT (m_endRxEvent.IsExpired ()); | 3669 NS_ASSERT (m_endRxEvent.IsExpired ()); |
3713 m_endRxEvent = Simulator::Schedule (rxDuration, &WifiPhy::EndReceive, this
, | 3670 m_endRxEvent = Simulator::Schedule (rxDuration, &WifiPhy::EndReceive, this
, |
3714 packet, preamble, mpdutype, event); | 3671 packet, preamble, mpdutype, event); |
3715 } | 3672 } |
3716 else | 3673 else |
3717 { | 3674 { |
3718 NS_LOG_DEBUG ("drop packet because signal power too Small (" << | 3675 NS_LOG_DEBUG ("drop packet because signal power too Small (" << |
3719 rxPowerW << "<" << GetEdThresholdW () << ")"); | 3676 rxPowerW << "<" << DbmToW (GetEdThreshold ()) << ")"); |
3720 NotifyRxDrop (packet); | 3677 NotifyRxDrop (packet); |
3721 m_plcpSuccess = false; | 3678 m_plcpSuccess = false; |
3722 MaybeCcaBusyDuration (); | 3679 MaybeCcaBusyDuration (); |
3723 } | 3680 } |
3724 } | 3681 } |
3725 | 3682 |
3726 int64_t | 3683 int64_t |
3727 WifiPhy::AssignStreams (int64_t stream) | 3684 WifiPhy::AssignStreams (int64_t stream) |
3728 { | 3685 { |
3729 NS_LOG_FUNCTION (this << stream); | 3686 NS_LOG_FUNCTION (this << stream); |
3730 m_random->SetStream (stream); | 3687 m_random->SetStream (stream); |
3731 return 1; | 3688 return 1; |
3732 } | 3689 } |
3733 | 3690 |
3734 std::ostream& operator<< (std::ostream& os, WifiPhy::State state) | 3691 std::ostream& operator<< (std::ostream& os, WifiPhyState state) |
3735 { | 3692 { |
3736 switch (state) | 3693 switch (state) |
3737 { | 3694 { |
3738 case WifiPhy::IDLE: | 3695 case WifiPhyState::IDLE: |
3739 return (os << "IDLE"); | 3696 return (os << "IDLE"); |
3740 case WifiPhy::CCA_BUSY: | 3697 case WifiPhyState::CCA_BUSY: |
3741 return (os << "CCA_BUSY"); | 3698 return (os << "CCA_BUSY"); |
3742 case WifiPhy::TX: | 3699 case WifiPhyState::TX: |
3743 return (os << "TX"); | 3700 return (os << "TX"); |
3744 case WifiPhy::RX: | 3701 case WifiPhyState::RX: |
3745 return (os << "RX"); | 3702 return (os << "RX"); |
3746 case WifiPhy::SWITCHING: | 3703 case WifiPhyState::SWITCHING: |
3747 return (os << "SWITCHING"); | 3704 return (os << "SWITCHING"); |
3748 case WifiPhy::SLEEP: | 3705 case WifiPhyState::SLEEP: |
3749 return (os << "SLEEP"); | 3706 return (os << "SLEEP"); |
3750 case WifiPhy::OFF: | 3707 case WifiPhyState::OFF: |
3751 return (os << "OFF"); | 3708 return (os << "OFF"); |
3752 default: | 3709 default: |
3753 NS_FATAL_ERROR ("Invalid WifiPhy state"); | 3710 NS_FATAL_ERROR ("Invalid WifiPhy state"); |
3754 return (os << "INVALID"); | 3711 return (os << "INVALID"); |
3755 } | 3712 } |
3756 } | 3713 } |
3757 | 3714 |
3758 } //namespace ns3 | 3715 } //namespace ns3 |
3759 | 3716 |
3760 namespace { | 3717 namespace { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3854 ns3::WifiPhy::GetHeMcs6 (); | 3811 ns3::WifiPhy::GetHeMcs6 (); |
3855 ns3::WifiPhy::GetHeMcs7 (); | 3812 ns3::WifiPhy::GetHeMcs7 (); |
3856 ns3::WifiPhy::GetHeMcs8 (); | 3813 ns3::WifiPhy::GetHeMcs8 (); |
3857 ns3::WifiPhy::GetHeMcs9 (); | 3814 ns3::WifiPhy::GetHeMcs9 (); |
3858 ns3::WifiPhy::GetHeMcs10 (); | 3815 ns3::WifiPhy::GetHeMcs10 (); |
3859 ns3::WifiPhy::GetHeMcs11 (); | 3816 ns3::WifiPhy::GetHeMcs11 (); |
3860 } | 3817 } |
3861 } g_constructor; ///< the constructor | 3818 } g_constructor; ///< the constructor |
3862 | 3819 |
3863 } | 3820 } |
LEFT | RIGHT |