blob: 3a53c3549b048d624a58d5154a4d657108834e06 [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"
28
29#include <iostream>
30#include <sstream>
Ilya Moiseenko58d26672011-12-08 13:48:06 -080031#include "ns3/rocketfuel-topology-reader.h"
32
Ilya Moiseenko58d26672011-12-08 13:48:06 -080033using namespace ns3;
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -080034using namespace std;
Ilya Moiseenko58d26672011-12-08 13:48:06 -080035
36NS_LOG_COMPONENT_DEFINE ("CcnxSprintTopology");
37
38int
39main (int argc, char *argv[])
40{
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -080041 // Packet::EnableChecking();
42 // Packet::EnablePrinting();
43 string weights ("./src/NDNabstraction/examples/sprint.weights");
44 string latencies ("./src/NDNabstraction/examples/sprint.latencies");
Ilya Moiseenko58d26672011-12-08 13:48:06 -080045
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -080046 Time finishTime = Seconds (2.0);
47 string animationFile;
48 string strategy = "ns3::CcnxFloodingStrategy";
49 CommandLine cmd;
50 cmd.AddValue ("finish", "Finish time", finishTime);
51 cmd.AddValue ("netanim", "NetAnim filename", animationFile);
52 cmd.AddValue ("strategy", "CCNx forwarding strategy", strategy);
53 cmd.AddValue ("weights", "Weights file", weights);
54 cmd.AddValue ("latencies", "Latencies file", latencies);
55 cmd.Parse (argc, argv);
Alexander Afanasyevae3b7c32011-12-13 13:20:06 -080056
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -080057 // ------------------------------------------------------------
58 // -- Read topology data.
59 // --------------------------------------------
Ilya Moiseenko58d26672011-12-08 13:48:06 -080060
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -080061 RocketfuelWeightsReader reader ("/sprint");
62 reader.SetBoundingBox (0, 0, 400, 250);
63
64 reader.SetFileName (weights);
65 reader.SetFileType (RocketfuelWeightsReader::WEIGHTS);
66 NodeContainer nodes = reader.Read ();
67
68 reader.SetFileName (latencies);
69 reader.SetFileType (RocketfuelWeightsReader::LATENCIES);
70 reader.Read ();
71
72 reader.Commit ();
73 if (reader.LinksSize () == 0)
Ilya Moiseenko58d26672011-12-08 13:48:06 -080074 {
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -080075 NS_LOG_ERROR ("Problems reading the topology file. Failing.");
76 return -1;
Ilya Moiseenko58d26672011-12-08 13:48:06 -080077 }
78
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -080079 NS_LOG_INFO("Nodes = " << nodes.GetN());
80 NS_LOG_INFO("Links = " << reader.LinksSize ());
Ilya Moiseenko58d26672011-12-08 13:48:06 -080081
Alexander Afanasyev7dbdcaf2011-12-13 21:40:37 -080082 InternetStackHelper stack;
83 Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingOrderedNexthops");
84 stack.SetRoutingHelper (ipv4RoutingHelper);
85 stack.Install (nodes);
86
87 reader.AssignIpv4Addresses (Ipv4Address ("10.0.0.0"));
88
89 // Install CCNx stack
90 NS_LOG_INFO ("Installing CCNx stack");
91 CcnxStackHelper ccnxHelper;
92 ccnxHelper.SetForwardingStrategy (strategy);
93 ccnxHelper.EnableLimits (false, Seconds(0.1));
94 ccnxHelper.SetDefaultRoutes (true);
95 ccnxHelper.InstallAll ();
96
97 // // Populate FIB based on IPv4 global routing controller
98 // ccnxHelper.InstallFakeGlobalRoutes ();
99 // ccnxHelper.InstallRouteTo (Names::Find<Node> ("/sprint", "San+Jose,+CA4062"));
100
101 // Simulator::Schedule (Seconds (1.0), PrintFIBs);
102 // PrintFIBs ();
103
104 Simulator::Stop (finishTime);
105
106 NS_LOG_INFO ("Run Simulation.");
107 Simulator::Run ();
108 Simulator::Destroy ();
109 NS_LOG_INFO ("Done.");
110 return 0;
Alexander Afanasyev3406f3e2011-12-08 14:11:31 -0800111}