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>
71 static TypeId tid =
TypeId (
"ns3::SingleModelSpectrumChannel")
73 .AddConstructor<SingleModelSpectrumChannel> ()
74 .AddAttribute (
"MaxLossDb",
75 "If a single-frequency PropagationLossModel is used, this value "
76 "represents the maximum loss in dB for which transmissions will be "
77 "passed to the receiving PHY. Signals for which the PropagationLossModel "
78 "returns a loss bigger than this value will not be propagated to the receiver. "
79 "This parameter is to be used to reduce "
80 "the computational load by not propagating signals that are far beyond "
81 "the interference range. Note that the default value corresponds to "
82 "considering all signals for reception. Tune this value with care. ",
85 MakeDoubleChecker<double> ())
86 .AddTraceSource (
"PathLoss",
87 "This trace is fired "
88 "whenever a new path loss value is calculated. The first and second parameters "
89 "to the trace are pointers respectively to the TX and RX SpectrumPhy instances, "
90 "whereas the third parameters is the loss value in dB. Note that the loss value "
91 "reported by this trace is the single-frequency loss value obtained by evaluating "
92 "only the TX and RX AntennaModels and the PropagationLossModel. In particular, note that "
93 "SpectrumPropagationLossModel (even if present) is never used to evaluate the loss value "
94 "reported in this trace. ",
112 NS_LOG_FUNCTION (
this << txParams->psd << txParams->duration << txParams->txPhy);
133 for (PhyList::const_iterator rxPhyIterator =
m_phyList.begin ();
137 if ((*rxPhyIterator) != txParams->txPhy)
139 Time delay = MicroSeconds (0);
142 NS_LOG_LOGIC (
"copying signal parameters " << txParams);
145 if (senderMobility && receiverMobility)
147 double pathLossDb = 0;
148 if (rxParams->txAntenna != 0)
151 double txAntennaGain = rxParams->txAntenna->GetGainDb (txAngles);
152 NS_LOG_LOGIC (
"txAntennaGain = " << txAntennaGain <<
" dB");
153 pathLossDb -= txAntennaGain;
159 double rxAntennaGain = rxAntenna->GetGainDb (rxAngles);
160 NS_LOG_LOGIC (
"rxAntennaGain = " << rxAntennaGain <<
" dB");
161 pathLossDb -= rxAntennaGain;
166 NS_LOG_LOGIC (
"propagationGainDb = " << propagationGainDb <<
" dB");
167 pathLossDb -= propagationGainDb;
169 NS_LOG_LOGIC (
"total pathLoss = " << pathLossDb <<
" dB");
176 double pathGainLinear = std::pow (10.0, (-pathLossDb) / 10.0);
177 *(rxParams->psd) *= pathGainLinear;
195 uint32_t dstNode = netDev->GetNode ()->GetId ();
202 rxParams, *rxPhyIterator);
keep track of time values and allow control of global simulation resolution
#define NS_LOG_FUNCTION(parameters)
virtual void StartRx(Ptr< SpectrumSignalParameters > params)=0
Notify the SpectrumPhy instance of an incoming signal.
virtual Ptr< SpectrumPropagationLossModel > GetSpectrumPropagationLossModel(void)
Ptr< PropagationDelayModel > m_propagationDelay
propagation delay model to be used with this channel
virtual void AddRx(Ptr< SpectrumPhy > phy)
add a SpectrumPhy to a channel, so it can receive packets
virtual void AddSpectrumPropagationLossModel(Ptr< SpectrumPropagationLossModel > loss)
set the frequency-dependent propagation loss model to be used
#define NS_ASSERT(condition)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
Vector GetPosition(void) const
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
virtual void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
set the single-frequency propagation loss model to be used
virtual Ptr< NetDevice > GetDevice(uint32_t i) const
NS_LOG_COMPONENT_DEFINE("SingleModelSpectrumChannel")
Ptr< PropagationLossModel > m_propagationLoss
single-frequency propagation loss model to be used with this channel
TracedCallback< Ptr< SpectrumPhy >, Ptr< SpectrumPhy >, double > m_pathLossTrace
void StartRx(Ptr< SpectrumSignalParameters > params, Ptr< SpectrumPhy > receiver)
used internally to reschedule transmission after the propagation delay
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
double CalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
virtual uint32_t GetNDevices(void) const
static void ScheduleWithContext(uint32_t context, Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event with the given context.
#define NS_LOG_LOGIC(msg)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
static TypeId GetTypeId(void)
virtual void StartTx(Ptr< SpectrumSignalParameters > params)
Used by attached PHY instances to transmit signals on the channel.
Ptr< SpectrumPropagationLossModel > m_spectrumPropagationLoss
frequency-dependent propagation loss model to be used with this channel
#define NS_ASSERT_MSG(condition, message)
SingleModelSpectrumChannel()
Network layer to device interface.
virtual void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
set the propagation delay model to be used
Defines the interface for spectrum-aware channel implementations.
struct holding the azimuth and inclination angles of spherical coordinates.
Hold a floating point type.
PhyList m_phyList
list of SpectrumPhy instances attached to the channel
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Ptr< const SpectrumModel > m_spectrumModel
SpectrumModel that this channel instance is supporting.