22

Anyone know what command can I use to check my Internet speed in the Terminal app?

May be I can use curl command and add some IP addresses, like the to check our IP and Country location via curl ipinfo.io command?

Allan
  • 101,432
Caldas
  • 333

4 Answers4

40

There is a CLI version of Speedtest called, appropriately, speedtest-cli.

You can install it via Homebrew:

brew install speedtest-cli

It's also available via MacPorts

Just execute it by running the command:

$ speedtest-cli


Retrieving speedtest.net configuration...
Testing from ACME Cable (xxx.xxx.xxx.xxx)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by ServerPronto (Miami, FL) [22.39 km]: 25.419 ms 
Testing download speed............................................................
Download: 70.16 Mbit/s
Testing upload speed............................................................
.Upload: 5.92 Mbit/s
Allan
  • 101,432
  • 1
    I think this is the simplest method, it doesn't need sudo privilege and the command will find nearest server to check the speed. It also display the distance of the server (in Kilometer) with my IP address).

    I'm using VPN, so Retrieving speedtest.net server list... and Selecting best server based on ping... processes need longer time.

    – Caldas Mar 09 '18 at 07:57
  • the command is not speedtest_cli, but speedtest-cli – Caldas Mar 11 '18 at 03:52
  • Also available at https://www.speedtest.net/apps/cli – lhf Nov 28 '21 at 12:00
28

If you have macOS Monterey or later in your system, here is how you can test Internet speed:-

  1. Go to Terminal
  2. Type networkQuality -v and Press Enter

You will see internet speed test running inside your terminal & returning the result within a minute.

Sample Output:-

==== SUMMARY ====                                                                                         
Upload capacity: 18.856 Mbps
Download capacity: 98.696 Mbps
Upload flows: 20
Download flows: 12
Responsiveness: Low (121 RPM)
Base RTT: 273
Start: 28/11/21, 1:06:09 AM
End: 28/11/21, 1:06:28 AM
OS Version: Version 12.0.1 (Build XXXXXX)

(Source: https://support.apple.com/en-gb/HT212313)

UPDATED:- In case you are willing to test in earlier versions of macOS, just run the following in your terminal.

curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -
7

Install iPerf3 from the developer: iPerf - The ultimate speed test tool for TCP, UDP and SCTP. This is a stand-alone cli, which doesn't require brew or MacPorts.

In the Terminal enter:

iperf3 -c <server-ip>

to get the upload speed/bandwidth and:

iperf3 -c <server-ip> -R

to get the download speed/bandwidth

You can get some public iPerf servers here: Public iPerf3 servers. Other servers are available by searching for iperf/iperf3 servers with Google.

I have tested this one: https://speedtest.wtnet.de/ (while watching TV online) with the following results:

iperf3 -c speedtest.wtnet.de -p 5200 -P 10 -4
...
[SUM]   0.00-10.00  sec  12.1 MBytes  10.1 Mbits/sec                  sender
[SUM]   0.00-10.00  sec  10.9 MBytes  9.17 Mbits/sec                  receiver

iperf3 -c speedtest.wtnet.de -p 5200 -P 10 -4 -R
...
[SUM]   0.00-10.00  sec  54.2 MBytes  45.5 Mbits/sec  558             sender
[SUM]   0.00-10.00  sec  51.8 MBytes  43.5 Mbits/sec                  receiver

The 558 in the third sum is the number of retransmitted TCP segments (Retr)!

klanomath
  • 66,391
  • 9
  • 130
  • 201
-1

Ping and traceroute are legendary unix utilities.

macworld’s explanation

TL;DR ping measures stats about a network path. Your computer/network switch/router/modem is connected to your internet provider/gateway. The gateway has an ip-address xxx.xxx. xxx.xxx, just like your computer and your router. Try

sudo time ping -s 1024 -c 1024 xxx.xxx. xxx.xx

This will send 1Kilobit 1024 times. Check the total time and do the math. 10 kilobits is roughly 1 kilobyte (due to parity checks).