#!/usr/bin/perl -w use strict; use Getopt::Long; my $topology; my $num_nodes; my $model; my $logfile; my %options; &GetOptions( \%options, "help|?", "topology=s", "protocol=s", "logdir=s", "seed=s", "nice=i", "model=s", "nnodes=i", "topofile=s", "neighbors=i", "timestep=f", "adaptive=s", "model-opts=s", "prot-opts=s", "p2psim=s", "joinstagger=i", "config=s") or &usage; if ($options{"help"}) { &usage(); } sub usage () { print "no help yet\n"; die; } if ($options{"protocol"}) { open P, ">p-$$"; my $prot = $options{"protocol"}; my $logdir = "."; $logdir = $options{"logdir"} if ($options{"logdir"}); $logfile = "$logdir/p2psim-$prot-$$"; print STDERR "logs to $logfile\n"; open LOG, ">$logfile" or die "can't open $logfile\n"; if ($options{"nnodes"}) { $num_nodes = $options{"nnodes"}; print LOG "# nnodes = $num_nodes\n"; } else { print STDERR "nnodes not specified\n"; usage (); } if ($prot eq "Vivaldi" or $prot eq "vivaldi" or $prot eq "viv") { my $adapt = "relrel"; $adapt = $options{"adaptive"} if ($options{"adaptive"}); print P "VivaldiTest adaptive=$adapt totalnodes=$num_nodes "; print LOG "# VivaldiTest adaptive=$adapt \n"; } elsif ($prot eq "PIC") { print P "VivaldiTest adaptive=relrel algorithm=simplex window-size=32 "; print LOG "# PIC adaptive=relrel algorithm=simplex window-size=32\n"; } else { die "only PIC and Vivaldi are supported\n"; } if ($options{"model"}) { my ($kind, $dim) = split(/-/, $options{"model"}); if ($kind eq "height" or $kind eq "height-vectors") { print P "using-height-vectors=1 "; print P "model-dimension=$dim "; } elsif ($kind eq "euc" or $kind eq "euclidean") { print P "using-height-vectors=0 "; print P "model-dimension=$dim "; } elsif ($kind eq "sphere") { print P "model=sphere radius=$dim model-dimenion=3 "; } elsif ($kind eq "torus") { print P "model=torus tsize=$dim"; } else { die "no model specified\n"; } $model = $options{"model"}; print LOG "# model=$model\n"; } if ($options{"neighbors"}) { my $n = $options{"neighbors"}; print P "neighbors=$n "; print LOG "# neighbors=$n\n"; } if ($options{"timestep"}) { my $raw = $options{"timestep"}; my $t = $raw*1000000; print P "timestep=$t "; print LOG "# timestep=$raw\n"; } else { print P "timestep=250000 "; print LOG "# timestep=250000\n"; } if ($options{"config"}) { my $c = $options{"config"}; print P "$c=1 "; print LOG "# $c\n"; } print P "\n"; close P; } else { print STDERR "No protocol specified."; usage(); } if ($options{"topology"} ) { my $topo = $options{"topology"}; print LOG "# topo=$topo\n"; $topology = $topo; if ($topo eq "GT" or $topo eq "gtitm") { open T, ">t-$$"; print T "topology gtitm $num_nodes ts2000-0.gb\n"; print T "failure_model NullFailureModel\n\n"; close T; } elsif ($topo eq "king") { die "must specify topo file for King\n" unless ($options{"topofile"}); # print T "topology E2EGraph $num_nodes\n"; # print T "failure_model NullFailureModel\n\n"; # output pairwise latencies? my $kt = $options{"topofile"}; system ("ln -s $kt t-$$"); } elsif ($topo eq "euclidean") { die "must specify topo file for King\n" unless ($options{"kingtopo"}); my $kt = $options{"topofile"}; # generate it instead? system ("ln -s $kt t"); } # generate e and f open E, ">e-$$"; print E "generator FileEventGenerator name=f-$$\n"; close E; open F, ">f-$$"; my $jtime = 0; my $stagger = 0; $stagger = $options{"joinstagger"} if ($options{"joinstagger"}); print LOG "# stagger=$stagger\n"; for (my $i = 1; $i <= $num_nodes; $i++) { print F "node $jtime $i join\n"; #$jtime += $stagger + 1; $jtime += $stagger; } print F "simulator 1000000000 exit\n"; close F; } else { print STDERR "No topology file specified"; usage(); } close LOG; my $p2psim_cmd = $ENV{"P2PSIM"}; $p2psim_cmd = $options{"p2psim"} if $options{"p2psim"}; while(1) {system ("$p2psim_cmd p-$$ t-$$ e-$$>> $logfile 2>> $logfile"); }; #system ("rm p-$$ t-$$ e-$$ f-$$");