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.
13 die "Usage: perl transfrom_optorsim_platform.pl <file.conf>\n";
16 my($conf_file)=$ARGV[0];
18 open FILE, $conf_file or die "Unable to open $conf_file";
20 print "<?xml version='1.0'?>\n";
21 print "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n";
22 print "<platform version=\"3\">\n";
23 print "<AS id=\"AS0\" routing=\"Floyd\">\n";
34 my @links_router = ();
39 my @routes_router = ();
40 my @routes_cluster = ();
42 while(defined($line=<FILE>))
45 if($line =~ /^#(.*)\)(.*)$/)
47 print "<!--$1 $2-->\n";
48 push @list_of_name, $2;
50 elsif($line =~ /^([0-9]*) ([0-9]*) ([0-9]*) (.*)$/)
55 push @routers, "\t\t<router id=\"$list_of_name[$src]\"/>\n";
58 push @routers, "\t\t<router id=\"router$src\"/>\n";
65 push @hosts, "\t<cluster id=\"$list_of_name[$src]\" prefix=\"$list_of_name[$src]-\" suffix=\"\"\n";
66 push @hosts, "\t radical=\"1-$nb_host\" power=\"1000000000\" bw=\"125000000\" lat=\"5E-5\"\n";
67 push @hosts, "\t router_id=\"$list_of_name[$src]-router\"/>\n";
70 push @hosts, "\t<cluster id=\"cluster$src\" prefix=\"$list_of_name[$src]-\" suffix=\"\"\n";
71 push @hosts, "\t radical=\"1-$nb_host\" power=\"1000000000\" bw=\"125000000\" lat=\"5E-5\"\n";
72 push @hosts, "\t router_id=\"cluster$src-router\"/>\n";
76 @tokens = split(/ /,$table);
77 foreach $token (@tokens) {
79 if($token != "0") #if there is a link between src and dst
83 push @links_router, "\t\t<link id=\"link$num_link\" bandwidth=\"$token\"/>\n";
86 push @links, "\t<link id=\"link$num_link\" bandwidth=\"$token\"/>\n";
89 #Create the route between router and router
90 if($is_router[$src] && $is_router[$dst])
93 push @routes_router, "\t\t<route src=\"$list_of_name[$src]\" dst=\"$list_of_name[$dst]\">\n";
96 push @routes_router, "\t\t<route src=\"router$src\" dst=\"router$dst\">\n";
98 push @routes_router, "\t\t\t<link_ctn id=\"link$num_link\"/>\n";
99 push @routes_router, "\t\t</route>\n";
102 #Create the route between cluster and cluster
103 elsif(!$is_router[$src] && !$is_router[$dst])
106 push @routes_cluster, "\t\t<ASroute src=\"$list_of_name[$src]\" dst=\"$list_of_name[$dst]\"\n";
107 push @routes_cluster, "\t\t gw_src=\"$list_of_name[$src]-router\" gw_dst=\"$list_of_name[$dst]-router\">\n";
110 push @routes_cluster, "\t\t<ASroute src=\"cluster$src\" dst=\"cluster$dst\"\n";
111 push @routes_cluster, "\t\t gw_src=\"cluster$src-router\" dst=\"cluster$dst-router\">\n";
113 push @routes_cluster, "\t\t\t<link_ctn id=\"link$num_link\"/>\n";
114 push @routes_cluster, "\t\t</ASroute>\n";
118 push @routes, "\t<ASroute ";
120 if($is_router[$src]) #router
121 {push @routes, "src=\"AS_intern\" gw_src=\"$list_of_name[$src]\"\n";}
123 {push @routes, "src=\"$list_of_name[$src]\" gw_src=\"$list_of_name[$src]-router\"\n";}
126 if($is_router[$dst]) #router
127 {push @routes, "\t\tdst=\"AS_intern\" gw_dst=\"$list_of_name[$dst]\">\n";}
129 {push @routes, "\t\tdst=\"$list_of_name[$dst]\" gw_dst=\"$list_of_name[$dst]-router\">\n";}
132 if($is_router[$src]) #router
133 {push @routes, "src=\"AS_intern\" gw_src=\"router$src\"\n";}
135 {push @routes, "src=\"cluster$src\" gw_src=\"cluster$src-router\"\n";}
138 if($is_router[$dst]) #router
139 {push @routes, "\t\tdst=\"AS_intern\" gw_dst=\"router$dst\">\n";}
141 {push @routes, "\t\tdst=\"cluster$dst\" gw_dst=\"cluster$dst-router\">\n";}
143 push @routes, "\t\t<link_ctn id=\"link$num_link\"/>\n";
144 push @routes, "\t</ASroute>\n";
165 print "\t<AS id=\"AS_intern\" routing=\"Floyd\">\n";
168 print @routes_router;
172 print @routes_cluster;