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.cc
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
#include "
spectrum-helper.h
"
9
10
#include <ns3/config.h>
11
#include <ns3/half-duplex-ideal-phy.h>
12
#include <ns3/multi-model-spectrum-channel.h>
13
#include <ns3/names.h>
14
#include <ns3/simulator.h>
15
#include <ns3/single-model-spectrum-channel.h>
16
#include <ns3/spectrum-channel.h>
17
#include <ns3/spectrum-phy.h>
18
19
namespace
ns3
20
{
21
22
SpectrumChannelHelper
23
SpectrumChannelHelper::Default
()
24
{
25
SpectrumChannelHelper
h;
26
h.
SetChannel
(
"ns3::SingleModelSpectrumChannel"
);
27
h.
SetPropagationDelay
(
"ns3::ConstantSpeedPropagationDelayModel"
);
28
h.
AddSpectrumPropagationLoss
(
"ns3::FriisSpectrumPropagationLossModel"
);
29
return
h;
30
}
31
32
void
33
SpectrumChannelHelper::AddPropagationLoss
(
Ptr<PropagationLossModel>
m)
34
{
35
m->SetNext(
m_propagationLossModel
);
36
m_propagationLossModel
= m;
37
}
38
39
void
40
SpectrumChannelHelper::AddSpectrumPropagationLoss
(
Ptr<SpectrumPropagationLossModel>
m)
41
{
42
m->SetNext(
m_spectrumPropagationLossModel
);
43
m_spectrumPropagationLossModel
= m;
44
}
45
46
Ptr<SpectrumChannel>
47
SpectrumChannelHelper::Create
()
const
48
{
49
Ptr<SpectrumChannel>
channel = (
m_channel
.
Create
())->GetObject<SpectrumChannel>();
50
channel->AddSpectrumPropagationLossModel(
m_spectrumPropagationLossModel
);
51
channel->AddPropagationLossModel(
m_propagationLossModel
);
52
Ptr<PropagationDelayModel>
delay =
m_propagationDelay
.
Create
<
PropagationDelayModel
>();
53
channel->SetPropagationDelayModel(delay);
54
return
channel;
55
}
56
57
void
58
SpectrumPhyHelper::SetChannel
(
Ptr<SpectrumChannel>
channel)
59
{
60
m_channel
= channel;
61
}
62
63
void
64
SpectrumPhyHelper::SetChannel
(std::string channelName)
65
{
66
Ptr<SpectrumChannel>
channel =
Names::Find<SpectrumChannel>
(channelName);
67
m_channel
= channel;
68
}
69
70
void
71
SpectrumPhyHelper::SetPhyAttribute
(std::string name,
const
AttributeValue
& v)
72
{
73
m_phy
.
Set
(name, v);
74
}
75
76
Ptr<SpectrumPhy>
77
SpectrumPhyHelper::Create
(
Ptr<Node>
node,
Ptr<NetDevice>
device)
const
78
{
79
NS_ASSERT
(
m_channel
);
80
Ptr<SpectrumPhy>
phy = (
m_phy
.
Create
())->GetObject<SpectrumPhy>();
81
phy->SetChannel(
m_channel
);
82
phy->SetMobility(node->GetObject<
MobilityModel
>());
83
phy->SetDevice(device);
84
return
phy;
85
}
86
87
}
// namespace ns3
ns3::AttributeValue
Hold a value for an Attribute.
Definition
attribute.h:59
ns3::MobilityModel
Keep track of the current position and velocity of an object.
Definition
mobility-model.h:29
ns3::Names::Find
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
Definition
names.h:443
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::PropagationDelayModel
calculate a propagation delay.
Definition
propagation-delay-model.h:27
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::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
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:55
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
spectrum-helper.h
src
spectrum
helper
spectrum-helper.cc
Generated on Fri Nov 8 2024 13:59:06 for ns-3 by
1.11.0