#!/usr/bin/perl

# Run ssh-agent .ssh/id_rsa and sfskey login fubob@ny.lcs.mit.edu before 
# starting

$| = 1;


$trials    =   20;

# Test bandwidth of rex port forwarding

# Test latency of resumed Rex sessions on low latency network (.4ms RT ping)
system "rex -XT /sfs/cookies.lcs.mit.edu:sjtpx9265ja4ma62rehm45rfxnfd26wg /bin/true";
for ($trial = 0; $trial < $trials; $trial++ ) {

   system "/usr/bin/time -a -o rex-bw.log -f \"%Uuser %Ssystem %eelapsed\" rex -XT -m "moduled connect localhost:6666" "listen 6666" /sfs/pdos.lcs.mit.edu/cookies";
}

# Test latency of first Rex on low latency network
for ($trial = 0; $trial < $trials; $trial++ ) {
    system "/usr/bin/time -a -o rex.log -f \"%Uuser %Ssystem %eelapsed\" rex -XT /sfs/cookies.lcs.mit.edu:sjtpx9265ja4ma62rehm45rfxnfd26wg /bin/true";
    system "rex -XT /sfs/cookies.lcs.mit.edu:sjtpx9265ja4ma62rehm45rfxnfd26wg killall proxy";
}

# Test latency of SSH2 on low latency network
for ($trial = 0; $trial < $trials; $trial++ ) {
    system "/usr/bin/time -a -o ssh.log -f \"%Uuser %Ssystem %eelapsed\" ssh -2 -ax cookies.lcs.mit.edu /bin/true";
}


exit;

foreach $rextest (@rextests) {

    foreach $target ( @rextargets ) {
	
	for ($trial = 0; $trial < $trials; $trial++ ) {
	    system "/usr/bin/time $target";
	
	}
	
    }
}
