mgmt: add satisfied and unsatisfied counters for forwarder status management

refs: #4720

Change-Id: I69545e0fbf4ebba75a292644631c2cf9fdaa301a
diff --git a/daemon/fw/forwarder-counters.hpp b/daemon/fw/forwarder-counters.hpp
index 5a63406..ca9eb4d 100644
--- a/daemon/fw/forwarder-counters.hpp
+++ b/daemon/fw/forwarder-counters.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2017,  Regents of the University of California,
+ * Copyright (c) 2014-2018,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -41,6 +41,8 @@
   PacketCounter nOutData;
   PacketCounter nInNacks;
   PacketCounter nOutNacks;
+  PacketCounter nSatisfiedInterests;
+  PacketCounter nUnsatisfiedInterests;
 
   PacketCounter nCsHits;
   PacketCounter nCsMisses;
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 7e28db2..d55da5a 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -246,6 +246,14 @@
   // Dead Nonce List insert if necessary
   this->insertDeadNonceList(*pitEntry, 0);
 
+  // Increment satisfied/unsatisfied Interests counter
+  if (pitEntry->isSatisfied) {
+    ++m_counters.nSatisfiedInterests;
+  }
+  else {
+    ++m_counters.nUnsatisfiedInterests;
+  }
+
   // PIT delete
   scheduler::cancel(pitEntry->expiryTimer);
   m_pit.erase(pitEntry.get());
diff --git a/daemon/mgmt/forwarder-status-manager.cpp b/daemon/mgmt/forwarder-status-manager.cpp
index 108914f..e0a19d2 100644
--- a/daemon/mgmt/forwarder-status-manager.cpp
+++ b/daemon/mgmt/forwarder-status-manager.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017,  Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -61,7 +61,9 @@
         .setNInData(counters.nInData)
         .setNOutData(counters.nOutData)
         .setNInNacks(counters.nInNacks)
-        .setNOutNacks(counters.nOutNacks);
+        .setNOutNacks(counters.nOutNacks)
+        .setNSatisfiedInterests(counters.nSatisfiedInterests)
+        .setNUnsatisfiedInterests(counters.nUnsatisfiedInterests);
 
   return status;
 }
diff --git a/tests/daemon/mgmt/forwarder-status-manager.t.cpp b/tests/daemon/mgmt/forwarder-status-manager.t.cpp
index 3b30b5c..3df77ec 100644
--- a/tests/daemon/mgmt/forwarder-status-manager.t.cpp
+++ b/tests/daemon/mgmt/forwarder-status-manager.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017,  Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -63,10 +63,19 @@
   m_forwarder.getMeasurements().get("ndn:/measurements3");
   m_forwarder.getCs().insert(*makeData("ndn:/cs1"));
   m_forwarder.getCs().insert(*makeData("ndn:/cs2"));
+  shared_ptr<pit::Entry> pitA = m_forwarder.getPit().insert(*makeInterest("ndn:/pitA")).first;
+  pitA->isSatisfied = false;
+  m_forwarder.onInterestFinalize(pitA);
+  shared_ptr<pit::Entry> pitB = m_forwarder.getPit().insert(*makeInterest("ndn:/pitB")).first;
+  pitB->isSatisfied = true;
+  m_forwarder.onInterestFinalize(pitB);
+
   BOOST_CHECK_GE(m_forwarder.getFib().size(), 1);
   BOOST_CHECK_GE(m_forwarder.getPit().size(), 4);
   BOOST_CHECK_GE(m_forwarder.getMeasurements().size(), 3);
   BOOST_CHECK_GE(m_forwarder.getCs().size(), 2);
+  BOOST_CHECK_EQUAL(m_forwarder.getCounters().nSatisfiedInterests, 1);
+  BOOST_CHECK_EQUAL(m_forwarder.getCounters().nUnsatisfiedInterests, 1);
 
   // request
   time::system_clock::TimePoint beforeRequest = time::system_clock::now();
@@ -93,6 +102,9 @@
   BOOST_CHECK_EQUAL(status.getNMeasurementsEntries(), m_forwarder.getMeasurements().size());
   BOOST_CHECK_EQUAL(status.getNCsEntries(), m_forwarder.getCs().size());
   // TODO#3325 check packet counter values
+
+  BOOST_CHECK_EQUAL(status.getNSatisfiedInterests(), m_forwarder.getCounters().nSatisfiedInterests);
+  BOOST_CHECK_EQUAL(status.getNUnsatisfiedInterests(), m_forwarder.getCounters().nUnsatisfiedInterests);
 }
 
 BOOST_AUTO_TEST_SUITE_END() // TestForwarderStatusManager