From: Navarrop Date: Thu, 20 Oct 2011 11:22:19 +0000 (+0200) Subject: Rewrite perl script for optorsim X-Git-Tag: exp_20120216~548 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d78b0f4b92b14b7784c3e3b7ae833b2d03e00cc8 Rewrite perl script for optorsim --- diff --git a/examples/platforms/conf/transform_optorsim_platform.pl b/examples/platforms/conf/transform_optorsim_platform.pl index 2efc350f57..5b021e2c75 100644 --- a/examples/platforms/conf/transform_optorsim_platform.pl +++ b/examples/platforms/conf/transform_optorsim_platform.pl @@ -23,82 +23,153 @@ my @list_of_name; my $num_link = 0; my @links = (); +my @links_router = (); my @routers = (); my @hosts = (); +my @is_router = (); my @routes = (); -my $power; +my @routes_router = (); +my @routes_cluster = (); +my $nb_host; while(defined($line=)) { - if($line =~ /^#(.*)\)(.*)$/) - { - print "\n"; - push @list_of_name, $2; +if($line =~ /^#(.*)\)(.*)$/) +{ + print "\n"; + push @list_of_name, $2; +} +elsif($line =~ /^([0-9]*) ([0-9]*) ([0-9]*) (.*)$/) +{ + if($1 == "0"){ + push @is_router, 1; + if(@list_of_name){ + push @routers, "\t\t\n"; + } + else{ + push @routers, "\t\t\n"; + } } - elsif($line =~ /^([0-9]*) ([0-9]*) ([0-9]*) (.*)$/) - { - if($1.$2.$3 == "000"){ - if(@list_of_name){ - push @routers, "\t\n"; - } - else{ - push @routers, "\t\n"; - } + else{ + push @is_router, 0; + $nb_host = $1; + if(@list_of_name){ + push @hosts, "\t\n"; } else{ - $power = $1 * $3; - if($power == 0){ - $power=1; - } - if(@list_of_name){ - push @hosts, "\t\n"; - } - else{ - push @hosts, "\t\n"; - } - } - my $table = $4; - @tokens = split(/ /,$table); - foreach $token (@tokens) { - if($token != "0"){ - if($src <= $dst){ - + push @hosts, "\t\n"; + } + } + my $table = $4; + @tokens = split(/ /,$table); + foreach $token (@tokens) { + if($src >= $dst){ + if($token != "0") #if there is a link between src and dst + { + #Create a link + if($1 == "0"){ + push @links_router, "\t\t\n"; + } + else{ push @links, "\t\n"; - + } + + #Create the route between router and router + if($is_router[$src] && $is_router[$dst]) + { + if(@list_of_name){ + push @routes_router, "\t\t\n"; + } + else{ + push @routes_router, "\t\t\n"; + } + push @routes_router, "\t\t\t\n"; + push @routes_router, "\t\t\n"; + } + + #Create the route between cluster and cluster + elsif(!$is_router[$src] && !$is_router[$dst]) + { if(@list_of_name){ - push @routes, "\t\n"; + push @routes_cluster, "\t\t\n"; } else{ - push @routes, "\t\n"; + push @routes_cluster, "\t\t\n"; + } + push @routes_cluster, "\t\t\t\n"; + push @routes_cluster, "\t\t\n"; + } + else + { + push @routes, "\t\n";} + else #cluster + {push @routes, "\t\tdst=\"$list_of_name[$dst]\" gw_dst=\"$list_of_name[$dst]-router\">\n";} + } + else{ + if($is_router[$src]) #router + {push @routes, "src=\"AS_intern\" gw_src=\"router$src\"\n";} + else #cluster + {push @routes, "src=\"cluster$src\" gw_src=\"cluster$src-router\"\n";} + + + if($is_router[$dst]) #router + {push @routes, "\t\tdst=\"AS_intern\" gw_dst=\"router$dst\">\n";} + else #cluster + {push @routes, "\t\tdst=\"cluster$dst\" gw_dst=\"cluster$dst-router\">\n";} } push @routes, "\t\t\n"; - push @routes, "\t\n"; - $num_link++; + push @routes, "\t\n"; + } + + $num_link++; } - $dst++; } - $src++; - $dst = 0; - } - else - { - die; - } + $dst++; + } + $src++; + $dst = 0; +} +else +{ +die; +} } close(FILE); - -print @hosts; -print "\n"; + +print "\t\n"; print @routers; +print @links_router; +print @routes_router; +print "\t\n"; +print "\n"; +print @hosts; +print @routes_cluster; print "\n"; + print @links; print "\n"; print @routes; +print "\n"; print "\n"; print ""; -print " \n"; \ No newline at end of file +print " \n";