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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
8
9#ifndef WAVEFORM_GENERATOR_H
10#define WAVEFORM_GENERATOR_H
11
12#include "spectrum-channel.h"
13#include "spectrum-phy.h"
14#include "spectrum-value.h"
15
16#include <ns3/event-id.h>
17#include <ns3/mobility-model.h>
18#include <ns3/net-device.h>
19#include <ns3/nstime.h>
20#include <ns3/packet.h>
21#include <ns3/trace-source-accessor.h>
22
23namespace ns3
24{
25
26class AntennaModel;
27
28/**
29 * \ingroup spectrum
30 *
31 * Simple SpectrumPhy implementation that sends customizable waveform.
32 * The generated waveforms have a given Spectrum Power Density and
33 * duration (set with the SetResolution()) . The generator activates
34 * and deactivates periodically with a given period and with a duty
35 * cycle of 1/2.
36 *
37 * This PHY model supports a single antenna model instance which is
38 * used for both transmission and reception (though received signals
39 * are discarded by this PHY).
40 */
42{
43 public:
45 ~WaveformGenerator() override;
46
47 /**
48 * \brief Get the type ID.
49 * \return the object TypeId
50 */
51 static TypeId GetTypeId();
52
53 // inherited from SpectrumPhy
54 void SetChannel(Ptr<SpectrumChannel> c) override;
55 void SetMobility(Ptr<MobilityModel> m) override;
56 void SetDevice(Ptr<NetDevice> d) override;
57 Ptr<MobilityModel> GetMobility() const override;
58 Ptr<NetDevice> GetDevice() const override;
60 Ptr<Object> GetAntenna() const override;
61 void StartRx(Ptr<SpectrumSignalParameters> params) override;
62
63 /**
64 * Set the Power Spectral Density used for outgoing waveforms
65 *
66 * @param txs the Power Spectral Density
67 */
69
70 /**
71 * Set the period according to which the WaveformGenerator switches
72 * on and off
73 *
74 * @param period
75 */
76 void SetPeriod(Time period);
77
78 /**
79 *
80 * @return the value of the period according to which the WaveformGenerator switches
81 * on and off
82 */
83 Time GetPeriod() const;
84
85 /**
86 *
87 * @param value the value of the duty cycle
88 */
89 void SetDutyCycle(double value);
90
91 /**
92 *
93 * @return the value of the duty cycle
94 */
95 double GetDutyCycle() const;
96
97 /**
98 * set the AntennaModel to be used
99 *
100 * \param a the Antenna Model
101 */
103
104 /**
105 * Start the waveform generator
106 *
107 */
108 virtual void Start();
109
110 /**
111 * Stop the waveform generator
112 *
113 */
114 virtual void Stop();
115
116 private:
117 void DoDispose() override;
118
119 Ptr<MobilityModel> m_mobility; //!< Mobility model
120 Ptr<AntennaModel> m_antenna; //!< Antenna model
121 Ptr<NetDevice> m_netDevice; //!< Owning NetDevice
123
124 /**
125 * Generates a waveform
126 */
127 virtual void GenerateWaveform();
128
130 Time m_period; //!< Period
131 double m_dutyCycle; //!< Duty Cycle (should be in [0,1])
132 Time m_startTime; //!< Start time
133 EventId m_nextWave; //!< Next waveform generation event
134
137};
138
139} // namespace ns3
140
141#endif /* WAVEFORM_GENERATOR_H */
An identifier for simulation events.
Definition event-id.h:45
Smart pointer class similar to boost::intrusive_ptr.
Abstract base class for Spectrum-aware PHY layers.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
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.