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 |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "ns3/simulator.h" | 24 #include "ns3/simulator.h" |
25 #include "ns3/log.h" | 25 #include "ns3/log.h" |
26 #include "ns3/boolean.h" | 26 #include "ns3/boolean.h" |
27 #include "ns3/double.h" | 27 #include "ns3/double.h" |
28 #include "ns3/uinteger.h" | 28 #include "ns3/uinteger.h" |
29 #include "ns3/pointer.h" | 29 #include "ns3/pointer.h" |
30 #include "wifi-phy-tag.h" | 30 #include "wifi-phy-tag.h" |
31 #include "ampdu-tag.h" | 31 #include "ampdu-tag.h" |
32 #include "wifi-utils.h" | 32 #include "wifi-utils.h" |
33 #include "frame-capture-model.h" | 33 #include "frame-capture-model.h" |
| 34 #include "wifi-radio-energy-model.h" |
34 | 35 |
35 namespace ns3 { | 36 namespace ns3 { |
36 | 37 |
37 NS_LOG_COMPONENT_DEFINE ("WifiPhy"); | 38 NS_LOG_COMPONENT_DEFINE ("WifiPhy"); |
38 | 39 |
39 /**************************************************************** | 40 /**************************************************************** |
40 * This destructor is needed. | 41 * This destructor is needed. |
41 ****************************************************************/ | 42 ****************************************************************/ |
42 | 43 |
43 WifiPhyListener::~WifiPhyListener () | 44 WifiPhyListener::~WifiPhyListener () |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 .AddAttribute ("State", | 234 .AddAttribute ("State", |
234 "The state of the PHY layer.", | 235 "The state of the PHY layer.", |
235 PointerValue (), | 236 PointerValue (), |
236 MakePointerAccessor (&WifiPhy::m_state), | 237 MakePointerAccessor (&WifiPhy::m_state), |
237 MakePointerChecker<WifiPhyStateHelper> ()) | 238 MakePointerChecker<WifiPhyStateHelper> ()) |
238 .AddAttribute ("ChannelSwitchDelay", | 239 .AddAttribute ("ChannelSwitchDelay", |
239 "Delay between two short frames transmitted on different freq
uencies.", | 240 "Delay between two short frames transmitted on different freq
uencies.", |
240 TimeValue (MicroSeconds (250)), | 241 TimeValue (MicroSeconds (250)), |
241 MakeTimeAccessor (&WifiPhy::m_channelSwitchDelay), | 242 MakeTimeAccessor (&WifiPhy::m_channelSwitchDelay), |
242 MakeTimeChecker ()) | 243 MakeTimeChecker ()) |
243 .AddAttribute ("TxAntennas", | |
244 "The number of supported Tx antennas.", | |
245 UintegerValue (1), | |
246 MakeUintegerAccessor (&WifiPhy::m_numberOfTransmitters), | |
247 MakeUintegerChecker<uint8_t> (1, 8), | |
248 TypeId::DEPRECATED, | |
249 "Not used anymore.") | |
250 .AddAttribute ("RxAntennas", | |
251 "The number of supported Rx antennas.", | |
252 UintegerValue (1), | |
253 MakeUintegerAccessor (&WifiPhy::m_numberOfReceivers), | |
254 MakeUintegerChecker<uint8_t> (1, 8), | |
255 TypeId::DEPRECATED, | |
256 "Not used anymore.") | |
257 .AddAttribute ("Antennas", | 244 .AddAttribute ("Antennas", |
258 "The number of antennas on the device.", | 245 "The number of antennas on the device.", |
259 UintegerValue (1), | 246 UintegerValue (1), |
260 MakeUintegerAccessor (&WifiPhy::GetNumberOfAntennas, | 247 MakeUintegerAccessor (&WifiPhy::GetNumberOfAntennas, |
261 &WifiPhy::SetNumberOfAntennas), | 248 &WifiPhy::SetNumberOfAntennas), |
262 MakeUintegerChecker<uint8_t> (1, 8)) | 249 MakeUintegerChecker<uint8_t> (1, 8)) |
263 .AddAttribute ("MaxSupportedTxSpatialStreams", | 250 .AddAttribute ("MaxSupportedTxSpatialStreams", |
264 "The maximum number of supported TX spatial streams." | 251 "The maximum number of supported TX spatial streams." |
265 "This parameter is only valuable for 802.11n/ac/ax STAs and A
Ps.", | 252 "This parameter is only valuable for 802.11n/ac/ax STAs and A
Ps.", |
266 UintegerValue (1), | 253 UintegerValue (1), |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 "in monitor mode to sniff all frames being transmitted", | 353 "in monitor mode to sniff all frames being transmitted", |
367 MakeTraceSourceAccessor (&WifiPhy::m_phyMonitorSniffTxTrace
), | 354 MakeTraceSourceAccessor (&WifiPhy::m_phyMonitorSniffTxTrace
), |
368 "ns3::WifiPhy::MonitorSnifferTxTracedCallback") | 355 "ns3::WifiPhy::MonitorSnifferTxTracedCallback") |
369 ; | 356 ; |
370 return tid; | 357 return tid; |
371 } | 358 } |
372 | 359 |
373 WifiPhy::WifiPhy () | 360 WifiPhy::WifiPhy () |
374 : m_mpdusNum (0), | 361 : m_mpdusNum (0), |
375 m_plcpSuccess (false), | 362 m_plcpSuccess (false), |
376 m_txMpduReferenceNumber (0xffffffffffffffff), | 363 m_txMpduReferenceNumber (0xffffffff), |
377 m_rxMpduReferenceNumber (0xffffffffffffffff), | 364 m_rxMpduReferenceNumber (0xffffffff), |
378 m_endRxEvent (), | 365 m_endRxEvent (), |
379 m_endPlcpRxEvent (), | 366 m_endPlcpRxEvent (), |
380 m_standard (WIFI_PHY_STANDARD_UNSPECIFIED), | 367 m_standard (WIFI_PHY_STANDARD_UNSPECIFIED), |
381 m_isConstructed (false), | 368 m_isConstructed (false), |
382 m_channelCenterFrequency (0), | 369 m_channelCenterFrequency (0), |
383 m_initialFrequency (0), | 370 m_initialFrequency (0), |
384 m_frequencyChannelNumberInitialized (false), | 371 m_frequencyChannelNumberInitialized (false), |
385 m_channelNumber (0), | 372 m_channelNumber (0), |
386 m_initialChannelNumber (0), | 373 m_initialChannelNumber (0), |
387 m_totalAmpduSize (0), | 374 m_totalAmpduSize (0), |
388 m_totalAmpduNumSymbols (0), | 375 m_totalAmpduNumSymbols (0), |
389 m_currentEvent (0) | 376 m_currentEvent (0), |
| 377 m_wifiRadioEnergyModel (0) |
390 { | 378 { |
391 NS_LOG_FUNCTION (this); | 379 NS_LOG_FUNCTION (this); |
392 NS_UNUSED (m_numberOfTransmitters); | |
393 NS_UNUSED (m_numberOfReceivers); | |
394 m_random = CreateObject<UniformRandomVariable> (); | 380 m_random = CreateObject<UniformRandomVariable> (); |
395 m_state = CreateObject<WifiPhyStateHelper> (); | 381 m_state = CreateObject<WifiPhyStateHelper> (); |
396 } | 382 } |
397 | 383 |
398 WifiPhy::~WifiPhy () | 384 WifiPhy::~WifiPhy () |
399 { | 385 { |
400 NS_LOG_FUNCTION (this); | 386 NS_LOG_FUNCTION (this); |
401 } | 387 } |
402 | 388 |
403 void | 389 void |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 if (m_initialFrequency != 0) | 450 if (m_initialFrequency != 0) |
465 { | 451 { |
466 SetFrequency (m_initialFrequency); | 452 SetFrequency (m_initialFrequency); |
467 } | 453 } |
468 else if (m_initialChannelNumber != 0 && GetStandard () != WIFI_PHY_STANDARD_UN
SPECIFIED) | 454 else if (m_initialChannelNumber != 0 && GetStandard () != WIFI_PHY_STANDARD_UN
SPECIFIED) |
469 { | 455 { |
470 SetChannelNumber (m_initialChannelNumber); | 456 SetChannelNumber (m_initialChannelNumber); |
471 } | 457 } |
472 else if (m_initialChannelNumber != 0 && GetStandard () == WIFI_PHY_STANDARD_UN
SPECIFIED) | 458 else if (m_initialChannelNumber != 0 && GetStandard () == WIFI_PHY_STANDARD_UN
SPECIFIED) |
473 { | 459 { |
474 NS_FATAL_ERROR ("Error, ChannelNumber " << (uint16_t)GetChannelNumber () <
< " was set by user, but neither a standard nor a frequency"); | 460 NS_FATAL_ERROR ("Error, ChannelNumber " << static_cast<uint16_t> (GetChann
elNumber ()) << " was set by user, but neither a standard nor a frequency"); |
475 } | 461 } |
476 m_frequencyChannelNumberInitialized = true; | 462 m_frequencyChannelNumberInitialized = true; |
477 } | 463 } |
478 | 464 |
479 void | 465 void |
480 WifiPhy::SetEdThreshold (double threshold) | 466 WifiPhy::SetEdThreshold (double threshold) |
481 { | 467 { |
482 NS_LOG_FUNCTION (this << threshold); | 468 NS_LOG_FUNCTION (this << threshold); |
483 m_edThresholdW = DbmToW (threshold); | 469 m_edThresholdW = DbmToW (threshold); |
484 } | 470 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 m_txPowerEndDbm = end; | 528 m_txPowerEndDbm = end; |
543 } | 529 } |
544 | 530 |
545 double | 531 double |
546 WifiPhy::GetTxPowerEnd (void) const | 532 WifiPhy::GetTxPowerEnd (void) const |
547 { | 533 { |
548 return m_txPowerEndDbm; | 534 return m_txPowerEndDbm; |
549 } | 535 } |
550 | 536 |
551 void | 537 void |
552 WifiPhy::SetNTxPower (uint32_t n) | 538 WifiPhy::SetNTxPower (uint8_t n) |
553 { | 539 { |
554 NS_LOG_FUNCTION (this << n); | 540 NS_LOG_FUNCTION (this << n); |
555 m_nTxPower = n; | 541 m_nTxPower = n; |
556 } | 542 } |
557 | 543 |
558 uint32_t | 544 uint8_t |
559 WifiPhy::GetNTxPower (void) const | 545 WifiPhy::GetNTxPower (void) const |
560 { | 546 { |
561 return m_nTxPower; | 547 return m_nTxPower; |
562 } | 548 } |
563 | 549 |
564 void | 550 void |
565 WifiPhy::SetTxGain (double gain) | 551 WifiPhy::SetTxGain (double gain) |
566 { | 552 { |
567 NS_LOG_FUNCTION (this << gain); | 553 NS_LOG_FUNCTION (this << gain); |
568 m_txGainDb = gain; | 554 m_txGainDb = gain; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 void | 699 void |
714 WifiPhy::SetFrameCaptureModel (const Ptr<FrameCaptureModel> model) | 700 WifiPhy::SetFrameCaptureModel (const Ptr<FrameCaptureModel> model) |
715 { | 701 { |
716 m_frameCaptureModel = model; | 702 m_frameCaptureModel = model; |
717 } | 703 } |
718 | 704 |
719 Ptr<FrameCaptureModel> | 705 Ptr<FrameCaptureModel> |
720 WifiPhy::GetFrameCaptureModel (void) const | 706 WifiPhy::GetFrameCaptureModel (void) const |
721 { | 707 { |
722 return m_frameCaptureModel; | 708 return m_frameCaptureModel; |
| 709 } |
| 710 ···· |
| 711 void |
| 712 WifiPhy::SetWifiRadioEnergyModel (const Ptr<WifiRadioEnergyModel> wifiRadioEnerg
yModel) |
| 713 { |
| 714 m_wifiRadioEnergyModel = wifiRadioEnergyModel; |
723 } | 715 } |
724 | 716 |
725 double | 717 double |
726 WifiPhy::GetPowerDbm (uint8_t power) const | 718 WifiPhy::GetPowerDbm (uint8_t power) const |
727 { | 719 { |
728 NS_ASSERT (m_txPowerBaseDbm <= m_txPowerEndDbm); | 720 NS_ASSERT (m_txPowerBaseDbm <= m_txPowerEndDbm); |
729 NS_ASSERT (m_nTxPower > 0); | 721 NS_ASSERT (m_nTxPower > 0); |
730 double dbm; | 722 double dbm; |
731 if (m_nTxPower > 1) | 723 if (m_nTxPower > 1) |
732 { | 724 { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 m_deviceRateSet.push_back (WifiPhy::GetOfdmRate36Mbps ()); | 908 m_deviceRateSet.push_back (WifiPhy::GetOfdmRate36Mbps ()); |
917 m_deviceRateSet.push_back (WifiPhy::GetOfdmRate54Mbps ()); | 909 m_deviceRateSet.push_back (WifiPhy::GetOfdmRate54Mbps ()); |
918 } | 910 } |
919 | 911 |
920 void | 912 void |
921 WifiPhy::ConfigureHtDeviceMcsSet (void) | 913 WifiPhy::ConfigureHtDeviceMcsSet (void) |
922 { | 914 { |
923 NS_LOG_FUNCTION (this); | 915 NS_LOG_FUNCTION (this); |
924 | 916 |
925 bool htFound = false; | 917 bool htFound = false; |
926 for (std::vector<uint32_t>::size_type i = 0; i < m_bssMembershipSelectorSet.si
ze (); i++) | 918 for (std::vector<uint8_t>::size_type i = 0; i < m_bssMembershipSelectorSet.siz
e (); i++) |
927 { | 919 { |
928 if (m_bssMembershipSelectorSet[i] == HT_PHY) | 920 if (m_bssMembershipSelectorSet[i] == HT_PHY) |
929 { | 921 { |
930 htFound = true; | 922 htFound = true; |
931 break; | 923 break; |
932 } | 924 } |
933 } | 925 } |
934 if (htFound) | 926 if (htFound) |
935 { | 927 { |
936 // erase all HtMcs modes from deviceMcsSet | 928 // erase all HtMcs modes from deviceMcsSet |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs9 ()); | 1036 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs9 ()); |
1045 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs10 ()); | 1037 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs10 ()); |
1046 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs11 ()); | 1038 m_deviceMcsSet.push_back (WifiPhy::GetHeMcs11 ()); |
1047 | 1039 |
1048 m_bssMembershipSelectorSet.push_back (HE_PHY); | 1040 m_bssMembershipSelectorSet.push_back (HE_PHY); |
1049 } | 1041 } |
1050 | 1042 |
1051 bool | 1043 bool |
1052 WifiPhy::DefineChannelNumber (uint8_t channelNumber, WifiPhyStandard standard, u
int16_t frequency, uint8_t channelWidth) | 1044 WifiPhy::DefineChannelNumber (uint8_t channelNumber, WifiPhyStandard standard, u
int16_t frequency, uint8_t channelWidth) |
1053 { | 1045 { |
1054 NS_LOG_FUNCTION (this << (uint16_t)channelNumber << standard << frequency << (
uint16_t)channelWidth); | 1046 NS_LOG_FUNCTION (this << static_cast<uint16_t> (channelNumber) << standard <<
frequency << static_cast<uint16_t> (channelWidth)); |
1055 ChannelNumberStandardPair p = std::make_pair (channelNumber, standard); | 1047 ChannelNumberStandardPair p = std::make_pair (channelNumber, standard); |
1056 ChannelToFrequencyWidthMap::const_iterator it; | 1048 ChannelToFrequencyWidthMap::const_iterator it; |
1057 it = m_channelToFrequencyWidth.find (p); | 1049 it = m_channelToFrequencyWidth.find (p); |
1058 if (it != m_channelToFrequencyWidth.end ()) | 1050 if (it != m_channelToFrequencyWidth.end ()) |
1059 { | 1051 { |
1060 NS_LOG_DEBUG ("channel number/standard already defined; returning false"); | 1052 NS_LOG_DEBUG ("channel number/standard already defined; returning false"); |
1061 return false; | 1053 return false; |
1062 } | 1054 } |
1063 FrequencyWidthPair f = std::make_pair (frequency, channelWidth); | 1055 FrequencyWidthPair f = std::make_pair (frequency, channelWidth); |
1064 m_channelToFrequencyWidth[p] = f; | 1056 m_channelToFrequencyWidth[p] = f; |
1065 return true; | 1057 return true; |
1066 } | 1058 } |
1067 | 1059 |
1068 uint8_t | 1060 uint8_t |
1069 WifiPhy::FindChannelNumberForFrequencyWidth (uint16_t frequency, uint8_t width)
const | 1061 WifiPhy::FindChannelNumberForFrequencyWidth (uint16_t frequency, uint8_t width)
const |
1070 { | 1062 { |
1071 NS_LOG_FUNCTION (this << frequency << (uint16_t)width); | 1063 NS_LOG_FUNCTION (this << frequency << static_cast<uint16_t> (width)); |
1072 bool found = false; | 1064 bool found = false; |
1073 FrequencyWidthPair f = std::make_pair (frequency, width); | 1065 FrequencyWidthPair f = std::make_pair (frequency, width); |
1074 ChannelToFrequencyWidthMap::const_iterator it = m_channelToFrequencyWidth.begi
n (); | 1066 ChannelToFrequencyWidthMap::const_iterator it = m_channelToFrequencyWidth.begi
n (); |
1075 while (it != m_channelToFrequencyWidth.end ()) | 1067 while (it != m_channelToFrequencyWidth.end ()) |
1076 { | 1068 { |
1077 if (it->second == f) | 1069 if (it->second == f) |
1078 { | 1070 { |
1079 found = true; | 1071 found = true; |
1080 break; | 1072 break; |
1081 } | 1073 } |
1082 ++it; | 1074 ++it; |
1083 } | 1075 } |
1084 if (found) | 1076 if (found) |
1085 { | 1077 { |
1086 NS_LOG_DEBUG ("Found, returning " << it->first.first); | 1078 NS_LOG_DEBUG ("Found, returning " << static_cast<uint16_t> (it->first.firs
t)); |
1087 return (it->first.first); | 1079 return (it->first.first); |
1088 } | 1080 } |
1089 else | 1081 else |
1090 { | 1082 { |
1091 NS_LOG_DEBUG ("Not found, returning 0"); | 1083 NS_LOG_DEBUG ("Not found, returning 0"); |
1092 return 0; | 1084 return 0; |
1093 } | 1085 } |
1094 } | 1086 } |
1095 | 1087 |
1096 void | 1088 void |
1097 WifiPhy::ConfigureChannelForStandard (WifiPhyStandard standard) | 1089 WifiPhy::ConfigureChannelForStandard (WifiPhyStandard standard) |
1098 { | 1090 { |
1099 NS_LOG_FUNCTION (this << standard); | 1091 NS_LOG_FUNCTION (this << standard); |
1100 // If the user has configured both Frequency and ChannelNumber, Frequency | 1092 // If the user has configured both Frequency and ChannelNumber, Frequency |
1101 // takes precedence | 1093 // takes precedence |
1102 if (GetFrequency () != 0) | 1094 if (GetFrequency () != 0) |
1103 { | 1095 { |
1104 // If Frequency is already set, then see whether a ChannelNumber can | 1096 // If Frequency is already set, then see whether a ChannelNumber can |
1105 // be found that matches Frequency and ChannelWidth. If so, configure | 1097 // be found that matches Frequency and ChannelWidth. If so, configure |
1106 // the ChannelNumber to that channel number. If not, set ChannelNumber to
zero. | 1098 // the ChannelNumber to that channel number. If not, set ChannelNumber to
zero. |
1107 NS_LOG_DEBUG ("Frequency set; checking whether a channel number correspond
s"); | 1099 NS_LOG_DEBUG ("Frequency set; checking whether a channel number correspond
s"); |
1108 uint8_t channelNumberSearched = FindChannelNumberForFrequencyWidth (GetFre
quency (), GetChannelWidth ()); | 1100 uint8_t channelNumberSearched = FindChannelNumberForFrequencyWidth (GetFre
quency (), GetChannelWidth ()); |
1109 if (channelNumberSearched) | 1101 if (channelNumberSearched) |
1110 { | 1102 { |
1111 NS_LOG_DEBUG ("Channel number found; setting to " << (uint16_t)channel
NumberSearched); | 1103 NS_LOG_DEBUG ("Channel number found; setting to " << static_cast<uint1
6_t> (channelNumberSearched)); |
1112 SetChannelNumber (channelNumberSearched); | 1104 SetChannelNumber (channelNumberSearched); |
1113 } | 1105 } |
1114 else | 1106 else |
1115 { | 1107 { |
1116 NS_LOG_DEBUG ("Channel number not found; setting to zero"); | 1108 NS_LOG_DEBUG ("Channel number not found; setting to zero"); |
1117 SetChannelNumber (0); | 1109 SetChannelNumber (0); |
1118 } | 1110 } |
1119 } | 1111 } |
1120 else if (GetChannelNumber () != 0) | 1112 else if (GetChannelNumber () != 0) |
1121 { | 1113 { |
1122 // If the channel number is known for this particular standard or for | 1114 // If the channel number is known for this particular standard or for |
1123 // the unspecified standard, configure using the known values; | 1115 // the unspecified standard, configure using the known values; |
1124 // otherwise, this is a configuration error | 1116 // otherwise, this is a configuration error |
1125 NS_LOG_DEBUG ("Configuring for channel number " << (uint16_t)GetChannelNum
ber ()); | 1117 NS_LOG_DEBUG ("Configuring for channel number " << static_cast<uint16_t> (
GetChannelNumber ())); |
1126 FrequencyWidthPair f = GetFrequencyWidthForChannelNumberStandard (GetChann
elNumber (), standard); | 1118 FrequencyWidthPair f = GetFrequencyWidthForChannelNumberStandard (GetChann
elNumber (), standard); |
1127 if (f.first == 0) | 1119 if (f.first == 0) |
1128 { | 1120 { |
1129 // the specific pair of number/standard is not known | 1121 // the specific pair of number/standard is not known |
1130 NS_LOG_DEBUG ("Falling back to check WIFI_PHY_STANDARD_UNSPECIFIED"); | 1122 NS_LOG_DEBUG ("Falling back to check WIFI_PHY_STANDARD_UNSPECIFIED"); |
1131 f = GetFrequencyWidthForChannelNumberStandard (GetChannelNumber (), WI
FI_PHY_STANDARD_UNSPECIFIED); | 1123 f = GetFrequencyWidthForChannelNumberStandard (GetChannelNumber (), WI
FI_PHY_STANDARD_UNSPECIFIED); |
1132 } | 1124 } |
1133 if (f.first == 0) | 1125 if (f.first == 0) |
1134 { | 1126 { |
1135 NS_FATAL_ERROR ("Error, ChannelNumber " << (uint16_t)GetChannelNumber
() << " is unknown for this standard"); | 1127 NS_FATAL_ERROR ("Error, ChannelNumber " << static_cast<uint16_t> (GetC
hannelNumber ()) << " is unknown for this standard"); |
1136 } | 1128 } |
1137 else | 1129 else |
1138 { | 1130 { |
1139 NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << (
uint16_t)f.second); | 1131 NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << s
tatic_cast<uint16_t> (f.second)); |
1140 SetFrequency (f.first); | 1132 SetFrequency (f.first); |
1141 SetChannelWidth (f.second); | 1133 SetChannelWidth (f.second); |
1142 } | 1134 } |
1143 } | 1135 } |
1144 } | 1136 } |
1145 | 1137 |
1146 void | 1138 void |
1147 WifiPhy::ConfigureStandard (WifiPhyStandard standard) | 1139 WifiPhy::ConfigureStandard (WifiPhyStandard standard) |
1148 { | 1140 { |
1149 NS_LOG_FUNCTION (this << standard); | 1141 NS_LOG_FUNCTION (this << standard); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 m_channelCenterFrequency = 0; | 1223 m_channelCenterFrequency = 0; |
1232 m_channelNumber = 0; | 1224 m_channelNumber = 0; |
1233 return; | 1225 return; |
1234 } | 1226 } |
1235 // If the user has configured both Frequency and ChannelNumber, Frequency | 1227 // If the user has configured both Frequency and ChannelNumber, Frequency |
1236 // takes precedence. Lookup the channel number corresponding to the | 1228 // takes precedence. Lookup the channel number corresponding to the |
1237 // requested frequency. | 1229 // requested frequency. |
1238 uint8_t nch = FindChannelNumberForFrequencyWidth (frequency, GetChannelWidth (
)); | 1230 uint8_t nch = FindChannelNumberForFrequencyWidth (frequency, GetChannelWidth (
)); |
1239 if (nch != 0) | 1231 if (nch != 0) |
1240 { | 1232 { |
1241 NS_LOG_DEBUG ("Setting frequency " << frequency << " corresponds to channe
l " << (uint16_t)nch); | 1233 NS_LOG_DEBUG ("Setting frequency " << frequency << " corresponds to channe
l " << static_cast<uint16_t> (nch)); |
1242 if (DoFrequencySwitch (frequency)) | 1234 if (DoFrequencySwitch (frequency)) |
1243 { | 1235 { |
1244 NS_LOG_DEBUG ("Channel frequency switched to " << frequency << "; chan
nel number to " << (uint16_t)nch); | 1236 NS_LOG_DEBUG ("Channel frequency switched to " << frequency << "; chan
nel number to " << static_cast<uint16_t> (nch)); |
1245 m_channelCenterFrequency = frequency; | 1237 m_channelCenterFrequency = frequency; |
1246 m_channelNumber = nch; | 1238 m_channelNumber = nch; |
1247 } | 1239 } |
1248 else | 1240 else |
1249 { | 1241 { |
1250 NS_LOG_DEBUG ("Suppressing reassignment of frequency"); | 1242 NS_LOG_DEBUG ("Suppressing reassignment of frequency"); |
1251 } | 1243 } |
1252 } | 1244 } |
1253 else | 1245 else |
1254 { | 1246 { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 NS_ASSERT (streams <= GetNumberOfAntennas ()); | 1312 NS_ASSERT (streams <= GetNumberOfAntennas ()); |
1321 m_rxSpatialStreams = streams; | 1313 m_rxSpatialStreams = streams; |
1322 } | 1314 } |
1323 | 1315 |
1324 uint8_t | 1316 uint8_t |
1325 WifiPhy::GetMaxSupportedRxSpatialStreams (void) const | 1317 WifiPhy::GetMaxSupportedRxSpatialStreams (void) const |
1326 { | 1318 { |
1327 return m_rxSpatialStreams; | 1319 return m_rxSpatialStreams; |
1328 } | 1320 } |
1329 | 1321 |
1330 uint32_t | 1322 uint8_t |
1331 WifiPhy::GetNBssMembershipSelectors (void) const | 1323 WifiPhy::GetNBssMembershipSelectors (void) const |
1332 { | 1324 { |
1333 return m_bssMembershipSelectorSet.size (); | 1325 return static_cast<uint8_t>(m_bssMembershipSelectorSet.size ()); |
1334 } | 1326 } |
1335 | 1327 |
1336 uint32_t | 1328 uint8_t |
1337 WifiPhy::GetBssMembershipSelector (uint32_t selector) const | 1329 WifiPhy::GetBssMembershipSelector (uint8_t selector) const |
1338 { | 1330 { |
1339 return m_bssMembershipSelectorSet[selector]; | 1331 return m_bssMembershipSelectorSet[selector]; |
1340 } | 1332 } |
1341 | 1333 |
1342 WifiModeList | 1334 WifiModeList |
1343 WifiPhy::GetMembershipSelectorModes (uint32_t selector) | 1335 WifiPhy::GetMembershipSelectorModes (uint32_t selector) |
1344 { | 1336 { |
1345 uint32_t id = GetBssMembershipSelector (selector); | 1337 uint32_t id = GetBssMembershipSelector (static_cast<uint8_t>(selector)); |
1346 WifiModeList supportedmodes; | 1338 WifiModeList supportedmodes; |
1347 if (id == HT_PHY || id == VHT_PHY || id == HE_PHY) | 1339 if (id == HT_PHY || id == VHT_PHY || id == HE_PHY) |
1348 { | 1340 { |
1349 //mandatory MCS 0 to 7 | 1341 //mandatory MCS 0 to 7 |
1350 supportedmodes.push_back (WifiPhy::GetHtMcs0 ()); | 1342 supportedmodes.push_back (WifiPhy::GetHtMcs0 ()); |
1351 supportedmodes.push_back (WifiPhy::GetHtMcs1 ()); | 1343 supportedmodes.push_back (WifiPhy::GetHtMcs1 ()); |
1352 supportedmodes.push_back (WifiPhy::GetHtMcs2 ()); | 1344 supportedmodes.push_back (WifiPhy::GetHtMcs2 ()); |
1353 supportedmodes.push_back (WifiPhy::GetHtMcs3 ()); | 1345 supportedmodes.push_back (WifiPhy::GetHtMcs3 ()); |
1354 supportedmodes.push_back (WifiPhy::GetHtMcs4 ()); | 1346 supportedmodes.push_back (WifiPhy::GetHtMcs4 ()); |
1355 supportedmodes.push_back (WifiPhy::GetHtMcs5 ()); | 1347 supportedmodes.push_back (WifiPhy::GetHtMcs5 ()); |
(...skipping 29 matching lines...) Expand all Loading... |
1385 supportedmodes.push_back (WifiPhy::GetHeMcs9 ()); | 1377 supportedmodes.push_back (WifiPhy::GetHeMcs9 ()); |
1386 supportedmodes.push_back (WifiPhy::GetHeMcs10 ()); | 1378 supportedmodes.push_back (WifiPhy::GetHeMcs10 ()); |
1387 supportedmodes.push_back (WifiPhy::GetHeMcs11 ()); | 1379 supportedmodes.push_back (WifiPhy::GetHeMcs11 ()); |
1388 } | 1380 } |
1389 return supportedmodes; | 1381 return supportedmodes; |
1390 } | 1382 } |
1391 | 1383 |
1392 void | 1384 void |
1393 WifiPhy::AddSupportedChannelWidth (uint8_t width) | 1385 WifiPhy::AddSupportedChannelWidth (uint8_t width) |
1394 { | 1386 { |
1395 NS_LOG_FUNCTION (this << (uint16_t)width); | 1387 NS_LOG_FUNCTION (this << static_cast<uint16_t> (width)); |
1396 for (std::vector<uint32_t>::size_type i = 0; i != m_supportedChannelWidthSet.s
ize (); i++) | 1388 for (std::vector<uint32_t>::size_type i = 0; i != m_supportedChannelWidthSet.s
ize (); i++) |
1397 { | 1389 { |
1398 if (m_supportedChannelWidthSet[i] == width) | 1390 if (m_supportedChannelWidthSet[i] == width) |
1399 { | 1391 { |
1400 return; | 1392 return; |
1401 } | 1393 } |
1402 } | 1394 } |
1403 NS_LOG_FUNCTION ("Adding " << (uint16_t)width << " to supported channel width
set"); | 1395 NS_LOG_FUNCTION ("Adding " << static_cast<uint16_t> (width) << " to supported
channel width set"); |
1404 m_supportedChannelWidthSet.push_back (width); | 1396 m_supportedChannelWidthSet.push_back (width); |
1405 } | 1397 } |
1406 | 1398 |
1407 std::vector<uint8_t> | 1399 std::vector<uint8_t> |
1408 WifiPhy::GetSupportedChannelWidthSet (void) const | 1400 WifiPhy::GetSupportedChannelWidthSet (void) const |
1409 { | 1401 { |
1410 return m_supportedChannelWidthSet; | 1402 return m_supportedChannelWidthSet; |
1411 } | 1403 } |
1412 | 1404 |
1413 WifiPhy::FrequencyWidthPair | 1405 WifiPhy::FrequencyWidthPair |
1414 WifiPhy::GetFrequencyWidthForChannelNumberStandard (uint8_t channelNumber, WifiP
hyStandard standard) const | 1406 WifiPhy::GetFrequencyWidthForChannelNumberStandard (uint8_t channelNumber, WifiP
hyStandard standard) const |
1415 { | 1407 { |
1416 ChannelNumberStandardPair p = std::make_pair (channelNumber, standard); | 1408 ChannelNumberStandardPair p = std::make_pair (channelNumber, standard); |
1417 FrequencyWidthPair f = m_channelToFrequencyWidth[p]; | 1409 FrequencyWidthPair f = m_channelToFrequencyWidth[p]; |
1418 return f; | 1410 return f; |
1419 } | 1411 } |
1420 | 1412 |
1421 void | 1413 void |
1422 WifiPhy::SetChannelNumber (uint8_t nch) | 1414 WifiPhy::SetChannelNumber (uint8_t nch) |
1423 { | 1415 { |
1424 NS_LOG_FUNCTION (this << (uint16_t)nch); | 1416 NS_LOG_FUNCTION (this << static_cast<uint16_t> (nch)); |
1425 if (m_isConstructed == false) | 1417 if (m_isConstructed == false) |
1426 { | 1418 { |
1427 NS_LOG_DEBUG ("Saving channel number configuration for initialization"); | 1419 NS_LOG_DEBUG ("Saving channel number configuration for initialization"); |
1428 m_initialChannelNumber = nch; | 1420 m_initialChannelNumber = nch; |
1429 return; | 1421 return; |
1430 } | 1422 } |
1431 if (GetChannelNumber () == nch) | 1423 if (GetChannelNumber () == nch) |
1432 { | 1424 { |
1433 NS_LOG_DEBUG ("No channel change requested"); | 1425 NS_LOG_DEBUG ("No channel change requested"); |
1434 return; | 1426 return; |
(...skipping 13 matching lines...) Expand all Loading... |
1448 // in use | 1440 // in use |
1449 FrequencyWidthPair f = GetFrequencyWidthForChannelNumberStandard (nch, GetStan
dard ()); | 1441 FrequencyWidthPair f = GetFrequencyWidthForChannelNumberStandard (nch, GetStan
dard ()); |
1450 if (f.first == 0) | 1442 if (f.first == 0) |
1451 { | 1443 { |
1452 f = GetFrequencyWidthForChannelNumberStandard (nch, WIFI_PHY_STANDARD_UNSP
ECIFIED); | 1444 f = GetFrequencyWidthForChannelNumberStandard (nch, WIFI_PHY_STANDARD_UNSP
ECIFIED); |
1453 } | 1445 } |
1454 if (f.first != 0) | 1446 if (f.first != 0) |
1455 { | 1447 { |
1456 if (DoChannelSwitch (nch)) | 1448 if (DoChannelSwitch (nch)) |
1457 { | 1449 { |
1458 NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << (
uint16_t)f.second); | 1450 NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << s
tatic_cast<uint16_t> (f.second)); |
1459 m_channelCenterFrequency = f.first; | 1451 m_channelCenterFrequency = f.first; |
1460 SetChannelWidth (f.second); | 1452 SetChannelWidth (f.second); |
1461 m_channelNumber = nch; | 1453 m_channelNumber = nch; |
1462 } | 1454 } |
1463 else | 1455 else |
1464 { | 1456 { |
1465 // Subclass may have suppressed (e.g. waiting for state change) | 1457 // Subclass may have suppressed (e.g. waiting for state change) |
1466 NS_LOG_DEBUG ("Channel switch suppressed"); | 1458 NS_LOG_DEBUG ("Channel switch suppressed"); |
1467 } | 1459 } |
1468 } | 1460 } |
1469 else | 1461 else |
1470 { | 1462 { |
1471 NS_FATAL_ERROR ("Frequency not found for channel number " << nch); | 1463 NS_FATAL_ERROR ("Frequency not found for channel number " << nch); |
1472 } | 1464 } |
1473 } | 1465 } |
1474 | 1466 |
1475 uint8_t | 1467 uint8_t |
1476 WifiPhy::GetChannelNumber (void) const | 1468 WifiPhy::GetChannelNumber (void) const |
1477 { | 1469 { |
1478 return m_channelNumber; | 1470 return m_channelNumber; |
1479 } | 1471 } |
1480 | 1472 |
1481 bool | 1473 bool |
1482 WifiPhy::DoChannelSwitch (uint8_t nch) | 1474 WifiPhy::DoChannelSwitch (uint8_t nch) |
1483 { | 1475 { |
1484 if (!IsInitialized ()) | 1476 if (!IsInitialized ()) |
1485 { | 1477 { |
1486 //this is not channel switch, this is initialization | 1478 //this is not channel switch, this is initialization |
1487 NS_LOG_DEBUG ("initialize to channel " << (uint16_t)nch); | 1479 NS_LOG_DEBUG ("initialize to channel " << static_cast<uint16_t> (nch)); |
1488 return true; | 1480 return true; |
1489 } | 1481 } |
1490 | 1482 |
1491 NS_ASSERT (!IsStateSwitching ()); | 1483 NS_ASSERT (!IsStateSwitching ()); |
1492 switch (m_state->GetState ()) | 1484 switch (m_state->GetState ()) |
1493 { | 1485 { |
1494 case WifiPhy::RX: | 1486 case WifiPhy::RX: |
1495 NS_LOG_DEBUG ("drop packet because of channel switching while reception"); | 1487 NS_LOG_DEBUG ("drop packet because of channel switching while reception"); |
1496 m_endPlcpRxEvent.Cancel (); | 1488 m_endPlcpRxEvent.Cancel (); |
1497 m_endRxEvent.Cancel (); | 1489 m_endRxEvent.Cancel (); |
(...skipping 12 matching lines...) Expand all Loading... |
1510 break; | 1502 break; |
1511 default: | 1503 default: |
1512 NS_ASSERT (false); | 1504 NS_ASSERT (false); |
1513 break; | 1505 break; |
1514 } | 1506 } |
1515 | 1507 |
1516 return false; | 1508 return false; |
1517 | 1509 |
1518 switchChannel: | 1510 switchChannel: |
1519 | 1511 |
1520 NS_LOG_DEBUG ("switching channel " << (uint16_t)GetChannelNumber () << " -> "
<< (uint16_t)nch); | 1512 NS_LOG_DEBUG ("switching channel " << static_cast<uint16_t> (GetChannelNumber
()) << " -> " << static_cast<uint16_t> (nch)); |
1521 m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ()); | 1513 m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ()); |
1522 m_interference.EraseEvents (); | 1514 m_interference.EraseEvents (); |
1523 /* | 1515 /* |
1524 * Needed here to be able to correctly sensed the medium for the first | 1516 * Needed here to be able to correctly sensed the medium for the first |
1525 * time after the switching. The actual switching is not performed until | 1517 * time after the switching. The actual switching is not performed until |
1526 * after m_channelSwitchDelay. Packets received during the switching | 1518 * after m_channelSwitchDelay. Packets received during the switching |
1527 * state are added to the event list and are employed later to figure | 1519 * state are added to the event list and are employed later to figure |
1528 * out the state of the medium after the switching. | 1520 * out the state of the medium after the switching. |
1529 */ | 1521 */ |
1530 return true; | 1522 return true; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching
"); | 1592 NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching
"); |
1601 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetSleepMode, this); | 1593 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetSleepMode, this); |
1602 break; | 1594 break; |
1603 case WifiPhy::CCA_BUSY: | 1595 case WifiPhy::CCA_BUSY: |
1604 case WifiPhy::IDLE: | 1596 case WifiPhy::IDLE: |
1605 NS_LOG_DEBUG ("setting sleep mode"); | 1597 NS_LOG_DEBUG ("setting sleep mode"); |
1606 m_state->SwitchToSleep (); | 1598 m_state->SwitchToSleep (); |
1607 break; | 1599 break; |
1608 case WifiPhy::SLEEP: | 1600 case WifiPhy::SLEEP: |
1609 NS_LOG_DEBUG ("already in sleep mode"); | 1601 NS_LOG_DEBUG ("already in sleep mode"); |
| 1602 break; |
| 1603 default: |
| 1604 NS_ASSERT (false); |
| 1605 break; |
| 1606 } |
| 1607 } |
| 1608 |
| 1609 void |
| 1610 WifiPhy::SetOffMode (void) |
| 1611 { |
| 1612 NS_LOG_FUNCTION (this); |
| 1613 switch (m_state->GetState ()) |
| 1614 { |
| 1615 case WifiPhy::RX: |
| 1616 m_endPlcpRxEvent.Cancel (); |
| 1617 m_endRxEvent.Cancel (); |
| 1618 case WifiPhy::TX: |
| 1619 case WifiPhy::SWITCHING: |
| 1620 case WifiPhy::CCA_BUSY: |
| 1621 case WifiPhy::IDLE: |
| 1622 case WifiPhy::SLEEP: |
| 1623 m_state->SwitchToOff (); |
1610 break; | 1624 break; |
1611 default: | 1625 default: |
1612 NS_ASSERT (false); | 1626 NS_ASSERT (false); |
1613 break; | 1627 break; |
1614 } | 1628 } |
1615 } | 1629 } |
1616 | 1630 |
1617 void | 1631 void |
1618 WifiPhy::ResumeFromSleep (void) | 1632 WifiPhy::ResumeFromSleep (void) |
1619 { | 1633 { |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2291 { | 2305 { |
2292 m_phyMonitorSniffTxTrace (packet, channelFreqMhz, txVector, aMpdu); | 2306 m_phyMonitorSniffTxTrace (packet, channelFreqMhz, txVector, aMpdu); |
2293 } | 2307 } |
2294 | 2308 |
2295 void | 2309 void |
2296 WifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, MpduType m
pdutype) | 2310 WifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, MpduType m
pdutype) |
2297 { | 2311 { |
2298 NS_LOG_FUNCTION (this << packet << txVector.GetMode () | 2312 NS_LOG_FUNCTION (this << packet << txVector.GetMode () |
2299 << txVector.GetMode ().GetDataRate (txVector) | 2313 << txVector.GetMode ().GetDataRate (txVector) |
2300 << txVector.GetPreambleType () | 2314 << txVector.GetPreambleType () |
2301 << (uint16_t)txVector.GetTxPowerLevel () | 2315 << static_cast<uint16_t> (txVector.GetTxPowerLevel ()) |
2302 << (uint16_t)mpdutype); | 2316 << static_cast<uint16_t> (mpdutype)); |
2303 /* Transmission can happen if: | 2317 /* Transmission can happen if: |
2304 * - we are syncing on a packet. It is the responsability of the | 2318 * - we are syncing on a packet. It is the responsability of the |
2305 * MAC layer to avoid doing this but the PHY does nothing to | 2319 * MAC layer to avoid doing this but the PHY does nothing to |
2306 * prevent it. | 2320 * prevent it. |
2307 * - we are idle | 2321 * - we are idle |
2308 */ | 2322 */ |
2309 NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ()); | 2323 NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ()); |
2310 | 2324 |
2311 if (txVector.GetNss () > GetMaxSupportedTxSpatialStreams ()) | 2325 if (txVector.GetNss () > GetMaxSupportedTxSpatialStreams ()) |
2312 { | 2326 { |
(...skipping 24 matching lines...) Expand all Loading... |
2337 } | 2351 } |
2338 MpduInfo aMpdu; | 2352 MpduInfo aMpdu; |
2339 aMpdu.type = mpdutype; | 2353 aMpdu.type = mpdutype; |
2340 aMpdu.mpduRefNumber = m_txMpduReferenceNumber; | 2354 aMpdu.mpduRefNumber = m_txMpduReferenceNumber; |
2341 NotifyMonitorSniffTx (packet, GetFrequency (), txVector, aMpdu); | 2355 NotifyMonitorSniffTx (packet, GetFrequency (), txVector, aMpdu); |
2342 m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel
()), txVector); | 2356 m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel
()), txVector); |
2343 | 2357 |
2344 Ptr<Packet> newPacket = packet->Copy (); // obtain non-const Packet | 2358 Ptr<Packet> newPacket = packet->Copy (); // obtain non-const Packet |
2345 WifiPhyTag oldtag; | 2359 WifiPhyTag oldtag; |
2346 newPacket->RemovePacketTag (oldtag); | 2360 newPacket->RemovePacketTag (oldtag); |
2347 WifiPhyTag tag (txVector, mpdutype); | 2361 if (m_state->GetState () == WifiPhy::OFF) |
| 2362 { |
| 2363 NS_LOG_DEBUG ("Transmission canceled because device is OFF"); |
| 2364 return; |
| 2365 } |
| 2366 uint8_t isFrameComplete = 1; |
| 2367 if (m_wifiRadioEnergyModel != 0 && m_wifiRadioEnergyModel->GetMaximumTimeInSta
te (WifiPhy::TX) < txDuration) |
| 2368 { |
| 2369 isFrameComplete = 0; |
| 2370 } |
| 2371 WifiPhyTag tag (txVector, mpdutype, isFrameComplete); |
2348 newPacket->AddPacketTag (tag); | 2372 newPacket->AddPacketTag (tag); |
2349 | 2373 |
2350 StartTx (newPacket, txVector, txDuration); | 2374 StartTx (newPacket, txVector, txDuration); |
2351 } | 2375 } |
2352 | 2376 |
2353 void | 2377 void |
2354 WifiPhy::StartReceivePreambleAndHeader (Ptr<Packet> packet, double rxPowerW, Tim
e rxDuration) | 2378 WifiPhy::StartReceivePreambleAndHeader (Ptr<Packet> packet, double rxPowerW, Tim
e rxDuration) |
2355 { | 2379 { |
2356 //This function should be later split to check separately whether plcp preambl
e and plcp header can be successfully received. | 2380 //This function should be later split to check separately whether plcp preambl
e and plcp header can be successfully received. |
2357 //Note: plcp preamble reception is not yet modeled. | 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 |
2358 NS_LOG_FUNCTION (this << packet << WToDbm (rxPowerW) << rxDuration); | 2388 NS_LOG_FUNCTION (this << packet << WToDbm (rxPowerW) << rxDuration); |
2359 Time endRx = Simulator::Now () + rxDuration; | 2389 Time endRx = Simulator::Now () + rxDuration; |
2360 | 2390 |
2361 WifiPhyTag tag; | 2391 WifiPhyTag tag; |
2362 bool found = packet->RemovePacketTag (tag); | 2392 bool found = packet->RemovePacketTag (tag); |
2363 if (!found) | 2393 if (!found) |
2364 { | 2394 { |
2365 NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag"); | 2395 NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag"); |
2366 return; | 2396 return; |
2367 } | 2397 } |
2368 | 2398 |
| 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 |
2369 WifiTxVector txVector = tag.GetWifiTxVector (); | 2407 WifiTxVector txVector = tag.GetWifiTxVector (); |
2370 | 2408 |
2371 if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT | 2409 if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT |
2372 && (txVector.GetNss () != (1 + (txVector.GetMode ().GetMcsValue () / 8)))) | 2410 && (txVector.GetNss () != (1 + (txVector.GetMode ().GetMcsValue () / 8)))) |
2373 { | 2411 { |
2374 NS_FATAL_ERROR ("MCS value does not match NSS value: MCS = " << (uint16_t)
txVector.GetMode ().GetMcsValue () << ", NSS = " << (uint16_t)txVector.GetNss ()
); | 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 ())); |
2375 } | 2413 } |
2376 | 2414 |
2377 Ptr<InterferenceHelper::Event> event; | 2415 Ptr<InterferenceHelper::Event> event; |
2378 event = m_interference.Add (packet, | 2416 event = m_interference.Add (packet, |
2379 txVector, | 2417 txVector, |
2380 rxDuration, | 2418 rxDuration, |
2381 rxPowerW); | 2419 rxPowerW); |
2382 | 2420 |
2383 if (txVector.GetNss () > GetMaxSupportedRxSpatialStreams ()) | 2421 if (txVector.GetNss () > GetMaxSupportedRxSpatialStreams ()) |
2384 { | 2422 { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2481 m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd); | 2519 m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd); |
2482 } | 2520 } |
2483 } | 2521 } |
2484 | 2522 |
2485 void | 2523 void |
2486 WifiPhy::StartReceivePacket (Ptr<Packet> packet, | 2524 WifiPhy::StartReceivePacket (Ptr<Packet> packet, |
2487 WifiTxVector txVector, | 2525 WifiTxVector txVector, |
2488 MpduType mpdutype, | 2526 MpduType mpdutype, |
2489 Ptr<InterferenceHelper::Event> event) | 2527 Ptr<InterferenceHelper::Event> event) |
2490 { | 2528 { |
2491 NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetPreamble
Type () << (uint16_t)mpdutype); | 2529 NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetPreamble
Type () << static_cast<uint16_t> (mpdutype)); |
2492 NS_ASSERT (IsStateRx ()); | 2530 NS_ASSERT (IsStateRx ()); |
2493 NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); | 2531 NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
2494 WifiMode txMode = txVector.GetMode (); | 2532 WifiMode txMode = txVector.GetMode (); |
2495 | 2533 |
2496 InterferenceHelper::SnrPer snrPer; | 2534 InterferenceHelper::SnrPer snrPer; |
2497 snrPer = m_interference.CalculatePlcpHeaderSnrPer (event); | 2535 snrPer = m_interference.CalculatePlcpHeaderSnrPer (event); |
2498 | 2536 |
2499 NS_LOG_DEBUG ("snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per); | 2537 NS_LOG_DEBUG ("snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per); |
2500 | 2538 |
2501 if (m_random->GetValue () > snrPer.per) //plcp reception succeeded | 2539 if (m_random->GetValue () > snrPer.per) //plcp reception succeeded |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3502 return static_cast<uint8_t>(m_deviceMcsSet.size ()); | 3540 return static_cast<uint8_t>(m_deviceMcsSet.size ()); |
3503 } | 3541 } |
3504 | 3542 |
3505 WifiMode | 3543 WifiMode |
3506 WifiPhy::GetMcs (uint8_t mcs) const | 3544 WifiPhy::GetMcs (uint8_t mcs) const |
3507 { | 3545 { |
3508 return m_deviceMcsSet[mcs]; | 3546 return m_deviceMcsSet[mcs]; |
3509 } | 3547 } |
3510 | 3548 |
3511 bool | 3549 bool |
3512 WifiPhy::IsStateCcaBusy (void) | 3550 WifiPhy::IsStateCcaBusy (void) const |
3513 { | 3551 { |
3514 return m_state->IsStateCcaBusy (); | 3552 return m_state->IsStateCcaBusy (); |
3515 } | 3553 } |
3516 | 3554 |
3517 bool | 3555 bool |
3518 WifiPhy::IsStateIdle (void) | 3556 WifiPhy::IsStateIdle (void) const |
3519 { | 3557 { |
3520 return m_state->IsStateIdle (); | 3558 return m_state->IsStateIdle (); |
3521 } | 3559 } |
3522 | 3560 |
3523 bool | 3561 bool |
3524 WifiPhy::IsStateBusy (void) | 3562 WifiPhy::IsStateBusy (void) const |
3525 { | 3563 { |
3526 return m_state->IsStateBusy (); | 3564 return m_state->IsStateBusy (); |
3527 } | 3565 } |
3528 | 3566 |
3529 bool | 3567 bool |
3530 WifiPhy::IsStateRx (void) | 3568 WifiPhy::IsStateRx (void) const |
3531 { | 3569 { |
3532 return m_state->IsStateRx (); | 3570 return m_state->IsStateRx (); |
3533 } | 3571 } |
3534 | 3572 |
3535 bool | 3573 bool |
3536 WifiPhy::IsStateTx (void) | 3574 WifiPhy::IsStateTx (void) const |
3537 { | 3575 { |
3538 return m_state->IsStateTx (); | 3576 return m_state->IsStateTx (); |
3539 } | 3577 } |
3540 | 3578 |
3541 bool | 3579 bool |
3542 WifiPhy::IsStateSwitching (void) | 3580 WifiPhy::IsStateSwitching (void) const |
3543 { | 3581 { |
3544 return m_state->IsStateSwitching (); | 3582 return m_state->IsStateSwitching (); |
3545 } | 3583 } |
3546 | 3584 |
3547 bool | 3585 bool |
3548 WifiPhy::IsStateSleep (void) | 3586 WifiPhy::IsStateSleep (void) const |
3549 { | 3587 { |
3550 return m_state->IsStateSleep (); | 3588 return m_state->IsStateSleep (); |
| 3589 } |
| 3590 |
| 3591 bool |
| 3592 WifiPhy::IsStateOff (void) const |
| 3593 { |
| 3594 return m_state->IsStateOff (); |
3551 } | 3595 } |
3552 | 3596 |
3553 Time | 3597 Time |
3554 WifiPhy::GetStateDuration (void) | 3598 WifiPhy::GetStateDuration (void) |
3555 { | 3599 { |
3556 return m_state->GetStateDuration (); | 3600 return m_state->GetStateDuration (); |
3557 } | 3601 } |
3558 | 3602 |
3559 Time | 3603 Time |
3560 WifiPhy::GetDelayUntilIdle (void) | 3604 WifiPhy::GetDelayUntilIdle (void) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3599 } | 3643 } |
3600 NotifyRxDrop (m_currentEvent->GetPacket ()); | 3644 NotifyRxDrop (m_currentEvent->GetPacket ()); |
3601 m_interference.NotifyRxEnd (); | 3645 m_interference.NotifyRxEnd (); |
3602 m_state->SwitchFromRxAbort (); | 3646 m_state->SwitchFromRxAbort (); |
3603 m_currentEvent = 0; | 3647 m_currentEvent = 0; |
3604 } | 3648 } |
3605 | 3649 |
3606 void | 3650 void |
3607 WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype,
double rxPowerW, Time rxDuration, Ptr<InterferenceHelper::Event> event) | 3651 WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype,
double rxPowerW, Time rxDuration, Ptr<InterferenceHelper::Event> event) |
3608 { | 3652 { |
3609 NS_LOG_FUNCTION (this << packet << txVector << (uint16_t)mpdutype << rxPowerW
<< rxDuration); | 3653 NS_LOG_FUNCTION (this << packet << txVector << static_cast<uint16_t> (mpdutype
) << rxPowerW << rxDuration); |
3610 if (rxPowerW > GetEdThresholdW ()) //checked here, no need to check in the pay
load reception (current implementation assumes constant rx power over the packet
duration) | 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 { | 3655 { |
3612 AmpduTag ampduTag; | 3656 AmpduTag ampduTag; |
3613 WifiPreamble preamble = txVector.GetPreambleType (); | 3657 WifiPreamble preamble = txVector.GetPreambleType (); |
3614 if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess ==
false)) | 3658 if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess ==
false)) |
3615 { | 3659 { |
3616 m_plcpSuccess = false; | 3660 m_plcpSuccess = false; |
3617 m_mpdusNum = 0; | 3661 m_mpdusNum = 0; |
3618 NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been re
ceived"); | 3662 NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been re
ceived"); |
3619 NotifyRxDrop (packet); | 3663 NotifyRxDrop (packet); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3810 ns3::WifiPhy::GetHeMcs6 (); | 3854 ns3::WifiPhy::GetHeMcs6 (); |
3811 ns3::WifiPhy::GetHeMcs7 (); | 3855 ns3::WifiPhy::GetHeMcs7 (); |
3812 ns3::WifiPhy::GetHeMcs8 (); | 3856 ns3::WifiPhy::GetHeMcs8 (); |
3813 ns3::WifiPhy::GetHeMcs9 (); | 3857 ns3::WifiPhy::GetHeMcs9 (); |
3814 ns3::WifiPhy::GetHeMcs10 (); | 3858 ns3::WifiPhy::GetHeMcs10 (); |
3815 ns3::WifiPhy::GetHeMcs11 (); | 3859 ns3::WifiPhy::GetHeMcs11 (); |
3816 } | 3860 } |
3817 } g_constructor; ///< the constructor | 3861 } g_constructor; ///< the constructor |
3818 | 3862 |
3819 } | 3863 } |
LEFT | RIGHT |