blob: 8d5e3e030dfc3a05a06fa8185281f88249867532 [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
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -07007using namespace ns3;
8
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 /****************************************************************************/
20 // Install CCNx stack on all nodes
21 ndn::StackHelper ccnxHelper;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080022 ccnxHelper.SetContentStore("ns3::ndn::cs::Lru", "MaxSize", "1000");
23 ccnxHelper.SetForwardingStrategy("ns3::ndn::fw::BestRoute");
24 ccnxHelper.InstallAll();
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070025 /****************************************************************************/
26 // Installing global routing interface on all nodes
27 ndn::GlobalRoutingHelper ccnxGlobalRoutingHelper;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080028 ccnxGlobalRoutingHelper.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
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080090 ccnxGlobalRoutingHelper.AddOrigins("/dst1", producer1);
91 producerHelper.SetPrefix("/dst1");
92 producerHelper.Install(producer1);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070093
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080094 ccnxGlobalRoutingHelper.AddOrigins("/dst2", producer2);
95 producerHelper.SetPrefix("/dst2");
96 producerHelper.Install(producer2);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070097
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080098 ccnxGlobalRoutingHelper.AddOrigins("/dst3", producer3);
99 producerHelper.SetPrefix("/dst3");
100 producerHelper.Install(producer3);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700101
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800102 ccnxGlobalRoutingHelper.AddOrigins("/dst4", producer4);
103 producerHelper.SetPrefix("/dst4");
104 producerHelper.Install(producer4);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700105
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800106 ccnxGlobalRoutingHelper.AddOrigins("/dst5", producer5);
107 producerHelper.SetPrefix("/dst5");
108 producerHelper.Install(producer5);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700109
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800110 ccnxGlobalRoutingHelper.AddOrigins("/dst6", producer6);
111 producerHelper.SetPrefix("/dst6");
112 producerHelper.Install(producer6);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700113
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800114 ccnxGlobalRoutingHelper.AddOrigins("/dst7", producer7);
115 producerHelper.SetPrefix("/dst7");
116 producerHelper.Install(producer7);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700117
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800118 ccnxGlobalRoutingHelper.AddOrigins("/dst8", producer8);
119 producerHelper.SetPrefix("/dst8");
120 producerHelper.Install(producer8);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700121
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800122 ccnxGlobalRoutingHelper.AddOrigins("/dst9", producer9);
123 producerHelper.SetPrefix("/dst9");
124 producerHelper.Install(producer9);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700125
126 /*****************************************************************************/
127 // Calculate and install FIBs
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800128 ccnxGlobalRoutingHelper.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}