utils/tracers: An optimized way to connect to L2 and ndn.CS traces
diff --git a/utils/tracers/l2-tracer.cc b/utils/tracers/l2-tracer.cc
index a3dc05b..3338309 100644
--- a/utils/tracers/l2-tracer.cc
+++ b/utils/tracers/l2-tracer.cc
@@ -24,6 +24,8 @@
 #include "ns3/names.h"
 #include "ns3/callback.h"
 
+#include "ns3/point-to-point-net-device.h"
+#include "ns3/queue.h"
 #include <boost/lexical_cast.hpp>
 
 using namespace std;
@@ -47,8 +49,14 @@
 void
 L2Tracer::Connect ()
 {
-  Config::ConnectWithoutContext ("/NodeList/"+m_node+"/DeviceList/*/TxQueue/Drop",
-                                 MakeCallback (&L2Tracer::Drop, this));
+  for (uint32_t devId = 0; devId < m_nodePtr->GetNDevices (); devId ++)
+    {
+      Ptr<PointToPointNetDevice> p2pnd = DynamicCast<PointToPointNetDevice> (m_nodePtr->GetDevice (devId));
+      if (p2pnd)
+        {
+          p2pnd->GetQueue ()->TraceConnectWithoutContext ("Drop", MakeCallback (&L2Tracer::Drop, this));
+        }
+    }
 }
 
 } // namespace ns3
diff --git a/utils/tracers/ndn-cs-tracer.cc b/utils/tracers/ndn-cs-tracer.cc
index 7f2553d..2fb1337 100644
--- a/utils/tracers/ndn-cs-tracer.cc
+++ b/utils/tracers/ndn-cs-tracer.cc
@@ -29,6 +29,7 @@
 #include "ns3/ndn-app.h"
 #include "ns3/ndn-interest.h"
 #include "ns3/ndn-data.h"
+#include "ns3/ndn-content-store.h"
 #include "ns3/simulator.h"
 #include "ns3/node-list.h"
 #include "ns3/log.h"
@@ -233,10 +234,9 @@
 void
 CsTracer::Connect ()
 {
-  Config::ConnectWithoutContext ("/NodeList/"+m_node+"/$ns3::ndn::ContentStore/CacheHits",
-                                 MakeCallback (&CsTracer::CacheHits, this));
-  Config::ConnectWithoutContext ("/NodeList/"+m_node+"/$ns3::ndn::ContentStore/CacheMisses",
-                                 MakeCallback (&CsTracer::CacheMisses, this));
+  Ptr<ContentStore> cs = m_nodePtr->GetObject<ContentStore> ();
+  cs->TraceConnectWithoutContext ("CacheHits",   MakeCallback (&CsTracer::CacheHits,   this));
+  cs->TraceConnectWithoutContext ("CacheMisses", MakeCallback (&CsTracer::CacheMisses, this));
 
   Reset ();  
 }