5 die "Usage: perl transfrom_optorsim_platform.pl <file.conf>\n";
8 my($conf_file)=$ARGV[0];
10 open FILE, $conf_file or die "Unable to open $conf_file";
12 print "<?xml version='1.0'?>\n";
13 print "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n";
14 print "<platform version=\"3\">\n";
15 print "<AS id=\"AS0\" routing=\"Floyd\">\n";
26 my @links_router = ();
31 my @routes_router = ();
32 my @routes_cluster = ();
34 while(defined($line=<FILE>))
37 if($line =~ /^#(.*)\)(.*)$/)
39 print "<!--$1 $2-->\n";
40 push @list_of_name, $2;
42 elsif($line =~ /^([0-9]*) ([0-9]*) ([0-9]*) (.*)$/)
47 push @routers, "\t\t<router id=\"$list_of_name[$src]\"/>\n";
50 push @routers, "\t\t<router id=\"router$src\"/>\n";
57 push @hosts, "\t<cluster id=\"$list_of_name[$src]\" prefix=\"$list_of_name[$src]-\" suffix=\"\"\n";
58 push @hosts, "\t radical=\"1-$nb_host\" power=\"1000000000\" bw=\"125000000\" lat=\"5E-5\"\n";
59 push @hosts, "\t router_id=\"$list_of_name[$src]-router\"/>\n";
62 push @hosts, "\t<cluster id=\"cluster$src\" prefix=\"$list_of_name[$src]-\" suffix=\"\"\n";
63 push @hosts, "\t radical=\"1-$nb_host\" power=\"1000000000\" bw=\"125000000\" lat=\"5E-5\"\n";
64 push @hosts, "\t router_id=\"cluster$src-router\"/>\n";
68 @tokens = split(/ /,$table);
69 foreach $token (@tokens) {
71 if($token != "0") #if there is a link between src and dst
75 push @links_router, "\t\t<link id=\"link$num_link\" bandwidth=\"$token\"/>\n";
78 push @links, "\t<link id=\"link$num_link\" bandwidth=\"$token\"/>\n";
81 #Create the route between router and router
82 if($is_router[$src] && $is_router[$dst])
85 push @routes_router, "\t\t<route src=\"$list_of_name[$src]\" dst=\"$list_of_name[$dst]\">\n";
88 push @routes_router, "\t\t<route src=\"router$src\" dst=\"router$dst\">\n";
90 push @routes_router, "\t\t\t<link_ctn id=\"link$num_link\"/>\n";
91 push @routes_router, "\t\t</route>\n";
94 #Create the route between cluster and cluster
95 elsif(!$is_router[$src] && !$is_router[$dst])
98 push @routes_cluster, "\t\t<ASroute src=\"$list_of_name[$src]\" dst=\"$list_of_name[$dst]\"\n";
99 push @routes_cluster, "\t\t gw_src=\"$list_of_name[$src]-router\" gw_dst=\"$list_of_name[$dst]-router\">\n";
102 push @routes_cluster, "\t\t<ASroute src=\"cluster$src\" dst=\"cluster$dst\"\n";
103 push @routes_cluster, "\t\t gw_src=\"cluster$src-router\" dst=\"cluster$dst-router\">\n";
105 push @routes_cluster, "\t\t\t<link_ctn id=\"link$num_link\"/>\n";
106 push @routes_cluster, "\t\t</ASroute>\n";
110 push @routes, "\t<ASroute ";
112 if($is_router[$src]) #router
113 {push @routes, "src=\"AS_intern\" gw_src=\"$list_of_name[$src]\"\n";}
115 {push @routes, "src=\"$list_of_name[$src]\" gw_src=\"$list_of_name[$src]-router\"\n";}
118 if($is_router[$dst]) #router
119 {push @routes, "\t\tdst=\"AS_intern\" gw_dst=\"$list_of_name[$dst]\">\n";}
121 {push @routes, "\t\tdst=\"$list_of_name[$dst]\" gw_dst=\"$list_of_name[$dst]-router\">\n";}
124 if($is_router[$src]) #router
125 {push @routes, "src=\"AS_intern\" gw_src=\"router$src\"\n";}
127 {push @routes, "src=\"cluster$src\" gw_src=\"cluster$src-router\"\n";}
130 if($is_router[$dst]) #router
131 {push @routes, "\t\tdst=\"AS_intern\" gw_dst=\"router$dst\">\n";}
133 {push @routes, "\t\tdst=\"cluster$dst\" gw_dst=\"cluster$dst-router\">\n";}
135 push @routes, "\t\t<link_ctn id=\"link$num_link\"/>\n";
136 push @routes, "\t</ASroute>\n";
157 print "\t<AS id=\"AS_intern\" routing=\"Floyd\">\n";
160 print @routes_router;
164 print @routes_cluster;