<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Why not using these counters?
<div class=""><br class="">
</div>
<div class=""><a href="https://github.com/named-data-ndnSIM/NFD/blob/NFD-0.6.5-ndnSIM/daemon/face/face-counters.hpp" class="">https://github.com/named-data-ndnSIM/NFD/blob/NFD-0.6.5-ndnSIM/daemon/face/face-counters.hpp</a></div>
<div class=""><br class="">
</div>
<div class="">Thanks,</div>
<div class=""><br class="">
<div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div>Spyridon (Spyros) Mastorakis<br class="">
Assistant Professor<br class="">
Computer Science Department<br class="">
University of Nebraska, Omaha<br class="">
Peter Kiewit Institute Room 175A<br class="">
<a href="https://sites.google.com/site/spyridonmastorakis" class="">https://sites.google.com/site/spyridonmastorakis</a><br class="">
<br class="">
</div>
</div>
</div>
</div>
</div>
<div>
<blockquote type="cite" class="">
<div class="">On Feb 4, 2020, at 1:31 PM, Dyaneswaran S <<a href="mailto:dyaneswaran16028@cse.ssn.edu.in" class="">dyaneswaran16028@cse.ssn.edu.in</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">Hi guys,
<div class="">    My objective is to count the no of interest packets received in a node. Since this looked like the kind of namespace specific information that can be stored in the Measurements Table, I did the following as suggested in the NFD Developers
 Guide and other strategies in the forwarder,</div>
<div class=""><br class="">
</div>
<div class="">1. Created a Nested Counter Class inside my Strategy class. It looks something like this - </div>
<div class=""><br class="">
</div>
<div class="">
<div class="">  class CounterInfo : public StrategyInfo</div>
<div class="">  {</div>
<div class="">        public:</div>
<div class="">        static constexpr int</div>
<div class="">        getTypeId()</div>
<div class="">        {   return 1009; }</div>
<div class=""><br class="">
</div>
<div class="">        CounterInfo() : m_count(0)</div>
<div class="">        {</div>
<div class="">        }</div>
<div class=""><br class="">
</div>
<div class="">        void</div>
<div class="">        increment()</div>
<div class="">        {  ++m_count;}</div>
<div class=""><br class="">
</div>
<div class="">        uint64_t</div>
<div class="">        get()</div>
<div class="">        {   return m_count; }</div>
<div class="">        private:</div>
<div class="">        uint64_t m_count;</div>
<div class="">  };</div>
</div>
<div class=""><br class="">
</div>
<div class="">2. Then, in my AfterReceiveInterest() Trigger, I retrieve the entry using the piEntry APIs like this,</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">          CounterInfo *counter = pitEntry->getStrategyInfo<CounterInfo>();</div>
<div class="">          if(pitEntry->getStrategyInfo<CounterInfo>() == nullptr)</div>
<div class="">          {</div>
<div class="">                counter = new CounterInfo();</div>
<div class="">                counter->increment();</div>
<div class="">                pitEntry->insertStrategyInfo<CounterInfo>(*counter);</div>
<div class="">          }</div>
<div class="">          else</div>
<div class="">          {</div>
<div class="">                counter->increment();</div>
<div class="">          }</div>
</div>
<div class=""><br class="">
</div>
<div class="">3. I thought the above 2 steps were sufficient, but apparently not. So after more digging, I found out I had to extend the Lifetime of Measurements Table Entries. I was not sure how Measurements and StrategyInfo Class were interrelated but I did
 it anyway. (superstitious, I agree).  That looked like - </div>
<div class="">
<div class=""><br class="">
</div>
<div class=""> this->getMeasurements().extendLifetime(*entry, MEASUREMENTS_LIFETIME);</div>
<div class=""><br class="">
</div>
</div>
<div class="">But even then, I didnt get the expected output. That is the counter variable is not counting the packets.</div>
<div class=""><br class="">
</div>
<div class="">Instead, its count never gets past 1. I am sure this is because its getting instantiated newly everytime this strategy is applied.</div>
<div class=""><br class="">
</div>
<div class="">Somehow, its not accessing the already stored strategy info. I thought it was because of the different pit entries causing new measurement entries (since measurements are accessed via pitentries). But I made sure that didnt happen as well.</div>
<div class=""><br class="">
</div>
<div class="">I thought about approximating the count of interest packets to the no. of PIT inrecords but that was ridiculous. I needed the actual count of interest packets. </div>
<div class=""><br class="">
</div>
<div class="">Any pointers?? Any of my assumptions wrong?</div>
<div class="">Am I doing it the hard/correct way? Any other methods?</div>
<div class=""><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>