Posts tagged with channel

Monitoring Wireless Channel Congestion

June 16th, 2008

While 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