Monitoring Wireless Channel Congestion
June 16th, 2008While playing around with my wireless connection it occurred to me that there’s no way to see which channels are the busiest in my area. I know the command shown below lists all the scan details including the channel number for each router, but to see the most heavily congested channels I have to search the list manually.
$ /sbin/iwlist eth1 scan
It occurred to me that a simple python script could do the job, so here it is.
#! /usr/bin/python
# set to the number of channels available
MAX_CHANNEL=14
# enter your wireless device name
DEVICE="eth1"
import os
f=os.popen("/sbin/iwlist " + DEVICE + " scan")
str=f.read()
channel=range(1,MAX_CHANNEL+1,1)
for i in channel:
if i<10:
ch="0" + `i`
else:
ch=`i`
sChannel="(Channel " + `i` + ")"
print "Channel " + ch + ":" + `str.count(sChannel)`
f.close()
It simply runs the Linux command using popen, parses the output and counts the channels producing an output like this.
Channel 01:3 Channel 02:2 Channel 03:2 Channel 04:0 Channel 05:0 Channel 06:2 Channel 07:1 Channel 08:0 Channel 09:1 Channel 10:0 Channel 11:0 Channel 12:0 Channel 13:4 Channel 14:0
April 20th, 2009 at 7:44 pm
Thank you for this useful script.
I was thinking about to switch to a free channel to avoid interference.
July 19th, 2009 at 12:35 am
Don’t you also want to look at the signal levels and choose the channel with the smallest total, not the lowest count?
July 20th, 2009 at 9:31 am
Hi Rob,
ideally it should combine everything on the line:
Quality=63/100 Signal level=-51 dBm Noise level=-72 dBm
along with how busy each channel is to give a ‘suggested channel’
Maybe I’ll look at that in future.
Bob Peers