[ndnSIM] [External]Re: No Cache Hits or Misses via ndnSim Example or anything else

Justin Rodrigues justin99 at student.fdu.edu
Tue Jul 27 13:24:31 PDT 2021


Ok I implemented this quick fix into the code does it matter if I run it with visualizer or a debugger?

Thanks,

Justin Rodrigues
________________________________
From: Prajjwal Singh <csb17053 at tezu.ac.in>
Sent: Tuesday, July 27, 2021 4:19 PM
To: Justin Rodrigues <justin99 at student.fdu.edu>
Cc: ndnsim at lists.cs.ucla.edu <ndnsim at lists.cs.ucla.edu>
Subject: [External]Re: [ndnSIM] No Cache Hits or Misses via ndnSim Example or anything else

Hello Justin,
Just as a quick fix to check which node had which interest Name prefix hit, here is what I would do.

open NFD/daemon/table/cs.hpp and tweak the find () function as the one below
.
template<typename HitCallback, typename MissCallback>
void
find(const Interest& interest, HitCallback&& hit, MissCallback&& miss) const
{
auto match = findImpl(interest);

if (match == m_table.end()) {
miss(interest);
return;
}
int node = ns3::Simulator::GetContext();
std::cout<<"Node:"<<node<<"  HIT"<<"  for Name:"<<interest.getName()<<std::endl;
hit(interest, match->getData());
}

// instead of stdout you can output to a file.

On Wed, 28 Jul 2021, 01:34 Justin Rodrigues via ndnSIM, <ndnsim at lists.cs.ucla.edu<mailto:ndnsim at lists.cs.ucla.edu>> wrote:
Hello Everyone,

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:

/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2011-2015  Regents of the University of California.
 *
 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
 * contributors.
 *
 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * ndnSIM, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/<https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&data=04%7C01%7Cjustin99%40student.fdu.edu%7Cbf457fb0b49c4e7fcf9708d9513be61e%7C3224fad94bcc4d47ae9886ea3c6b3b13%7C1%7C0%7C637630139984347941%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=qHYKc5qSumZWEcpuAJRohs6BdbIHsJYBj7rj8DzEu5I%3D&reserved=0>>.
 **/

// ndn-simple-with-content-freshness.cpp

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/ndnSIM-module.h"

namespace ns3 {

/**
 * This scenario simulates a very simple network topology:
 *
 *
 *      +----------+     1Mbps      +--------+     1Mbps      +----------+
 *      | consumer | <------------> | router | <------------> | producer |
 *      +----------+         10ms   +--------+          10ms  +----------+
 *
 * This scenario demonstrates how to use content store that responds to Freshness parameter set in
 * data packets.  In other words, if the producer set FreshnessPeriod field to 2 seconds, the
 * corresponding data packet will not be considered fresh for more than 2 seconds (can be cached
 * for a shorter time, if entry is evicted earlier)
 *
 *     NS_LOG=OneInterestRequester ./waf --run ndn-simple-with-content-freshness
 */

int
main(int argc, char* argv[])
{
  // setting default parameters for PointToPoint links and channels
  Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("1Mbps"));
  Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("10ms"));
  Config::SetDefault("ns3::QueueBase::MaxSize", StringValue("20p"));

  // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
  CommandLine cmd;
  cmd.Parse(argc, argv);

  // Creating nodes
  NodeContainer nodes;
  nodes.Create(3);

  // Connecting nodes using two links
  PointToPointHelper p2p;
  p2p.Install(nodes.Get(0), nodes.Get(1));
  p2p.Install(nodes.Get(1), nodes.Get(2));

  // Install Ndn stack on all nodes
  ndn::StackHelper ndnHelper;
  ndnHelper.SetDefaultRoutes(true);
  ndnHelper.setCsSize(2); // allow just 2 entries to be cached
  ndnHelper.setPolicy("nfd::cs::lru");
  ndnHelper.InstallAll();

  // Installing applications

  // Consumer
  ndn::AppHelper consumerHelper("OneInterestRequester");

  // /*
  //   1) at time 1 second requests Data from a producer that does not specify freshness Client 1
  //   2) at time 10 seconds requests the same Data packet as client 1

  //   3) at time 2 seconds requests Data from a producer that specifies freshness set to 2 seconds
  //   4) at time 12 seconds requests the same Data packet as client 3

  //   Expectation:
  //   Interests from 1, 3 and 4 will reach producers
  //   Interset from 2 will be served from cache
  //  */

  consumerHelper.SetPrefix("/no-freshness");
  consumerHelper.Install(nodes.Get(0)).Start(Seconds(1));
  //nfd::cs::insert("/no-freshness",true);
  consumerHelper.Install(nodes.Get(0)).Start(Seconds(10));

  consumerHelper.SetPrefix("/with-freshness");
  consumerHelper.Install(nodes.Get(0)).Start(Seconds(2));
  consumerHelper.Install(nodes.Get(0)).Start(Seconds(12));



  // Producer
  ndn::AppHelper producerHelper("ns3::ndn::Producer");
  producerHelper.SetAttribute("PayloadSize", StringValue("1024"));

  producerHelper.SetAttribute("Freshness", TimeValue(Years(100))); // freshness long enough
  producerHelper.SetPrefix("/no-freshness");
  producerHelper.Install(nodes.Get(2)); // last node

  producerHelper.SetAttribute("Freshness", TimeValue(Seconds(2.0))); // freshness 2 seconds (!!!
                                                                     // freshness granularity is 1
                                                                     // seconds !!!)
  producerHelper.SetPrefix("/with-freshness");
  producerHelper.Install(nodes.Get(2)); // last node


  ndn::L3RateTracer::InstallAll("../traces/rate-trace.txt", Seconds(1.0));
  L2RateTracer::InstallAll("../traces/drop-trace.txt", Seconds(1.0));
  ndn::AppDelayTracer::InstallAll("../traces/app-delays-trace.txt" );
  ndn::CsTracer::InstallAll("../traces/cs-trace.txt", Seconds(1.0));



  Simulator::Stop(Seconds(30.0));

  Simulator::Run();
  Simulator::Destroy();

  return 0;
}
} // namespace ns3

int
main(int argc, char* argv[])
{
  return ns3::main(argc, argv);
}

That's the current code I am working with.

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.

Thanks,

Justin Rodrigues
________________________________
From: Justin Rodrigues
Sent: Monday, July 26, 2021 2:50 PM
To: ndnsim at lists.cs.ucla.edu<mailto:ndnsim at lists.cs.ucla.edu> <ndnsim at lists.cs.ucla.edu<mailto:ndnsim at lists.cs.ucla.edu>>
Subject: No Cache Hits or Misses via ndnSim Example or anything else

Hello Everyone,

I hope you are doing well.

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.

// ndn-tree-cs-tracers.cpp

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/ndnSIM-module.h"

namespace ns3 {

int
main(int argc, char* argv[])
{
  CommandLine cmd;
  cmd.Parse(argc, argv);

  AnnotatedTopologyReader topologyReader("", 1);
  topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-tree.txt");
  topologyReader.Read();

  // Install NDN stack on all nodes
  ndn::StackHelper ndnHelper;
  ndnHelper.setPolicy("nfd::cs::lru");
  ndnHelper.setCsSize(100);
  ndnHelper.InstallAll();

  // Choosing forwarding strategy
  ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/best-route");

  // Installing global routing interface on all nodes
  ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
  ndnGlobalRoutingHelper.InstallAll();

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

  for (int i = 0; i < 4; i++) {
    ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
    consumerHelper.SetAttribute("Frequency", StringValue("10")); // 100 interests a second

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

  ndn::AppHelper producerHelper("ns3::ndn::Producer");
  producerHelper.SetAttribute("PayloadSize", StringValue("1024"));

  // Register /root prefix with global routing controller and
  // install producer that will satisfy Interests in /root namespace
  ndnGlobalRoutingHelper.AddOrigins("/root", producer);
  producerHelper.SetPrefix("/root");
  producerHelper.Install(producer);

  // Calculate and install FIBs
  ndn::GlobalRoutingHelper::CalculateRoutes();

  Simulator::Stop(Seconds(20.0));

  ndn::CsTracer::InstallAll("cs-trace.txt", Seconds(1));

  Simulator::Run();
  Simulator::Destroy();

  return 0;
}

} // namespace ns3

int
main(int argc, char* argv[])
{
  return ns3::main(argc, argv);
}

Above is the source file that I am creating the trace file from which can be found via this link:

https://ndnsim.net/current/metric.html?highlight=obtaining%20metrics<https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fndnsim.net%2Fcurrent%2Fmetric.html%3Fhighlight%3Dobtaining%2520metrics&data=04%7C01%7Cjustin99%40student.fdu.edu%7Cbf457fb0b49c4e7fcf9708d9513be61e%7C3224fad94bcc4d47ae9886ea3c6b3b13%7C1%7C0%7C637630139984347941%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=hCIsSbyNNej8LOhhOPouHa3MPP8r%2F9tn3E5YF5aYofI%3D&reserved=0>


Thanks,

Justin Rodrigues
_______________________________________________
ndnSIM mailing list
ndnSIM at lists.cs.ucla.edu<mailto:ndnSIM at lists.cs.ucla.edu>
http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim<https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.lists.cs.ucla.edu%2Fmailman%2Flistinfo%2Fndnsim&data=04%7C01%7Cjustin99%40student.fdu.edu%7Cbf457fb0b49c4e7fcf9708d9513be61e%7C3224fad94bcc4d47ae9886ea3c6b3b13%7C1%7C0%7C637630139984357933%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Ubiwr7y9sMAqJaMk5EYrVqYSn%2BMKjcNg6pHLYoHC0l4%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20210727/919e81e7/attachment-0001.html>


More information about the ndnSIM mailing list