|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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 .SetGroupName (
"Spectrum")
76 .AddAttribute (
"Resolution",
77 "The length of the time interval over which the "
78 "power spectral density of incoming signals is averaged",
82 .AddAttribute (
"NoisePowerSpectralDensity",
83 "The power spectral density of the measuring instrument "
84 "noise, in Watt/Hz. Mostly useful to make spectrograms "
85 "look more similar to those obtained by real devices. "
86 "Defaults to the value for thermal noise at 300K.",
89 MakeDoubleChecker<double> ())
90 .AddTraceSource (
"AveragePowerSpectralDensityReport",
91 "Trace fired whenever a new value for the average "
92 "Power Spectral Density is calculated",
94 "ns3::SpectrumValue::TracedCallback")
174 (*m_sumPowerSpectralDensity) += (*psd);
182 (*m_sumPowerSpectralDensity) -= (*psd);
191 (*m_energySpectralDensity) += (*m_sumPowerSpectralDensity) * ((
Now () -
m_lastChangeTime).GetSeconds ());
209 (*m_energySpectralDensity) = 0;
214 *avgPowerSpectralDensity = 0;
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< const SpectrumModel > GetRxSpectrumModel() const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
Ptr< AntennaModel > m_antenna
Pointer to the Antenna model.
Ptr< SpectrumChannel > m_channel
Pointer to the channel to be analyzed.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< NetDevice > m_netDevice
Pointer to the NetDevice using this object.
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming signal.
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
void SetAntenna(Ptr< AntennaModel > a)
Set the AntennaModel to be used.
bool m_active
True if the analyzer is active.
Ptr< NetDevice > GetDevice() const
Get the associated NetDevice instance.
Ptr< const SpectrumModel > GetSpectrumModel() const
void DoDispose()
Destructor implementation.
Ptr< MobilityModel > GetMobility() const
Get the associated MobilityModel instance.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void AddSignal(Ptr< const SpectrumValue > psd)
Adds a signal to the data collected.
void SetRxSpectrumModel(Ptr< SpectrumModel > m)
Set the spectrum model used by the SpectrumAnalyzer to represent incoming signals.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
void SetDevice(Ptr< NetDevice > d)
Set the associated NetDevice instance.
Ptr< SpectrumValue > m_sumPowerSpectralDensity
Sum of the received PSD.
virtual void Stop()
Stop the spectrum analyzer.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Abstract base class for Spectrum-aware PHY layers.
TracedCallback< Ptr< const SpectrumValue > > m_averagePowerSpectralDensityReportTrace
TracedCallback - average power spectral density report.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void SubtractSignal(Ptr< const SpectrumValue > psd)
Removes a signal to the data collected.
virtual ~SpectrumAnalyzer()
static TypeId GetTypeId(void)
Get the type ID.
void UpdateEnergyReceivedSoFar()
Updates the data about the received Energy.
Ptr< AntennaModel > GetRxAntenna() const
Get the AntennaModel used by the NetDevice for reception.
virtual void GenerateReport()
Generates a report of the data collected so far.
double f(double x, void *params)
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< SpectrumModel > m_spectrumModel
Spectrum model.
Ptr< SpectrumValue > m_energySpectralDensity
Energy spectral density.
double m_noisePowerSpectralDensity
Noise power spectral density.
Time m_lastChangeTime
When the last update happened.
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
Simple SpectrumPhy implementation that averages the spectrum power density of incoming transmissions ...
Time m_resolution
Time resolution.
virtual void Start()
Start the spectrum analyzer.
virtual void DoDispose(void)
Destructor implementation.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.