A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
waveform-generator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 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
20#ifndef WAVEFORM_GENERATOR_H
21#define WAVEFORM_GENERATOR_H
22
23#include "spectrum-channel.h"
24#include "spectrum-phy.h"
25#include "spectrum-value.h"
26
27#include <ns3/event-id.h>
28#include <ns3/mobility-model.h>
29#include <ns3/net-device.h>
30#include <ns3/nstime.h>
31#include <ns3/packet.h>
32#include <ns3/trace-source-accessor.h>
33
34namespace ns3
35{
36
37class AntennaModel;
38
39/**
40 * \ingroup spectrum
41 *
42 * Simple SpectrumPhy implementation that sends customizable waveform.
43 * The generated waveforms have a given Spectrum Power Density and
44 * duration (set with the SetResolution()) . The generator activates
45 * and deactivates periodically with a given period and with a duty
46 * cycle of 1/2.
47 *
48 * This PHY model supports a single antenna model instance which is
49 * used for both transmission and reception (though received signals
50 * are discarded by this PHY).
51 */
53{
54 public:
56 ~WaveformGenerator() override;
57
58 /**
59 * \brief Get the type ID.
60 * \return the object TypeId
61 */
62 static TypeId GetTypeId();
63
64 // inherited from SpectrumPhy
65 void SetChannel(Ptr<SpectrumChannel> c) override;
66 void SetMobility(Ptr<MobilityModel> m) override;
67 void SetDevice(Ptr<NetDevice> d) override;
68 Ptr<MobilityModel> GetMobility() const override;
69 Ptr<NetDevice> GetDevice() const override;
71 Ptr<Object> GetAntenna() const override;
72 void StartRx(Ptr<SpectrumSignalParameters> params) override;
73
74 /**
75 * Set the Power Spectral Density used for outgoing waveforms
76 *
77 * @param txs the Power Spectral Density
78 */
80
81 /**
82 * Set the period according to which the WaveformGenerator switches
83 * on and off
84 *
85 * @param period
86 */
87 void SetPeriod(Time period);
88
89 /**
90 *
91 * @return the value of the period according to which the WaveformGenerator switches
92 * on and off
93 */
94 Time GetPeriod() const;
95
96 /**
97 *
98 * @param value the value of the duty cycle
99 */
100 void SetDutyCycle(double value);
101
102 /**
103 *
104 * @return the value of the duty cycle
105 */
106 double GetDutyCycle() const;
107
108 /**
109 * set the AntennaModel to be used
110 *
111 * \param a the Antenna Model
112 */
114
115 /**
116 * Start the waveform generator
117 *
118 */
119 virtual void Start();
120
121 /**
122 * Stop the waveform generator
123 *
124 */
125 virtual void Stop();
126
127 private:
128 void DoDispose() override;
129
130 Ptr<MobilityModel> m_mobility; //!< Mobility model
131 Ptr<AntennaModel> m_antenna; //!< Antenna model
132 Ptr<NetDevice> m_netDevice; //!< Owning NetDevice
134
135 /**
136 * Generates a waveform
137 */
138 virtual void GenerateWaveform();
139
141 Time m_period; //!< Period
142 double m_dutyCycle; //!< Duty Cycle (should be in [0,1])
143 Time m_startTime; //!< Start time
144 EventId m_nextWave; //!< Next waveform generation event
145
148};
149
150} // namespace ns3
151
152#endif /* WAVEFORM_GENERATOR_H */
An identifier for simulation events.
Definition: event-id.h:55
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Abstract base class for Spectrum-aware PHY layers.
Definition: spectrum-phy.h:46
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Simple SpectrumPhy implementation that sends customizable waveform.
void SetDevice(Ptr< NetDevice > d) override
Set the associated NetDevice instance.
static TypeId GetTypeId()
Get the type ID.
void SetChannel(Ptr< SpectrumChannel > c) override
Set the channel attached to this device.
Ptr< MobilityModel > GetMobility() const override
Get the associated MobilityModel instance.
EventId m_nextWave
Next waveform generation event.
TracedCallback< Ptr< const Packet > > m_phyTxStartTrace
TracedCallback: Tx start.
Ptr< MobilityModel > m_mobility
Mobility model.
Ptr< Object > GetAntenna() const override
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.
Ptr< AntennaModel > m_antenna
Antenna model.
void SetAntenna(Ptr< AntennaModel > a)
set the AntennaModel to be used
void StartRx(Ptr< SpectrumSignalParameters > params) override
Notify the SpectrumPhy instance of an incoming signal.
Ptr< SpectrumChannel > m_channel
Channel.
Ptr< const SpectrumModel > GetRxSpectrumModel() const override
virtual void GenerateWaveform()
Generates a waveform.
Ptr< NetDevice > m_netDevice
Owning NetDevice.
Ptr< NetDevice > GetDevice() const override
Get the associated NetDevice instance.
Ptr< SpectrumValue > m_txPowerSpectralDensity
Tx PSD.
virtual void Start()
Start the waveform generator.
void DoDispose() override
Destructor implementation.
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txs)
Set the Power Spectral Density used for outgoing waveforms.
double m_dutyCycle
Duty Cycle (should be in [0,1])
void SetDutyCycle(double value)
void SetMobility(Ptr< MobilityModel > m) override
Set the mobility model associated with this device.
void SetPeriod(Time period)
Set the period according to which the WaveformGenerator switches on and off.
virtual void Stop()
Stop the waveform generator.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
TracedCallback: Tx end.
Every class exported by the ns3 library is enclosed in the ns3 namespace.