Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2011-2015 Regents of the University of California. |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame^] | 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and |
| 6 | * contributors. |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 7 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame^] | 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. |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 11 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame^] | 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. |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 15 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame^] | 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 | **/ |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 19 | |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame^] | 20 | // ndn-tree-app-delay-tracer.cpp |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 21 | |
| 22 | #include "ns3/core-module.h" |
| 23 | #include "ns3/network-module.h" |
| 24 | #include "ns3/ndnSIM-module.h" |
| 25 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 26 | namespace ns3 { |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 27 | |
| 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 Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 34 | * ^ ^ ^ ^ |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 35 | * | | | | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 36 | * \ / \ / |
| 37 | * \ / \ / 10Mbps / 1ms |
| 38 | * \ / \ / |
| 39 | * | | | | |
| 40 | * v v v v |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 41 | * /-------\ /-------\ |
| 42 | * | rtr-1 | | rtr-2 | |
| 43 | * \-------/ \-------/ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 44 | * ^ ^ |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 45 | * | | |
| 46 | * \ / 10 Mpbs / 1ms |
| 47 | * +--------+ +--------+ |
| 48 | * | | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 49 | * v v |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 50 | * /--------\ |
| 51 | * | root | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 52 | * \--------/ |
| 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 | |
| 60 | int |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 61 | main(int argc, char* argv[]) |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 62 | { |
| 63 | CommandLine cmd; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 64 | cmd.Parse(argc, argv); |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 65 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 66 | AnnotatedTopologyReader topologyReader("", 1); |
| 67 | topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-tree.txt"); |
| 68 | topologyReader.Read(); |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 69 | |
| 70 | // Install CCNx stack on all nodes |
| 71 | ndn::StackHelper ndnHelper; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 72 | ndnHelper.InstallAll(); |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 73 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 74 | // Choosing forwarding strategy |
| 75 | ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/best-route"); |
| 76 | |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 77 | // Installing global routing interface on all nodes |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 78 | ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; |
| 79 | ndnGlobalRoutingHelper.InstallAll(); |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 80 | |
| 81 | // Getting containers for the consumer/producer |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 82 | 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 Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 85 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 86 | 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 Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 90 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 91 | 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 Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 99 | |
| 100 | // Register /root prefix with global routing controller and |
| 101 | // install producer that will satisfy Interests in /root namespace |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 102 | ndnGlobalRoutingHelper.AddOrigins("/root", producer); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 103 | producerHelper.SetPrefix("/root"); |
| 104 | producerHelper.Install(producer).Start(Seconds(9)); |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 105 | |
| 106 | // Calculate and install FIBs |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 107 | ndn::GlobalRoutingHelper::CalculateRoutes(); |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 108 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 109 | Simulator::Stop(Seconds(20.0)); |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 110 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 111 | ndn::AppDelayTracer::InstallAll("app-delays-trace.txt"); |
| 112 | |
| 113 | Simulator::Run(); |
| 114 | Simulator::Destroy(); |
Alexander Afanasyev | db64ff1 | 2013-01-18 16:37:31 -0800 | [diff] [blame] | 115 | |
| 116 | return 0; |
| 117 | } |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 118 | |
| 119 | } // namespace ns3 |
| 120 | |
| 121 | int |
| 122 | main(int argc, char* argv[]) |
| 123 | { |
| 124 | return ns3::main(argc, argv); |
| 125 | } |