Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 1 | // ndn-simple-withl2tracer.cc |
| 2 | |
| 3 | #include "ns3/core-module.h" |
| 4 | #include "ns3/network-module.h" |
| 5 | #include "ns3/ndnSIM-module.h" |
| 6 | |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 7 | using namespace ns3; |
| 8 | |
| 9 | int |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 10 | main(int argc, char* argv[]) |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 11 | { |
| 12 | CommandLine cmd; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 13 | cmd.Parse(argc, argv); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 14 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 15 | AnnotatedTopologyReader topologyReader("", 10); |
| 16 | topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-tree-25-node.txt"); |
| 17 | topologyReader.Read(); |
| 18 | |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 19 | /****************************************************************************/ |
| 20 | // Install CCNx stack on all nodes |
| 21 | ndn::StackHelper ccnxHelper; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 22 | ccnxHelper.SetContentStore("ns3::ndn::cs::Lru", "MaxSize", "1000"); |
| 23 | ccnxHelper.SetForwardingStrategy("ns3::ndn::fw::BestRoute"); |
| 24 | ccnxHelper.InstallAll(); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 25 | /****************************************************************************/ |
| 26 | // Installing global routing interface on all nodes |
| 27 | ndn::GlobalRoutingHelper ccnxGlobalRoutingHelper; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 28 | ccnxGlobalRoutingHelper.InstallAll(); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 29 | /****************************************************************************/ |
| 30 | // Getting containers for the consumer/producer |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 31 | Ptr<Node> consumer1 = Names::Find<Node>("Src1"); |
| 32 | Ptr<Node> consumer2 = Names::Find<Node>("Src2"); |
| 33 | Ptr<Node> consumer3 = Names::Find<Node>("Src3"); |
| 34 | Ptr<Node> consumer4 = Names::Find<Node>("Src4"); |
| 35 | Ptr<Node> consumer5 = Names::Find<Node>("Src5"); |
| 36 | Ptr<Node> consumer6 = Names::Find<Node>("Src6"); |
| 37 | Ptr<Node> consumer7 = Names::Find<Node>("Src7"); |
| 38 | Ptr<Node> consumer8 = Names::Find<Node>("Src8"); |
| 39 | Ptr<Node> consumer9 = Names::Find<Node>("Src9"); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 40 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 41 | Ptr<Node> producer1 = Names::Find<Node>("Dst1"); |
| 42 | Ptr<Node> producer2 = Names::Find<Node>("Dst2"); |
| 43 | Ptr<Node> producer3 = Names::Find<Node>("Dst3"); |
| 44 | Ptr<Node> producer4 = Names::Find<Node>("Dst4"); |
| 45 | Ptr<Node> producer5 = Names::Find<Node>("Dst5"); |
| 46 | Ptr<Node> producer6 = Names::Find<Node>("Dst6"); |
| 47 | Ptr<Node> producer7 = Names::Find<Node>("Dst7"); |
| 48 | Ptr<Node> producer8 = Names::Find<Node>("Dst8"); |
| 49 | Ptr<Node> producer9 = Names::Find<Node>("Dst9"); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 50 | /****************************************************************************/ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 51 | ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr"); |
| 52 | consumerHelper.SetAttribute("Frequency", StringValue("1000")); // interests per Second |
| 53 | consumerHelper.SetAttribute("Randomize", StringValue("uniform")); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 54 | /****************************************************************************/ |
| 55 | // on the first to ninth consumer node install a Consumer application |
| 56 | // that will express interests in /dst1 to /dst9 namespace |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 57 | consumerHelper.SetPrefix("/dst9"); |
| 58 | consumerHelper.Install(consumer1); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 59 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 60 | consumerHelper.SetPrefix("/dst8"); |
| 61 | consumerHelper.Install(consumer2); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 62 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 63 | consumerHelper.SetPrefix("/dst7"); |
| 64 | consumerHelper.Install(consumer3); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 65 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 66 | consumerHelper.SetPrefix("/dst6"); |
| 67 | consumerHelper.Install(consumer4); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 68 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 69 | consumerHelper.SetPrefix("/dst5"); |
| 70 | consumerHelper.Install(consumer5); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 71 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 72 | consumerHelper.SetPrefix("/dst4"); |
| 73 | consumerHelper.Install(consumer6); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 74 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 75 | consumerHelper.SetPrefix("/dst3"); |
| 76 | consumerHelper.Install(consumer7); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 77 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 78 | consumerHelper.SetPrefix("/dst2"); |
| 79 | consumerHelper.Install(consumer8); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 80 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 81 | consumerHelper.SetPrefix("/dst1"); |
| 82 | consumerHelper.Install(consumer9); |
| 83 | |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 84 | /****************************************************************************/ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 85 | ndn::AppHelper producerHelper("ns3::ndn::Producer"); |
| 86 | producerHelper.SetAttribute("PayloadSize", StringValue("1024")); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 87 | /****************************************************************************/ |
| 88 | // Register /dst1 to /dst9 prefix with global routing controller and |
| 89 | // install producer that will satisfy Interests in /dst1 to /dst9 namespace |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 90 | ccnxGlobalRoutingHelper.AddOrigins("/dst1", producer1); |
| 91 | producerHelper.SetPrefix("/dst1"); |
| 92 | producerHelper.Install(producer1); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 93 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 94 | ccnxGlobalRoutingHelper.AddOrigins("/dst2", producer2); |
| 95 | producerHelper.SetPrefix("/dst2"); |
| 96 | producerHelper.Install(producer2); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 97 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 98 | ccnxGlobalRoutingHelper.AddOrigins("/dst3", producer3); |
| 99 | producerHelper.SetPrefix("/dst3"); |
| 100 | producerHelper.Install(producer3); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 101 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 102 | ccnxGlobalRoutingHelper.AddOrigins("/dst4", producer4); |
| 103 | producerHelper.SetPrefix("/dst4"); |
| 104 | producerHelper.Install(producer4); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 105 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 106 | ccnxGlobalRoutingHelper.AddOrigins("/dst5", producer5); |
| 107 | producerHelper.SetPrefix("/dst5"); |
| 108 | producerHelper.Install(producer5); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 109 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 110 | ccnxGlobalRoutingHelper.AddOrigins("/dst6", producer6); |
| 111 | producerHelper.SetPrefix("/dst6"); |
| 112 | producerHelper.Install(producer6); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 113 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 114 | ccnxGlobalRoutingHelper.AddOrigins("/dst7", producer7); |
| 115 | producerHelper.SetPrefix("/dst7"); |
| 116 | producerHelper.Install(producer7); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 117 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 118 | ccnxGlobalRoutingHelper.AddOrigins("/dst8", producer8); |
| 119 | producerHelper.SetPrefix("/dst8"); |
| 120 | producerHelper.Install(producer8); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 121 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 122 | ccnxGlobalRoutingHelper.AddOrigins("/dst9", producer9); |
| 123 | producerHelper.SetPrefix("/dst9"); |
| 124 | producerHelper.Install(producer9); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 125 | |
| 126 | /*****************************************************************************/ |
| 127 | // Calculate and install FIBs |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 128 | ccnxGlobalRoutingHelper.CalculateRoutes(); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 129 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 130 | Simulator::Stop(Seconds(10.0)); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 131 | |
| 132 | /****************************************************************************/ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 133 | // Tracer: |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 134 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 135 | L2RateTracer::InstallAll("drop-trace.txt", Seconds(0.5)); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 136 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 137 | Simulator::Run(); |
| 138 | Simulator::Destroy(); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 139 | |
| 140 | return 0; |
| 141 | } |