3 # Copyright (c) 2011, 2014. The SimGrid Team.
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the license (GNU LGPL) which comes with this package.
12 die "Usage: perl transfrom_optorsim_platform.pl <file.conf>\n";
15 my($conf_file)=$ARGV[0];
17 open FILE, $conf_file or die "Unable to open $conf_file";
19 print "<?xml version='1.0'?>\n";
20 print "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n";
21 print "<platform version=\"3\">\n";
22 print "<AS id=\"AS0\" routing=\"Floyd\">\n";
33 my @links_router = ();
38 my @routes_router = ();
39 my @routes_cluster = ();
41 while(defined($line=<FILE>))
44 if($line =~ /^#(.*)\)(.*)$/)
46 print "<!--$1 $2-->\n";
47 push @list_of_name, $2;
49 elsif($line =~ /^([0-9]*) ([0-9]*) ([0-9]*) (.*)$/)
54 push @routers, "\t\t<router id=\"$list_of_name[$src]\"/>\n";
57 push @routers, "\t\t<router id=\"router$src\"/>\n";
64 push @hosts, "\t<cluster id=\"$list_of_name[$src]\" prefix=\"$list_of_name[$src]-\" suffix=\"\"\n";
65 push @hosts, "\t radical=\"1-$nb_host\" power=\"1000000000\" bw=\"125000000\" lat=\"5E-5\"\n";
66 push @hosts, "\t router_id=\"$list_of_name[$src]-router\"/>\n";
69 push @hosts, "\t<cluster id=\"cluster$src\" prefix=\"$list_of_name[$src]-\" suffix=\"\"\n";
70 push @hosts, "\t radical=\"1-$nb_host\" power=\"1000000000\" bw=\"125000000\" lat=\"5E-5\"\n";
71 push @hosts, "\t router_id=\"cluster$src-router\"/>\n";
75 @tokens = split(/ /,$table);
76 foreach $token (@tokens) {
78 if($token != "0") #if there is a link between src and dst
82 push @links_router, "\t\t<link id=\"link$num_link\" bandwidth=\"$token\"/>\n";
85 push @links, "\t<link id=\"link$num_link\" bandwidth=\"$token\"/>\n";
88 #Create the route between router and router
89 if($is_router[$src] && $is_router[$dst])
92 push @routes_router, "\t\t<route src=\"$list_of_name[$src]\" dst=\"$list_of_name[$dst]\">\n";
95 push @routes_router, "\t\t<route src=\"router$src\" dst=\"router$dst\">\n";
97 push @routes_router, "\t\t\t<link_ctn id=\"link$num_link\"/>\n";
98 push @routes_router, "\t\t</route>\n";
101 #Create the route between cluster and cluster
102 elsif(!$is_router[$src] && !$is_router[$dst])
105 push @routes_cluster, "\t\t<ASroute src=\"$list_of_name[$src]\" dst=\"$list_of_name[$dst]\"\n";
106 push @routes_cluster, "\t\t gw_src=\"$list_of_name[$src]-router\" gw_dst=\"$list_of_name[$dst]-router\">\n";
109 push @routes_cluster, "\t\t<ASroute src=\"cluster$src\" dst=\"cluster$dst\"\n";
110 push @routes_cluster, "\t\t gw_src=\"cluster$src-router\" dst=\"cluster$dst-router\">\n";
112 push @routes_cluster, "\t\t\t<link_ctn id=\"link$num_link\"/>\n";
113 push @routes_cluster, "\t\t</ASroute>\n";
117 push @routes, "\t<ASroute ";
119 if($is_router[$src]) #router
120 {push @routes, "src=\"AS_intern\" gw_src=\"$list_of_name[$src]\"\n";}
122 {push @routes, "src=\"$list_of_name[$src]\" gw_src=\"$list_of_name[$src]-router\"\n";}
125 if($is_router[$dst]) #router
126 {push @routes, "\t\tdst=\"AS_intern\" gw_dst=\"$list_of_name[$dst]\">\n";}
128 {push @routes, "\t\tdst=\"$list_of_name[$dst]\" gw_dst=\"$list_of_name[$dst]-router\">\n";}
131 if($is_router[$src]) #router
132 {push @routes, "src=\"AS_intern\" gw_src=\"router$src\"\n";}
134 {push @routes, "src=\"cluster$src\" gw_src=\"cluster$src-router\"\n";}
137 if($is_router[$dst]) #router
138 {push @routes, "\t\tdst=\"AS_intern\" gw_dst=\"router$dst\">\n";}
140 {push @routes, "\t\tdst=\"cluster$dst\" gw_dst=\"cluster$dst-router\">\n";}
142 push @routes, "\t\t<link_ctn id=\"link$num_link\"/>\n";
143 push @routes, "\t</ASroute>\n";
164 print "\t<AS id=\"AS_intern\" routing=\"Floyd\">\n";
167 print @routes_router;
171 print @routes_cluster;