blob: ab8067538cc13e71faa218054f90d8374beda607 [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
4 *
5 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
7 *
8 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20// ndn-simple-withl2tracer.cpp
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070021
22#include "ns3/core-module.h"
23#include "ns3/network-module.h"
24#include "ns3/ndnSIM-module.h"
25
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080026namespace ns3 {
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070027
28int
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080029main(int argc, char* argv[])
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070030{
31 CommandLine cmd;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080032 cmd.Parse(argc, argv);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070033
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080034 AnnotatedTopologyReader topologyReader("", 10);
35 topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-tree-25-node.txt");
36 topologyReader.Read();
37
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070038 /****************************************************************************/
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080039 // Install NDN stack on all nodes
40 ndn::StackHelper ndnHelper;
Alexander Afanasyevdde1e812015-01-06 14:26:09 -080041 ndnHelper.SetOldContentStore("ns3::ndn::cs::Lru", "MaxSize", "1000");
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080042 ndnHelper.InstallAll();
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070043 /****************************************************************************/
44 // Installing global routing interface on all nodes
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080045 ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
46 ndnGlobalRoutingHelper.InstallAll();
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070047 /****************************************************************************/
48 // Getting containers for the consumer/producer
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080049 Ptr<Node> consumer1 = Names::Find<Node>("Src1");
50 Ptr<Node> consumer2 = Names::Find<Node>("Src2");
51 Ptr<Node> consumer3 = Names::Find<Node>("Src3");
52 Ptr<Node> consumer4 = Names::Find<Node>("Src4");
53 Ptr<Node> consumer5 = Names::Find<Node>("Src5");
54 Ptr<Node> consumer6 = Names::Find<Node>("Src6");
55 Ptr<Node> consumer7 = Names::Find<Node>("Src7");
56 Ptr<Node> consumer8 = Names::Find<Node>("Src8");
57 Ptr<Node> consumer9 = Names::Find<Node>("Src9");
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070058
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080059 Ptr<Node> producer1 = Names::Find<Node>("Dst1");
60 Ptr<Node> producer2 = Names::Find<Node>("Dst2");
61 Ptr<Node> producer3 = Names::Find<Node>("Dst3");
62 Ptr<Node> producer4 = Names::Find<Node>("Dst4");
63 Ptr<Node> producer5 = Names::Find<Node>("Dst5");
64 Ptr<Node> producer6 = Names::Find<Node>("Dst6");
65 Ptr<Node> producer7 = Names::Find<Node>("Dst7");
66 Ptr<Node> producer8 = Names::Find<Node>("Dst8");
67 Ptr<Node> producer9 = Names::Find<Node>("Dst9");
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070068 /****************************************************************************/
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080069 ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
70 consumerHelper.SetAttribute("Frequency", StringValue("1000")); // interests per Second
71 consumerHelper.SetAttribute("Randomize", StringValue("uniform"));
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070072 /****************************************************************************/
73 // on the first to ninth consumer node install a Consumer application
74 // that will express interests in /dst1 to /dst9 namespace
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080075 consumerHelper.SetPrefix("/dst9");
76 consumerHelper.Install(consumer1);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070077
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080078 consumerHelper.SetPrefix("/dst8");
79 consumerHelper.Install(consumer2);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070080
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080081 consumerHelper.SetPrefix("/dst7");
82 consumerHelper.Install(consumer3);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070083
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080084 consumerHelper.SetPrefix("/dst6");
85 consumerHelper.Install(consumer4);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070086
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080087 consumerHelper.SetPrefix("/dst5");
88 consumerHelper.Install(consumer5);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070089
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080090 consumerHelper.SetPrefix("/dst4");
91 consumerHelper.Install(consumer6);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070092
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080093 consumerHelper.SetPrefix("/dst3");
94 consumerHelper.Install(consumer7);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070095
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080096 consumerHelper.SetPrefix("/dst2");
97 consumerHelper.Install(consumer8);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070098
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080099 consumerHelper.SetPrefix("/dst1");
100 consumerHelper.Install(consumer9);
101
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700102 /****************************************************************************/
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800103 ndn::AppHelper producerHelper("ns3::ndn::Producer");
104 producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700105 /****************************************************************************/
106 // Register /dst1 to /dst9 prefix with global routing controller and
107 // install producer that will satisfy Interests in /dst1 to /dst9 namespace
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800108 ndnGlobalRoutingHelper.AddOrigins("/dst1", producer1);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800109 producerHelper.SetPrefix("/dst1");
110 producerHelper.Install(producer1);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700111
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800112 ndnGlobalRoutingHelper.AddOrigins("/dst2", producer2);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800113 producerHelper.SetPrefix("/dst2");
114 producerHelper.Install(producer2);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700115
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800116 ndnGlobalRoutingHelper.AddOrigins("/dst3", producer3);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800117 producerHelper.SetPrefix("/dst3");
118 producerHelper.Install(producer3);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700119
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800120 ndnGlobalRoutingHelper.AddOrigins("/dst4", producer4);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800121 producerHelper.SetPrefix("/dst4");
122 producerHelper.Install(producer4);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700123
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800124 ndnGlobalRoutingHelper.AddOrigins("/dst5", producer5);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800125 producerHelper.SetPrefix("/dst5");
126 producerHelper.Install(producer5);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700127
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800128 ndnGlobalRoutingHelper.AddOrigins("/dst6", producer6);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800129 producerHelper.SetPrefix("/dst6");
130 producerHelper.Install(producer6);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700131
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800132 ndnGlobalRoutingHelper.AddOrigins("/dst7", producer7);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800133 producerHelper.SetPrefix("/dst7");
134 producerHelper.Install(producer7);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700135
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800136 ndnGlobalRoutingHelper.AddOrigins("/dst8", producer8);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800137 producerHelper.SetPrefix("/dst8");
138 producerHelper.Install(producer8);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700139
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800140 ndnGlobalRoutingHelper.AddOrigins("/dst9", producer9);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800141 producerHelper.SetPrefix("/dst9");
142 producerHelper.Install(producer9);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700143
144 /*****************************************************************************/
145 // Calculate and install FIBs
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800146 ndn::GlobalRoutingHelper::CalculateRoutes();
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700147
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800148 Simulator::Stop(Seconds(10.0));
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700149
150 /****************************************************************************/
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800151 // Tracer:
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700152
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800153 L2RateTracer::InstallAll("drop-trace.txt", Seconds(0.5));
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700154
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800155 Simulator::Run();
156 Simulator::Destroy();
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700157
158 return 0;
159}
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800160
161} // namespace ns3
162
163int
164main(int argc, char* argv[])
165{
166 return ns3::main(argc, argv);
167}