blob: 52b8e8dcb8b7a028d1c36e43103d4ed831298f6d [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;
41 ndnHelper.SetContentStoreChoice(false);
42 ndnHelper.SetContentStore("ns3::ndn::cs::Lru", "MaxSize", "1000");
43 ndnHelper.InstallAll();
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070044 /****************************************************************************/
45 // Installing global routing interface on all nodes
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080046 ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
47 ndnGlobalRoutingHelper.InstallAll();
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070048 /****************************************************************************/
49 // Getting containers for the consumer/producer
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080050 Ptr<Node> consumer1 = Names::Find<Node>("Src1");
51 Ptr<Node> consumer2 = Names::Find<Node>("Src2");
52 Ptr<Node> consumer3 = Names::Find<Node>("Src3");
53 Ptr<Node> consumer4 = Names::Find<Node>("Src4");
54 Ptr<Node> consumer5 = Names::Find<Node>("Src5");
55 Ptr<Node> consumer6 = Names::Find<Node>("Src6");
56 Ptr<Node> consumer7 = Names::Find<Node>("Src7");
57 Ptr<Node> consumer8 = Names::Find<Node>("Src8");
58 Ptr<Node> consumer9 = Names::Find<Node>("Src9");
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070059
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080060 Ptr<Node> producer1 = Names::Find<Node>("Dst1");
61 Ptr<Node> producer2 = Names::Find<Node>("Dst2");
62 Ptr<Node> producer3 = Names::Find<Node>("Dst3");
63 Ptr<Node> producer4 = Names::Find<Node>("Dst4");
64 Ptr<Node> producer5 = Names::Find<Node>("Dst5");
65 Ptr<Node> producer6 = Names::Find<Node>("Dst6");
66 Ptr<Node> producer7 = Names::Find<Node>("Dst7");
67 Ptr<Node> producer8 = Names::Find<Node>("Dst8");
68 Ptr<Node> producer9 = Names::Find<Node>("Dst9");
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070069 /****************************************************************************/
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080070 ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
71 consumerHelper.SetAttribute("Frequency", StringValue("1000")); // interests per Second
72 consumerHelper.SetAttribute("Randomize", StringValue("uniform"));
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070073 /****************************************************************************/
74 // on the first to ninth consumer node install a Consumer application
75 // that will express interests in /dst1 to /dst9 namespace
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080076 consumerHelper.SetPrefix("/dst9");
77 consumerHelper.Install(consumer1);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070078
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080079 consumerHelper.SetPrefix("/dst8");
80 consumerHelper.Install(consumer2);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070081
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080082 consumerHelper.SetPrefix("/dst7");
83 consumerHelper.Install(consumer3);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070084
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080085 consumerHelper.SetPrefix("/dst6");
86 consumerHelper.Install(consumer4);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070087
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080088 consumerHelper.SetPrefix("/dst5");
89 consumerHelper.Install(consumer5);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070090
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080091 consumerHelper.SetPrefix("/dst4");
92 consumerHelper.Install(consumer6);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070093
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080094 consumerHelper.SetPrefix("/dst3");
95 consumerHelper.Install(consumer7);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070096
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080097 consumerHelper.SetPrefix("/dst2");
98 consumerHelper.Install(consumer8);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -070099
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800100 consumerHelper.SetPrefix("/dst1");
101 consumerHelper.Install(consumer9);
102
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700103 /****************************************************************************/
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800104 ndn::AppHelper producerHelper("ns3::ndn::Producer");
105 producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700106 /****************************************************************************/
107 // Register /dst1 to /dst9 prefix with global routing controller and
108 // install producer that will satisfy Interests in /dst1 to /dst9 namespace
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800109 ndnGlobalRoutingHelper.AddOrigins("/dst1", producer1);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800110 producerHelper.SetPrefix("/dst1");
111 producerHelper.Install(producer1);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700112
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800113 ndnGlobalRoutingHelper.AddOrigins("/dst2", producer2);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800114 producerHelper.SetPrefix("/dst2");
115 producerHelper.Install(producer2);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700116
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800117 ndnGlobalRoutingHelper.AddOrigins("/dst3", producer3);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800118 producerHelper.SetPrefix("/dst3");
119 producerHelper.Install(producer3);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700120
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800121 ndnGlobalRoutingHelper.AddOrigins("/dst4", producer4);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800122 producerHelper.SetPrefix("/dst4");
123 producerHelper.Install(producer4);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700124
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800125 ndnGlobalRoutingHelper.AddOrigins("/dst5", producer5);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800126 producerHelper.SetPrefix("/dst5");
127 producerHelper.Install(producer5);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700128
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800129 ndnGlobalRoutingHelper.AddOrigins("/dst6", producer6);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800130 producerHelper.SetPrefix("/dst6");
131 producerHelper.Install(producer6);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700132
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800133 ndnGlobalRoutingHelper.AddOrigins("/dst7", producer7);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800134 producerHelper.SetPrefix("/dst7");
135 producerHelper.Install(producer7);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700136
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800137 ndnGlobalRoutingHelper.AddOrigins("/dst8", producer8);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800138 producerHelper.SetPrefix("/dst8");
139 producerHelper.Install(producer8);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700140
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800141 ndnGlobalRoutingHelper.AddOrigins("/dst9", producer9);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800142 producerHelper.SetPrefix("/dst9");
143 producerHelper.Install(producer9);
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700144
145 /*****************************************************************************/
146 // Calculate and install FIBs
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800147 ndn::GlobalRoutingHelper::CalculateRoutes();
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700148
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800149 Simulator::Stop(Seconds(10.0));
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700150
151 /****************************************************************************/
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800152 // Tracer:
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700153
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800154 L2RateTracer::InstallAll("drop-trace.txt", Seconds(0.5));
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700155
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800156 Simulator::Run();
157 Simulator::Destroy();
Hovaidi Ardestani Mohammad8682ae02013-03-12 13:53:15 -0700158
159 return 0;
160}
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800161
162} // namespace ns3
163
164int
165main(int argc, char* argv[])
166{
167 return ns3::main(argc, argv);
168}