blob: bc085d14ffcfb24ae3a9e6e050ff38b9d71a6f09 [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.
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -08004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -08007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * 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.
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * 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.
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * 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 **/
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080019
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080020// ndn-tree-app-delay-tracer.cpp
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080021
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 {
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080027
28/**
29 * This scenario simulates a tree topology (using topology reader module)
30 *
31 * /------\ /------\ /------\ /------\
32 * |leaf-1| |leaf-2| |leaf-3| |leaf-4|
33 * \------/ \------/ \------/ \------/
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080034 * ^ ^ ^ ^
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080035 * | | | |
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080036 * \ / \ /
37 * \ / \ / 10Mbps / 1ms
38 * \ / \ /
39 * | | | |
40 * v v v v
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080041 * /-------\ /-------\
42 * | rtr-1 | | rtr-2 |
43 * \-------/ \-------/
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080044 * ^ ^
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080045 * | |
46 * \ / 10 Mpbs / 1ms
47 * +--------+ +--------+
48 * | |
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080049 * v v
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080050 * /--------\
51 * | root |
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080052 * \--------/
53 *
54 *
55 * To run scenario and see what is happening, use the following command:
56 *
57 * ./waf --run=ndn-tree-app-delay-tracer
58 */
59
60int
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061main(int argc, char* argv[])
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080062{
63 CommandLine cmd;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080064 cmd.Parse(argc, argv);
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080065
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066 AnnotatedTopologyReader topologyReader("", 1);
67 topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-tree.txt");
68 topologyReader.Read();
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080069
70 // Install CCNx stack on all nodes
71 ndn::StackHelper ndnHelper;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080072 ndnHelper.InstallAll();
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080073
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080074 // Choosing forwarding strategy
75 ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/best-route");
76
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080077 // Installing global routing interface on all nodes
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080078 ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
79 ndnGlobalRoutingHelper.InstallAll();
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080080
81 // Getting containers for the consumer/producer
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080082 Ptr<Node> consumers[4] = {Names::Find<Node>("leaf-1"), Names::Find<Node>("leaf-2"),
83 Names::Find<Node>("leaf-3"), Names::Find<Node>("leaf-4")};
84 Ptr<Node> producer = Names::Find<Node>("root");
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080085
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080086 ndn::AppHelper consumerHelper("ns3::ndn::ConsumerBatches");
87 consumerHelper.SetPrefix("/root");
88 consumerHelper.SetAttribute("Batches", StringValue("1s 1 10s 1"));
89 consumerHelper.Install(consumers[0]);
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080090
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080091 consumerHelper.SetAttribute("Batches", StringValue("11s 1"));
92 consumerHelper.Install(consumers[1]);
93
94 consumerHelper.SetAttribute("Batches", StringValue("11s 1"));
95 consumerHelper.Install(consumers[2]);
96
97 ndn::AppHelper producerHelper("ns3::ndn::Producer");
98 producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080099
100 // Register /root prefix with global routing controller and
101 // install producer that will satisfy Interests in /root namespace
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800102 ndnGlobalRoutingHelper.AddOrigins("/root", producer);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800103 producerHelper.SetPrefix("/root");
104 producerHelper.Install(producer).Start(Seconds(9));
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800105
106 // Calculate and install FIBs
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800107 ndn::GlobalRoutingHelper::CalculateRoutes();
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800108
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800109 Simulator::Stop(Seconds(20.0));
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800110
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800111 ndn::AppDelayTracer::InstallAll("app-delays-trace.txt");
112
113 Simulator::Run();
114 Simulator::Destroy();
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800115
116 return 0;
117}
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800118
119} // namespace ns3
120
121int
122main(int argc, char* argv[])
123{
124 return ns3::main(argc, argv);
125}