Category Archives: Random Thoughts

DD-WRT Command Line Wireless Scanning

A handy script for scanning wireless signals from the DD-WRT command line found at:
http://www.karlosp.net/blog/2008/07/31/wireless-network-scanner-working-on-dd-wrt-v24/

Either telnet or SSH into router (PuTTY is a great tool for both:  http://www.chiark.greenend.org.uk/~sgtatham/putty/ ), then paste in:

#!/bin/sh

awk -F”[][]” ‘
BEGIN{
IGNORECASE = 1;
command = “site_survey 2>&1”;
red = “\x1b[31m”; green = “\x1b[32m”;
greenback=”\x1b[42m”; yellow = “\x1b[33m”;
cyan = “\x1b[36m”; blue = “\x1b[34m”;
blueback = “\x1b[44m”; white = “\x1b[37m”;
whiteback = “\x1b[47m”; reset = “\x1b[0m”;
underscore = “\x1b[4m”; clear = “\x1b[2J”;
home = “\x1b[0;0H”; erase2end = “\x1b[K”;
cName = white; cSignal = green;
cNoise = red; cCaps = green;
cStrengthLow = blue blueback; cChannel = green;
cStrengthMed = white whiteback;
cStrengthHi = green greenback;
cStrengthAged = red;

print clear;
for(;;)
{
while (command|getline)
{
if ($22 == “”) continue;
bssid=$6;
name[bssid] = $4;
rssi[bssid] = $10;
noise[bssid]= $12;
channel[bssid] = $8;
caps[bssid] = $22;
age[bssid] = 1;
}
close(command);
printf home;
ln = 0;
print white ” Name BSSID Signal Noise Channel Type”;
for (x in name)
{
#arbitrary strength calc through trial and error… modify as you wish:
sigstrength = ((rssi[x] – noise[x])*1.5) + ((rssi[x] +90)*1.5);
if (sigstrength <1) sigstrength=0; cStrength = cStrengthLow; if(sigstrength>4) cStrength = cStrengthMed;
if(sigstrength>7) cStrength = cStrengthHi;
if(age[x]=0) cStrength = cStrengthAged;
fmt = “%s%-15s %s%0″sigstrength”d “reset erase2end “\n %s %s%-4d %s%-4d %s%-4d %s%2s ” reset erase2end “\n” erase2end “\n”;
printf fmt, cName,name[x],cStrength,0,x,cSignal,rssi[x],cNoise,noise[x],cChannel, channel[x],cCaps,caps[x];
rssi[x] = “-100 xxxx”;
ln++;
}
if (ln ==0)
print red “No Results – Do you have survey capability? \nThis program depends on site_survey to run. Hit ctrl-c to stop.”;

print erase2end;
}
}