|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
23 #include "ns3/abort.h"
24 #include "ns3/assert.h"
28 #include "ns3/names.h"
29 #include "ns3/net-device.h"
30 #include "ns3/pcap-file-wrapper.h"
51 std::ios::openmode filemode,
56 NS_LOG_FUNCTION (filename << filemode << dataLinkType << snapLen << tzCorrection);
59 file->Open (filename, filemode);
62 file->Init (dataLinkType, snapLen, tzCorrection);
85 std::ostringstream oss;
89 std::string devicename;
105 oss << node->
GetId ();
110 if (devicename.size ())
130 std::ostringstream oss;
131 oss << prefix <<
"-";
134 std::string nodename;
148 else if (nodename.size ())
154 oss <<
"n" << node->
GetId ();
157 oss <<
"-i" <<
interface << ".pcap";
208 return StreamWrapper;
217 std::ostringstream oss;
218 oss << prefix <<
"-";
220 std::string nodename;
221 std::string devicename;
231 if (nodename.size ())
237 oss << node->
GetId ();
242 if (devicename.size ())
266 std::ostringstream oss;
267 oss << prefix <<
"-";
270 std::string nodename;
284 else if (nodename.size ())
290 oss <<
"n" << node->
GetId ();
293 oss <<
"-i" <<
interface << ".tr";
410 EnablePcap (prefix, nd, promiscuous, explicitFilename);
430 for (uint32_t j = 0; j < node->
GetNDevices (); ++j)
452 if (node->
GetId () != nodeid)
509 bool explicitFilename)
574 for (uint32_t j = 0; j < node->
GetNDevices (); ++j)
617 bool explicitFilename)
631 bool explicitFilename)
638 if (node->
GetId () != nodeid)
644 "AsciiTraceHelperForDevice::EnableAscii(): Unknown deviceid = " << deviceid);
holds a vector of ns3::NetDevice pointers
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)=0
Enable pcap output the indicated net 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 EnableAsciiAll(std::string prefix)
Enable ascii trace output on each device (which is of the appropriate type) in the set of all nodes c...
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
uint32_t GetId(void) const
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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 EnableAsciiImpl(Ptr< OutputStreamWrapper > stream, std::string prefix, uint32_t nodeid, uint32_t deviceid, bool explicitFilename)
Enable ascii trace output on the device specified by a global node-id (of a previously created node) ...
static void DefaultEnqueueSinkWithoutContext(Ptr< OutputStreamWrapper > file, Ptr< const Packet > p)
Basic Enqueue default trace sink.
PcapHelper()
Create a pcap helper.
AsciiTraceHelper()
Create an ascii trace helper.
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
~AsciiTraceHelper()
Destroy an ascii trace helper.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
static NodeContainer GetGlobal(void)
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
static void DefaultReceiveSinkWithoutContext(Ptr< OutputStreamWrapper > file, Ptr< const Packet > p)
Basic Receive default trace sink.
Smart pointer class similar to boost::intrusive_ptr.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice 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.
virtual Ptr< Node > GetNode(void) const =0
static std::string FindName(Ptr< Object > object)
Given a pointer to an object, look to see if that object has a name associated with it and,...
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
static void DefaultSink(Ptr< PcapFileWrapper > file, Ptr< const Packet > p)
The basic default trace sink.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
static void DefaultReceiveSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Receive default trace sink.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
static void DefaultDropSinkWithoutContext(Ptr< OutputStreamWrapper > file, Ptr< const Packet > p)
Basic Drop default trace sink.
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
static void DefaultDequeueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Dequeue default trace sink.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
static void SinkWithHeader(Ptr< PcapFileWrapper > file, const Header &header, Ptr< const Packet > p)
This trace sink passes a header separately from the packet to prevent creating a new packet (for perf...
keep track of a set of node pointers.
static void DefaultDequeueSinkWithoutContext(Ptr< OutputStreamWrapper > file, Ptr< const Packet > p)
Basic Dequeue default trace sink.
static void DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Drop default trace sink.
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)=0
Enable ascii trace output on the indicated net device.
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...
uint32_t GetNDevices(void) const
static void DefaultEnqueueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Enqueue default trace sink.
~PcapHelper()
Destroy a pcap helper.
DataLinkType
This enumeration holds the data link types that will be written to the pcap file.
virtual uint32_t GetIfIndex(void) const =0
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
std::string GetFilenameFromInterfacePair(std::string prefix, Ptr< Object > object, uint32_t interface, bool useObjectNames=true)
Let the pcap helper figure out a reasonable filename to use for the pcap file associated with a node.
std::string GetFilenameFromInterfacePair(std::string prefix, Ptr< Object > object, uint32_t interface, bool useObjectNames=true)
Let the ascii trace helper figure out a reasonable filename to use for an ascii trace file associated...
void EnableAscii(std::string prefix, Ptr< NetDevice > nd, bool explicitFilename=false)
Enable ascii trace output on the indicated net device.