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.SetOldContentStore("ns3::ndn::cs::Lru", "MaxSize",
                               "100"); // default ContentStore parameters
  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;
}
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 CCNx stack on all nodes
  ndn::StackHelper ndnHelper;
  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");

  ndn::AppHelper consumerHelper("ns3::ndn::ConsumerBatches");
  consumerHelper.SetPrefix("/root");
  consumerHelper.SetAttribute("Batches", StringValue("1s 1 10s 1"));
  consumerHelper.Install(consumers[0]);

  consumerHelper.SetAttribute("Batches", StringValue("11s 1"));
  consumerHelper.Install(consumers[1]);

  consumerHelper.SetAttribute("Batches", StringValue("11s 1"));
  consumerHelper.Install(consumers[2]);

  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).Start(Seconds(9));

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

  Simulator::Stop(Seconds(20.0));

  ndn::AppDelayTracer::InstallAll("app-delays-trace.txt");

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

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

  AnnotatedTopologyReader topologyReader("", 25);
  topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-grid-3x3-red-queues.txt");
  topologyReader.Read();

  // Install NDN stack on all nodes
  ndn::StackHelper ndnHelper;
  ndnHelper.InstallAll();

  ndn::StrategyChoiceHelper::InstallAll("/", "ndn:/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> producer = Names::Find<Node>("Node8");
  NodeContainer consumerNodes;
  consumerNodes.Add(Names::Find<Node>("Node0"));

  // Install NDN applications
  std::string prefix = "/prefix";

  ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
  consumerHelper.SetPrefix(prefix);
  consumerHelper.SetAttribute("Frequency", StringValue("100")); // 100 interests a second
  consumerHelper.Install(consumerNodes);

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

  // Add /prefix origins to ndn::GlobalRouter
  ndnGlobalRoutingHelper.AddOrigins(prefix, producer);

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

  Simulator::Stop(Seconds(20.0));

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

  return 0;
}
int
main(int argc, char* argv[])
{
  std::string fof = "fof.txt";
  std::string dropFileName = "drops.txt";
  std::string topologyFile = "src/ndnSIM/examples/topologies/topo-tree.txt";
  std::string appDelayFile = "app-delays-trace.txt";
  std::string rateTraceFile = "rate-trace.txt";
  std::string percentage = "1.0";
  std::string frequency = "1";
  int simulationTime = 1000;

  CommandLine cmd;
  cmd.AddValue("fof", "forwarder overhead file", fof);
  cmd.AddValue("time", "simulation time argument", simulationTime);
  cmd.AddValue("top", "topology file", topologyFile);
  cmd.AddValue("drop", "bead drop file", dropFileName);
  cmd.AddValue("appd", "app delay file", appDelayFile);
  cmd.AddValue("rate", "rate trace file", rateTraceFile);
  cmd.AddValue("percentage", "bead percentage", percentage);
  cmd.AddValue("freq", "bead frequency", frequency);
  cmd.Parse(argc, argv);

  delayFile.open(fof);
  dropFile.open(dropFileName);

  AnnotatedTopologyReader topologyReader("", 1);
  topologyReader.SetFileName(topologyFile);
  topologyReader.Read();

  ndn::StackHelper ndnHelper;
  ndnHelper.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> routers[2] = {Names::Find<Node>("rtr-1"), Names::Find<Node>("rtr-2")};
  // Ptr<Node> producers[2] = {Names::Find<Node>("root-1"), Names::Find<Node>("root-2")};
  Ptr<Node> producer = Names::Find<Node>("root-1");

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

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

  // Install NDN on routers
  ndn::StackHelper ndnHelperWithCache;
  ndnHelperWithCache.SetDefaultRoutes(true);
  ndnHelperWithCache.SetOldContentStore("ns3::ndn::cs::Freshness::Lru", "MaxSize", "0");
  ndnHelperWithCache.InstallCallback(routers[0], (size_t)&ForwardingDelay, 0);
  ndnHelperWithCache.InstallBeadDropCallback(routers[0], (size_t)&BeadDropCallback, 0);
  ndnHelperWithCache.SetUseHistory(routers[0], 100);
  ndnHelperWithCache.InstallCallback(routers[1], (size_t)&ForwardingDelay, 1);
  ndnHelperWithCache.InstallBeadDropCallback(routers[1], (size_t)&BeadDropCallback, 1);
  ndnHelperWithCache.SetUseHistory(routers[0], 100);


  ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
  // Consumer will request /prefix/0, /prefix/1, ...
  consumerHelper.SetPrefix("/root");
  consumerHelper.SetAttribute("Frequency", StringValue("10")); // 10 interests a second
  consumerHelper.Install(consumers[0]);
  consumerHelper.Install(consumers[1]);
  consumerHelper.Install(consumers[2]);

  ndn::AppHelper producerHelper("ns3::ndn::Producer");
  producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
  producerHelper.SetAttribute("Frequency", StringValue(frequency)); // 1 BEAD every second
  producerHelper.SetAttribute("Percentage", StringValue(percentage));

  // 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).Start(Seconds(0));
  producerHelper.Install(producer).Start(Seconds(0));
  ndnHelperWithCache.InstallCallback(producer, (size_t)&ForwardingDelay, 2);

  // ndnGlobalRoutingHelper.AddOrigins("/root/nonbead", producers[1]);
  // producerHelper.SetPrefix("/root/nonbead");
  // producerHelper.Install(producers[1]).Start(Seconds(9));

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

  Simulator::Stop(Seconds(simulationTime));

  ndn::AppDelayTracer::InstallAll(appDelayFile);
  ndn::L3RateTracer::InstallAll(rateTraceFile, Seconds(0.5));

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

  delayFile.flush();
  delayFile.close();

  dropFile.flush();
  dropFile.close();

  return 0;
}
Beispiel #5
0
int
main(int argc, char* argv[])
{
  // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
  CommandLine cmd;
  cmd.Parse(argc, argv);

  AnnotatedTopologyReader topologyReader("", 1);
  topologyReader.SetFileName("src/ndnSIM/examples/topologies/Geant2012.txt");
  topologyReader.Read();
//  topologyReader.ApplySettings();
  topologyReader.SaveGraphviz("src/ndnSIM/examples/topologies/GeantGraph.dot");


    // Install NDN stack on all nodes
    ndn::StackHelper ndnHelper;
    ndnHelper.disableRibManager();
    //ndnHelper.disableFaceManager();
    ndnHelper.InstallAll();

    // Choosing forwarding strategy
    ndn::StrategyChoiceHelper::InstallAll("/cs-www.bu.edu/", "/localhost/nfd/strategy/multicast");
    // Choosing forwarding strategy for content adverts
    ndn::StrategyChoiceHelper::InstallAll("/ContentAdVert/", "/localhost/nfd/strategy/multicast");

    // Installing applications

    // Consumer
    ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");

    std:: string path= "/home/ali/GitHub/Datasets/test/firstDir/URLs/";
    ifstream inFile(path + "URLs.con2.cs18.800051214");
    string line;
    if (inFile.is_open())
    {
      //NS_LOG_UNCOND ("salam!");
      while(getline (inFile,line))
        {
          consumerHelper.SetPrefix(line);
          //NS_LOG_UNCOND ("file line = "<<line);

          consumerHelper.SetAttribute("Frequency", StringValue("1")); // 1 interests a second
          //i put first only greece as a consumer
          consumerHelper.Install(Names::Find<Node>("id15")).Start (Seconds(0.005));
        }
    }

    inFile.close();



    // Producer
    ndn::AppHelper producerHelper("ns3::ndn::Producer");
    // Producer will reply to all requests starting with /videos/myvideos/video1
    producerHelper.SetPrefix("/cs-www.bu.edu/");
    producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
    //I put first NO as the only producer
    producerHelper.Install(Names::Find<Node>("id35")).Start (Seconds(0.0));

    //install advertiser app on the server
    consumerHelper.SetPrefix ("/ContentAdVert/cs-www.bu.edu/");
    consumerHelper.SetAttribute("Frequency", StringValue("0.2")); // 1 advert per 5 second
    consumerHelper.Install(Names::Find<Node>("id35")).Start (Seconds(0.0));

  // Getting containers for the consumer/producer
/*  Ptr<Node> consumers[4] = {Names::Find<Node>("id0"), Names::Find<Node>("id1"),
                            Names::Find<Node>("id2"), Names::Find<Node>("id3")};
  Ptr<Node> producers[4] = {Names::Find<Node>("id36"), Names::Find<Node>("id37"),
                            Names::Find<Node>("id38"), Names::Find<Node>("id39")};

  if (consumers[0] == 0 || consumers[1] == 0 || consumers[2] == 0 || consumers[3] == 0
      || producers[0] == 0 || producers[1] == 0 || producers[2] == 0 || producers[3] == 0) {
    NS_FATAL_ERROR("Error in topology: one nodes c1, c2, c3, c4, p1, p2, p3, or p4 is missing");
  }

  for (int i = 0; i < 4; i++) {
    std::string prefix = "/data/" + Names::FindName(producers[i]);

    /////////////////////////////////////////////////////////////////////////////////
    // install consumer app on consumer node c_i to request data from producer p_i //
    /////////////////////////////////////////////////////////////////////////////////

    ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
    consumerHelper.SetAttribute("Frequency", StringValue("10")); // 100 interests a second

    consumerHelper.SetPrefix(prefix);
    ApplicationContainer consumer = consumerHelper.Install(consumers[i]);
    consumer.Start(Seconds(i));     // start consumers at 0s, 1s, 2s, 3s
    consumer.Stop(Seconds(19 - i)); // stop consumers at 19s, 18s, 17s, 16s

    ///////////////////////////////////////////////
    // install producer app on producer node p_i //
    ///////////////////////////////////////////////

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

    // install producer that will satisfy Interests in /dst1 namespace
    producerHelper.SetPrefix(prefix);
    ApplicationContainer producer = producerHelper.Install(producers[i]);
    // when Start/Stop time is not specified, the application is running throughout the simulation
  }

  // Manually configure FIB routes
  ndn::FibHelper::AddRoute("id0", "/data", "n1", 1); // link to n1
  ndn::FibHelper::AddRoute("id1", "/data", "n1", 1); // link to n1
  ndn::FibHelper::AddRoute("id2", "/data", "n1", 1); // link to n1
  ndn::FibHelper::AddRoute("id3", "/data", "n1", 1); // link to n1

  ndn::FibHelper::AddRoute("n1", "/data", "n2", 1);  // link to n2
  ndn::FibHelper::AddRoute("n1", "/data", "n12", 2); // link to n12

  ndn::FibHelper::AddRoute("n12", "/data", "n2", 1); // link to n2

  ndn::FibHelper::AddRoute("n2", "/data/p1", "id36", 1); // link to p1
  ndn::FibHelper::AddRoute("n2", "/data/p2", "id37", 1); // link to p2
  ndn::FibHelper::AddRoute("n2", "/data/p3", "id38", 1); // link to p3
  ndn::FibHelper::AddRoute("n2", "/data/p4", "id39", 1); // link to p4
*/
  // Schedule simulation time and run the simulation
  Simulator::Stop(Seconds(20.0));
  Simulator::Run();
  Simulator::Destroy();

  return 0;
}
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);

  ofstream file1("/tmp/topo1.txt");
  file1 << "router\n\n"
        << "#node	city	y	x	mpi-partition\n"
        << "A1	NA	1	1	1\n"
        << "B1	NA	80	-40	1\n"
        << "C1	NA	80	40	1\n"
        << "A2	NA	1	1	1\n"
        << "B2	NA	80	-40	1\n"
        << "C2	NA	80	40	1\n\n"
        << "link\n\n"
        << "# from  to  capacity	metric	delay	queue\n"
        << "A1	    B1	10Mbps		100	1ms	100\n"
        << "A1	    C1	10Mbps		50	1ms	100\n"
        << "B1	    C1	10Mbps		1	1ms	100\n"
        << "A2	    B2	10Mbps		50	1ms	100\n"
        << "A2	    C2	10Mbps		100	1ms	100\n"
        << "B2	    C2	10Mbps		1	1ms	100\n";
  file1.close();

  AnnotatedTopologyReader topologyReader("");
  topologyReader.SetFileName("/tmp/topo1.txt");
  topologyReader.Read();

  // Install NDN stack on all nodes
  ndn::StackHelper ndnHelper;
  ndnHelper.InstallAll();

  topologyReader.ApplyOspfMetric();

  ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
  ndnGlobalRoutingHelper.InstallAll();

  ndnGlobalRoutingHelper.AddOrigins("/test/prefix", Names::Find<Node>("C1"));
  ndnGlobalRoutingHelper.AddOrigins("/test/prefix", Names::Find<Node>("C2"));
  ndn::GlobalRoutingHelper::CalculateRoutes();

  auto printFib = [](Ptr<Node> node) {
    auto ndn = node->GetObject<ndn::L3Protocol>();
    for (const auto& entry : ndn->getForwarder()->getFib()) {
      cout << entry.getPrefix() << " (";

      bool isFirst = true;
      for (auto& nextHop : entry.getNextHops()) {
        cout << *nextHop.getFace();
        auto face = dynamic_pointer_cast<ndn::NetDeviceFace>(nextHop.getFace());
        if (face == nullptr)
          continue;

        cout << " towards ";

        if (!isFirst)
          cout << ", ";
        cout << Names::FindName(face->GetNetDevice()->GetChannel()->GetDevice(1)->GetNode());
        isFirst = false;
      }
      cout << ")" << endl;
    }
  };

  cout << "FIB content on node A1" << endl;
  printFib(Names::Find<Node>("A1"));

  cout << "FIB content on node A2" << endl;
  printFib(Names::Find<Node>("A2"));

  Simulator::Stop(Seconds(20.0));
  Simulator::Run();
  Simulator::Destroy();

  return 0;
}
Beispiel #7
0
int
main(int argc, char* argv[])
{

  AnnotatedTopologyReader topologyReader("", 1);
  topologyReader.SetFileName("src/ndnSIM/examples/topologies/Geant2012.txt");
  topologyReader.Read();
  
  // 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;
  size_t nNode=3;
  nodes.Create(nNode);

  // 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.disableRibManager();
  //ndnHelper.disableFaceManager();
  ndnHelper.InstallAll();



  // Choosing forwarding strategy
  ndn::StrategyChoiceHelper::InstallAll("/cs-www.bu.edu/", "/localhost/nfd/strategy/multicast");

  // Installing applications

  // Consumer
  ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");


  ifstream inFile("URLs.con2.cs18.800051214");
  string line;
  if (inFile.is_open())
  {
    //NS_LOG_UNCOND ("salam!");
    while(getline (inFile,line))
      {
        consumerHelper.SetPrefix(line);
        //NS_LOG_UNCOND ("file line = "<<line);

        consumerHelper.SetAttribute("Frequency", StringValue("1")); // 1 interests a second
        consumerHelper.Install(nodes.Get(0)).Start (Seconds(2));
      }
  }

  inFile.close();



  // Producer
  ndn::AppHelper producerHelper("ns3::ndn::Producer");
  // Producer will reply to all requests starting with /videos/myvideos/video1
  producerHelper.SetPrefix("/cs-www.bu.edu/");
  producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
  producerHelper.Install(nodes.Get(2)).Start (Seconds(0.0)); // last node


  // Choosing forwarding strategy for content adverts
  ndn::StrategyChoiceHelper::InstallAll("/ContentAdVert/", "/localhost/nfd/strategy/multicast");


  //install advertiser app on the server
  consumerHelper.SetPrefix ("/ContentAdVert/cs-www.bu.edu/");
  consumerHelper.SetAttribute("Frequency", StringValue("0.2")); // 1 advert per 5 second
  consumerHelper.Install(nodes.Get(2)).Start (Seconds(0.0));

  Simulator::Stop(Seconds(10.0));

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

  return 0;
}
int
main(int argc, char* argv[])
{
  // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
  CommandLine cmd;
  cmd.Parse(argc, argv);

  AnnotatedTopologyReader topologyReader("", 1);
  topologyReader.SetFileName("src/ndnSIM/examples/topologies/Geant2012.txt");
  topologyReader.Read();
//  topologyReader.ApplySettings();
  topologyReader.SaveGraphviz("src/ndnSIM/examples/topologies/GeantGraph.dot");


    // Install NDN stack on all nodes
    ndn::StackHelper ndnHelper;
    ndnHelper.disableRibManager();
    //ndnHelper.disableFaceManager();
    ndnHelper.InstallAll();

    // Choosing forwarding strategy for all
    ndn::StrategyChoiceHelper::InstallAll("/", "/localhost/nfd/strategy/multicast");

    // Installing applications

    ////////////////////////////////////////////////////////////////
    //from 5 file logs, i assign to five consumer each ONE file//
    ///////////////////////////////////////////////////////////////
    size_t nConsumers = 5;
    // Consumer (DE-4, DK-2, CH-8, NL-0, CZ-5)
    std::string consArray[] ={"id4", "id2", "id8", "id0", "id5"} ;

    NS_LOG_UNCOND ("The "<<nConsumers<<" consumers are: ");
    for (size_t i = 0; i < nConsumers; i++) {
      NS_LOG_UNCOND (consArray[i]);
    }

    // Producers (FI-37, ES-25, GR-15)
    size_t nProducers = 3;
    string prodArray[] = {"id37", "id25", "id15"};

      NS_LOG_UNCOND ("The "<<nProducers<<" producers are: ");
      for (size_t i = 0; i < nProducers; i++) {
        NS_LOG_UNCOND (prodArray[i]);
      }


    ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");

    std:: string consumerPath= "/home/ali/GitHub/Datasets/test/fifty/consumers/5F-5C-3P/";

    size_t consIndex=0;
    size_t fileCounter=0;
    DIR *dir;
    struct dirent *ent;

    //This is to avoid collision !
    double l = 0;
    double s = 0.01;
    Ptr<UniformRandomVariable> uniVar;
    uniVar=CreateObject<UniformRandomVariable> ();
    uniVar->SetAttribute ("Min", DoubleValue (l));
    uniVar->SetAttribute ("Max", DoubleValue (s));

    if ((dir = opendir (consumerPath.c_str())) != NULL) {
          /* Go read each of files in this directory */
          const char* invalidFileName1 = ".";
          const char* invalidFileName2 = "..";
          while ((ent = readdir (dir)) != NULL) {
            if (ent->d_name != invalidFileName1 && ent->d_name != invalidFileName2){

              //avoid . and ..
              std::string str1 = ent->d_name;
              if (str1[0]!='U'){
                continue;
              }

              std::string path = consumerPath + ent->d_name;
              //NS_LOG_UNCOND("path.c_str() = "<<path.c_str());
              ifstream inFile(path.c_str());
              NS_LOG_UNCOND ("for node "<<consArray[consIndex]<<", inFile is "<< path.c_str());
                string line;
                if (inFile.is_open())
                {
                    //NS_LOG_UNCOND ("salam!");
                    while(getline (inFile,line))
                      {
                        consumerHelper.SetPrefix(line);
                        //NS_LOG_UNCOND ("file line = "<<line);

                        consumerHelper.SetAttribute("Frequency", StringValue("1")); // 1 interests per five second

                        //we care about collision!
                        consumerHelper.Install(Names::Find<Node>(consArray[consIndex])).Start (Seconds(consStart + uniVar->GetValue(0.0, 0.01)));
                      }//while
                  inFile.close();
                  consIndex++;
                  ++fileCounter;
                  if(fileCounter==5){
                    break;
                  }
                }
                else{
                  NS_LOG_UNCOND("UNABLE TO OPEN FILE "<<ent->d_name);
                }
            }

          }//Dirent while
      }//dirent

    // Producers (FI-37, ES-25, GR-15)
    std:: string producerPath= "/home/ali/GitHub/Datasets/test/fifty/producers/server_dataset/5F-5C-3P/";
    ndn::AppHelper producerHelper("ns3::ndn::Producer");
    // Producer will reply to all requests starting with /videos/myvideos/video1
    producerHelper.SetPrefix("/");
    producerHelper.SetAttribute("PayloadSize", StringValue("1024"));

    producerHelper.Install(Names::Find<Node>(prodArray[0])).Start (Seconds(prodStart));
    producerHelper.Install(Names::Find<Node>(prodArray[1])).Start (Seconds(prodStart));
    producerHelper.Install(Names::Find<Node>(prodArray[2])).Start (Seconds(prodStart));


    //install advertiser app on the server
    consumerHelper.SetAttribute("Frequency", StringValue("0.2")); // 1 advert per 5 second

    consumerHelper.SetPrefix ("/ContentAdVert/FE");
    consumerHelper.Install(Names::Find<Node>(prodArray[0])).Start (Seconds(advertStart));


    consumerHelper.SetPrefix ("/ContentAdVert/ES");
    consumerHelper.Install(Names::Find<Node>(prodArray[1])).Start (Seconds(advertStart + uniVar->GetValue(0.0, 0.001)));

    consumerHelper.SetPrefix ("/ContentAdVert/GR");
    consumerHelper.Install(Names::Find<Node>(prodArray[2])).Start (Seconds(advertStart + uniVar->GetValue(0.0, 0.001)));


  // Schedule simulation time and run the simulation
  Simulator::Stop(Seconds(simulationTime));
  Simulator::Run();
  Simulator::Destroy();

  return 0;
}//ns3::main
/**
 * This scenario simulates a one-node two-custom-app scenario:
 *
 *   +------+ <-----> (CustomApp)
 *   | Node |
 *   +------+ <-----> (Hijacker)
 *
 *     NS_LOG=CustomApp ./waf --run=ndn-custom-apps
 */
int
main(int argc, char* argv[])
{
  // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
  CommandLine cmd;
  cmd.Parse(argc, argv);

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

  // Creating nodes
//  Ptr<Node> node = CreateObject<Node>();
  // Install Content Store stack on cache node
  ndn::StackHelper ndnHelperCache;
  ndnHelperCache.SetOldContentStore("ns3::ndn::cs::Lru", "MaxSize", "10");
  ndnHelperCache.Install(Names::Find<Node>("cacheServer")); 

  // Install NDN stack on all nodes
/*  ndn::StackHelper ndnHelper;
  ndnHelper.SetDefaultRoutes(true);
  ndnHelper.InstallAll();*/

// Install NDN stack on rest of the nodes
  ndn::StackHelper ndnHelper;
  ndnHelper.Install(Names::Find<Node>("client1"));
  ndnHelper.Install(Names::Find<Node>("client2"));
  ndnHelper.Install(Names::Find<Node>("client3"));
  ndnHelper.Install(Names::Find<Node>("originServer"));


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

//  Ptr<Node> consumers1 = Names::Find<Node>("client1");
//  Ptr<Node> consumers2 = Names::Find<Node>("client2");
//  Ptr<Node> consumers3 = Names::Find<Node>("client3");
  Ptr<Node> consumers[3] = {Names::Find<Node>("client1"), Names::Find<Node>("client2"), Names::Find<Node>("client3")};
  Ptr<Node> producer = Names::Find<Node>("originServer");

  cout << "Installing Global routing interface on all nodes";

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

  cout << " Creating app1....";
  // App1
  /*ndn::AppHelper app1("CustomApp");
  app1.SetPrefix("/root");
  app1.Install(consumers1);
  app1.Install(consumers2);
  app1.Install(consumers3);*/

//  for (int i = 0; i < 3; i++) {
 //   std::cout << "i: " << i;
    ndn::AppHelper consumerHelper1("ns3::ndn::ConsumerCbr");
    consumerHelper1.SetAttribute("Frequency", StringValue("1")); 
    consumerHelper1.SetPrefix("/root/" + Names::FindName(consumers[0]));
//    consumerHelper.Install(consumers[i]);
    ns3::ApplicationContainer ac1 = consumerHelper1.Install(consumers[0]);
    ac1.Start(Seconds (1.0));
    ac1.Stop(Seconds (2.0));
//  }
    
    ndn::AppHelper consumerHelper2("ns3::ndn::ConsumerCbr");
    consumerHelper2.SetAttribute("Frequency", StringValue("1")); 
    consumerHelper2.SetPrefix("/root/" + Names::FindName(consumers[1]));
//    consumerHelper.Install(consumers[i]);
    //consumerHelper2.Install(consumers[1]).Start(Seconds (2.0));
    ns3::ApplicationContainer ac2 = consumerHelper2.Install(consumers[1]);
    ac2.Start(Seconds (2.0));
    ac2.Stop(Seconds (3.0));
    //consumerHelper2.Install(consumers[0]).Stop(Seconds (3.0));
    
    ndn::AppHelper consumerHelper3("ns3::ndn::ConsumerCbr");
    consumerHelper3.SetAttribute("Frequency", StringValue("1")); 
    consumerHelper3.SetPrefix("/root/" + Names::FindName(consumers[2]));
//    consumerHelper.Install(consumers[i]);
    //consumerHelper3.Install(consumers[2]).Start(Seconds (3.0));
    ns3::ApplicationContainer ac3 = consumerHelper3.Install(consumers[2]);
    ac3.Start(Seconds (3.0));
    ac3.Stop(Seconds (4.0));
    //consumerHelper3.Install(consumers[0]).Stop(Seconds (4.0));

  // App2
  //ndn::AppHelper app2("Hijacker");
  //app2.Install(producer); // last node

  cout << " Creating Producer";

  ndn::AppHelper producerHelper("ns3::ndn::Producer");
  // Producer will reply to all requests starting with /prefix
  producerHelper.SetAttribute("PayloadSize", StringValue("1024"));

  ndnGlobalRoutingHelper.AddOrigins("/root", producer);
  producerHelper.SetPrefix("/root");
  producerHelper.Install(producer);

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

  Simulator::Stop(Seconds(4.0));

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

  return 0;
}
int
main(int argc, char* argv[])
{
  // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
  CommandLine cmd;
  cmd.Parse(argc, argv);

  NS_LOG_UNCOND("NUMBER OF NODES = "<<ns3::N_NODES<<" , nConsumers = "<<ns3::N_TotalClients<<" , nProducers = "<<ns3::N_PRODUCERS);

  double l = 0;
  double s = ns3::N_GEANT_ROUTERS-1;
  Ptr<UniformRandomVariable> uniVar;
  uniVar=CreateObject<UniformRandomVariable> ();
  uniVar->SetAttribute ("Min", DoubleValue (l));
  uniVar->SetAttribute ("Max", DoubleValue (s));

  // setting default parameters for PointToPoint links and channels
  //this is for 56 clients to be attached
  Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue(ns3::CONS_LINK_DATA_RATE));
  Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue(ns3::CONS_LINK_DELAY));
  Config::SetDefault("ns3::DropTailQueue::MaxPackets", StringValue("20"));
  /////////////////////////////////////////////////////////////////////////
  //***IDs 0-55 are consumers, the next "N_PRODUCERS" IDs are producers, //
  //***and the IDs after them are Geant routers                          //
  /////////////////////////////////////////////////////////////////////////
  NodeContainer nodes;
  nodes.Create(ns3::N_TotalClients + ns3::N_PRODUCERS);
  PointToPointHelper p2p;

  //let's first read the Geant topology
  AnnotatedTopologyReader topologyReader("", 1);
  topologyReader.SetFileName("/home/ali/ndnSIM/ns-3/src/ndnSIM/examples/topologies/Geant2012.txt");
  topologyReader.Read();
  //  topologyReader.ApplySettings();
  topologyReader.SaveGraphviz("src/ndnSIM/examples/topologies/GeantGraph.dot");

   RandomizeConsumers (uniVar, "/home/ali/ndnSIM/ns-3/src/ndnSIM/examples/topologies/Geant2012.txt",
                         topologyReader ,nodes, p2p);
  RandomizeProducers(uniVar, "/home/ali/GitHub/Datasets/test/fifty/producers/server_dataset/large_scale/", nodes, p2p);

  MyResultApp resApp;
  resApp.InstallEndpointApp(nodes);
  resApp.InstallRouterApp(topologyReader);

    // Install NDN stack on all nodes
    ndn::StackHelper ndnHelper;
    ndnHelper.disableRibManager();
    //ndnHelper.disableFaceManager();


    //set cache store size
    ndnHelper.setCsSize(ns3::CACHE_SIZE);
    ndnHelper.InstallAll();

    ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
    ndnGlobalRoutingHelper.Install(nodes);
    for (size_t i = 0; i < ns3::N_PRODUCERS; i++) {
      ifstream inFile ((SERVERS_DATASETS_PATH + "server_dataset_"+std::to_string(i)).c_str());
      if(inFile.is_open()){
        std::string line;
        while (getline(inFile, line)){
          ndnGlobalRoutingHelper.AddOrigins (line, nodes.Get (i+ns3::N_TotalClients));
        }
      }
      else{
        NS_LOG_UNCOND("ERROR!!! UNABLE TO OPEN FILE "<<inFile);
      }

    }
    ndn::GlobalRoutingHelper::CalculateRoutes();


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


    // Installing applications

    ////////////////////////////////////////////////////////////////
    //from 5 file logs, i assign to five consumer each ONE file//
    ///////////////////////////////////////////////////////////////


    NS_LOG_UNCOND("now we've 56 clients attached to some of routers (randomly chosen) and "<<ns3::N_PRODUCERS<<" producers");

    ndn::AppHelper consumerHelper("ns3::ndn::ConsumerZipfMandelbrot");

    consumerHelper.SetAttribute("Frequency", StringValue(ns3::CONSUMER_FREQ));
    consumerHelper.SetAttribute("NumberOfContents", UintegerValue(CONTENT_UNIVERSE));
  //  consumerHelper.SetAttribute("MaxSeq",IntegerValue(MAX_SEQ_NUMBER));
    consumerHelper.SetAttribute("Randomize", StringValue(RANDOMIZE_ATTRIBUTE));
    consumerHelper.SetAttribute("q", DoubleValue(Q));
    consumerHelper.SetAttribute("s", DoubleValue(S));

  //  std:: string consumerPath= "/home/ali/GitHub/Datasets/test/fifty/producers/server_dataset/5F-5C-3P/content_universe_165";

      for(size_t consIndex=0; consIndex<ns3::N_TotalClients;consIndex++){
              consumerHelper.SetPrefix("/");
              consumerHelper.Install(nodes.Get(consIndex))
              .Start (Seconds(CONS_START + uniVar->GetValue(0.0, 0.01)));
      }//for

  // Schedule simulation time and run the simulation
  Simulator::Stop(Seconds(ns3::SIMULATION_TIME));

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

  Simulator::Run();

  uint64_t m_totalForwardedInterest=0;
  uint64_t m_totalInterestOverhead=0;
  uint64_t m_totalForwardedData=0;
  uint64_t m_totalDataOverhead=0;
  uint64_t m_totalUnsatisfiedInterests=0;
  uint64_t m_totalSatisfiedInterests=0;
  uint64_t m_totalRetrievedDataAtClients=0;


  ofstream spUnsatisfiedInterestsFile;
  spUnsatisfiedInterestsFile.open("/home/ali/Documents/BFRresults/unsatisfied_Interests/spUnsatisfiedInterestsFile_"+std::to_string(ns3::S)+"_FP = "+std::to_string(ns3::FPP));


  ofstream SPDataOverheadFile;
  SPDataOverheadFile.open("/home/ali/Documents/BFRresults/overhead_files/SPDataOverheadFile_"+std::to_string(ns3::S));
  ofstream SPInterestOverheadFile;
  SPInterestOverheadFile.open("/home/ali/Documents//BFRresults/overhead_files/SPInterestOverheadFile_"+std::to_string(ns3::S)+"_FP = "+std::to_string(ns3::FPP));

  SPDataOverheadFile<<"nodeID"<<"     "<<"lastDataFwd"<<"     "
                  <<"nDataFwd"<<"     "<<"dataOverhead"<<"\n";

  SPInterestOverheadFile<<"nodeID"<<"     "<<"lastInterestFwd"<<"     "
                  <<"nInterestFwd"<<"     "<<"interestOverhead"<<"\n";

  spUnsatisfiedInterestsFile<<"consumerID"<<"     	"<<"NumberOfUnsatisfiedInterests"<<"     	"<<"NumberOfSatisfiedInterests"<<"\n";


  //let's extract results from nodes' apps
  Ptr<MyResultApp> nodeApp;
  for (NodeList::Iterator node = NodeList::Begin(); node != NodeList::End(); node++) {
    nodeApp = CreateObject<ns3::MyResultApp> ();
    if ((*node)->GetId()>=ns3::N_TotalClients && (*node)->GetId()<=ns3::N_TotalClients+ns3::N_PRODUCERS-1){
      nodeApp = (*node)->GetApplication(1)->GetObject<ns3::MyResultApp>();
    }
    else{
      nodeApp = (*node)->GetApplication(0)->GetObject<ns3::MyResultApp>();
    }

    spUnsatisfiedInterestsFile<<(*node)->GetId()<<"     	"<<nodeApp->m_myNumberOfUnsatisfiedInterests<<"     	"<<nodeApp->m_myNumberOfSatisfiedInterests<<"\n";

    if((*node)->GetId()<ns3::N_TotalClients){
      m_totalUnsatisfiedInterests+= nodeApp->m_myNumberOfUnsatisfiedInterests;
      m_totalSatisfiedInterests+= nodeApp->m_myNumberOfSatisfiedInterests;
      m_totalRetrievedDataAtClients+= nodeApp->m_myNumberOfRetrievedData;
    }

    if((*node)->GetId()>=ns3::N_TotalClients){
      SPDataOverheadFile<<nodeApp->GetNode()->GetId()<<"    "<<nodeApp->m_myLastDataForwardTime
	                    <<"     "<<nodeApp->m_nMyForwardedData<<"     "
	                    <<nodeApp->m_myTotalDataOverhead<<"\n";
      m_totalForwardedData += nodeApp->m_nMyForwardedData;
      m_totalDataOverhead += nodeApp->m_myTotalDataOverhead;

    }
    if((*node)->GetId()<=ns3::N_TotalClients-1 || (*node)->GetId()>=ns3::N_TotalClients+ns3::N_PRODUCERS){
      SPInterestOverheadFile<<nodeApp->GetNode()->GetId()<<"    "<<nodeApp->m_myLastInterestForwardTime
	                    <<"     "<<nodeApp->m_nMyForwardedInterest<<"     "
	                    <<nodeApp->m_myTotalInterestOverhead<<"\n";
      m_totalForwardedInterest += nodeApp->m_nMyForwardedInterest;
      m_totalInterestOverhead += nodeApp->m_myTotalInterestOverhead;
    }
  }//for

  //let's write the totals also in interest file:
  SPInterestOverheadFile<<"nTotalForwardedInterest = "<<m_totalForwardedInterest<<"\n";
  SPInterestOverheadFile<<"totalInterestOverhead = "<<m_totalInterestOverhead<<"\n";

  SPInterestOverheadFile<<"nTotalForwardedData = "<<m_totalForwardedData<<"\n";
  SPInterestOverheadFile<<"totalDataOverhead = "<<m_totalDataOverhead<<"\n";
  SPInterestOverheadFile<<"Normalized overhead over interest count = "
                         <<double(m_totalInterestOverhead+m_totalDataOverhead)/(double)m_totalForwardedInterest<<"\n";
  SPInterestOverheadFile<<"Normalized overhead over data count = "
                        <<double(m_totalInterestOverhead+m_totalDataOverhead)/(double)m_totalForwardedData;

  spUnsatisfiedInterestsFile<<"total number of unsatisfied Interests at all the consumers = "<<m_totalUnsatisfiedInterests<<"\n";
  spUnsatisfiedInterestsFile<<"total number of satisfied Interests at all the consumers = "<<m_totalSatisfiedInterests<<"\n";
  spUnsatisfiedInterestsFile<<"Unsatisfaction due to link failure or false positive (METHOD a) = "<<(double)m_totalUnsatisfiedInterests/(m_totalSatisfiedInterests+m_totalUnsatisfiedInterests)<<"\n";
  spUnsatisfiedInterestsFile<<"total number of retrieved data at consumers =  "<<m_totalRetrievedDataAtClients;

  SPInterestOverheadFile.close();
  SPDataOverheadFile.close();
  spUnsatisfiedInterestsFile.close();


  Simulator::Destroy();

  //std::string hitDistanceCompleteFile = "/home/ali/ndnSIM/ns-3/HitDistanceFile"
  //CreateHitDistanceDataset (hitDistanceCompleteFile);

  return 0;
}//ns3::main
/**
 * This scenario simulates a one-node two-custom-app scenario:
 *
 *   +------+ <-----> (CustomApp)
 *   | Node |
 *   +------+ <-----> (Hijacker)
 *
 *     NS_LOG=CustomApp ./waf --run=ndn-custom-apps
 */
int
main(int argc, char* argv[])
{
  // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
  CommandLine cmd;
  cmd.Parse(argc, argv);

  AnnotatedTopologyReader topologyReader("", 1);
//  topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-custom1.txt");
//  topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-custom2.txt");
 // topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-custom3.txt");
//  topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-project.txt");
  std::cout << "Reading topology file";
  topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-project_400clients.txt");
  topologyReader.Read();
  
  std::cout << "Adding clients in vector";
  vector<Ptr<Node>> clients;
  for(int i = 1; i <= 400; i++) {
    std::string cli = "client" + std::to_string(i);
    clients.push_back(Names::Find<Node>(cli));    
  }

  std::cout << "Adding Cache servers in vector";
  vector<Ptr<Node>> cacheServers;
  for(int i = 1; i <= 7; i++) {
    std::string cs = "cache" + std::to_string(i);
    cacheServers.push_back(Names::Find<Node>(cs));    
  }
  
  // Creating nodes
//  Ptr<Node> node = CreateObject<Node>();
  // Install Content Store stack on cache node
  ndn::StackHelper ndnHelperCache;
//  ndnHelperCache.SetOldContentStore("ns3::ndn::cs::Lru", "MaxSize", "2");
  //ndnHelperCache.SetOldContentStore("ns3::ndn::cs::Nocache");
//  ndnHelperCache.SetOldContentStore("ns3::ndn::cs::ProbCacheExt::Lru", "MaxSize", "2");
  ndnHelperCache.setCsSize(2); 
  for(int i = 0; i < (int)cacheServers.size(); i++) {
    ndnHelperCache.Install(cacheServers[i]);
  } 

  // Install NDN stack on all nodes
/*  ndn::StackHelper ndnHelper;
  ndnHelper.SetDefaultRoutes(true);
  ndnHelper.InstallAll();*/

// Install NDN stack on rest of the nodes
  ndn::StackHelper ndnHelper;
  for(int i = 0; i < (int)clients.size(); i++) {
    ndnHelper.Install(clients[i]);
  }
//  ndnHelper.Install(Names::Find<Node>("client2"));
//  ndnHelper.Install(Names::Find<Node>("client3"));
  ndnHelper.Install(Names::Find<Node>("originServer"));


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

//  Ptr<Node> consumers1 = Names::Find<Node>("client1");
//  Ptr<Node> consumers2 = Names::Find<Node>("client2");
//  Ptr<Node> consumers3 = Names::Find<Node>("client3");
//  Ptr<Node> consumers[3] = {Names::Find<Node>("client1"), Names::Find<Node>("client2"), Names::Find<Node>("client3")};
  Ptr<Node> producer = Names::Find<Node>("originServer");

  cout << "Installing Global routing interface on all nodes";

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

  cout << " Creating app1....";
  // App1
  /*ndn::AppHelper app1("CustomApp");
  app1.SetPrefix("/root");
  app1.Install(consumers1);
  app1.Install(consumers2);
  app1.Install(consumers3);*/
  
//  std::string content[] = {"alpha", "beta", "gamma", "delta", "epsilon"};

//  const int nrolls=100000;  // number of experiments
//  const int nstars=100;    // maximum number of stars to distribute

  std::default_random_engine generator;
  std::lognormal_distribution<double> distribution(0.0,1.0);

  //int p[100]={};

/*  for (int i=0; i<nrolls; ++i) {
    double number = distribution(generator);
    if ((number>=0.0)&&(number<10.0)) ++p[int(number)];
  }*/

  int j = 0;
/*  int alphaCount = 1;
  int betaCount = 2;
  int gammaCount = 3;
  int deltaCount = 4;
  int epsilonCount = 10;  */
  for (int k = 0; k < 1; k++) {
    for (int i = 0; i < 200; i++) {
      for(int l = 0; l < 2; l++) {
      j = int(distribution(generator));
     // j = p[i]*nstars/nrolls;
     //   std::cout << "i: " << i;
      ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
      consumerHelper.SetAttribute("Frequency", StringValue("1")); 
      consumerHelper.SetAttribute("Content", IntegerValue(j)); 
      int temp = 0;
      if(l == 0) {
        temp = i;
      } else {
        temp = i + 200;
      }
      consumerHelper.SetPrefix("/root/" + Names::FindName(clients[temp]));
      ns3::ApplicationContainer ac = consumerHelper.Install(clients[temp]);
      ac.Start(Seconds (double(k * 1000 + ( (i * 10) + 1))));
      ac.Stop(Seconds (double(k * 1000 + ( (i * 10) + 2))));
      }
    /*  if((j % 5) == 0) {
        if(alphaCount == 0) {
          alphaCount++;
        } else {
          alphaCount--;
        }
        j++;
      } else if ((j % 5) == 1) {
        if(betaCount >= 1) {
          betaCount--;
        } else {
          betaCount = 2;
          j++;
        }
      } else if ((j % 5) == 2) {
        if(gammaCount >= 1) {
          gammaCount--;
        } else {
          gammaCount = 3;
          j++;
        }
      } else if ((j % 5) == 3) {
        if(deltaCount >= 1) {
          deltaCount--;
        } else {
          deltaCount = 4;
          j++;
        }
      } else if ((j % 5) == 4) {
        if(epsilonCount >= 1) {
          epsilonCount--;
        } else {
          epsilonCount = 10;
          j++;
        }
      } */  
    }
  }
    
/*    ndn::AppHelper consumerHelper2("ns3::ndn::ConsumerCbr");
    consumerHelper2.SetAttribute("Frequency", StringValue("1")); 
    consumerHelper2.SetPrefix("/root/" + Names::FindName(consumers[1]));
//    consumerHelper.Install(consumers[i]);
    //consumerHelper2.Install(consumers[1]).Start(Seconds (2.0));
    ns3::ApplicationContainer ac2 = consumerHelper2.Install(consumers[1]);
    ac2.Start(Seconds (2.0));
    ac2.Stop(Seconds (3.0));
    //consumerHelper2.Install(consumers[0]).Stop(Seconds (3.0));
    
    ndn::AppHelper consumerHelper3("ns3::ndn::ConsumerCbr");
    consumerHelper3.SetAttribute("Frequency", StringValue("1")); 
    consumerHelper3.SetPrefix("/root/" + Names::FindName(consumers[2]));
//    consumerHelper.Install(consumers[i]);
    //consumerHelper3.Install(consumers[2]).Start(Seconds (3.0));
    ns3::ApplicationContainer ac3 = consumerHelper3.Install(consumers[2]);
    ac3.Start(Seconds (3.0));
    ac3.Stop(Seconds (4.0)); */
    //consumerHelper3.Install(consumers[0]).Stop(Seconds (4.0));

  // App2
  //ndn::AppHelper app2("Hijacker");
  //app2.Install(producer); // last node

  cout << " Creating Producer";

  ndn::AppHelper producerHelper("ns3::ndn::Producer");
  // Producer will reply to all requests starting with /prefix
  producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
  producerHelper.SetAttribute("Freshness", TimeValue (Seconds (2.0)));
  ndnGlobalRoutingHelper.AddOrigins("/root", producer);
  producerHelper.SetPrefix("/root");
  producerHelper.Install(producer);

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

  Simulator::Stop(Seconds(2004.0));
//  Simulator::Stop(Seconds(9993.0));

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

  return 0;
}