22 #include "ns3/abort.h"
23 #include "ns3/config.h"
24 #include "ns3/csma-channel.h"
25 #include "ns3/csma-net-device.h"
27 #include "ns3/names.h"
28 #include "ns3/net-device-queue-interface.h"
29 #include "ns3/object-factory.h"
30 #include "ns3/packet.h"
31 #include "ns3/simulator.h"
32 #include "ns3/trace-helper.h"
71 bool explicitFilename)
81 NS_LOG_INFO(
"CsmaHelper::EnablePcapInternal(): Device "
82 << device <<
" not of type ns3::CsmaNetDevice");
114 bool explicitFilename)
124 NS_LOG_INFO(
"CsmaHelper::EnableAsciiInternal(): Device "
125 << device <<
" not of type ns3::CsmaNetDevice");
150 std::string filename;
151 if (explicitFilename)
197 uint32_t nodeid = nd->GetNode()->GetId();
198 uint32_t deviceid = nd->GetIfIndex();
199 std::ostringstream oss;
201 oss <<
"/NodeList/" << nd->GetNode()->GetId() <<
"/DeviceList/" << deviceid
202 <<
"/$ns3::CsmaNetDevice/MacRx";
207 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid
208 <<
"/$ns3::CsmaNetDevice/TxQueue/Enqueue";
213 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid
214 <<
"/$ns3::CsmaNetDevice/TxQueue/Dequeue";
219 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid
220 <<
"/$ns3::CsmaNetDevice/TxQueue/Drop";
235 Ptr<Node> node = Names::Find<Node>(nodeName);
255 Ptr<Node> node = Names::Find<Node>(nodeName);
262 Ptr<Node> node = Names::Find<Node>(nodeName);
280 for (
auto i = c.
Begin(); i != c.
End(); i++)
298 int64_t currentStream = stream;
300 for (
auto i = c.
Begin(); i != c.
End(); ++i)
306 currentStream +=
csma->AssignStreams(currentStream);
309 return (currentStream - stream);
319 device->SetQueue(queue);
325 ndqi->GetTxQueue(0)->ConnectQueueTraces(queue);
326 device->AggregateObject(ndqi);
Manage ASCII trace files for device models.
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::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 DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Drop default trace sink.
static void DefaultReceiveSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Receive default trace sink.
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 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 ...
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 ...
static void DefaultEnqueueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Enqueue default trace sink.
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 ...
static void DefaultDequeueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Dequeue default trace sink.
Hold a value for an Attribute.
ObjectFactory m_channelFactory
factory for the channel
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename) override
Enable ascii trace output on the indicated net device.
bool m_enableFlowControl
whether to enable flow control
Ptr< NetDevice > InstallPriv(Ptr< Node > node, Ptr< CsmaChannel > channel) const
This method creates an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttr...
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
CsmaHelper()
Construct a CsmaHelper.
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
void DisableFlowControl()
Disable flow control only if you know what you are doing.
ObjectFactory m_queueFactory
factory for the queues
void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename) override
Enable pcap output on the indicated net device.
ObjectFactory m_deviceFactory
factory for the NetDevices
A Device for a Csma Network Link.
Ptr< Queue< Packet > > GetQueue() const
Get a copy of the attached Queue.
static Mac48Address Allocate()
Allocate a new Mac48Address.
holds a vector of ns3::NetDevice pointers
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
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.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
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.
static void EnablePrinting()
Enable printing packets metadata.
Manage pcap files for device models.
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< 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.
void HookDefaultSink(Ptr< T > object, std::string traceName, Ptr< PcapFileWrapper > file)
Hook a trace source to the default trace sink.
Smart pointer class similar to boost::intrusive_ptr.
Template class for packet Queues.
void Connect(std::string path, const CallbackBase &cb)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Every class exported by the ns3 library is enclosed in the ns3 namespace.