<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Hello Everyone,<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
So right now I am running  a scenario where I have one consumer running four client requests. Based on the ndn-simple-with-content-freshness example:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
<div>/**</div>
<div> * Copyright (c) 2011-2015  Regents of the University of California.</div>
<div> *</div>
<div> * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and</div>
<div> * contributors.</div>
<div> *</div>
<div> * ndnSIM is free software: you can redistribute it and/or modify it under the terms</div>
<div> * of the GNU General Public License as published by the Free Software Foundation,</div>
<div> * either version 3 of the License, or (at your option) any later version.</div>
<div> *</div>
<div> * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;</div>
<div> * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR</div>
<div> * PURPOSE.  See the GNU General Public License for more details.</div>
<div> *</div>
<div> * You should have received a copy of the GNU General Public License along with</div>
<div> * ndnSIM, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.</div>
<div> **/</div>
<div><br>
</div>
<div>// ndn-simple-with-content-freshness.cpp</div>
<div><br>
</div>
<div>#include "ns3/core-module.h"</div>
<div>#include "ns3/network-module.h"</div>
<div>#include "ns3/point-to-point-module.h"</div>
<div>#include "ns3/ndnSIM-module.h"</div>
<div><br>
</div>
<div>namespace ns3 {</div>
<div><br>
</div>
<div>/**</div>
<div> * This scenario simulates a very simple network topology:</div>
<div> *</div>
<div> *</div>
<div> *      +----------+     1Mbps      +--------+     1Mbps      +----------+</div>
<div> *      | consumer | <------------> | router | <------------> | producer |</div>
<div> *      +----------+         10ms   +--------+          10ms  +----------+</div>
<div> *</div>
<div> * This scenario demonstrates how to use content store that responds to Freshness parameter set in</div>
<div> * data packets.  In other words, if the producer set FreshnessPeriod field to 2 seconds, the</div>
<div> * corresponding data packet will not be considered fresh for more than 2 seconds (can be cached</div>
<div> * for a shorter time, if entry is evicted earlier)</div>
<div> *</div>
<div> *     NS_LOG=OneInterestRequester ./waf --run ndn-simple-with-content-freshness</div>
<div> */</div>
<div><br>
</div>
<div>int</div>
<div>main(int argc, char* argv[])</div>
<div>{</div>
<div>  // setting default parameters for PointToPoint links and channels</div>
<div>  Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("1Mbps"));</div>
<div>  Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("10ms"));</div>
<div>  Config::SetDefault("ns3::QueueBase::MaxSize", StringValue("20p"));</div>
<div><br>
</div>
<div>  // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize</div>
<div>  CommandLine cmd;</div>
<div>  cmd.Parse(argc, argv);</div>
<div><br>
</div>
<div>  // Creating nodes</div>
<div>  NodeContainer nodes;</div>
<div>  nodes.Create(3);</div>
<div><br>
</div>
<div>  // Connecting nodes using two links</div>
<div>  PointToPointHelper p2p;</div>
<div>  p2p.Install(nodes.Get(0), nodes.Get(1));</div>
<div>  p2p.Install(nodes.Get(1), nodes.Get(2));</div>
<div><br>
</div>
<div>  // Install Ndn stack on all nodes</div>
<div>  ndn::StackHelper ndnHelper;</div>
<div>  ndnHelper.SetDefaultRoutes(true);</div>
<div>  ndnHelper.setCsSize(2); // allow just 2 entries to be cached</div>
<div>  ndnHelper.setPolicy("nfd::cs::lru");</div>
<div>  ndnHelper.InstallAll();</div>
<div><br>
</div>
<div>  // Installing applications</div>
<div><br>
</div>
<div>  // Consumer</div>
<div>  ndn::AppHelper consumerHelper("OneInterestRequester");</div>
<div><br>
</div>
<div>  // /*</div>
<div>  //   1) at time 1 second requests Data from a producer that does not specify freshness Client 1<br>
</div>
<div>  //   <span style="background-color: rgb(255, 255, 0);">2</span>) at time 10 seconds requests the same Data packet as client 1</div>
<div><br>
</div>
<div>  //   3) at time 2 seconds requests Data from a producer that specifies freshness set to 2 seconds</div>
<div>  //   4) at time 12 seconds requests the same Data packet as client 3</div>
<div><br>
</div>
<div>  //   Expectation:</div>
<div>  //   Interests from 1, 3 and 4 will reach producers</div>
<div>  //   <span style="background-color: rgb(255, 255, 0);">Interset from 2 will be served from cache</span></div>
<div>  //  */</div>
<div><br>
</div>
<div>  consumerHelper.SetPrefix("/no-freshness");</div>
<div>  consumerHelper.Install(nodes.Get(0)).Start(Seconds(1));</div>
<div>  //nfd::cs::insert("/no-freshness",true);</div>
<div>  consumerHelper.Install(nodes.Get(0)).Start(Seconds(10));</div>
<div><br>
</div>
<div>  consumerHelper.SetPrefix("/with-freshness");</div>
<div>  consumerHelper.Install(nodes.Get(0)).Start(Seconds(2));</div>
<div>  consumerHelper.Install(nodes.Get(0)).Start(Seconds(12));</div>
<div><br>
</div>
<div><br>
</div>
<div>  </div>
<div>  // Producer</div>
<div>  ndn::AppHelper producerHelper("ns3::ndn::Producer");</div>
<div>  producerHelper.SetAttribute("PayloadSize", StringValue("1024"));</div>
<div><br>
</div>
<div>  producerHelper.SetAttribute("Freshness", TimeValue(Years(100))); // freshness long enough</div>
<div>  producerHelper.SetPrefix("/no-freshness");</div>
<div>  producerHelper.Install(nodes.Get(2)); // last node</div>
<div><br>
</div>
<div>  producerHelper.SetAttribute("Freshness", TimeValue(Seconds(2.0))); // freshness 2 seconds (!!!</div>
<div>                                                                     // freshness granularity is 1</div>
<div>                                                                     // seconds !!!)</div>
<div>  producerHelper.SetPrefix("/with-freshness");</div>
<div>  producerHelper.Install(nodes.Get(2)); // last node</div>
<div><br>
</div>
<div>  </div>
<div>  ndn::L3RateTracer::InstallAll("../traces/rate-trace.txt", Seconds(1.0));</div>
<div>  L2RateTracer::InstallAll("../traces/drop-trace.txt", Seconds(1.0));</div>
<div>  ndn::AppDelayTracer::InstallAll("../traces/app-delays-trace.txt" );</div>
<div>  ndn::CsTracer::InstallAll("../traces/cs-trace.txt", Seconds(1.0));</div>
<div><br>
</div>
<div>  </div>
<div><br>
</div>
<div>  Simulator::Stop(Seconds(30.0));</div>
<div><br>
</div>
<div>  Simulator::Run();</div>
<div>  Simulator::Destroy();</div>
<div><br>
</div>
<div>  return 0;</div>
<div>}</div>
<div>} // namespace ns3</div>
<div><br>
</div>
<div>int</div>
<div>main(int argc, char* argv[])</div>
<div>{</div>
<div>  return ns3::main(argc, argv);</div>
}<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
That's the current code I am working with.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
I want to prove without a shadow of a doubt that the 2nd Client is retrieving data from a cache hit basically. I can show it in visualizer but I was requested to also have this information in some trace file. I thought cs-tracer would work but all I get are
 0s in Cache hits and Misses even though I know that the information is being retrieved from the cache. Then I would use the app-delays trace file to show how the Round trip time of this client would be much shorter than the other 3 clients due to the fact
 that this client retrieved the data from the content store of the router as opposed to the interest being forwarded to the producer and then back to the router and then consumer.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Thanks,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Justin Rodrigues<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Justin Rodrigues<br>
<b>Sent:</b> Monday, July 26, 2021 2:50 PM<br>
<b>To:</b> ndnsim@lists.cs.ucla.edu <ndnsim@lists.cs.ucla.edu><br>
<b>Subject:</b> No Cache Hits or Misses via ndnSim Example or anything else </font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Hello Everyone,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
I hope you are doing well.<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
I am not sure why but when I run the example for cs-trace called ndn-tree-cs-tracers.cpp I get 0 cache hits and 0 misses is this normal in the cs-trace file? I need to understand how the hits or misses are accounted for I think something is wrong.
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<pre><span class="x_c1">// ndn-tree-cs-tracers.cpp</span>

<span class="x_cp">#include</span> <span class="x_cpf">"ns3/core-module.h"</span><span class="x_cp"></span>
<span class="x_cp">#include</span> <span class="x_cpf">"ns3/network-module.h"</span><span class="x_cp"></span>
<span class="x_cp">#include</span> <span class="x_cpf">"ns3/ndnSIM-module.h"</span><span class="x_cp"></span>

<span class="x_k">namespace</span> <span class="x_n">ns3</span> <span class="x_p">{</span>

<span class="x_kt">int</span>
<span class="x_n">main</span><span class="x_p">(</span><span class="x_kt">int</span> <span class="x_n">argc</span><span class="x_p">,</span> <span class="x_kt">char</span><span class="x_o">*</span> <span class="x_n">argv</span><span class="x_p">[])</span>
<span class="x_p">{</span>
  <span class="x_n">CommandLine</span> <span class="x_n">cmd</span><span class="x_p">;</span>
  <span class="x_n">cmd</span><span class="x_p">.</span><span class="x_n">Parse</span><span class="x_p">(</span><span class="x_n">argc</span><span class="x_p">,</span> <span class="x_n">argv</span><span class="x_p">);</span>

  <span class="x_n">AnnotatedTopologyReader</span> <span class="x_nf">topologyReader</span><span class="x_p">(</span><span class="x_s">""</span><span class="x_p">,</span> <span class="x_mi">1</span><span class="x_p">);</span>
  <span class="x_n">topologyReader</span><span class="x_p">.</span><span class="x_n">SetFileName</span><span class="x_p">(</span><span class="x_s">"src/ndnSIM/examples/topologies/topo-tree.txt"</span><span class="x_p">);</span>
  <span class="x_n">topologyReader</span><span class="x_p">.</span><span class="x_n">Read</span><span class="x_p">();</span>

  <span class="x_c1">// Install NDN stack on all nodes</span>
  <span class="x_n">ndn</span><span class="x_o">::</span><span class="x_n">StackHelper</span> <span class="x_n">ndnHelper</span><span class="x_p">;</span>
  <span class="x_n">ndnHelper</span><span class="x_p">.</span><span class="x_n">setPolicy</span><span class="x_p">(</span><span class="x_s">"nfd::cs::lru"</span><span class="x_p">);</span>
  <span class="x_n">ndnHelper</span><span class="x_p">.</span><span class="x_n">setCsSize</span><span class="x_p">(</span><span class="x_mi">100</span><span class="x_p">);</span>
  <span class="x_n">ndnHelper</span><span class="x_p">.</span><span class="x_n">InstallAll</span><span class="x_p">();</span>

  <span class="x_c1">// Choosing forwarding strategy</span>
  <span class="x_n">ndn</span><span class="x_o">::</span><span class="x_n">StrategyChoiceHelper</span><span class="x_o">::</span><span class="x_n">InstallAll</span><span class="x_p">(</span><span class="x_s">"/prefix"</span><span class="x_p">,</span> <span class="x_s">"/localhost/nfd/strategy/best-route"</span><span class="x_p">);</span>

  <span class="x_c1">// Installing global routing interface on all nodes</span>
  <span class="x_n">ndn</span><span class="x_o">::</span><span class="x_n">GlobalRoutingHelper</span> <span class="x_n">ndnGlobalRoutingHelper</span><span class="x_p">;</span>
  <span class="x_n">ndnGlobalRoutingHelper</span><span class="x_p">.</span><span class="x_n">InstallAll</span><span class="x_p">();</span>

  <span class="x_c1">// Getting containers for the consumer/producer</span>
  <span class="x_n">Ptr</span><span class="x_o"><</span><span class="x_n">Node</span><span class="x_o">></span> <span class="x_n">consumers</span><span class="x_p">[</span><span class="x_mi">4</span><span class="x_p">]</span> <span class="x_o">=</span> <span class="x_p">{</span><span class="x_n">Names</span><span class="x_o">::</span><span class="x_n">Find</span><span class="x_o"><</span><span class="x_n">Node</span><span class="x_o">></span><span class="x_p">(</span><span class="x_s">"leaf-1"</span><span class="x_p">),</span> <span class="x_n">Names</span><span class="x_o">::</span><span class="x_n">Find</span><span class="x_o"><</span><span class="x_n">Node</span><span class="x_o">></span><span class="x_p">(</span><span class="x_s">"leaf-2"</span><span class="x_p">),</span>
                            <span class="x_n">Names</span><span class="x_o">::</span><span class="x_n">Find</span><span class="x_o"><</span><span class="x_n">Node</span><span class="x_o">></span><span class="x_p">(</span><span class="x_s">"leaf-3"</span><span class="x_p">),</span> <span class="x_n">Names</span><span class="x_o">::</span><span class="x_n">Find</span><span class="x_o"><</span><span class="x_n">Node</span><span class="x_o">></span><span class="x_p">(</span><span class="x_s">"leaf-4"</span><span class="x_p">)};</span>
  <span class="x_n">Ptr</span><span class="x_o"><</span><span class="x_n">Node</span><span class="x_o">></span> <span class="x_n">producer</span> <span class="x_o">=</span> <span class="x_n">Names</span><span class="x_o">::</span><span class="x_n">Find</span><span class="x_o"><</span><span class="x_n">Node</span><span class="x_o">></span><span class="x_p">(</span><span class="x_s">"root"</span><span class="x_p">);</span>

  <span class="x_k">for</span> <span class="x_p">(</span><span class="x_kt">int</span> <span class="x_n">i</span> <span class="x_o">=</span> <span class="x_mi">0</span><span class="x_p">;</span> <span class="x_n">i</span> <span class="x_o"><</span> <span class="x_mi">4</span><span class="x_p">;</span> <span class="x_n">i</span><span class="x_o">++</span><span class="x_p">)</span> <span class="x_p">{</span>
    <span class="x_n">ndn</span><span class="x_o">::</span><span class="x_n">AppHelper</span> <span class="x_n">consumerHelper</span><span class="x_p">(</span><span class="x_s">"ns3::ndn::ConsumerCbr"</span><span class="x_p">);</span>
    <span class="x_n">consumerHelper</span><span class="x_p">.</span><span class="x_n">SetAttribute</span><span class="x_p">(</span><span class="x_s">"Frequency"</span><span class="x_p">,</span> <span class="x_n">StringValue</span><span class="x_p">(</span><span class="x_s">"10"</span><span class="x_p">));</span> <span class="x_c1">// 100 interests a second</span>

    <span class="x_c1">// Each consumer will express the same data /root/<seq-no></span>
    <span class="x_n">consumerHelper</span><span class="x_p">.</span><span class="x_n">SetPrefix</span><span class="x_p">(</span><span class="x_s">"/root"</span><span class="x_p">);</span>
    <span class="x_n">ApplicationContainer</span> <span class="x_n">app</span> <span class="x_o">=</span> <span class="x_n">consumerHelper</span><span class="x_p">.</span><span class="x_n">Install</span><span class="x_p">(</span><span class="x_n">consumers</span><span class="x_p">[</span><span class="x_n">i</span><span class="x_p">]);</span>
    <span class="x_n">app</span><span class="x_p">.</span><span class="x_n">Start</span><span class="x_p">(</span><span class="x_n">Seconds</span><span class="x_p">(</span><span class="x_mf">0.01</span> <span class="x_o">*</span> <span class="x_n">i</span><span class="x_p">));</span>
  <span class="x_p">}</span>

  <span class="x_n">ndn</span><span class="x_o">::</span><span class="x_n">AppHelper</span> <span class="x_n">producerHelper</span><span class="x_p">(</span><span class="x_s">"ns3::ndn::Producer"</span><span class="x_p">);</span>
  <span class="x_n">producerHelper</span><span class="x_p">.</span><span class="x_n">SetAttribute</span><span class="x_p">(</span><span class="x_s">"PayloadSize"</span><span class="x_p">,</span> <span class="x_n">StringValue</span><span class="x_p">(</span><span class="x_s">"1024"</span><span class="x_p">));</span>

  <span class="x_c1">// Register /root prefix with global routing controller and</span>
  <span class="x_c1">// install producer that will satisfy Interests in /root namespace</span>
  <span class="x_n">ndnGlobalRoutingHelper</span><span class="x_p">.</span><span class="x_n">AddOrigins</span><span class="x_p">(</span><span class="x_s">"/root"</span><span class="x_p">,</span> <span class="x_n">producer</span><span class="x_p">);</span>
  <span class="x_n">producerHelper</span><span class="x_p">.</span><span class="x_n">SetPrefix</span><span class="x_p">(</span><span class="x_s">"/root"</span><span class="x_p">);</span>
  <span class="x_n">producerHelper</span><span class="x_p">.</span><span class="x_n">Install</span><span class="x_p">(</span><span class="x_n">producer</span><span class="x_p">);</span>

  <span class="x_c1">// Calculate and install FIBs</span>
  <span class="x_n">ndn</span><span class="x_o">::</span><span class="x_n">GlobalRoutingHelper</span><span class="x_o">::</span><span class="x_n">CalculateRoutes</span><span class="x_p">();</span>

  <span class="x_n">Simulator</span><span class="x_o">::</span><span class="x_n">Stop</span><span class="x_p">(</span><span class="x_n">Seconds</span><span class="x_p">(</span><span class="x_mf">20.0</span><span class="x_p">));</span>

<span class="x_hll">  <span class="x_n">ndn</span><span class="x_o">::</span><span class="x_n">CsTracer</span><span class="x_o">::</span><span class="x_n">InstallAll</span><span class="x_p">(</span><span class="x_s">"cs-trace.txt"</span><span class="x_p">,</span> <span class="x_n">Seconds</span><span class="x_p">(</span><span class="x_mi">1</span><span class="x_p">));</span>
</span>
  <span class="x_n">Simulator</span><span class="x_o">::</span><span class="x_n">Run</span><span class="x_p">();</span>
  <span class="x_n">Simulator</span><span class="x_o">::</span><span class="x_n">Destroy</span><span class="x_p">();</span>

  <span class="x_k">return</span> <span class="x_mi">0</span><span class="x_p">;</span>
<span class="x_p">}</span>

<span class="x_p">}</span> <span class="x_c1">// namespace ns3</span>

<span class="x_kt">int</span>
<span class="x_n">main</span><span class="x_p">(</span><span class="x_kt">int</span> <span class="x_n">argc</span><span class="x_p">,</span> <span class="x_kt">char</span><span class="x_o">*</span> <span class="x_n">argv</span><span class="x_p">[])</span>
<span class="x_p">{</span>
  <span class="x_k">return</span> <span class="x_n">ns3</span><span class="x_o">::</span><span class="x_n">main</span><span class="x_p">(</span><span class="x_n">argc</span><span class="x_p">,</span> <span class="x_n">argv</span><span class="x_p">);</span>
<span class="x_p">}</span></pre>
Above is the source file that I am creating the trace file from which can be found via this link:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<a href="https://ndnsim.net/current/metric.html?highlight=obtaining%20metrics" id="LPlnk672623">https://ndnsim.net/current/metric.html?highlight=obtaining%20metrics</a></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Thanks,<br>
<br>
Justin Rodrigues<br>
</div>
</div>
</body>
</html>