Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a way to get the bandwidth, delay, jitter collision, error rate and loss rate of a certain link through the interface on a local machine?

let's say my machine is connected to a network via two interfaces, one wireless and the other ethernet. I want to compare the quality of these two links through these measurements.

Is there any way to get these measurements in the Linux kernel? (v. 3.5.0)

share|improve this question

3 Answers 3

This is probably the best tutorial I've found for getting familiar with QoS stats within the Linux Kernel. It was originally published in the Linux Magazine in 2010 but is still completely relevant.

The article was titled: Journey to the Center of the Linux Kernel: Traffic Control, Shaping and QoS.

share|improve this answer

It is hard to give full details, especially not knowing what distribution you are using and how detailed you want the results to be - so I will just list some very basic examples.

If you are looking to get individual stats for each interface, we can break each item down separately (the following assumes root access on a distro like CentOS):

For bandwidth usage - I really like iftop. When you have iftop installed you could run the following command:

iftop -i eth0 -B

The -B option is for Bytes. Once inside iftop I like to press "T" to get a cummulative total.

For error rate you can easily see this in the output of ifconfig in your console. To get a more streamline approach you could run a very crude command like this (assuming something like Centos):

# ifconfig | grep -E "^\w|errors.* " | sed 's/pack.*errors:/Errors:/g' | sed 's/ drop.*//g' | sed 's/HW.*//g'
eth0      Link encap:Ethernet
          RX Errors:0
          TX Errors:0
eth1      Link encap:Ethernet
          RX Errors:3
          TX Errors:1
lo        Link encap:Local Loopback
          RX Errors:0
          TX Errors:0

This will give you the error count for each interface.

For collisions you can still use ifconfig. To get just the collision count, another basic command would be as follows:

# ifconfig | grep -E "^\w|collisions.* " | sed 's/pack.*collisions:/Collisions:/g' | sed 's/ txq.*//g' | sed 's/HW.*//g'
eth0      Link encap:Ethernet
          collisions:0
eth1      Link encap:Ethernet
          collisions:0
lo        Link encap:Local Loopback
          collisions:0

For dropped packets, still using ifconfig, you can run another simple command:

# ifconfig | grep -E "^\w|dropped.* " | sed 's/pack.*dropped:/Dropped:/g' | sed 's/ over.*//g' | sed 's/HW.*//g'
eth0      Link encap:Ethernet
          RX Dropped:0
          TX Dropped:0
eth1      Link encap:Ethernet
          RX Dropped:1
          TX Dropped:0
lo        Link encap:Local Loopback
          RX Dropped:0
          TX Dropped:0

If you are having a lot of bad packets (errors, collisions, or dropped), you could put the previous 3 commands into a bash script and use the watch command to monitor them:

FILE /tmp/netErrors:

#!/bin/sh

ifconfig | grep -E "^\w|errors.* " | sed 's/pack.*errors:/Errors:/g' | sed 's/ drop.*//g' | sed 's/HW.*//g'
echo
ifconfig | grep -E "^\w|collisions.* " | sed 's/pack.*collisions:/Collisions:/g' | sed 's/ txq.*//g' | sed 's/HW.*//g'
echo
ifconfig | grep -E "^\w|dropped.* " | sed 's/pack.*dropped:/Dropped:/g' | sed 's/ over.*//g' | sed 's/HW.*//g'
echo

COMMAND:

watch /tmp/netErrors

For QoS, it really depends on how you are setting it. For Linux, traffic control is common for setting QoS. To see the current QoS with traffic control you can run the following command:

# tc qdisc ls
qdisc pfifo_fast 0: dev eth0 root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc pfifo_fast 0: dev eth1 root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc pfifo_fast 0: dev eth2 root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc pfifo_fast 0: dev tun0 root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1

tc - traffic control command qdisc - queuing disciplines ls - list

To get a good break down of traffic control you should check out the following link on traffic control.

share|improve this answer
1  
I'm pretty familiur with most of the tools you mentioned here. However, I did point out in my question that I'm looking for a way to collect these data in the LINUX KERNEL –  Someone Jun 21 '13 at 14:59

Packages like ntop show this information. You can also install nagios and cacti, which are much more powerful but take some time to configure.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.