[ndnSIM] fw: Fix hop count of data packet received from content store
Change-Id: I3b863344ec040bc61c8100843e13fce814766b1f
Refs: #2764
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index bf1cb39..1c8d53e 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -28,6 +28,9 @@
#include "core/random.hpp"
#include "strategy.hpp"
#include "face/null-face.hpp"
+
+#include "utils/ndn-ns3-packet-tag.hpp"
+
#include <boost/random/uniform_int_distribution.hpp>
namespace nfd {
@@ -306,11 +309,20 @@
return;
}
+ // Remove Ptr<Packet> from the Data before inserting into cache, serving two purposes
+ // - reduce amount of memory used by cached entries
+ // - remove all tags that (e.g., hop count tag) that could have been associated with Ptr<Packet>
+ //
+ // Copying of Data is relatively cheap operation, as it copies (mostly) a collection of Blocks
+ // pointing to the same underlying memory buffer.
+ shared_ptr<Data> dataCopyWithoutPacket = make_shared<Data>(data);
+ dataCopyWithoutPacket->removeTag<ns3::ndn::Ns3PacketTag>();
+
// CS insert
if (m_csFromNdnSim == nullptr)
- m_cs.insert(data);
+ m_cs.insert(*dataCopyWithoutPacket);
else
- m_csFromNdnSim->Add(data.shared_from_this());
+ m_csFromNdnSim->Add(dataCopyWithoutPacket);
std::set<shared_ptr<Face> > pendingDownstreams;
// foreach PitEntry