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

Ok, I'm trying to determine what my options are with the following, and I'm sure I can do something with Perl here ;)

I've got several (potentially many) Win32 clients that connect to a Linux box (RH 7.2, has Perl installed), that then basically port maps the connection to other Win32 hosts on the local subnet.

Everything works as intended so far. Now, I'm trying to add some sort of automated connection speed estimation so that I can adjust compression rates on the client side. Because the end connection is on the local subnet, I'm only going to worry about the connection speed between the client and my port mapping box.

The Win32 client software is patched together using Visual Basic for size and look-and-feel reasons and is really just a GUI frontend and wrapper for a couple of other programs.

Is there any sort of Perl hackery out there now to do something like this on the Linux box side of things?? I've searched Google and came up with some old hits about someone doing this with a CGI script, but no code...

Sample code appreciated.

Thanks,

Glenn

Replies are listed 'Best First'.
Re: estimating effective connection speed
by traveler (Parson) on Nov 30, 2001 at 03:46 UTC
    Unless you want to implement a server in your client (which is likely to have the same issues as ping and traceroute), what I have found effective is to have a thread (or separate task) in the client that downloads a file, computes the download time / download size and reports that back to the server. True, that measures a combination of link speed and latency, but it is a good quick and dirty indication of how good or bad the link is. You need to do it a few times to get a somewhat meaningful picture of performance and do it occasionally over time in case the route or link changes.

    HTH, --traveler

Re: estimating effective connection speed
by FoxtrotUniform (Prior) on Nov 30, 2001 at 02:53 UTC

    Well, I was going to direct you to the Net::Ping module, but Net::Ping doesn't actually tell you how long the send/receive cycle took. So, I'd suggest calling ping via the shell and parsing its output:

    my $output = grep {/round-trip/} `ping -c N foo.bar`; my ($avg, $stddev) = ($output =~ m|([0-9.]+)/[0-9.]+/([0-9.]+) ms$|); print "Average round-trip time: $avg (standard deviation $stddev)\n";

    Or something like that... haven't tested this code.

    I'm surprised that my cursory search of CPAN didn't turn up anything that'll do this for you.

    --
    :wq
      Important detail I forgot earlier: ping and traceroute are NOT an option due to potential restrictions on the client side (ie, I can't be certain if the client's firewall is blocking outbound ping or traceroute - I don't want to take that chance).

      Thanks for the suggestion, though ;)

      Glenn