Test Wireless Signal Strength from Command Line of Mac OS X
If you’re trying to tweak a wireless router to get the best signal, being able to continuously measure the wi-fi signal strength while you toy with the antennas, placement, and whatever else on the network is really valuable. While most users are best served by using the Mac Wi-Fi Diagnostics app to monitor signal strength and performance, another option is to turn to the command line of Mac OS X, and that’s what we’re going to cover here.
This trick is based entirely from the command line using the somewhat secretive airport wireless tool, and it’s available on all Macs with all versions of Mac OS X. Yes the airport tool is still around and as useful as ever, even though wireless networking is now called Wi-Fi on the Mac.
Open the Terminal app to get started. For best results, you’ll probably want to increase the text size of your terminal font, the Command+ keystroke makes that easy.
How to Monitor Wi-Fi Signal Strength from Command Line on Mac OS X and View RSSI History
To see a running tally of signal strength use the following command, be sure the syntax is entered properly with no linebreaks (wrapping is ok) for this to function as intended:
while x=1; do /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep CtlRSSI; sleep 0.5; done
Hit return and you’ll start to see something like the following scrolling on screen:
agrCtlRSSI: -46
agrCtlRSSI: -48
agrCtlRSSI: -38
agrCtlRSSI: -44
This is your signal strength indicator, you’ll notice the last number of ‘agrCtlRSSI: -38’ should be changing frequently as it is printed repeatedly on your terminal screen. That number is the strength of your wi-fi signal coming from the router to your Mac.
You can stop this continuous signal monitoring command from refreshing by hitting Control+C at the Terminal window.
How to Test & Watch Wi-Fi Signal Strength on a Single Line in Mac OS X Terminal
If you don’t want to see a list of wireless signal strength with history (which makes it easy to tell if your adjustments are making things better or worse), you can also have the command report just a single line with signal strength. This can be helpful for scripting and customizing your shell, and may be preferential to some users in general. To have a single line of text, use the following syntax:
clear; while x=1; do /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep CtlRSSI | sed -e 's/^.*://g' | xargs -I SIGNAL printf "\rRSSI dBm: SIGNAL"; sleep 0.5; done
Again just hit Control+C to stop the command.
It’s worth remembering that wi-fi signal strength is impacted by many factors, including the power of the wireless router antenna, interference from local items and physical barriers like a chimney or microwave, radio signals, and much more. For best results, you’ll want to be sure you have chosen the best wi-fi channel for your network, easily possible with this Mac utility, so that the wi-fi broadcast channel has minimal nearby usage and interference.
I found both of above code samples on a long-gone forum page when searching for a way to do monitor signal strength, this was before the days of the Mac OS X Wireless Diagnostics Tool natively including such functionality, and they’ve been a big help when trying to position my wi-fi hardware for maximum reception quality. This command line approach works in all vaguely modern versions of Mac system software, and it’s still around in the latest releases too, including macOS Mojave, Catalina, Sierra, El Capitan, Mac OS X Mavericks, and others.
I wonder if there’s a way to get the NSS (number of spatial streams) via CLI. I haven’t been able to find it.
Instead of:
while x=1; do …
should do:
while true; do …
Avoids confusing the issue with an unnecessary variable.
wireless_perf.sh
——————
#!/bin/bash
# Header Definition
function header {
printf “%-19s %-10s %-7s %-5s %-5s %-5s %-4s %-4s\n” “Time” “SSID” “Channel” “MCS” “Max” “Rate” “RSSI” “Noise”
}
count=0
while true; do
# Every 20 entries, spit out the header again
if [[ $count%20 -eq 0 ]]; then
header
fi
# Gather details about wireless performance /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | gawk ‘
/agrCtlRSSI:/ { rssi=$NF }
/agrCtlNoise:/ { noise=$NF }
/lastTxRate:/ { lastrate=$NF }
/maxRate:/ { maxrate=$NF }
/SSID:/ { ssid=$NF }
/MCS:/ { mcs=$NF }
/channel:/ { channel=$NF }
END {
timestamp=strftime(“%Y/%m/%dT%H:%M:%S”)
printf(“%-19s %-10s %-7s %-5s %-5s %-5s %-4s %-4s\n”,timestamp,ssid,channel,mcs,maxrate,lastrate,rssi,noise)
}’
sleep 5
let count=$count+1
done
There’s another handy way to use this script:
while x=1; do /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep CtlRSSI | sed -e ‘s/^.*://g’ | say ; sleep 1; done
This will let my macbook read the signal strength out loud, while I’m tweaking the antenna in the other room ;-)
Thanks!
Does anyone know how you can get the signal strength of an iPhone connected to a WiFi network? If I open Airport Utility and look under: /Advanced/Logs and Statistics/Wireless Clients/ it shows me signal strength of clients connected to network, any way to get at this from command line? Thanks. :]
If you use this one often, you might want to symlink it as follows…
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/bin/airport
…so that “airport” is now symlinked into a directory within your $path, so subsequently instead of having to type out the full path, you can simply type e.g. “airport -I”