Wi-Fi channel auto-selection

On my device setting channel to auto sets channel=acs_survey in the generated hostapd-phyX.conf.

https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf

# If CONFIG_ACS build option is enabled, the channel can be selected
# automatically at run time by setting channel=acs_survey or channel=0, both of
# which will enable the ACS survey based algorithm.

You can verify the ACS algorithm in the log output from hostapd.
logread | grep hostapd | grep ACS

daemon.notice hostapd: ACS: Automatic channel selection started, this may take a bit
daemon.notice hostapd: wlan0: interface state COUNTRY_UPDATE->ACS
daemon.notice hostapd: wlan0: ACS-STARTED
daemon.notice hostapd: ACS: Automatic channel selection started, this may take a bit
daemon.notice hostapd: wlan1: interface state COUNTRY_UPDATE->ACS
daemon.notice hostapd: wlan1: ACS-STARTED
daemon.notice hostapd: wlan1: ACS-COMPLETED freq=2437 channel=6
daemon.notice hostapd: wlan1: interface state ACS->ENABLED
daemon.notice hostapd: wlan0: ACS-COMPLETED freq=5260 channel=52
daemon.notice hostapd: wlan0: interface state ACS->HT_SCAN

There are also other options supported, like:
acs_chan_bias, acs_exclude_dfs, chanlist

# acs_chan_bias is a space-separated list of <channel>:<bias> pairs. It can be
# used to increase (or decrease) the likelihood of a specific channel to be
# selected by the ACS algorithm. The total interference factor for each channel
# gets multiplied by the specified bias value before finding the channel with
# the lowest value. In other words, values between 0.0 and 1.0 can be used to
# make a channel more likely to be picked while values larger than 1.0 make the
# specified channel less likely to be picked. This can be used, e.g., to prefer
# the commonly used 2.4 GHz band channels 1, 6, and 11 (which is the default
# behavior on 2.4 GHz band if no acs_chan_bias parameter is specified).
#
# Defaults:
#acs_num_scans=5
#acs_chan_bias=1:0.8 6:0.8 11:0.8

But actually, I don't understand this option.
The total interference factor for each channel gets multiplied by the specified bias value. The total interference factor for each channel gets multiplied by the specified bias value before finding the channel with the lowest value
So it would make more sense if the bias value would be negative.

# Exclude DFS channels from ACS
# This option can be used to exclude all DFS channels from the ACS channel list
# in cases where the driver supports DFS channels.
#acs_exclude_dfs=1
# Channel list restriction. This option allows hostapd to select one of the
# provided channels when a channel should be automatically selected.
# Channel list can be provided as range using hyphen ('-') or individual
# channels can be specified by space (' ') separated values
# Default: all channels allowed in selected hw_mode
#chanlist=100 104 108 112 116
#chanlist=1 6 11-13

chanlist = channels in openwrt wifi config.

acs_exclude_dfs doesn't work on my device because the driver doesn't report DFS channels (correctly), I guess.

And chanlist/channels work better for me than acs_chan_bias.
option channels '1 6 11'
vs
option acs_chan_bias '1:0.8 6:0.8 11:0.8'

If your surrounding WiFis use a 4 Channel plan, like 1-5-9-13
It's better to use:
option channels '1 5 9 13'
or
option acs_chan_bias '1:0.8 5:0.8 9:0.8 13:0.8',
I guess.

I think, its also better to use chanlist/channels because acs_chan_bias allows hostapd to choose channels other channels then 1,6,11/1,5,9,13.
So maybe your wifi radio ends up using channel 3, which will cause (side-channel) interference for channels 1-6.
See this graphic here from cisco (3 channels plan):


4 Channels plan:

But most likely you will end up using the 3 channels plan because most devices are defaulting to it, even in Europe.
If you are setting up a wifi on large area where no other rogue WiFis are around you can of course deploy a 4 channels plan.

5 Likes

Are you running vanilla OpenWrt on that device?

Latest trunk version with no modifications to hostapd, so yes it's vanilla?

I can't find any commit log for acs_survey but for acs_chan_bias.

So there must be support for ACS at least since 2017?

acs_exclude_dfs was added this year.

So this will not work on stable OpenWRT release.

//edit
looking through the make files of hostapd and wpa-supplicant, like this for example:

#CONFIG_ACS=y

Seems like all makefiles have this line commented.
Idk why this feature is enabled.

1 Like

When you post a "this works for me" answer, I think it would be nice to disclose that you are using a snapshot, to avoid confusing users that are running a stable release.

1 Like

The mac80211.sh script in 18.06 has support for acs_survey, so it should work?

ACS is algorithm for channel selection ?
Which is better ACS or CCA ?

Short precise questions make one tick. I did my best to collect answers in the same manner.

ACS is algorithm for channel selection ?

Yes.

Which is better ACS or CCA ?

Those can not be compared. Supposed the acronyms mean what they are written to above, ie. Automatic Channel Selection (ACS) and Clear Channel Assessment (CCA).

ACS explained here: https://wireless.wiki.kernel.org/en/users/documentation/acs

CCA explained here (one source from many, the definitive being IEEE 802.11-2016 Standard): https://www.extremenetworks.com/extreme-networks-blog/what-is-a-clear-channel-assessment-cca/

Dynamic Frequency Selection (DFS) in channels on 5GHz is one more acronym affecting channel selection, description 1: https://forum.openwrt.org/t/wireless-config-channel-auto/1015/2 and description 2 https://en.wikipedia.org/wiki/Dynamic_frequency_selection.

A note: CCA and DFS are defined in 802.11 ammendments and standards, ACS seems not.

Disclaimer: I'm not an expert in 802.11 radios or standards, just a nerd trying to understand the pieces the 802.11 is made of and who's controlling what.

3 Likes

I got tired of having to change the channels due the surrounding AP's continuously moving over onto the same channel that I use, so I decided to try the auto channel. Despite everyone saying that that doesn't work and the first channel is always selected, that does not seem to be so. It is selecting channels and while I do not quite agree with the 2.4Ghz selection, the channels chosen for 5GHz are empty, so a good choice.

So, is this feature working or not? This is the latest 19.07 with non-ct firmware.

daemon.notice hostapd: ap2: ACS-STARTED
daemon.notice hostapd: ap2: ACS-COMPLETED freq=2462 channel=11
daemon.notice hostapd: ap2: interface state ACS->ENABLED
daemon.notice hostapd: ap2: ACS-STARTED
daemon.notice hostapd: ap5: ACS-STARTED
daemon.notice hostapd: ap2: ACS-COMPLETED freq=2412 channel=1
daemon.notice hostapd: ap2: interface state ACS->ENABLED
daemon.notice hostapd: ap5: ACS-COMPLETED freq=5300 channel=60
daemon.notice hostapd: ap5: interface state ACS->HT_SCAN
daemon.notice hostapd: ap2: ACS-STARTED
daemon.notice hostapd: ap5: ACS-STARTED
daemon.notice hostapd: ap2: ACS-COMPLETED freq=2412 channel=1
daemon.notice hostapd: ap2: interface state ACS->ENABLED
daemon.notice hostapd: ap5: ACS-COMPLETED freq=5260 channel=52
daemon.notice hostapd: ap5: interface state ACS->HT_SCAN
daemon.notice hostapd: ap5: ACS-STARTED
daemon.notice hostapd: ap5: ACS-COMPLETED freq=5300 channel=60
daemon.notice hostapd: ap5: interface state ACS->HT_SCAN
daemon.notice hostapd: ap5: ACS-STARTED
daemon.notice hostapd: ap2: ACS-STARTED
daemon.notice hostapd: ap2: ACS-COMPLETED freq=2412 channel=1
daemon.notice hostapd: ap2: interface state ACS->ENABLED
daemon.notice hostapd: ap5: ACS-COMPLETED freq=5300 channel=60
daemon.notice hostapd: ap5: interface state ACS->HT_SCAN
1 Like

Could it be enabled because of this:

./package/network/services/hostapd/Makefile

DRIVER_MAKEOPTS= \
        CONFIG_ACS=$(CONFIG_PACKAGE_kmod-cfg80211) \
        CONFIG_DRIVER_NL80211=$(CONFIG_PACKAGE_kmod-cfg80211) \
        CONFIG_IEEE80211N=$(HOSTAPD_IEEE80211N) \
        CONFIG_IEEE80211AC=$(HOSTAPD_IEEE80211AC) \
        CONFIG_DRIVER_WEXT=$(CONFIG_DRIVER_WEXT_SUPPORT) \

grep -r CONFIG_PACKAGE_kmod-cfg80211 .config
CONFIG_PACKAGE_kmod-cfg80211=y
2 Likes

I'm new to OpenWrt and have been running it for a couple of months on my R7800. Wifi auto channel selection seems to work when I reboot or restart a radio in Network->Wireless. Do any other events trigger channel auto selection?

Not really, channels are only chosen when the interface goes up or when a DFS event requires a change.

3 Likes

That's good to know. Thanks!

What happens if i use :

option channels '5 9 13 1'

Is there a way to add "random" time to activation or scan ? If there is a power cycle or if i reboot many Aps they will all start to scan with chan 5 as the first one.....

1 Like

With this setup i see that channels 1,9 and 13 are used.
APs seem to 'skip' 5 ?!?

How can i set 'acs_num_scans=10' via UCI ?

I just spent an hour reading @shm0 post 8 w/link and have concluded that the answer to your question is you don't configure this via any uci command.

the parameter and value you question; are meant to be carefully adjusted in the /var/run/hostapd-phy1.conf file of supporting acs devices on older OpenWrt builds.

I can not say confidently that all this has be deprecated by newer algorithms, yet the thread you necroed is quite old and the person you've quoted has been recently active.

2 Likes

Problem that i have is that even if i set "channels '1 5 9 13' most of APs in that area seem to "avoid" channel 5 and use either 1 , 9 or 13.
Also it's not that some would use 1 and some 13, but it seems that the majority "decides" to use 9 or 13...

and there you are looking at chann 5 and it's empty. And you see some 10+ aps using chan 9....

What could cause this ? Should i make wifi reload once a day or .... ?

Adding

uci add_list wireless.radio1.hostapd_options='acs_num_scans=50'
uci add_list wireless.radio0.hostapd_options='acs_num_scans=50'

does not help

nor adding to radio1 (2.4)

acs_chan_bias=5:0.5

When my only selection in chanlist is 5, then it works. :slight_smile:

Tried on OpenWrt 21.02 ... 22.03.4
MikroTiks or TPlink EAP225

Anything, but 5 :rage:

Any clues?

wireless.radio1.channel='auto'
wireless.radio1.channels='5 13 9 1'
wireless.radio1.hostapd_options='vendor_elements=DD080050F21101000000' 'acs_num_scans=25'