poweredlocal / openwrt-auto-channel-select Goto Github PK
View Code? Open in Web Editor NEWAutomatic Wi-Fi channel selection script for OpenWRT and supported systems
License: MIT License
Automatic Wi-Fi channel selection script for OpenWRT and supported systems
License: MIT License
When I'm running the script on an LEDE powered router I'm getting
root@OpenWrt:~# ./setAutoChannel.sh 0
Iteration 1
Iteration 2
Iteration 3
Channel 1 has an average of 0 networks
Channel 6 has an average of 0 networks
Channel 11 has an average of 0 networks
Setting channel to 1
but the result of iw wlan0 scan is:
root@OpenWrt:~# iw wlan0 scan
BSS e8:94:f6:cc:44:3d(on wlan0)
TSF: 1869218724 usec (0d, 00:31:09)
freq: 2412
beacon interval: 100 TUs
capability: ESS (0x0431)
signal: -71.00 dBm
last seen: 890 ms ago
Information elements from Probe Response frame:
SSID: drahtlos nicht ratlos
HT capabilities:
Capabilities: 0x1ad
RX LDPC
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: No restriction (0x00)
HT RX MCS rate indexes supported: 0-15
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 1
* secondary channel offset: no secondary
* STA channel width: 20 MHz
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
BSS bc:05:43:ab:37:76(on wlan0)
TSF: 2286763344 usec (0d, 00:38:06)
freq: 2412
beacon interval: 100 TUs
capability: ESS (0x0431)
signal: -79.00 dBm
last seen: 980 ms ago
SSID: sdt.net 33298
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
HT capabilities:
Capabilities: 0x13ce
HT20/HT40
SM Power Save disabled
RX HT40 SGI
TX STBC
RX STBC 3-streams
Max AMSDU length: 3839 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-15
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 1
* secondary channel offset: above
* STA channel width: any
BSS 04:c0:6f:a2:16:b3(on wlan0)
TSF: 476191568154 usec (5d, 12:16:31)
freq: 2437
beacon interval: 100 TUs
capability: ESS (0x0411)
signal: -81.00 dBm
last seen: 590 ms ago
SSID: WLAN-B1A7E9
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
BSS f4:30:b9:1f:ff:48(on wlan0)
TSF: 5876737280910 usec (68d, 00:25:37)
freq: 2437
beacon interval: 100 TUs
capability: ESS (0x0511)
signal: -87.00 dBm
last seen: 600 ms ago
SSID: DIRECT-47-HP OfficeJet 4650
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
HT capabilities:
Capabilities: 0x20
HT20
Static SM Power Save
RX HT20 SGI
No RX STBC
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 32767 bytes (exponent: 0x002)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-7
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 6
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS bc:f2:af:e3:d2:7a(on wlan0)
TSF: 27822871061 usec (0d, 07:43:42)
freq: 2437
beacon interval: 100 TUs
capability: ESS (0x0431)
signal: -82.00 dBm
last seen: 600 ms ago
SSID: devolo-bcf2afe3d27a
HT capabilities:
Capabilities: 0x11ef
RX LDPC
HT20/HT40
SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: No restriction (0x00)
HT RX MCS rate indexes supported: 0-15
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 6
* secondary channel offset: no secondary
* STA channel width: 20 MHz
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
BSS c8:51:95:8c:a2:7a(on wlan0)
TSF: 72038824076 usec (0d, 20:00:38)
freq: 2462
beacon interval: 100 TUs
capability: ESS (0x0411)
signal: -69.00 dBm
last seen: 120 ms ago
Information elements from Probe Response frame:
SSID: WLAN1-000531
RSN: * Version: 1
* Group cipher: TKIP
* Pairwise ciphers: CCMP TKIP
* Authentication suites: PSK
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
HT capabilities:
Capabilities: 0x19bc
HT20
SM Power Save disabled
RX Greenfield
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 7935 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 32767 bytes (exponent: 0x002)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-15
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 11
* secondary channel offset: no secondary
* STA channel width: 20 MHz
BSS 38:10:d5:b7:6a:cf(on wlan0)
TSF: 132239580368 usec (1d, 12:43:59)
freq: 2462
beacon interval: 100 TUs
capability: ESS (0x0431)
signal: -86.00 dBm
last seen: 210 ms ago
SSID: WLAN
HT capabilities:
Capabilities: 0x1ad
RX LDPC
HT20
SM Power Save disabled
RX HT20 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
No DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT TX/RX MCS rate indexes supported: 0-23
HT operation:
* primary channel: 11
* secondary channel offset: no secondary
* STA channel width: 20 MHz
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
BSS 34:31:c4:d8:58:d6(on wlan0)
TSF: 12097715968384 usec (140d, 00:28:35)
freq: 2462
beacon interval: 100 TUs
capability: ESS (0x0431)
signal: -89.00 dBm
last seen: 200 ms ago
Information elements from Probe Response frame:
SSID: FRITZ!Powerline 546E
HT capabilities:
Capabilities: 0x11ef
RX LDPC
HT20/HT40
SM Power Save disabled
RX HT20 SGI
RX HT40 SGI
TX STBC
RX STBC 1-stream
Max AMSDU length: 3839 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT TX/RX MCS rate indexes supported: 0-15
HT operation:
* primary channel: 11
* secondary channel offset: below
* STA channel width: any
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
so there are definitely several WLAN on channels 1,6 and 11 around.
Why is it then the script is not recognizing those ?
I'm trying to run this on an OpenWrt 21.02.2 router, but I'm getting a lot of:
ash: -a: unknown operand
I'm guessing that this is due to constructs such as:
if [[ "$FIRST" == "*" -a "$SIGNAL" != "NO" ]]; then
on line 32. As far as I can tell:
[[
is a bashism,
[[
is not defined by posix, and
[[
behaves as though it were [
under busybox.
Good Afternoon -
I live in a neighborhood with many APs and found then script when searching for something specifically like it. After testing, I planned to implement to run via cron to hopefully stay on the best channel. Unfortunately, either I'm not doing something correctly or there's an issue with the script as I'm having two issues:
Issue 1: Not Setting Channel
After downloading & running chmod on the script, I executed "./setAutoChannel.sh 0" (my 2.4ghz wlan1 interface) via SSH which echoed the below:
Iteration 1
Iteration 2
Iteration 3
Channel 1 has an average of 0 networks
Channel 6 has an average of 0 networks
Channel 11 has an average of 0 networks
Setting channel to 1
root@KNGateway:~# ./setAutoChannel.sh 1
Iteration 1
Iteration 2
Iteration 3
Channel 1 has an average of 1 networks
Channel 6 has an average of 1 networks
Channel 11 has an average of 0 networks
Setting channel to 11
After this, I went into LUCI and looked up that interface, but it was still on the channel it was on prior to running the script:
Mode: Master | SSID: XXXXXXXX
BSSID: XX:XX:XX:XX:XX:XX
Encryption: WPA2 PSK (CCMP)
Channel: 2 (2.417 GHz)
Tx-Power: 30 dBm
Signal: -55 dBm | Noise: -85 dBm
Bitrate: 83.4 Mbit/s | Country: US
Issue 2: Not Finding all APs
The echo above shows that the scan seemingly detected 2 2.4Ghz networks on channel 1 & 6. However, when performing a site survey, I see many more as shown in the attached screenshot.
Finally, it fixing those two is simple, 5Ghz support would be great too as the screenshot has a whole other page of 5Ghz APs which is much more crowded.
Any suggestions? Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.