blob: cc24c23d7af0a749d69ed4da10771c1d5b6fd308 [file] [log] [blame]
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -07001// ndn-simple-withl2tracer.cc
2
3#include "ns3/core-module.h"
4#include "ns3/network-module.h"
5#include "ns3/ndnSIM-module.h"
6
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -08007namespace ns3 {
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -07008
9int
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080010main(int argc, char* argv[])
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070011{
12 CommandLine cmd;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080013 cmd.Parse(argc, argv);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070014
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080015 AnnotatedTopologyReader topologyReader("", 10);
16 topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-tree-25-node.txt");
17 topologyReader.Read();
18
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070019 /****************************************************************************/
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080020 // Install NDN stack on all nodes
21 ndn::StackHelper ndnHelper;
22 ndnHelper.SetContentStoreChoice(false);
23 ndnHelper.SetContentStore("ns3::ndn::cs::Lru", "MaxSize", "1000");
24 ndnHelper.InstallAll();
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070025 /****************************************************************************/
26 // Installing global routing interface on all nodes
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080027 ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
28 ndnGlobalRoutingHelper.InstallAll();
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070029 /****************************************************************************/
30 // Getting containers for the consumer/producer
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080031 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 Mohammad8682ae02013-03-12 13:53:15 -070040
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080041 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 Mohammad8682ae02013-03-12 13:53:15 -070050 /****************************************************************************/
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080051 ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
52 consumerHelper.SetAttribute("Frequency", StringValue("1000")); // interests per Second
53 consumerHelper.SetAttribute("Randomize", StringValue("uniform"));
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070054 /****************************************************************************/
55 // on the first to ninth consumer node install a Consumer application
56 // that will express interests in /dst1 to /dst9 namespace
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080057 consumerHelper.SetPrefix("/dst9");
58 consumerHelper.Install(consumer1);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070059
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080060 consumerHelper.SetPrefix("/dst8");
61 consumerHelper.Install(consumer2);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070062
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080063 consumerHelper.SetPrefix("/dst7");
64 consumerHelper.Install(consumer3);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070065
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066 consumerHelper.SetPrefix("/dst6");
67 consumerHelper.Install(consumer4);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070068
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080069 consumerHelper.SetPrefix("/dst5");
70 consumerHelper.Install(consumer5);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070071
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080072 consumerHelper.SetPrefix("/dst4");
73 consumerHelper.Install(consumer6);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070074
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080075 consumerHelper.SetPrefix("/dst3");
76 consumerHelper.Install(consumer7);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070077
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080078 consumerHelper.SetPrefix("/dst2");
79 consumerHelper.Install(consumer8);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070080
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080081 consumerHelper.SetPrefix("/dst1");
82 consumerHelper.Install(consumer9);
83
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070084 /****************************************************************************/
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080085 ndn::AppHelper producerHelper("ns3::ndn::Producer");
86 producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070087 /****************************************************************************/
88 // Register /dst1 to /dst9 prefix with global routing controller and
89 // install producer that will satisfy Interests in /dst1 to /dst9 namespace
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080090 ndnGlobalRoutingHelper.AddOrigins("/dst1", producer1);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080091 producerHelper.SetPrefix("/dst1");
92 producerHelper.Install(producer1);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070093
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080094 ndnGlobalRoutingHelper.AddOrigins("/dst2", producer2);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080095 producerHelper.SetPrefix("/dst2");
96 producerHelper.Install(producer2);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070097
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080098 ndnGlobalRoutingHelper.AddOrigins("/dst3", producer3);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080099 producerHelper.SetPrefix("/dst3");
100 producerHelper.Install(producer3);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700101
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800102 ndnGlobalRoutingHelper.AddOrigins("/dst4", producer4);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800103 producerHelper.SetPrefix("/dst4");
104 producerHelper.Install(producer4);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700105
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800106 ndnGlobalRoutingHelper.AddOrigins("/dst5", producer5);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800107 producerHelper.SetPrefix("/dst5");
108 producerHelper.Install(producer5);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700109
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800110 ndnGlobalRoutingHelper.AddOrigins("/dst6", producer6);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800111 producerHelper.SetPrefix("/dst6");
112 producerHelper.Install(producer6);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700113
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800114 ndnGlobalRoutingHelper.AddOrigins("/dst7", producer7);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800115 producerHelper.SetPrefix("/dst7");
116 producerHelper.Install(producer7);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700117
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800118 ndnGlobalRoutingHelper.AddOrigins("/dst8", producer8);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800119 producerHelper.SetPrefix("/dst8");
120 producerHelper.Install(producer8);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700121
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800122 ndnGlobalRoutingHelper.AddOrigins("/dst9", producer9);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800123 producerHelper.SetPrefix("/dst9");
124 producerHelper.Install(producer9);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700125
126 /*****************************************************************************/
127 // Calculate and install FIBs
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800128 ndn::GlobalRoutingHelper::CalculateRoutes();
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700129
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800130 Simulator::Stop(Seconds(10.0));
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700131
132 /****************************************************************************/
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800133 // Tracer:
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700134
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800135 L2RateTracer::InstallAll("drop-trace.txt", Seconds(0.5));
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700136
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800137 Simulator::Run();
138 Simulator::Destroy();
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700139
140 return 0;
141}
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800142
143} // namespace ns3
144
145int
146main(int argc, char* argv[])
147{
148 return ns3::main(argc, argv);
149}