- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Useful Bandwidth Monitoring Tools to Analyze Network Usage in Linux
Monitoring network usage is important in order to understand the performance and potential bottlenecks in a network. In Linux, there are several tools that can be used to monitor network usage. These tools can be broadly categorized into two groups; tools that report the network usage per interface as a single figure and tools that group the network usage on a per-socket or per-process basis. In this article, we'll look at different tools for monitoring network usage in Linux, including nload, speedometer and iftop.
nload Tool in Linux
nload is a command-line tool that displays network usage on a Linux system. nload belongs to the category of network monitoring tools in Linux that simply sum up all the network traffic on a network interface.
nload Tool Installation
For Debian-based Linux systems, nload can be installed using apt-get −
$ apt-get install -y nload
For RHEL-based Linux systems, nload can be installed using yum −
$ yum install -y epel-release $ yum install -y nload
Basic Usage nload
To use nload, simply type the following command in the terminal −
This will launch an interactive screen that displays the network usage for incoming and outgoing network traffic. The screen shows the current network usage, the average, minimum, and maximum figures, and the total amount of data transferred. The top of the screen displays the device being monitored, and by using the arrow keys left and right, we can cycle between different network interfaces available in the system.
Changing the Refresh Interval
By default, nload updates the network usage once every 500 milliseconds. To change the refresh interval, pass the -t flag followed by an integer value in milliseconds −
$ nload -t 5000
The above command will refresh the network usage once every 5 seconds.
Setting the Unit
To change the unit used to display the network traffic rate, use the -u flag −
$ nload -u m
The above command will display the network traffic rate in megabits per second. The -u flag accepts the following values −
b (for bits) or B (for bytes) k (for kilobits) or K (for kilobytes) m (for megabits) or M (for megabytes) g (for gigabits) or G (for gigabytes)
Similarly, the unit of the total amount of data transferred can be changed using the -U flag, which also accepts similar values to the -u flag.
Displaying All Devices
To display all the network interfaces in a single screen, use the -m flag −
$ nload -m
This mode allows you to view the network usage for all interfaces in one screen, but the graphs for network traffic will not be displayed.
Speedometer Tool in Linux
speedometer is a network monitoring tool that displays network usage graphically. It is similar to nload in that it does not differentiate the network traffic on a network interface by socket or process. However, one of the advantages of speedometer over nload is that the display of speedometer is much more customizable.
Speedometer Tool Installation
speedometer can be installed on Debian-based Linux systems using apt-get −
$ apt-get install -y speedometer
Unfortunately, the speedometer package is unavailable in yum package manager.
Basic Usage of Speedometer
Let’s monitor the outgoing network traffic rate for our network interface eth0 −
$ speedometer -t eth0
Running the command results in a graph showing up on the console output. Additionally, this graph is being constantly updated by the speedometer instance that is monitoring the interface eth0.
At the bottom of the graph, we can see additional information like the total data transferred, the average transfer rate, the current transfer rate, and the peak transfer rate.
Changing the Scale
By default, ‘speedometer’ command displays the network usage in bytes per second. To change the scale, we can use the flag -k to display it in kilobytes per second, -m to display it in megabytes per second, and -g to display it in gigabytes per second.
For example, to display the network usage in kilobytes per second −
$ speedometer -k -t eth0
Displaying Multiple Interfaces
By default, the speedometer command displays the network usage for a single network interface. To display multiple network interfaces, we can specify the network interfaces separated by a comma.
For example, to display the network usage for eth0 and eth1 −
$ speedometer -t eth0,eth1
iftop Tool in Linux
iftop is a command-line tool that displays a real-time report of the network bandwidth usage. Unlike nload and speedometer, iftop provides a more detailed view of the network usage, showing the network usage on a per-socket or per-process basis.
iftop Tool installation
On Debian based Linux, we can install iftop using apt −
$ apt install -y iftop
On the other hand, we can use yum to install iftop on RHEL based Linux −
$ yum install -y epel-release $ yum install -y iftop
Basic Usage of iftop
To use iftop, we simply run the iftop command −
This command will launch an interactive screen displaying the network usage for the default network interface. By default, iftop sorts the network usage by the amount of bandwidth used.
The columns in the iftop display show the local address and port, the remote address and port, the hostnames of the local and remote hosts, and the amount of bandwidth used by the socket or process.
Customizing the Display
iftop provides several flags that allow us to customize the display of the network usage.
For example, we can change the network interface that iftop is monitoring by using the flag -i −
$ iftop -i eth0
This command launches iftop and displays the network usage for the network interface eth0.
We can also change the sorting order of the network usage by using the flag -N −
$ iftop -N
In conclusion, having the right tools for monitoring network usage in Linux is crucial for ensuring the stability and performance of our systems. The three tools we've discussed in this article, nload, speedometer and iftop, are some of the most popular and effective tools for monitoring network usage in Linux. By understanding the functionality, installation, and usage of each of these tools, we can select the one that best suits our needs and use it to optimize our network performance.
Kickstart Your Career
Get certified by completing the courseGet Started