blob: ff7f52d05ae463a330931e8fead168fcec56cffc [file] [log] [blame]
Ilya Moiseenko58d26672011-12-08 13:48:06 -08001/* -*- 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 Afanasyev4a5c2c12011-12-12 18:50:57 -080028#include "ns3/animation-interface.h"
Ilya Moiseenko58d26672011-12-08 13:48:06 -080029
Alexander Afanasyev141d1312011-12-18 14:58:35 -080030#include "../helper/ccnx-trace-helper.h"
Ilya Moiseenko58d26672011-12-08 13:48:06 -080031#include "ns3/annotated-topology-reader.h"
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -080032#include "../utils/spring-mobility-helper.h"
Ilya Moiseenko58d26672011-12-08 13:48:06 -080033
Alexander Afanasyevbdc0d982011-12-16 01:15:26 -080034#include "ns3/config-store.h"
35
Ilya Moiseenko58d26672011-12-08 13:48:06 -080036using namespace ns3;
37using namespace std;
38
39NS_LOG_COMPONENT_DEFINE ("CcnxAbileneTopology");
40
Ilya Moiseenko816de832011-12-15 16:32:24 -080041
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -080042void PrintTime ()
43{
44 NS_LOG_INFO (Simulator::Now ());
45
46 Simulator::Schedule (Seconds (10.0), PrintTime);
47}
48
Alexander Afanasyev011b8592011-12-21 14:45:27 -080049// 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 Afanasyev4a5c2c12011-12-12 18:50:57 -080058
Alexander Afanasyev011b8592011-12-21 14:45:27 -080059// Ptr<CcnxFib> fib = (*node)->GetObject<CcnxFib> ();
60// NS_ASSERT_MSG (fib != 0, "Fire alarm");
61// *routingStream->GetStream () << *fib << "\n\n";
62// }
63// }
Alexander Afanasyevf8fd5902011-12-16 16:23:23 -080064
Ilya Moiseenko816de832011-12-15 16:32:24 -080065
Ilya Moiseenko58d26672011-12-08 13:48:06 -080066int
67main (int argc, char *argv[])
68{
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080069 string input ("./src/NDNabstraction/examples/abilene-topology.txt");
Alexander Afanasyevbdc0d982011-12-16 01:15:26 -080070
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080071 Time finishTime = Seconds (20.0);
72 string animationFile;
73 string strategy = "ns3::CcnxFloodingStrategy";
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080074 CommandLine cmd;
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080075 cmd.AddValue ("finish", "Finish time", finishTime);
76 cmd.AddValue ("netanim", "NetAnim filename", animationFile);
77 cmd.AddValue ("strategy", "CCNx forwarding strategy", strategy);
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080078 cmd.Parse (argc, argv);
Ilya Moiseenko58d26672011-12-08 13:48:06 -080079
Alexander Afanasyevbdc0d982011-12-16 01:15:26 -080080 ConfigStore config;
81 config.ConfigureDefaults ();
82
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080083 // ------------------------------------------------------------
84 // -- Read topology data.
85 // --------------------------------------------
Ilya Moiseenko58d26672011-12-08 13:48:06 -080086
Alexander Afanasyev011b8592011-12-21 14:45:27 -080087 AnnotatedTopologyReader reader ("/abilene", 2.0);
88 // reader.SetMobilityModel ("ns3::SpringMobilityModel");
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080089 reader.SetFileName (input);
Ilya Moiseenko58d26672011-12-08 13:48:06 -080090
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080091 NodeContainer nodes = reader.Read ();
Ilya Moiseenko58d26672011-12-08 13:48:06 -080092
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -080093 if (reader.LinksSize () == 0)
Ilya Moiseenko58d26672011-12-08 13:48:06 -080094 {
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -080095 NS_LOG_ERROR ("Problems reading the topology file. Failing.");
96 return -1;
Ilya Moiseenko58d26672011-12-08 13:48:06 -080097 }
98
Alexander Afanasyev011b8592011-12-21 14:45:27 -080099 // SpringMobilityHelper::InstallSprings (reader.LinksBegin (), reader.LinksEnd ());
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -0800100
Alexander Afanasyeva174aa52011-12-13 01:30:32 -0800101 // 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 Afanasyev3406f3e2011-12-08 14:11:31 -0800108 NS_LOG_INFO("Nodes = " << nodes.GetN());
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -0800109 NS_LOG_INFO("Links = " << reader.LinksSize ());
Ilya Moiseenko58d26672011-12-08 13:48:06 -0800110
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -0800111 // Install CCNx stack
112 NS_LOG_INFO ("Installing CCNx stack");
113 CcnxStackHelper ccnxHelper;
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800114 ccnxHelper.SetForwardingStrategy (strategy);
115 ccnxHelper.EnableLimits (false, Seconds(0.1));
116 ccnxHelper.SetDefaultRoutes (true);
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -0800117 ccnxHelper.InstallAll ();
Ilya Moiseenko58d26672011-12-08 13:48:06 -0800118
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800119 NS_LOG_INFO ("Installing Applications");
Alexander Afanasyeve1a065d2012-01-10 15:55:14 -0800120 CcnxAppHelper consumerHelper ("ns3::CcnxConsumerCbr");
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800121 consumerHelper.SetPrefix ("/Data");
122 consumerHelper.SetAttribute ("MeanRate", StringValue ("1Mbps"));
123 ApplicationContainer consumers = consumerHelper.Install (Names::Find<Node> ("/abilene", "SNVAng"));
Alexander Afanasyev4975f732011-12-20 17:52:19 -0800124
125 CcnxAppHelper producerHelper ("ns3::CcnxProducer");
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800126 producerHelper.SetPrefix ("/Data");
Alexander Afanasyev4975f732011-12-20 17:52:19 -0800127
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800128 ApplicationContainer producers = producerHelper.Install (Names::Find<Node> ("/abilene", "NYCMng"));
Ilya Moiseenko58d26672011-12-08 13:48:06 -0800129
Alexander Afanasyeva174aa52011-12-13 01:30:32 -0800130 // // Populate FIB based on IPv4 global routing controller
131 // ccnxHelper.InstallFakeGlobalRoutes ();
132 // ccnxHelper.InstallRouteTo (Names::Find<Node> ("/abilene", "IPLSng"));
133
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800134 // Simulator::Schedule (Seconds (1.0), PrintFIBs);
Alexander Afanasyeva174aa52011-12-13 01:30:32 -0800135 // PrintFIBs ();
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800136
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800137 Simulator::Schedule (Seconds (10.0), PrintTime);
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800138
Alexander Afanasyev8633d5d2011-12-12 18:02:31 -0800139 Simulator::Stop (finishTime);
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800140
141 AnimationInterface *anim = 0;
142 if (animationFile != "")
143 {
144 anim = new AnimationInterface (animationFile);
145 anim->SetMobilityPollInterval (Seconds (1));
146 }
147
Alexander Afanasyev141d1312011-12-18 14:58:35 -0800148 CcnxTraceHelper traceHelper;
Alexander Afanasyeve1a065d2012-01-10 15:55:14 -0800149 traceHelper.EnableAggregateAppAll ("ns3::CcnxConsumerCbr");
Alexander Afanasyev141d1312011-12-18 14:58:35 -0800150 traceHelper.EnableAggregateAppAll ("ns3::CcnxProducer");
151 traceHelper.EnableAggregateL3All ();
152 traceHelper.SetL3TraceFile ("trace-l3.log");
153 traceHelper.SetAppTraceFile ("trace-app.log");
154
Alexander Afanasyevbdc0d982011-12-16 01:15:26 -0800155 config.ConfigureAttributes ();
156
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -0800157 NS_LOG_INFO ("Run Simulation.");
158 Simulator::Run ();
159 Simulator::Destroy ();
160 NS_LOG_INFO ("Done.");
Ilya Moiseenko816de832011-12-15 16:32:24 -0800161
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -0800162 return 0;
163}