Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Ilya Moiseenko <iliamo@cs.ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | |
| 22 | #include "ns3/core-module.h" |
| 23 | #include "ns3/network-module.h" |
| 24 | #include "ns3/point-to-point-module.h" |
| 25 | #include "ns3/NDNabstraction-module.h" |
| 26 | #include "ns3/point-to-point-grid.h" |
| 27 | #include "ns3/ipv4-global-routing-helper.h" |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 28 | #include "../utils/spring-mobility-helper.h" |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame] | 29 | #include "../helper/ccnx-trace-helper.h" |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 30 | |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 31 | #include <sstream> |
| 32 | #include "ns3/annotated-topology-reader.h" |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 33 | |
| 34 | #include "ns3/config-store.h" |
| 35 | |
| 36 | using namespace ns3; |
| 37 | using namespace std; |
| 38 | |
| 39 | NS_LOG_COMPONENT_DEFINE ("CcnxSyntheticTopology"); |
| 40 | |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 41 | void PrintTime () |
| 42 | { |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 43 | NS_LOG_INFO (Simulator::Now ()); |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 44 | |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 45 | Simulator::Schedule (Seconds (10.0), PrintTime); |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 46 | } |
| 47 | |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 48 | int |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 49 | main (int argc, char *argv[]) |
| 50 | { |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 51 | string input ("./src/NDNabstraction/examples/synthetic-topology.txt"); |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 52 | |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 53 | Time finishTime = Seconds (20.0); |
| 54 | string strategy = "ns3::CcnxFloodingStrategy"; |
| 55 | CommandLine cmd; |
| 56 | cmd.AddValue ("finish", "Finish time", finishTime); |
| 57 | cmd.AddValue ("strategy", "CCNx forwarding strategy", strategy); |
| 58 | cmd.Parse (argc, argv); |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 59 | |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 60 | ConfigStore config; |
| 61 | config.ConfigureDefaults (); |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 62 | |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 63 | // ------------------------------------------------------------ |
| 64 | // -- Read topology data. |
| 65 | // -------------------------------------------- |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 66 | |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 67 | AnnotatedTopologyReader reader ("/synthetic"); |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 68 | // reader.SetMobilityModel ("ns3::SpringMobilityModel"); |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 69 | reader.SetFileName (input); |
| 70 | NodeContainer nodes = reader.Read (); |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 71 | // SpringMobilityHelper::InstallSprings (reader.LinksBegin (), reader.LinksEnd ()); |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 72 | |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 73 | InternetStackHelper stack; |
| 74 | Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingOrderedNexthops"); |
| 75 | stack.SetRoutingHelper (ipv4RoutingHelper); |
| 76 | stack.Install (nodes); |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 77 | |
| 78 | reader.AssignIpv4Addresses (Ipv4Address ("10.0.0.0")); |
| 79 | |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 80 | NS_LOG_INFO("Nodes = " << nodes.GetN()); |
| 81 | NS_LOG_INFO("Links = " << reader.LinksSize ()); |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 82 | |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 83 | // Install CCNx stack |
| 84 | NS_LOG_INFO ("Installing CCNx stack"); |
| 85 | CcnxStackHelper ccnxHelper; |
| 86 | ccnxHelper.SetForwardingStrategy (strategy); |
| 87 | ccnxHelper.EnableLimits (true, Seconds(0.1)); |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 88 | ccnxHelper.SetDefaultRoutes (false); |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 89 | ccnxHelper.InstallAll (); |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 90 | |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 91 | NS_LOG_INFO ("Installing Applications"); |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 92 | CcnxAppHelper consumerHelper ("ns3::CcnxConsumer"); |
| 93 | |
| 94 | consumerHelper.SetPrefix ("/6"); |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 95 | consumerHelper.SetAttribute ("MeanRate", StringValue ("2Mbps")); |
Alexander Afanasyev | 3183b5a | 2011-12-23 20:48:20 -0800 | [diff] [blame] | 96 | consumerHelper.SetAttribute ("Size", StringValue ("1.0")); |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 97 | ApplicationContainer consumers = consumerHelper.Install (Names::Find<Node> ("/synthetic", "c1")); |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 98 | |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 99 | consumerHelper.SetPrefix ("/7"); |
Alexander Afanasyev | 011b859 | 2011-12-21 14:45:27 -0800 | [diff] [blame] | 100 | consumerHelper.SetAttribute ("MeanRate", StringValue ("2Mbps")); |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 101 | ApplicationContainer consumers2 = consumerHelper.Install(Names::Find<Node> ("/synthetic", "c2")); |
| 102 | |
| 103 | consumerHelper.SetPrefix ("/8"); |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 104 | consumerHelper.SetAttribute ("MeanRate", StringValue ("2Mbps")); |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 105 | ApplicationContainer consumers3 = consumerHelper.Install(Names::Find<Node> ("/synthetic", "c3")); |
| 106 | |
| 107 | consumerHelper.SetPrefix ("/10"); |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 108 | consumerHelper.SetAttribute ("MeanRate", StringValue ("2Mbps")); |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 109 | ApplicationContainer consumers4 = consumerHelper.Install(Names::Find<Node> ("/synthetic", "c4")); |
| 110 | |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 111 | consumers.Start (Seconds (0)); |
Alexander Afanasyev | 3183b5a | 2011-12-23 20:48:20 -0800 | [diff] [blame] | 112 | consumers2.Start (Seconds (2.5)); |
| 113 | consumers3.Start (Seconds (5)); |
| 114 | consumers4.Start (Seconds (7.5)); |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 115 | |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 116 | ///////////////////////////////////////////// |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 117 | |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 118 | CcnxAppHelper producerHelper ("ns3::CcnxProducer"); |
| 119 | producerHelper.SetAttribute ("PayloadSize", StringValue("1024")); |
| 120 | |
| 121 | producerHelper.SetPrefix ("/6"); |
| 122 | producerHelper.Install (Names::Find<Node> ("/synthetic", "p1")); |
| 123 | |
| 124 | producerHelper.SetPrefix ("/7"); |
| 125 | producerHelper.Install (Names::Find<Node> ("/synthetic", "p2")); |
| 126 | |
| 127 | producerHelper.SetPrefix ("/8"); |
| 128 | producerHelper.Install (Names::Find<Node> ("/synthetic", "p3")); |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 129 | |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 130 | producerHelper.SetPrefix ("/10"); |
| 131 | producerHelper.Install (Names::Find<Node> ("/synthetic", "p4")); |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 132 | |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 133 | // Populate FIB based on IPv4 global routing controller |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 134 | ccnxHelper.InstallFakeGlobalRoutes (); |
| 135 | ccnxHelper.InstallRouteTo (Names::Find<Node> ("/synthetic", "p1")); |
| 136 | ccnxHelper.InstallRouteTo (Names::Find<Node> ("/synthetic", "p2")); |
| 137 | ccnxHelper.InstallRouteTo (Names::Find<Node> ("/synthetic", "p3")); |
| 138 | ccnxHelper.InstallRouteTo (Names::Find<Node> ("/synthetic", "p4")); |
| 139 | |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 140 | Simulator::Schedule (Seconds (10.0), PrintTime); |
| 141 | |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 142 | Simulator::Stop (finishTime); |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 143 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame] | 144 | CcnxTraceHelper traceHelper; |
| 145 | // traceHelper.EnableAggregateAppAll ("ns3::CcnxConsumer"); |
| 146 | // traceHelper.EnableAggregateAppAll ("ns3::CcnxProducer"); |
| 147 | // traceHelper.EnableAggregateL3All (); |
| 148 | // traceHelper.SetL3TraceFile ("trace-l3.log"); |
| 149 | // traceHelper.SetAppTraceFile ("trace-app.log"); |
Alexander Afanasyev | 3183b5a | 2011-12-23 20:48:20 -0800 | [diff] [blame] | 150 | // traceHelper.EnableRateL3All ("rate-trace.log"); |
| 151 | traceHelper.EnableSeqsAppAll ("ns3::CcnxConsumer", "consumers-seqs.log"); |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame] | 152 | |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 153 | NS_LOG_INFO ("Run Simulation."); |
| 154 | Simulator::Run (); |
| 155 | Simulator::Destroy (); |
| 156 | NS_LOG_INFO ("Done."); |
| 157 | |
| 158 | return 0; |
Ilya Moiseenko | 6f5e8fa | 2011-12-16 15:20:19 -0800 | [diff] [blame] | 159 | } |