A Discrete-Event Network Simulator
API
spectrum-helper.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 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 #include "spectrum-helper.h"
20 
21 #include <ns3/config.h>
22 #include <ns3/half-duplex-ideal-phy.h>
23 #include <ns3/multi-model-spectrum-channel.h>
24 #include <ns3/names.h>
25 #include <ns3/simulator.h>
26 #include <ns3/single-model-spectrum-channel.h>
27 #include <ns3/spectrum-channel.h>
28 #include <ns3/spectrum-phy.h>
29 
30 namespace ns3
31 {
32 
33 SpectrumChannelHelper
35 {
37  h.SetChannel("ns3::SingleModelSpectrumChannel");
38  h.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
39  h.AddSpectrumPropagationLoss("ns3::FriisSpectrumPropagationLossModel");
40  return h;
41 }
42 
43 void
45 {
46  m->SetNext(m_propagationLossModel);
48 }
49 
50 void
52 {
55 }
56 
59 {
60  Ptr<SpectrumChannel> channel = (m_channel.Create())->GetObject<SpectrumChannel>();
61  channel->AddSpectrumPropagationLossModel(m_spectrumPropagationLossModel);
62  channel->AddPropagationLossModel(m_propagationLossModel);
64  channel->SetPropagationDelayModel(delay);
65  return channel;
66 }
67 
68 void
70 {
72 }
73 
74 void
75 SpectrumPhyHelper::SetChannel(std::string channelName)
76 {
77  Ptr<SpectrumChannel> channel = Names::Find<SpectrumChannel>(channelName);
79 }
80 
81 void
83 {
84  m_phy.Set(name, v);
85 }
86 
89 {
91  Ptr<SpectrumPhy> phy = (m_phy.Create())->GetObject<SpectrumPhy>();
92  phy->SetChannel(m_channel);
93  phy->SetMobility(node->GetObject<MobilityModel>());
94  phy->SetDevice(device);
95  return phy;
96 }
97 
98 } // namespace ns3
Hold a value for an Attribute.
Definition: attribute.h:70
Keep track of the current position and velocity of an object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
calculate a propagation delay.
Setup a SpectrumChannel.
ObjectFactory m_propagationDelay
Propagation delay.
ObjectFactory m_channel
Channel.
Ptr< SpectrumChannel > Create() const
void AddPropagationLoss(std::string name, Ts &&... args)
static SpectrumChannelHelper Default()
Setup a default SpectrumChannel.
void AddSpectrumPropagationLoss(std::string name, Ts &&... args)
void SetPropagationDelay(std::string name, Ts &&... args)
void SetChannel(std::string type, Ts &&... args)
Ptr< SpectrumPropagationLossModel > m_spectrumPropagationLossModel
Spectrum propagation loss model.
Ptr< PropagationLossModel > m_propagationLossModel
Propagation loss model.
void SetChannel(Ptr< SpectrumChannel > channel)
set the channel that will be used by SpectrumPhy instances created by this helper
Ptr< SpectrumChannel > m_channel
Channel.
ObjectFactory m_phy
Object factory for the phy objects.
void SetPhyAttribute(std::string name, const AttributeValue &v)
Ptr< SpectrumPhy > Create(Ptr< Node > node, Ptr< NetDevice > device) const
#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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
channel
Definition: third.py:88
phy
Definition: third.py:89