Several weeks ago, I noticed a serious decrease in performance on my local area network. The first indication of a problem was latency when streaming videos from my media-server. My Raspberry Pi Kodi systems were all working fine, but any time I tried to play an HD (or 4K) video on Macbook, I experienced significant stuttering and buffering issues. My initial thought was that it was related to a MacOS update, and I was afraid my venerable Mid-2012 era Macbook was reaching end-of-life. This turned out not to be the case. I tried multiple video players, and they all exhibited the same issue.
My next thought was that it was a network throughput issue, and I discovered valuable tool called iPerf. I've never really been concerned about the actual bandwidth on my LAN, because it's always been "fast enough". But now, I needed to know just how fast (or slow) it was. I installed iPerf3 on both my Linux media server and my Macbook and discovered to my horror that I was only achieving a bandwidth of about 10Mbps on my 100% wired LAN.
Now, I've wired every port and run every cable in the house, and they're all 8-wire CAT-5e, theoretically capable of up to gigabit speeds. My router and main switch are also gigabit devices. I checked the specs for the NICs of both my old Macbook and the Linux box and they, too, are both capable of gigabit speeds. I scratched my head for a bit, then went went to check the cabling on the router & switches. One of the cables was not fully inserted. I'd never experienced a slow-down due to poor connection, but since gigabit speeds require all four pairs to be reliable, it made sense that the NICs were auto negotiating a slower speed. In the end, it turned out that TWO cables were not securely connected, and once I rectified the situation, iPerf3 was showing me speeds of around 450 Mbps.
That's great, I thought, and certainly fast enough. But 450 Mbps is still less than half of 1Gbps. So I dug through the iPerf3 options to see if I can measure the absolute maximum bandwidth of my network. Here's what I now use.
On the server side, it's simple. Simply run iperf3 with the server option:
$ iperf3 -s
On the client side, try a few different options:
1. $ iperf3 -c
This combination is what produced the 450Mbps output. A google search revealed the need to use UDP to establish the absolute bandwidth. UDP data transfer is faster since there it is a "connectionless" (fire-and-forget) protocol. TCP includes overhead that allows for error correction and is inherently slower.
2. $ iperf3 -c --udp --bitrate 0
This combination will show you your maximum bandwidth. You 'll need the --bitrate 0 option, or iperf3 will limit the throughput to about 1Mbps. When I used these options, iperf3 reported well OVER 1Gbps!. Concerned that iperf3 was exaggerating, I set the bitrate limit to 1G.
3. $ iperf3 -c --udp --bitrate 1G
This produced some reasonable results. Netx I dug further and found the -l option which sets the buffer length for the read/write operations. For UDP, the buffer is determined dynamically, or, failing that, set to 1460 bytes. To establish a baseline, I decided to manually set it:
4. $ iperf3 -c --udp --bitrate 1G -l 1460
This showed an uplink speed of 1Gbps which was about the same without the -l option. I also discovered that you can reverse the direction of the test with the -R option:
5. $ iperf3 -c --udp --bitrate 1G -R
The reverse (downlink) speed averaged around 627Mbps. Not sure why it's asymmetric, but I can live with that.
When I swapped roles (running iperf3 -s on the Macbook and iperf3 -c on the server), I obtained similar results with the -R option, and slightly slower speeds without it. I assume this has something to do with resources on the Macbook being used by other applications (such as Firefox as I'm composing this). In the future, I will go with options shown in number 3 which seems to produce "reasonable" results.
TL;DR
Check your network cables. A loose cable can cause significant network slow-down. Use iperf3 to test your bandwidth.