21 #include "ns3/abort.h"
23 #include "ns3/simulator.h"
24 #include "ns3/object-factory.h"
25 #include "ns3/queue.h"
26 #include "ns3/csma-net-device.h"
27 #include "ns3/csma-channel.h"
28 #include "ns3/config.h"
29 #include "ns3/packet.h"
30 #include "ns3/names.h"
32 #include "ns3/trace-helper.h"
85 NS_LOG_INFO (
"CsmaHelper::EnablePcapInternal(): Device " << device <<
" not of type ns3::CsmaNetDevice");
118 bool explicitFilename)
128 NS_LOG_INFO (
"CsmaHelper::EnableAsciiInternal(): Device " << device <<
" not of type ns3::CsmaNetDevice");
153 std::string filename;
154 if (explicitFilename)
194 uint32_t nodeid = nd->GetNode ()->GetId ();
195 uint32_t deviceid = nd->GetIfIndex ();
196 std::ostringstream oss;
198 oss <<
"/NodeList/" << nd->GetNode ()->GetId () <<
"/DeviceList/" << deviceid <<
"/$ns3::CsmaNetDevice/MacRx";
202 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::CsmaNetDevice/TxQueue/Enqueue";
206 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::CsmaNetDevice/TxQueue/Dequeue";
210 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::CsmaNetDevice/TxQueue/Drop";
218 return Install (node, channel);
224 Ptr<Node> node = Names::Find<Node> (nodeName);
244 Ptr<Node> node = Names::Find<Node> (nodeName);
251 Ptr<Node> node = Names::Find<Node> (nodeName);
287 int64_t currentStream = stream;
295 currentStream += csma->AssignStreams (currentStream);
298 return (currentStream - stream);
308 device->SetQueue (queue);
309 device->Attach (channel);
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
Manage ASCII trace files for device models.
smart pointer class similar to boost::intrusive_ptr
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
static void DefaultEnqueueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, uint32_t dataLinkType, uint32_t snapLen=65535, int32_t tzCorrection=0)
Create and initialize a pcap file.
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...
std::vector< Ptr< Node > >::const_iterator Iterator
Hold a value for an Attribute.
Manage pcap files for device models.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Build bound Callbacks which take varying numbers of arguments, and potentially returning a value...
static void DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
void SetTypeId(TypeId tid)
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)
Enable pcap output on the indicated net device.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
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. ...
void Connect(std::string path, const CallbackBase &cb)
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 ...
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...
Abstract base class for packet Queues.
CsmaHelper()
Construct a CsmaHelper.
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...
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
static void EnablePrinting(void)
By default, packets do not keep around enough metadata to perform the operations requested by the Pri...
Ptr< Object > Create(void) const
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
ObjectFactory m_deviceFactory
holds a vector of ns3::NetDevice pointers
ObjectFactory m_channelFactory
Ptr< Queue > GetQueue(void) const
Get a copy of the attached Queue.
static void DefaultReceiveSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
static void DefaultDequeueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
keep track of a set of node pointers.
A Device for a Csma Network Link.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
NS_LOG_COMPONENT_DEFINE("CsmaHelper")
void Set(std::string name, const AttributeValue &value)
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 ...
ObjectFactory m_queueFactory
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output on the indicated net device.
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
uint32_t AddDevice(Ptr< NetDevice > device)
std::vector< Ptr< NetDevice > >::const_iterator Iterator
Ptr< NetDevice > InstallPriv(Ptr< Node > node, Ptr< CsmaChannel > channel) const
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())
void HookDefaultSink(Ptr< T > object, std::string traceName, Ptr< PcapFileWrapper > file)
Hook a trace source to the default trace sink.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
Ptr< T > GetObject(void) const
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 ...