Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -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 | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 28 | #include "ns3/animation-interface.h" |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 29 | |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 30 | #include "../helper/ccnx-trace-helper.h" |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 31 | #include "ns3/annotated-topology-reader.h" |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 32 | #include "../utils/spring-mobility-helper.h" |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 33 | |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 34 | #include "ns3/config-store.h" |
| 35 | |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 36 | using namespace ns3; |
| 37 | using namespace std; |
| 38 | |
| 39 | NS_LOG_COMPONENT_DEFINE ("CcnxAbileneTopology"); |
| 40 | |
Ilya Moiseenko | 816de83 | 2011-12-15 16:32:24 -0800 | [diff] [blame] | 41 | |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 42 | void PrintTime () |
| 43 | { |
| 44 | NS_LOG_INFO (Simulator::Now ()); |
| 45 | |
| 46 | Simulator::Schedule (Seconds (10.0), PrintTime); |
| 47 | } |
| 48 | |
| 49 | void PrintFIBs () |
| 50 | { |
| 51 | NS_LOG_INFO ("Outputing FIBs into [fibs.log]"); |
| 52 | Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper> ("fibs.log", std::ios::out); |
| 53 | for (NodeList::Iterator node = NodeList::Begin (); |
| 54 | node != NodeList::End (); |
| 55 | node++) |
| 56 | { |
| 57 | // *routingStream->GetStream () << "Node " << (*node)->GetId () << "\n"; |
| 58 | |
| 59 | Ptr<CcnxFib> fib = (*node)->GetObject<CcnxFib> (); |
| 60 | NS_ASSERT_MSG (fib != 0, "Fire alarm"); |
| 61 | *routingStream->GetStream () << *fib << "\n\n"; |
| 62 | } |
| 63 | } |
| 64 | |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 65 | |
Alexander Afanasyev | f8fd590 | 2011-12-16 16:23:23 -0800 | [diff] [blame] | 66 | |
Alexander Afanasyev | f8fd590 | 2011-12-16 16:23:23 -0800 | [diff] [blame] | 67 | |
Alexander Afanasyev | f8fd590 | 2011-12-16 16:23:23 -0800 | [diff] [blame] | 68 | |
Ilya Moiseenko | 816de83 | 2011-12-15 16:32:24 -0800 | [diff] [blame] | 69 | |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 70 | int |
| 71 | main (int argc, char *argv[]) |
| 72 | { |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 73 | string input ("./src/NDNabstraction/examples/abilene-topology.txt"); |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 74 | |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 75 | Time finishTime = Seconds (20.0); |
| 76 | string animationFile; |
| 77 | string strategy = "ns3::CcnxFloodingStrategy"; |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 78 | CommandLine cmd; |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 79 | cmd.AddValue ("finish", "Finish time", finishTime); |
| 80 | cmd.AddValue ("netanim", "NetAnim filename", animationFile); |
| 81 | cmd.AddValue ("strategy", "CCNx forwarding strategy", strategy); |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 82 | cmd.Parse (argc, argv); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 83 | |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 84 | ConfigStore config; |
| 85 | config.ConfigureDefaults (); |
| 86 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 87 | // ------------------------------------------------------------ |
| 88 | // -- Read topology data. |
| 89 | // -------------------------------------------- |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 90 | |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 91 | AnnotatedTopologyReader reader ("/abilene"); |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 92 | reader.SetMobilityModel ("ns3::SpringMobilityModel"); |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 93 | reader.SetFileName (input); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 94 | |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 95 | NodeContainer nodes = reader.Read (); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 96 | |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 97 | if (reader.LinksSize () == 0) |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 98 | { |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 99 | NS_LOG_ERROR ("Problems reading the topology file. Failing."); |
| 100 | return -1; |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 101 | } |
| 102 | |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 103 | SpringMobilityHelper::InstallSprings (reader.LinksBegin (), reader.LinksEnd ()); |
| 104 | |
Alexander Afanasyev | a174aa5 | 2011-12-13 01:30:32 -0800 | [diff] [blame] | 105 | // InternetStackHelper stack; |
| 106 | // Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingOrderedNexthops"); |
| 107 | // stack.SetRoutingHelper (ipv4RoutingHelper); |
| 108 | // stack.Install (nodes); |
| 109 | |
| 110 | // reader.AssignIpv4Addresses (Ipv4Address ("10.0.0.0")); |
| 111 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 112 | NS_LOG_INFO("Nodes = " << nodes.GetN()); |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 113 | NS_LOG_INFO("Links = " << reader.LinksSize ()); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 114 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 115 | // Install CCNx stack |
| 116 | NS_LOG_INFO ("Installing CCNx stack"); |
| 117 | CcnxStackHelper ccnxHelper; |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 118 | ccnxHelper.SetForwardingStrategy (strategy); |
| 119 | ccnxHelper.EnableLimits (false, Seconds(0.1)); |
| 120 | ccnxHelper.SetDefaultRoutes (true); |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 121 | ccnxHelper.InstallAll (); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 122 | |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 123 | NS_LOG_INFO ("Installing Applications"); |
Alexander Afanasyev | a174aa5 | 2011-12-13 01:30:32 -0800 | [diff] [blame] | 124 | CcnxConsumerHelper consumerHelper ("/5"); |
Alexander Afanasyev | 66e6fd7 | 2011-12-12 21:34:51 -0800 | [diff] [blame] | 125 | ApplicationContainer consumers = consumerHelper.Install (Names::Find<Node> ("/abilene", "ATLAng")); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 126 | |
Alexander Afanasyev | f8fd590 | 2011-12-16 16:23:23 -0800 | [diff] [blame] | 127 | CcnxProducerHelper producerHelper ("/5",1024); |
| 128 | ApplicationContainer producers = producerHelper.Install (Names::Find<Node> ("/abilene", "IPLSng")); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 129 | |
Alexander Afanasyev | a174aa5 | 2011-12-13 01:30:32 -0800 | [diff] [blame] | 130 | // // Populate FIB based on IPv4 global routing controller |
| 131 | // ccnxHelper.InstallFakeGlobalRoutes (); |
| 132 | // ccnxHelper.InstallRouteTo (Names::Find<Node> ("/abilene", "IPLSng")); |
| 133 | |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 134 | // Simulator::Schedule (Seconds (1.0), PrintFIBs); |
Alexander Afanasyev | a174aa5 | 2011-12-13 01:30:32 -0800 | [diff] [blame] | 135 | // PrintFIBs (); |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 136 | |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 137 | // Simulator::Schedule (Seconds (10.0), PrintTime); |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 138 | |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 139 | Simulator::Stop (finishTime); |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 140 | |
| 141 | AnimationInterface *anim = 0; |
| 142 | if (animationFile != "") |
| 143 | { |
| 144 | anim = new AnimationInterface (animationFile); |
| 145 | anim->SetMobilityPollInterval (Seconds (1)); |
| 146 | } |
| 147 | |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 148 | // NS_LOG_INFO ("Configure Tracing."); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 149 | // CcnxAggregateAppTracer consumerTrace ("ns3::CcnxConsumer", "*"); |
| 150 | // CcnxAggregateAppTracer producerTrace ("ns3::CcnxProducer", "*"); |
| 151 | // CcnxAggregateL3Tracer ccnxTrace ("1"); |
| 152 | CcnxTraceHelper traceHelper; |
| 153 | traceHelper.EnableAggregateAppAll ("ns3::CcnxConsumer"); |
| 154 | traceHelper.EnableAggregateAppAll ("ns3::CcnxProducer"); |
| 155 | traceHelper.EnableAggregateL3All (); |
| 156 | traceHelper.SetL3TraceFile ("trace-l3.log"); |
| 157 | traceHelper.SetAppTraceFile ("trace-app.log"); |
| 158 | |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 159 | config.ConfigureAttributes (); |
| 160 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 161 | NS_LOG_INFO ("Run Simulation."); |
| 162 | Simulator::Run (); |
| 163 | Simulator::Destroy (); |
| 164 | NS_LOG_INFO ("Done."); |
Ilya Moiseenko | 816de83 | 2011-12-15 16:32:24 -0800 | [diff] [blame] | 165 | |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 166 | // NS_LOG_INFO ("ConsumerTrace: \n" << consumerTrace); |
| 167 | // NS_LOG_INFO ("ProducerTrace: \n" << producerTrace); |
| 168 | // NS_LOG_INFO ("CcnxTrace: \n" << ccnxTrace); |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 169 | return 0; |
| 170 | } |