Simple SpectrumPhy implementation that averages the spectrum power density of incoming transmissions to produce a spectrogram. More...
#include "spectrum-analyzer.h"
Public Member Functions | |
SpectrumAnalyzer () | |
~SpectrumAnalyzer () override | |
Ptr< Object > | GetAntenna () const override |
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception. | |
Ptr< NetDevice > | GetDevice () const override |
Get the associated NetDevice instance. | |
Ptr< MobilityModel > | GetMobility () const override |
Get the associated MobilityModel instance. | |
Ptr< const SpectrumModel > | GetRxSpectrumModel () 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. | |
![]() | |
SpectrumPhy () | |
SpectrumPhy (const SpectrumPhy &)=delete | |
~SpectrumPhy () override | |
virtual Ptr< Object > | GetAntenna () const =0 |
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception. | |
virtual Ptr< NetDevice > | GetDevice () const =0 |
Get the associated NetDevice instance. | |
virtual Ptr< MobilityModel > | GetMobility () const =0 |
Get the associated MobilityModel instance. | |
virtual Ptr< const SpectrumModel > | GetRxSpectrumModel () const =0 |
SpectrumPhy & | operator= (const SpectrumPhy &)=delete |
virtual void | SetChannel (Ptr< SpectrumChannel > c)=0 |
Set the channel attached to this device. | |
virtual void | SetDevice (Ptr< NetDevice > d)=0 |
Set the associated NetDevice instance. | |
virtual void | SetMobility (Ptr< MobilityModel > m)=0 |
Set the mobility model associated with this device. | |
virtual void | StartRx (Ptr< SpectrumSignalParameters > params)=0 |
Notify the SpectrumPhy instance of an incoming signal. | |
![]() | |
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< Object > | GetObject () 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< Object > | GetObject (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. | |
![]() | |
SimpleRefCount () | |
Default constructor. | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. | |
void | Ref () const |
Increment the reference count. | |
void | Unref () const |
Decrement the reference count. | |
![]() | |
virtual | ~ObjectBase () |
Virtual destructor. | |
void | GetAttribute (std::string name, AttributeValue &value) 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. | |
virtual TypeId | GetInstanceTypeId () const =0 |
Get the most derived TypeId for this Object. | |
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 TypeId | GetTypeId () |
Get the type ID. | |
![]() | |
static TypeId | GetTypeId () |
Register this type. | |
![]() | |
static TypeId | GetTypeId () |
Get the type ID. | |
Protected Member Functions | |
void | DoDispose () override |
Destructor implementation. | |
![]() | |
Object (const Object &o) | |
Copy an Object. | |
virtual void | DoDispose () |
Destructor implementation. | |
virtual void | DoInitialize () |
Initialize() implementation. | |
virtual void | NotifyNewAggregate () |
Notify all Objects aggregated to this one of a new Object being aggregated. | |
![]() | |
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< AntennaModel > | m_antenna |
Pointer to the Antenna model. | |
TracedCallback< Ptr< const SpectrumValue > > | m_averagePowerSpectralDensityReportTrace |
TracedCallback - average power spectral density report. | |
Ptr< SpectrumChannel > | m_channel |
Pointer to the channel to be analyzed. | |
Ptr< SpectrumValue > | m_energySpectralDensity |
Energy spectral density. | |
Time | m_lastChangeTime |
When the last update happened. | |
Ptr< MobilityModel > | m_mobility |
Pointer to the mobility model. | |
Ptr< NetDevice > | m_netDevice |
Pointer to the NetDevice using this object. | |
double | m_noisePowerSpectralDensity |
Noise power spectral density. | |
Time | m_resolution |
Time resolution. | |
Ptr< SpectrumModel > | m_spectrumModel |
Spectrum model. | |
Ptr< SpectrumValue > | m_sumPowerSpectralDensity |
Sum of the received PSD. | |
Additional Inherited Members | |
![]() | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
Simple SpectrumPhy implementation that averages the spectrum power density of incoming transmissions to produce a spectrogram.
Introspection did not find any typical Config paths.
This PHY model supports a single antenna model instance which is used for reception (this PHY model never transmits).
Time
+9.22337e+18ns:+9.22337e+18ns Size of this type is 136 bytes (on a 64-bit architecture).
Definition at line 47 of file spectrum-analyzer.h.
ns3::SpectrumAnalyzer::SpectrumAnalyzer | ( | ) |
Definition at line 36 of file spectrum-analyzer.cc.
References NS_LOG_FUNCTION.
|
override |
Definition at line 48 of file spectrum-analyzer.cc.
References NS_LOG_FUNCTION.
|
private |
Adds a signal to the data collected.
psd | signal to add |
Definition at line 158 of file spectrum-analyzer.cc.
References NS_LOG_FUNCTION, and UpdateEnergyReceivedSoFar().
Referenced by StartRx().
|
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 54 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.
|
privatevirtual |
Generates a report of the data collected so far.
This function is called periodically.
Definition at line 190 of file spectrum-analyzer.cc.
References GenerateReport(), ns3::Time::GetSeconds(), ns3::SpectrumValue::GetSpectrumModel(), 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().
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.
Implements ns3::SpectrumPhy.
Definition at line 137 of file spectrum-analyzer.cc.
References m_antenna.
Get the associated NetDevice instance.
Implements ns3::SpectrumPhy.
Definition at line 98 of file spectrum-analyzer.cc.
References m_netDevice.
|
overridevirtual |
Get the associated MobilityModel instance.
Implements ns3::SpectrumPhy.
Definition at line 104 of file spectrum-analyzer.cc.
References m_mobility.
|
overridevirtual |
Implements ns3::SpectrumPhy.
Definition at line 110 of file spectrum-analyzer.cc.
References m_spectrumModel.
|
static |
Get the type ID.
Definition at line 67 of file spectrum-analyzer.cc.
References m_averagePowerSpectralDensityReportTrace, m_noisePowerSpectralDensity, m_resolution, ns3::MakeDoubleAccessor(), ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), ns3::MilliSeconds(), and ns3::TypeId::SetParent().
void ns3::SpectrumAnalyzer::SetAntenna | ( | Ptr< AntennaModel > | a | ) |
Set the AntennaModel to be used.
a | the Antenna Model |
Definition at line 143 of file spectrum-analyzer.cc.
References m_antenna, and NS_LOG_FUNCTION.
|
overridevirtual |
Set the channel attached to this device.
c | the channel |
Implements ns3::SpectrumPhy.
Definition at line 130 of file spectrum-analyzer.cc.
References m_channel, and NS_LOG_FUNCTION.
Set the associated NetDevice instance.
d | the NetDevice instance |
Implements ns3::SpectrumPhy.
Definition at line 116 of file spectrum-analyzer.cc.
References m_netDevice, and NS_LOG_FUNCTION.
|
overridevirtual |
Set the mobility model associated with this device.
m | the mobility model |
Implements ns3::SpectrumPhy.
Definition at line 123 of file spectrum-analyzer.cc.
References m_mobility, and NS_LOG_FUNCTION.
void ns3::SpectrumAnalyzer::SetRxSpectrumModel | ( | Ptr< SpectrumModel > | m | ) |
Set the spectrum model used by the SpectrumAnalyzer to represent incoming signals.
m | the Rx Spectrum model |
Definition at line 213 of file spectrum-analyzer.cc.
References f(), m_energySpectralDensity, m_spectrumModel, m_sumPowerSpectralDensity, NS_ASSERT, and NS_LOG_FUNCTION.
|
virtual |
Start the spectrum analyzer.
Definition at line 224 of file spectrum-analyzer.cc.
References GenerateReport(), m_active, m_resolution, NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::Simulator::Schedule().
|
overridevirtual |
Notify the SpectrumPhy instance of an incoming signal.
params | the parameters of the signals being received |
Implements ns3::SpectrumPhy.
Definition at line 150 of file spectrum-analyzer.cc.
References AddSignal(), NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and SubtractSignal().
|
virtual |
Stop the spectrum analyzer.
Definition at line 236 of file spectrum-analyzer.cc.
References m_active.
|
private |
Removes a signal to the data collected.
psd | signal to subtract |
Definition at line 166 of file spectrum-analyzer.cc.
References NS_LOG_FUNCTION, and UpdateEnergyReceivedSoFar().
Referenced by StartRx().
|
private |
Updates the data about the received Energy.
Definition at line 174 of file spectrum-analyzer.cc.
References m_lastChangeTime, ns3::Now(), NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by AddSignal(), GenerateReport(), and SubtractSignal().
|
private |
True if the analyzer is active.
Definition at line 132 of file spectrum-analyzer.h.
Referenced by GenerateReport(), Start(), and Stop().
|
private |
Pointer to the Antenna model.
Definition at line 100 of file spectrum-analyzer.h.
Referenced by GetAntenna(), and SetAntenna().
|
private |
TracedCallback - average power spectral density report.
Definition at line 135 of file spectrum-analyzer.h.
Referenced by GenerateReport(), and GetTypeId().
|
private |
Pointer to the channel to be analyzed.
Definition at line 102 of file spectrum-analyzer.h.
Referenced by DoDispose(), and SetChannel().
|
private |
Energy spectral density.
Definition at line 128 of file spectrum-analyzer.h.
Referenced by DoDispose(), and SetRxSpectrumModel().
|
private |
When the last update happened.
Definition at line 131 of file spectrum-analyzer.h.
Referenced by UpdateEnergyReceivedSoFar().
|
private |
Pointer to the mobility model.
Definition at line 99 of file spectrum-analyzer.h.
Referenced by DoDispose(), GetMobility(), and SetMobility().
Pointer to the NetDevice using this object.
Definition at line 101 of file spectrum-analyzer.h.
Referenced by DoDispose(), GetDevice(), and SetDevice().
|
private |
Noise power spectral density.
Definition at line 129 of file spectrum-analyzer.h.
Referenced by GenerateReport(), and GetTypeId().
|
private |
Time resolution.
Definition at line 130 of file spectrum-analyzer.h.
Referenced by GenerateReport(), GetTypeId(), and Start().
|
private |
Spectrum model.
Definition at line 126 of file spectrum-analyzer.h.
Referenced by DoDispose(), GetRxSpectrumModel(), and SetRxSpectrumModel().
|
private |
Sum of the received PSD.
Definition at line 127 of file spectrum-analyzer.h.
Referenced by DoDispose(), GenerateReport(), and SetRxSpectrumModel().