21#include "ns3/config.h"
24#include "ns3/net-device-queue-interface.h"
25#include "ns3/packet.h"
26#include "ns3/point-to-point-channel.h"
27#include "ns3/point-to-point-net-device.h"
28#include "ns3/simulator.h"
31#include "ns3/mpi-interface.h"
32#include "ns3/mpi-receiver.h"
33#include "ns3/point-to-point-remote-channel.h"
38#include "ns3/trace-helper.h"
75 bool explicitFilename)
85 NS_LOG_INFO(
"PointToPointHelper::EnablePcapInternal(): Device "
86 << device <<
" not of type ns3::PointToPointNetDevice");
110 bool explicitFilename)
120 NS_LOG_INFO(
"PointToPointHelper::EnableAsciiInternal(): Device "
121 << device <<
" not of type ns3::PointToPointNetDevice");
146 std::string filename;
147 if (explicitFilename)
198 uint32_t nodeid = nd->GetNode()->GetId();
199 uint32_t deviceid = nd->GetIfIndex();
200 std::ostringstream oss;
202 oss <<
"/NodeList/" << nd->GetNode()->GetId() <<
"/DeviceList/" << deviceid
203 <<
"/$ns3::PointToPointNetDevice/MacRx";
208 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid
209 <<
"/$ns3::PointToPointNetDevice/TxQueue/Enqueue";
214 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid
215 <<
"/$ns3::PointToPointNetDevice/TxQueue/Dequeue";
220 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid
221 <<
"/$ns3::PointToPointNetDevice/TxQueue/Drop";
226 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid
227 <<
"/$ns3::PointToPointNetDevice/PhyRxDrop";
248 devA->SetQueue(queueA);
253 devB->SetQueue(queueB);
258 ndqiA->GetTxQueue(0)->ConnectQueueTraces(queueA);
259 devA->AggregateObject(ndqiA);
261 ndqiB->GetTxQueue(0)->ConnectQueueTraces(queueB);
262 devB->AggregateObject(ndqiB);
271 bool useNormalChannel =
true;
274 uint32_t n1SystemId = a->GetSystemId();
275 uint32_t n2SystemId = b->GetSystemId();
277 if (n1SystemId != currSystemId || n2SystemId != currSystemId)
279 useNormalChannel =
false;
282 if (useNormalChannel)
295 devA->AggregateObject(mpiRecA);
296 devB->AggregateObject(mpiRecB);
302 devA->Attach(channel);
303 devB->Attach(channel);
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.
static Mac48Address Allocate()
Allocate a new Mac48Address.
static bool IsEnabled()
Returns enabled state of parallel environment.
static uint32_t GetSystemId()
Get the id number of this rank.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
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.
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.
Simple Point To Point Channel.
ObjectFactory m_channelFactory
Channel Factory.
PointToPointHelper()
Create a PointToPointHelper to make life easier when creating point to point networks.
bool m_enableFlowControl
whether to enable flow control
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void DisableFlowControl()
Disable flow control only if you know what you are doing.
void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename) override
Enable pcap output the indicated net device.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
ObjectFactory m_queueFactory
Queue Factory.
ObjectFactory m_deviceFactory
Device Factory.
NetDeviceContainer Install(NodeContainer c)
void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename) override
Enable ascii trace output on the indicated net device.
A Device for a Point to Point Network Link.
Ptr< Queue< Packet > > GetQueue() const
Get a copy of the attached Queue.
void Receive(Ptr< Packet > p)
Receive a packet from a connected PointToPointChannel.
A Remote Point-To-Point Channel.
Smart pointer class similar to boost::intrusive_ptr.
Template class for packet Queues.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
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.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...