Wi-Fi extensions to Speedtest

At WLPC in Prague I presented some scripts I’ve written to collect client data from Cisco WLCs via SNMP. A handful of people have asked for more details regarding one of my use cases: providing and logging connection data when a user runs speedtest from a Wi-Fi client.

How it’s done

When the user clicks the start button, the speedtest server picks up the client’s IP address and sends it in a UDP packet to a Wi-Fi lookup server, which uses my scripts to retrieve data from the wireless LAN controlllers. This data is returned to the speedtest server, and forwarded to the client browser as part of the normal speedtest response.

There’s some additional details, like what happens if the client is connected via cable, and syslog’ing of test results, but I’ll assume that’s below the noise floor. Look it up in the code or try it out if you’re interested. Or ask.

The code

The speedtest server extension (PHP code) is written by an ex-colleague of mine (who can contact me if he wants his name here), and inherits its license from the speedtest application (GPL). The Wi-Fi lookup code in Perl is mine, and it’s GPL’ed too.

The source code available here.

Installation

  1. The APtools scripts must be installed  and capable of retrieving data from Cisco WLCs. Copy the two additional Perl scripts into the same directory as aplist/apuser/apclients.
  2. Verify that lookups work locally, based on client IP address
  3. The PHP files are aligned with the speedtest version on the WLAN Pi. If that’s your speedtest server platform, copy them to /var/www/html/
  4. Adjust the speedtest files to your environment (see below).
  5. Adjust the Wi-Fi lookup files to your environment (ditto).

Adjustments

Determine a UDP port which gets through from your speedtest server to the Wi-Fi lookup server. In my environment the default 23456/udp is blocked by firewall/ACL, so I settled for 53/udp instead. Which is what DNS uses. Not very nice, I know.

Also, to use a port <1024 the Wi-Fi lookup server must be started as root. If that’s the case for you, change $suUser in speedtesterWiFiLookupSrv.pl from ‘wifimgr’ to a user that actually exists on the host.

conf_settings:php: change to the host and port of your Wi-Fi lookup server.

speedtest_worker.js: you may want to change getIp_ispInfo from ‘true’ to ‘false’ in line 52.

speedtesterWiFiLookupSrv.pl:
– in line 55-58 you may want to insert the paths as prefixes to the external programs
– change the reg.exp in line 65 (sub accessAllowed{…}) to the IP address of your speedtest server, i.e. /^(MY.IP.ADD.RESS)$/

And GO!

Start “speedtesterWiFiLookupSrv.pl rcvPort=yourUDPport debug=on”, and begin by verifying that the UDP packets flow from the speedtest server host to Wi-Fi lookup server and back. To do that, determine the IP address of a Wi-Fi client and use nc(1) in a terminal window with your server and port:
wlanpi@wlanpi: echo WI.FI.CLIENT.IP |nc -u lookupSrv lookupPort

If you get something back it should work with speedtest too.

Good luck!

Leave a Reply

Your email address will not be published. Required fields are marked *