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. | |
Public Member Functions inherited from ns3::SpectrumPhy | |
SpectrumPhy () | |
SpectrumPhy (const SpectrumPhy &)=delete | |
~SpectrumPhy () override | |
SpectrumPhy & | operator= (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< 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. | |
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. | |
SimpleRefCount & | operator= (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< 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 | |
Related Symbols inherited from ns3::ObjectBase | |
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.
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.
ns3::SpectrumAnalyzer::SpectrumAnalyzer | ( | ) |
Definition at line 25 of file spectrum-analyzer.cc.
References NS_LOG_FUNCTION.
|
override |
Definition at line 37 of file spectrum-analyzer.cc.
References NS_LOG_FUNCTION.
|
private |
Adds a signal to the data collected.
psd | signal to add |
Definition at line 147 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 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.
|
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().
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 126 of file spectrum-analyzer.cc.
References m_antenna.
Get the associated NetDevice instance.
Implements ns3::SpectrumPhy.
Definition at line 87 of file spectrum-analyzer.cc.
References m_netDevice.
|
overridevirtual |
Get the associated MobilityModel instance.
Implements ns3::SpectrumPhy.
Definition at line 93 of file spectrum-analyzer.cc.
References m_mobility.
|
overridevirtual |
Implements ns3::SpectrumPhy.
Definition at line 99 of file spectrum-analyzer.cc.
References m_spectrumModel.
|
static |
Get the type ID.
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().
void ns3::SpectrumAnalyzer::SetAntenna | ( | Ptr< AntennaModel > | a | ) |
Set the AntennaModel to be used.
a | the Antenna Model |
Definition at line 132 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 119 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 105 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 112 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 202 of file spectrum-analyzer.cc.
References ns3::Create(), m_energySpectralDensity, m_spectrumModel, m_sumPowerSpectralDensity, NS_ASSERT, and NS_LOG_FUNCTION.
|
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().
|
overridevirtual |
Notify the SpectrumPhy instance of an incoming signal.
params | the 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().
|
virtual |
Stop the spectrum analyzer.
Definition at line 225 of file spectrum-analyzer.cc.
References m_active.
|
private |
Removes a signal to the data collected.
psd | signal to subtract |
Definition at line 155 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 163 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 122 of file spectrum-analyzer.h.
Referenced by GenerateReport(), Start(), and Stop().
|
private |
Pointer to the Antenna model.
Definition at line 90 of file spectrum-analyzer.h.
Referenced by GetAntenna(), and SetAntenna().
|
private |
TracedCallback - average power spectral density report.
Definition at line 125 of file spectrum-analyzer.h.
Referenced by GenerateReport(), and GetTypeId().
|
private |
Pointer to the channel to be analyzed.
Definition at line 92 of file spectrum-analyzer.h.
Referenced by DoDispose(), and SetChannel().
|
private |
Energy spectral density.
Definition at line 118 of file spectrum-analyzer.h.
Referenced by DoDispose(), and SetRxSpectrumModel().
|
private |
When the last update happened.
Definition at line 121 of file spectrum-analyzer.h.
Referenced by UpdateEnergyReceivedSoFar().
|
private |
Pointer to the mobility model.
Definition at line 89 of file spectrum-analyzer.h.
Referenced by DoDispose(), GetMobility(), and SetMobility().
Pointer to the NetDevice using this object.
Definition at line 91 of file spectrum-analyzer.h.
Referenced by DoDispose(), GetDevice(), and SetDevice().
|
private |
Noise power spectral density.
Definition at line 119 of file spectrum-analyzer.h.
Referenced by GenerateReport(), and GetTypeId().
|
private |
Time resolution.
Definition at line 120 of file spectrum-analyzer.h.
Referenced by GenerateReport(), GetTypeId(), and Start().
|
private |
Spectrum model.
Definition at line 116 of file spectrum-analyzer.h.
Referenced by DoDispose(), GetRxSpectrumModel(), and SetRxSpectrumModel().
|
private |
Sum of the received PSD.
Definition at line 117 of file spectrum-analyzer.h.
Referenced by DoDispose(), GenerateReport(), and SetRxSpectrumModel().