blob: 19ba3a2e42e31f9b143a9cd53fd152d00a0beb98 [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
10main (int argc, char *argv[])
11{
12 CommandLine cmd;
13 cmd.Parse (argc, argv);
14
15 AnnotatedTopologyReader topologyReader ("", 10);
16 topologyReader.SetFileName ("src/ndnSIM/examples/topologies/topo-tree-25-node.txt");
17 topologyReader.Read ();
18
19 /****************************************************************************/
20 // Install CCNx stack on all nodes
21 ndn::StackHelper ccnxHelper;
22 ccnxHelper.SetContentStore ("ns3::ndn::cs::Lru", "MaxSize", "1000");
23 ccnxHelper.SetForwardingStrategy ("ns3::ndn::fw::BestRoute");
24 ccnxHelper.InstallAll ();
25 /****************************************************************************/
26 // Installing global routing interface on all nodes
27 ndn::GlobalRoutingHelper ccnxGlobalRoutingHelper;
28 ccnxGlobalRoutingHelper.InstallAll ();
29 /****************************************************************************/
30 // Getting containers for the consumer/producer
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");
40
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");
50 /****************************************************************************/
51 ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
52 consumerHelper.SetAttribute ("Frequency", StringValue ("1000"));//interests per Second
53 consumerHelper.SetAttribute ("Randomize", StringValue ("uniform"));
54 /****************************************************************************/
55 // on the first to ninth consumer node install a Consumer application
56 // that will express interests in /dst1 to /dst9 namespace
57 consumerHelper.SetPrefix ("/dst9");
58 consumerHelper.Install (consumer1);
59
60 consumerHelper.SetPrefix ("/dst8");
61 consumerHelper.Install (consumer2);
62
63 consumerHelper.SetPrefix ("/dst7");
64 consumerHelper.Install (consumer3);
65
66 consumerHelper.SetPrefix ("/dst6");
67 consumerHelper.Install (consumer4);
68
69 consumerHelper.SetPrefix ("/dst5");
70 consumerHelper.Install (consumer5);
71
72 consumerHelper.SetPrefix ("/dst4");
73 consumerHelper.Install (consumer6);
74
75 consumerHelper.SetPrefix ("/dst3");
76 consumerHelper.Install (consumer7);
77
78 consumerHelper.SetPrefix ("/dst2");
79 consumerHelper.Install (consumer8);
80
81 consumerHelper.SetPrefix ("/dst1");
82 consumerHelper.Install (consumer9);
83
84 /****************************************************************************/
85 ndn::AppHelper producerHelper ("ns3::ndn::Producer");
86 producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
87 /****************************************************************************/
88 // Register /dst1 to /dst9 prefix with global routing controller and
89 // install producer that will satisfy Interests in /dst1 to /dst9 namespace
90 ccnxGlobalRoutingHelper.AddOrigins ("/dst1", producer1);
91 producerHelper.SetPrefix ("/dst1");
92 producerHelper.Install (producer1);
93
94 ccnxGlobalRoutingHelper.AddOrigins ("/dst2", producer2);
95 producerHelper.SetPrefix ("/dst2");
96 producerHelper.Install (producer2);
97
98 ccnxGlobalRoutingHelper.AddOrigins ("/dst3", producer3);
99 producerHelper.SetPrefix ("/dst3");
100 producerHelper.Install (producer3);
101
102 ccnxGlobalRoutingHelper.AddOrigins ("/dst4", producer4);
103 producerHelper.SetPrefix ("/dst4");
104 producerHelper.Install (producer4);
105
106 ccnxGlobalRoutingHelper.AddOrigins ("/dst5", producer5);
107 producerHelper.SetPrefix ("/dst5");
108 producerHelper.Install (producer5);
109
110 ccnxGlobalRoutingHelper.AddOrigins ("/dst6", producer6);
111 producerHelper.SetPrefix ("/dst6");
112 producerHelper.Install (producer6);
113
114 ccnxGlobalRoutingHelper.AddOrigins ("/dst7", producer7);
115 producerHelper.SetPrefix ("/dst7");
116 producerHelper.Install (producer7);
117
118 ccnxGlobalRoutingHelper.AddOrigins ("/dst8", producer8);
119 producerHelper.SetPrefix ("/dst8");
120 producerHelper.Install (producer8);
121
122 ccnxGlobalRoutingHelper.AddOrigins ("/dst9", producer9);
123 producerHelper.SetPrefix ("/dst9");
124 producerHelper.Install (producer9);
125
126 /*****************************************************************************/
127 // Calculate and install FIBs
128 ccnxGlobalRoutingHelper.CalculateRoutes ();
129
130 Simulator::Stop (Seconds (10.0));
131
132 /****************************************************************************/
133 //Tracer:
134
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700135 L2RateTracer::InstallAll ("drop-trace.txt", Seconds (0.5));
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700136
137 Simulator::Run ();
138 Simulator::Destroy ();
139
140 return 0;
141}