11#include <ns3/antenna-model.h>
12#include <ns3/double.h>
14#include <ns3/object-factory.h>
15#include <ns3/simulator.h>
16#include <ns3/trace-source-accessor.h>
26 : m_mobility(nullptr),
29 m_spectrumModel(nullptr),
30 m_sumPowerSpectralDensity(nullptr),
59 TypeId(
"ns3::SpectrumAnalyzer")
61 .SetGroupName(
"Spectrum")
63 .AddAttribute(
"Resolution",
64 "The length of the time interval over which the "
65 "power spectral density of incoming signals is averaged",
69 .AddAttribute(
"NoisePowerSpectralDensity",
70 "The power spectral density of the measuring instrument "
71 "noise, in Watt/Hz. Mostly useful to make spectrograms "
72 "look more similar to those obtained by real devices. "
73 "Defaults to the value for thermal noise at 300K.",
77 .AddTraceSource(
"AveragePowerSpectralDensityReport",
78 "Trace fired whenever a new value for the average "
79 "Power Spectral Density is calculated",
82 "ns3::SpectrumValue::TracedCallback");
151 (*m_sumPowerSpectralDensity) += (*psd);
159 (*m_sumPowerSpectralDensity) -= (*psd);
168 (*m_energySpectralDensity) +=
188 (*m_energySpectralDensity) = 0;
193 *avgPowerSpectralDensity = 0;
This class can be used to hold variables of floating point type such as 'double' or 'float'.
virtual void DoDispose()
Destructor implementation.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
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.
~SpectrumAnalyzer() override
Ptr< NetDevice > m_netDevice
Pointer to the NetDevice using this object.
Abstract base class for Spectrum-aware PHY layers.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeChecker > MakeDoubleChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.