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" 95 uint32_t interface,
bool useObjectNames =
true);
108 std::ios::openmode filemode,
111 int32_t tzCorrection = 0);
146 template <
typename T>
void 151 NS_ASSERT_MSG (result ==
true,
"PcapHelper::HookDefaultSink(): Unable to hook \"" << tracename <<
"\"");
196 uint32_t interface,
bool useObjectNames =
true);
223 std::ios::openmode filemode = std::ios::out);
233 template <
typename T>
245 template <
typename T>
246 void HookDefaultEnqueueSinkWithContext (
Ptr<T> object,
257 template <
typename T>
269 template <
typename T>
270 void HookDefaultDropSinkWithContext (
Ptr<T> object,
281 template <
typename T>
293 template <
typename T>
294 void HookDefaultDequeueSinkWithContext (
Ptr<T> object,
305 template <
typename T>
317 template <
typename T>
318 void HookDefaultReceiveSinkWithContext (
Ptr<T> object,
460 template <
typename T>
void 464 object->TraceConnectWithoutContext (tracename,
MakeBoundCallback (&DefaultEnqueueSinkWithoutContext, file));
465 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultEnqueueSinkWithoutContext(): Unable to hook \"" 466 << tracename <<
"\"");
469 template <
typename T>
void 473 std::string tracename,
477 object->TraceConnect (tracename, context,
MakeBoundCallback (&DefaultEnqueueSinkWithContext, stream));
478 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultEnqueueSinkWithContext(): Unable to hook \"" 479 << tracename <<
"\"");
482 template <
typename T>
void 486 object->TraceConnectWithoutContext (tracename,
MakeBoundCallback (&DefaultDropSinkWithoutContext, file));
487 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultDropSinkWithoutContext(): Unable to hook \"" 488 << tracename <<
"\"");
491 template <
typename T>
void 495 std::string tracename,
499 object->TraceConnect (tracename, context,
MakeBoundCallback (&DefaultDropSinkWithContext, stream));
500 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultDropSinkWithContext(): Unable to hook \"" 501 << tracename <<
"\"");
504 template <
typename T>
void 508 object->TraceConnectWithoutContext (tracename,
MakeBoundCallback (&DefaultDequeueSinkWithoutContext, file));
509 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultDequeueSinkWithoutContext(): Unable to hook \"" 510 << tracename <<
"\"");
513 template <
typename T>
void 517 std::string tracename,
521 object->TraceConnect (tracename, context,
MakeBoundCallback (&DefaultDequeueSinkWithContext, stream));
522 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultDequeueSinkWithContext(): Unable to hook \"" 523 << tracename <<
"\"");
526 template <
typename T>
void 530 object->TraceConnectWithoutContext (tracename,
MakeBoundCallback (&DefaultReceiveSinkWithoutContext, file));
531 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultReceiveSinkWithoutContext(): Unable to hook \"" 532 << tracename <<
"\"");
535 template <
typename T>
void 539 std::string tracename,
543 object->TraceConnect (tracename, context,
MakeBoundCallback (&DefaultReceiveSinkWithContext, stream));
544 NS_ASSERT_MSG (result ==
true,
"AsciiTraceHelper::HookDefaultReceiveSinkWithContext(): Unable to hook \"" 545 << tracename <<
"\"");
573 virtual void EnablePcapInternal (std::string prefix,
Ptr<NetDevice> nd,
bool promiscuous,
bool explicitFilename) = 0;
583 void EnablePcap (std::string prefix,
Ptr<NetDevice> nd,
bool promiscuous =
false,
bool explicitFilename =
false);
594 void EnablePcap (std::string prefix, std::string ndName,
bool promiscuous =
false,
bool explicitFilename =
false);
614 void EnablePcap (std::string prefix,
NodeContainer n,
bool promiscuous =
false);
625 void EnablePcap (std::string prefix, uint32_t nodeid, uint32_t deviceid,
bool promiscuous =
false);
634 void EnablePcapAll (std::string prefix,
bool promiscuous =
false);
680 bool explicitFilename) = 0;
689 void EnableAscii (std::string prefix,
Ptr<NetDevice> nd,
bool explicitFilename =
false);
708 void EnableAscii (std::string prefix, std::string ndName,
bool explicitFilename =
false);
764 void EnableAsciiAll (std::string prefix);
786 void EnableAscii (std::string prefix, uint32_t nodeid, uint32_t deviceid,
bool explicitFilename);
820 bool explicitFilename);
854 void EnableAsciiImpl (
Ptr<OutputStreamWrapper> stream, std::string prefix, std::string ndName,
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.
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...
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...
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 ...
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 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...
NS_ASSERT_MSG(false,"Ipv4AddressGenerator::MaskToIndex(): Impossible")
holds a vector of ns3::NetDevice pointers
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...
AsciiTraceHelperForDevice()
Construct an AsciiTraceHelperForDevice.
static void DefaultSink(Ptr< PcapFileWrapper > file, Ptr< const Packet > p)
The basic default trace sink.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
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...
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 ...
PcapHelperForDevice()
Construct a PcapHelperForDevice.
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...
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 ...