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::MaxPackets", UintegerValue(10)); // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize CommandLine cmd; cmd.Parse(argc, argv); // Creating 3x3 topology PointToPointHelper p2p; PointToPointGridHelper grid(3, 3, p2p); grid.BoundingBox(100, 100, 200, 200); // Install NDN stack on all nodes ndn::StackHelper ndnHelper; ndnHelper.InstallAll(); // Set BestRoute strategy ndn::StrategyChoiceHelper::InstallAll("/", "/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 = grid.GetNode(2, 2); NodeContainer consumerNodes; consumerNodes.Add(grid.GetNode(0, 0)); // 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[]) { 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[]) { // 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); // 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.SetOldContentStore( "ns3::ndn::cs::Freshness::Lru"); // don't set up max size here, will use default value = 100 ndnHelper.InstallAll(); // set up max sizes, after NDN stack is installed Config::Set("/NodeList/0/$ns3::ndn::ContentStore/MaxSize", UintegerValue( 1)); // number after nodeList is global ID of the node (= node->GetId ()) Config::Set("/NodeList/1/$ns3::ndn::ContentStore/MaxSize", UintegerValue(2)); Config::Set("/NodeList/2/$ns3::ndn::ContentStore/MaxSize", UintegerValue(200)); // Installing applications // Consumer 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 consumerHelper.Install(nodes.Get(0)); // first node // Producer ndn::AppHelper producerHelper("ns3::ndn::Producer"); // Producer will reply to all requests starting with /prefix producerHelper.SetPrefix("/prefix"); producerHelper.SetAttribute("PayloadSize", StringValue("1024")); producerHelper.Install(nodes.Get(2)); // last node Simulator::Stop(Seconds(20.0)); 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[]) { // 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); // 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 StackHelper ndnHelper; ndnHelper.InstallAll(); // Installing global routing interface on all nodes ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; ndnGlobalRoutingHelper.InstallAll(); // Installing applications // Consumer ndn::AppHelper consumerHelper("PingClientApp"); consumerHelper.SetAttribute("Prefix", StringValue("/ping")); consumerHelper.SetAttribute("nPings", StringValue("3")); consumerHelper.Install(nodes.Get(0)).Start(Seconds(2)); // Producer ndn::AppHelper producerHelper("PingServerApp"); producerHelper.SetAttribute("Prefix", StringValue("/ping")); producerHelper.SetAttribute("nMaxPings", StringValue("3")); producerHelper.Install(nodes.Get(2)).Start(Seconds(0.1)); ndnGlobalRoutingHelper.AddOrigins("/ping", nodes.Get(2)); // Calculate and install FIBs ndn::GlobalRoutingHelper::CalculateRoutes(); 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::QueueBase::MaxPackets", UintegerValue(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); // 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.InstallAll(); // Installing applications // Consumer 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 consumerHelper.Install(nodes.Get(0)); // first node // Producer ndn::AppHelper producerHelper("ns3::ndn::Producer"); // Producer will reply to all requests starting with /prefix producerHelper.SetPrefix("/prefix"); producerHelper.SetAttribute("PayloadSize", StringValue("1024")); producerHelper.SetAttribute("Signature", UintegerValue(100)); producerHelper.SetAttribute("KeyLocator", StringValue("/unique/key/locator")); producerHelper.Install(nodes.Get(2)); // last node PcapWriter trace("ndn-simple-trace.pcap"); Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::PointToPointNetDevice/MacTx", MakeCallback(&PcapWriter::TracePacket, &trace)); 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); // 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.InstallAll(); // Choosing forwarding strategy ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/multicast"); // Installing applications // Consumer ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr"); // Consumer will request /prefix/0, /prefix/1, ... consumerHelper.SetPrefix("/prefix"); consumerHelper.SetAttribute("Frequency", StringValue("1")); // 10 interests a second consumerHelper.SetAttribute("MaxSeq",IntegerValue(5)); consumerHelper.Install(nodes.Get(0)); // first node // Producer ndn::AppHelper producerHelper("ns3::ndn::Producer"); // Producer will reply to all requests starting with /prefix producerHelper.SetPrefix("/prefix"); producerHelper.SetAttribute("PayloadSize", StringValue("1024")); producerHelper.Install(nodes.Get(2)); // last node Simulator::Stop(Seconds(20.0)); 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; }
inline void RandomizeProducers (Ptr<UniformRandomVariable> uniVar, std::string serverDatasetsPath, NodeContainer& nodes, PointToPointHelper& p2p){ RouterEndPointMap pr; pr.clear(); size_t prodIndex = 0; while (prodIndex < ns3::N_PRODUCERS){ size_t rtrID = uniVar->GetInteger (0, ns3::N_GEANT_ROUTERS-1); if(prodIndex==0){ pr[prodIndex] = rtrID; ++prodIndex; } else{ size_t rtrID1=0; do{ rtrID1 = uniVar->GetInteger (0, ns3::N_GEANT_ROUTERS-1); }while(pr.find(rtrID1)!= pr.end()); pr[prodIndex] = rtrID1; ++prodIndex; } }//while //////////////////////////////////////////////////////////////// //****HERE I ATTACH PRODUCERS TO SOME OF ROUTERS RANDOMLY*****// /////////////////////////////////////////////////////////////// ndn::AppHelper producerHelper("ns3::ndn::Producer"); // Producer will reply to all requests starting with /videos/myvideos/video1 producerHelper.SetPrefix("/"); producerHelper.SetAttribute("PayloadSize", StringValue(PAYLOAD_SIZE)); std::string strID="id"; //choose randomly the producers NS_LOG_UNCOND("from among "<<ns3::N_PRODUCERS<<" producers:"); for (RouterEndPointMap::iterator it= pr.begin(); it!=pr.end(); it++) { p2p.SetDeviceAttribute ("DataRate", StringValue (ns3::PROD_LINK_DATA_RATE)); p2p.SetChannelAttribute ("Delay", StringValue (ns3::PROD_LINK_DELAY)); NS_LOG_UNCOND("PRODUCER "<<it->first<<" was attached to id"<<it->second<<" lINK DataRate= "<<ns3::PROD_LINK_DATA_RATE<<" and LINK Delay = "<<ns3::PROD_LINK_DELAY); p2p.Install(nodes.Get(it->first + ns3::N_TotalClients), Names::Find<Node>(strID + std::to_string(it->second))); producerHelper.Install(nodes.Get(it->first + ns3::N_TotalClients)).Start (Seconds(ns3::PROD_START)); }//for }//FUNCTION: RandomizeProducers
int main(int argc, char* argv[]) { // LogComponentEnable("ndn.CbisGlobalRoutingHelper", LOG_LEVEL_INFO); // Setting default parameters for PointToPoint links and channels Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("1Mbps")); Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("1ms")); Config::SetDefault("ns3::QueueBase::MaxSize", StringValue("10p")); // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize CommandLine cmd; cmd.Parse(argc, argv); // Creating 3x3 topology PointToPointHelper p2p; PointToPointGridHelper grid(3, 3, p2p); grid.BoundingBox(100, 100, 200, 200); // Install CCNx stack on all nodes ndn::StackHelper ndnHelper; // ndnHelper.SetForwardingStrategy ("ns3::ndn::fw::SmartFlooding"); // ndnHelper.SetContentStore ("ns3::ndn::cs::Lru", "MaxSize", "10"); ndnHelper.InstallAll(); // Choosing forwarding strategy ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/ncc"); // Installing global routing interface on all nodes // ndn::CbisGlobalRoutingHelper ndnGlobalRoutingHelper; ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; ndnGlobalRoutingHelper.InstallAll(); // Getting containers for the consumer/producer Ptr<Node> producer = grid.GetNode(2, 2); NodeContainer consumerNodes; consumerNodes.Add(grid.GetNode(0, 0)); // Install CCNx applications std::string prefix = "/prefix"; ndn::AppHelper consumerHelper("ns3::ndn::ConsumerZipfMandelbrot"); // ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr"); consumerHelper.SetPrefix(prefix); consumerHelper.SetAttribute("Frequency", StringValue("100")); // 100 interests a second consumerHelper.SetAttribute("NumberOfContents", StringValue("100")); // 10 different contents // consumerHelper.SetAttribute ("Randomize", StringValue ("uniform")); // 100 interests a second consumerHelper.Install(consumerNodes); ndn::AppHelper producerHelper("ns3::ndn::Producer"); producerHelper.SetPrefix(prefix); producerHelper.SetAttribute("PayloadSize", StringValue("100")); producerHelper.Install(producer); ndnGlobalRoutingHelper.AddOrigins(prefix, producer); // Calculate and install FIBs ndn::GlobalRoutingHelper::CalculateRoutes(); Simulator::Stop(Seconds(1.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; }
int main(int argc, char* argv[]) { // setting default parameters for PointToPoint links and channels Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("10Mbps")); Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("1ms")); Config::SetDefault("ns3::DropTailQueue::MaxPackets", StringValue("100")); uint64_t catalogCardinality = 0; // Estimated Content Catalog Cardinality. double cacheToCatalogRatio = 0.01; // Cache to Catalog Ratio per each node. uint32_t lambda = 1; // Request rate per each client. double alpha = 1; // Zipf's Exponent double plateau = 0; // q parameter for the ZipfMandelbrot distribution std::string simType = ""; // Simulation Type Description uint32_t simDuration = 100; uint32_t numReqTot = 10000; // Total number of requests inside the simulation. // Read optional command-line parameters CommandLine cmd; cmd.AddValue ("catalogCardinality", "Estimated Content Catalog Cardinality.", catalogCardinality); cmd.AddValue ("cacheToCatalogRatio", "Cache to Catalog Ratio per each node.", cacheToCatalogRatio); cmd.AddValue ("lambda", "Request rate per each client.", lambda); cmd.AddValue ("alpha", "Zipf's Exponent", alpha); cmd.AddValue ("plateau", "q parameter for the ZipfMandelbrot distribution", plateau); cmd.AddValue ("simType", "Simulation Type Description", simType); cmd.AddValue ("simDuration", "Length of the simulation, in seconds.", simDuration); cmd.AddValue ("numReqTot", "Total number of requests during the simulation", numReqTot); cmd.Parse (argc, argv); std::string catalogCardinalityStr, lambdaStr, alphaStr, plateauStr,reqStr; std::stringstream ss; ss << catalogCardinality; catalogCardinalityStr = ss.str(); ss.str(""); ss << lambda; lambdaStr = ss.str(); ss.str(""); ss << alpha; alphaStr = ss.str(); ss.str(""); ss << plateau; plateauStr = ss.str(); ss.str(""); ss << numReqTot; reqStr = ss.str(); ss.str(""); // ********** Getting the simulation run ********** uint64_t simRun = SeedManager::GetRun(); uint64_t simRunOut = simRun - 1; std::string simRunStr; ss << simRun; simRunStr = ss.str(); ss.str(""); //NS_LOG_UNCOND("M=" << catalogCardinality << "\nC=" << cacheToCatalogRatio << "\nL=" << lambda // << "\nT=" << simType << "\nA=" << alpha << "\nR=" << simRun); // ********** Calculate the Cache Size per each cache *********** uint32_t cacheSize = round((double)catalogCardinality * cacheToCatalogRatio); ss << cacheSize; std::string cacheSizeStr = ss.str(); ss.str(""); // Creating nodes NodeContainer nodes; //nodes.Create(3); nodes.Create(1); // 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.InstallAll(); //ndnHelper.SetOldContentStore("ns3::ndn::cs::Nocache"); //ndnHelper.Install(nodes.Get(0)); // Consumer //ndnHelper.Install(nodes.Get(2)); // Producer ndnHelper.SetOldContentStore("ns3::ndn::cs::Lru", "MaxSize", cacheSizeStr); //ndnHelper.Install(nodes.Get(1)); // Router ndnHelper.Install(nodes.Get(0)); // Router // Choosing forwarding strategy ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/broadcast"); // Installing applications // Consumer ndn::AppHelper consumerHelper("ns3::ndn::ConsumerZipfMandelbrot"); // Consumer will request /prefix/0, /prefix/1, ... consumerHelper.SetPrefix("/prefix"); consumerHelper.SetAttribute ("Frequency", StringValue(lambdaStr)); // lambda Interest per second consumerHelper.SetAttribute ("NumberOfContents", StringValue (catalogCardinalityStr)); consumerHelper.SetAttribute ("Randomize", StringValue ("exponential")); consumerHelper.SetAttribute ("q", StringValue (plateauStr)); // q paremeter consumerHelper.SetAttribute ("s", StringValue (alphaStr)); // Zipf's exponent consumerHelper.Install(nodes.Get(0)); // first node // Producer ndn::AppHelper producerHelper("ns3::ndn::Producer"); // Producer will reply to all requests starting with /prefix producerHelper.SetPrefix("/prefix"); producerHelper.SetAttribute("PayloadSize", StringValue("1024")); //producerHelper.Install(nodes.Get(2)); // last node producerHelper.Install(nodes.Get(0)); // last node Simulator::Stop (Seconds (simDuration)); Simulator::Run(); Simulator::Destroy(); return 0; }
int run(int argc, char* argv[]) { delayFile.open(DELAY_OUTPUT_FILE_NAME); // setting default parameters for PointToPoint links and channels Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("1000Mbps")); Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("10ms")); Config::SetDefault("ns3::DropTailQueue::MaxPackets", StringValue("4294967295")); // 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(NUM_OF_CONSUMERS + NUM_OF_ROUTERS + NUM_OF_PRODUCER); // Connecting nodes using two links // Connecting nodes using two links PointToPointHelper p2p; // Connecting consumers to edge routers int g = 0; for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (0 + NUM_OF_CONSUMERS)); // C0 <--> R0 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (1 + NUM_OF_CONSUMERS)); // C1 <--> R1 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (3 + NUM_OF_CONSUMERS)); // C2 <--> R3 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (5 + NUM_OF_CONSUMERS)); // C3 <--> R5 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (6 + NUM_OF_CONSUMERS)); // C4 <--> R6 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (10 + NUM_OF_CONSUMERS)); // C5 <--> R10 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (8 + NUM_OF_CONSUMERS)); // C6 <--> R8 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (11 + NUM_OF_CONSUMERS)); // C7 <--> R11 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (12 + NUM_OF_CONSUMERS)); // C8 <--> R12 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (18 + NUM_OF_CONSUMERS)); // C9 <--> R18 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (17 + NUM_OF_CONSUMERS)); // C10 <--> R17 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (20 + NUM_OF_CONSUMERS)); // C11 <--> R20 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (24 + NUM_OF_CONSUMERS)); // C12 <--> R24 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (29 + NUM_OF_CONSUMERS)); // C13 <--> R2 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (28 + NUM_OF_CONSUMERS)); // C14 <--> R28 for (int i = 0; i < GROUP_SIZE; i++, g++) p2p.Install (nodes.Get (g), nodes.Get (21 + NUM_OF_CONSUMERS)); // C15 <--> R21 // Connect routers p2p.Install (nodes.Get (0 + NUM_OF_CONSUMERS), nodes.Get (9 + NUM_OF_CONSUMERS)); // R0 <--> R9 p2p.Install (nodes.Get (1 + NUM_OF_CONSUMERS), nodes.Get (15 + NUM_OF_CONSUMERS)); // R1 <--> R15 p2p.Install (nodes.Get (2 + NUM_OF_CONSUMERS), nodes.Get (9 + NUM_OF_CONSUMERS)); // R2 <--> R9 p2p.Install (nodes.Get (3 + NUM_OF_CONSUMERS), nodes.Get (4 + NUM_OF_CONSUMERS)); // R3 <--> R4 p2p.Install (nodes.Get (4 + NUM_OF_CONSUMERS), nodes.Get (7 + NUM_OF_CONSUMERS)); // R4 <--> R7 p2p.Install (nodes.Get (4 + NUM_OF_CONSUMERS), nodes.Get (14 + NUM_OF_CONSUMERS)); // R4 <--> R14 p2p.Install (nodes.Get (4 + NUM_OF_CONSUMERS), nodes.Get (9 + NUM_OF_CONSUMERS)); // R4 <--> R9 p2p.Install (nodes.Get (4 + NUM_OF_CONSUMERS), nodes.Get (16 + NUM_OF_CONSUMERS)); // R4 <--> R16 p2p.Install (nodes.Get (4 + NUM_OF_CONSUMERS), nodes.Get (25 + NUM_OF_CONSUMERS)); // R4 <--> R25 p2p.Install (nodes.Get (5 + NUM_OF_CONSUMERS), nodes.Get (13 + NUM_OF_CONSUMERS)); // R5 <--> R13 p2p.Install (nodes.Get (6 + NUM_OF_CONSUMERS), nodes.Get (7 + NUM_OF_CONSUMERS)); // R6 <--> R7 p2p.Install (nodes.Get (7 + NUM_OF_CONSUMERS), nodes.Get (9 + NUM_OF_CONSUMERS)); // R7 <--> R9 p2p.Install (nodes.Get (7 + NUM_OF_CONSUMERS), nodes.Get (14 + NUM_OF_CONSUMERS)); // R7 <--> R14 p2p.Install (nodes.Get (7 + NUM_OF_CONSUMERS), nodes.Get (22 + NUM_OF_CONSUMERS)); // R7 <--> R22 p2p.Install (nodes.Get (7 + NUM_OF_CONSUMERS), nodes.Get (23 + NUM_OF_CONSUMERS)); // R7 <--> R23 p2p.Install (nodes.Get (8 + NUM_OF_CONSUMERS), nodes.Get (9 + NUM_OF_CONSUMERS)); // R8 <--> R9 p2p.Install (nodes.Get (9 + NUM_OF_CONSUMERS), nodes.Get (13 + NUM_OF_CONSUMERS)); // R9 <--> R13 p2p.Install (nodes.Get (9 + NUM_OF_CONSUMERS), nodes.Get (14 + NUM_OF_CONSUMERS)); // R9 <--> R14 p2p.Install (nodes.Get (9 + NUM_OF_CONSUMERS), nodes.Get (22 + NUM_OF_CONSUMERS)); // R9 <--> R22 p2p.Install (nodes.Get (9 + NUM_OF_CONSUMERS), nodes.Get (25 + NUM_OF_CONSUMERS)); // R9 <--> R25 p2p.Install (nodes.Get (9 + NUM_OF_CONSUMERS), nodes.Get (27 + NUM_OF_CONSUMERS)); // R9 <--> R27 p2p.Install (nodes.Get (10 + NUM_OF_CONSUMERS), nodes.Get (14 + NUM_OF_CONSUMERS)); // R10 <--> R14 p2p.Install (nodes.Get (11 + NUM_OF_CONSUMERS), nodes.Get (13 + NUM_OF_CONSUMERS)); // R11 <--> R13 p2p.Install (nodes.Get (12 + NUM_OF_CONSUMERS), nodes.Get (13 + NUM_OF_CONSUMERS)); // R12 <--> R13 p2p.Install (nodes.Get (13 + NUM_OF_CONSUMERS), nodes.Get (14 + NUM_OF_CONSUMERS)); // R13 <--> R14 p2p.Install (nodes.Get (13 + NUM_OF_CONSUMERS), nodes.Get (22 + NUM_OF_CONSUMERS)); // R13 <--> R22 p2p.Install (nodes.Get (13 + NUM_OF_CONSUMERS), nodes.Get (25 + NUM_OF_CONSUMERS)); // R13 <--> R25 p2p.Install (nodes.Get (13 + NUM_OF_CONSUMERS), nodes.Get (27 + NUM_OF_CONSUMERS)); // R13 <--> R27 p2p.Install (nodes.Get (14 + NUM_OF_CONSUMERS), nodes.Get (15 + NUM_OF_CONSUMERS)); // R14 <--> R15 p2p.Install (nodes.Get (14 + NUM_OF_CONSUMERS), nodes.Get (18 + NUM_OF_CONSUMERS)); // R14 <--> R18 p2p.Install (nodes.Get (14 + NUM_OF_CONSUMERS), nodes.Get (19 + NUM_OF_CONSUMERS)); // R14 <--> R19 p2p.Install (nodes.Get (15 + NUM_OF_CONSUMERS), nodes.Get (16 + NUM_OF_CONSUMERS)); // R15 <--> R16 p2p.Install (nodes.Get (15 + NUM_OF_CONSUMERS), nodes.Get (19 + NUM_OF_CONSUMERS)); // R15 <--> R19 p2p.Install (nodes.Get (15 + NUM_OF_CONSUMERS), nodes.Get (21 + NUM_OF_CONSUMERS)); // R15 <--> R21 p2p.Install (nodes.Get (15 + NUM_OF_CONSUMERS), nodes.Get (22 + NUM_OF_CONSUMERS)); // R15 <--> R22 p2p.Install (nodes.Get (15 + NUM_OF_CONSUMERS), nodes.Get (23 + NUM_OF_CONSUMERS)); // R15 <--> R23 p2p.Install (nodes.Get (15 + NUM_OF_CONSUMERS), nodes.Get (25 + NUM_OF_CONSUMERS)); // R15 <--> R25 p2p.Install (nodes.Get (15 + NUM_OF_CONSUMERS), nodes.Get (27 + NUM_OF_CONSUMERS)); // R15 <--> R27 p2p.Install (nodes.Get (16 + NUM_OF_CONSUMERS), nodes.Get (23 + NUM_OF_CONSUMERS)); // R16 <--> R23 p2p.Install (nodes.Get (16 + NUM_OF_CONSUMERS), nodes.Get (27 + NUM_OF_CONSUMERS)); // R16 <--> R27 p2p.Install (nodes.Get (17 + NUM_OF_CONSUMERS), nodes.Get (23 + NUM_OF_CONSUMERS)); // R17 <--> R23 // 18 done p2p.Install (nodes.Get (19 + NUM_OF_CONSUMERS), nodes.Get (22 + NUM_OF_CONSUMERS)); // R19 <--> R22 p2p.Install (nodes.Get (20 + NUM_OF_CONSUMERS), nodes.Get (25 + NUM_OF_CONSUMERS)); // R20 <--> R25 p2p.Install (nodes.Get (21 + NUM_OF_CONSUMERS), nodes.Get (22 + NUM_OF_CONSUMERS)); // R21 <--> R22 p2p.Install (nodes.Get (21 + NUM_OF_CONSUMERS), nodes.Get (27 + NUM_OF_CONSUMERS)); // R21 <--> R27 p2p.Install (nodes.Get (22 + NUM_OF_CONSUMERS), nodes.Get (23 + NUM_OF_CONSUMERS)); // R22 <--> R23 p2p.Install (nodes.Get (22 + NUM_OF_CONSUMERS), nodes.Get (28 + NUM_OF_CONSUMERS)); // R22 <--> R28 p2p.Install (nodes.Get (22 + NUM_OF_CONSUMERS), nodes.Get (29 + NUM_OF_CONSUMERS)); // R22 <--> R29 p2p.Install (nodes.Get (23 + NUM_OF_CONSUMERS), nodes.Get (24 + NUM_OF_CONSUMERS)); // R23 <--> R24 p2p.Install (nodes.Get (23 + NUM_OF_CONSUMERS), nodes.Get (25 + NUM_OF_CONSUMERS)); // R23 <--> R25 p2p.Install (nodes.Get (23 + NUM_OF_CONSUMERS), nodes.Get (27 + NUM_OF_CONSUMERS)); // R23 <--> R27 // 24 done // 25 done p2p.Install (nodes.Get (26 + NUM_OF_CONSUMERS), nodes.Get (27 + NUM_OF_CONSUMERS)); // R26 <--> R27 // 27 done // 28 done // 29 done // Connecting producer(s) int producerId = 0 + NUM_OF_CONSUMERS + NUM_OF_ROUTERS; p2p.Install (nodes.Get (producerId), nodes.Get (0 + NUM_OF_CONSUMERS)); // P0 <--> R0 // Install NDN stack without cache ndn::StackHelper ndnHelperNoCache; // ndnHelperNoCache.SetDefaultRoutes(true); ndnHelperNoCache.SetOldContentStore("ns3::ndn::cs::Nocache"); // no cache // Install on consumers for (int i = 0; i < NUM_OF_CONSUMERS; i++) { ndnHelperNoCache.Install(nodes.Get(i)); } // Install on producer(s) ndnHelperNoCache.Install(nodes.Get(0 + NUM_OF_CONSUMERS + NUM_OF_ROUTERS)); // Install NDN stack with cache ndn::StackHelper ndnHelperWithCache; // ndnHelperWithCache.SetDefaultRoutes(true); ndnHelperWithCache.SetOldContentStore("ns3::ndn::cs::Freshness::Lru", "MaxSize", "0"); // Install on routers for (int i = NUM_OF_CONSUMERS; i < NUM_OF_CONSUMERS + NUM_OF_ROUTERS; i++) { ndnHelperWithCache.InstallWithCallback(nodes.Get(i), (size_t)&ForwardingDelay, i, USE_PINT); } // Consumers ndn::AppHelper consumerHelperHonest("ns3::ndn::AccountingEncrConsumer"); // Consumer will request /prefix/A/0, /prefix/A/1, ... consumerHelperHonest.SetAttribute("Frequency", StringValue("1")); // 10 interests a second consumerHelperHonest.SetAttribute("Randomize", StringValue("uniform")); consumerHelperHonest.SetAttribute("StartSeq", IntegerValue(0)); for(int i=0; i < NUM_OF_CONSUMERS; i++) { consumerHelperHonest.SetPrefix("/prefix/A/" + std::to_string(i)); ApplicationContainer consumer = consumerHelperHonest.Install(nodes.Get(i)); consumer.Start(Seconds(0)); std::ostringstream node_id; node_id << i; Config::ConnectWithoutContext("/NodeList/" + node_id.str() + "/ApplicationList/0/ReceivedMeaningfulContent", MakeCallback(ReceivedMeaningfulContent)); } // Producer ndn::AppHelper producerHelper("ns3::ndn::AccountingEncrProducer"); // Producer will reply to all requests starting with /prefix/A. For /prefix/B we expect NACK producerHelper.SetPrefix("/prefix/A"); producerHelper.SetAttribute("PayloadSize", StringValue("1024")); producerHelper.Install(nodes.Get(producerId)); ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; ndnGlobalRoutingHelper.Install(nodes); std::string prefix = "/prefix/A"; ndnGlobalRoutingHelper.AddOrigins(prefix, nodes.Get(producerId)); ndn::GlobalRoutingHelper::CalculateRoutes(); // Traces ndn::L3RateTracer::InstallAll(RATE_OUTPUT_FILE_NAME, Seconds(1.0)); Simulator::Stop(Seconds(SIMULATION_DURATION)); Simulator::Run(); Simulator::Destroy(); delayFile.close(); 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 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; }
/** * 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; }
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
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; }
/** * 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[]) { // 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(5); // 5 nodes (3 clients), connected like this: {0,1,2} <---> 3 <---> 4 // Connecting nodes using two links PointToPointHelper p2p; p2p.Install(nodes.Get(0), nodes.Get(3)); p2p.Install(nodes.Get(1), nodes.Get(3)); p2p.Install(nodes.Get(2), nodes.Get(3)); p2p.Install(nodes.Get(3), nodes.Get(4)); // Install NDN stack on all nodes ndn::StackHelper ndnHelper; ndnHelper.SetDefaultRoutes(true); ndnHelper.InstallAll(); // Choosing forwarding strategy ndn::StrategyChoiceHelper::InstallAll("/myprefix", "/localhost/nfd/strategy/best-route"); // Consumer ndn::AppHelper consumerHelper("ns3::ndn::FileConsumerCbr"); consumerHelper.SetAttribute("FileToRequest", StringValue("/myprefix/file1.img")); consumerHelper.Install(nodes.Get(0)); consumerHelper.SetAttribute("FileToRequest", StringValue("/myprefix/file2.img")); consumerHelper.Install(nodes.Get(1)); consumerHelper.SetAttribute("FileToRequest", StringValue("/myprefix/file3.img")); consumerHelper.Install(nodes.Get(2)); // Connect Tracers Config::ConnectWithoutContext("/NodeList/*/ApplicationList/*/FileDownloadFinished", MakeCallback(&FileDownloadedTrace)); Config::ConnectWithoutContext("/NodeList/*/ApplicationList/*/ManifestReceived", MakeCallback(&FileDownloadedManifestTrace)); Config::ConnectWithoutContext("/NodeList/*/ApplicationList/*/FileDownloadStarted", MakeCallback(&FileDownloadStartedTrace)); // Producer ndn::AppHelper producerHelper("ns3::ndn::FakeFileServer"); // Producer will reply to all requests starting with /prefix producerHelper.SetPrefix("/myprefix"); producerHelper.SetAttribute("MetaDataFile", StringValue("fake.csv")); producerHelper.Install(nodes.Get(4)); // install to some node from nodelist ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; ndnGlobalRoutingHelper.InstallAll(); ndnGlobalRoutingHelper.AddOrigins("/myprefix", nodes.Get(4)); ndn::GlobalRoutingHelper::CalculateRoutes(); ndn::AppDelayTracer::InstallAll("app-delays-trace.txt"); ndn::FileConsumerLogTracer::InstallAll("file-consumer-log-trace.txt"); Simulator::Stop(Seconds(600.0)); Simulator::Run(); Simulator::Destroy(); NS_LOG_UNCOND("Simulation Finished."); 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::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 Ptr<Node> consumer = CreateObject<Node>(); Ptr<Node> intRouter = CreateObject<Node>(); NodeContainer uclaRegion; uclaRegion.Create(3); // Connecting nodes using two links PointToPointHelper p2p; p2p.Install(consumer, intRouter); p2p.Install(intRouter, uclaRegion.Get(0)); p2p.Install(intRouter, uclaRegion.Get(1)); p2p.Install(uclaRegion.Get(0), uclaRegion.Get(1)); p2p.Install(uclaRegion.Get(1), uclaRegion.Get(2)); // Install NDN stack on all nodes ndn::StackHelper ndnHelper; ndnHelper.SetDefaultRoutes(true); ndnHelper.InstallAll(); // Install Routes Manually ndn::FibHelper::AddRoute(intRouter, ndn::Name("/ucla"), uclaRegion.Get(1), 1); // Configure NetworkRegionTable ndn::NetworkRegionTableHelper::AddRegionName(uclaRegion, ndn::Name("/ucla")); // Installing applications // Consumer ndn::AppHelper requesterHelper("RequesterApp"); requesterHelper.SetAttribute("Name", StringValue("/ndnSIM/someData")); requesterHelper.SetAttribute("Delegation", StringValue("/ucla1")); requesterHelper.Install(consumer).Start(Seconds(1)); requesterHelper.SetAttribute("Name", StringValue("/ndnSIM/anotherData")); requesterHelper.Install(consumer).Start(Seconds(2)); requesterHelper.SetAttribute("Name", StringValue("/ndnSIM/yetAnotherData")); requesterHelper.SetAttribute("Delegation", StringValue("/non-existing")); requesterHelper.Install(consumer).Start(Seconds(3)); // Producer ndn::AppHelper producerHelper("ns3::ndn::Producer"); producerHelper.SetPrefix("/ndnSIM"); producerHelper.SetAttribute("PayloadSize", StringValue("1024")); producerHelper.Install(uclaRegion.Get(0)); Simulator::Stop(Seconds(20.0)); Simulator::Run(); Simulator::Destroy(); return 0; }
int main(int argc, char* argv[]) { // setting default parameters for Wifi // enable rts cts all the time. Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0")); // disable fragmentation Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200")); Config::SetDefault("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue("OfdmRate24Mbps")); // 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")); std::uint32_t max_routers = 1; std::string cSize = "100"; std::string cSplit = "75"; // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize CommandLine cmd; cmd.AddValue("cSize", "Cache Size", cSize); cmd.AddValue("cSplit", "Cache Split", cSplit); cmd.AddValue("routers", "number of routers", max_routers); cmd.Parse(argc, argv); Packet::EnablePrinting (); // Wifi config WifiHelper wifi = WifiHelper::Default (); // Nodes NodeContainer sta_consumers; NodeContainer sta_mobile_consumers; NodeContainer ap; NodeContainer routers; NodeContainer producers; // ?? NetDeviceContainer staDevs; PacketSocketHelper packetSocket; // 5 stationary consumers, 5 mobile, 4 APs and 1 router sta_consumers.Create(3*max_routers); sta_mobile_consumers.Create(7*max_routers); ap.Create (5*max_routers); routers.Create(max_routers); producers.Create(1); // give packet socket powers to nodes. packetSocket.Install(sta_mobile_consumers); packetSocket.Install(sta_consumers); packetSocket.Install (ap); // Wifi Config NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); wifiPhy.Set("TxPowerStart", DoubleValue(5)); wifiPhy.Set("TxPowerEnd", DoubleValue(5)); Ssid ssid = Ssid ("wifi-default"); wifi.SetRemoteStationManager ("ns3::ArfWifiManager"); // setup stas. wifiMac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid), "ActiveProbing", BooleanValue (false)); // install wifi wifi.Install(wifiPhy, wifiMac, sta_mobile_consumers); wifi.Install(wifiPhy, wifiMac, sta_consumers); // setup ap. wifiMac.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid)); wifi.Install (wifiPhy, wifiMac, ap); // Mobility config -- Change max_routers value to change size of sim int number_rows = sqrt(max_routers); int x = 0; int y = 0; int pos_counter = 0; Ptr<UniformRandomVariable> randomizerX = CreateObject<UniformRandomVariable>(); Ptr<UniformRandomVariable> randomizerY = CreateObject<UniformRandomVariable>(); MobilityHelper stationary_mobility; stationary_mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel"); MobilityHelper mobility; mobility.SetMobilityModel("ns3::GaussMarkovMobilityModel", "Bounds", BoxValue(Box (0, number_rows*10, 0, number_rows*10, 0, 0)), "TimeStep", TimeValue(Seconds(1))); // Place router in center of box randomizerX->SetAttribute("Min", DoubleValue(5)); randomizerX->SetAttribute("Max", DoubleValue(5)); randomizerY->SetAttribute("Min", DoubleValue(5)); randomizerY->SetAttribute("Max", DoubleValue(5)); stationary_mobility.SetPositionAllocator("ns3::RandomBoxPositionAllocator", "X", PointerValue(randomizerX), "Y", PointerValue(randomizerY)); // Install on routers stationary_mobility.Install(producers.Get(0)); // p2p helper PointToPointHelper p2p; // for each row for (int i=0; i < number_rows; i++) { x = i * 10 + 5; // for each column for (int j=0; j < number_rows; j++) { y = j * 10 + 5; // Place router in center of box randomizerX->SetAttribute("Min", DoubleValue(x)); randomizerX->SetAttribute("Max", DoubleValue(x)); randomizerY->SetAttribute("Min", DoubleValue(y)); randomizerY->SetAttribute("Max", DoubleValue(y)); stationary_mobility.SetPositionAllocator("ns3::RandomBoxPositionAllocator", "X", PointerValue(randomizerX), "Y", PointerValue(randomizerY)); // Install on routers stationary_mobility.Install(routers.Get(pos_counter)); // Set box (center +/-5) randomizerX->SetAttribute("Min", DoubleValue(x-5)); randomizerX->SetAttribute("Max", DoubleValue(x+5)); randomizerY->SetAttribute("Min", DoubleValue(y-5)); randomizerY->SetAttribute("Max", DoubleValue(y+5)); // Connect router to previous if not 1 if (pos_counter == 0) { p2p.Install(routers.Get(0), producers.Get(0)); } else // Otherwise connect to router behind you { p2p.Install(routers.Get(pos_counter), routers.Get(pos_counter-1)); } // APs for (int k=0; k < 5; k++) { stationary_mobility.SetPositionAllocator("ns3::RandomBoxPositionAllocator", "X", PointerValue(randomizerX), "Y", PointerValue(randomizerY)); stationary_mobility.Install(ap.Get(pos_counter * 5 + k)); p2p.Install(routers.Get(pos_counter), ap.Get(pos_counter * 5 + k)); } // Consumers (stationary) for (int l=0; l < 3; l++) { stationary_mobility.SetPositionAllocator("ns3::RandomBoxPositionAllocator", "X", PointerValue(randomizerX), "Y", PointerValue(randomizerY)); stationary_mobility.Install(sta_consumers.Get(pos_counter * 3 + l)); } // Consumers (Mobile) for (int m=0; m < 7; m++) { mobility.SetPositionAllocator("ns3::RandomBoxPositionAllocator", "X", PointerValue(randomizerX), "Y", PointerValue(randomizerY)); mobility.Install(sta_mobile_consumers.Get(pos_counter * 7 + m)); } // Keep track of overall position pos_counter++; } } // Install NDN stack on all nodes ndn::StackHelper ndnHelper; ndnHelper.SetDefaultRoutes(true); ndnHelper.SetOldContentStore("ns3::ndn::cs::Splitcache", "NormalPolicy", "ns3::ndn::cs::Lru", "SpecialPolicy", "ns3::ndn::cs::Lfu", "TotalCacheSize", cSize, "Configure", cSplit); // Percentage Special^ //ndnHelper.SetOldContentStore("ns3::ndn::cs::Lru"); ndnHelper.Install(ap); ndnHelper.Install(routers); ndnHelper.SetOldContentStore("ns3::ndn::cs::Nocache"); ndnHelper.Install(sta_consumers); ndnHelper.Install(sta_mobile_consumers); ndnHelper.Install(producers); // Choosing forwarding strategy ndn::StrategyChoiceHelper::Install(sta_consumers, "/", "/localhost/nfd/strategy/best-route"); ndn::StrategyChoiceHelper::Install(sta_mobile_consumers, "/", "/localhost/nfd/strategy/best-route"); ndn::StrategyChoiceHelper::Install(ap, "/", "/localhost/nfd/strategy/best-route"); ndn::StrategyChoiceHelper::Install(routers, "/", "/localhost/nfd/strategy/best-route"); ndn::StrategyChoiceHelper::Install(producers, "/", "/localhost/nfd/strategy/best-route"); // Installing applications // Consumer (basic and special data) ndn::AppHelper consumerHelper("ns3::ndn::ConsumerZipfMandelbrot"); consumerHelper.SetAttribute("NumberOfContents", StringValue("100")); // 10 different contents // Consumer will request /prefix/0, /prefix/1, ... // Basic consumers request basic data (and pumpkin spice coffee) consumerHelper.SetPrefix("data/basic"); consumerHelper.SetAttribute("Frequency", StringValue("10")); // 1 interests a second consumerHelper.Install(sta_consumers); // Mobile consumers request special data only consumerHelper.SetPrefix("data/special"); consumerHelper.SetAttribute("Frequency", StringValue("10")); // 2 interests a second consumerHelper.Install(sta_mobile_consumers); // Producer ndn::AppHelper producerHelper("ns3::ndn::Producer"); // Producer will reply to all requests starting with /prefix producerHelper.SetPrefix("/data"); producerHelper.SetAttribute("PayloadSize", StringValue("1024")); producerHelper.SetAttribute("Freshness", TimeValue(Seconds(-1.0))); // unlimited freshness producerHelper.Install(producers); // Tracers 'n stuff //AthstatsHelper athstats; //athstats.EnableAthstats("athstats-sta", sta_mobile_consumers); //athstats.EnableAthstats("athstats-sta", sta_consumers); //athstats.EnableAthstats ("athstats-ap", ap); ndn::AppDelayTracer::Install(sta_consumers, "app-delays-trace-stationary-03.txt"); ndn::AppDelayTracer::Install(sta_mobile_consumers, "app-delays-trace-mobile-03.txt"); ndn::CsTracer::Install(ap, "cs-trace-ap-03.txt", Seconds(1)); ndn::CsTracer::Install(routers, "cs-trace-routers-03.txt", Seconds(1)); // 10 min Simulator::Stop(Seconds(600.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("10Mbps")); 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); // 3 nodes, connected: 0 <---> 1 <---> 2 // 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(0); ndnHelper.SetOldContentStore("ns3::ndn::cs::Lru", "MaxSize", "100"); ndnHelper.InstallAll(); // Choosing forwarding strategy ndn::StrategyChoiceHelper::InstallAll("/myprefix", "/localhost/nfd/strategy/best-route"); // Installing multimedia consumer ns3::ndn::AppHelper consumerHelper("ns3::ndn::FileConsumerCbr::MultimediaConsumer"); consumerHelper.SetAttribute("AllowUpscale", BooleanValue(true)); consumerHelper.SetAttribute("AllowDownscale", BooleanValue(false)); consumerHelper.SetAttribute("ScreenWidth", UintegerValue(1920)); consumerHelper.SetAttribute("ScreenHeight", UintegerValue(1080)); consumerHelper.SetAttribute("StartRepresentationId", StringValue("auto")); consumerHelper.SetAttribute("MaxBufferedSeconds", UintegerValue(30)); consumerHelper.SetAttribute("StartUpDelay", StringValue("0.1")); consumerHelper.SetAttribute("AdaptationLogic", StringValue("dash::player::SVCBufferBasedAdaptationLogic")); consumerHelper.SetAttribute("MpdFileToRequest", StringValue(std::string("/myprefix/SVC/BBB-III.mpd" ))); ApplicationContainer app1 = consumerHelper.Install (nodes.Get(2)); // Producer ndn::AppHelper producerHelper("ns3::ndn::FileServer"); // Producer will reply to all requests starting with /myprefix producerHelper.SetPrefix("/myprefix"); producerHelper.SetAttribute("ContentDirectory", StringValue("/home/someuser/multimediaData")); producerHelper.Install(nodes.Get(0)); // install to some node from nodelist ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; ndnGlobalRoutingHelper.InstallAll(); ndnGlobalRoutingHelper.AddOrigins("/myprefix", nodes.Get(0)); ndn::GlobalRoutingHelper::CalculateRoutes(); Simulator::Stop(Seconds(1200.0)); ndn::DASHPlayerTracer::InstallAll("dash-output.txt"); ndn::CsTracer::InstallAll("cs-trace.txt", Seconds(1)); Simulator::Run(); Simulator::Destroy(); NS_LOG_UNCOND("Simulation Finished."); return 0; }