Moving around path weight tagging. Now CcnxFace owns metric field, which is used for tagging.

Correcting bugs in blackhole-sprint scenario.  This time it should be
the right one:
- instead of a hijacker app, all faces on hijacked node are turned down
- there was a trick with RTT estimation (when batch, it is necessary to
  reset history upon a new batch)
- instead of random runs, trying all possible combinations of
  producer/hijacker
diff --git a/model/annotated-topology-reader.cc b/model/annotated-topology-reader.cc
index 345c2f5..a9b66bf 100644
--- a/model/annotated-topology-reader.cc
+++ b/model/annotated-topology-reader.cc
@@ -37,6 +37,8 @@
 #include "ns3/pointer.h"
 #include "ns3/uinteger.h"
 #include "ns3/ipv4-address.h"
+#include "ns3/ccnx.h"
+#include "ns3/ccnx-face.h"
 
 #include "ns3/constant-position-mobility-model.h"
 
@@ -219,8 +221,6 @@
       base = Ipv4Address (base.Get () + 256);
       address.SetBase (base, Ipv4Mask ("/24"));
     }
-        
-  ApplyOspfMetric ();
 }
         
 void
@@ -233,22 +233,42 @@
         
       {
         Ptr<Ipv4> ipv4 = link.GetFromNode ()->GetObject<Ipv4> ();
-        NS_ASSERT (ipv4 != 0);
+        if (ipv4 != 0)
+          {
+            int32_t interfaceId = ipv4->GetInterfaceForDevice (link.GetFromNetDevice ());
+            NS_ASSERT (interfaceId >= 0);
         
-        int32_t interfaceId = ipv4->GetInterfaceForDevice (link.GetFromNetDevice ());
-        NS_ASSERT (interfaceId >= 0);
-        
-        ipv4->SetMetric (interfaceId,metric);
+            ipv4->SetMetric (interfaceId,metric);
+          }
+
+        Ptr<Ccnx> ccnx = link.GetFromNode ()->GetObject<Ccnx> ();
+        if (ccnx != 0)
+          {
+            Ptr<CcnxFace> face = ccnx->GetFaceByNetDevice (link.GetFromNetDevice ());
+            NS_ASSERT (face != 0);
+            
+            face->SetMetric (metric);
+          }
       }
         
       {
         Ptr<Ipv4> ipv4 = link.GetToNode ()->GetObject<Ipv4> ();
-        NS_ASSERT (ipv4 != 0);
-        
-        int32_t interfaceId = ipv4->GetInterfaceForDevice (link.GetToNetDevice ());
-        NS_ASSERT (interfaceId >= 0);
+        if (ipv4 != 0)
+          {
+            int32_t interfaceId = ipv4->GetInterfaceForDevice (link.GetToNetDevice ());
+            NS_ASSERT (interfaceId >= 0);
 
-        ipv4->SetMetric (interfaceId,metric);
+            ipv4->SetMetric (interfaceId,metric);
+          }
+        
+        Ptr<Ccnx> ccnx = link.GetToNode ()->GetObject<Ccnx> ();
+        if (ccnx != 0)
+          {
+            Ptr<CcnxFace> face = ccnx->GetFaceByNetDevice (link.GetToNetDevice ());
+            NS_ASSERT (face != 0);
+            
+            face->SetMetric (metric);
+          }
       }
     }
 }
diff --git a/model/annotated-topology-reader.h b/model/annotated-topology-reader.h
index 6edcb34..91e6d26 100644
--- a/model/annotated-topology-reader.h
+++ b/model/annotated-topology-reader.h
@@ -80,12 +80,28 @@
   void
   AssignIpv4Addresses (Ipv4Address base);
 
+  /**
+   * \brief Set bounding box where nodes will be randomly places (if positions are unspecified)
+   * \param ulx Upper left x coordinate
+   * \param uly Upper left y coordinate
+   * \param lrx Lower right x coordinate
+   * \param lry Lower right y coordinate
+   */
   void
   SetBoundingBox (double ulx, double uly, double lrx, double lry);
 
+  /**
+   * \brief Set mobility model to be used on nodes
+   * \param model class name of the model
+   */
   void
   SetMobilityModel (const std::string &model);
 
+  /**
+   * \brief Apply OSPF metric on Ipv4 (if exists) and Ccnx (if exists) stacks
+   */
+  void ApplyOspfMetric ();
+
 protected:
   Ptr<Node>
   CreateNode (const std::string name);
@@ -100,7 +116,6 @@
    * NodeContainer from Read method
    */
   void ApplySettings ();
-  void ApplyOspfMetric ();
     
 protected:
   std::string m_path;
diff --git a/model/ccnx-bestroute-strategy.cc b/model/ccnx-bestroute-strategy.cc
index e8be345..2f3057f 100644
--- a/model/ccnx-bestroute-strategy.cc
+++ b/model/ccnx-bestroute-strategy.cc
@@ -103,7 +103,6 @@
                      ll::bind(&CcnxPitEntry::AddOutgoing, ll::_1, metricFace.m_face));
 
       Ptr<Packet> packetToSend = packet->Copy ();
-      TagPacket (packetToSend, metricFace);
 
       //transmission
       metricFace.m_face->Send (packetToSend);
diff --git a/model/ccnx-face.cc b/model/ccnx-face.cc
index b1f7b42..781bb72 100644
--- a/model/ccnx-face.cc
+++ b/model/ccnx-face.cc
@@ -27,8 +27,11 @@
 #include "ns3/assert.h"
 #include "ns3/uinteger.h"
 #include "ns3/double.h"
+#include "ns3/boolean.h"
 #include "ns3/simulator.h"
 
+#include "ccnx-path-stretch-tag.h"
+
 #include <boost/ref.hpp>
 
 NS_LOG_COMPONENT_DEFINE ("CcnxFace");
@@ -56,6 +59,10 @@
                    MakeDoubleAccessor (&CcnxFace::m_bucketLeak),
                    MakeDoubleChecker<double> ())
                    
+    .AddAttribute ("MetricTagging", "Enable metric tagging (path-stretch calculation)",
+                   BooleanValue (false),
+                   MakeBooleanAccessor (&CcnxFace::m_enableMetricTagging),
+                   MakeBooleanChecker ())
     ;
   return tid;
 }
@@ -74,6 +81,8 @@
   , m_ifup (false)
   , m_id ((uint32_t)-1)
   , m_lastLeakTime (0)
+  , m_metric (0)
+  , m_enableMetricTagging (false)
 {
   NS_LOG_FUNCTION (this);
 
@@ -145,6 +154,24 @@
   if (!IsUp ())
     return false;
 
+  if (m_enableMetricTagging)
+    {
+      // update path information
+      Ptr<const WeightsPathStretchTag> origTag = packet->RemovePacketTag<WeightsPathStretchTag> ();
+      Ptr<WeightsPathStretchTag> tag;
+      if (origTag == 0)
+        {
+          tag = CreateObject<WeightsPathStretchTag> (); // create a new tag
+        }
+      else
+        {
+          tag = CreateObject<WeightsPathStretchTag> (*origTag); // will update existing tag
+        }
+
+      tag->AddPathInfo (m_node, GetMetric ());
+      packet->AddPacketTag (tag);
+    }
+  
   SendImpl (packet);
   return true;
 }
@@ -198,19 +225,19 @@
   m_bucketLeak = leak;
 }
 
-// void
-// CcnxFace::SetMetric (uint16_t metric)
-// {
-//   NS_LOG_FUNCTION (metric);
-//   m_metric = metric;
-// }
+void
+CcnxFace::SetMetric (uint16_t metric)
+{
+  NS_LOG_FUNCTION (metric);
+  m_metric = metric;
+}
 
-// uint16_t
-// CcnxFace::GetMetric (void) const
-// {
-//   NS_LOG_FUNCTION_NOARGS ();
-//   return m_metric;
-// }
+uint16_t
+CcnxFace::GetMetric (void) const
+{
+  NS_LOG_FUNCTION_NOARGS ();
+  return m_metric;
+}
 
 /**
  * These are face states and may be distinct from 
diff --git a/model/ccnx-face.h b/model/ccnx-face.h
index 29ec371..e2100c6 100644
--- a/model/ccnx-face.h
+++ b/model/ccnx-face.h
@@ -111,19 +111,19 @@
   Receive (const Ptr<const Packet> &p);
   ////////////////////////////////////////////////////////////////////
 
-  // /**
-  //  * \Brief Assign routing/forwarding metric with face
-  //  *
-  //  * \param metric configured routing metric (cost) of this face
-  //  */
-  // virtual void SetMetric (uint16_t metric);
+  /**
+   * \Brief Assign routing/forwarding metric with face
+   *
+   * \param metric configured routing metric (cost) of this face
+   */
+  virtual void SetMetric (uint16_t metric);
 
-  // /**
-  //  * \brief Get routing/forwarding metric assigned to the face
-  //  *
-  //  * \returns configured routing/forwarding metric (cost) of this face
-  //  */
-  // virtual uint16_t GetMetric (void) const;
+  /**
+   * \brief Get routing/forwarding metric assigned to the face
+   *
+   * \returns configured routing/forwarding metric (cost) of this face
+   */
+  virtual uint16_t GetMetric (void) const;
 
   /**
    * These are face states and may be distinct from actual lower-layer
@@ -228,7 +228,10 @@
   ProtocolHandler m_protocolHandler; ///< Callback via which packets are getting send to CCNx stack
   bool m_ifup; ///< \brief flag indicating that the interface is UP 
   uint32_t m_id; ///< \brief id of the interface in CCNx stack (per-node uniqueness)
-  Time m_lastLeakTime; 
+  Time m_lastLeakTime;
+  uint32_t m_metric; ///< \brief metric of the face
+
+  bool m_enableMetricTagging; 
 };
 
 std::ostream& operator<< (std::ostream& os, const CcnxFace &face);
diff --git a/model/ccnx-flooding-strategy.cc b/model/ccnx-flooding-strategy.cc
index 2a7f2ee..182381e 100644
--- a/model/ccnx-flooding-strategy.cc
+++ b/model/ccnx-flooding-strategy.cc
@@ -118,7 +118,6 @@
       //   }
 
       Ptr<Packet> packetToSend = packet->Copy ();
-      TagPacket (packetToSend, metricFace);
 
       //transmission
       metricFace.m_face->Send (packetToSend);
diff --git a/model/ccnx-forwarding-strategy.cc b/model/ccnx-forwarding-strategy.cc
index 45e0fd7..a856577 100644
--- a/model/ccnx-forwarding-strategy.cc
+++ b/model/ccnx-forwarding-strategy.cc
@@ -25,14 +25,11 @@
 #include "ns3/ptr.h"
 #include "ns3/log.h"
 #include "ns3/simulator.h"
-#include "ns3/double.h"
-#include "ns3/boolean.h"
 
 #include "ccnx-pit.h"
 #include "ccnx-pit-entry.h"
 
 #include "ccnx-interest-header.h"
-#include "ccnx-path-stretch-tag.h"
 
 #include <boost/ref.hpp>
 #include <boost/foreach.hpp>
@@ -54,11 +51,6 @@
     .SetGroupName ("Ccnx")
     .SetParent<Object> ()
 
-    .AddAttribute ("MetricTagging", "Enable metric tagging (path-stretch calculation)",
-                   BooleanValue (false),
-                   MakeBooleanAccessor (&CcnxForwardingStrategy::m_enableMetricTagging),
-                   MakeBooleanChecker ())
-
     .AddTraceSource ("OutInterests", "Interests that were transmitted",
                     MakeTraceSourceAccessor (&CcnxForwardingStrategy::m_transmittedInterestsTrace))
 
@@ -67,7 +59,6 @@
 }
 
 CcnxForwardingStrategy::CcnxForwardingStrategy ()
-  : m_enableMetricTagging (false)
 {
 }
 
@@ -121,7 +112,6 @@
                      ll::bind (&CcnxPitEntry::AddOutgoing, ll::_1, metricFace.m_face));
 
       Ptr<Packet> packetToSend = packet->Copy ();
-      TagPacket (packetToSend, metricFace);
 
       //transmission
       metricFace.m_face->Send (packetToSend);
@@ -134,27 +124,4 @@
   return propagatedCount > 0;
 }
 
-void
-CcnxForwardingStrategy::TagPacket (Ptr<Packet> packet, const CcnxFibFaceMetric &metricFace)
-{
-  // if (m_enableMetricTagging)
-    {
-      // update path information
-
-      Ptr<const WeightsPathStretchTag> origTag = packet->RemovePacketTag<WeightsPathStretchTag> ();
-      Ptr<WeightsPathStretchTag> tag;
-      if (origTag == 0)
-        {
-          tag = CreateObject<WeightsPathStretchTag> (); // create a new tag
-        }
-      else
-        {
-          tag = CreateObject<WeightsPathStretchTag> (*origTag); // will update existing tag
-        }
-
-      tag->AddPathInfo (metricFace.m_face->GetNode (), metricFace.m_routingCost);
-      packet->AddPacketTag (tag);
-    }
-}
-
 } //namespace ns3
diff --git a/model/ccnx-forwarding-strategy.h b/model/ccnx-forwarding-strategy.h
index 7be0450..ea9f692 100644
--- a/model/ccnx-forwarding-strategy.h
+++ b/model/ccnx-forwarding-strategy.h
@@ -93,14 +93,10 @@
                              Ptr<CcnxInterestHeader> &header,
                              const Ptr<const Packet> &packet);
 
-  void
-  TagPacket (Ptr<Packet> packet, const CcnxFibFaceMetric &metricFace);
-  
   TracedCallback<Ptr<const CcnxInterestHeader>, Ptr<const CcnxFace> > m_transmittedInterestsTrace;
   
 protected:  
   Ptr<CcnxPit> m_pit;
-  bool m_enableMetricTagging; 
 };
 
 } //namespace ns3
diff --git a/model/ccnx-path-stretch-tag.cc b/model/ccnx-path-stretch-tag.cc
index c8fc6dd..31adca1 100644
--- a/model/ccnx-path-stretch-tag.cc
+++ b/model/ccnx-path-stretch-tag.cc
@@ -105,11 +105,12 @@
       if (info != m_infos.begin ()) os << ",";
       NS_ASSERT (info->node != 0);
 
-      std::string name = Names::FindName (info->node);
-      if (!name.empty ())
-        os << name;
-      else
-        os << info->node->GetId ();
+      os << info->node->GetId () << "(" << Names::FindName (info->node) << ")";
+      // std::string name = Names::FindName (info->node);
+      // if (!name.empty ())
+      //   os << name;
+      // else
+      //   os << info->node->GetId ();
       os << ":" << info->weight;
     }
 }