21 #include "ns3/abort.h"
23 #include "ns3/simulator.h"
24 #include "ns3/point-to-point-net-device.h"
25 #include "ns3/point-to-point-channel.h"
26 #include "ns3/point-to-point-remote-channel.h"
27 #include "ns3/queue.h"
28 #include "ns3/config.h"
29 #include "ns3/packet.h"
30 #include "ns3/names.h"
31 #include "ns3/mpi-interface.h"
32 #include "ns3/mpi-receiver.h"
34 #include "ns3/trace-helper.h"
87 NS_LOG_INFO (
"PointToPointHelper::EnablePcapInternal(): Device " << device <<
" not of type ns3::PointToPointNetDevice");
113 bool explicitFilename)
123 NS_LOG_INFO (
"PointToPointHelper::EnableAsciiInternal(): Device " << device <<
124 " not of type ns3::PointToPointNetDevice");
149 std::string filename;
150 if (explicitFilename)
193 uint32_t nodeid = nd->GetNode ()->GetId ();
194 uint32_t deviceid = nd->GetIfIndex ();
195 std::ostringstream oss;
197 oss <<
"/NodeList/" << nd->GetNode ()->GetId () <<
"/DeviceList/" << deviceid <<
"/$ns3::PointToPointNetDevice/MacRx";
201 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::PointToPointNetDevice/TxQueue/Enqueue";
205 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::PointToPointNetDevice/TxQueue/Dequeue";
209 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::PointToPointNetDevice/TxQueue/Drop";
213 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::PointToPointNetDevice/PhyRxDrop";
233 devA->SetQueue (queueA);
238 devB->SetQueue (queueB);
242 bool useNormalChannel =
true;
250 if (n1SystemId != currSystemId || n2SystemId != currSystemId)
252 useNormalChannel =
false;
255 if (useNormalChannel)
266 devA->AggregateObject (mpiRecA);
267 devB->AggregateObject (mpiRecB);
270 devA->Attach (channel);
271 devB->Attach (channel);
272 container.
Add (devA);
273 container.
Add (devB);
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)
Enable pcap output the indicated net device.
Manage ASCII trace files for device models.
smart pointer class similar to boost::intrusive_ptr
Ptr< Queue > GetQueue(void) const
Get a copy of the attached Queue.
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...
NetDeviceContainer Install(NodeContainer c)
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...
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())
Each point to point net device must have a queue to pass packets through.
#define NS_ASSERT(condition)
static void DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
void SetTypeId(TypeId tid)
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)
ObjectFactory m_channelFactory
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...
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
uint32_t GetSystemId(void) const
Abstract base class for packet Queues.
PointToPointHelper()
Create a PointToPointHelper to make life easier when creating point to point networks.
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
NS_LOG_COMPONENT_DEFINE("PointToPointHelper")
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
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output on the indicated net device.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
holds a vector of ns3::NetDevice pointers
A Device for a Point to Point Network Link.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
ObjectFactory m_deviceFactory
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.
void Set(std::string name, const AttributeValue &value)
ObjectFactory m_remoteChannelFactory
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 ...
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
uint32_t AddDevice(Ptr< NetDevice > device)
Simple Point To Point Channel.
static uint32_t GetSystemId()
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
void Receive(Ptr< Packet > p)
Receive a packet from a connected PointToPointChannel.
ObjectFactory m_queueFactory
void HookDefaultSink(Ptr< T > object, std::string traceName, Ptr< PcapFileWrapper > file)
Hook a trace source to the 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 ...