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 | |
Alexander Afanasyev | 011b859 | 2011-12-21 14:45:27 -0800 | [diff] [blame] | 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"; |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 58 | |
Alexander Afanasyev | 011b859 | 2011-12-21 14:45:27 -0800 | [diff] [blame] | 59 | // Ptr<CcnxFib> fib = (*node)->GetObject<CcnxFib> (); |
| 60 | // NS_ASSERT_MSG (fib != 0, "Fire alarm"); |
| 61 | // *routingStream->GetStream () << *fib << "\n\n"; |
| 62 | // } |
| 63 | // } |
Alexander Afanasyev | f8fd590 | 2011-12-16 16:23:23 -0800 | [diff] [blame] | 64 | |
Ilya Moiseenko | 816de83 | 2011-12-15 16:32:24 -0800 | [diff] [blame] | 65 | |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 66 | int |
| 67 | main (int argc, char *argv[]) |
| 68 | { |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 69 | string input ("./src/NDNabstraction/examples/abilene-topology.txt"); |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 70 | |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 71 | Time finishTime = Seconds (20.0); |
| 72 | string animationFile; |
| 73 | string strategy = "ns3::CcnxFloodingStrategy"; |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 74 | CommandLine cmd; |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 75 | cmd.AddValue ("finish", "Finish time", finishTime); |
| 76 | cmd.AddValue ("netanim", "NetAnim filename", animationFile); |
| 77 | cmd.AddValue ("strategy", "CCNx forwarding strategy", strategy); |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 78 | cmd.Parse (argc, argv); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 79 | |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 80 | ConfigStore config; |
| 81 | config.ConfigureDefaults (); |
| 82 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 83 | // ------------------------------------------------------------ |
| 84 | // -- Read topology data. |
| 85 | // -------------------------------------------- |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 86 | |
Alexander Afanasyev | 011b859 | 2011-12-21 14:45:27 -0800 | [diff] [blame] | 87 | AnnotatedTopologyReader reader ("/abilene", 2.0); |
| 88 | // reader.SetMobilityModel ("ns3::SpringMobilityModel"); |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 89 | reader.SetFileName (input); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 90 | |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 91 | NodeContainer nodes = reader.Read (); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 92 | |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 93 | if (reader.LinksSize () == 0) |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 94 | { |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 95 | NS_LOG_ERROR ("Problems reading the topology file. Failing."); |
| 96 | return -1; |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 97 | } |
| 98 | |
Alexander Afanasyev | 011b859 | 2011-12-21 14:45:27 -0800 | [diff] [blame] | 99 | // SpringMobilityHelper::InstallSprings (reader.LinksBegin (), reader.LinksEnd ()); |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 100 | |
Alexander Afanasyev | a174aa5 | 2011-12-13 01:30:32 -0800 | [diff] [blame] | 101 | // InternetStackHelper stack; |
| 102 | // Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingOrderedNexthops"); |
| 103 | // stack.SetRoutingHelper (ipv4RoutingHelper); |
| 104 | // stack.Install (nodes); |
| 105 | |
| 106 | // reader.AssignIpv4Addresses (Ipv4Address ("10.0.0.0")); |
| 107 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 108 | NS_LOG_INFO("Nodes = " << nodes.GetN()); |
Alexander Afanasyev | 8633d5d | 2011-12-12 18:02:31 -0800 | [diff] [blame] | 109 | NS_LOG_INFO("Links = " << reader.LinksSize ()); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 110 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 111 | // Install CCNx stack |
| 112 | NS_LOG_INFO ("Installing CCNx stack"); |
| 113 | CcnxStackHelper ccnxHelper; |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 114 | ccnxHelper.SetForwardingStrategy (strategy); |
| 115 | ccnxHelper.EnableLimits (false, Seconds(0.1)); |
| 116 | ccnxHelper.SetDefaultRoutes (true); |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 117 | ccnxHelper.InstallAll (); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 118 | |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 119 | NS_LOG_INFO ("Installing Applications"); |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 120 | CcnxAppHelper consumerHelper ("ns3::CcnxConsumer"); |
Alexander Afanasyev | 011b859 | 2011-12-21 14:45:27 -0800 | [diff] [blame] | 121 | consumerHelper.SetPrefix ("/Data"); |
| 122 | consumerHelper.SetAttribute ("MeanRate", StringValue ("1Mbps")); |
| 123 | ApplicationContainer consumers = consumerHelper.Install (Names::Find<Node> ("/abilene", "SNVAng")); |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 124 | |
| 125 | CcnxAppHelper producerHelper ("ns3::CcnxProducer"); |
Alexander Afanasyev | 011b859 | 2011-12-21 14:45:27 -0800 | [diff] [blame] | 126 | producerHelper.SetPrefix ("/Data"); |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 127 | |
Alexander Afanasyev | 011b859 | 2011-12-21 14:45:27 -0800 | [diff] [blame] | 128 | ApplicationContainer producers = producerHelper.Install (Names::Find<Node> ("/abilene", "NYCMng")); |
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 | 011b859 | 2011-12-21 14:45:27 -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 | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 148 | CcnxTraceHelper traceHelper; |
| 149 | traceHelper.EnableAggregateAppAll ("ns3::CcnxConsumer"); |
| 150 | traceHelper.EnableAggregateAppAll ("ns3::CcnxProducer"); |
| 151 | traceHelper.EnableAggregateL3All (); |
| 152 | traceHelper.SetL3TraceFile ("trace-l3.log"); |
| 153 | traceHelper.SetAppTraceFile ("trace-app.log"); |
| 154 | |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 155 | config.ConfigureAttributes (); |
| 156 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 157 | NS_LOG_INFO ("Run Simulation."); |
| 158 | Simulator::Run (); |
| 159 | Simulator::Destroy (); |
| 160 | NS_LOG_INFO ("Done."); |
Ilya Moiseenko | 816de83 | 2011-12-15 16:32:24 -0800 | [diff] [blame] | 161 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame] | 162 | return 0; |
| 163 | } |