Is there an API or software to get accurate strength of a WiFi signals on Mac?

1.5k Views Asked by At

Is there an API, shell command or AppleScript for getting an accurate reading of the current WiFi strength in Mac OSX?

FYI I can also open a browser and use JavaScript if it has that value available.

What I'm trying to do is check WiFi strength for different spots in my kitchen or living room. I need to check WiFi strength for each spot. If it's low I move to a new spot. The WiFi bars that OSX displays is not enough data for me.

4

There are 4 best solutions below

7
On BEST ANSWER

There is a built-in airport command which will do it. It's location is:

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport

For convenience, you can create a link which will let you run the command from anywhere.

 sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport

To get info about the current wireless network

airport -I

http://osxdaily.com/2007/01/18/airport-the-little-known-command-line-wireless-utility/

Assuming you've created the link, an AppleScript that converts the value to percentage and displays a notification:

set wirelessRSSI to do shell script "airport -I | grep CtlRSSI | sed -e 's/^.*: //g'"
set wirelessStrength to (wirelessRSSI + 100) * 2
display notification "Wireless sigal quality: " & wirelessStrength & "%"
0
On

Here's a simple Python script which uses the CoreWLAN framework:

#!/usr/bin/python

from AppKit import CWInterface

IFACE = 'en0'
NAME  = 'MyWifiNetwork'

interface      = CWInterface.interfaceWithName_(IFACE)
results, error = interface.scanForNetworksWithName_error_(NAME, None)

for result in results:
    print 'SSID:', result.ssid()
    print 'RSSI:', result.rssiValue()
4
On

I must admit that I don't know whether OS X has information like a received strength indicator easily accessible.

What I can tell you from an RF communication's engineer's perspective is that the displayed signal strength is everything but accurate, and it's even less usable to really predict how well communication will work.

As you said, the bars aren't enough information for anyone -- and the fact that there are already five different amounts of bars you can have usually greatly exaggerates the accuracy with which these things are available to the operating system. WiFi quality is so much more than received signal strength that you can't directly map bars to quality. I really don't know why GUIs keep including that measure instead of e.g. a measure of how many packets get lost along the way (which is actually something that an OS can observer).

I assume you want to do something like "if WiFi A is weak, switch to WiFi B", or similar. I think the right way to do that is actually two steps up the OSI layer model, at least. I'd personally just set up a server somewhere on the internet that replies to UDP packets and is pingable. Then, you'd just use standard ping to figure out whether latency is still acceptable, and use short UDP to the server packets to figure out how much packet loss you see (you can do that via ping and ICMP, too, but that won't normally allow you to send a couple of hundred packets per second -- which is what I'd do periodically).

4
On

This is an well-hidden gem. Just navigate in the Finder to the folder

/System/Library/CoreServices/Applications

and run the

Wireless Diagnostics.app

It has many builtin tools.

Before you click "Continue" (in the 1st window) you should check the "Window" menu for the available tools:

  • WiFi sniffer of an exact channel ⌘6
  • Performance analyser (signal/Noise) ⌘5
  • Wifi scanner (available networks) ⌘4
  • Logger of some protocols (like DHCP, DNS etc) ⌘3
  • Info about the connected WiFI ⌘2 (same as when you Alt-click on the menubar WiFi)

Reply about 1.21 Gigawatts concerns

About the above tools:

  • The report is collected only if you click the "continue" button in the 1st screen.
    • As i told above, you not need to click it.
    • You can use the tools without collecting any report.

About report sending:

  • The app warns you about the data collecting.
  • The report is placed into your desktop. (as a file called date_string.wdmon)
  • The app doesn't sends any part of the report to Apple automatically.
  • You can send it to apple, if want - me personally doesn't want too. :)
  • If the user is stupid enough to double-click on the report file (what triggers the report-sending), after he, reads the warnings on the 1st screen it is his own fault.
  • you can monitor yourself what outgoing connections are done

Summary:

  • you don't need even start the report collecting. (simply don't click the continue button)
  • you can use the tools without the report-collecting - they're available in the Window menu as I told it already in my answer.
  • don't double-click on the files if you don't know what's happens

Warning users about the data collection is a good thing. Thank you for your explicit warning.