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 | aa1c4c3 | 2012-11-21 16:17:03 -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 | aa1c4c3 | 2012-11-21 16:17:03 -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 | aa1c4c3 | 2012-11-21 16:17:03 -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 | aa1c4c3 | 2012-11-21 16:17:03 -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 | **/ |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 19 | |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 20 | // ndn-congestion-topo-plugin.cpp |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 21 | |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 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 | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * This scenario simulates a grid topology (using topology reader module) |
| 30 | * |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 31 | * /------\ /------\ |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 32 | * | Src1 |<--+ +-->| Dst1 | |
| 33 | * \------/ \ / \------/ |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 34 | * \ / |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 35 | * +-->/------\ "bottleneck" /------\<-+ |
| 36 | * | Rtr1 |<===============>| Rtr2 | |
| 37 | * +-->\------/ \------/<-+ |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 38 | * / \ |
| 39 | * /------\ / \ /------\ |
| 40 | * | Src2 |<--+ +-->| Dst2 | |
| 41 | * \------/ \------/ |
| 42 | * |
| 43 | * To run scenario and see what is happening, use the following command: |
| 44 | * |
| 45 | * NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-congestion-topo-plugin |
| 46 | */ |
| 47 | |
| 48 | int |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 49 | main(int argc, char* argv[]) |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 50 | { |
| 51 | CommandLine cmd; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 52 | cmd.Parse(argc, argv); |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 53 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 54 | AnnotatedTopologyReader topologyReader("", 25); |
| 55 | topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-6-node.txt"); |
| 56 | topologyReader.Read(); |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 57 | |
Alexander Afanasyev | 9fb2e3d | 2013-03-30 21:11:07 -0700 | [diff] [blame] | 58 | // Install NDN stack on all nodes |
| 59 | ndn::StackHelper ndnHelper; |
Alexander Afanasyev | 25e4d8f | 2019-07-29 13:44:04 -0400 | [diff] [blame^] | 60 | ndnHelper.setPolicy("nfd::cs::lru"); |
| 61 | ndnHelper.setCsSize(10000); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 62 | ndnHelper.InstallAll(); |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 63 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 64 | // Choosing forwarding strategy |
| 65 | ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/best-route"); |
| 66 | |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 67 | // Installing global routing interface on all nodes |
Alexander Afanasyev | 9fb2e3d | 2013-03-30 21:11:07 -0700 | [diff] [blame] | 68 | ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 69 | ndnGlobalRoutingHelper.InstallAll(); |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 70 | |
| 71 | // Getting containers for the consumer/producer |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 72 | Ptr<Node> consumer1 = Names::Find<Node>("Src1"); |
| 73 | Ptr<Node> consumer2 = Names::Find<Node>("Src2"); |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 74 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 75 | Ptr<Node> producer1 = Names::Find<Node>("Dst1"); |
| 76 | Ptr<Node> producer2 = Names::Find<Node>("Dst2"); |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 77 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 78 | ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr"); |
| 79 | consumerHelper.SetAttribute("Frequency", StringValue("100")); // 100 interests a second |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 80 | |
| 81 | // on the first consumer node install a Consumer application |
| 82 | // that will express interests in /dst1 namespace |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 83 | consumerHelper.SetPrefix("/dst1"); |
| 84 | consumerHelper.Install(consumer1); |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 85 | |
| 86 | // on the second consumer node install a Consumer application |
| 87 | // that will express interests in /dst2 namespace |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 88 | consumerHelper.SetPrefix("/dst2"); |
| 89 | consumerHelper.Install(consumer2); |
| 90 | |
| 91 | ndn::AppHelper producerHelper("ns3::ndn::Producer"); |
| 92 | producerHelper.SetAttribute("PayloadSize", StringValue("1024")); |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 93 | |
| 94 | // Register /dst1 prefix with global routing controller and |
| 95 | // install producer that will satisfy Interests in /dst1 namespace |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 96 | ndnGlobalRoutingHelper.AddOrigins("/dst1", producer1); |
| 97 | producerHelper.SetPrefix("/dst1"); |
| 98 | producerHelper.Install(producer1); |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 99 | |
| 100 | // Register /dst2 prefix with global routing controller and |
| 101 | // install producer that will satisfy Interests in /dst2 namespace |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 102 | ndnGlobalRoutingHelper.AddOrigins("/dst2", producer2); |
| 103 | producerHelper.SetPrefix("/dst2"); |
| 104 | producerHelper.Install(producer2); |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 105 | |
| 106 | // Calculate and install FIBs |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 107 | ndn::GlobalRoutingHelper::CalculateRoutes(); |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 108 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 109 | Simulator::Stop(Seconds(20.0)); |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 110 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 111 | Simulator::Run(); |
| 112 | Simulator::Destroy(); |
Alexander Afanasyev | aa1c4c3 | 2012-11-21 16:17:03 -0800 | [diff] [blame] | 113 | |
| 114 | return 0; |
| 115 | } |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 116 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 117 | } // namespace ns3 |
| 118 | |
| 119 | int |
| 120 | main(int argc, char* argv[]) |
| 121 | { |
| 122 | return ns3::main(argc, argv); |
| 123 | } |