[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 2a7f527..7ed58d2 100644
--- a/daemon/face/generic-link-service.cpp
+++ b/daemon/face/generic-link-service.cpp
@@ -98,6 +98,14 @@
if (congestionMarkTag != nullptr) {
lpPacket.add<lp::CongestionMarkField>(*congestionMarkTag);
}
+
+ shared_ptr<lp::HopCountTag> hopCountTag = netPkt.getTag<lp::HopCountTag>();
+ if (hopCountTag != nullptr) {
+ lpPacket.add<lp::HopCountTagField>(*hopCountTag);
+ }
+ else {
+ lpPacket.add<lp::HopCountTagField>(0);
+ }
}
void
@@ -222,6 +230,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>()));
@@ -257,6 +270,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");