Networking Forums

Networking Forums > Computer Networking > Linux Networking > Measuring data transfer over a NIC

Reply
Thread Tools Display Modes

Measuring data transfer over a NIC

 
 
Augustus SFX van Dusen
Guest
Posts: n/a

 
      06-21-2005, 09:24 PM
I am looking for a tool that tells me how many bytes have been
transferred over a specified network interface, between two given points
in time. Anybody know about such a thing?


 
Reply With Quote
 
 
 
 
Augustus SFX van Dusen
Guest
Posts: n/a

 
      06-21-2005, 09:34 PM
On Tue, 21 Jun 2005 21:24:38 +0000, Augustus SFX van Dusen wrote:

> I am looking for a tool that tells me how many bytes have been
> transferred over a specified network interface, between two given points
> in time. Anybody know about such a thing?


Let me add that I'd be interested in a simple command-line tool, that
when stopped spits out the number of bytes transferred since it was
launched. Things like ntop, while nice, do much more than I require, and
what I require they do in ways which are not practical for my purposes.



 
Reply With Quote
 
Wolfman's Brother
Guest
Posts: n/a

 
      06-21-2005, 10:22 PM
Augustus SFX van Dusen wrote:
> On Tue, 21 Jun 2005 21:24:38 +0000, Augustus SFX van Dusen wrote:
>
>
>> I am looking for a tool that tells me how many bytes have been
>>transferred over a specified network interface, between two given points
>>in time. Anybody know about such a thing?

>
>
> Let me add that I'd be interested in a simple command-line tool, that
> when stopped spits out the number of bytes transferred since it was
> launched. Things like ntop, while nice, do much more than I require, and
> what I require they do in ways which are not practical for my purposes.


ifconfig prints the number of bytes and packets transferred over the
interface since boot. To measure between two points in time, run the
command at the start and again at the end, and compare.

Note: as "man ifconfig" says ..

Since kernel release 2.2 there are no explicit interface statistics for
alias interfaces anymore. The statistics printed for the original
address are shared with all alias addresses on the same device. If you
want per-address statistics you should add explicit accounting rules for
the address using the ipchains(8) [or rather: iptables] command.

--
ROPE: Scriptable IP packet match module. http://www.lowth.com/rope
 
Reply With Quote
 
Floyd L. Davidson
Guest
Posts: n/a

 
      06-22-2005, 04:48 AM
Augustus SFX van Dusen <(E-Mail Removed)> wrote:
>On Tue, 21 Jun 2005 21:24:38 +0000, Augustus SFX van Dusen wrote:
>
>> I am looking for a tool that tells me how many bytes have been
>> transferred over a specified network interface, between two given points
>> in time. Anybody know about such a thing?

>
> Let me add that I'd be interested in a simple command-line tool, that
>when stopped spits out the number of bytes transferred since it was
>launched. Things like ntop, while nice, do much more than I require, and
>what I require they do in ways which are not practical for my purposes.


Here's a shell script that does what you ask, I think. If
invoked as "foo eth0", it will run until you kill it, and then
will exit showing the bytes rcvd and sent on the eth0 interface.
If invoked as "foo eth10 10" if will run for 10 seconds, and
stop on its own. (The interval must be within the range that
bash's sleep function can handle.)

Typical output looks like this:

#./foo eth0 10
eth0: 13251 bytes rcvd, 5451 bytes sent.


#!/bin/bash

trap showresults exit

iface="${1}"
interval=${2}

showresults () {
if [ ${retval} -ne 0 ] ; then
exit ${retval}
fi

rstart=${rbytes}
tstart=${tbytes}
get_data

echo -n "$iface: $(expr $rbytes - $rstart) bytes rcvd, "
echo "$(expr $tbytes - $tstart) bytes sent."
}

get_data () {
IFS=" :"
while read if rbytes a b c d e f g tbytes junk ; do
if [ "${if}" = "${iface}" ] ; then break; fi
done < /proc/net/dev
}

retval=1;

if [ ${#} -lt 1 ] ; then
echo ""
echo "Error: no interface name specified"
echo "Usage: $0 interface [ seconds ]"
echo ""
exit ${retval}
fi

get_data

if [ "${if}" != "${iface}" ] ; then
echo "Error: No data for interface $iface"
exit 1
fi

retval=0

if [ ${#} -gt 1 ] ; then
sleep ${interval}
else
while true ; do
sleep 100
done
fi
# end of script file

--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) (E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
data transfer louis@inlovewithfashion.com Windows Networking 2 12-09-2006 05:49 AM
Measuring a data stream... Cyphos Windows Networking 0 03-27-2006 10:09 PM
Data transfer twosheds Wireless Networks 2 08-16-2005 09:29 AM
data transfer 98 to xp brad Windows Networking 1 07-26-2005 07:38 PM
measuring data transfer spirofantasio@zoom.co.uk Broadband 2 01-17-2005 12:00 PM



1 2 3 4 5 6 7 8 9 10 11