blob: 4a6c0c84ee5d1c812412580b72a58f4a754bffde [file] [log] [blame]
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011-2012 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
21// ndn-tree-app-delay-tracer.cc
22
23#include "ns3/core-module.h"
24#include "ns3/network-module.h"
25#include "ns3/ndnSIM-module.h"
26
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080027namespace ns3 {
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080028
29/**
30 * This scenario simulates a tree topology (using topology reader module)
31 *
32 * /------\ /------\ /------\ /------\
33 * |leaf-1| |leaf-2| |leaf-3| |leaf-4|
34 * \------/ \------/ \------/ \------/
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080035 * ^ ^ ^ ^
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080036 * | | | |
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080037 * \ / \ /
38 * \ / \ / 10Mbps / 1ms
39 * \ / \ /
40 * | | | |
41 * v v v v
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080042 * /-------\ /-------\
43 * | rtr-1 | | rtr-2 |
44 * \-------/ \-------/
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080045 * ^ ^
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080046 * | |
47 * \ / 10 Mpbs / 1ms
48 * +--------+ +--------+
49 * | |
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080050 * v v
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080051 * /--------\
52 * | root |
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080053 * \--------/
54 *
55 *
56 * To run scenario and see what is happening, use the following command:
57 *
58 * ./waf --run=ndn-tree-app-delay-tracer
59 */
60
61int
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080062main(int argc, char* argv[])
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080063{
64 CommandLine cmd;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080065 cmd.Parse(argc, argv);
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080066
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080067 AnnotatedTopologyReader topologyReader("", 1);
68 topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-tree.txt");
69 topologyReader.Read();
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080070
71 // Install CCNx stack on all nodes
72 ndn::StackHelper ndnHelper;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080073 ndnHelper.InstallAll();
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080074
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080075 // Choosing forwarding strategy
76 ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/best-route");
77
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080078 // Installing global routing interface on all nodes
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080079 ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
80 ndnGlobalRoutingHelper.InstallAll();
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080081
82 // Getting containers for the consumer/producer
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080083 Ptr<Node> consumers[4] = {Names::Find<Node>("leaf-1"), Names::Find<Node>("leaf-2"),
84 Names::Find<Node>("leaf-3"), Names::Find<Node>("leaf-4")};
85 Ptr<Node> producer = Names::Find<Node>("root");
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080086
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080087 ndn::AppHelper consumerHelper("ns3::ndn::ConsumerBatches");
88 consumerHelper.SetPrefix("/root");
89 consumerHelper.SetAttribute("Batches", StringValue("1s 1 10s 1"));
90 consumerHelper.Install(consumers[0]);
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080091
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080092 consumerHelper.SetAttribute("Batches", StringValue("11s 1"));
93 consumerHelper.Install(consumers[1]);
94
95 consumerHelper.SetAttribute("Batches", StringValue("11s 1"));
96 consumerHelper.Install(consumers[2]);
97
98 ndn::AppHelper producerHelper("ns3::ndn::Producer");
99 producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800100
101 // Register /root prefix with global routing controller and
102 // install producer that will satisfy Interests in /root namespace
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800103 ndnGlobalRoutingHelper.AddOrigins("/root", producer);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800104 producerHelper.SetPrefix("/root");
105 producerHelper.Install(producer).Start(Seconds(9));
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800106
107 // Calculate and install FIBs
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800108 ndn::GlobalRoutingHelper::CalculateRoutes();
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800109
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800110 Simulator::Stop(Seconds(20.0));
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800111
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800112 ndn::AppDelayTracer::InstallAll("app-delays-trace.txt");
113
114 Simulator::Run();
115 Simulator::Destroy();
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800116
117 return 0;
118}
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800119
120} // namespace ns3
121
122int
123main(int argc, char* argv[])
124{
125 return ns3::main(argc, argv);
126}