blob: d9fa17e86e18d23a71ec4292c801f7fcb1cd0d5d [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
64 cerr << cmd;
65 return 1;
66 }
67
68 if (output_prefix == "")
69 {
70 cerr << "ERROR: output needs to be specified" << endl;
71 cerr << endl;
72
73 cerr << cmd;
74 return 1;
75 }
76
77 if (run == 0)
78 {
79 cerr << "ERROR: run needs to be specified" << endl;
80 cerr << endl;
81
82 cerr << cmd;
83 return 1;
84 }
85
86 if (clientNodeDegrees < 0)
87 {
88 cerr << "ERROR: clients needs to be specified" << endl;
89 cerr << endl;
90
91 cerr << cmd;
92 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 {
138 system (("neato -Tpdf \"" + graph + "\" > \"" + graph_pdf + "\"").c_str ());
139 }
140
141 topologyReader.SaveTopology (output);
142
143 // Names::Clear ();
144 // Simulator::Destroy ();
145
146 // // assign weights
147 // AnnotatedTopologyReader topologyReader2 ("", 1.0);
148 // topologyReader2.SetFileName (output);
149 // topologyReader2.Read ();
150
151 // char env[] = "NS_VIS_ASSIGN=1";
152 // putenv (env);
153
154 // Simulator::Stop (Seconds (0.0));
155 // Simulator::Run ();
156
157 // topologyReader2.SaveTopology (output);
158
159 // Simulator::Destroy ();
160 return 0;
161}