A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
spectrum-analyzer.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 SPECTRUM_ANALYZER_H
21#define SPECTRUM_ANALYZER_H
22
23#include "spectrum-channel.h"
24#include "spectrum-phy.h"
25#include "spectrum-value.h"
26
27#include <ns3/mobility-model.h>
28#include <ns3/net-device.h>
29#include <ns3/nstime.h>
30#include <ns3/packet.h>
31
32#include <fstream>
33#include <string>
34
35namespace ns3
36{
37
38/**
39 * \ingroup spectrum
40 *
41 * Simple SpectrumPhy implementation that averages the spectrum power
42 * density of incoming transmissions to produce a spectrogram.
43 *
44 *
45 * This PHY model supports a single antenna model instance which is
46 * used for reception (this PHY model never transmits).
47 */
49{
50 public:
52 ~SpectrumAnalyzer() override;
53
54 /**
55 * \brief Get the type ID.
56 * \return the object TypeId
57 */
58 static TypeId GetTypeId();
59
60 // inherited from SpectrumPhy
61 void SetChannel(Ptr<SpectrumChannel> c) override;
62 void SetMobility(Ptr<MobilityModel> m) override;
63 void SetDevice(Ptr<NetDevice> d) override;
64 Ptr<MobilityModel> GetMobility() const override;
65 Ptr<NetDevice> GetDevice() const override;
67 Ptr<Object> GetAntenna() const override;
68 void StartRx(Ptr<SpectrumSignalParameters> params) override;
69
70 /**
71 * Set the spectrum model used by the SpectrumAnalyzer to represent incoming signals
72 *
73 * @param m the Rx Spectrum model
74 */
76
77 /**
78 * Set the AntennaModel to be used
79 *
80 * \param a the Antenna Model
81 */
83
84 /**
85 * Start the spectrum analyzer
86 *
87 */
88 virtual void Start();
89
90 /**
91 * Stop the spectrum analyzer
92 *
93 */
94 virtual void Stop();
95
96 protected:
97 void DoDispose() override;
98
99 private:
100 Ptr<MobilityModel> m_mobility; //!< Pointer to the mobility model
101 Ptr<AntennaModel> m_antenna; //!< Pointer to the Antenna model
102 Ptr<NetDevice> m_netDevice; //!< Pointer to the NetDevice using this object
103 Ptr<SpectrumChannel> m_channel; //!< Pointer to the channel to be analyzed
104
105 /**
106 * Generates a report of the data collected so far.
107 *
108 * This function is called periodically.
109 */
110 virtual void GenerateReport();
111
112 /**
113 * Adds a signal to the data collected.
114 * \param psd signal to add
115 */
117 /**
118 * Removes a signal to the data collected.
119 * \param psd signal to subtract
120 */
122 /**
123 * Updates the data about the received Energy
124 */
126
128 Ptr<SpectrumValue> m_sumPowerSpectralDensity; //!< Sum of the received PSD
129 Ptr<SpectrumValue> m_energySpectralDensity; //!< Energy spectral density
130 double m_noisePowerSpectralDensity; //!< Noise power spectral density
131 Time m_resolution; //!< Time resolution
132 Time m_lastChangeTime; //!< When the last update happened
133 bool m_active; //!< True if the analyzer is active
134
135 /// TracedCallback - average power spectral density report.
137};
138
139} // namespace ns3
140
141#endif /* SPECTRUM_ANALYZER_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simple SpectrumPhy implementation that averages the spectrum power density of incoming transmissions ...
TracedCallback< Ptr< const SpectrumValue > > m_averagePowerSpectralDensityReportTrace
TracedCallback - average power spectral density report.
void SetRxSpectrumModel(Ptr< SpectrumModel > m)
Set the spectrum model used by the SpectrumAnalyzer to represent incoming signals.
virtual void Start()
Start the spectrum analyzer.
static TypeId GetTypeId()
Get the type ID.
void DoDispose() override
Destructor implementation.
double m_noisePowerSpectralDensity
Noise power spectral density.
void SetAntenna(Ptr< AntennaModel > a)
Set the AntennaModel to be used.
virtual void Stop()
Stop the spectrum analyzer.
void SetMobility(Ptr< MobilityModel > m) override
Set the mobility model associated with this device.
Ptr< Object > GetAntenna() const override
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.
void StartRx(Ptr< SpectrumSignalParameters > params) override
Notify the SpectrumPhy instance of an incoming signal.
bool m_active
True if the analyzer is active.
Ptr< SpectrumChannel > m_channel
Pointer to the channel to be analyzed.
Time m_resolution
Time resolution.
Ptr< AntennaModel > m_antenna
Pointer to the Antenna model.
Ptr< NetDevice > GetDevice() const override
Get the associated NetDevice instance.
Ptr< MobilityModel > GetMobility() const override
Get the associated MobilityModel instance.
virtual void GenerateReport()
Generates a report of the data collected so far.
Ptr< SpectrumModel > m_spectrumModel
Spectrum model.
Time m_lastChangeTime
When the last update happened.
void AddSignal(Ptr< const SpectrumValue > psd)
Adds a signal to the data collected.
Ptr< SpectrumValue > m_sumPowerSpectralDensity
Sum of the received PSD.
Ptr< const SpectrumModel > GetRxSpectrumModel() const override
Ptr< SpectrumValue > m_energySpectralDensity
Energy spectral density.
void UpdateEnergyReceivedSoFar()
Updates the data about the received Energy.
void SetChannel(Ptr< SpectrumChannel > c) override
Set the channel attached to this device.
void SubtractSignal(Ptr< const SpectrumValue > psd)
Removes a signal to the data collected.
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
void SetDevice(Ptr< NetDevice > d) override
Set the associated NetDevice instance.
Ptr< NetDevice > m_netDevice
Pointer to the NetDevice using this object.
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.