blob: a2059b2b0afffd0c9155509e0a1d08bfb578bf24 [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 Afanasyevf4a03592012-12-10 16:12:34 -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 Afanasyevf4a03592012-12-10 16:12:34 -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 Afanasyevf4a03592012-12-10 16:12:34 -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 Afanasyevf4a03592012-12-10 16:12:34 -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 Afanasyevf4a03592012-12-10 16:12:34 -080019
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080020// ndn-tree-cs-tracers.cpp
Alexander Afanasyevf4a03592012-12-10 16:12:34 -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 Afanasyevf4a03592012-12-10 16:12:34 -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 Afanasyevf4a03592012-12-10 16:12:34 -080035 * | | | |
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080036 * \ / \ /
37 * \ / \ / 10Mbps / 1ms
38 * \ / \ /
39 * | | | |
40 * v v v v
Alexander Afanasyevf4a03592012-12-10 16:12:34 -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 Afanasyevf4a03592012-12-10 16:12:34 -080049 * v v
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080050 * /--------\
51 * | root |
Alexander Afanasyevf4a03592012-12-10 16:12:34 -080052 * \--------/
53 *
54 *
55 * To run scenario and see what is happening, use the following command:
56 *
57 * ./waf --run=ndn-tree-cs-tracers
58 */
59
60int
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061main(int argc, char* argv[])
Alexander Afanasyevf4a03592012-12-10 16:12:34 -080062{
63 CommandLine cmd;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080064 cmd.Parse(argc, argv);
Alexander Afanasyevf4a03592012-12-10 16:12:34 -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 Afanasyevf4a03592012-12-10 16:12:34 -080069
70 // Install CCNx stack on all nodes
71 ndn::StackHelper ndnHelper;
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080072 ndnHelper.SetContentStoreChoice(false);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080073 ndnHelper.SetContentStore("ns3::ndn::cs::Lru", "MaxSize",
74 "100"); // default ContentStore parameters
75 ndnHelper.InstallAll();
Alexander Afanasyevf4a03592012-12-10 16:12:34 -080076
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080077 // Choosing forwarding strategy
78 ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/best-route");
79
Alexander Afanasyevf4a03592012-12-10 16:12:34 -080080 // Installing global routing interface on all nodes
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080081 ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
82 ndnGlobalRoutingHelper.InstallAll();
Alexander Afanasyevf4a03592012-12-10 16:12:34 -080083
84 // Getting containers for the consumer/producer
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080085 Ptr<Node> consumers[4] = {Names::Find<Node>("leaf-1"), Names::Find<Node>("leaf-2"),
86 Names::Find<Node>("leaf-3"), Names::Find<Node>("leaf-4")};
87 Ptr<Node> producer = Names::Find<Node>("root");
Alexander Afanasyevf4a03592012-12-10 16:12:34 -080088
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080089 for (int i = 0; i < 4; i++) {
90 ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
91 consumerHelper.SetAttribute("Frequency", StringValue("10")); // 100 interests a second
Alexander Afanasyevf4a03592012-12-10 16:12:34 -080092
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080093 // Each consumer will express the same data /root/<seq-no>
94 consumerHelper.SetPrefix("/root");
95 ApplicationContainer app = consumerHelper.Install(consumers[i]);
96 app.Start(Seconds(0.01 * i));
97 }
98
99 ndn::AppHelper producerHelper("ns3::ndn::Producer");
100 producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800101
102 // Register /root prefix with global routing controller and
103 // install producer that will satisfy Interests in /root namespace
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800104 ndnGlobalRoutingHelper.AddOrigins("/root", producer);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800105 producerHelper.SetPrefix("/root");
106 producerHelper.Install(producer);
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800107
108 // Calculate and install FIBs
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800109 ndn::GlobalRoutingHelper::CalculateRoutes();
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800110
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800111 Simulator::Stop(Seconds(20.0));
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800112
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800113 ndn::CsTracer::InstallAll("cs-trace.txt", Seconds(1));
114
115 Simulator::Run();
116 Simulator::Destroy();
Alexander Afanasyevf4a03592012-12-10 16:12:34 -0800117
118 return 0;
119}
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -0800120
121} // namespace ns3
122
123int
124main(int argc, char* argv[])
125{
126 return ns3::main(argc, argv);
127}