A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
spectrum-channel.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 CTTC
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Nicola Baldo <nbaldo@cttc.es>
18 */
19
20#include "spectrum-channel.h"
21
22#include <ns3/double.h>
23#include <ns3/log.h>
24#include <ns3/pointer.h>
25
26namespace ns3
27{
28
29NS_LOG_COMPONENT_DEFINE("SpectrumChannel");
30
31NS_OBJECT_ENSURE_REGISTERED(SpectrumChannel);
32
34{
35 NS_LOG_FUNCTION(this);
36}
37
39{
40}
41
42void
44{
45 NS_LOG_FUNCTION(this);
46 m_propagationLoss = nullptr;
47 m_propagationDelay = nullptr;
49}
50
53{
54 static TypeId tid =
55 TypeId("ns3::SpectrumChannel")
57 .SetGroupName("Spectrum")
58 .AddAttribute("MaxLossDb",
59 "If a single-frequency PropagationLossModel is used, "
60 "this value represents the maximum loss in dB for which "
61 "transmissions will be passed to the receiving PHY. "
62 "Signals for which the PropagationLossModel returns "
63 "a loss bigger than this value will not be propagated "
64 "to the receiver. This parameter is to be used to reduce "
65 "the computational load by not propagating signals "
66 "that are far beyond the interference range. Note that "
67 "the default value corresponds to considering all signals "
68 "for reception. Tune this value with care.",
69 DoubleValue(1.0e9),
71 MakeDoubleChecker<double>())
72
73 .AddAttribute("PropagationLossModel",
74 "A pointer to the propagation loss model attached to this channel.",
75 PointerValue(nullptr),
77 MakePointerChecker<PropagationLossModel>())
78
79 .AddTraceSource("Gain",
80 "This trace is fired whenever a new path loss value "
81 "is calculated. The parameters to this trace are : "
82 "Pointer to the mobility model of the transmitter, "
83 "Pointer to the mobility model of the receiver, "
84 "Tx antenna gain, "
85 "Rx antenna gain, "
86 "Propagation gain, "
87 "Pathloss",
89 "ns3::SpectrumChannel::GainTracedCallback")
90
91 .AddTraceSource("PathLoss",
92 "This trace is fired whenever a new path loss value "
93 "is calculated. The first and second parameters "
94 "to the trace are pointers respectively to the TX and "
95 "RX SpectrumPhy instances, whereas the third parameters "
96 "is the loss value in dB. Note that the loss value "
97 "reported by this trace is the single-frequency loss "
98 "value obtained by evaluating only the TX and RX "
99 "AntennaModels and the PropagationLossModel. "
100 "In particular, note that SpectrumPropagationLossModel "
101 "(even if present) is never used to evaluate the "
102 "loss value reported in this trace.",
104 "ns3::SpectrumChannel::LossTracedCallback")
105
106 .AddTraceSource("TxSigParams",
107 "This trace is fired whenever a signal is transmitted. "
108 "The sole parameter is a pointer to a copy of the "
109 "SpectrumSignalParameters provided by the transmitter.",
111 "ns3::SpectrumChannel::SignalParametersTracedCallback");
112 return tid;
113}
114
115void
117{
118 NS_LOG_FUNCTION(this << loss);
120 {
121 loss->SetNext(m_propagationLoss);
122 }
123 m_propagationLoss = loss;
124}
125
126void
128{
129 NS_LOG_FUNCTION(this << loss);
131 {
132 loss->SetNext(m_spectrumPropagationLoss);
133 }
135}
136
137void
140{
141 NS_LOG_FUNCTION(this << loss);
143 {
145 }
147}
148
149void
151{
152 NS_LOG_FUNCTION(this << filter);
153
154 if (m_filter)
155 {
156 filter->SetNext(m_filter);
157 }
158 m_filter = filter;
159}
160
163{
164 return m_filter;
165}
166
167void
169{
171 m_propagationDelay = delay;
172}
173
176{
177 NS_LOG_FUNCTION(this);
179}
180
183{
184 NS_LOG_FUNCTION(this);
186}
187
190{
191 return m_propagationLoss;
192}
193
194} // namespace ns3
Abstract Channel Base Class.
Definition: channel.h:45
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
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< PhasedArraySpectrumPropagationLossModel > GetPhasedArraySpectrumPropagationLossModel()
Get the frequency-dependent propagation loss model that is compatible with the phased antenna arrays ...
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.
Ptr< const SpectrumTransmitFilter > GetSpectrumTransmitFilter() const
Get the transmit filter, or first in a chain of transmit filters if more than one is present.
TracedCallback< Ptr< const SpectrumPhy >, Ptr< const SpectrumPhy >, double > m_pathLossTrace
The PathLoss trace source.
Ptr< SpectrumPropagationLossModel > GetSpectrumPropagationLossModel()
Get the frequency-dependent propagation loss model.
TracedCallback< Ptr< const MobilityModel >, Ptr< const MobilityModel >, double, double, double, double > m_gainTrace
The Gain trace source.
Ptr< PropagationLossModel > m_propagationLoss
Single-frequency propagation loss model to be used with this channel.
Ptr< PropagationLossModel > GetPropagationLossModel()
Get the propagation loss model.
static TypeId GetTypeId()
Get the type ID.
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
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.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:936
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:227
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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.
Definition: object-base.h:46
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.