How to use iperf3 tool to monitor network bandwidth in Linux
Brief information on my setup:
Server
My server IP is 192.169.32.15 where I have 2 bond interfaces as below
# ifconfig bond0
bond0 Link encap:Ethernet HWaddr 00:17:A4:77:00:38
inet addr:192.169.32.15 Bcast:192.169.32.31 Mask:255.255.255.224
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:9042150 errors:0 dropped:4553 overruns:0 frame:0
TX packets:2277574 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:13654658052 (13022.0 Mb) TX bytes:153728769 (146.6 Mb)
# ifconfig bond1
bond1 Link encap:Ethernet HWaddr 38:63:BB:2F:E5:A9
inet addr:192.169.32.37 Bcast:192.169.32.63 Mask:255.255.255.224
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:28334533 errors:0 dropped:2 overruns:0 frame:0
TX packets:2066047 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:42898423316 (40911.1 Mb) TX bytes:136362958 (130.0 Mb)
The ethernet speed assigned to both interfaces eth0 and eth1 under bond0 is 1 GB
# ethtool eth0 | grep -i Speed
Speed: 1000Mb/s
# ethtool eth1 | grep -i Speed
Speed: 1000Mb/s
so if we use bond0 for our network operations then ethernet bandwidth must not exceed 1 GB
The ethernet speed assigned to both interfaces eth2 and eth3 under bond1 is 3 GB
# ethtool eth2 | grep -i Speed
Speed: 3000Mb/s
# ethtool eth3 | grep -i Speed
Speed: 3000Mb/s
so if we use bond1 for our network operations then ethernet bandwidth must not exceed 3 GB
Client
My clinet node is 192.169.32.17 where as well I have 2 bond interfaces in the same subnet as my server
# ifconfig bond0
bond0 Link encap:Ethernet HWaddr 00:17:A4:77:00:44
inet addr:192.169.32.17 Bcast:192.169.32.31 Mask:255.255.255.224
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:2263768 errors:0 dropped:5390 overruns:0 frame:0
TX packets:8626819 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:150407672 (143.4 Mb) TX bytes:12455852277 (11878.8 Mb)
# ifconfig bond1
bond1 Link encap:Ethernet HWaddr 38:63:BB:2F:56:C1
inet addr:192.169.32.38 Bcast:192.169.32.63 Mask:255.255.255.224
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:2067482 errors:0 dropped:16 overruns:0 frame:0
TX packets:28335782 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:136453804 (130.1 Mb) TX bytes:41070143636 (39167.5 Mb)
The ethernet speed assigned to bond0 and bond1 is same as server i.e. 1 GB and 3 GB respectively
Let us start our test
Installed netperf on both the machines
NOTE: I would recommend to disable the firewall on both server and client for the monitoring purpose as at times your firewall might stop netperf from sending traffic to client machine
On Server
server # rpm -Uvh /tmp/netperf-2.6.0-3.3.x86_64.rpm
warning: /tmp/netperf-2.6.0-3.3.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID f388ca22
Preparing... ########################################### [100%]
1:netperf ########################################### [100%]
Start netperf on any free port number
# netserver -p 16604
Starting netserver with host 'IN(6)ADDR_ANY' port '16604' and family AF_UNSPEC
# netstat -ntlp | grep 16604
tcp 0 0 :::16604 :::* LISTEN 3624/netserver
So our port has been opened by netperf
On Client
client # rpm -Uvh /tmp/netperf-2.6.0-3.3.x86_64.rpm
warning: /tmp/netperf-2.6.0-3.3.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID f388ca22
Preparing... ########################################### [100%]
1:netperf ########################################### [100%]
In the below example we are sending traffic for 100 seconds to host server IP 192.169.32.15
# netperf -H 192.169.32.15 -p 16604 -l 100
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.169.32.15 () port 0 AF_INET : demo
enable_enobufs failed: setsockopt
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
11796480 11796480 11796480 100.07 994.23
So bond0 network traffic is within our limit as provided to the interface i.e. 1 GB/s
Lets validate bond1
Here my server IP of bond1 is 192.169.32.37
# netperf -H 192.169.32.37 -p 16604 -l 100
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.169.32.37 () port 0 AF_INET : demo
enable_enobufs failed: setsockopt
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
11796480 11796480 11796480 100.02 2982.72
bond1 network traffic is also within our provided limit i.e. 3 GB/s
I hope the article was helpful