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>
68 static TypeId tid =
TypeId (
"ns3::SingleModelSpectrumChannel")
70 .AddConstructor<SingleModelSpectrumChannel> ()
71 .AddAttribute (
"MaxLossDb",
72 "If a single-frequency PropagationLossModel is used, "
73 "this value represents the maximum loss in dB for which "
74 "transmissions will be passed to the receiving PHY. "
75 "Signals for which the PropagationLossModel returns "
76 "a loss bigger than this value will not be propagated "
77 "to the receiver. This parameter is to be used to reduce "
78 "the computational load by not propagating signals "
79 "that are far beyond the interference range. Note that "
80 "the default value corresponds to considering all signals "
81 "for reception. Tune this value with care. ",
84 MakeDoubleChecker<double> ())
85 .AddTraceSource (
"PathLoss",
86 "This trace is fired whenever a new path loss value "
87 "is calculated. The first and second parameters "
88 "to the trace are pointers respectively to the TX and "
89 "RX SpectrumPhy instances, whereas the third parameters "
90 "is the loss value in dB. Note that the loss value "
91 "reported by this trace is the single-frequency loss "
92 "value obtained by evaluating only the TX and RX "
93 "AntennaModels and the PropagationLossModel. "
94 "In particular, note that SpectrumPropagationLossModel "
95 "(even if present) is never used to evaluate the "
96 "loss value reported in this trace. ",
98 "ns3::SpectrumChannel::LossTracedCallback")
115 NS_LOG_FUNCTION (
this << txParams->psd << txParams->duration << txParams->txPhy);
136 for (PhyList::const_iterator rxPhyIterator =
m_phyList.begin ();
140 if ((*rxPhyIterator) != txParams->txPhy)
145 NS_LOG_LOGIC (
"copying signal parameters " << txParams);
148 if (senderMobility && receiverMobility)
150 double pathLossDb = 0;
151 if (rxParams->txAntenna != 0)
154 double txAntennaGain = rxParams->txAntenna->GetGainDb (txAngles);
155 NS_LOG_LOGIC (
"txAntennaGain = " << txAntennaGain <<
" dB");
156 pathLossDb -= txAntennaGain;
162 double rxAntennaGain = rxAntenna->GetGainDb (rxAngles);
163 NS_LOG_LOGIC (
"rxAntennaGain = " << rxAntennaGain <<
" dB");
164 pathLossDb -= rxAntennaGain;
169 NS_LOG_LOGIC (
"propagationGainDb = " << propagationGainDb <<
" dB");
170 pathLossDb -= propagationGainDb;
172 NS_LOG_LOGIC (
"total pathLoss = " << pathLossDb <<
" dB");
179 double pathGainLinear = std::pow (10.0, (-pathLossDb) / 10.0);
180 *(rxParams->psd) *= pathGainLinear;
198 uint32_t dstNode = netDev->GetNode ()->GetId ();
205 rxParams, *rxPhyIterator);
Simulation virtual time values and global simulation resolution.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void StartRx(Ptr< SpectrumSignalParameters > params)=0
Notify the SpectrumPhy instance of an incoming signal.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
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)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Vector GetPosition(void) const
virtual void DoDispose(void)
Destructor implementation.
#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
Ptr< PropagationLossModel > m_propagationLoss
single-frequency propagation loss model to be used with this channel
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
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()
Destructor implementation.
double CalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account all the PropagatinLossModel(s) chained to the current one...
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)
Use NS_LOG to output a message of level LOG_LOGIC.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
struct holding the azimuth and inclination angles of spherical coordinates.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
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.