blob: b4563a962a6a0bf24ffcf3e1eb74bfb6556511f6 [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
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080027using namespace ns3;
28
29/**
30 * This scenario simulates a tree topology (using topology reader module)
31 *
32 * /------\ /------\ /------\ /------\
33 * |leaf-1| |leaf-2| |leaf-3| |leaf-4|
34 * \------/ \------/ \------/ \------/
35 * ^ ^ ^ ^
36 * | | | |
37 * \ / \ /
38 * \ / \ / 10Mbps / 1ms
39 * \ / \ /
40 * | | | |
41 * v v v v
42 * /-------\ /-------\
43 * | rtr-1 | | rtr-2 |
44 * \-------/ \-------/
45 * ^ ^
46 * | |
47 * \ / 10 Mpbs / 1ms
48 * +--------+ +--------+
49 * | |
50 * v v
51 * /--------\
52 * | root |
53 * \--------/
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
62main (int argc, char *argv[])
63{
64 CommandLine cmd;
65 cmd.Parse (argc, argv);
66
67 AnnotatedTopologyReader topologyReader ("", 1);
68 topologyReader.SetFileName ("src/ndnSIM/examples/topologies/topo-tree.txt");
69 topologyReader.Read ();
70
71 // Install CCNx stack on all nodes
72 ndn::StackHelper ndnHelper;
73 ndnHelper.SetForwardingStrategy ("ns3::ndn::fw::BestRoute");
74 ndnHelper.InstallAll ();
75
76 // Installing global routing interface on all nodes
77 ndn::GlobalRoutingHelper ccnxGlobalRoutingHelper;
78 ccnxGlobalRoutingHelper.InstallAll ();
79
80 // Getting containers for the consumer/producer
81 Ptr<Node> consumers[4] = { Names::Find<Node> ("leaf-1"), Names::Find<Node> ("leaf-2"),
82 Names::Find<Node> ("leaf-3"), Names::Find<Node> ("leaf-4") };
83 Ptr<Node> producer = Names::Find<Node> ("root");
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080084
85 ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerBatches");
86 consumerHelper.SetPrefix ("/root");
87 consumerHelper.SetAttribute ("Batches", StringValue ("1s 1 10s 1"));
88 consumerHelper.Install (consumers[0]);
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080089
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080090 consumerHelper.SetAttribute ("Batches", StringValue ("11s 1"));
91 consumerHelper.Install (consumers[1]);
92
93 consumerHelper.SetAttribute ("Batches", StringValue ("11s 1"));
94 consumerHelper.Install (consumers[2]);
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080095
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080096 ndn::AppHelper producerHelper ("ns3::ndn::Producer");
97 producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
98
99 // Register /root prefix with global routing controller and
100 // install producer that will satisfy Interests in /root namespace
101 ccnxGlobalRoutingHelper.AddOrigins ("/root", producer);
102 producerHelper.SetPrefix ("/root");
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -0800103 producerHelper.Install (producer)
104 .Start (Seconds (9));
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800105
106 // Calculate and install FIBs
107 ccnxGlobalRoutingHelper.CalculateRoutes ();
108
109 Simulator::Stop (Seconds (20.0));
110
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700111 ndn::AppDelayTracer::InstallAll ("app-delays-trace.txt");
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -0800112
113 Simulator::Run ();
114 Simulator::Destroy ();
115
116 return 0;
117}