20 #include "ns3/propagation-delay-model.h"
21 #include "ns3/spectrum-propagation-loss-model.h"
22 #include "ns3/mobility-model.h"
24 #include "ns3/config.h"
25 #include "ns3/simulator.h"
26 #include "ns3/names.h"
27 #include "ns3/antenna-model.h"
28 #include "ns3/spectrum-channel.h"
29 #include "ns3/spectrum-analyzer.h"
30 #include "ns3/non-communicating-net-device.h"
31 #include "ns3/output-stream-wrapper.h"
32 #include "ns3/trace-helper.h"
33 #include "spectrum-analyzer-helper.h"
44 WriteAveragePowerSpectralDensityReport (Ptr<OutputStreamWrapper> streamWrapper,
45 Ptr<const SpectrumValue> avgPowerSpectralDensity)
48 std::ostream* ostream = streamWrapper->GetStream ();
51 Bands::const_iterator fi = avgPowerSpectralDensity->ConstBandsBegin ();
52 Values::const_iterator vi = avgPowerSpectralDensity->ConstValuesBegin ();
53 while (fi != avgPowerSpectralDensity->ConstBandsEnd ())
55 NS_ASSERT (vi != avgPowerSpectralDensity->ConstValuesEnd ());
63 *ostream << std::endl;
69 SpectrumAnalyzerHelper::SpectrumAnalyzerHelper ()
72 m_phy.
SetTypeId (
"ns3::SpectrumAnalyzer");
73 m_device.
SetTypeId (
"ns3::NonCommunicatingNetDevice");
74 m_antenna.
SetTypeId (
"ns3::IsotropicAntennaModel");
77 SpectrumAnalyzerHelper::~SpectrumAnalyzerHelper ()
110 m_device.
Set (name, v);
126 factory.
Set (n0, v0);
127 factory.
Set (n1, v1);
128 factory.
Set (n2, v2);
129 factory.
Set (n3, v3);
130 factory.
Set (n4, v4);
131 factory.
Set (n5, v5);
132 factory.
Set (n6, v6);
133 factory.
Set (n7, v7);
142 m_rxSpectrumModel = m;
159 for (NodeContainer::Iterator i = c.
Begin (); i != c.
End (); ++i)
174 phy->SetDevice (dev);
176 NS_ASSERT_MSG (m_rxSpectrumModel,
"you forgot to call SpectrumAnalyzerHelper::SetRxSpectrumModel ()");
177 phy->SetRxSpectrumModel (m_rxSpectrumModel);
179 NS_ASSERT_MSG (m_channel,
"you forgot to call SpectrumAnalyzerHelper::SetChannel ()");
180 m_channel->AddRx (phy);
182 dev->SetChannel (m_channel);
185 NS_ASSERT_MSG (antenna,
"error in creating the AntennaModel object");
186 phy->SetAntenna (antenna);
191 if (!m_prefix.empty ())
193 NS_LOG_LOGIC (
"creating new output stream and binding it to the callback");
195 std::string filename;
202 std::ostringstream oss;
204 oss <<
"/NodeList/" << node->
GetId () <<
"/DeviceList/" << devId <<
"/$ns3::NonCommunicatingNetDevice/Phy/AveragePowerSpectralDensityReport";
225 Ptr<Node> node = Names::Find<Node> (nodeName);
Manage ASCII trace files for device models.
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
void SetAntenna(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
NetDeviceContainer Install(NodeContainer c) const
Hold a value for an Attribute.
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
void SetTypeId(TypeId tid)
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
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. ...
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...
Keep track of the current position and velocity of an object.
double GetSeconds(void) const
Ptr< Object > Create(void) const
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
holds a vector of ns3::NetDevice pointers
#define NS_LOG_LOGIC(msg)
void SetPhyAttribute(std::string name, const AttributeValue &v)
keep track of a set of node pointers.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void Set(std::string name, const AttributeValue &value)
#define NS_ASSERT_MSG(condition, message)
instantiate subclasses of ns3::Object.
uint32_t AddDevice(Ptr< NetDevice > device)
uint32_t GetId(void) const
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
void SetChannel(Ptr< SpectrumChannel > channel)
void SetRxSpectrumModel(Ptr< SpectrumModel > m)
void EnableAsciiAll(std::string prefix)
Ptr< T > GetObject(void) const
void ConnectWithoutContext(std::string path, const CallbackBase &cb)