22 #include <ns3/abort.h>
23 #include <ns3/double.h>
25 #include <ns3/pointer.h>
56 TypeId(
"ns3::SpectrumChannel")
58 .SetGroupName(
"Spectrum")
59 .AddAttribute(
"MaxLossDb",
60 "If a single-frequency PropagationLossModel is used, "
61 "this value represents the maximum loss in dB for which "
62 "transmissions will be passed to the receiving PHY. "
63 "Signals for which the PropagationLossModel returns "
64 "a loss bigger than this value will not be propagated "
65 "to the receiver. This parameter is to be used to reduce "
66 "the computational load by not propagating signals "
67 "that are far beyond the interference range. Note that "
68 "the default value corresponds to considering all signals "
69 "for reception. Tune this value with care.",
72 MakeDoubleChecker<double>())
74 .AddAttribute(
"PropagationLossModel",
75 "A pointer to the propagation loss model attached to this channel.",
78 MakePointerChecker<PropagationLossModel>())
80 .AddTraceSource(
"Gain",
81 "This trace is fired whenever a new path loss value "
82 "is calculated. The parameters to this trace are : "
83 "Pointer to the mobility model of the transmitter, "
84 "Pointer to the mobility model of the receiver, "
90 "ns3::SpectrumChannel::GainTracedCallback")
92 .AddTraceSource(
"PathLoss",
93 "This trace is fired whenever a new path loss value "
94 "is calculated. The first and second parameters "
95 "to the trace are pointers respectively to the TX and "
96 "RX SpectrumPhy instances, whereas the third parameters "
97 "is the loss value in dB. Note that the loss value "
98 "reported by this trace is the single-frequency loss "
99 "value obtained by evaluating only the TX and RX "
100 "AntennaModels and the PropagationLossModel. "
101 "In particular, note that SpectrumPropagationLossModel "
102 "(even if present) is never used to evaluate the "
103 "loss value reported in this trace.",
105 "ns3::SpectrumChannel::LossTracedCallback")
107 .AddTraceSource(
"TxSigParams",
108 "This trace is fired whenever a signal is transmitted. "
109 "The sole parameter is a pointer to a copy of the "
110 "SpectrumSignalParameters provided by the transmitter.",
112 "ns3::SpectrumChannel::SignalParametersTracedCallback");
203 auto currentStream = stream;
204 auto lastCurrentStream = stream;
209 if (currentStream - lastCurrentStream)
211 NS_LOG_DEBUG(
"PropagationLossModel objects used " << currentStream - lastCurrentStream
214 lastCurrentStream = currentStream;
220 if (currentStream - lastCurrentStream)
222 NS_LOG_DEBUG(
"PropagationDelayModel object used " << currentStream - lastCurrentStream
225 lastCurrentStream = currentStream;
230 if (currentStream - lastCurrentStream)
232 NS_LOG_DEBUG(
"SpectrumPropagationLossModel objects used "
233 << currentStream - lastCurrentStream <<
" streams");
235 lastCurrentStream = currentStream;
240 if (currentStream - lastCurrentStream)
242 NS_LOG_DEBUG(
"PhasedArraySpectrumPropagationLossModel objects used "
243 << currentStream - lastCurrentStream <<
" streams");
245 lastCurrentStream = currentStream;
248 currentStream +=
m_filter->AssignStreams(currentStream);
250 if (currentStream - lastCurrentStream)
252 NS_LOG_DEBUG(
"SpectrumTransmitFilter objects used " << currentStream - lastCurrentStream
256 NS_LOG_DEBUG(
"Assigned a total of " << currentStream - stream <<
" streams");
257 return (currentStream - stream);
Abstract Channel Base Class.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold objects of type Ptr<T>.
int64_t AssignStreams(int64_t stream)
If this loss model uses objects of type RandomVariableStream, set the stream numbers to the integers ...
void SetNext(Ptr< PropagationLossModel > next)
Enables a chain of loss models to act on the signal.
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
TracedCallback< Ptr< SpectrumSignalParameters > > m_txSigParamsTrace
Traced callback for SpectrumSignalParameters in StartTx requests.
void DoDispose() override
Destructor implementation.
Ptr< SpectrumTransmitFilter > m_filter
Transmit filter to be used with this channel.
void AddSpectrumPropagationLossModel(Ptr< SpectrumPropagationLossModel > loss)
Add the frequency-dependent propagation loss model to be used.
SpectrumChannel()
constructor
Ptr< PropagationDelayModel > m_propagationDelay
Propagation delay model to be used with this channel.
void AddSpectrumTransmitFilter(Ptr< SpectrumTransmitFilter > filter)
Add the transmit filter to be used to filter possible signal receptions at the StartTx() time.
Ptr< SpectrumPropagationLossModel > m_spectrumPropagationLoss
Frequency-dependent propagation loss model to be used with this channel.
Ptr< PhasedArraySpectrumPropagationLossModel > m_phasedArraySpectrumPropagationLoss
Frequency-dependent propagation loss model to be used with this channel.
TracedCallback< Ptr< const SpectrumPhy >, Ptr< const SpectrumPhy >, double > m_pathLossTrace
The PathLoss trace source.
Ptr< SpectrumTransmitFilter > GetSpectrumTransmitFilter() const
Get the transmit filter, or first in a chain of transmit filters if more than one is present.
TracedCallback< Ptr< const MobilityModel >, Ptr< const MobilityModel >, double, double, double, double > m_gainTrace
The Gain trace source.
int64_t AssignStreams(int64_t stream)
This method calls AssignStreams() on any/all of the PropagationLossModel, PropagationDelayModel,...
Ptr< PropagationLossModel > m_propagationLoss
Single-frequency propagation loss model to be used with this channel.
static TypeId GetTypeId()
Get the type ID.
Ptr< SpectrumPropagationLossModel > GetSpectrumPropagationLossModel() const
Get the frequency-dependent propagation loss model.
virtual int64_t DoAssignStreams(int64_t stream)
This provides a base class implementation that may be subclassed if needed by subclasses that might n...
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
Ptr< PropagationLossModel > GetPropagationLossModel() const
Get the propagation loss model.
Ptr< PhasedArraySpectrumPropagationLossModel > GetPhasedArraySpectrumPropagationLossModel() const
Get the frequency-dependent propagation loss model that is compatible with the phased antenna arrays ...
Ptr< PropagationDelayModel > GetPropagationDelayModel() const
Get the propagation delay model that has been set on the channel.
double m_maxLossDb
Maximum loss [dB].
void AddPhasedArraySpectrumPropagationLossModel(Ptr< PhasedArraySpectrumPropagationLossModel > loss)
Add the frequency-dependent propagation loss model that is compapatible with the phased antenna array...
~SpectrumChannel() override
destructor
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)