fw: process HopLimit
refs #4806
Change-Id: I20682570409a576a6f35784f34d33ef27bf801cd
diff --git a/daemon/face/face-counters.cpp b/daemon/face/face-counters.cpp
index 52b94ac..275783f 100644
--- a/daemon/face/face-counters.cpp
+++ b/daemon/face/face-counters.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2020, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -32,7 +32,7 @@
const Transport::Counters& transportCounters)
: nInInterests(linkServiceCounters.nInInterests)
, nOutInterests(linkServiceCounters.nOutInterests)
- , nDroppedInterests(linkServiceCounters.nDroppedInterests)
+ , nInterestsExceededRetx(linkServiceCounters.nInterestsExceededRetx)
, nInData(linkServiceCounters.nInData)
, nOutData(linkServiceCounters.nOutData)
, nInNacks(linkServiceCounters.nInNacks)
diff --git a/daemon/face/face-counters.hpp b/daemon/face/face-counters.hpp
index 51af2d9..aed0ba4 100644
--- a/daemon/face/face-counters.hpp
+++ b/daemon/face/face-counters.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2020, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -70,18 +70,25 @@
public:
const PacketCounter& nInInterests;
const PacketCounter& nOutInterests;
- const PacketCounter& nDroppedInterests;
+ const PacketCounter& nInterestsExceededRetx;
const PacketCounter& nInData;
const PacketCounter& nOutData;
const PacketCounter& nInNacks;
const PacketCounter& nOutNacks;
- PacketCounter nKeptInterests;
const PacketCounter& nInPackets;
const PacketCounter& nOutPackets;
const ByteCounter& nInBytes;
const ByteCounter& nOutBytes;
+ /** \brief count of incoming Interests dropped due to HopLimit == 0
+ */
+ PacketCounter nInHopLimitZero;
+
+ /** \brief count of outgoing Interests dropped due to HopLimit == 0 on non-local faces
+ */
+ PacketCounter nOutHopLimitZero;
+
private:
const LinkService::Counters& m_linkServiceCounters;
const Transport::Counters& m_transportCounters;
diff --git a/daemon/face/link-service.cpp b/daemon/face/link-service.cpp
index a382ebe..df0fe9c 100644
--- a/daemon/face/link-service.cpp
+++ b/daemon/face/link-service.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2020, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -117,7 +117,7 @@
void
LinkService::notifyDroppedInterest(const Interest& interest)
{
- ++this->nDroppedInterests;
+ ++this->nInterestsExceededRetx;
onDroppedInterest(interest);
}
diff --git a/daemon/face/link-service.hpp b/daemon/face/link-service.hpp
index fd35723..c239cf2 100644
--- a/daemon/face/link-service.hpp
+++ b/daemon/face/link-service.hpp
@@ -50,7 +50,7 @@
/** \brief count of Interests dropped by reliability system for exceeding allowed number of retx
*/
- PacketCounter nDroppedInterests;
+ PacketCounter nInterestsExceededRetx;
/** \brief count of incoming Data packets
*/
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 5c529a8..8ab209a 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2020, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -92,6 +92,18 @@
interest.setTag(make_shared<lp::IncomingFaceIdTag>(ingress.face.getId()));
++m_counters.nInInterests;
+ // drop if HopLimit zero, decrement otherwise (if present)
+ if (interest.getHopLimit()) {
+ if (*interest.getHopLimit() < 1) {
+ NFD_LOG_DEBUG("onIncomingInterest in=" << ingress << " interest=" << interest.getName()
+ << " hop-limit=0");
+ ++const_cast<PacketCounter&>(ingress.face.getCounters().nInHopLimitZero);
+ return;
+ }
+
+ const_cast<Interest&>(interest).setHopLimit(*interest.getHopLimit() - 1);
+ }
+
// /localhost scope control
bool isViolatingLocalhost = ingress.face.getScope() == ndn::nfd::FACE_SCOPE_NON_LOCAL &&
scope_prefix::LOCALHOST.isPrefixOf(interest.getName());
@@ -230,6 +242,14 @@
Forwarder::onOutgoingInterest(const shared_ptr<pit::Entry>& pitEntry,
const FaceEndpoint& egress, const Interest& interest)
{
+ // drop if HopLimit == 0 but sending on non-local face
+ if (interest.getHopLimit() == 0 && egress.face.getScope() == ndn::nfd::FACE_SCOPE_NON_LOCAL) {
+ NFD_LOG_DEBUG("onOutgoingInterest out=" << egress << " interest=" << pitEntry->getName()
+ << " non-local hop-limit=0");
+ ++const_cast<PacketCounter&>(egress.face.getCounters().nOutHopLimitZero);
+ return;
+ }
+
NFD_LOG_DEBUG("onOutgoingInterest out=" << egress << " interest=" << pitEntry->getName());
// insert out-record