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