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. |
| 4 | * |
| 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and |
| 6 | * contributors. |
| 7 | * |
| 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. |
| 11 | * |
| 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. |
| 15 | * |
| 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 | **/ |
| 19 | |
| 20 | // ndn-simple-withl2tracer.cpp |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [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 { |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 27 | |
| 28 | int |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 29 | main(int argc, char* argv[]) |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 30 | { |
| 31 | CommandLine cmd; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 32 | cmd.Parse(argc, argv); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 33 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 34 | AnnotatedTopologyReader topologyReader("", 10); |
| 35 | topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-tree-25-node.txt"); |
| 36 | topologyReader.Read(); |
| 37 | |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 38 | /****************************************************************************/ |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 39 | // Install NDN stack on all nodes |
| 40 | ndn::StackHelper ndnHelper; |
Alexander Afanasyev | 25e4d8f | 2019-07-29 13:44:04 -0400 | [diff] [blame] | 41 | ndnHelper.setPolicy("nfd::cs::lru"); |
| 42 | ndnHelper.setCsSize(1000); |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 43 | ndnHelper.InstallAll(); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 44 | /****************************************************************************/ |
| 45 | // Installing global routing interface on all nodes |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 46 | ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; |
| 47 | ndnGlobalRoutingHelper.InstallAll(); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 48 | /****************************************************************************/ |
| 49 | // Getting containers for the consumer/producer |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 50 | Ptr<Node> consumer1 = Names::Find<Node>("Src1"); |
| 51 | Ptr<Node> consumer2 = Names::Find<Node>("Src2"); |
| 52 | Ptr<Node> consumer3 = Names::Find<Node>("Src3"); |
| 53 | Ptr<Node> consumer4 = Names::Find<Node>("Src4"); |
| 54 | Ptr<Node> consumer5 = Names::Find<Node>("Src5"); |
| 55 | Ptr<Node> consumer6 = Names::Find<Node>("Src6"); |
| 56 | Ptr<Node> consumer7 = Names::Find<Node>("Src7"); |
| 57 | Ptr<Node> consumer8 = Names::Find<Node>("Src8"); |
| 58 | Ptr<Node> consumer9 = Names::Find<Node>("Src9"); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 59 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 60 | Ptr<Node> producer1 = Names::Find<Node>("Dst1"); |
| 61 | Ptr<Node> producer2 = Names::Find<Node>("Dst2"); |
| 62 | Ptr<Node> producer3 = Names::Find<Node>("Dst3"); |
| 63 | Ptr<Node> producer4 = Names::Find<Node>("Dst4"); |
| 64 | Ptr<Node> producer5 = Names::Find<Node>("Dst5"); |
| 65 | Ptr<Node> producer6 = Names::Find<Node>("Dst6"); |
| 66 | Ptr<Node> producer7 = Names::Find<Node>("Dst7"); |
| 67 | Ptr<Node> producer8 = Names::Find<Node>("Dst8"); |
| 68 | Ptr<Node> producer9 = Names::Find<Node>("Dst9"); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 69 | /****************************************************************************/ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 70 | ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr"); |
| 71 | consumerHelper.SetAttribute("Frequency", StringValue("1000")); // interests per Second |
| 72 | consumerHelper.SetAttribute("Randomize", StringValue("uniform")); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 73 | /****************************************************************************/ |
| 74 | // on the first to ninth consumer node install a Consumer application |
| 75 | // that will express interests in /dst1 to /dst9 namespace |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 76 | consumerHelper.SetPrefix("/dst9"); |
| 77 | consumerHelper.Install(consumer1); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 78 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 79 | consumerHelper.SetPrefix("/dst8"); |
| 80 | consumerHelper.Install(consumer2); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 81 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 82 | consumerHelper.SetPrefix("/dst7"); |
| 83 | consumerHelper.Install(consumer3); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 84 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 85 | consumerHelper.SetPrefix("/dst6"); |
| 86 | consumerHelper.Install(consumer4); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 87 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 88 | consumerHelper.SetPrefix("/dst5"); |
| 89 | consumerHelper.Install(consumer5); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 90 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 91 | consumerHelper.SetPrefix("/dst4"); |
| 92 | consumerHelper.Install(consumer6); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 93 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 94 | consumerHelper.SetPrefix("/dst3"); |
| 95 | consumerHelper.Install(consumer7); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 96 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 97 | consumerHelper.SetPrefix("/dst2"); |
| 98 | consumerHelper.Install(consumer8); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 99 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 100 | consumerHelper.SetPrefix("/dst1"); |
| 101 | consumerHelper.Install(consumer9); |
| 102 | |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 103 | /****************************************************************************/ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 104 | ndn::AppHelper producerHelper("ns3::ndn::Producer"); |
| 105 | producerHelper.SetAttribute("PayloadSize", StringValue("1024")); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 106 | /****************************************************************************/ |
| 107 | // Register /dst1 to /dst9 prefix with global routing controller and |
| 108 | // install producer that will satisfy Interests in /dst1 to /dst9 namespace |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 109 | ndnGlobalRoutingHelper.AddOrigins("/dst1", producer1); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 110 | producerHelper.SetPrefix("/dst1"); |
| 111 | producerHelper.Install(producer1); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 112 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 113 | ndnGlobalRoutingHelper.AddOrigins("/dst2", producer2); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 114 | producerHelper.SetPrefix("/dst2"); |
| 115 | producerHelper.Install(producer2); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 116 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 117 | ndnGlobalRoutingHelper.AddOrigins("/dst3", producer3); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 118 | producerHelper.SetPrefix("/dst3"); |
| 119 | producerHelper.Install(producer3); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 120 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 121 | ndnGlobalRoutingHelper.AddOrigins("/dst4", producer4); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 122 | producerHelper.SetPrefix("/dst4"); |
| 123 | producerHelper.Install(producer4); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 124 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 125 | ndnGlobalRoutingHelper.AddOrigins("/dst5", producer5); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 126 | producerHelper.SetPrefix("/dst5"); |
| 127 | producerHelper.Install(producer5); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 128 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 129 | ndnGlobalRoutingHelper.AddOrigins("/dst6", producer6); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 130 | producerHelper.SetPrefix("/dst6"); |
| 131 | producerHelper.Install(producer6); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 132 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 133 | ndnGlobalRoutingHelper.AddOrigins("/dst7", producer7); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 134 | producerHelper.SetPrefix("/dst7"); |
| 135 | producerHelper.Install(producer7); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 136 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 137 | ndnGlobalRoutingHelper.AddOrigins("/dst8", producer8); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 138 | producerHelper.SetPrefix("/dst8"); |
| 139 | producerHelper.Install(producer8); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 140 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 141 | ndnGlobalRoutingHelper.AddOrigins("/dst9", producer9); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 142 | producerHelper.SetPrefix("/dst9"); |
| 143 | producerHelper.Install(producer9); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 144 | |
| 145 | /*****************************************************************************/ |
| 146 | // Calculate and install FIBs |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 147 | ndn::GlobalRoutingHelper::CalculateRoutes(); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 148 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 149 | Simulator::Stop(Seconds(10.0)); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 150 | |
| 151 | /****************************************************************************/ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 152 | // Tracer: |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 153 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 154 | L2RateTracer::InstallAll("drop-trace.txt", Seconds(0.5)); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 155 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 156 | Simulator::Run(); |
| 157 | Simulator::Destroy(); |
Hovaidi Ardestani Mohammad | 8682ae0 | 2013-03-12 13:53:15 -0700 | [diff] [blame] | 158 | |
| 159 | return 0; |
| 160 | } |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 161 | |
| 162 | } // namespace ns3 |
| 163 | |
| 164 | int |
| 165 | main(int argc, char* argv[]) |
| 166 | { |
| 167 | return ns3::main(argc, argv); |
| 168 | } |