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