[ndnSIM] daemon: HopCount handling as a tag of an lp Packet
Change-Id: I2c25bcf29f4858049d1040a3e421e1c7151b3ba2
diff --git a/daemon/face/generic-link-service.cpp b/daemon/face/generic-link-service.cpp
index d7ebc7c..a8e9710 100644
--- a/daemon/face/generic-link-service.cpp
+++ b/daemon/face/generic-link-service.cpp
@@ -158,6 +158,14 @@
lpPacket.add<lp::PrefixAnnouncementField>(*prefixAnnouncementTag);
}
}
+
+ shared_ptr<lp::HopCountTag> hopCountTag = netPkt.getTag<lp::HopCountTag>();
+ if (hopCountTag != nullptr) {
+ lpPacket.add<lp::HopCountTagField>(*hopCountTag);
+ }
+ else {
+ lpPacket.add<lp::HopCountTagField>(0);
+ }
}
void
@@ -355,6 +363,11 @@
// forwarding expects Interest to be created with make_shared
auto interest = make_shared<Interest>(netPkt);
+ // Increment HopCount
+ if (firstPkt.has<lp::HopCountTagField>()) {
+ interest->setTag(make_shared<lp::HopCountTag>(firstPkt.get<lp::HopCountTagField>() + 1));
+ }
+
if (firstPkt.has<lp::NextHopFaceIdField>()) {
if (m_options.allowLocalFields) {
interest->setTag(make_shared<lp::NextHopFaceIdTag>(firstPkt.get<lp::NextHopFaceIdField>()));
@@ -405,6 +418,10 @@
// forwarding expects Data to be created with make_shared
auto data = make_shared<Data>(netPkt);
+ if (firstPkt.has<lp::HopCountTagField>()) {
+ data->setTag(make_shared<lp::HopCountTag>(firstPkt.get<lp::HopCountTagField>() + 1));
+ }
+
if (firstPkt.has<lp::NackField>()) {
++this->nInNetInvalid;
NFD_LOG_FACE_WARN("received Nack with Data: DROP");
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 2ee8e1b..55544fa 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -319,11 +319,14 @@
return;
}
+ shared_ptr<Data> dataCopyWithoutTag = make_shared<Data>(data);
+ dataCopyWithoutTag->removeTag<lp::HopCountTag>();
+
// CS insert
if (m_csFromNdnSim == nullptr)
- m_cs.insert(data);
+ m_cs.insert(*dataCopyWithoutTag);
else
- m_csFromNdnSim->Add(data.shared_from_this());
+ m_csFromNdnSim->Add(dataCopyWithoutTag);
std::set<Face*> pendingDownstreams;
// foreach PitEntry