tracers: Extending helper API in tracers
Now all tracers can be installed on individual nodes.
It is also possible to specify "-" as a file name, leading to tracing on
standard output.
Refs #1007 (http://redmine.named-data.net)
diff --git a/utils/tracers/ndn-l3-rate-tracer.h b/utils/tracers/ndn-l3-rate-tracer.h
index 4db4e70..64e5177 100644
--- a/utils/tracers/ndn-l3-rate-tracer.h
+++ b/utils/tracers/ndn-l3-rate-tracer.h
@@ -25,6 +25,7 @@
#include "ns3/nstime.h"
#include "ns3/event-id.h"
+#include <ns3/node-container.h>
#include <boost/tuple/tuple.hpp>
#include <boost/shared_ptr.hpp>
@@ -63,7 +64,7 @@
/**
* @brief Helper method to install tracers on all simulation nodes
*
- * @param file File to which traces will be written
+ * @param file File to which traces will be written. If filename is -, then std::out is used
* @param averagingPeriod Defines averaging period for the rate calculation,
* as well as how often data will be written into the trace file (default, every half second)
*
@@ -74,6 +75,47 @@
static boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<L3RateTracer> > >
InstallAll (const std::string &file, Time averagingPeriod = Seconds (0.5));
+ /**
+ * @brief Helper method to install tracers on the selected simulation nodes
+ *
+ * @param nodes Nodes on which to install tracer
+ * @param file File to which traces will be written. If filename is -, then std::out is used
+ * @param averagingPeriod How often data will be written into the trace file (default, every half second)
+ *
+ * @returns a tuple of reference to output stream and list of tracers. !!! Attention !!! This tuple needs to be preserved
+ * for the lifetime of simulation, otherwise SEGFAULTs are inevitable
+ *
+ */
+ static boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<L3RateTracer> > >
+ Install (const NodeContainer &nodes, const std::string &file, Time averagingPeriod = Seconds (0.5));
+
+ /**
+ * @brief Helper method to install tracers on a specific simulation node
+ *
+ * @param nodes Nodes on which to install tracer
+ * @param file File to which traces will be written. If filename is -, then std::out is used
+ * @param averagingPeriod How often data will be written into the trace file (default, every half second)
+ *
+ * @returns a tuple of reference to output stream and list of tracers. !!! Attention !!! This tuple needs to be preserved
+ * for the lifetime of simulation, otherwise SEGFAULTs are inevitable
+ *
+ */
+ static boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<L3RateTracer> > >
+ Install (Ptr<Node> node, const std::string &file, Time averagingPeriod = Seconds (0.5));
+
+ /**
+ * @brief Helper method to install tracers on a specific simulation node
+ *
+ * @param nodes Nodes on which to install tracer
+ * @param outputStream Smart pointer to a stream
+ * @param averagingPeriod How often data will be written into the trace file (default, every half second)
+ *
+ * @returns a tuple of reference to output stream and list of tracers. !!! Attention !!! This tuple needs to be preserved
+ * for the lifetime of simulation, otherwise SEGFAULTs are inevitable
+ */
+ static Ptr<L3RateTracer>
+ Install (Ptr<Node> node, boost::shared_ptr<std::ostream> outputStream, Time averagingPeriod = Seconds (0.5));
+
// from L3Tracer
virtual void
PrintHeader (std::ostream &os) const;
@@ -84,40 +126,31 @@
protected:
// from L3Tracer
virtual void
- OutInterests (std::string context,
- Ptr<const Interest>, Ptr<const Face>);
+ OutInterests (Ptr<const Interest>, Ptr<const Face>);
virtual void
- InInterests (std::string context,
- Ptr<const Interest>, Ptr<const Face>);
+ InInterests (Ptr<const Interest>, Ptr<const Face>);
virtual void
- DropInterests (std::string context,
- Ptr<const Interest>, Ptr<const Face>);
+ DropInterests (Ptr<const Interest>, Ptr<const Face>);
virtual void
- OutNacks (std::string context,
- Ptr<const Interest>, Ptr<const Face>);
+ OutNacks (Ptr<const Interest>, Ptr<const Face>);
virtual void
- InNacks (std::string context,
- Ptr<const Interest>, Ptr<const Face>);
+ InNacks (Ptr<const Interest>, Ptr<const Face>);
virtual void
- DropNacks (std::string context,
- Ptr<const Interest>, Ptr<const Face>);
+ DropNacks (Ptr<const Interest>, Ptr<const Face>);
virtual void
- OutData (std::string context,
- Ptr<const ContentObject>, Ptr<const Packet>, bool fromCache, Ptr<const Face>);
+ OutData (Ptr<const ContentObject>, Ptr<const Packet>, bool fromCache, Ptr<const Face>);
virtual void
- InData (std::string context,
- Ptr<const ContentObject>, Ptr<const Packet>, Ptr<const Face>);
+ InData (Ptr<const ContentObject>, Ptr<const Packet>, Ptr<const Face>);
virtual void
- DropData (std::string context,
- Ptr<const ContentObject>, Ptr<const Packet>, Ptr<const Face>);
+ DropData (Ptr<const ContentObject>, Ptr<const Packet>, Ptr<const Face>);
virtual void
SatisfiedInterests (Ptr<const pit::Entry>);