Left: | ||
Right: |
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 10 matching lines...) Expand all Loading... | |
1265 } | 1257 } |
1266 } | 1258 } |
1267 } | 1259 } |
1268 | 1260 |
1269 uint16_t | 1261 uint16_t |
1270 WifiPhy::GetFrequency (void) const | 1262 WifiPhy::GetFrequency (void) const |
1271 { | 1263 { |
1272 return m_channelCenterFrequency; | 1264 return m_channelCenterFrequency; |
1273 } | 1265 } |
1274 | 1266 |
1275 bool | |
1276 WifiPhy::Is2_4Ghz (double frequency) | |
1277 { | |
1278 if (frequency >= 2400 && frequency <= 2500) | |
1279 { | |
1280 return true; | |
1281 } | |
1282 return false; | |
1283 } | |
1284 | |
1285 bool | |
1286 WifiPhy::Is5Ghz (double frequency) | |
1287 { | |
1288 if (frequency >= 5000 && frequency <= 6000) | |
1289 { | |
1290 return true; | |
1291 } | |
1292 return false; | |
1293 } | |
1294 | |
1295 void | 1267 void |
1296 WifiPhy::SetChannelWidth (uint8_t channelwidth) | 1268 WifiPhy::SetChannelWidth (uint8_t channelwidth) |
1297 { | 1269 { |
1298 NS_ASSERT_MSG (channelwidth == 5 || channelwidth == 10 || channelwidth == 20 | | channelwidth == 22 || channelwidth == 40 || channelwidth == 80 || channelwidth == 160, "wrong channel width value"); | 1270 NS_ASSERT_MSG (channelwidth == 5 || channelwidth == 10 || channelwidth == 20 | | channelwidth == 22 || channelwidth == 40 || channelwidth == 80 || channelwidth == 160, "wrong channel width value"); |
1299 m_channelWidth = channelwidth; | 1271 m_channelWidth = channelwidth; |
1300 AddSupportedChannelWidth (channelwidth); | 1272 AddSupportedChannelWidth (channelwidth); |
1301 } | 1273 } |
1302 | 1274 |
1303 uint8_t | 1275 uint8_t |
1304 WifiPhy::GetChannelWidth (void) const | 1276 WifiPhy::GetChannelWidth (void) const |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1340 NS_ASSERT (streams <= GetNumberOfAntennas ()); | 1312 NS_ASSERT (streams <= GetNumberOfAntennas ()); |
1341 m_rxSpatialStreams = streams; | 1313 m_rxSpatialStreams = streams; |
1342 } | 1314 } |
1343 | 1315 |
1344 uint8_t | 1316 uint8_t |
1345 WifiPhy::GetMaxSupportedRxSpatialStreams (void) const | 1317 WifiPhy::GetMaxSupportedRxSpatialStreams (void) const |
1346 { | 1318 { |
1347 return m_rxSpatialStreams; | 1319 return m_rxSpatialStreams; |
1348 } | 1320 } |
1349 | 1321 |
1350 uint32_t | 1322 uint8_t |
1351 WifiPhy::GetNBssMembershipSelectors (void) const | 1323 WifiPhy::GetNBssMembershipSelectors (void) const |
1352 { | 1324 { |
1353 return m_bssMembershipSelectorSet.size (); | 1325 return static_cast<uint8_t>(m_bssMembershipSelectorSet.size ()); |
1354 } | 1326 } |
1355 | 1327 |
1356 uint32_t | 1328 uint8_t |
1357 WifiPhy::GetBssMembershipSelector (uint32_t selector) const | 1329 WifiPhy::GetBssMembershipSelector (uint8_t selector) const |
1358 { | 1330 { |
1359 return m_bssMembershipSelectorSet[selector]; | 1331 return m_bssMembershipSelectorSet[selector]; |
1360 } | 1332 } |
1361 | 1333 |
1362 WifiModeList | 1334 WifiModeList |
1363 WifiPhy::GetMembershipSelectorModes (uint32_t selector) | 1335 WifiPhy::GetMembershipSelectorModes (uint32_t selector) |
1364 { | 1336 { |
1365 uint32_t id = GetBssMembershipSelector (selector); | 1337 uint32_t id = GetBssMembershipSelector (static_cast<uint8_t>(selector)); |
1366 WifiModeList supportedmodes; | 1338 WifiModeList supportedmodes; |
1367 if (id == HT_PHY || id == VHT_PHY || id == HE_PHY) | 1339 if (id == HT_PHY || id == VHT_PHY || id == HE_PHY) |
1368 { | 1340 { |
1369 //mandatory MCS 0 to 7 | 1341 //mandatory MCS 0 to 7 |
1370 supportedmodes.push_back (WifiPhy::GetHtMcs0 ()); | 1342 supportedmodes.push_back (WifiPhy::GetHtMcs0 ()); |
1371 supportedmodes.push_back (WifiPhy::GetHtMcs1 ()); | 1343 supportedmodes.push_back (WifiPhy::GetHtMcs1 ()); |
1372 supportedmodes.push_back (WifiPhy::GetHtMcs2 ()); | 1344 supportedmodes.push_back (WifiPhy::GetHtMcs2 ()); |
1373 supportedmodes.push_back (WifiPhy::GetHtMcs3 ()); | 1345 supportedmodes.push_back (WifiPhy::GetHtMcs3 ()); |
1374 supportedmodes.push_back (WifiPhy::GetHtMcs4 ()); | 1346 supportedmodes.push_back (WifiPhy::GetHtMcs4 ()); |
1375 supportedmodes.push_back (WifiPhy::GetHtMcs5 ()); | 1347 supportedmodes.push_back (WifiPhy::GetHtMcs5 ()); |
(...skipping 29 matching lines...) Expand all Loading... | |
1405 supportedmodes.push_back (WifiPhy::GetHeMcs9 ()); | 1377 supportedmodes.push_back (WifiPhy::GetHeMcs9 ()); |
1406 supportedmodes.push_back (WifiPhy::GetHeMcs10 ()); | 1378 supportedmodes.push_back (WifiPhy::GetHeMcs10 ()); |
1407 supportedmodes.push_back (WifiPhy::GetHeMcs11 ()); | 1379 supportedmodes.push_back (WifiPhy::GetHeMcs11 ()); |
1408 } | 1380 } |
1409 return supportedmodes; | 1381 return supportedmodes; |
1410 } | 1382 } |
1411 | 1383 |
1412 void | 1384 void |
1413 WifiPhy::AddSupportedChannelWidth (uint8_t width) | 1385 WifiPhy::AddSupportedChannelWidth (uint8_t width) |
1414 { | 1386 { |
1415 NS_LOG_FUNCTION (this << (uint16_t)width); | 1387 NS_LOG_FUNCTION (this << static_cast<uint16_t> (width)); |
1416 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++) |
1417 { | 1389 { |
1418 if (m_supportedChannelWidthSet[i] == width) | 1390 if (m_supportedChannelWidthSet[i] == width) |
1419 { | 1391 { |
1420 return; | 1392 return; |
1421 } | 1393 } |
1422 } | 1394 } |
1423 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"); |
1424 m_supportedChannelWidthSet.push_back (width); | 1396 m_supportedChannelWidthSet.push_back (width); |
1425 } | 1397 } |
1426 | 1398 |
1427 std::vector<uint8_t> | 1399 std::vector<uint8_t> |
1428 WifiPhy::GetSupportedChannelWidthSet (void) const | 1400 WifiPhy::GetSupportedChannelWidthSet (void) const |
1429 { | 1401 { |
1430 return m_supportedChannelWidthSet; | 1402 return m_supportedChannelWidthSet; |
1431 } | 1403 } |
1432 | 1404 |
1433 WifiPhy::FrequencyWidthPair | 1405 WifiPhy::FrequencyWidthPair |
1434 WifiPhy::GetFrequencyWidthForChannelNumberStandard (uint8_t channelNumber, WifiP hyStandard standard) const | 1406 WifiPhy::GetFrequencyWidthForChannelNumberStandard (uint8_t channelNumber, WifiP hyStandard standard) const |
1435 { | 1407 { |
1436 ChannelNumberStandardPair p = std::make_pair (channelNumber, standard); | 1408 ChannelNumberStandardPair p = std::make_pair (channelNumber, standard); |
1437 FrequencyWidthPair f = m_channelToFrequencyWidth[p]; | 1409 FrequencyWidthPair f = m_channelToFrequencyWidth[p]; |
1438 return f; | 1410 return f; |
1439 } | 1411 } |
1440 | 1412 |
1441 void | 1413 void |
1442 WifiPhy::SetChannelNumber (uint8_t nch) | 1414 WifiPhy::SetChannelNumber (uint8_t nch) |
1443 { | 1415 { |
1444 NS_LOG_FUNCTION (this << (uint16_t)nch); | 1416 NS_LOG_FUNCTION (this << static_cast<uint16_t> (nch)); |
1445 if (m_isConstructed == false) | 1417 if (m_isConstructed == false) |
1446 { | 1418 { |
1447 NS_LOG_DEBUG ("Saving channel number configuration for initialization"); | 1419 NS_LOG_DEBUG ("Saving channel number configuration for initialization"); |
1448 m_initialChannelNumber = nch; | 1420 m_initialChannelNumber = nch; |
1449 return; | 1421 return; |
1450 } | 1422 } |
1451 if (GetChannelNumber () == nch) | 1423 if (GetChannelNumber () == nch) |
1452 { | 1424 { |
1453 NS_LOG_DEBUG ("No channel change requested"); | 1425 NS_LOG_DEBUG ("No channel change requested"); |
1454 return; | 1426 return; |
(...skipping 13 matching lines...) Expand all Loading... | |
1468 // in use | 1440 // in use |
1469 FrequencyWidthPair f = GetFrequencyWidthForChannelNumberStandard (nch, GetStan dard ()); | 1441 FrequencyWidthPair f = GetFrequencyWidthForChannelNumberStandard (nch, GetStan dard ()); |
1470 if (f.first == 0) | 1442 if (f.first == 0) |
1471 { | 1443 { |
1472 f = GetFrequencyWidthForChannelNumberStandard (nch, WIFI_PHY_STANDARD_UNSP ECIFIED); | 1444 f = GetFrequencyWidthForChannelNumberStandard (nch, WIFI_PHY_STANDARD_UNSP ECIFIED); |
1473 } | 1445 } |
1474 if (f.first != 0) | 1446 if (f.first != 0) |
1475 { | 1447 { |
1476 if (DoChannelSwitch (nch)) | 1448 if (DoChannelSwitch (nch)) |
1477 { | 1449 { |
1478 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)); |
1479 m_channelCenterFrequency = f.first; | 1451 m_channelCenterFrequency = f.first; |
1480 SetChannelWidth (f.second); | 1452 SetChannelWidth (f.second); |
1481 m_channelNumber = nch; | 1453 m_channelNumber = nch; |
1482 } | 1454 } |
1483 else | 1455 else |
1484 { | 1456 { |
1485 // Subclass may have suppressed (e.g. waiting for state change) | 1457 // Subclass may have suppressed (e.g. waiting for state change) |
1486 NS_LOG_DEBUG ("Channel switch suppressed"); | 1458 NS_LOG_DEBUG ("Channel switch suppressed"); |
1487 } | 1459 } |
1488 } | 1460 } |
1489 else | 1461 else |
1490 { | 1462 { |
1491 NS_FATAL_ERROR ("Frequency not found for channel number " << nch); | 1463 NS_FATAL_ERROR ("Frequency not found for channel number " << nch); |
1492 } | 1464 } |
1493 } | 1465 } |
1494 | 1466 |
1495 uint8_t | 1467 uint8_t |
1496 WifiPhy::GetChannelNumber (void) const | 1468 WifiPhy::GetChannelNumber (void) const |
1497 { | 1469 { |
1498 return m_channelNumber; | 1470 return m_channelNumber; |
1499 } | 1471 } |
1500 | 1472 |
1501 bool | 1473 bool |
1502 WifiPhy::DoChannelSwitch (uint8_t nch) | 1474 WifiPhy::DoChannelSwitch (uint8_t nch) |
1503 { | 1475 { |
1504 if (!IsInitialized ()) | 1476 if (!IsInitialized ()) |
1505 { | 1477 { |
1506 //this is not channel switch, this is initialization | 1478 //this is not channel switch, this is initialization |
1507 NS_LOG_DEBUG ("initialize to channel " << (uint16_t)nch); | 1479 NS_LOG_DEBUG ("initialize to channel " << static_cast<uint16_t> (nch)); |
1508 return true; | 1480 return true; |
1509 } | 1481 } |
1510 | 1482 |
1511 NS_ASSERT (!IsStateSwitching ()); | 1483 NS_ASSERT (!IsStateSwitching ()); |
1512 switch (m_state->GetState ()) | 1484 switch (m_state->GetState ()) |
1513 { | 1485 { |
1514 case WifiPhy::RX: | 1486 case WifiPhy::RX: |
1515 NS_LOG_DEBUG ("drop packet because of channel switching while reception"); | 1487 NS_LOG_DEBUG ("drop packet because of channel switching while reception"); |
1516 m_endPlcpRxEvent.Cancel (); | 1488 m_endPlcpRxEvent.Cancel (); |
1517 m_endRxEvent.Cancel (); | 1489 m_endRxEvent.Cancel (); |
(...skipping 12 matching lines...) Expand all Loading... | |
1530 break; | 1502 break; |
1531 default: | 1503 default: |
1532 NS_ASSERT (false); | 1504 NS_ASSERT (false); |
1533 break; | 1505 break; |
1534 } | 1506 } |
1535 | 1507 |
1536 return false; | 1508 return false; |
1537 | 1509 |
1538 switchChannel: | 1510 switchChannel: |
1539 | 1511 |
1540 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)); |
1541 m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ()); | 1513 m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ()); |
1542 m_interference.EraseEvents (); | 1514 m_interference.EraseEvents (); |
1543 /* | 1515 /* |
1544 * 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 |
1545 * time after the switching. The actual switching is not performed until | 1517 * time after the switching. The actual switching is not performed until |
1546 * after m_channelSwitchDelay. Packets received during the switching | 1518 * after m_channelSwitchDelay. Packets received during the switching |
1547 * 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 |
1548 * out the state of the medium after the switching. | 1520 * out the state of the medium after the switching. |
1549 */ | 1521 */ |
1550 return true; | 1522 return true; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1620 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 "); |
1621 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetSleepMode, this); | 1593 Simulator::Schedule (GetDelayUntilIdle (), &WifiPhy::SetSleepMode, this); |
1622 break; | 1594 break; |
1623 case WifiPhy::CCA_BUSY: | 1595 case WifiPhy::CCA_BUSY: |
1624 case WifiPhy::IDLE: | 1596 case WifiPhy::IDLE: |
1625 NS_LOG_DEBUG ("setting sleep mode"); | 1597 NS_LOG_DEBUG ("setting sleep mode"); |
1626 m_state->SwitchToSleep (); | 1598 m_state->SwitchToSleep (); |
1627 break; | 1599 break; |
1628 case WifiPhy::SLEEP: | 1600 case WifiPhy::SLEEP: |
1629 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 (); | |
1630 break; | 1624 break; |
1631 default: | 1625 default: |
1632 NS_ASSERT (false); | 1626 NS_ASSERT (false); |
1633 break; | 1627 break; |
1634 } | 1628 } |
1635 } | 1629 } |
1636 | 1630 |
1637 void | 1631 void |
1638 WifiPhy::ResumeFromSleep (void) | 1632 WifiPhy::ResumeFromSleep (void) |
1639 { | 1633 { |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2311 { | 2305 { |
2312 m_phyMonitorSniffTxTrace (packet, channelFreqMhz, txVector, aMpdu); | 2306 m_phyMonitorSniffTxTrace (packet, channelFreqMhz, txVector, aMpdu); |
2313 } | 2307 } |
2314 | 2308 |
2315 void | 2309 void |
2316 WifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, MpduType m pdutype) | 2310 WifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, MpduType m pdutype) |
2317 { | 2311 { |
2318 NS_LOG_FUNCTION (this << packet << txVector.GetMode () | 2312 NS_LOG_FUNCTION (this << packet << txVector.GetMode () |
2319 << txVector.GetMode ().GetDataRate (txVector) | 2313 << txVector.GetMode ().GetDataRate (txVector) |
2320 << txVector.GetPreambleType () | 2314 << txVector.GetPreambleType () |
2321 << (uint16_t)txVector.GetTxPowerLevel () | 2315 << static_cast<uint16_t> (txVector.GetTxPowerLevel ()) |
2322 << (uint16_t)mpdutype); | 2316 << static_cast<uint16_t> (mpdutype)); |
2323 /* Transmission can happen if: | 2317 /* Transmission can happen if: |
2324 * - 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 |
2325 * 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 |
2326 * prevent it. | 2320 * prevent it. |
2327 * - we are idle | 2321 * - we are idle |
2328 */ | 2322 */ |
2329 NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ()); | 2323 NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ()); |
2330 | 2324 |
2331 if (txVector.GetNss () > GetMaxSupportedTxSpatialStreams ()) | 2325 if (txVector.GetNss () > GetMaxSupportedTxSpatialStreams ()) |
2332 { | 2326 { |
(...skipping 24 matching lines...) Expand all Loading... | |
2357 } | 2351 } |
2358 MpduInfo aMpdu; | 2352 MpduInfo aMpdu; |
2359 aMpdu.type = mpdutype; | 2353 aMpdu.type = mpdutype; |
2360 aMpdu.mpduRefNumber = m_txMpduReferenceNumber; | 2354 aMpdu.mpduRefNumber = m_txMpduReferenceNumber; |
2361 NotifyMonitorSniffTx (packet, GetFrequency (), txVector, aMpdu); | 2355 NotifyMonitorSniffTx (packet, GetFrequency (), txVector, aMpdu); |
2362 m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector); | 2356 m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector); |
2363 | 2357 |
2364 Ptr<Packet> newPacket = packet->Copy (); // obtain non-const Packet | 2358 Ptr<Packet> newPacket = packet->Copy (); // obtain non-const Packet |
2365 WifiPhyTag oldtag; | 2359 WifiPhyTag oldtag; |
2366 newPacket->RemovePacketTag (oldtag); | 2360 newPacket->RemovePacketTag (oldtag); |
2367 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); | |
2368 newPacket->AddPacketTag (tag); | 2372 newPacket->AddPacketTag (tag); |
2369 | 2373 |
2370 StartTx (newPacket, txVector, txDuration); | 2374 StartTx (newPacket, txVector, txDuration); |
2371 } | 2375 } |
2372 | 2376 |
2373 void | 2377 void |
2374 WifiPhy::StartReceivePreambleAndHeader (Ptr<Packet> packet, double rxPowerW, Tim e rxDuration) | 2378 WifiPhy::StartReceivePreambleAndHeader (Ptr<Packet> packet, double rxPowerW, Tim e rxDuration) |
2375 { | 2379 { |
2376 //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. |
2377 //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 | |
2378 NS_LOG_FUNCTION (this << packet << WToDbm (rxPowerW) << rxDuration); | 2388 NS_LOG_FUNCTION (this << packet << WToDbm (rxPowerW) << rxDuration); |
2379 Time endRx = Simulator::Now () + rxDuration; | 2389 Time endRx = Simulator::Now () + rxDuration; |
2380 | 2390 |
2381 WifiPhyTag tag; | 2391 WifiPhyTag tag; |
2382 bool found = packet->RemovePacketTag (tag); | 2392 bool found = packet->RemovePacketTag (tag); |
2383 if (!found) | 2393 if (!found) |
2384 { | 2394 { |
2385 NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag"); | 2395 NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag"); |
2386 return; | 2396 return; |
2387 } | 2397 } |
2388 | 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 | |
2389 WifiTxVector txVector = tag.GetWifiTxVector (); | 2407 WifiTxVector txVector = tag.GetWifiTxVector (); |
2390 | 2408 |
2391 if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT | 2409 if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT |
2392 && (txVector.GetNss () != (1 + (txVector.GetMode ().GetMcsValue () / 8)))) | 2410 && (txVector.GetNss () != (1 + (txVector.GetMode ().GetMcsValue () / 8)))) |
2393 { | 2411 { |
2394 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 ())); |
2395 } | 2413 } |
2396 | 2414 |
2397 Ptr<InterferenceHelper::Event> event; | 2415 Ptr<InterferenceHelper::Event> event; |
2398 event = m_interference.Add (packet, | 2416 event = m_interference.Add (packet, |
2399 txVector, | 2417 txVector, |
2400 rxDuration, | 2418 rxDuration, |
2401 rxPowerW); | 2419 rxPowerW); |
2402 | 2420 |
2403 if (txVector.GetNss () > GetMaxSupportedRxSpatialStreams ()) | 2421 if (txVector.GetNss () > GetMaxSupportedRxSpatialStreams ()) |
2404 { | 2422 { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2501 m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd); | 2519 m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd); |
2502 } | 2520 } |
2503 } | 2521 } |
2504 | 2522 |
2505 void | 2523 void |
2506 WifiPhy::StartReceivePacket (Ptr<Packet> packet, | 2524 WifiPhy::StartReceivePacket (Ptr<Packet> packet, |
2507 WifiTxVector txVector, | 2525 WifiTxVector txVector, |
2508 MpduType mpdutype, | 2526 MpduType mpdutype, |
2509 Ptr<InterferenceHelper::Event> event) | 2527 Ptr<InterferenceHelper::Event> event) |
2510 { | 2528 { |
2511 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)); |
2512 NS_ASSERT (IsStateRx ()); | 2530 NS_ASSERT (IsStateRx ()); |
2513 NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); | 2531 NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
2514 WifiMode txMode = txVector.GetMode (); | 2532 WifiMode txMode = txVector.GetMode (); |
2515 | 2533 |
2516 InterferenceHelper::SnrPer snrPer; | 2534 InterferenceHelper::SnrPer snrPer; |
2517 snrPer = m_interference.CalculatePlcpHeaderSnrPer (event); | 2535 snrPer = m_interference.CalculatePlcpHeaderSnrPer (event); |
2518 | 2536 |
2519 NS_LOG_DEBUG ("snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per); | 2537 NS_LOG_DEBUG ("snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per); |
2520 | 2538 |
2521 if (m_random->GetValue () > snrPer.per) //plcp reception succeeded | 2539 if (m_random->GetValue () > snrPer.per) //plcp reception succeeded |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3472 | 3490 |
3473 WifiMode | 3491 WifiMode |
3474 WifiPhy::GetHeMcs11 () | 3492 WifiPhy::GetHeMcs11 () |
3475 { | 3493 { |
3476 static WifiMode mcs = | 3494 static WifiMode mcs = |
3477 WifiModeFactory::CreateWifiMcs ("HeMcs11", 11, WIFI_MOD_CLASS_HE); | 3495 WifiModeFactory::CreateWifiMcs ("HeMcs11", 11, WIFI_MOD_CLASS_HE); |
3478 return mcs; | 3496 return mcs; |
3479 } | 3497 } |
3480 | 3498 |
3481 bool | 3499 bool |
3482 WifiPhy::IsValidTxVector (WifiTxVector txVector) | |
3483 { | |
3484 uint8_t chWidth = txVector.GetChannelWidth (); | |
3485 uint8_t nss = txVector.GetNss (); | |
3486 std::string modeName = txVector.GetMode ().GetUniqueName (); | |
3487 | |
3488 if (chWidth == 20) | |
3489 { | |
3490 if (nss != 3 && nss != 6) | |
3491 { | |
3492 return (modeName != "VhtMcs9"); | |
3493 } | |
3494 } | |
3495 else if (chWidth == 80) | |
3496 { | |
3497 if (nss == 3 || nss == 7) | |
3498 { | |
3499 return (modeName != "VhtMcs6"); | |
3500 } | |
3501 else if (nss == 6) | |
3502 { | |
3503 return (modeName != "VhtMcs9"); | |
3504 } | |
3505 } | |
3506 else if (chWidth == 160) | |
3507 { | |
3508 if (nss == 3) | |
3509 { | |
3510 return (modeName != "VhtMcs9"); | |
3511 } | |
3512 } | |
3513 | |
3514 return true; | |
3515 } | |
3516 | |
3517 bool | |
3518 WifiPhy::IsModeSupported (WifiMode mode) const | 3500 WifiPhy::IsModeSupported (WifiMode mode) const |
3519 { | 3501 { |
3520 for (uint8_t i = 0; i < GetNModes (); i++) | 3502 for (uint8_t i = 0; i < GetNModes (); i++) |
3521 { | 3503 { |
3522 if (mode == GetMode (i)) | 3504 if (mode == GetMode (i)) |
3523 { | 3505 { |
3524 return true; | 3506 return true; |
3525 } | 3507 } |
3526 } | 3508 } |
3527 return false; | 3509 return false; |
3528 } | 3510 } |
3529 | 3511 |
3530 bool | 3512 bool |
3531 WifiPhy::IsMcsSupported (WifiMode mcs) const | 3513 WifiPhy::IsMcsSupported (WifiMode mcs) const |
3532 { | 3514 { |
3533 for (uint8_t i = 0; i < GetNMcs (); i++) | 3515 for (uint8_t i = 0; i < GetNMcs (); i++) |
3534 { | 3516 { |
3535 if (mcs == GetMcs (static_cast<uint8_t>(i))) | 3517 if (mcs == GetMcs (i)) |
S. Deronne
2017/12/17 15:39:16
why is this cast needed?
ammo6818-vandals.uidaho.edu
2017/12/20 04:16:35
removed.
| |
3536 { | 3518 { |
3537 return true; | 3519 return true; |
3538 } | 3520 } |
3539 } | 3521 } |
3540 return false; | 3522 return false; |
3541 } | 3523 } |
3542 | 3524 |
3543 uint32_t | 3525 uint8_t |
3544 WifiPhy::GetNModes (void) const | 3526 WifiPhy::GetNModes (void) const |
3545 { | 3527 { |
3546 return m_deviceRateSet.size (); | 3528 return static_cast<uint8_t>(m_deviceRateSet.size ()); |
3547 } | 3529 } |
3548 | 3530 |
3549 WifiMode | 3531 WifiMode |
3550 WifiPhy::GetMode (uint32_t mode) const | 3532 WifiPhy::GetMode (uint8_t mode) const |
3551 { | 3533 { |
3552 return m_deviceRateSet[mode]; | 3534 return m_deviceRateSet[mode]; |
3553 } | 3535 } |
3554 | 3536 |
3555 uint8_t | 3537 uint8_t |
3556 WifiPhy::GetNMcs (void) const | 3538 WifiPhy::GetNMcs (void) const |
3557 { | 3539 { |
3558 return static_cast<uint8_t>(m_deviceMcsSet.size ()); | 3540 return static_cast<uint8_t>(m_deviceMcsSet.size ()); |
3559 } | 3541 } |
3560 | 3542 |
3561 WifiMode | 3543 WifiMode |
3562 WifiPhy::GetMcs (uint8_t mcs) const | 3544 WifiPhy::GetMcs (uint8_t mcs) const |
3563 { | 3545 { |
3564 return m_deviceMcsSet[mcs]; | 3546 return m_deviceMcsSet[mcs]; |
3565 } | 3547 } |
3566 | 3548 |
3567 bool | 3549 bool |
3568 WifiPhy::IsStateCcaBusy (void) | 3550 WifiPhy::IsStateCcaBusy (void) const |
3569 { | 3551 { |
3570 return m_state->IsStateCcaBusy (); | 3552 return m_state->IsStateCcaBusy (); |
3571 } | 3553 } |
3572 | 3554 |
3573 bool | 3555 bool |
3574 WifiPhy::IsStateIdle (void) | 3556 WifiPhy::IsStateIdle (void) const |
3575 { | 3557 { |
3576 return m_state->IsStateIdle (); | 3558 return m_state->IsStateIdle (); |
3577 } | 3559 } |
3578 | 3560 |
3579 bool | 3561 bool |
3580 WifiPhy::IsStateBusy (void) | 3562 WifiPhy::IsStateBusy (void) const |
3581 { | 3563 { |
3582 return m_state->IsStateBusy (); | 3564 return m_state->IsStateBusy (); |
3583 } | 3565 } |
3584 | 3566 |
3585 bool | 3567 bool |
3586 WifiPhy::IsStateRx (void) | 3568 WifiPhy::IsStateRx (void) const |
3587 { | 3569 { |
3588 return m_state->IsStateRx (); | 3570 return m_state->IsStateRx (); |
3589 } | 3571 } |
3590 | 3572 |
3591 bool | 3573 bool |
3592 WifiPhy::IsStateTx (void) | 3574 WifiPhy::IsStateTx (void) const |
3593 { | 3575 { |
3594 return m_state->IsStateTx (); | 3576 return m_state->IsStateTx (); |
3595 } | 3577 } |
3596 | 3578 |
3597 bool | 3579 bool |
3598 WifiPhy::IsStateSwitching (void) | 3580 WifiPhy::IsStateSwitching (void) const |
3599 { | 3581 { |
3600 return m_state->IsStateSwitching (); | 3582 return m_state->IsStateSwitching (); |
3601 } | 3583 } |
3602 | 3584 |
3603 bool | 3585 bool |
3604 WifiPhy::IsStateSleep (void) | 3586 WifiPhy::IsStateSleep (void) const |
3605 { | 3587 { |
3606 return m_state->IsStateSleep (); | 3588 return m_state->IsStateSleep (); |
3589 } | |
3590 | |
3591 bool | |
3592 WifiPhy::IsStateOff (void) const | |
3593 { | |
3594 return m_state->IsStateOff (); | |
3607 } | 3595 } |
3608 | 3596 |
3609 Time | 3597 Time |
3610 WifiPhy::GetStateDuration (void) | 3598 WifiPhy::GetStateDuration (void) |
3611 { | 3599 { |
3612 return m_state->GetStateDuration (); | 3600 return m_state->GetStateDuration (); |
3613 } | 3601 } |
3614 | 3602 |
3615 Time | 3603 Time |
3616 WifiPhy::GetDelayUntilIdle (void) | 3604 WifiPhy::GetDelayUntilIdle (void) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3655 } | 3643 } |
3656 NotifyRxDrop (m_currentEvent->GetPacket ()); | 3644 NotifyRxDrop (m_currentEvent->GetPacket ()); |
3657 m_interference.NotifyRxEnd (); | 3645 m_interference.NotifyRxEnd (); |
3658 m_state->SwitchFromRxAbort (); | 3646 m_state->SwitchFromRxAbort (); |
3659 m_currentEvent = 0; | 3647 m_currentEvent = 0; |
3660 } | 3648 } |
3661 | 3649 |
3662 void | 3650 void |
3663 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) |
3664 { | 3652 { |
3665 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); |
3666 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) |
3667 { | 3655 { |
3668 AmpduTag ampduTag; | 3656 AmpduTag ampduTag; |
3669 WifiPreamble preamble = txVector.GetPreambleType (); | 3657 WifiPreamble preamble = txVector.GetPreambleType (); |
3670 if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false)) | 3658 if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false)) |
3671 { | 3659 { |
3672 m_plcpSuccess = false; | 3660 m_plcpSuccess = false; |
3673 m_mpdusNum = 0; | 3661 m_mpdusNum = 0; |
3674 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"); |
3675 NotifyRxDrop (packet); | 3663 NotifyRxDrop (packet); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3866 ns3::WifiPhy::GetHeMcs6 (); | 3854 ns3::WifiPhy::GetHeMcs6 (); |
3867 ns3::WifiPhy::GetHeMcs7 (); | 3855 ns3::WifiPhy::GetHeMcs7 (); |
3868 ns3::WifiPhy::GetHeMcs8 (); | 3856 ns3::WifiPhy::GetHeMcs8 (); |
3869 ns3::WifiPhy::GetHeMcs9 (); | 3857 ns3::WifiPhy::GetHeMcs9 (); |
3870 ns3::WifiPhy::GetHeMcs10 (); | 3858 ns3::WifiPhy::GetHeMcs10 (); |
3871 ns3::WifiPhy::GetHeMcs11 (); | 3859 ns3::WifiPhy::GetHeMcs11 (); |
3872 } | 3860 } |
3873 } g_constructor; ///< the constructor | 3861 } g_constructor; ///< the constructor |
3874 | 3862 |
3875 } | 3863 } |
LEFT | RIGHT |