Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ns3/core-module.h"
- #include "ns3/network-module.h"
- #include "ns3/ndnSIM-module.h"
- namespace ns3 {
- /**
- * This scenario simulates a grid topology (using topology reader module)
- *
- * /------\ /------\
- * | Src1 |<--+ +-->| Dst1 |
- * \------/ \ / \------/
- * \ /
- * +-->/------\ /------\<-+
- * | Rtr1 |<===============>| Rtr2 |
- * +-->\------/ \------/<-+
- * / \
- * /------\ / \ /------\
- * | Src2 |<--+ +-->| Dst2 |
- * \------/ \------/
- *
- *
- */
- //Lifetime function
- void CacheEntryRemoved(std::string context, Ptr<const ndn::cs::Entry> entry, Time lifetime)
- {
- std::cout << entry->GetName() << " " << lifetime.ToDouble(Time::S) << "s" << std::endl;
- }
- int main(int argc, char* argv[])
- {
- CommandLine cmd;
- cmd.Parse(argc, argv);
- AnnotatedTopologyReader topologyReader("", 25);
- topologyReader.SetFileName("../ns-3/src/ndnSIM/examples/topologies/topo-6-node.txt");
- //topologyReader.SetFileName("/home/christos/ndn/scenario/extensions/topo6.txt");
- topologyReader.Read();
- // Install NDN stack on all nodes
- ndn::StackHelper ndnHelper;
- //ndnHelper.SetOldContentStore("nfd:cs:lru", "MaxSize", "10000");
- ndnHelper.SetOldContentStore("ns3::ndn::cs::Stats::Fifo", "MaxSize", "50000");
- ndnHelper.InstallAll();
- // connect (each node) to lifetime trace
- Config::Connect("/Nodelist/ns3::ndn::cs::Stats::Fifo/WillRemoveEntry", MakeCallback(CacheEntryRemoved));
- // 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> consumer1 = Names::Find<Node>("Src1");
- Ptr<Node> consumer2 = Names::Find<Node>("Src2");
- Ptr<Node> producer1 = Names::Find<Node>("Dst1");
- Ptr<Node> producer2 = Names::Find<Node>("Dst2");
- ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
- consumerHelper.SetAttribute("Frequency", StringValue("32")); // 32 interests a second
- // on the first consumer node install a Consumer application
- // that will express interests in /dst1 namespace
- consumerHelper.SetPrefix("/dst1");
- consumerHelper.Install(consumer1);
- // on the second consumer node install a Consumer application
- // that will express interests in /dst2 namespace
- consumerHelper.SetPrefix("/dst2");
- consumerHelper.Install(consumer2);
- ndn::AppHelper producerHelper("ns3::ndn::Producer");
- producerHelper.SetAttribute("PayloadSize", StringValue("320000"));
- // Register /dst1 prefix with global routing controller and
- // install producer that will satisfy Interests in /dst1 namespace
- ndnGlobalRoutingHelper.AddOrigins("/dst1", producer1);
- producerHelper.SetPrefix("/dst1");
- producerHelper.Install(producer1);
- // Register /dst2 prefix with global routing controller and
- // install producer that will satisfy Interests in /dst2 namespace
- ndnGlobalRoutingHelper.AddOrigins("/dst2", producer2);
- producerHelper.SetPrefix("/dst2");
- producerHelper.Install(producer2);
- // Calculate and install FIBs
- ndn::GlobalRoutingHelper::CalculateRoutes();
- Simulator::Stop(Seconds(20.0));
- //ndn::L3RateTracer::InstallAll("top_320.txt", Seconds(0.5));
- ndn::CsTracer::InstallAll("cs-trace320.txt", Seconds(0.5));
- // ndn::AppDelayTracer::InstallAll("delay320.txt");
- Simulator::Run();
- Simulator::Destroy();
- return 0;
- }
- } // namespace ns3
- int
- main(int argc, char* argv[])
- {
- return ns3::main(argc, argv);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement