path stretch support
diff --git a/model/ccnx-bestroute-strategy.cc b/model/ccnx-bestroute-strategy.cc
index 2bbe287..4bb8199 100644
--- a/model/ccnx-bestroute-strategy.cc
+++ b/model/ccnx-bestroute-strategy.cc
@@ -62,6 +62,8 @@
 {
   NS_LOG_FUNCTION (this);
 
+  
+
   // Try to work out with just green faces
   bool greenOk = PropagateInterestViaGreen (pitEntry, incomingFace, header, packet);
   if (greenOk)
@@ -99,6 +101,14 @@
       m_pit->modify (m_pit->iterator_to (pitEntry),
                      ll::bind(&CcnxPitEntry::AddOutgoing, ll::_1, metricFace.m_face));
 
+      //update path stretch
+      WeightsPathStretchTag pathStretch;
+      //packet->PeekPacketTag(pathStretch);
+      
+      pathStretch.AddNewHop(metricFace.m_routingCost);
+      packet->AddPacketTag(pathStretch);
+
+      //transmission
       metricFace.m_face->Send (packet->Copy ());
       m_transmittedInterestsTrace (header, metricFace.m_face);
       
diff --git a/model/ccnx-flooding-strategy.cc b/model/ccnx-flooding-strategy.cc
index 5b8542d..27133b4 100644
--- a/model/ccnx-flooding-strategy.cc
+++ b/model/ccnx-flooding-strategy.cc
@@ -116,6 +116,15 @@
       //     NS_LOG_ERROR ("size: " << pitEntry.m_outgoing.size ());
       //   }
 
+
+      //update path stretch
+      WeightsPathStretchTag pathStretch;
+      //packet->PeekPacketTag(pathStretch);
+      
+      pathStretch.AddNewHop(metricFace.m_routingCost);
+      packet->AddPacketTag(pathStretch);
+      
+      //transmission
       metricFace.m_face->Send (packet->Copy ());
       m_transmittedInterestsTrace (header, metricFace.m_face);
       
diff --git a/model/ccnx-forwarding-strategy.cc b/model/ccnx-forwarding-strategy.cc
index fbd4613..1253571 100644
--- a/model/ccnx-forwarding-strategy.cc
+++ b/model/ccnx-forwarding-strategy.cc
@@ -111,6 +111,14 @@
       m_pit->modify (m_pit->iterator_to (pitEntry),
                      ll::bind(&CcnxPitEntry::AddOutgoing, ll::_1, metricFace.m_face));
 
+      //update path stretch
+      WeightsPathStretchTag pathStretch;
+      //packet->PeekPacketTag(pathStretch);
+      
+      pathStretch.AddNewHop(metricFace.m_routingCost);
+      packet->AddPacketTag(pathStretch);
+
+      //transmission
       metricFace.m_face->Send (packet->Copy ());
       m_transmittedInterestsTrace (header, metricFace.m_face);
       
diff --git a/model/ccnx-forwarding-strategy.h b/model/ccnx-forwarding-strategy.h
index 23c15a5..ed9cd82 100644
--- a/model/ccnx-forwarding-strategy.h
+++ b/model/ccnx-forwarding-strategy.h
@@ -25,6 +25,7 @@
 #include "ns3/callback.h"
 #include "ns3/object.h"
 #include "ns3/traced-callback.h"
+#include "ccnx-path-stretch-tag.h"
 
 namespace ns3 {
 
diff --git a/model/ccnx-l3-protocol.cc b/model/ccnx-l3-protocol.cc
index 223c578..d6391c5 100644
--- a/model/ccnx-l3-protocol.cc
+++ b/model/ccnx-l3-protocol.cc
@@ -236,6 +236,16 @@
   return 0;
 }
 
+Ptr<NetDevice>
+CcnxL3Protocol::GetNetDeviceByFace(Ptr<CcnxFace> face) const
+{
+    Ptr<CcnxNetDeviceFace> netDeviceFace = DynamicCast<CcnxNetDeviceFace> (face);
+    if (netDeviceFace == 0) 
+      return 0;
+
+    return netDeviceFace->GetNetDevice ();
+}
+
 uint32_t 
 CcnxL3Protocol::GetNFaces (void) const
 {
diff --git a/model/ccnx-l3-protocol.h b/model/ccnx-l3-protocol.h
index d3e1b44..f4b8f61 100644
--- a/model/ccnx-l3-protocol.h
+++ b/model/ccnx-l3-protocol.h
@@ -118,6 +118,9 @@
   virtual Ptr<CcnxFace>
   GetFaceByNetDevice (Ptr<NetDevice> netDevice) const;
   
+  virtual Ptr<NetDevice>
+  GetNetDeviceByFace (Ptr<CcnxFace> face) const;
+  
   Ptr<CcnxPit> GetPit();
   
   // void ScheduleLeakage();
diff --git a/model/ccnx-local-face.cc b/model/ccnx-local-face.cc
index 7b4413c..fe7271f 100644
--- a/model/ccnx-local-face.cc
+++ b/model/ccnx-local-face.cc
@@ -44,6 +44,8 @@
   static TypeId tid = TypeId ("ns3::CcnxLocalFace")
     .SetParent<CcnxFace> ()
     .SetGroupName ("Ccnx")
+    .AddTraceSource ("ReceivedPathStretchTags", "ReceivedPathStretchTags",
+                    MakeTraceSourceAccessor (&CcnxLocalFace::m_receivedPathStretchTags))
     ;
   return tid;
 }
@@ -106,7 +108,19 @@
             if (header->GetNack () > 0)
               m_app->OnNack (header);
             else
-              m_app->OnInterest (header);
+              {
+                WeightsPathStretchTag totalStretch;
+                
+                WeightsPathStretchTag pathStretch;
+                while(p->RemovePacketTag(pathStretch) == true)
+                {
+                    totalStretch.AddNewHop (pathStretch.GetValue ());
+                }
+                
+                m_receivedPathStretchTags (totalStretch,header,m_app);
+                
+                m_app->OnInterest (header);
+              }
           
             break;
           }
diff --git a/model/ccnx-local-face.h b/model/ccnx-local-face.h
index 63458f2..b1d5478 100644
--- a/model/ccnx-local-face.h
+++ b/model/ccnx-local-face.h
@@ -23,6 +23,8 @@
 #define CCNX_LOCAL_FACE_H
 
 #include "ccnx-face.h"
+#include "ns3/traced-callback.h"
+#include "ccnx-path-stretch-tag.h"
 
 namespace ns3 
 {
@@ -75,6 +77,9 @@
 
 private:
   Ptr<CcnxApp> m_app;
+  
+  TracedCallback<WeightsPathStretchTag,Ptr<const CcnxInterestHeader>, 
+                  Ptr<CcnxApp> > m_receivedPathStretchTags;
 };
 
 std::ostream& operator<< (std::ostream& os, const CcnxLocalFace &localFace);
diff --git a/model/ccnx-path-stretch-tag.cc b/model/ccnx-path-stretch-tag.cc
new file mode 100644
index 0000000..f2759be
--- /dev/null
+++ b/model/ccnx-path-stretch-tag.cc
@@ -0,0 +1,92 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Ilya Moiseenko <iliamo@cs.ucla.edu>
+ */
+ 
+#include "ccnx-path-stretch-tag.h"
+
+namespace ns3 {
+
+WeightsPathStretchTag::WeightsPathStretchTag()
+    : m_weightPathStretch(0)
+{
+}
+
+WeightsPathStretchTag::WeightsPathStretchTag(const WeightsPathStretchTag &o)
+    : m_weightPathStretch(o.m_weightPathStretch)
+{
+}
+
+WeightsPathStretchTag &WeightsPathStretchTag::operator = (const WeightsPathStretchTag &o)
+{
+    if (this == &o)
+        return *this;
+
+    m_weightPathStretch = o.m_weightPathStretch;
+    return *this;
+}
+
+bool WeightsPathStretchTag::operator == (WeightsPathStretchTag const &o) const
+{
+    return (m_weightPathStretch == o.m_weightPathStretch);
+}
+
+TypeId WeightsPathStretchTag::GetTypeId(void)
+{
+    static TypeId tid = TypeId("ns3::WeightsPathStretchTag")
+        .SetParent<Tag>()
+        .AddConstructor<WeightsPathStretchTag>()
+        ;
+    return tid;
+}
+
+TypeId WeightsPathStretchTag::GetInstanceTypeId(void) const
+{
+    return GetTypeId();
+}
+
+uint32_t WeightsPathStretchTag::GetSerializedSize(void) const
+{
+    return sizeof(uint32_t);
+}
+
+void WeightsPathStretchTag::Serialize(TagBuffer i) const
+{
+    i.WriteU32(m_weightPathStretch);
+}
+
+void WeightsPathStretchTag::Deserialize(TagBuffer i)
+{
+    m_weightPathStretch = i.ReadU32();
+}
+
+void WeightsPathStretchTag::Print(std::ostream &os) const
+{
+    os << "Path Stretch (Weights) = " << m_weightPathStretch << std::endl;
+}
+
+void WeightsPathStretchTag::AddNewHop(uint32_t weight)
+{
+    m_weightPathStretch +=weight;
+}
+uint32_t WeightsPathStretchTag::GetValue()
+{
+  return m_weightPathStretch;
+}
+} // namespace ns3
+
diff --git a/model/ccnx-path-stretch-tag.h b/model/ccnx-path-stretch-tag.h
new file mode 100644
index 0000000..dd49041
--- /dev/null
+++ b/model/ccnx-path-stretch-tag.h
@@ -0,0 +1,89 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Ilya Moiseenko <iliamo@cs.ucla.edu>
+ */
+ 
+#include "ns3/tag.h"
+ 
+#ifndef PATH_STRETCH_TAG_H
+#define PATH_STRETCH_TAG_H
+
+namespace ns3 {
+
+class Node;
+class Packet;
+
+//#define PATH_SPLICING_MAX_N_HOPS 38
+//#define PATH_SPLICING_MAX_SLICE_INDEX 16
+
+class WeightsPathStretchTag : public Tag
+{
+public:
+    WeightsPathStretchTag();
+    WeightsPathStretchTag(const WeightsPathStretchTag &o);
+    WeightsPathStretchTag &operator = (const WeightsPathStretchTag &o);
+
+    bool operator == (WeightsPathStretchTag const &o) const;
+
+    static TypeId GetTypeId(void);
+    virtual TypeId GetInstanceTypeId(void) const;
+
+    virtual uint32_t GetSerializedSize(void) const;
+    virtual void Serialize(TagBuffer i) const;
+    virtual void Deserialize(TagBuffer i);
+    virtual void Print(std::ostream &os) const;
+
+    void AddNewHop(uint32_t weight);
+    uint32_t GetValue();
+    
+private:
+    uint32_t m_weightPathStretch;
+};
+
+class DelaysPathStretchTag : public Tag
+{
+public:
+    DelaysPathStretchTag();
+    //PathSplicingPathTag(const PathSplicingPathTag &o);
+    //PathSplicingPathTag &operator = (const PathSplicingPathTag &o);
+
+    //bool operator == (PathSplicingPathTag const &o) const;
+
+    static TypeId GetTypeId(void);
+    virtual TypeId GetInstanceTypeId(void) const;
+
+    virtual uint32_t GetSerializedSize(void) const;
+    virtual void Serialize(TagBuffer i) const;
+    virtual void Deserialize(TagBuffer i);
+    virtual void Print(std::ostream &os) const;
+
+    int GetNHops();
+    void AddNewHop(double delay);
+    int GetCurrentHop();
+    void RemoveCurrentHop();
+    //void RandomizeTags(UniformVariable &rand, uint32_t max);
+
+private:
+    std::list<double> m_delays;
+};
+
+
+} // namespace ns3
+
+
+#endif /* PATH_STRETCH_TAG_H */
\ No newline at end of file