Study of iftop Command
Experiment
Study of iftop Command
π― Aim
To analyze real-time network bandwidth usage using the iftop command in Linux.
π Objective
By the end of this experiment, students will be able to:
- Monitor live network traffic
- Identify bandwidth usage per connection
- Understand incoming and outgoing data flow
- Analyze network activity in real time
π Theory
The iftop command is a real-time network monitoring tool that displays:
- Bandwidth usage between hosts
- Source and destination IP addresses
- Data transfer rates
π It is similar to the top command, but instead of CPU usage, it shows network bandwidth usage.
π It listens to network traffic on a selected interface and summarizes usage dynamically.
π§Ύ Syntax
Common Options:
-
-i <interface>→ Specify network interface (e.g.,eth0,wlan0) -
-n→ Disable hostname resolution (faster output) -
-N→ Show port numbers instead of service names -
-P→ Display port numbers -
-B→ Display bandwidth in bytes (default is bits)
π§° Prerequisites
- Linux system
- Root/sudo privileges
-
iftopinstalled
Installation:
π¬ Procedure & Commands
1️⃣ Run iftop (Default Interface)
π Displays live bandwidth usage.
2️⃣ Monitor Specific Interface
3️⃣ Disable Hostname Resolution
π Speeds up output by showing IP addresses only.
4️⃣ Show Port Numbers
5️⃣ Display in Bytes Instead of Bits
π₯️ Understanding the Output
Explanation:
-
=>→ Outgoing traffic -
<=→ Incoming traffic -
Three columns represent:
- Last 2 seconds
- Last 10 seconds
- Last 40 seconds
⌨️ Interactive Keys (During Execution)
| Key | Function |
|---|---|
t | Toggle display mode |
n | Toggle hostname/IP |
p | Toggle port display |
P | Pause display |
q | Quit |
π Exercises for Students
-
Run
iftopand observe traffic while browsing websites. - Identify which IP is consuming the most bandwidth.
-
Compare results with and without
-noption. - Monitor traffic on Wi-Fi vs Ethernet interfaces.
- Note differences between incoming and outgoing traffic.
❓ Viva Questions
-
What is the purpose of
iftop? -
Difference between
iftopandifconfig? - Why is root permission required?
- What do the three bandwidth columns represent?
⚠️ Precautions
- Requires root privileges to capture packets
- May not show encrypted traffic details (only endpoints)
- Use on authorized networks only
✅ Result
The iftop command is a powerful tool for real-time network bandwidth monitoring, helping users analyze traffic patterns and detect high network usage.
Comments
Post a Comment