A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
waveform-generator-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 */
20
21#include "ns3/antenna-model.h"
22#include "ns3/config.h"
23#include "ns3/log.h"
24#include "ns3/mobility-model.h"
25#include "ns3/names.h"
26#include "ns3/non-communicating-net-device.h"
27#include "ns3/propagation-delay-model.h"
28#include "ns3/simulator.h"
29#include "ns3/spectrum-channel.h"
30#include "ns3/spectrum-propagation-loss-model.h"
31#include "ns3/waveform-generator.h"
32
33namespace ns3
34{
35
36NS_LOG_COMPONENT_DEFINE("WaveformGeneratorHelper");
37
39{
40 m_phy.SetTypeId("ns3::WaveformGenerator");
41 m_device.SetTypeId("ns3::NonCommunicatingNetDevice");
42 m_antenna.SetTypeId("ns3::IsotropicAntennaModel");
43}
44
46{
47}
48
49void
51{
52 m_channel = channel;
53}
54
55void
57{
58 Ptr<SpectrumChannel> channel = Names::Find<SpectrumChannel>(channelName);
59 m_channel = channel;
60}
61
62void
64{
65 NS_LOG_FUNCTION(this << txPsd);
66 m_txPsd = txPsd;
67}
68
69void
71{
72 m_phy.Set(name, v);
73}
74
75void
77{
78 m_device.Set(name, v);
79}
80
83{
84 NetDeviceContainer devices;
85 for (auto i = c.Begin(); i != c.End(); ++i)
86 {
87 Ptr<Node> node = *i;
88
91
93 NS_ASSERT(phy);
94
95 dev->SetPhy(phy);
96
97 NS_ASSERT(node);
98 phy->SetMobility(node->GetObject<MobilityModel>());
99
100 NS_ASSERT(dev);
101 phy->SetDevice(dev);
102
104 "you forgot to call WaveformGeneratorHelper::SetTxPowerSpectralDensity ()");
105 phy->SetTxPowerSpectralDensity(m_txPsd);
106
107 NS_ASSERT_MSG(m_channel, "you forgot to call WaveformGeneratorHelper::SetChannel ()");
108 phy->SetChannel(m_channel);
109 dev->SetChannel(m_channel);
110
111 Ptr<AntennaModel> antenna = (m_antenna.Create())->GetObject<AntennaModel>();
112 NS_ASSERT_MSG(antenna, "error in creating the AntennaModel object");
113 phy->SetAntenna(antenna);
114
115 node->AddDevice(dev);
116 devices.Add(dev);
117 }
118 return devices;
119}
120
123{
124 return Install(NodeContainer(node));
125}
126
128WaveformGeneratorHelper::Install(std::string nodeName) const
129{
130 Ptr<Node> node = Names::Find<Node>(nodeName);
131 return Install(node);
132}
133
134} // namespace ns3
Hold a value for an Attribute.
Definition: attribute.h:70
Keep track of the current position and velocity of an object.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
This class implements a device which does not communicate, in the sense that it does not interact wit...
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.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:522
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
Ptr< SpectrumValue > m_txPsd
Tx power spectral density.
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
ObjectFactory m_phy
Object factory for the phy objects.
void SetChannel(Ptr< SpectrumChannel > channel)
set the SpectrumChannel that will be used by SpectrumPhy instances created by this helper
Ptr< SpectrumChannel > m_channel
Channel.
NetDeviceContainer Install(NodeContainer c) const
void SetPhyAttribute(std::string name, const AttributeValue &v)
ObjectFactory m_device
Object factory for the NetDevice objects.
ObjectFactory m_antenna
Object factory for the Antenna objects.
Simple SpectrumPhy implementation that sends customizable waveform.
#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
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.