A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::SpectrumAnalyzer Class Reference

Simple SpectrumPhy implementation that averages the spectrum power density of incoming transmissions to produce a spectrogram. More...

#include "spectrum-analyzer.h"

+ Inheritance diagram for ns3::SpectrumAnalyzer:
+ Collaboration diagram for ns3::SpectrumAnalyzer:

Public Member Functions

 SpectrumAnalyzer ()
 
 ~SpectrumAnalyzer () override
 
Ptr< ObjectGetAntenna () const override
 Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.
 
Ptr< NetDeviceGetDevice () const override
 Get the associated NetDevice instance.
 
Ptr< MobilityModelGetMobility () const override
 Get the associated MobilityModel instance.
 
Ptr< const SpectrumModelGetRxSpectrumModel () const override
 
void SetAntenna (Ptr< AntennaModel > a)
 Set the AntennaModel to be used.
 
void SetChannel (Ptr< SpectrumChannel > c) override
 Set the channel attached to this device.
 
void SetDevice (Ptr< NetDevice > d) override
 Set the associated NetDevice instance.
 
void SetMobility (Ptr< MobilityModel > m) override
 Set the mobility model associated with this device.
 
void SetRxSpectrumModel (Ptr< SpectrumModel > m)
 Set the spectrum model used by the SpectrumAnalyzer to represent incoming signals.
 
virtual void Start ()
 Start the spectrum analyzer.
 
void StartRx (Ptr< SpectrumSignalParameters > params) override
 Notify the SpectrumPhy instance of an incoming signal.
 
virtual void Stop ()
 Stop the spectrum analyzer.
 
- Public Member Functions inherited from ns3::SpectrumPhy
 SpectrumPhy ()
 
 SpectrumPhy (const SpectrumPhy &)=delete
 
 ~SpectrumPhy () override
 
SpectrumPhyoperator= (const SpectrumPhy &)=delete
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::SpectrumPhy
static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Protected Member Functions

void DoDispose () override
 Destructor implementation.
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
virtual void DoInitialize ()
 Initialize() implementation.
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated.
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Private Member Functions

void AddSignal (Ptr< const SpectrumValue > psd)
 Adds a signal to the data collected.
 
virtual void GenerateReport ()
 Generates a report of the data collected so far.
 
void SubtractSignal (Ptr< const SpectrumValue > psd)
 Removes a signal to the data collected.
 
void UpdateEnergyReceivedSoFar ()
 Updates the data about the received Energy.
 

Private Attributes

bool m_active
 True if the analyzer is active.
 
Ptr< AntennaModelm_antenna
 Pointer to the Antenna model.
 
TracedCallback< Ptr< const SpectrumValue > > m_averagePowerSpectralDensityReportTrace
 TracedCallback - average power spectral density report.
 
Ptr< SpectrumChannelm_channel
 Pointer to the channel to be analyzed.
 
Ptr< SpectrumValuem_energySpectralDensity
 Energy spectral density.
 
Time m_lastChangeTime
 When the last update happened.
 
Ptr< MobilityModelm_mobility
 Pointer to the mobility model.
 
Ptr< NetDevicem_netDevice
 Pointer to the NetDevice using this object.
 
double m_noisePowerSpectralDensity
 Noise power spectral density.
 
Time m_resolution
 Time resolution.
 
Ptr< SpectrumModelm_spectrumModel
 Spectrum model.
 
Ptr< SpectrumValuem_sumPowerSpectralDensity
 Sum of the received PSD.
 

Additional Inherited Members

Detailed Description

Simple SpectrumPhy implementation that averages the spectrum power density of incoming transmissions to produce a spectrogram.

This PHY model supports a single antenna model instance which is used for reception (this PHY model never transmits).

Definition at line 37 of file spectrum-analyzer.h.

Constructor & Destructor Documentation

◆ SpectrumAnalyzer()

ns3::SpectrumAnalyzer::SpectrumAnalyzer ( )

Definition at line 25 of file spectrum-analyzer.cc.

References NS_LOG_FUNCTION.

◆ ~SpectrumAnalyzer()

ns3::SpectrumAnalyzer::~SpectrumAnalyzer ( )
override

Definition at line 37 of file spectrum-analyzer.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ AddSignal()

void ns3::SpectrumAnalyzer::AddSignal ( Ptr< const SpectrumValue > psd)
private

Adds a signal to the data collected.

Parameters
psdsignal to add

Definition at line 147 of file spectrum-analyzer.cc.

References NS_LOG_FUNCTION, and UpdateEnergyReceivedSoFar().

Referenced by StartRx().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoDispose()

void ns3::SpectrumAnalyzer::DoDispose ( )
overrideprotectedvirtual

Destructor implementation.

This method is called by Dispose() or by the Object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overridden version of this method and chain up to their parent's implementation once they are done. i.e, for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose() method.

It is safe to call GetObject() from within this method.

Reimplemented from ns3::Object.

Definition at line 43 of file spectrum-analyzer.cc.

References ns3::Object::DoDispose(), m_channel, m_energySpectralDensity, m_mobility, m_netDevice, m_spectrumModel, m_sumPowerSpectralDensity, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ GenerateReport()

void ns3::SpectrumAnalyzer::GenerateReport ( )
privatevirtual

Generates a report of the data collected so far.

This function is called periodically.

Definition at line 179 of file spectrum-analyzer.cc.

References ns3::Create(), GenerateReport(), ns3::Time::GetSeconds(), m_active, m_averagePowerSpectralDensityReportTrace, m_noisePowerSpectralDensity, m_resolution, m_sumPowerSpectralDensity, NS_LOG_FUNCTION, NS_LOG_INFO, ns3::Simulator::Schedule(), and UpdateEnergyReceivedSoFar().

Referenced by GenerateReport(), and Start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAntenna()

Ptr< Object > ns3::SpectrumAnalyzer::GetAntenna ( ) const
overridevirtual

Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.

Note that in general and depending on each module design, there can be multiple SpectrumPhy instances per NetDevice.

Returns
a Ptr to the AntennaModel used by this SpectrumPhy instance for transmission and/or reception

Implements ns3::SpectrumPhy.

Definition at line 126 of file spectrum-analyzer.cc.

References m_antenna.

◆ GetDevice()

Ptr< NetDevice > ns3::SpectrumAnalyzer::GetDevice ( ) const
overridevirtual

Get the associated NetDevice instance.

Returns
a Ptr to the associated NetDevice instance

Implements ns3::SpectrumPhy.

Definition at line 87 of file spectrum-analyzer.cc.

References m_netDevice.

◆ GetMobility()

Ptr< MobilityModel > ns3::SpectrumAnalyzer::GetMobility ( ) const
overridevirtual

Get the associated MobilityModel instance.

Returns
a Ptr to the associated MobilityModel instance

Implements ns3::SpectrumPhy.

Definition at line 93 of file spectrum-analyzer.cc.

References m_mobility.

◆ GetRxSpectrumModel()

Ptr< const SpectrumModel > ns3::SpectrumAnalyzer::GetRxSpectrumModel ( ) const
overridevirtual
Returns
returns the SpectrumModel that this SpectrumPhy expects to be used for all SpectrumValues that are passed to StartRx. If 0 is returned, it means that any model will be accepted.

Implements ns3::SpectrumPhy.

Definition at line 99 of file spectrum-analyzer.cc.

References m_spectrumModel.

◆ GetTypeId()

TypeId ns3::SpectrumAnalyzer::GetTypeId ( )
static

Get the type ID.

Returns
the object TypeId

Definition at line 56 of file spectrum-analyzer.cc.

References m_averagePowerSpectralDensityReportTrace, m_noisePowerSpectralDensity, m_resolution, ns3::MakeDoubleAccessor(), ns3::MakeDoubleChecker(), ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), ns3::MilliSeconds(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ SetAntenna()

void ns3::SpectrumAnalyzer::SetAntenna ( Ptr< AntennaModel > a)

Set the AntennaModel to be used.

Parameters
athe Antenna Model

Definition at line 132 of file spectrum-analyzer.cc.

References m_antenna, and NS_LOG_FUNCTION.

◆ SetChannel()

void ns3::SpectrumAnalyzer::SetChannel ( Ptr< SpectrumChannel > c)
overridevirtual

Set the channel attached to this device.

Parameters
cthe channel

Implements ns3::SpectrumPhy.

Definition at line 119 of file spectrum-analyzer.cc.

References m_channel, and NS_LOG_FUNCTION.

◆ SetDevice()

void ns3::SpectrumAnalyzer::SetDevice ( Ptr< NetDevice > d)
overridevirtual

Set the associated NetDevice instance.

Parameters
dthe NetDevice instance

Implements ns3::SpectrumPhy.

Definition at line 105 of file spectrum-analyzer.cc.

References m_netDevice, and NS_LOG_FUNCTION.

◆ SetMobility()

void ns3::SpectrumAnalyzer::SetMobility ( Ptr< MobilityModel > m)
overridevirtual

Set the mobility model associated with this device.

Parameters
mthe mobility model

Implements ns3::SpectrumPhy.

Definition at line 112 of file spectrum-analyzer.cc.

References m_mobility, and NS_LOG_FUNCTION.

◆ SetRxSpectrumModel()

void ns3::SpectrumAnalyzer::SetRxSpectrumModel ( Ptr< SpectrumModel > m)

Set the spectrum model used by the SpectrumAnalyzer to represent incoming signals.

Parameters
mthe Rx Spectrum model

Definition at line 202 of file spectrum-analyzer.cc.

References ns3::Create(), m_energySpectralDensity, m_spectrumModel, m_sumPowerSpectralDensity, NS_ASSERT, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ Start()

void ns3::SpectrumAnalyzer::Start ( )
virtual

Start the spectrum analyzer.

Definition at line 213 of file spectrum-analyzer.cc.

References GenerateReport(), m_active, m_resolution, NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::Simulator::Schedule().

+ Here is the call graph for this function:

◆ StartRx()

void ns3::SpectrumAnalyzer::StartRx ( Ptr< SpectrumSignalParameters > params)
overridevirtual

Notify the SpectrumPhy instance of an incoming signal.

Parameters
paramsthe parameters of the signals being received

Implements ns3::SpectrumPhy.

Definition at line 139 of file spectrum-analyzer.cc.

References AddSignal(), NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and SubtractSignal().

+ Here is the call graph for this function:

◆ Stop()

void ns3::SpectrumAnalyzer::Stop ( )
virtual

Stop the spectrum analyzer.

Definition at line 225 of file spectrum-analyzer.cc.

References m_active.

◆ SubtractSignal()

void ns3::SpectrumAnalyzer::SubtractSignal ( Ptr< const SpectrumValue > psd)
private

Removes a signal to the data collected.

Parameters
psdsignal to subtract

Definition at line 155 of file spectrum-analyzer.cc.

References NS_LOG_FUNCTION, and UpdateEnergyReceivedSoFar().

Referenced by StartRx().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateEnergyReceivedSoFar()

void ns3::SpectrumAnalyzer::UpdateEnergyReceivedSoFar ( )
private

Updates the data about the received Energy.

Definition at line 163 of file spectrum-analyzer.cc.

References m_lastChangeTime, ns3::Now(), NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by AddSignal(), GenerateReport(), and SubtractSignal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_active

bool ns3::SpectrumAnalyzer::m_active
private

True if the analyzer is active.

Definition at line 122 of file spectrum-analyzer.h.

Referenced by GenerateReport(), Start(), and Stop().

◆ m_antenna

Ptr<AntennaModel> ns3::SpectrumAnalyzer::m_antenna
private

Pointer to the Antenna model.

Definition at line 90 of file spectrum-analyzer.h.

Referenced by GetAntenna(), and SetAntenna().

◆ m_averagePowerSpectralDensityReportTrace

TracedCallback<Ptr<const SpectrumValue> > ns3::SpectrumAnalyzer::m_averagePowerSpectralDensityReportTrace
private

TracedCallback - average power spectral density report.

Definition at line 125 of file spectrum-analyzer.h.

Referenced by GenerateReport(), and GetTypeId().

◆ m_channel

Ptr<SpectrumChannel> ns3::SpectrumAnalyzer::m_channel
private

Pointer to the channel to be analyzed.

Definition at line 92 of file spectrum-analyzer.h.

Referenced by DoDispose(), and SetChannel().

◆ m_energySpectralDensity

Ptr<SpectrumValue> ns3::SpectrumAnalyzer::m_energySpectralDensity
private

Energy spectral density.

Definition at line 118 of file spectrum-analyzer.h.

Referenced by DoDispose(), and SetRxSpectrumModel().

◆ m_lastChangeTime

Time ns3::SpectrumAnalyzer::m_lastChangeTime
private

When the last update happened.

Definition at line 121 of file spectrum-analyzer.h.

Referenced by UpdateEnergyReceivedSoFar().

◆ m_mobility

Ptr<MobilityModel> ns3::SpectrumAnalyzer::m_mobility
private

Pointer to the mobility model.

Definition at line 89 of file spectrum-analyzer.h.

Referenced by DoDispose(), GetMobility(), and SetMobility().

◆ m_netDevice

Ptr<NetDevice> ns3::SpectrumAnalyzer::m_netDevice
private

Pointer to the NetDevice using this object.

Definition at line 91 of file spectrum-analyzer.h.

Referenced by DoDispose(), GetDevice(), and SetDevice().

◆ m_noisePowerSpectralDensity

double ns3::SpectrumAnalyzer::m_noisePowerSpectralDensity
private

Noise power spectral density.

Definition at line 119 of file spectrum-analyzer.h.

Referenced by GenerateReport(), and GetTypeId().

◆ m_resolution

Time ns3::SpectrumAnalyzer::m_resolution
private

Time resolution.

Definition at line 120 of file spectrum-analyzer.h.

Referenced by GenerateReport(), GetTypeId(), and Start().

◆ m_spectrumModel

Ptr<SpectrumModel> ns3::SpectrumAnalyzer::m_spectrumModel
private

Spectrum model.

Definition at line 116 of file spectrum-analyzer.h.

Referenced by DoDispose(), GetRxSpectrumModel(), and SetRxSpectrumModel().

◆ m_sumPowerSpectralDensity

Ptr<SpectrumValue> ns3::SpectrumAnalyzer::m_sumPowerSpectralDensity
private

Sum of the received PSD.

Definition at line 117 of file spectrum-analyzer.h.

Referenced by DoDispose(), GenerateReport(), and SetRxSpectrumModel().


The documentation for this class was generated from the following files: