A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
spectrum-helper.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010 CTTC
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Nicola Baldo <nbaldo@cttc.es>
7
*/
8
9
#ifndef SPECTRUM_HELPER_H
10
#define SPECTRUM_HELPER_H
11
12
#include <ns3/attribute.h>
13
#include <ns3/net-device-container.h>
14
#include <ns3/node-container.h>
15
#include <ns3/object-factory.h>
16
#include <ns3/propagation-loss-model.h>
17
#include <ns3/spectrum-propagation-loss-model.h>
18
19
#include <string>
20
21
namespace
ns3
22
{
23
24
class
SpectrumPhy;
25
class
SpectrumChannel;
26
class
Node;
27
class
NetDevice;
28
29
/**
30
* \ingroup spectrum
31
* \brief Setup a SpectrumChannel
32
*/
33
class
SpectrumChannelHelper
34
{
35
public
:
36
/**
37
* \brief Setup a default SpectrumChannel. The Default mode is:
38
* Channel: "ns3::SingleModelSpectrumChannel",
39
* PropagationDelay: "ns3::ConstantSpeedPropagationDelayModel", and
40
* SpectrumPropagationLoss: "ns3::FriisSpectrumPropagationLossModel".
41
*
42
* \returns a Default-configured SpectrumChannelHelper
43
*/
44
static
SpectrumChannelHelper
Default
();
45
46
/**
47
* \tparam Ts \deduced Argument types
48
* \param type the type of the SpectrumChannel to use
49
* \param [in] args Name and AttributeValue pairs to set.
50
*/
51
template
<
typename
... Ts>
52
void
SetChannel
(std::string type, Ts&&... args);
53
/**
54
* \tparam Ts \deduced Argument types
55
* \param name the name of the model to set
56
* \param [in] args Name and AttributeValue pairs to set.
57
*
58
* Add a new single-frequency propagation loss model to this channel helper.
59
*/
60
template
<
typename
... Ts>
61
void
AddPropagationLoss
(std::string name, Ts&&... args);
62
63
/**
64
* Add a new single-frequency propagation loss model instance to this channel helper.
65
*
66
* \param m a pointer to the instance of the propagation loss model
67
*/
68
void
AddPropagationLoss
(
Ptr<PropagationLossModel>
m);
69
70
/**
71
* \tparam Ts \deduced Argument types
72
* \param name the name of the model to set
73
* \param [in] args Name and AttributeValue pairs to set.
74
*
75
* Add a new frequency-dependent propagation loss model to this channel helper.
76
*/
77
template
<
typename
... Ts>
78
void
AddSpectrumPropagationLoss
(std::string name, Ts&&... args);
79
80
/**
81
* Add a new frequency-dependent propagation loss model instance to this channel helper.
82
*
83
* \param m a pointer to the instance of the propagation loss model
84
*/
85
void
AddSpectrumPropagationLoss
(
Ptr<SpectrumPropagationLossModel>
m);
86
87
/**
88
* \tparam Ts \deduced Argument types
89
* \param name the name of the model to set
90
* \param [in] args Name and AttributeValue pairs to set.
91
*
92
* Configure a propagation delay for this channel.
93
*/
94
template
<
typename
... Ts>
95
void
SetPropagationDelay
(std::string name, Ts&&... args);
96
97
/**
98
* \returns a new channel
99
*
100
* Create a channel based on the configuration parameters set previously.
101
*/
102
Ptr<SpectrumChannel>
Create
()
const
;
103
104
private
:
105
Ptr<SpectrumPropagationLossModel>
106
m_spectrumPropagationLossModel
;
//!< Spectrum propagation loss model
107
Ptr<PropagationLossModel>
m_propagationLossModel
;
//!< Propagation loss model
108
ObjectFactory
m_propagationDelay
;
//!< Propagation delay
109
ObjectFactory
m_channel
;
//!< Channel
110
};
111
112
/**
113
* \ingroup spectrum
114
*
115
* Create and configure several SpectrumPhy instances and connect them to a channel.
116
*/
117
class
SpectrumPhyHelper
118
{
119
public
:
120
/**
121
* \tparam Ts \deduced Argument types
122
* \param name the type of SpectrumPhy to use
123
* \param [in] args Name and AttributeValue pairs to set.
124
*/
125
template
<
typename
... Ts>
126
void
SetPhy
(std::string name, Ts&&... args);
127
128
/**
129
* set the channel that will be used by SpectrumPhy instances created by this helper
130
*
131
* @param channel
132
*/
133
void
SetChannel
(
Ptr<SpectrumChannel>
channel);
134
135
/**
136
* set the channel that will be used by SpectrumPhy instances created by this helper
137
*
138
* @param channelName
139
*/
140
void
SetChannel
(std::string channelName);
141
142
/**
143
* \param name the name of the attribute to set
144
* \param v the value of the attribute
145
*
146
* Set an attribute of the SpectrumPhy instances to be created
147
*/
148
void
SetPhyAttribute
(std::string name,
const
AttributeValue
& v);
149
150
/**
151
*
152
* @param node
153
* @param device
154
*
155
* @return a newly created SpectrumPhy instance
156
*/
157
Ptr<SpectrumPhy>
Create
(
Ptr<Node>
node,
Ptr<NetDevice>
device)
const
;
158
159
private
:
160
ObjectFactory
m_phy
;
//!< Object factory for the phy objects
161
Ptr<SpectrumChannel>
m_channel
;
//!< Channel
162
};
163
164
/***************************************************************
165
* Implementation of the templates declared above.
166
***************************************************************/
167
168
template
<
typename
... Ts>
169
void
170
SpectrumChannelHelper::SetChannel
(std::string type, Ts&&... args)
171
{
172
m_channel
.
SetTypeId
(type);
173
m_channel
.
Set
(std::forward<Ts>(args)...);
174
}
175
176
template
<
typename
... Ts>
177
void
178
SpectrumChannelHelper::AddPropagationLoss
(std::string name, Ts&&... args)
179
{
180
ObjectFactory
factory(name, std::forward<Ts>(args)...);
181
Ptr<PropagationLossModel>
m = factory.
Create
<
PropagationLossModel
>();
182
AddPropagationLoss
(m);
183
}
184
185
template
<
typename
... Ts>
186
void
187
SpectrumChannelHelper::AddSpectrumPropagationLoss
(std::string name, Ts&&... args)
188
{
189
ObjectFactory
factory(name, std::forward<Ts>(args)...);
190
Ptr<SpectrumPropagationLossModel>
m = factory.
Create
<
SpectrumPropagationLossModel
>();
191
AddSpectrumPropagationLoss
(m);
192
}
193
194
template
<
typename
... Ts>
195
void
196
SpectrumChannelHelper::SetPropagationDelay
(std::string name, Ts&&... args)
197
{
198
m_propagationDelay
=
ObjectFactory
(name, std::forward<Ts>(args)...);
199
}
200
201
template
<
typename
... Ts>
202
void
203
SpectrumPhyHelper::SetPhy
(std::string name, Ts&&... args)
204
{
205
m_phy
.
SetTypeId
(name);
206
m_phy
.
Set
(std::forward<Ts>(args)...);
207
}
208
209
}
// namespace ns3
210
211
#endif
/* SPECTRUM_HELPER_H */
ns3::AttributeValue
Hold a value for an Attribute.
Definition
attribute.h:59
ns3::ObjectFactory
Instantiate subclasses of ns3::Object.
Definition
object-factory.h:37
ns3::ObjectFactory::Create
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
Definition
object-factory.cc:82
ns3::ObjectFactory::Set
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Definition
object-factory.h:213
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition
object-factory.cc:31
ns3::PropagationLossModel
Models the propagation loss through a transmission medium.
Definition
propagation-loss-model.h:45
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::SpectrumChannelHelper
Setup a SpectrumChannel.
Definition
spectrum-helper.h:34
ns3::SpectrumChannelHelper::m_propagationDelay
ObjectFactory m_propagationDelay
Propagation delay.
Definition
spectrum-helper.h:108
ns3::SpectrumChannelHelper::m_channel
ObjectFactory m_channel
Channel.
Definition
spectrum-helper.h:109
ns3::SpectrumChannelHelper::Create
Ptr< SpectrumChannel > Create() const
Definition
spectrum-helper.cc:47
ns3::SpectrumChannelHelper::AddPropagationLoss
void AddPropagationLoss(std::string name, Ts &&... args)
Definition
spectrum-helper.h:178
ns3::SpectrumChannelHelper::Default
static SpectrumChannelHelper Default()
Setup a default SpectrumChannel.
Definition
spectrum-helper.cc:23
ns3::SpectrumChannelHelper::AddSpectrumPropagationLoss
void AddSpectrumPropagationLoss(std::string name, Ts &&... args)
Definition
spectrum-helper.h:187
ns3::SpectrumChannelHelper::SetPropagationDelay
void SetPropagationDelay(std::string name, Ts &&... args)
Definition
spectrum-helper.h:196
ns3::SpectrumChannelHelper::SetChannel
void SetChannel(std::string type, Ts &&... args)
Definition
spectrum-helper.h:170
ns3::SpectrumChannelHelper::m_spectrumPropagationLossModel
Ptr< SpectrumPropagationLossModel > m_spectrumPropagationLossModel
Spectrum propagation loss model.
Definition
spectrum-helper.h:106
ns3::SpectrumChannelHelper::m_propagationLossModel
Ptr< PropagationLossModel > m_propagationLossModel
Propagation loss model.
Definition
spectrum-helper.h:107
ns3::SpectrumPhyHelper
Create and configure several SpectrumPhy instances and connect them to a channel.
Definition
spectrum-helper.h:118
ns3::SpectrumPhyHelper::SetChannel
void SetChannel(Ptr< SpectrumChannel > channel)
set the channel that will be used by SpectrumPhy instances created by this helper
Definition
spectrum-helper.cc:58
ns3::SpectrumPhyHelper::m_channel
Ptr< SpectrumChannel > m_channel
Channel.
Definition
spectrum-helper.h:161
ns3::SpectrumPhyHelper::m_phy
ObjectFactory m_phy
Object factory for the phy objects.
Definition
spectrum-helper.h:160
ns3::SpectrumPhyHelper::SetPhyAttribute
void SetPhyAttribute(std::string name, const AttributeValue &v)
Definition
spectrum-helper.cc:71
ns3::SpectrumPhyHelper::Create
Ptr< SpectrumPhy > Create(Ptr< Node > node, Ptr< NetDevice > device) const
Definition
spectrum-helper.cc:77
ns3::SpectrumPhyHelper::SetPhy
void SetPhy(std::string name, Ts &&... args)
Definition
spectrum-helper.h:203
ns3::SpectrumPropagationLossModel
spectrum-aware propagation loss model
Definition
spectrum-propagation-loss-model.h:33
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
spectrum
helper
spectrum-helper.h
Generated on Fri Nov 8 2024 13:59:06 for ns-3 by
1.11.0