Commit ae4b5046 authored by Dan Gebhardt's avatar Dan Gebhardt

*** empty log message ***

parent 4fd155fe
#!/usr/bin/perl
#!/usr/bin/perl -W
use Getopt::Std;
use strict;
use IO::Socket::INET;
use IO::Select;
use libwanetmon;
# A node from each site to take part in the measurements
my @expnodes;
......@@ -12,7 +13,7 @@ my %deadnodes;
sub usage
{
warn "Usage: $0 <input_file> [-p port] [-e pid/eid] [-l latency period] [-b bandwidth period] [-a]\n";
warn "Usage: $0 <input_file> [-p port] [-e pid/eid] [-l latency period] [-b bandwidth period] [-a] [-o outputport]\n";
return 1;
}
......@@ -35,11 +36,11 @@ my %DEF_PER = (
my %settings; #misc options
$settings{"allpairs"} = 0; #if 0 interprets input nodes as pairs
$settings{"expt"} = "__none";
my @expnodes;
#*****************************************
my %opt = ();
getopts("s:p:h:e:l:b:a", \%opt);
getopts("s:p:o:h:e:l:b:a", \%opt);
if ($opt{h}) { exit &usage; }
if ($opt{e}) { $settings{"expt"} = $opt{e}; }
......@@ -70,16 +71,25 @@ while( <FILE> ){
}
close FILE;
my ($port);
if ($opt{p}) { $port = $opt{p}; } else{ $port = 5060; }
my ($port, $lport);
if ($opt{p}) { $port = $opt{p}; } else{ $port = 5052; }
if ($opt{o}) { $lport = $opt{o}; } else{ $lport = 5052; }
print "using remote port $port and local port $lport\n";
print "experiment $settings{expt}\n";
my $socket;
setcmdport($port);
setexpid($settings{expt});
#MAIN
#TODO: Control Loop
my $cmd;
my $cmd = "";
while( $cmd ne "q" )
{
%deadnodes = ();
$cmd = <STDIN>;
chomp $cmd;
......@@ -231,14 +241,6 @@ sub initnode($$$$)
);
sendcmd($node,\%cmd);
=pod
$socket = IO::Socket::INET->new( PeerPort => $port,
Proto => 'udp',
PeerAddr => $node );
# my $sercmd = Storable::freeze \%cmd ;
my $sercmd = serialize_hash( \%cmd );
$socket->send($sercmd);
=cut
print "sent initnode to $node\n";
print "destnodes = $destnodes\n";
......@@ -246,63 +248,6 @@ sub initnode($$$$)
print "testtype = $testtype\n";
}
sub stopnode($)
{
my ($node) = @_;
my %cmd = ( expid => $settings{expt},
cmdtype => "STOPALL" );
sendcmd($node,\%cmd);
}
sub sendcmd($$)
{
my $node = $_[0];
my $hashref = $_[1];
my %cmd = %$hashref;
my $sercmd = serialize_hash( \%cmd );
my $f_success = 0;
my $max_tries = 5;
do{
$socket = IO::Socket::INET->new( PeerPort => $port,
Proto => 'tcp',
PeerAddr => $node,
Timeout => 1);
if( defined $socket ){
$sel->add($socket);
print $socket "$sercmd\n";
#todo: wait for ack;
# timeout period?
$sel->add($socket);
my ($ready) = $sel->can_read(1);
if( $ready eq $socket ){
my $ack = <$ready>;
chomp $ack;
if( $ack eq "ACK" ){
$f_success = 1;
print "Got ACK from $node for command\n";
close $socket;
}else{
$max_tries--;
}
}else{
$max_tries--;
}
$sel->remove($socket);
close($socket);
}else{
select(undef, undef, undef, 0.2);
$max_tries--;
}
}while( $f_success != 1 && $max_tries != 0 );
if( $f_success == 0 && $max_tries == 0 ){
$deadnodes{$node} = 1;
}
}
sub updatenodes
{
......@@ -339,23 +284,3 @@ sub outputErrors()
print "\n";
}
#
# Custom sub to turn a hash into a string. Hashes must not contain
# the substring of $separator anywhere!!!
#
sub serialize_hash($)
{
my ($hashref) = @_;
my %hash = %$hashref;
my $separator = "::";
my $out = "";
for my $key (keys %hash){
$out .= $separator if( $out ne "" );
$out .= $key.$separator.$hash{$key};
}
return $out;
}
......@@ -2,8 +2,12 @@
rm bgmon.tar.gz
#tar -czf bgmon.tar.gz bgmon.pl runbgmon event.pm
tar -czf bgmon.tar.gz bgmon.pl runbgmon
cp bgmon.tar.gz /proj/tbres/gebhardt/
rm /proj/tbres/gebhardt/iperfd.tar.gz
cp /proj/tbres/bin/iperfd .
tar -zcf /proj/tbres/gebhardt/iperfd.tar.gz iperfd
tar -czf bgmon.tar.gz bgmon.pl libwanetmon.pm runbgmon
cp bgmon.tar.gz /proj/tbres/gebhardt/wanetmonstuff/
#rm /proj/tbres/gebhardt/wanetmonstuff/iperfd.tar.gz
#rm /proj/tbres/gebhardt/wanetmonstuff/fping.tar.gz
#cp /proj/tbres/bin/iperfd .
#cp /proj/tbres/bin/fping .
#tar -zcf /proj/tbres/gebhardt/wanetmonstuff/iperfd.tar.gz iperfd
#tar -zcf /proj/tbres/gebhardt/wanetmonstuff/fping.tar.gz fping
#!/usr/bin/perl
#
# Configure variables
#
use lib '/usr/testbed/lib';
use event;
use libwanetmon;
use IO::Socket::INET;
use IO::Select;
use Getopt::Std;
use strict;
sub usage {
warn "Usage: $0 [-s server] [-p port] <monitoraddr> <link dest> ".
warn "Usage: $0 [-p port] [-e pid/eid] <monitoraddr> <link dest> ".
"<testtype> <testper(seconds)> <COMMAND>\n";
return 1;
}
my %opt = ();
getopt("s:p:h",\%opt);
getopts("e:s:p:h",\%opt);
my ($expt, $port);
if ($opt{e}) { $expt = $opt{e}; } else { $expt = "__none"; }
if ($opt{p}) { $port = $opt{p}; } else{ $port = 5052; }
if ($opt{h}) { exit &usage; }
if (@ARGV != 5) { exit &usage; }
my ($server,$port);
if ($opt{s}) { $server = $opt{s}; } else { $server = "localhost"; }
if ($opt{p}) { $port = $opt{p}; }
setcmdport($port);
my $URL = "elvin://$server";
if ($port) { $URL .= ":$port"; }
my ($srcnode, $destnode, $testtype, $testper, $cmd) = @ARGV;
my $handle = event_register($URL,0);
if (!$handle) { die "Unable to register with event system\n"; }
my $tuple = address_tuple_alloc();
if (!$tuple) { die "Could not allocate an address tuple\n"; }
my %cmd = ( expid => $expt,
cmdtype => $cmd,
dstnode => $destnode,
testtype => $testtype,
testper => $testper
);
my $socket;
my $sel = IO::Select->new();
%$tuple = ( objtype => "BGMON",
objname => $ARGV[0],
eventtype => $ARGV[4],
expt => "__none");
sendcmd( $srcnode, \%cmd );
my $notification = event_notification_alloc($handle,$tuple);
if (!$notification) { die "Could not allocate notification\n"; }
print "Sent at time " . time() . "\n";
#add attributes to event
if( 0 == event_notification_put_string( $handle,
$notification,
"linkdest",
$ARGV[1] ) )
{ die "Could not add attribute to notification\n"; }
if( 0 == event_notification_put_string( $handle,
$notification,
"testtype",
$ARGV[2] ) )
{ die "Could not add attribute to notification\n"; }
if( 0 == event_notification_put_string( $handle,
$notification,
"testper",
$ARGV[3] ) )
{ die "Could not add attribute to notification\n"; }
#send notification
if (!event_notify($handle, $notification)) {
die("could not send test event notification");
}
event_notification_free($handle, $notification);
if (event_unregister($handle) == 0) {
die("could not unregister with event system");
}
exit(0);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment