|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
21 #include "ns3/abort.h"
23 #include "ns3/simulator.h"
24 #include "ns3/object-factory.h"
25 #include "ns3/queue.h"
26 #include "ns3/net-device-queue-interface.h"
27 #include "ns3/csma-net-device.h"
28 #include "ns3/csma-channel.h"
29 #include "ns3/config.h"
30 #include "ns3/packet.h"
31 #include "ns3/names.h"
33 #include "ns3/trace-helper.h"
88 NS_LOG_INFO (
"CsmaHelper::EnablePcapInternal(): Device " << device <<
" not of type ns3::CsmaNetDevice");
121 bool explicitFilename)
131 NS_LOG_INFO (
"CsmaHelper::EnableAsciiInternal(): Device " << device <<
" not of type ns3::CsmaNetDevice");
156 std::string filename;
157 if (explicitFilename)
199 std::ostringstream oss;
201 oss <<
"/NodeList/" << nd->
GetNode ()->
GetId () <<
"/DeviceList/" << deviceid <<
"/$ns3::CsmaNetDevice/MacRx";
205 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::CsmaNetDevice/TxQueue/Enqueue";
209 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::CsmaNetDevice/TxQueue/Dequeue";
213 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::CsmaNetDevice/TxQueue/Drop";
227 Ptr<Node> node = Names::Find<Node> (nodeName);
247 Ptr<Node> node = Names::Find<Node> (nodeName);
254 Ptr<Node> node = Names::Find<Node> (nodeName);
290 int64_t currentStream = stream;
298 currentStream +=
csma->AssignStreams (currentStream);
301 return (currentStream - stream);
311 device->SetQueue (queue);
315 ndqi->GetTxQueue (0)->ConnectQueueTraces (queue);
316 device->AggregateObject (ndqi);
holds a vector of ns3::NetDevice pointers
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, DataLinkType dataLinkType, uint32_t snapLen=std::numeric_limits< uint32_t >::max(), int32_t tzCorrection=0)
Create and initialize a pcap file.
uint32_t GetId(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the pcap helper figure out a reasonable filename to use for a pcap file associated with a device.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
static void EnablePrinting(void)
Enable printing packets metadata.
Hold a value for an Attribute.
CsmaHelper()
Construct a CsmaHelper.
void HookDefaultSink(Ptr< T > object, std::string traceName, Ptr< PcapFileWrapper > file)
Hook a trace source to the default trace sink.
void HookDefaultEnqueueSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default enqueue operation trace sink that does not accept nor log a trace ...
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
ObjectFactory m_channelFactory
factory for the channel
static void AppendItemTypeIfNotPresent(std::string &typeId, const std::string &itemType)
Append the item type to the provided type ID if the latter does not end with '>'.
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output on the indicated net device.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
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.
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
virtual Ptr< Node > GetNode(void) const =0
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
ObjectFactory m_queueFactory
factory for the queues
void HookDefaultReceiveSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default receive operation trace sink that does not accept nor log a trace ...
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Manage pcap files for device models.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
ObjectFactory m_deviceFactory
factory for the NetDevices
Ptr< NetDevice > InstallPriv(Ptr< Node > node, Ptr< CsmaChannel > channel) const
This method creates an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttr...
static void DefaultReceiveSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Receive default trace sink.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Manage ASCII trace files for device models.
void SetQueue(std::string type, 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::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
void Connect(std::string path, const CallbackBase &cb)
Ptr< Queue< Packet > > GetQueue(void) const
Get a copy of the attached Queue.
static void DefaultDequeueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Dequeue default trace sink.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)
Enable pcap output on the indicated net device.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
keep track of a set of node pointers.
void HookDefaultDropSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default drop operation trace sink that does not accept nor log a trace con...
A Device for a Csma Network Link.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
static void DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Drop default trace sink.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
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...
static void DefaultEnqueueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Enqueue default trace sink.
virtual uint32_t GetIfIndex(void) const =0
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
void HookDefaultDequeueSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default dequeue operation trace sink that does not accept nor log a trace ...