Created
February 10, 2016 04:45
-
-
Save koniu/fa30f2afebf6b169e8eb to your computer and use it in GitHub Desktop.
scan method tests for openwrt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env lua | |
require("iwinfo") | |
require("socket") | |
-- config | |
IFACES = { 'wlan0', 'wlan1' } | |
SCANS = 5 -- number of iterations for every scan method | |
PRESCANS = 0 -- number of unaccounted scans to fill up buffers | |
WAIT_METHOD = 0 -- seconds of sleep before each method | |
WAIT_SCAN = 0 -- seconds of sleep before each scan | |
METHODS = { | |
iwinfo_lua_wext = function(iface) return #iwinfo.wext.scanlist(iface) end, | |
iwinfo_lua_nl = function(iface) return #iwinfo.nl80211.scanlist(iface) end, | |
iwinfo_cli = function(iface) return pread("iwinfo "..iface.." scan | grep Cell | wc -l") end, | |
iw_cli = function(iface) return pread("iw "..iface.." scan | egrep ^BSS | wc -l") end, | |
iwlist_cli = function(iface) return pread("iwlist "..iface.." scan | egrep Address: | wc -l") end, | |
} | |
-- helper functions | |
function pread(cmd) | |
local f = io.popen(cmd) | |
local o = f:read() | |
f:close() | |
return o | |
end | |
function sleep(t) | |
socket.select(nil, nil, t) | |
end | |
-- main loop | |
for i,iface in ipairs(IFACES) do | |
local typ = iwinfo.type(iface) | |
local drv = pread("ls /sys/class/net/"..iface.."/device/driver/module/drivers/") | |
print( | |
'######', | |
iface, | |
iwinfo[typ].phyname(iface), | |
iwinfo[typ].mode(iface), | |
typ, | |
drv, | |
'\n' | |
) | |
for m,method in pairs(METHODS) do | |
print(" ["..m.."]") | |
sleep(WAIT_METHOD) | |
-- prescan a few times to fill up buffers? | |
for n=1,PRESCANS do method(iface) end | |
-- scan and output stats | |
for n=1,SCANS do | |
sleep(WAIT_SCAN) | |
local tstart = socket.gettime() | |
local res = method(iface) | |
local tend = socket.gettime() | |
local tdelta = tend - tstart | |
local out = string.format(" %02d r: %02d t: %1.2fs", n, res, tdelta) | |
print(out) | |
end | |
print() | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###### wlan0 phy0 Client nl80211 pci:ath9k | |
[iwinfo_lua_wext] | |
01 r: 04 t: 1.69s | |
02 r: 04 t: 1.77s | |
03 r: 03 t: 1.76s | |
04 r: 03 t: 1.76s | |
05 r: 03 t: 1.77s | |
[iwinfo_lua_nl] | |
01 r: 03 t: 1.89s | |
02 r: 00 t: 1.67s | |
03 r: 00 t: 1.68s | |
04 r: 00 t: 1.68s | |
05 r: 00 t: 1.68s | |
[iwlist_cli] | |
01 r: 03 t: 1.74s | |
02 r: 03 t: 1.80s | |
03 r: 03 t: 2.01s | |
04 r: 03 t: 1.73s | |
05 r: 03 t: 1.86s | |
[iw_cli] | |
01 r: 04 t: 1.95s | |
02 r: 04 t: 1.77s | |
03 r: 04 t: 1.75s | |
04 r: 04 t: 1.76s | |
05 r: 04 t: 1.74s | |
[iwinfo_cli] | |
01 r: 04 t: 1.74s | |
02 r: 04 t: 1.72s | |
03 r: 04 t: 1.74s | |
04 r: 05 t: 2.00s | |
05 r: 05 t: 1.75s | |
###### wlan1 phy1 Client nl80211 usb:ath9k_htc | |
[iwinfo_lua_wext] | |
01 r: 19 t: 7.41s | |
02 r: 21 t: 7.40s | |
03 r: 21 t: 6.99s | |
04 r: 22 t: 7.08s | |
05 r: 23 t: 7.33s | |
[iwinfo_lua_nl] | |
01 r: 00 t: 7.31s | |
02 r: 20 t: 26.53s | |
03 r: 00 t: 6.96s | |
04 r: 21 t: 26.40s | |
05 r: 00 t: 6.87s | |
[iwlist_cli] | |
01 r: 21 t: 2.02s | |
02 r: 21 t: 1.65s | |
03 r: 21 t: 1.71s | |
04 r: 20 t: 3.80s | |
05 r: 22 t: 7.54s | |
[iw_cli] | |
01 r: 23 t: 7.25s | |
02 r: 23 t: 6.95s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment