apps+model+utils: Implementing Interest/Data hop counting using new PacketTag
diff --git a/model/fw/ndn-forwarding-strategy.cc b/model/fw/ndn-forwarding-strategy.cc
index 4bab0a1..0e773f9 100644
--- a/model/fw/ndn-forwarding-strategy.cc
+++ b/model/fw/ndn-forwarding-strategy.cc
@@ -37,6 +37,8 @@
#include "ns3/boolean.h"
#include "ns3/string.h"
+#include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.h"
+
#include <boost/ref.hpp>
#include <boost/foreach.hpp>
#include <boost/lambda/lambda.hpp>
@@ -171,7 +173,13 @@
boost::tie (contentObject, contentObjectHeader, payload) = m_contentStore->Lookup (header);
if (contentObject != 0)
{
- NS_ASSERT (contentObjectHeader != 0);
+ NS_ASSERT (contentObjectHeader != 0);
+
+ FwHopCountTag hopCountTag;
+ if (origPacket->PeekPacketTag (hopCountTag))
+ {
+ contentObject->AddPacketTag (hopCountTag);
+ }
pitEntry->AddIncoming (inFace/*, Seconds (1.0)*/);
@@ -223,8 +231,20 @@
}
else
{
- // Add or update entry in the content store
- m_contentStore->Add (header, payload);
+ FwHopCountTag hopCountTag;
+ if (payload->PeekPacketTag (hopCountTag))
+ {
+ Ptr<Packet> payloadCopy = payload->Copy ();
+ payloadCopy->RemovePacketTag (hopCountTag);
+
+ // Add or update entry in the content store
+ m_contentStore->Add (header, payloadCopy);
+ }
+ else
+ {
+ // Add or update entry in the content store
+ m_contentStore->Add (header, payload); // no need for extra copy
+ }
}
while (pitEntry != 0)
diff --git a/model/ndn-face.cc b/model/ndn-face.cc
index f91fc19..4ae7ee9 100644
--- a/model/ndn-face.cc
+++ b/model/ndn-face.cc
@@ -32,7 +32,7 @@
#include "ns3/random-variable.h"
#include "ns3/pointer.h"
-// #include "ns3/weights-path-stretch-tag.h"
+#include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.h"
#include <boost/ref.hpp>
@@ -55,11 +55,6 @@
MakeUintegerAccessor (&Face::m_id),
MakeUintegerChecker<uint32_t> ())
- // .AddAttribute ("MetricTagging", "Enable metric tagging (path-stretch calculation)",
- // BooleanValue (false),
- // MakeBooleanAccessor (&Face::m_enableMetricTagging),
- // MakeBooleanChecker ())
-
.AddTraceSource ("NdnTx", "Transmitted packet trace",
MakeTraceSourceAccessor (&Face::m_txTrace))
.AddTraceSource ("NdnRx", "Received packet trace",
@@ -81,7 +76,6 @@
, m_ifup (false)
, m_id ((uint32_t)-1)
, m_metric (0)
- // , m_enableMetricTagging (false)
{
NS_LOG_FUNCTION (this);
@@ -128,23 +122,13 @@
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);
- // }
+ FwHopCountTag hopCount;
+ bool tagExists = packet->RemovePacketTag (hopCount);
+ if (tagExists)
+ {
+ hopCount.Increment ();
+ packet->AddPacketTag (hopCount);
+ }
bool ok = SendImpl (packet);
if (ok)
diff --git a/model/ndn-face.h b/model/ndn-face.h
index acb1c90..f5aba0f 100644
--- a/model/ndn-face.h
+++ b/model/ndn-face.h
@@ -215,8 +215,6 @@
uint32_t m_id; ///< \brief id of the interface in Ndn stack (per-node uniqueness)
uint32_t m_metric; ///< \brief metric of the face
- // bool m_enableMetricTagging;
-
TracedCallback<Ptr<const Packet> > m_txTrace;
TracedCallback<Ptr<const Packet> > m_rxTrace;
TracedCallback<Ptr<const Packet> > m_dropTrace;