Change in CcnxApp API.  Now callbacks also contain pointer of original
packet (useful to get packet tags, if they exist)

Reflecting changes in PackegTag API

Rescanning bindings

More work on packet-path-weight tracers
diff --git a/helper/ccnx-trace-helper.cc b/helper/ccnx-trace-helper.cc
index a7f8014..303d1aa 100644
--- a/helper/ccnx-trace-helper.cc
+++ b/helper/ccnx-trace-helper.cc
@@ -32,6 +32,7 @@
 #include "ns3/simulator.h"
 #include "ns3/names.h"
 #include "ns3/tcp-l4-protocol.h"
+#include "ns3/node.h"
 
 #include <boost/ref.hpp>
 #include <boost/lexical_cast.hpp>
@@ -42,6 +43,7 @@
 #include "tracers/ccnx-seqs-app-tracer.h"
 #include "tracers/ipv4-seqs-app-tracer.h"
 #include "tracers/ccnx-consumer-window-tracer.h"
+#include "tracers/ccnx-path-weight-tracer.h"
 
 #include "ns3/ccnx-interest-header.h"
 #include "ns3/ccnx-content-object-header.h"
@@ -61,6 +63,7 @@
   , m_ipv4AppSeqsTrace (0)
   , m_windowsTrace (0)
   , m_windowsTcpTrace (0)
+  , m_pathWeightsTrace (0)
 {
 }
 
@@ -72,6 +75,7 @@
   if (m_ipv4AppSeqsTrace != 0) delete m_ipv4AppSeqsTrace;
   if (m_windowsTrace != 0) delete m_windowsTrace;
   if (m_windowsTcpTrace != 0) delete m_windowsTcpTrace;
+  if (m_pathWeightsTrace != 0) delete m_pathWeightsTrace;
   
   if (m_apps.size () > 0)
     {
@@ -360,4 +364,31 @@
   *m_windowsTcpTrace << "\n";
 }
 
+void
+CcnxTraceHelper::EnablePathWeights (const std::string &pathWeights)
+{
+  NS_LOG_FUNCTION (this);
+  m_pathWeightsTrace = new ofstream (pathWeights.c_str (), ios::trunc);
+
+  WindowTracer::PrintHeader (*m_pathWeightsTrace);
+  *m_pathWeightsTrace << "\n";
+}
+
+void
+CcnxTraceHelper::WeightsConnect (Ptr<Node> node, Ptr<Application> app)
+{
+  // small hack to find out app index
+  uint32_t appId = 0;
+  for (uint32_t appId = 0; appId < node->GetNApplications (); appId++)
+    {
+      if (app == node->GetApplication (appId)) break;
+    }
+  NS_ASSERT (appId != node->GetNApplications ());
+
+  Ptr<CcnxPathWeightTracer> trace = Create<CcnxPathWeightTracer> (boost::ref(*m_pathWeightsTrace),
+                                                                  node,
+                                                                  lexical_cast<string> (appId));
+  m_pathWeights.push_back (trace);
+}
+
 } // namespace ns3
diff --git a/helper/ccnx-trace-helper.h b/helper/ccnx-trace-helper.h
index cfff107..37565f5 100644
--- a/helper/ccnx-trace-helper.h
+++ b/helper/ccnx-trace-helper.h
@@ -33,6 +33,8 @@
 class CcnxL3Tracer;
 class Ipv4AppTracer;
 class WindowTracer;
+class CcnxPathWeightTracer;
+class Application;
 
 class CcnxTraceHelper
 {
@@ -108,8 +110,26 @@
   void
   EnableWindowsTcpAll (const std::string &windowTrace);
 
+  /**
+   * @brief Should be called with node pointer after TCP application
+   *
+   * Workaround because NS-3 needs object to exist before connecting trace
+   */
   void TcpConnect (Ptr<Node> node);
 
+  /**
+   * @brief Enable tracing of path weights
+   */
+  void
+  EnablePathWeights (const std::string &pathWeights);
+
+  /**
+   * @brief Should be called with node pointer after TCP application
+   *
+   * Workaround because NS-3 needs object to exist before connecting trace
+   */
+  void WeightsConnect (Ptr<Node> node, Ptr<Application> AppId);
+
 private:
   std::string m_appTrace;
   std::list<Ptr<CcnxAppTracer> > m_apps;
@@ -131,6 +151,9 @@
 
   std::list<Ptr<WindowTracer> > m_windowsTcp;
   std::ostream *m_windowsTcpTrace;
+
+  std::list<Ptr<CcnxPathWeightTracer> > m_pathWeights;
+  std::ostream *m_pathWeightsTrace;
 };
 
 
diff --git a/helper/tracers/ccnx-path-weight-tracer.cc b/helper/tracers/ccnx-path-weight-tracer.cc
new file mode 100644
index 0000000..d1cb709
--- /dev/null
+++ b/helper/tracers/ccnx-path-weight-tracer.cc
@@ -0,0 +1,81 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 UCLA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author:  Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ccnx-path-weight-tracer.h"
+#include "ns3/node.h"
+#include "ns3/packet.h"
+#include "ns3/config.h"
+#include "ns3/names.h"
+#include "ns3/callback.h"
+#include "ns3/ccnx-app.h"
+#include "ns3/ccnx-face.h"
+#include "ns3/boolean.h"
+
+#include <boost/lexical_cast.hpp>
+#include <boost/foreach.hpp>
+
+using namespace std;
+
+namespace ns3 {
+    
+CcnxPathWeightTracer::CcnxPathWeightTracer (std::ostream &os, Ptr<Node> node, std::string appId)
+  : m_os (os)
+  , m_nodePtr (node)
+  , m_appId (appId)
+{
+  m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
+
+  Connect ();
+
+  string name = Names::FindName (node);
+  if (!name.empty ())
+    {
+      m_node = name;
+    }
+}
+
+void
+CcnxPathWeightTracer::Connect ()
+{
+  Config::Set ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/ForwardingStrategy/MetricTagging",
+               BooleanValue (true));
+
+  Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/FaceList/*/$ns3::CcnxLocalFace/PathWeightsTrace",
+                   MakeCallback (&CcnxPathWeightTracer::InLocalFace, this));
+}
+
+
+void
+CcnxPathWeightTracer::PrintHeader (std::ostream &os) const
+{
+  os << "Node\t"
+     << "AppId\t"
+     << "PathWeight\t"
+     << "PathWeights\n";
+}
+
+void
+CcnxPathWeightTracer::InLocalFace (std::string context,
+                                   uint32_t weight, Ptr<Node> src, Ptr<Node> dst)
+{
+  std::cout << "Path weights from " << Names::FindName (src) << " to "<< Names::FindName (dst) <<" : " << weight << "\n";
+}
+
+} // namespace ns3
diff --git a/helper/tracers/ccnx-path-weight-tracer.h b/helper/tracers/ccnx-path-weight-tracer.h
new file mode 100644
index 0000000..ca43a5d
--- /dev/null
+++ b/helper/tracers/ccnx-path-weight-tracer.h
@@ -0,0 +1,63 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 UCLA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author:  Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef CCNX_PATH_WEIGHT_TRACER_H
+#define CCNX_PATH_WEIGHT_TRACER_H
+
+#include "ns3/ptr.h"
+#include "ns3/simple-ref-count.h"
+#include "ns3/ccnx-path-stretch-tag.h"
+#include <list>
+
+namespace ns3 {
+
+class Node;
+class Packet;
+class CcnxApp;
+
+class CcnxPathWeightTracer : public SimpleRefCount<CcnxPathWeightTracer>
+{
+public:
+  CcnxPathWeightTracer (std::ostream &os, Ptr<Node> node, std::string appId);
+  virtual ~CcnxPathWeightTracer () { };
+
+  void
+  Connect ();
+  
+  virtual void
+  PrintHeader (std::ostream &os) const;
+
+  /**
+   * \brief Process packet weight upon reception of packet on a local face
+   */
+  virtual void
+  InLocalFace (std::string context,
+               uint32_t weight, Ptr<Node> src, Ptr<Node> dst);
+
+protected:
+  std::ostream &m_os;
+  std::string m_node;
+  Ptr<Node> m_nodePtr;
+  std::string m_appId;
+};
+
+} // namespace ns3
+
+#endif // CCNX_PATH_WEIGHT_TRACER_H