A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
spectrum-channel.h
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#ifndef SPECTRUM_CHANNEL_H
21#define SPECTRUM_CHANNEL_H
22
24#include "spectrum-phy.h"
28
29#include <ns3/channel.h>
30#include <ns3/mobility-model.h>
31#include <ns3/nstime.h>
32#include <ns3/object.h>
33#include <ns3/propagation-delay-model.h>
34#include <ns3/propagation-loss-model.h>
35#include <ns3/traced-callback.h>
36
37namespace ns3
38{
39
40class PacketBurst;
41class SpectrumValue;
42
43/**
44 * \ingroup spectrum
45 *
46 * Defines the interface for spectrum-aware channel implementations
47 *
48 */
50{
51 public:
52 /**
53 * constructor
54 *
55 */
57 /**
58 * destructor
59 *
60 */
61 ~SpectrumChannel() override;
62
63 // inherited from Object
64 void DoDispose() override;
65
66 /**
67 * \brief Get the type ID.
68 * \return the object TypeId
69 */
70 static TypeId GetTypeId();
71
72 /**
73 * Add the single-frequency propagation loss model to be used
74 * \warning only models that do not depend on the TX power should be used.
75 *
76 * \param loss a pointer to the propagation loss model to be used.
77 */
79
80 /**
81 * Add the frequency-dependent propagation loss model to be used
82 * \param loss a pointer to the propagation loss model to be used.
83 */
85
86 /**
87 * Add the frequency-dependent propagation loss model
88 * that is compapatible with the phased antenna arrays at the TX and RX
89 * \param loss a pointer to the propagation loss model to be used.
90 */
93
94 /**
95 * Set the propagation delay model to be used. This method will abort
96 * the simulation if there exists a previously set propagation delay model
97 * (i.e., unlike propagation loss models, multiple of which can be chained
98 * together, there is only one propagation delay model).
99 * \param delay Ptr to the propagation delay model to be used.
100 */
102
103 /**
104 * Get the frequency-dependent propagation loss model.
105 * \returns a pointer to the propagation loss model.
106 */
108
109 /**
110 * Get the frequency-dependent propagation loss model that is
111 * compatible with the phased antenna arrays at TX and RX
112 * \returns a pointer to the propagation loss model.
113 */
115
116 /**
117 * Get the propagation loss model.
118 * \returns a pointer to the propagation loss model.
119 */
121
122 /**
123 * Get the propagation delay model that has been set on the channel.
124 * \returns a pointer to the propagation delay model.
125 */
127
128 /**
129 * Add the transmit filter to be used to filter possible signal receptions
130 * at the StartTx() time. This method may be called multiple
131 * times to chain multiple filters together; the last filter added will
132 * be the first one used in the chain.
133 *
134 * \param filter an instance of a SpectrumTransmitFilter
135 */
137
138 /**
139 * Get the transmit filter, or first in a chain of transmit filters
140 * if more than one is present.
141 * \returns a pointer to the transmit filter.
142 */
144
145 /**
146 * Used by attached PHY instances to transmit signals on the channel
147 *
148 * \param params the parameters of the signals being transmitted
149 */
150 virtual void StartTx(Ptr<SpectrumSignalParameters> params) = 0;
151
152 /**
153 * This method calls AssignStreams() on any/all of the PropagationLossModel,
154 * PropagationDelayModel, SpectrumPropagationLossModel,
155 * PhasedArraySpectrumPropagationLossModel, and SpectrumTransmitFilter
156 * objects that have been added to this channel. If any of those
157 * objects are chained together (e.g., multiple PropagationDelayModel
158 * objects), the base class of that object is responsible for ensuring
159 * that all models in the chain have AssignStreams recursively called.
160 *
161 * \param stream the stream index offset start
162 * \return the number of stream indices assigned by this model
163 */
164 int64_t AssignStreams(int64_t stream);
165
166 /**
167 * \brief Remove a SpectrumPhy from a channel
168 *
169 * This method is used to detach a SpectrumPhy instance from a
170 * SpectrumChannel instance, so that the SpectrumPhy does not receive
171 * packets sent on that channel.
172 *
173 * This method is to be implemented by all classes inheriting from
174 * SpectrumChannel.
175 *
176 * @param phy the SpectrumPhy instance to be removed from the channel as
177 * a receiver.
178 */
179 virtual void RemoveRx(Ptr<SpectrumPhy> phy) = 0;
180
181 /**
182 * \brief Add a SpectrumPhy to a channel, so it can receive packets
183 *
184 * This method is used to attach a SpectrumPhy instance to a
185 * SpectrumChannel instance, so that the SpectrumPhy can receive
186 * packets sent on that channel. Note that a SpectrumPhy that only
187 * transmits (without receiving ever) does not need to be added to
188 * the channel.
189 *
190 * This method is to be implemented by all classes inheriting from
191 * SpectrumChannel.
192 *
193 * \param phy the SpectrumPhy instance to be added to the channel as
194 * a receiver.
195 */
196 virtual void AddRx(Ptr<SpectrumPhy> phy) = 0;
197
198 /**
199 * TracedCallback signature for path loss calculation events.
200 *
201 * \param [in] txPhy The TX SpectrumPhy instance.
202 * \param [in] rxPhy The RX SpectrumPhy instance.
203 * \param [in] lossDb The loss value, in dB.
204 */
207 double lossDb);
208 /**
209 * TracedCallback signature for path loss calculation events.
210 *
211 * \param [in] txMobility The mobility model of the transmitter.
212 * \param [in] rxMobility The mobility model of the receiver.
213 * \param [in] txAntennaGain The transmitter antenna gain, in dB.
214 * \param [in] rxAntennaGain The receiver antenna gain, in dB.
215 * \param [in] propagationGain The propagation gain, in dB.
216 * \param [in] pathloss The path loss value, in dB.
217 */
219 Ptr<const MobilityModel> rxMobility,
220 double txAntennaGain,
221 double rxAntennaGain,
222 double propagationGain,
223 double pathloss);
224 /**
225 * TracedCallback signature for Ptr<const SpectrumSignalParameters>.
226 *
227 * \param [in] params SpectrumSignalParameters instance.
228 */
230
231 protected:
232 /**
233 * This provides a base class implementation that may be subclassed
234 * if needed by subclasses that might need additional stream assignments.
235 *
236 * \param stream first stream index to use
237 * \return the number of stream indices assigned by this model
238 */
239 virtual int64_t DoAssignStreams(int64_t stream);
240
241 /**
242 * The `PathLoss` trace source. Exporting the pointers to the Tx and Rx
243 * SpectrumPhy and a pathloss value, in dB.
244 */
246
247 /**
248 * The `Gain` trace source. Fired whenever a new path loss value
249 * is calculated. Exporting pointer to the mobility model of the transmitter and
250 * the receiver, Tx antenna gain, Rx antenna gain, propagation gain and pathloss
251 */
254 double,
255 double,
256 double,
257 double>
259
260 /**
261 * Traced callback for SpectrumSignalParameters in StartTx requests
262 */
264
265 /**
266 * Maximum loss [dB].
267 *
268 * Any device above this loss is considered out of range.
269 */
271
272 /**
273 * Single-frequency propagation loss model to be used with this channel.
274 */
276
277 /**
278 * Propagation delay model to be used with this channel.
279 */
281
282 /**
283 * Frequency-dependent propagation loss model to be used with this channel.
284 */
286
287 /**
288 * Frequency-dependent propagation loss model to be used with this channel.
289 */
291
292 /**
293 * Transmit filter to be used with this channel
294 */
296};
297
298} // namespace ns3
299
300#endif /* SPECTRUM_CHANNEL_H */
Abstract Channel Base Class.
Definition: channel.h:45
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Defines the interface for spectrum-aware channel implementations.
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.
virtual void RemoveRx(Ptr< SpectrumPhy > phy)=0
Remove a SpectrumPhy from a channel.
virtual void StartTx(Ptr< SpectrumSignalParameters > params)=0
Used by attached PHY instances to transmit signals on the channel.
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
void(* LossTracedCallback)(Ptr< const SpectrumPhy > txPhy, Ptr< const SpectrumPhy > rxPhy, double lossDb)
TracedCallback signature for path loss calculation events.
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,...
void(* GainTracedCallback)(Ptr< const MobilityModel > txMobility, Ptr< const MobilityModel > rxMobility, double txAntennaGain, double rxAntennaGain, double propagationGain, double pathloss)
TracedCallback signature for path loss calculation events.
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...
virtual void AddRx(Ptr< SpectrumPhy > phy)=0
Add a SpectrumPhy to a channel, so it can receive packets.
void(* SignalParametersTracedCallback)(Ptr< SpectrumSignalParameters > params)
TracedCallback signature for Ptr<const SpectrumSignalParameters>.
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
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.