22 #include <ns3/object-factory.h>
24 #include <ns3/double.h>
25 #include <ns3/simulator.h>
26 #include <ns3/trace-source-accessor.h>
27 #include <ns3/antenna-model.h>
43 m_sumPowerSpectralDensity (0),
44 m_resolution (MilliSeconds (50)),
75 .AddConstructor<SpectrumAnalyzer> ()
76 .AddAttribute (
"Resolution",
77 "the lengh of the time interval over which the power spectral "
78 "density of incoming signals is averaged",
82 .AddAttribute (
"NoisePowerSpectralDensity",
83 "the power spectral density of the measuring instrument noise, in Watt/Hz. Mostly useful to make spectrograms look more similar to those obtained by real devices. Defaults to the value for thermal noise at 300K.",
86 MakeDoubleChecker<double> ())
87 .AddTraceSource (
"AveragePowerSpectralDensityReport",
88 "Trace fired whenever a new value for the average Power Spectral Density is calculated",
169 (*m_sumPowerSpectralDensity) += (*psd);
177 (*m_sumPowerSpectralDensity) -= (*psd);
186 (*m_energySpectralDensity) += (*m_sumPowerSpectralDensity) * ((
Now () -
m_lastChangeTime).GetSeconds ());
204 (*m_energySpectralDensity) = 0;
209 *avgPowerSpectralDensity = 0;
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
Abstract base class for Spectrum-aware PHY layers.
Ptr< NetDevice > m_netDevice
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming signal.
double m_noisePowerSpectralDensity
Ptr< NetDevice > GetDevice()
get the associated NetDevice instance
Ptr< AntennaModel > m_antenna
#define NS_ASSERT(condition)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual void Start()
Start the spectrum analyzer.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
double GetSeconds(void) const
Ptr< SpectrumChannel > m_channel
hold objects of type ns3::Time
virtual ~SpectrumAnalyzer()
static TypeId GetTypeId(void)
virtual void Stop()
Stop the spectrum analyzer.
void SetRxSpectrumModel(Ptr< SpectrumModel > m)
Set the spectrum model used by the SpectrumAnalyzer to represent incoming signals.
NS_LOG_COMPONENT_DEFINE("SpectrumAnalyzer")
#define NS_LOG_LOGIC(msg)
void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
void SetDevice(Ptr< NetDevice > d)
set the associated NetDevice instance
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
void AddSignal(Ptr< const SpectrumValue > psd)
TracedCallback< Ptr< const SpectrumValue > > m_averagePowerSpectralDensityReportTrace
Ptr< SpectrumValue > m_sumPowerSpectralDensity
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Ptr< SpectrumModel > m_spectrumModel
Ptr< MobilityModel > GetMobility()
get the associated MobilityModel instance
virtual void GenerateReport()
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< const SpectrumModel > GetRxSpectrumModel() const
Ptr< AntennaModel > GetRxAntenna()
get the AntennaModel used by the NetDevice for reception
Hold a floating point type.
void SubtractSignal(Ptr< const SpectrumValue > psd)
a unique identifier for an interface.
Ptr< MobilityModel > m_mobility
TypeId SetParent(TypeId tid)
Ptr< SpectrumValue > m_energySpectralDensity
void SetAntenna(Ptr< AntennaModel > a)
set the AntennaModel to be used
void UpdateEnergyReceivedSoFar()