You have a problem. Measuring bandwidth can be extremely difficult. I'm assuming what you're wanting to do is simply see how 'fast' a DSL connection is?

This is a problem I looked at a while back. The simplest way seems to be to have a client server arrangement.

The client connects to the server, and downloads a (large ish) file. The time taken to download is your bandwidth measure.

In perl, well, refer elsewhere for code, but you could simply have a server that prints 1M bytes, and time how long it takes your client to recieve that. Alternatively, you can use FTP and upload and download a file. That's generally a reasonable measure :)

Other alternatives include using pings of various sizes. By comparing the round trip time of a ping of 1 byte payload. 10 bytes of payload, 100 bytes etc.

The theory being that there's a 'basic' round trip time for the small pings, that increases in direct proportion to the size of the data.

If your're actually looking to view/control bandwidth from another application, may I recommend trying to get a copy of "ntop" for viewing. Controlling bandwidth is difficult, requires bending RFCs and is a quite profitable business on the net.


In reply to Re: Bandwidth Testing by Preceptor
in thread Bandwidth Testing by sunadmn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.