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 .SetGroupName (
"Spectrum")
72 .AddAttribute (
"MaxLossDb",
73 "If a single-frequency PropagationLossModel is used, "
74 "this value represents the maximum loss in dB for which "
75 "transmissions will be passed to the receiving PHY. "
76 "Signals for which the PropagationLossModel returns "
77 "a loss bigger than this value will not be propagated "
78 "to the receiver. This parameter is to be used to reduce "
79 "the computational load by not propagating signals "
80 "that are far beyond the interference range. Note that "
81 "the default value corresponds to considering all signals "
82 "for reception. Tune this value with care. ",
85 MakeDoubleChecker<double> ())
86 .AddTraceSource (
"PathLoss",
87 "This trace is fired whenever a new path loss value "
88 "is calculated. The first and second parameters "
89 "to the trace are pointers respectively to the TX and "
90 "RX SpectrumPhy instances, whereas the third parameters "
91 "is the loss value in dB. Note that the loss value "
92 "reported by this trace is the single-frequency loss "
93 "value obtained by evaluating only the TX and RX "
94 "AntennaModels and the PropagationLossModel. "
95 "In particular, note that SpectrumPropagationLossModel "
96 "(even if present) is never used to evaluate the "
97 "loss value reported in this trace. ",
99 "ns3::SpectrumChannel::LossTracedCallback")
116 NS_LOG_FUNCTION (
this << txParams->psd << txParams->duration << txParams->txPhy);
137 for (PhyList::const_iterator rxPhyIterator =
m_phyList.begin ();
141 if ((*rxPhyIterator) != txParams->txPhy)
146 NS_LOG_LOGIC (
"copying signal parameters " << txParams);
149 if (senderMobility && receiverMobility)
151 double pathLossDb = 0;
152 if (rxParams->txAntenna != 0)
155 double txAntennaGain = rxParams->txAntenna->GetGainDb (txAngles);
156 NS_LOG_LOGIC (
"txAntennaGain = " << txAntennaGain <<
" dB");
157 pathLossDb -= txAntennaGain;
163 double rxAntennaGain = rxAntenna->GetGainDb (rxAngles);
164 NS_LOG_LOGIC (
"rxAntennaGain = " << rxAntennaGain <<
" dB");
165 pathLossDb -= rxAntennaGain;
170 NS_LOG_LOGIC (
"propagationGainDb = " << propagationGainDb <<
" dB");
171 pathLossDb -= propagationGainDb;
173 NS_LOG_LOGIC (
"total pathLoss = " << pathLossDb <<
" dB");
180 double pathGainLinear = std::pow (10.0, (-pathLossDb) / 10.0);
181 *(rxParams->psd) *= pathGainLinear;
199 uint32_t dstNode = netDev->GetNode ()->GetId ();
206 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.
void SetNext(Ptr< PropagationLossModel > next)
Enables a chain of loss models to act on the signal.
virtual Ptr< SpectrumPropagationLossModel > GetSpectrumPropagationLossModel(void)
Get the frequency-dependent propagation loss model.
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)
Add 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.
virtual void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add 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
NS_ASSERT_MSG(false,"Ipv4AddressGenerator::MaskToIndex(): Impossible")
void StartRx(Ptr< SpectrumSignalParameters > params, Ptr< SpectrumPhy > receiver)
Used internally to reschedule transmission after the propagation delay.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after 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 PropagationLossModel(s) chained to the current one...
virtual uint32_t GetNDevices(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TypeId GetTypeId(void)
Get the type ID.
double m_maxLossDb
Maximum loss [dB].
virtual void StartTx(Ptr< SpectrumSignalParameters > params)
Used by attached PHY instances to transmit signals on the channel.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
Ptr< SpectrumPropagationLossModel > m_spectrumPropagationLoss
Frequency-dependent propagation loss model to be used with this channel.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static void ScheduleWithContext(uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event with the given context.
SingleModelSpectrumChannel()
Network layer to device interface.
SpectrumChannel implementation which handles a single spectrum model.
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)
Set the parent TypeId.
Ptr< const SpectrumModel > m_spectrumModel
SpectrumModel that this channel instance is supporting.