mgmt: augment ForwarderStatus with counters for satisfied and unsatisfied Interests
refs: #4720
Change-Id: I9413aef59a9f4669beaaa214abd93c4bb40e622f
diff --git a/src/encoding/tlv-nfd.hpp b/src/encoding/tlv-nfd.hpp
index dcaed7e..6eff057 100644
--- a/src/encoding/tlv-nfd.hpp
+++ b/src/encoding/tlv-nfd.hpp
@@ -75,14 +75,16 @@
FaceEventKind = 193,
// ForwarderStatus and FaceStatus counters
- NInInterests = 144,
- NInData = 145,
- NInNacks = 151,
- NOutInterests = 146,
- NOutData = 147,
- NOutNacks = 152,
- NInBytes = 148,
- NOutBytes = 149,
+ NInInterests = 144,
+ NInData = 145,
+ NInNacks = 151,
+ NOutInterests = 146,
+ NOutData = 147,
+ NOutNacks = 152,
+ NInBytes = 148,
+ NOutBytes = 149,
+ NSatisfiedInterests = 153,
+ NUnsatisfiedInterests = 154,
// Content Store Management
CsInfo = 128,
diff --git a/src/mgmt/nfd/forwarder-status.cpp b/src/mgmt/nfd/forwarder-status.cpp
index 1661aa7..fb583d8 100644
--- a/src/mgmt/nfd/forwarder-status.cpp
+++ b/src/mgmt/nfd/forwarder-status.cpp
@@ -42,6 +42,8 @@
, m_nOutInterests(0)
, m_nOutData(0)
, m_nOutNacks(0)
+ , m_nSatisfiedInterests(0)
+ , m_nUnsatisfiedInterests(0)
{
}
@@ -56,6 +58,8 @@
{
size_t totalLength = 0;
+ totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NUnsatisfiedInterests, m_nUnsatisfiedInterests);
+ totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NSatisfiedInterests, m_nSatisfiedInterests);
totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutNacks, m_nOutNacks);
totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutData, m_nOutData);
totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutInterests, m_nOutInterests);
@@ -217,6 +221,22 @@
else {
BOOST_THROW_EXCEPTION(Error("missing required NOutNacks field"));
}
+
+ if (val != m_wire.elements_end() && val->type() == tlv::nfd::NSatisfiedInterests) {
+ m_nSatisfiedInterests = readNonNegativeInteger(*val);
+ ++val;
+ }
+ else {
+ BOOST_THROW_EXCEPTION(Error("missing required NSatisfiedInterests field"));
+ }
+
+ if (val != m_wire.elements_end() && val->type() == tlv::nfd::NUnsatisfiedInterests) {
+ m_nUnsatisfiedInterests = readNonNegativeInteger(*val);
+ ++val;
+ }
+ else {
+ BOOST_THROW_EXCEPTION(Error("missing required NUnsatisfiedInterests field"));
+ }
}
ForwarderStatus&
@@ -331,6 +351,22 @@
return *this;
}
+ForwarderStatus&
+ForwarderStatus::setNSatisfiedInterests(uint64_t nSatisfiedInterests)
+{
+ m_wire.reset();
+ m_nSatisfiedInterests = nSatisfiedInterests;
+ return *this;
+}
+
+ForwarderStatus&
+ForwarderStatus::setNUnsatisfiedInterests(uint64_t nUnsatisfiedInterests)
+{
+ m_wire.reset();
+ m_nUnsatisfiedInterests = nUnsatisfiedInterests;
+ return *this;
+}
+
bool
operator==(const ForwarderStatus& a, const ForwarderStatus& b)
{
@@ -347,7 +383,9 @@
a.getNInNacks() == b.getNInNacks() &&
a.getNOutInterests() == b.getNOutInterests() &&
a.getNOutData() == b.getNOutData() &&
- a.getNOutNacks() == b.getNOutNacks();
+ a.getNOutNacks() == b.getNOutNacks() &&
+ a.getNSatisfiedInterests() == b.getNSatisfiedInterests() &&
+ a.getNUnsatisfiedInterests() == b.getNUnsatisfiedInterests();
}
std::ostream&
@@ -366,7 +404,9 @@
<< " Data: {in: " << status.getNInData() << ", "
<< "out: " << status.getNOutData() << "},\n"
<< " Nacks: {in: " << status.getNInNacks() << ", "
- << "out: " << status.getNOutNacks() << "}}\n"
+ << "out: " << status.getNOutNacks() << "},\n"
+ << " SatisfiedInterests: " << status.getNSatisfiedInterests() << ",\n"
+ << " UnsatisfiedInterests: " << status.getNUnsatisfiedInterests() << "}\n"
<< " )";
return os;
diff --git a/src/mgmt/nfd/forwarder-status.hpp b/src/mgmt/nfd/forwarder-status.hpp
index f222f80..0991e6c 100644
--- a/src/mgmt/nfd/forwarder-status.hpp
+++ b/src/mgmt/nfd/forwarder-status.hpp
@@ -196,6 +196,24 @@
ForwarderStatus&
setNOutNacks(uint64_t nOutNacks);
+ uint64_t
+ getNSatisfiedInterests() const
+ {
+ return m_nSatisfiedInterests;
+ }
+
+ ForwarderStatus&
+ setNSatisfiedInterests(uint64_t nSatisfiedInterests);
+
+ uint64_t
+ getNUnsatisfiedInterests() const
+ {
+ return m_nUnsatisfiedInterests;
+ }
+
+ ForwarderStatus&
+ setNUnsatisfiedInterests(uint64_t nUnsatisfiedInterests);
+
private:
std::string m_nfdVersion;
time::system_clock::TimePoint m_startTimestamp;
@@ -211,6 +229,8 @@
uint64_t m_nOutInterests;
uint64_t m_nOutData;
uint64_t m_nOutNacks;
+ uint64_t m_nSatisfiedInterests;
+ uint64_t m_nUnsatisfiedInterests;
mutable Block m_wire;
};