10#include "ns3/antenna-model.h"
11#include "ns3/config.h"
13#include "ns3/mobility-model.h"
15#include "ns3/non-communicating-net-device.h"
16#include "ns3/output-stream-wrapper.h"
17#include "ns3/propagation-delay-model.h"
18#include "ns3/simulator.h"
19#include "ns3/spectrum-analyzer.h"
20#include "ns3/spectrum-channel.h"
21#include "ns3/spectrum-propagation-loss-model.h"
22#include "ns3/trace-helper.h"
40 std::ostream* ostream = streamWrapper->GetStream();
43 auto fi = avgPowerSpectralDensity->ConstBandsBegin();
44 auto vi = avgPowerSpectralDensity->ConstValuesBegin();
45 while (fi != avgPowerSpectralDensity->ConstBandsEnd())
47 NS_ASSERT(vi != avgPowerSpectralDensity->ConstValuesEnd());
48 *ostream <<
Now().
GetSeconds() <<
" " << fi->fc <<
" " << *vi << std::endl;
53 *ostream << std::endl;
118 for (
auto i = c.
Begin(); i != c.
End(); ++i)
137 "you forgot to call SpectrumAnalyzerHelper::SetRxSpectrumModel ()");
146 NS_ASSERT_MSG(antenna,
"error in creating the AntennaModel object");
147 phy->SetAntenna(antenna);
149 uint32_t devId = node->AddDevice(dev);
154 NS_LOG_LOGIC(
"creating new output stream and binding it to the callback");
156 std::string filename;
164 std::ostringstream oss;
166 oss <<
"/NodeList/" << node->GetId() <<
"/DeviceList/" << devId
167 <<
"/$ns3::NonCommunicatingNetDevice/Phy/AveragePowerSpectralDensityReport";
Manage ASCII trace files for device models.
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the ascii trace helper figure out a reasonable filename to use for an ascii trace file associated...
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
Hold a value for an Attribute.
Keep track of the current position and velocity of an object.
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
This class implements a device which does not communicate, in the sense that it does not interact wit...
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Smart pointer class similar to boost::intrusive_ptr.
ObjectFactory m_phy
Object factory for the phy objects.
NetDeviceContainer Install(NodeContainer c) const
Ptr< SpectrumModel > m_rxSpectrumModel
Spectrum model.
void SetPhyAttribute(std::string name, const AttributeValue &v)
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
void SetChannel(Ptr< SpectrumChannel > channel)
Set the SpectrumChannel that will be used by SpectrumPhy instances created by this helper.
ObjectFactory m_antenna
Object factory for the Antenna objects.
~SpectrumAnalyzerHelper()
std::string m_prefix
Prefix for the output files.
void EnableAsciiAll(std::string prefix)
Enable ASCII output.
Ptr< SpectrumChannel > m_channel
Channel.
ObjectFactory m_device
Object factory for the NetDevice objects.
void SetRxSpectrumModel(Ptr< SpectrumModel > m)
Set the spectrum model used by the created SpectrumAnalyzer instances to represent incoming signals.
Simple SpectrumPhy implementation that averages the spectrum power density of incoming transmissions ...
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Time Now()
create an ns3::Time instance which contains the current simulation time.
static void WriteAveragePowerSpectralDensityReport(Ptr< OutputStreamWrapper > streamWrapper, Ptr< const SpectrumValue > avgPowerSpectralDensity)
Writes a report of the Average Power Spectral Density.
Every class exported by the ns3 library is enclosed in the ns3 namespace.