Linux Bandwidth Sampling Tool

* Purpose: Linux command line utility to display bandwidth usage and stats.

  Availability: http://moogy.unstable.org:8080/bw.gz

The main feature of this Tcl script is that it does bytes received/transmitted sampling to provide the Linux user a quick estimate of current bandwidth usage.

It does this by accessing the /proc/net/dev pseudo-file to get the interface statistics, then waits <n> number of seconds and compares the difference and formats the output in human readable form.


Command line syntax:

 burp:/hack/tcl/bw# bw -h
  bw <flags>  #default is: -i all
   -i --interface <interface type> #(eg: ppp0 eth0 lo all)
   -p --packets      #include packets count
   -e --errors       #include errors
   -d --dropped      #include dropped packets
   -v --verbose      #same as: -p -e -d
   -s --seconds <n>  #number of seconds <n> to use for bandwidth usage
                     #sampling default is 3 seconds
 flags can be in any order but must be separate and not ganged together
   correct: -p -e   wrong: -pe 

Example output:

 burp:/hack/tcl/bw# bw -v -i ppp0
 ppp0:  Received: 14.8M Packets: 19.5K Errors: 0 Dropped: 0 Usage: 0.0B/s
      Transmited: 2.0M Packets: 21.2K Errors: 0 Dropped: 0 Usage: 0.0B/s

I was obviously idle. :)


Of special interest to me is the behaviour of the /proc/net/dev fields. When the bytes received/transmitted fields overflow their formatted field length, what is the actual behaviour? Does the value simply get trimmed to fit the field or does the value rollover in some sense?

If anyone knows the answer to this please edit this page.


See also Wolf "Grossi" Grossbauer's Network Traffic Graphic Display for Linux.