mrmick has asked for the wisdom of the Perl Monks concerning the following question:

I've been having a lot of downtime with Rogers@HOME since the end of April. I want to write a script that will test all connections, first to see if the remote host(s) is up and then to see if there is a response and also want to measure latency and download/upload speeds.

I suppose I could use Net::FTP and LWP::Simple for the first two but how would I get the latency and download/upload stats?

I would appreciate any insight and recommendations...

I could also post the completed script/program for any who would be interested once I have completed it.

Thanks in advance,

Mick

Replies are listed 'Best First'.
Re: @HOME service test...
by lhoward (Vicar) on Jul 30, 2000 at 18:01 UTC
    To measure throughput use LWP or Net::FTP and measure the time (using Time::HiRes for greater accuracy) it takes to push a large chunk of data across. Divide the data size by the elapsed time and you will have a usable aproximation of end-to-end application-layer throughput.
    use LWP::Simple; use Time::HiRes qw( gettimeofday tv_interval ); my $t0 = [gettimeofday]; my $d=get('http://www.perlmonks.org'); my $elapsed=tv_interval ( $t0, [gettimeofday]); my $throughput=length($d)/$elapsed; print "throughput=$throughput Bytes per second\n";

    Another (more accurate) measurement could be gathered by spawning off several such "data pusher" processes in parallel. Then use raw network IO stats (gathered by SNMP or however you want) to determine the throughput during the period of the test.

    You can get latency by using a Time::HiRes timer around Net::Ping. My example below takes only a single ping, for real use you'd probably want to take multiple tests and average them.

    use Time::HiRes qw( gettimeofday tv_interval ); use Net::Ping; my $p = Net::Ping->new("icmp"); my $t0 = [gettimeofday]; $p->ping('127.0.0.1',5); my $elapsed=tv_interval ( $t0, [gettimeofday]); print "latency=$elapsed\n";
RE: @HOME service test... (relevant nodes)
by ybiC (Prior) on Jul 31, 2000 at 02:26 UTC