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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
9
10#include "ns3/antenna-model.h"
11#include "ns3/config.h"
12#include "ns3/log.h"
13#include "ns3/mobility-model.h"
14#include "ns3/names.h"
15#include "ns3/non-communicating-net-device.h"
16#include "ns3/propagation-delay-model.h"
17#include "ns3/simulator.h"
18#include "ns3/spectrum-channel.h"
19#include "ns3/spectrum-propagation-loss-model.h"
20#include "ns3/waveform-generator.h"
21
22namespace ns3
23{
24
25NS_LOG_COMPONENT_DEFINE("WaveformGeneratorHelper");
26
28{
29 m_phy.SetTypeId("ns3::WaveformGenerator");
30 m_device.SetTypeId("ns3::NonCommunicatingNetDevice");
31 m_antenna.SetTypeId("ns3::IsotropicAntennaModel");
32}
33
37
38void
43
44void
46{
48 m_channel = channel;
49}
50
51void
57
58void
60{
61 m_phy.Set(name, v);
62}
63
64void
66{
67 m_device.Set(name, v);
68}
69
72{
73 NetDeviceContainer devices;
74 for (auto i = c.Begin(); i != c.End(); ++i)
75 {
76 Ptr<Node> node = *i;
77
80
82 NS_ASSERT(phy);
83
84 dev->SetPhy(phy);
85
86 NS_ASSERT(node);
87 phy->SetMobility(node->GetObject<MobilityModel>());
88
89 NS_ASSERT(dev);
90 phy->SetDevice(dev);
91
93 "you forgot to call WaveformGeneratorHelper::SetTxPowerSpectralDensity ()");
94 phy->SetTxPowerSpectralDensity(m_txPsd);
95
96 NS_ASSERT_MSG(m_channel, "you forgot to call WaveformGeneratorHelper::SetChannel ()");
97 phy->SetChannel(m_channel);
98 dev->SetChannel(m_channel);
99
100 Ptr<AntennaModel> antenna = (m_antenna.Create())->GetObject<AntennaModel>();
101 NS_ASSERT_MSG(antenna, "error in creating the AntennaModel object");
102 phy->SetAntenna(antenna);
103
104 node->AddDevice(dev);
105 devices.Add(dev);
106 }
107 return devices;
108}
109
112{
113 return Install(NodeContainer(node));
114}
115
117WaveformGeneratorHelper::Install(std::string nodeName) const
118{
119 Ptr<Node> node = Names::Find<Node>(nodeName);
120 return Install(node);
121}
122
123} // namespace ns3
Hold a value for an Attribute.
Definition attribute.h:59
Keep track of the current position and velocity of an object.
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
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:511
Smart pointer class similar to boost::intrusive_ptr.
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:55
#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:75
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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.