28 #include "ns3/simulator.h"
29 #include "ns3/packet.h"
30 #include "ns3/assert.h"
32 #include "ns3/double.h"
33 #include "ns3/uinteger.h"
35 #include "ns3/pointer.h"
36 #include "ns3/net-device.h"
37 #include "ns3/trace-source-accessor.h"
38 #include "ns3/boolean.h"
52 .AddConstructor<YansWifiPhy> ()
53 .AddAttribute (
"EnergyDetectionThreshold",
54 "The energy of a received signal should be higher than "
55 "this threshold (dbm) to allow the PHY layer to detect the signal.",
59 MakeDoubleChecker<double> ())
60 .AddAttribute (
"CcaMode1Threshold",
61 "The energy of a received signal should be higher than "
62 "this threshold (dbm) to allow the PHY layer to declare CCA BUSY state",
66 MakeDoubleChecker<double> ())
67 .AddAttribute (
"TxGain",
68 "Transmission gain (dB).",
72 MakeDoubleChecker<double> ())
73 .AddAttribute (
"RxGain",
74 "Reception gain (dB).",
78 MakeDoubleChecker<double> ())
79 .AddAttribute (
"TxPowerLevels",
80 "Number of transmission power levels available between "
81 "TxPowerStart and TxPowerEnd included.",
84 MakeUintegerChecker<uint32_t> ())
85 .AddAttribute (
"TxPowerEnd",
86 "Maximum available transmission level (dbm).",
90 MakeDoubleChecker<double> ())
91 .AddAttribute (
"TxPowerStart",
92 "Minimum available transmission level (dbm).",
96 MakeDoubleChecker<double> ())
97 .AddAttribute (
"RxNoiseFigure",
98 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
99 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
100 "\"the difference in decibels (dB) between"
101 " the noise output of the actual receiver to the noise output of an "
102 " ideal receiver with the same overall gain and bandwidth when the receivers "
103 " are connected to sources at the standard noise temperature T0 (usually 290 K)\"."
108 MakeDoubleChecker<double> ())
109 .AddAttribute (
"State",
"The state of the PHY layer",
112 MakePointerChecker<WifiPhyStateHelper> ())
113 .AddAttribute (
"ChannelSwitchDelay",
114 "Delay between two short frames transmitted on different frequencies.",
118 .AddAttribute (
"ChannelNumber",
119 "Channel center frequency = Channel starting frequency + 5 MHz * nch",
123 MakeUintegerChecker<uint16_t> ())
124 .AddAttribute (
"Frequency",
"The operating frequency.",
128 MakeUintegerChecker<uint32_t> ())
129 .AddAttribute (
"Transmitters",
"The number of transmitters.",
133 MakeUintegerChecker<uint32_t> ())
134 .AddAttribute (
"Recievers",
"The number of recievers.",
138 MakeUintegerChecker<uint32_t> ())
139 .AddAttribute (
"ShortGuardEnabled",
"Whether or not short guard interval is enabled.",
143 MakeBooleanChecker ())
144 .AddAttribute (
"LdpcEnabled",
"Whether or not LDPC is enabled.",
148 MakeBooleanChecker ())
149 .AddAttribute (
"STBCEnabled",
"Whether or not STBC is enabled.",
153 MakeBooleanChecker ())
154 .AddAttribute (
"GreenfieldEnabled",
"Whether or not STBC is enabled.",
158 MakeBooleanChecker ())
159 .AddAttribute (
"ChannelBonding",
"Whether 20MHz or 40MHz.",
163 MakeBooleanChecker ())
171 : m_channelNumber (1),
173 m_channelStartingFrequency (0)
176 m_random = CreateObject<UniformRandomVariable> ();
177 m_state = CreateObject<WifiPhyStateHelper> ();
394 NS_LOG_DEBUG (
"drop packet because of channel switching while reception");
399 NS_LOG_DEBUG (
"channel switching postponed until end of current transmission");
458 double rxPowerW =
DbmToW (rxPowerDbm);
474 NS_LOG_DEBUG (
"drop packet because of channel switching");
492 NS_LOG_DEBUG (
"drop packet because already in Rx (power=" <<
503 NS_LOG_DEBUG (
"drop packet because already in Tx (power=" <<
517 NS_LOG_DEBUG (
"sync to signal (power=" << rxPowerW <<
"W)");
529 NS_LOG_DEBUG (
"drop packet because signal power too Small (" <<
546 if (!delayUntilCcaEnd.
IsZero ())
777 double ratio = std::pow (10.0, dB / 10.0);
784 double mW = std::pow (10.0, dBm / 10.0);
791 return 10.0 * std::log10 (w * 1000.0);
797 return 10.0 * std::log10 (ratio);
835 NS_LOG_DEBUG (
"mode=" << (event->GetPayloadMode ().GetDataRate ()) <<
836 ", snr=" << snrPer.snr <<
", per=" << snrPer.per <<
", size=" << packet->
GetSize ());
840 uint32_t dataRate500KbpsUnits =
event->GetPayloadMode ().GetDataRate () *
event->GetTxVector().GetNss()/ 500000;
842 double signalDbm =
RatioToDb (event->GetRxPowerW ()) + 30;
966 for (uint8_t i=0; i <8; i++)
999 return supportedmodes;