blob: 13b4ddd5c4a77611cc684e5c8c2a3972e821a186 [file] [log] [blame]
Alexander Afanasyev957a84a2013-01-23 10:21:06 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 * Ilya Moiseenko <iliamo@ucla.edu>
20 */
21
22#include "ns3/core-module.h"
23#include "ns3/log.h"
24#include "ns3/ndnSIM-module.h"
25#include "ns3/point-to-point-module.h"
26#include "ns3/random-variable.h"
27
28#include <boost/foreach.hpp>
29
30#include "ns3/ndnSIM/plugins/topology/rocketfuel-map-reader.h"
31
32using namespace ns3;
33using namespace std;
34
35int main (int argc, char**argv)
36{
37 string topology = "";
38 string output_prefix = "";
39 uint32_t run = 0;
40 int clientNodeDegrees = -1;
41 bool buildGraphvizGraph = false;
42 bool keepLargestComponent = false;
43 bool connectBackbones = false;
44
45 CommandLine cmd;
46 cmd.AddValue ("topology", "Topology filename (.ccn)", topology);
47 cmd.AddValue ("output", "Prefix for output files", output_prefix);
48 cmd.AddValue ("run", "Run for ranged parameter randomization", run);
49 cmd.AddValue ("clients", "Maximum degree of client nodes", clientNodeDegrees);
50 cmd.AddValue ("buildGraph", "Whether or not build a graphviz graph (using neato)", buildGraphvizGraph);
51 cmd.AddValue ("keepLargestComponent", "Keep only largest connected component of the network graph", keepLargestComponent);
52 cmd.AddValue ("connectBackbones", "Make sure that ``backbone'' nodes are connected (adding extra links)", connectBackbones);
53 cmd.Parse (argc, argv);
54
55 /**
56 * @todo Make range parameters as command line arguments
57 */
58
59 if (topology == "")
60 {
61 cerr << "ERROR: topology needs to be specified" << endl;
62 cerr << endl;
63
Alexander Afanasyev547e5e62013-11-01 14:31:17 -070064 cmd.PrintHelp (cerr);
Alexander Afanasyev957a84a2013-01-23 10:21:06 -080065 return 1;
66 }
67
68 if (output_prefix == "")
69 {
70 cerr << "ERROR: output needs to be specified" << endl;
71 cerr << endl;
72
Alexander Afanasyev547e5e62013-11-01 14:31:17 -070073 cmd.PrintHelp (cerr);
Alexander Afanasyev957a84a2013-01-23 10:21:06 -080074 return 1;
75 }
76
77 if (run == 0)
78 {
79 cerr << "ERROR: run needs to be specified" << endl;
80 cerr << endl;
81
Alexander Afanasyev547e5e62013-11-01 14:31:17 -070082 cmd.PrintHelp (cerr);
Alexander Afanasyev957a84a2013-01-23 10:21:06 -080083 return 1;
84 }
85
86 if (clientNodeDegrees < 0)
87 {
88 cerr << "ERROR: clients needs to be specified" << endl;
89 cerr << endl;
90
Alexander Afanasyev547e5e62013-11-01 14:31:17 -070091 cmd.PrintHelp (cerr);
Alexander Afanasyev957a84a2013-01-23 10:21:06 -080092 return 1;
93 }
94
95 Config::SetGlobal ("RngRun", IntegerValue (run));
96 GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::VisualSimulatorImpl"));
97
98 string input = topology;
99 string output = output_prefix+"-conv-annotated.txt";
100 string graph = output_prefix+"-conv-annotated.dot";
101 string graph_pdf = output_prefix+"-conv-annotated.pdf";
102
103 RocketfuelParams params;
104 params.clientNodeDegrees = clientNodeDegrees;
105 params.averageRtt = 0.25; // 250ms
106 //parameters for links Backbone<->Backbone
107 params.minb2bBandwidth = "40Mbps";
108 params.minb2bDelay = "5ms";
109
110 params.maxb2bBandwidth = "100Mbps";
111 params.maxb2bDelay = "10ms";
112
113 //parameters for links Backbone<->Gateway and Gateway <-> Gateway
114 params.minb2gBandwidth = "10Mbps";
115 params.minb2gDelay = "5ms";
116
117 params.maxb2gBandwidth = "20Mbps";
118 params.maxb2gDelay = "10ms";
119
120 //parameters for links Gateway <-> Customer
121 params.ming2cBandwidth ="1Mbps";
122 params.ming2cDelay = "70ms";
123
124 params.maxg2cBandwidth ="3Mbps";
125 params.maxg2cDelay = "10ms";
126
127 RocketfuelMapReader topologyReader ("/", 1.0);
128 topologyReader.SetFileName (input);
129 NodeContainer nodes = topologyReader.Read (params, keepLargestComponent, connectBackbones);
130 NodeContainer backboneRouters = topologyReader.GetBackboneRouters();
131 NodeContainer gatewayRouters = topologyReader.GetGatewayRouters();
132 NodeContainer customerRouters = topologyReader.GetCustomerRouters();
133 list<TopologyReader::Link> links = topologyReader.GetLinks();
134
135 topologyReader.SaveGraphviz (graph);
136 if (buildGraphvizGraph)
137 {
Alexander Afanasyev93f13962013-03-07 11:26:38 -0800138 int ret = system (("neato -Tpdf \"" + graph + "\" > \"" + graph_pdf + "\"").c_str ());
139 if (ret != 0)
140 {
141 std::cerr << "WARN: failed to build a graph for the topology. Check if `neato' command is installed (part of graphviz package)" << std::endl;
142 }
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800143 }
144
145 topologyReader.SaveTopology (output);
146
147 // Names::Clear ();
148 // Simulator::Destroy ();
149
150 // // assign weights
151 // AnnotatedTopologyReader topologyReader2 ("", 1.0);
152 // topologyReader2.SetFileName (output);
153 // topologyReader2.Read ();
154
155 // char env[] = "NS_VIS_ASSIGN=1";
156 // putenv (env);
157
158 // Simulator::Stop (Seconds (0.0));
159 // Simulator::Run ();
160
161 // topologyReader2.SaveTopology (output);
162
163 // Simulator::Destroy ();
164 return 0;
165}