3 # Copyright (c) 2011-2023. 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 "<!-- This platform was automatically converted from the OptorSim platform.\n";
22 print " OptorSim files only describes information of the cluster interconnection.\n";
23 print " In a sense, it reflects the topology of a National Research and Education\n";
24 print " Network (NREN), but not of a full-fledged computational platform.\n";
25 print " The caracteristics of each cluster have been artificially added.\n";
27 print " We hope that you find it useful anyway. If you know how to complete\n";
28 print " this information with data on the cluster configurations, please\n";
29 print " drop us a mail so that we can add this information. -->\n\n";
31 print "<?xml version='1.0'?>\n";
32 print "<!DOCTYPE platform SYSTEM \"https://simgrid.org/simgrid.dtd\">\n";
33 print "<platform version=\"3\">\n";
34 print "<AS id=\"AS0\" routing=\"Floyd\">\n";
45 my @links_router = ();
50 my @routes_router = ();
51 my @routes_cluster = ();
53 while(defined($line=<FILE>)){
54 if($line =~ /^#(.*)\)(.*)$/)
56 print "<!--$1 $2-->\n";
57 push @list_of_name, $2;
59 elsif($line =~ /^([0-9]*) ([0-9]*) ([0-9]*) (.*)$/)
64 push @routers, " <router id=\"$list_of_name[$src]\"/>\n";
67 push @routers, " <router id=\"router$src\"/>\n";
74 push @hosts, " <cluster id=\"$list_of_name[$src]\" prefix=\"$list_of_name[$src]-\" suffix=\"\"\n";
75 push @hosts, " radical=\"1-$nb_host\" power=\"1000000000\" bw=\"125000000\" lat=\"5E-5\"\n";
76 push @hosts, " router_id=\"$list_of_name[$src]-router\"/>\n";
79 push @hosts, " <cluster id=\"cluster$src\" prefix=\"$src-\" suffix=\"\"\n";
80 push @hosts, " radical=\"1-$nb_host\" power=\"1000000000\" bw=\"125000000\" lat=\"5E-5\"\n";
81 push @hosts, " router_id=\"cluster$src-router\"/>\n";
85 @tokens = split(/ /,$table);
86 foreach $token (@tokens) {
88 if($token != "0") #if there is a link between src and dst
92 push @links_router, " <link id=\"link$num_link\" bandwidth=\"$token\"/>\n";
95 push @links, " <link id=\"link$num_link\" bandwidth=\"$token\"/>\n";
98 #Create the route between router and router
99 if($is_router[$src] && $is_router[$dst])
102 push @routes_router, " <route src=\"$list_of_name[$src]\" dst=\"$list_of_name[$dst]\">";
105 push @routes_router, " <route src=\"router$src\" dst=\"router$dst\">";
107 push @routes_router, " <link_ctn id=\"link$num_link\"/>";
108 push @routes_router, " </route>\n";
111 #Create the route between cluster and cluster
112 elsif(!$is_router[$src] && !$is_router[$dst])
115 push @routes_cluster, " <ASroute src=\"$list_of_name[$src]\" dst=\"$list_of_name[$dst]\"";
116 push @routes_cluster, " gw_src=\"$list_of_name[$src]-router\" gw_dst=\"$list_of_name[$dst]-router\">\n";
119 push @routes_cluster, " <ASroute src=\"cluster$src\" dst=\"cluster$dst\"";
120 push @routes_cluster, " gw_src=\"cluster$src-router\" dst=\"cluster$dst-router\">\n";
122 push @routes_cluster, " <link_ctn id=\"link$num_link\"/>\n";
123 push @routes_cluster, " </ASroute>\n";
127 push @routes, " <ASroute ";
129 if($is_router[$src]) #router
130 {push @routes, "src=\"AS_intern\" gw_src=\"$list_of_name[$src]\" ";}
132 {push @routes, "src=\"$list_of_name[$src]\" gw_src=\"$list_of_name[$src]-router\" ";}
135 if($is_router[$dst]) #router
136 {push @routes, "dst=\"AS_intern\" gw_dst=\"$list_of_name[$dst]\">\n";}
138 {push @routes, "dst=\"$list_of_name[$dst]\" gw_dst=\"$list_of_name[$dst]-router\">\n";}
141 if($is_router[$src]) #router
142 {push @routes, "src=\"AS_intern\" gw_src=\"router$src\" ";}
144 {push @routes, "src=\"cluster$src\" gw_src=\"cluster$src-router\" ";}
147 if($is_router[$dst]) #router
148 {push @routes, "dst=\"AS_intern\" gw_dst=\"router$dst\">\n";}
150 {push @routes, "dst=\"cluster$dst\" gw_dst=\"cluster$dst-router\">\n";}
152 push @routes, " <link_ctn id=\"link$num_link\"/>\n";
153 push @routes, " </ASroute>\n";
172 print " <AS id=\"AS_intern\" routing=\"Floyd\">\n";
175 print @routes_router;
179 print @routes_cluster;