Sunday, 4 December 2011

Selecting a good Channel for your WiFI, or how to find the WiFi spectrum around you.

why my wifi router in channel 6 is not working properly?..... well seems obvious

root@debian:/home/pablo# iwlist scan | grep Channel
                    Frequency:2.417 GHz (Channel 2)
                    Frequency:2.417 GHz (Channel 2)
                    Frequency:2.412 GHz (Channel 1)
                    Frequency:2.412 GHz (Channel 1)
                    Frequency:2.422 GHz (Channel 3)
                    Frequency:2.422 GHz (Channel 3)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.462 GHz (Channel 11)
                    Frequency:2.462 GHz (Channel 11)
                    Frequency:2.412 GHz (Channel 1)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.442 GHz (Channel 7)
                    Frequency:2.442 GHz (Channel 7)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.412 GHz (Channel 1)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.412 GHz (Channel 1)


I know that there are nice applications to see the the WiFi stations but this is something quick when you don't have the X's started (I like Arch sometimes and my debian without Xs in very old laptops)

root@debian:/home/pablo# iwlist scan | grep "ESSID\|Channel"| \
 perl -lane '($essid)=/ESSID:(.+)/; ($channel)= <>=~/Channel (\d+)/; \
 push @{$h{$channel}}, $essid;  END {print "Chnl\tcount\tESSIDs"; \
foreach (sort {$a<=>$b} keys %h){ $cnt=@{$h{$_}}; \
 print "$_\t[$cnt]\t @{$h{$_}}"}}'

Chnl count ESSIDs
1 [4]  "SKYC4E76" "TALKTALK-431FCD" "SISJ_Net" "virgin broadband"
3 [2]  "FON_ab" "my_place_ab"
6 [8]  "BTHomeHub2-2RQK" "BTOpenzone-H" "BTFON" "SKY8430D" "SKY74103" "ZyXEL_3340ras" "BTHomeHub2-MWCS" "VirginMedia8791617"
7 [1]  "BTOpenzone-H"
11 [2]  "BTHomeHub2-349C" "SKY97946"