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 ())
116 oss << device->GetIfIndex ();
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 ())
248 oss << device->GetIfIndex ();
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);
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
static void DefaultEnqueueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Enqueue default trace sink.
uint32_t GetId(void) const
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) ...
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
static void DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Drop default trace sink.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
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. ...
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...
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.
static void DefaultReceiveSinkWithoutContext(Ptr< OutputStreamWrapper > file, Ptr< const Packet > p)
Basic Receive default trace sink.
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...
DataLinkType
This enumeration holds the data link types that will be written to the pcap file. ...
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 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 ...
Iterator Begin(void) 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.
holds a vector of ns3::NetDevice pointers
static void DefaultEnqueueSinkWithoutContext(Ptr< OutputStreamWrapper > file, Ptr< const Packet > p)
Basic Enqueue default trace sink.
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...
static void DefaultDequeueSinkWithoutContext(Ptr< OutputStreamWrapper > file, Ptr< const Packet > p)
Basic Dequeue default trace sink.
static void DefaultReceiveSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Receive default trace sink.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
static void DefaultSink(Ptr< PcapFileWrapper > file, Ptr< const Packet > p)
The basic default trace sink.
static void DefaultDequeueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Dequeue default trace sink.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)=0
Enable pcap output the indicated net device.
AsciiTraceHelper()
Create an ascii trace helper.
static void DefaultDropSinkWithoutContext(Ptr< OutputStreamWrapper > file, Ptr< const Packet > p)
Basic Drop default trace sink.
static Time Now(void)
Return the current simulation virtual time.
PcapHelper()
Create a pcap helper.
static NodeContainer GetGlobal(void)
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
void EnableAscii(std::string prefix, Ptr< NetDevice > nd, bool explicitFilename=false)
Enable ascii trace output on the indicated net device.
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
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...
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)=0
Enable ascii trace output on the indicated net device.
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...
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.
~AsciiTraceHelper()
Destroy an ascii trace helper.
~PcapHelper()
Destroy a pcap helper.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
uint32_t GetNDevices(void) const