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>
42 m_sumPowerSpectralDensity (0),
74 .AddConstructor<SpectrumAnalyzer> ()
75 .AddAttribute (
"Resolution",
76 "the lengh of the time interval over which the power spectral "
77 "density of incoming signals is averaged",
81 .AddAttribute (
"NoisePowerSpectralDensity",
82 "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.",
85 MakeDoubleChecker<double> ())
86 .AddTraceSource (
"AveragePowerSpectralDensityReport",
87 "Trace fired whenever a new value for the average Power Spectral Density is calculated",
168 (*m_sumPowerSpectralDensity) += (*psd);
176 (*m_sumPowerSpectralDensity) -= (*psd);
185 (*m_energySpectralDensity) += (*m_sumPowerSpectralDensity) * ((
Now () -
m_lastChangeTime).GetSeconds ());
203 (*m_energySpectralDensity) = 0;
208 *avgPowerSpectralDensity = 0;
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Abstract base class for Spectrum-aware PHY layers.
Ptr< NetDevice > m_netDevice
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
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)
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.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
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...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
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.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Ptr< SpectrumChannel > m_channel
Attribute for objects of type ns3::Time.
virtual ~SpectrumAnalyzer()
Ptr< const SpectrumModel > GetSpectrumModel() const
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.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
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 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()