18 #ifndef TRACE_HELPER_H
19 #define TRACE_HELPER_H
24 #include "ns3/assert.h"
25 #include "ns3/output-stream-wrapper.h"
26 #include "ns3/pcap-file-wrapper.h"
27 #include "ns3/simulator.h"
87 bool useObjectNames =
true);
102 bool useObjectNames =
true);
115 std::ios::openmode filemode,
118 int32_t tzCorrection = 0);
126 template <
typename T>
156 template <
typename T>
163 "PcapHelper::HookDefaultSink(): Unable to hook \"" << tracename <<
"\"");
197 bool useObjectNames =
true);
212 bool useObjectNames =
true);
239 std::ios::openmode filemode = std::ios::out);
249 template <
typename T>
251 std::string traceName,
263 template <
typename T>
266 std::string traceName,
277 template <
typename T>
279 std::string traceName,
291 template <
typename T>
294 std::string traceName,
305 template <
typename T>
307 std::string traceName,
319 template <
typename T>
322 std::string traceName,
333 template <
typename T>
335 std::string traceName,
347 template <
typename T>
350 std::string traceName,
503 template <
typename T>
506 std::string tracename,
509 bool result =
object->TraceConnectWithoutContext(
513 "AsciiTraceHelper::HookDefaultEnqueueSinkWithoutContext(): Unable to hook \""
514 << tracename <<
"\"");
517 template <
typename T>
521 std::string tracename,
524 bool result =
object->TraceConnect(tracename,
528 "AsciiTraceHelper::HookDefaultEnqueueSinkWithContext(): Unable to hook \""
529 << tracename <<
"\"");
532 template <
typename T>
535 std::string tracename,
539 object->TraceConnectWithoutContext(tracename,
542 "AsciiTraceHelper::HookDefaultDropSinkWithoutContext(): Unable to hook \""
543 << tracename <<
"\"");
546 template <
typename T>
550 std::string tracename,
553 bool result =
object->TraceConnect(tracename,
557 "AsciiTraceHelper::HookDefaultDropSinkWithContext(): Unable to hook \""
558 << tracename <<
"\"");
561 template <
typename T>
564 std::string tracename,
567 bool result =
object->TraceConnectWithoutContext(
571 "AsciiTraceHelper::HookDefaultDequeueSinkWithoutContext(): Unable to hook \""
572 << tracename <<
"\"");
575 template <
typename T>
579 std::string tracename,
582 bool result =
object->TraceConnect(tracename,
586 "AsciiTraceHelper::HookDefaultDequeueSinkWithContext(): Unable to hook \""
587 << tracename <<
"\"");
590 template <
typename T>
593 std::string tracename,
596 bool result =
object->TraceConnectWithoutContext(
600 "AsciiTraceHelper::HookDefaultReceiveSinkWithoutContext(): Unable to hook \""
601 << tracename <<
"\"");
604 template <
typename T>
608 std::string tracename,
611 bool result =
object->TraceConnect(tracename,
615 "AsciiTraceHelper::HookDefaultReceiveSinkWithContext(): Unable to hook \""
616 << tracename <<
"\"");
651 bool explicitFilename) = 0;
663 bool promiscuous =
false,
664 bool explicitFilename =
false);
677 bool promiscuous =
false,
678 bool explicitFilename =
false);
712 bool promiscuous =
false);
721 void EnablePcapAll(std::string prefix,
bool promiscuous =
false);
771 bool explicitFilename) = 0;
799 void EnableAscii(std::string prefix, std::string ndName,
bool explicitFilename =
false);
877 void EnableAscii(std::string prefix, uint32_t nodeid, uint32_t deviceid,
bool explicitFilename);
911 bool explicitFilename);
948 bool explicitFilename);
962 bool explicitFilename);
Base class providing common user-level ascii trace operations for helpers representing net devices.
virtual ~AsciiTraceHelperForDevice()
Destroy an AsciiTraceHelperForDevice.
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 EnableAscii(std::string prefix, Ptr< NetDevice > nd, bool explicitFilename=false)
Enable ascii trace output on the indicated net device.
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...
AsciiTraceHelperForDevice()
Construct an AsciiTraceHelperForDevice.
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)=0
Enable ascii trace output on the indicated net device.
void EnableAsciiImpl(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output the indicated net device (implementation).
Manage ASCII trace files for device models.
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...
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 DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Drop default trace sink.
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...
static void DefaultReceiveSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Receive 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 ...
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...
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...
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 ...
AsciiTraceHelper()
Create an ascii trace helper.
static void DefaultDequeueSinkWithoutContext(Ptr< OutputStreamWrapper > file, Ptr< const Packet > p)
Basic Dequeue default trace sink.
static void DefaultEnqueueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Enqueue 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 ...
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...
static void DefaultDropSinkWithoutContext(Ptr< OutputStreamWrapper > file, Ptr< const Packet > p)
Basic Drop default trace sink.
static void DefaultDequeueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Dequeue default trace sink.
static void DefaultEnqueueSinkWithoutContext(Ptr< OutputStreamWrapper > file, Ptr< const Packet > p)
Basic Enqueue default trace sink.
~AsciiTraceHelper()
Destroy an ascii trace helper.
static void DefaultReceiveSinkWithoutContext(Ptr< OutputStreamWrapper > file, Ptr< const Packet > p)
Basic Receive default trace sink.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Base class providing common user-level pcap operations for helpers representing net devices.
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 ...
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)=0
Enable pcap output the indicated net device.
virtual ~PcapHelperForDevice()
Destroy a PcapHelperForDevice.
PcapHelperForDevice()
Construct a PcapHelperForDevice.
Manage pcap files for device models.
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.
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.
DataLinkType
This enumeration holds the data link types that will be written to the pcap file.
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...
void HookDefaultSink(Ptr< T > object, std::string traceName, Ptr< PcapFileWrapper > file)
Hook a trace source to the 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.
~PcapHelper()
Destroy a pcap helper.
static void DefaultSink(Ptr< PcapFileWrapper > file, Ptr< const Packet > p)
The basic default trace sink.
PcapHelper()
Create a pcap helper.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Every class exported by the ns3 library is enclosed in the ns3 namespace.