A Discrete-Event Network Simulator
API
spectrum-channel.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 CTTC
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Nicola Baldo <nbaldo@cttc.es>
19  */
20 
21 #include <ns3/log.h>
22 #include <ns3/double.h>
23 #include <ns3/pointer.h>
24 
25 #include "spectrum-channel.h"
26 
27 
28 namespace ns3 {
29 
30 NS_LOG_COMPONENT_DEFINE ("SpectrumChannel");
31 
32 NS_OBJECT_ENSURE_REGISTERED (SpectrumChannel);
33 
35 {
36  NS_LOG_FUNCTION (this);
37 }
38 
40 {
41 }
42 
43 void
45 {
46  NS_LOG_FUNCTION (this);
50 }
51 
52 TypeId
54 {
55  static TypeId tid = TypeId ("ns3::SpectrumChannel")
56  .SetParent<Channel> ()
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 (0),
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  ;
113  return tid;
114 }
115 
116 void
118 {
119  NS_LOG_FUNCTION (this << loss);
120  if (m_propagationLoss)
121  {
122  loss->SetNext (m_propagationLoss);
123  }
124  m_propagationLoss = loss;
125 }
126 
127 void
129 {
130  NS_LOG_FUNCTION (this << loss);
132  {
133  loss->SetNext (m_spectrumPropagationLoss);
134  }
136 }
137 
138 void
140 {
141  NS_LOG_FUNCTION (this << loss);
143  {
144  loss->SetNext (m_phasedArraySpectrumPropagationLoss);
145  }
147 }
148 
149 
150 void
152 {
154  m_propagationDelay = delay;
155 }
156 
159 {
160  NS_LOG_FUNCTION (this);
162 }
163 
166 {
167  NS_LOG_FUNCTION (this);
169 }
170 
173 {
174  return m_propagationLoss;
175 }
176 
177 
178 } // namespace
ns3::SpectrumChannel::SetPropagationDelayModel
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
Definition: spectrum-channel.cc:151
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
ns3::SpectrumChannel::AddPropagationLossModel
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
Definition: spectrum-channel.cc:117
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
spectrum-channel.h
ns3::SpectrumChannel::m_gainTrace
TracedCallback< Ptr< const MobilityModel >, Ptr< const MobilityModel >, double, double, double, double > m_gainTrace
The Gain trace source.
Definition: spectrum-channel.h:187
ns3::SpectrumChannel::AddPhasedArraySpectrumPropagationLossModel
void AddPhasedArraySpectrumPropagationLossModel(Ptr< PhasedArraySpectrumPropagationLossModel > loss)
Add the frequency-dependent propagation loss model that is compapatible with the phased antenna array...
Definition: spectrum-channel.cc:139
ns3::PointerValue
Hold objects of type Ptr<T>.
Definition: pointer.h:37
ns3::SpectrumChannel::GetPhasedArraySpectrumPropagationLossModel
Ptr< PhasedArraySpectrumPropagationLossModel > GetPhasedArraySpectrumPropagationLossModel(void)
Get the frequency-dependent propagation loss model that is compatible with the phased antenna arrays ...
Definition: spectrum-channel.cc:165
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
ns3::MakeTraceSourceAccessor
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Definition: trace-source-accessor.h:202
ns3::SpectrumChannel::~SpectrumChannel
virtual ~SpectrumChannel()
destructor
Definition: spectrum-channel.cc:39
ns3::Ptr< PropagationLossModel >
ns3::SpectrumChannel::m_maxLossDb
double m_maxLossDb
Maximum loss [dB].
Definition: spectrum-channel.h:199
ns3::SpectrumChannel::SpectrumChannel
SpectrumChannel()
constructor
Definition: spectrum-channel.cc:34
ns3::SpectrumChannel::m_spectrumPropagationLoss
Ptr< SpectrumPropagationLossModel > m_spectrumPropagationLoss
Frequency-dependent propagation loss model to be used with this channel.
Definition: spectrum-channel.h:214
ns3::PropagationLossModel::SetNext
void SetNext(Ptr< PropagationLossModel > next)
Enables a chain of loss models to act on the signal.
Definition: propagation-loss-model.cc:61
ns3::SpectrumChannel::GetSpectrumPropagationLossModel
Ptr< SpectrumPropagationLossModel > GetSpectrumPropagationLossModel(void)
Get the frequency-dependent propagation loss model.
Definition: spectrum-channel.cc:158
ns3::SpectrumChannel::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: spectrum-channel.cc:44
ns3::SpectrumChannel::m_phasedArraySpectrumPropagationLoss
Ptr< PhasedArraySpectrumPropagationLossModel > m_phasedArraySpectrumPropagationLoss
Frequency-dependent propagation loss model to be used with this channel.
Definition: spectrum-channel.h:219
ns3::SpectrumChannel::m_propagationDelay
Ptr< PropagationDelayModel > m_propagationDelay
Propagation delay model to be used with this channel.
Definition: spectrum-channel.h:209
ns3::SpectrumChannel::GetPropagationLossModel
Ptr< PropagationLossModel > GetPropagationLossModel(void)
Get the propagation loss model.
Definition: spectrum-channel.cc:172
ns3::MakePointerAccessor
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: pointer.h:227
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: double.h:42
ns3::Channel
Abstract Channel Base Class.
Definition: channel.h:44
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::SpectrumChannel::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: spectrum-channel.cc:53
ns3::SpectrumChannel::m_pathLossTrace
TracedCallback< Ptr< const SpectrumPhy >, Ptr< const SpectrumPhy >, double > m_pathLossTrace
The PathLoss trace source.
Definition: spectrum-channel.h:180
ns3::SpectrumChannel::m_txSigParamsTrace
TracedCallback< Ptr< SpectrumSignalParameters > > m_txSigParamsTrace
Traced callback for SpectrumSignalParameters in StartTx requests.
Definition: spectrum-channel.h:192
ns3::SpectrumChannel::AddSpectrumPropagationLossModel
void AddSpectrumPropagationLossModel(Ptr< SpectrumPropagationLossModel > loss)
Add the frequency-dependent propagation loss model to be used.
Definition: spectrum-channel.cc:128
ns3::SpectrumChannel::m_propagationLoss
Ptr< PropagationLossModel > m_propagationLoss
Single-frequency propagation loss model to be used with this channel.
Definition: spectrum-channel.h:204