19 #ifndef TRACE_HELPER_H
20 #define TRACE_HELPER_H
22 #include "ns3/assert.h"
23 #include "ns3/net-device-container.h"
24 #include "ns3/node-container.h"
25 #include "ns3/simulator.h"
26 #include "ns3/pcap-file-wrapper.h"
27 #include "ns3/output-stream-wrapper.h"
92 uint32_t interface,
bool useObjectNames =
true);
105 uint32_t dataLinkType, uint32_t snapLen = std::numeric_limits<uint32_t>::max (), int32_t tzCorrection = 0);
140 template <
typename T>
void
145 NS_ASSERT_MSG (result ==
true,
"PcapHelper::HookDefaultSink(): Unable to hook \"" << tracename <<
"\"");
190 uint32_t interface,
bool useObjectNames =
true);
217 std::ios::openmode filemode = std::ios::out);
227 template <
typename T>
239 template <
typename T>
251 template <
typename T>
263 template <
typename T>
275 template <
typename T>
287 template <
typename T>
299 template <
typename T>
311 template <
typename T>
454 template <
typename T>
void
459 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultEnqueueSinkWithoutContext(): Unable to hook \""
460 << tracename <<
"\"");
463 template <
typename T>
void
467 std::string tracename,
472 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultEnqueueSinkWithContext(): Unable to hook \""
473 << tracename <<
"\"");
476 template <
typename T>
void
481 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultDropSinkWithoutContext(): Unable to hook \""
482 << tracename <<
"\"");
485 template <
typename T>
void
489 std::string tracename,
494 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultDropSinkWithContext(): Unable to hook \""
495 << tracename <<
"\"");
498 template <
typename T>
void
503 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultDequeueSinkWithoutContext(): Unable to hook \""
504 << tracename <<
"\"");
507 template <
typename T>
void
511 std::string tracename,
516 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultDequeueSinkWithContext(): Unable to hook \""
517 << tracename <<
"\"");
520 template <
typename T>
void
525 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultReceiveSinkWithoutContext(): Unable to hook \""
526 << tracename <<
"\"");
529 template <
typename T>
void
533 std::string tracename,
538 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultReceiveSinkWithContext(): Unable to hook \""
539 << tracename <<
"\"");
588 void EnablePcap (std::string prefix, std::string ndName,
bool promiscuous =
false,
bool explicitFilename =
false);
619 void EnablePcap (std::string prefix, uint32_t nodeid, uint32_t deviceid,
bool promiscuous =
false);
628 void EnablePcapAll (std::string prefix,
bool promiscuous =
false);
674 bool explicitFilename) = 0;
702 void EnableAscii (std::string prefix, std::string ndName,
bool explicitFilename =
false);
780 void EnableAscii (std::string prefix, uint32_t nodeid, uint32_t deviceid,
bool explicitFilename);
814 bool explicitFilename);
Base class providing common user-level ascii trace operations for helpers representing net devices...
Manage ASCII trace files for device models.
Smart pointer class similar to boost::intrusive_ptr.
static void DefaultEnqueueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Enqueue default trace sink.
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) ...
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...
Manage pcap files for device models.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Base class providing common user-level pcap operations for helpers representing net devices...
static void DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Drop default trace sink.
void HookDefaultDequeueSinkWithContext(Ptr< T > object, std::string context, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default dequeue operation trace sink that does accept and log a trace cont...
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 ...
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 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...
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 ...
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.
AsciiTraceHelperForDevice()
Construct an AsciiTraceHelperForDevice.
static void DefaultReceiveSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Receive default trace sink.
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.
void HookDefaultReceiveSinkWithContext(Ptr< T > object, std::string context, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default receive operation trace sink that does accept and log a trace cont...
AsciiTraceHelper()
Create an ascii trace helper.
static void DefaultDropSinkWithoutContext(Ptr< OutputStreamWrapper > file, Ptr< const Packet > p)
Basic Drop default trace sink.
PcapHelper()
Create a pcap helper.
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 ...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void EnableAscii(std::string prefix, Ptr< NetDevice > nd, bool explicitFilename=false)
Enable ascii trace output on the indicated net device.
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...
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)=0
Enable ascii trace output on the indicated net device.
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, uint32_t 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...
PcapHelperForDevice()
Construct a PcapHelperForDevice.
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
void HookDefaultSink(Ptr< T > object, std::string traceName, Ptr< PcapFileWrapper > file)
Hook a trace source to the default trace sink.
void HookDefaultEnqueueSinkWithContext(Ptr< T > object, std::string context, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default enqueue operation trace sink that does accept and log a trace cont...
~AsciiTraceHelper()
Destroy an ascii trace helper.
virtual ~PcapHelperForDevice()
Destroy a PcapHelperForDevice.
~PcapHelper()
Destroy a pcap helper.
virtual ~AsciiTraceHelperForDevice()
Destroy an AsciiTraceHelperForDevice.
void HookDefaultDropSinkWithContext(Ptr< T > object, std::string context, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default drop operation trace sink that does accept and log a trace context...
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 ...