28 #include "ns3/double.h"
31 #include "ns3/traced-callback.h"
32 #include "ns3/trace-source-accessor.h"
33 #include "ns3/simulator.h"
61 .AddConstructor<UanPhyCalcSinrDual> ()
78 NS_LOG_WARN (
"Calculating SINR for unsupported modulation type");
81 double intKp = -
DbToKp (rxPowerDb);
82 UanTransducer::ArrivalList::const_iterator it = arrivalList.begin ();
83 for (; it != arrivalList.end (); it++)
86 if (std::abs ( (
double) it->GetTxMode ().GetCenterFreqHz () - (double) mode.
GetCenterFreqHz ())
87 < (
double)(it->GetTxMode ().GetBandwidthHz () / 2 + mode.
GetBandwidthHz () / 2) - 0.5)
94 it->GetPacket ()->PeekHeader (ch2);
101 << mode.
GetName () <<
" Int mode: " << it->GetTxMode ().GetName () <<
" Separation: "
102 << std::abs ( (
double) it->GetTxMode ().GetCenterFreqHz () - (double) mode.
GetCenterFreqHz ())
103 <<
" Combined bandwidths: " << (
double)(it->GetTxMode ().GetBandwidthHz () / 2 + mode.
GetBandwidthHz () / 2) - 0.5);
106 intKp +=
DbToKp (it->GetRxPowerDb ());
110 double totalIntDb =
KpToDb (intKp +
DbToKp (ambNoiseDb));
112 NS_LOG_DEBUG (
Simulator::Now ().GetSeconds () <<
" Calculating SINR: RxPower = " << rxPowerDb <<
" dB. Number of interferers = " << arrivalList.size () <<
" Interference + noise power = " << totalIntDb <<
" dB. SINR = " << rxPowerDb - totalIntDb <<
" dB.");
113 return rxPowerDb - totalIntDb;
120 m_phy1 = CreateObject<UanPhyGen> ();
121 m_phy2 = CreateObject<UanPhyGen> ();
124 m_phy2->SetReceiveOkCallback (
m_recOkCb);
161 .AddConstructor<UanPhyDual> ()
162 .AddAttribute (
"CcaThresholdPhy1",
163 "Aggregate energy of incoming signals to move to CCA Busy state dB of Phy1",
166 MakeDoubleChecker<double> ())
167 .AddAttribute (
"CcaThresholdPhy2",
168 "Aggregate energy of incoming signals to move to CCA Busy state dB of Phy2",
171 MakeDoubleChecker<double> ())
172 .AddAttribute (
"TxPowerPhy1",
173 "Transmission output power in dB of Phy1",
176 MakeDoubleChecker<double> ())
177 .AddAttribute (
"TxPowerPhy2",
178 "Transmission output power in dB of Phy2",
181 MakeDoubleChecker<double> ())
182 .AddAttribute (
"RxGainPhy1",
183 "Gain added to incoming signal at receiver of Phy1",
186 MakeDoubleChecker<double> ())
187 .AddAttribute (
"RxGainPhy2",
188 "Gain added to incoming signal at receiver of Phy2",
191 MakeDoubleChecker<double> ())
192 .AddAttribute (
"SupportedModesPhy1",
193 "List of modes supported by Phy1",
196 MakeUanModesListChecker () )
197 .AddAttribute (
"SupportedModesPhy2",
198 "List of modes supported by Phy2",
201 MakeUanModesListChecker () )
202 .AddAttribute (
"PerModelPhy1",
203 "Functor to calculate PER based on SINR and TxMode for Phy1",
206 MakePointerChecker<UanPhyPer> ())
207 .AddAttribute (
"PerModelPhy2",
208 "Functor to calculate PER based on SINR and TxMode for Phy2",
211 MakePointerChecker<UanPhyPer> ())
212 .AddAttribute (
"SinrModelPhy1",
213 "Functor to calculate SINR based on pkt arrivals and modes for Phy1",
216 MakePointerChecker<UanPhyCalcSinr> ())
217 .AddAttribute (
"SinrModelPhy2",
218 "Functor to calculate SINR based on pkt arrivals and modes for Phy2",
221 MakePointerChecker<UanPhyCalcSinr> ())
222 .AddTraceSource (
"RxOk",
223 "A packet was received successfully",
225 .AddTraceSource (
"RxError",
226 "A packet was received unsuccessfully",
228 .AddTraceSource (
"Tx",
229 "Packet transmission beginning",
332 NS_LOG_WARN (
"SetRxThresholdDb is deprecated and has no effect. Look at PER Functor attribute");
357 NS_LOG_WARN (
"Warning: UanPhyDual::GetRxGainDb returns RxGain of Phy 1");
374 NS_LOG_WARN (
"Warning: Dual Phy only returns TxPowerDb of Phy 1");
399 NS_LOG_WARN (
"Dual Phy only returns CCAThreshold of Phy 1");
538 NS_LOG_WARN (
"DualPhy Returning transducer of Phy1");
563 UanModesListValue modeValue;
565 return modeValue.Get ();
571 UanModesListValue modeValue;
573 return modeValue.Get ();
662 NS_FATAL_ERROR (
"GetPacketRx not valid for UanPhyDual. Must specify GetPhy1PacketRx or GetPhy2PacketRx");
663 return Create<Packet> ();