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.
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
- Per-host statistics of network usage.
- Graphical representation of statistics with character bars.
- Host names are not bound to process names in the statistic, so you have to figure out by yourself which processes they belong to.