|
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/point-to-point-net-device.h"
25 #include "ns3/point-to-point-channel.h"
26 #include "ns3/queue.h"
27 #include "ns3/net-device-queue-interface.h"
28 #include "ns3/config.h"
29 #include "ns3/packet.h"
30 #include "ns3/names.h"
33 #include "ns3/mpi-interface.h"
34 #include "ns3/mpi-receiver.h"
35 #include "ns3/point-to-point-remote-channel.h"
38 #include "ns3/trace-helper.h"
91 NS_LOG_INFO (
"PointToPointHelper::EnablePcapInternal(): Device " << device <<
" not of type ns3::PointToPointNetDevice");
117 bool explicitFilename)
127 NS_LOG_INFO (
"PointToPointHelper::EnableAsciiInternal(): Device " << device <<
128 " not of type ns3::PointToPointNetDevice");
153 std::string filename;
154 if (explicitFilename)
199 std::ostringstream oss;
201 oss <<
"/NodeList/" << nd->
GetNode ()->
GetId () <<
"/DeviceList/" << deviceid <<
"/$ns3::PointToPointNetDevice/MacRx";
205 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::PointToPointNetDevice/TxQueue/Enqueue";
209 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::PointToPointNetDevice/TxQueue/Dequeue";
213 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::PointToPointNetDevice/TxQueue/Drop";
217 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::PointToPointNetDevice/PhyRxDrop";
237 devA->SetQueue (queueA);
242 devB->SetQueue (queueB);
245 ndqiA->GetTxQueue (0)->ConnectQueueTraces (queueA);
246 devA->AggregateObject (ndqiA);
248 ndqiB->GetTxQueue (0)->ConnectQueueTraces (queueB);
249 devB->AggregateObject (ndqiB);
257 bool useNormalChannel =
true;
263 if (n1SystemId != currSystemId || n2SystemId != currSystemId)
265 useNormalChannel =
false;
268 if (useNormalChannel)
281 devA->AggregateObject (mpiRecA);
282 devB->AggregateObject (mpiRecB);
290 container.
Add (devA);
291 container.
Add (devB);
holds a vector of ns3::NetDevice pointers
ObjectFactory m_channelFactory
Channel Factory.
#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.
A Remote Point-To-Point Channel.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
uint32_t GetId(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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.
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.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
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.
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.
NetDeviceContainer Install(NodeContainer c)
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
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 ...
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output on the indicated net device.
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 '>'.
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)
Enable pcap output the indicated net device.
#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 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 GetSystemId(void) const
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Manage pcap files for device models.
ObjectFactory m_queueFactory
Queue Factory.
void Receive(Ptr< Packet > p)
Receive a packet from a connected PointToPointChannel.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
static void DefaultReceiveSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Receive default trace sink.
Manage ASCII trace files for device models.
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.
PointToPointHelper()
Create a PointToPointHelper to make life easier when creating point to point networks.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
ObjectFactory m_deviceFactory
Device Factory.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
A Device for a Point to Point Network Link.
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...
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 bool IsEnabled()
Returns enabled state of parallel environment.
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
static uint32_t GetSystemId()
Get the id number of this rank.
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 ...