iftop - display bandwidth usage on an interface by host
January 25th, 2009 edited by VichoArticle submitted by András Horváth. We’re running out of articles! If you like Debian Package of the Day please submit good articles about software you like!
Sometimes it’s hard to guess what is eating up our bandwidth the most - on a home computer with an xDSL connection, for example. We can run a lot of programs simultaneously while they can eat as much bandwidth as they want independently of their *****U usage.
Without by-host statistics, it would be hard to guess what is slowing down our internet connection the most. iftop helps us to find out with a simple curses based interface and real-time statistics output calculated on a by-host basis. When starting it from a terminal, it starts collecting data and printing them on the screen in lines separated by host name pairs or IP addresses, showing the highest network usage. It refreshes the screen every 2 seconds.
iftop works by reading the host names out of the network packets traversing the interface and then associating them together.
After identifying the host name, we can easily guess which program is generating this particular traffic — that’s why iftop must be run with root privileges.
Though ifstat can be used with complex filtering rules, running it without parameters gives enough statistics in most cases. iftop tries to listen on eth0
by default which might not exist at all. To specify an interface on which to listen, use the -i parameter: iftop -i wlan1, iftop -i eth1.
Pressing the h key while running will display a nice on-screen help, showing the commands that can be triggered interactively in running mode. Some other examples of key commands changing the default state:
- n turns off name resolving.
- p turns on port number display.
Pros and Cons
- Pros
- Per-host statistics of network usage.
- Graphical representation of statistics with character bars.
- Cons
- Host names are not bound to process names in the statistic, so you have to figure out by yourself which processes they belong to.
Official packages have been available in both Debian (since Etch) and Ubuntu (universe) for a long time now.
Posted in Debian, Ubuntu | 5 Comments »