21 #include <ns3/object.h>
22 #include <ns3/simulator.h>
24 #include <ns3/packet.h>
25 #include <ns3/packet-burst.h>
26 #include <ns3/net-device.h>
28 #include <ns3/double.h>
29 #include <ns3/mobility-model.h>
30 #include <ns3/spectrum-phy.h>
31 #include <ns3/spectrum-propagation-loss-model.h>
32 #include <ns3/propagation-loss-model.h>
33 #include <ns3/propagation-delay-model.h>
34 #include <ns3/antenna-model.h>
35 #include <ns3/angles.h>
70 static TypeId tid =
TypeId (
"ns3::SingleModelSpectrumChannel")
72 .AddConstructor<SingleModelSpectrumChannel> ()
73 .AddAttribute (
"MaxLossDb",
74 "If a single-frequency PropagationLossModel is used, this value "
75 "represents the maximum loss in dB for which transmissions will be "
76 "passed to the receiving PHY. Signals for which the PropagationLossModel "
77 "returns a loss bigger than this value will not be propagated to the receiver. "
78 "This parameter is to be used to reduce "
79 "the computational load by not propagating signals that are far beyond "
80 "the interference range. Note that the default value corresponds to "
81 "considering all signals for reception. Tune this value with care. ",
84 MakeDoubleChecker<double> ())
85 .AddTraceSource (
"PathLoss",
86 "This trace is fired "
87 "whenever a new path loss value is calculated. The first and second parameters "
88 "to the trace are pointers respectively to the TX and RX SpectrumPhy instances, "
89 "whereas the third parameters is the loss value in dB. Note that the loss value "
90 "reported by this trace is the single-frequency loss value obtained by evaluating "
91 "only the TX and RX AntennaModels and the PropagationLossModel. In particular, note that "
92 "SpectrumPropagationLossModel (even if present) is never used to evaluate the loss value "
93 "reported in this trace. ",
111 NS_LOG_FUNCTION (
this << txParams->psd << txParams->duration << txParams->txPhy);
132 for (PhyList::const_iterator rxPhyIterator =
m_phyList.begin ();
136 if ((*rxPhyIterator) != txParams->txPhy)
141 NS_LOG_LOGIC (
"copying signal parameters " << txParams);
144 if (senderMobility && receiverMobility)
146 double pathLossDb = 0;
147 if (rxParams->txAntenna != 0)
150 double txAntennaGain = rxParams->txAntenna->GetGainDb (txAngles);
151 NS_LOG_LOGIC (
"txAntennaGain = " << txAntennaGain <<
" dB");
152 pathLossDb -= txAntennaGain;
158 double rxAntennaGain = rxAntenna->
GetGainDb (rxAngles);
159 NS_LOG_LOGIC (
"rxAntennaGain = " << rxAntennaGain <<
" dB");
160 pathLossDb -= rxAntennaGain;
165 NS_LOG_LOGIC (
"propagationGainDb = " << propagationGainDb <<
" dB");
166 pathLossDb -= propagationGainDb;
168 NS_LOG_LOGIC (
"total pathLoss = " << pathLossDb <<
" dB");
175 double pathGainLinear = pow (10.0, (-pathLossDb) / 10.0);
176 *(rxParams->psd) *= pathGainLinear;
201 rxParams, *rxPhyIterator);