[ndnSIM] receive zero for cacheHit value

Zeinab Rezaeifar z.rezaiefar at yahoo.com
Sun Apr 10 19:08:42 PDT 2016


Hello everyone,
I have run below scenario, but i received zero for cache hit ( in cs-simple2-trace.txt file) . is there any one that knows what is the reason.
any help will be appreciate
thanks
best regards
zeinab

scenario
—————————

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

using namespace ns3;
//for trace
class PcapWriter {
public:
  PcapWriter(const std::string& file)
  {
    PcapHelper helper;
    m_pcap = helper.CreateFile(file, std::ios::out, PcapHelper::DLT_PPP);
  }

  void
  TracePacket(Ptr<const Packet> packet)
  {
    static PppHeader pppHeader;
    pppHeader.SetProtocol(0x0077);

    m_pcap->Write(Simulator::Now(), pppHeader, packet);
  }

private:
  Ptr<PcapFileWrapper> m_pcap;
};

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::DropTailQueue::MaxPackets", StringValue ("20"));

  // 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);
  NodeContainer routerNodes;
  	NodeContainer producerNodes;
  	NodeContainer consumerNodes;

	routerNodes.Create(9);
		producerNodes.Create(3);
		consumerNodes.Create(6);

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


			    //Router 0
			    p2p.Install(routerNodes.Get(0), routerNodes.Get(1));
			    p2p.Install(routerNodes.Get(0), routerNodes.Get(2));
			    p2p.Install(routerNodes.Get(0), routerNodes.Get(3));
			    p2p.Install(routerNodes.Get(0), routerNodes.Get(6));

			    //Router 1
			    p2p.Install(routerNodes.Get(1), routerNodes.Get(2));
			    p2p.Install(routerNodes.Get(1), routerNodes.Get(4));
			    p2p.Install(routerNodes.Get(1), routerNodes.Get(7));

			    //Router 2
			    p2p.Install(routerNodes.Get(2), routerNodes.Get(5));
			    p2p.Install(routerNodes.Get(2), routerNodes.Get(8));

			    //Router 3
			    //Router 4
			    //Router 5
			    //Router 6
			    //Router 7
			    //Router 8

			    //Producers
			    p2p.Install(routerNodes.Get(3), producerNodes.Get(0));
			    p2p.Install(routerNodes.Get(4), producerNodes.Get(1));
			    p2p.Install(routerNodes.Get(5), producerNodes.Get(2));

			    //Consumers
			    p2p.Install(consumerNodes.Get(0), routerNodes.Get(6));
			    p2p.Install(consumerNodes.Get(1), routerNodes.Get(7));
			    p2p.Install(consumerNodes.Get(2), routerNodes.Get(8));
			    p2p.Install(consumerNodes.Get(3), routerNodes.Get(3));
			    p2p.Install(consumerNodes.Get(4), routerNodes.Get(4));
			    p2p.Install(consumerNodes.Get(5), routerNodes.Get(5));

  // Install NDN stack on all nodes
  ndn::StackHelper ccnxHelper;
  ccnxHelper.SetContentStore("ns3::ndn::cs::Lru", "MaxSize", "10000");
//set the life time for satisfied interest message 
ccnxHelper.SetPit ("ns3::ndn::pit::Lru","PitEntryPruningTimout","20"); 
  /*ccnxHelper.Install(routerNodes);
  ccnxHelper.SetContentStore("ns3::ndn::cs::Nocache");
  ccnxHelper.Install(producerNodes);
  ccnxHelper.Install(consumerNodes);*/
 //ccnxHelper.InstallAll ();

 // ccnxHelper.SetDefaultRoutes (true);
  //ccnxHelper.InstallAll ();
  // Install NDN stack on all nodes
  // ndn::StackHelper ndnHelper;
  ccnxHelper.SetForwardingStrategy ("ns3::ndn::fw::BestRoute");
  ccnxHelper.InstallAll ();
    // Installing global routing interface on all nodes
      ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
      ndnGlobalRoutingHelper.InstallAll ();

  // Installing applications

  // Consumer
    for ( int i=0; i<6; i++)
    {  ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
  // Consumer will request /prefix/0, /prefix/1, ...
  consumerHelper.SetPrefix ("/prefix");
  consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
//for interest life time
 consumerHelper.SetAttribute ("LifeTime", StringValue ("20s"));
  //consumerHelper.Install (nodes.Get (0)); // first node
  ApplicationContainer consumer = consumerHelper.Install(consumerNodes.Get(i));
        consumer.Start(Seconds(0.01 * i));
 // consumer.Start(Seconds(2));     // start consumers at 0s, 1s, 2s, 3s
       // consumer.Stop(Seconds(19.0));
    }


  // Producer
  ndn::AppHelper producerHelper ("ns3::ndn::Producer");
  ApplicationContainer producers;
  // Producer will reply to all requests starting with /prefix
 /* producerHelper.SetPrefix ("/prefix");
  producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
  producerHelper.Install (nodes.Get (2)); // last node*/
  for (unsigned i=0; i<producerNodes.GetN(); i++) {
    // Producer will reply to all requests starting with /prefix
    producerHelper.SetPrefix("/prefix");
    producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
  producers = producerHelper.Install(producerNodes.Get(i));}
  // Add /prefix origins to ndn::GlobalRouter
   ndnGlobalRoutingHelper.AddOrigins("/prefix", producerNodes.Get(0));
   ndnGlobalRoutingHelper.AddOrigins("/prefix", producerNodes.Get(1));
   ndnGlobalRoutingHelper.AddOrigins("/prefix", producerNodes.Get(2));

 // Calculate and install FIBs
  ndn::GlobalRoutingHelper::CalculateRoutes();
  //for trace
    PcapWriter trace("ndn-simple-trace.pcap");
    Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::PointToPointNetDevice/MacTx",
                                  MakeCallback(&PcapWriter::TracePacket, &trace));

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

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

  return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20160411/aef517f7/attachment.html>


More information about the ndnSIM mailing list