Real-Time Network Monitoring with Iftop
Measuring Network Speed Between Hosts
While iftop is primarily a monitoring tool, creative users can leverage it to measure actual network speeds between specific hosts. The basic approach is to observe the bandwidth usage during a file transfer or other network operation and compare the measured rate against expected network capacity.
For example, to test upload speed to a specific server, you could initiate a large file upload to the target server and then enter
sudo iftop -i eth0 -f 'host target_server'
Then observe the outbound bandwidth rate during the transfer. This technique can help identify bottlenecks or confirm that you're getting the expected throughput from your network infrastructure. It's particularly valuable for troubleshooting speed issues where the theoretical network capacity doesn't match actual observed performance.
Identifying Bandwidth Hogs
One of the most common and valuable uses for iftop is identifying processes or connections consuming excessive bandwidth. On busy systems or networks, unexplained bandwidth usage can lead to performance degradation, quota overages, or even service disruptions. The cause for the excessive usage could be an unexpected backup, unauthorized media streaming, or even malware activity. Iftop provides the visibility needed to track down these bandwidth hogs.
If you notice slow network performance or unexpectedly high bandwidth usage, launch iftop and sort by bandwidth usage. You can identify the top consumers by examining the connection list. Then cross-reference the result with other tools like nethogs or lsof to zero in on the offending process.
Troubleshooting Network Performance Issues
Iftop serves as an excellent first-line tool for diagnosing various network performance problems. Its real-time connection view helps correlate user-reported issues with actual network behavior. You can use iftop to uncover uneven traffic distribution, troubleshoot unexpected traffic patterns, and diagnose protocol issues.
By observing traffic patterns during periods of poor performance, you can often pinpoint the root cause much faster than with trial-and-error approaches. The ability to see both the big picture of overall bandwidth usage and the micro view of individual connections makes iftop uniquely suited for this kind of troubleshooting.
Buy this article as PDF
(incl. VAT)