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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
8
9#ifndef SPECTRUM_ANALYZER_H
10#define SPECTRUM_ANALYZER_H
11
12#include "spectrum-channel.h"
13#include "spectrum-phy.h"
14#include "spectrum-value.h"
15
16#include <ns3/mobility-model.h>
17#include <ns3/net-device.h>
18#include <ns3/nstime.h>
19#include <ns3/packet.h>
20
21#include <fstream>
22#include <string>
23
24namespace ns3
25{
26
27/**
28 * \ingroup spectrum
29 *
30 * Simple SpectrumPhy implementation that averages the spectrum power
31 * density of incoming transmissions to produce a spectrogram.
32 *
33 *
34 * This PHY model supports a single antenna model instance which is
35 * used for reception (this PHY model never transmits).
36 */
38{
39 public:
41 ~SpectrumAnalyzer() override;
42
43 /**
44 * \brief Get the type ID.
45 * \return the object TypeId
46 */
47 static TypeId GetTypeId();
48
49 // inherited from SpectrumPhy
50 void SetChannel(Ptr<SpectrumChannel> c) override;
51 void SetMobility(Ptr<MobilityModel> m) override;
52 void SetDevice(Ptr<NetDevice> d) override;
53 Ptr<MobilityModel> GetMobility() const override;
54 Ptr<NetDevice> GetDevice() const override;
56 Ptr<Object> GetAntenna() const override;
57 void StartRx(Ptr<SpectrumSignalParameters> params) override;
58
59 /**
60 * Set the spectrum model used by the SpectrumAnalyzer to represent incoming signals
61 *
62 * @param m the Rx Spectrum model
63 */
65
66 /**
67 * Set the AntennaModel to be used
68 *
69 * \param a the Antenna Model
70 */
72
73 /**
74 * Start the spectrum analyzer
75 *
76 */
77 virtual void Start();
78
79 /**
80 * Stop the spectrum analyzer
81 *
82 */
83 virtual void Stop();
84
85 protected:
86 void DoDispose() override;
87
88 private:
89 Ptr<MobilityModel> m_mobility; //!< Pointer to the mobility model
90 Ptr<AntennaModel> m_antenna; //!< Pointer to the Antenna model
91 Ptr<NetDevice> m_netDevice; //!< Pointer to the NetDevice using this object
92 Ptr<SpectrumChannel> m_channel; //!< Pointer to the channel to be analyzed
93
94 /**
95 * Generates a report of the data collected so far.
96 *
97 * This function is called periodically.
98 */
99 virtual void GenerateReport();
100
101 /**
102 * Adds a signal to the data collected.
103 * \param psd signal to add
104 */
106 /**
107 * Removes a signal to the data collected.
108 * \param psd signal to subtract
109 */
111 /**
112 * Updates the data about the received Energy
113 */
115
117 Ptr<SpectrumValue> m_sumPowerSpectralDensity; //!< Sum of the received PSD
118 Ptr<SpectrumValue> m_energySpectralDensity; //!< Energy spectral density
119 double m_noisePowerSpectralDensity; //!< Noise power spectral density
120 Time m_resolution; //!< Time resolution
121 Time m_lastChangeTime; //!< When the last update happened
122 bool m_active; //!< True if the analyzer is active
123
124 /// TracedCallback - average power spectral density report.
126};
127
128} // namespace ns3
129
130#endif /* SPECTRUM_ANALYZER_H */
Smart pointer class similar to boost::intrusive_ptr.
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.
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.