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 CPU 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.
January 25th, 2009 at 12:49 pm
will this or any other app keep track of the amount down/up across interface changes? every time my dsl connection drops, the total line gets reset making it difficult to track bandwidth i’m using.
January 25th, 2009 at 2:10 pm
Great program. For per-process network usage looking at nethogs will help
January 25th, 2009 at 4:38 pm
Great - similar to one of the modes of iptraf as well.
For completeness, if you want to know what process is responsible for a given connection, netstat -p will show responsible processes (for the current user, or if done as root, for everyone).
January 26th, 2009 at 6:23 pm
marvellous thing!!!
thank you vicho
January 26th, 2009 at 7:03 pm
@dominik:
Don’t thank me, thank András Horváth! He’s the one that wrote the article.