oblique / create_ap

[NOT MAINTAINED] This script creates a NATed or Bridged WiFi Access Point.
BSD 2-Clause "Simplified" License
4.45k stars 1k forks source link

allow channel of 0 or acs_survey for automatic channel selection #435

Open dlenski opened 4 years ago

dlenski commented 4 years ago

This might be useful for some users. hostapd's “ACS survey mode” allows it to automatically select a channel based on WiFi interference:

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

TZubiri commented 4 years ago

Thank you! I just tried this on an old release and it didn't work. Good to know I'm not the only one, I'll pull this branch and update.

Would it be reasonable to change the default to acs instead of channel 1? I changed it from 1 to 11 because it was interfering with my neighboor, but later they switched to 11 as well. I doubt they have the knowledge to change or set channels, so their router probably defaulted to acs.

Dynamic frequency selection seems to be a more standard name for this feature, I would recommend anyone to use it, it looks like a tragedy of the commons scenario.

If we are going to build a layer on top of hostapd, we might as well provide opinionated defaults. But it's best to deploy it as an option first, and once it's well tested, push it as a default.

Regards.

TZubiri commented 4 years ago

root@devuan:~# pkill create_ap && /root/create_ap_acs/create_ap --country AR -c acs_survey --daemon --logfile /var/log/create_ap_acs wlan0 eth0 ssid password

This fails, the ap isn't created. If I change to the master branch and recompile with channel 11 instead of acs_survey it works correctly.

This are the logs:

root@devuan:~# cat /var/log/create_ap_acs
WARN: brmfmac driver doesn't work properly with virtual interfaces and
      it can cause kernel panic. For this reason we disallow virtual
      interfaces for your adapter.
      For more info: https://github.com/oblique/create_ap/issues/203
WARN: Your adapter does not fully support AP virtual interface, enabling --no-virt
Config dir: /tmp/create_ap.wlan0.conf.qG7UVJni
PID: 2874
Sharing Internet using method: nat
hostapd command-line interface: hostapd_cli -p /tmp/create_ap.wlan0.conf.qG7UVJni/hostapd_ctrl
Configuration file: /tmp/create_ap.wlan0.conf.qG7UVJni/hostapd.conf
Failed to create interface mon.wlan0: -95 (Operation not supported)
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
ACS: Automatic channel selection started, this may take a bit
wlan0: interface state COUNTRY_UPDATE->ACS
wlan0: ACS-STARTED 
ACS: Unable to collect survey data
ACS: All study options have failed
Interface initialization failed
wlan0: interface state ACS->DISABLED
wlan0: AP-DISABLED 
ACS: Possibly channel configuration is invalid, please report this along with your config file.
ACS: Failed to start
wlan0: AP-DISABLED 
hostapd_free_hapd_data: Interface wlan0 wasn't started
nl80211: deinit ifname=wlan0 disabled_11b_rates=0
wlan0: interface state DISABLED->DISABLED
wlan0: interface state DISABLED->DISABLED
wlan0: AP-DISABLED 
hostapd_free_hapd_data: Interface wlan0 wasn't started

Doing cleanup.. done

The relevant lines start with "ACS: Automatic channel selection started" the lines above are standard and expected in my setup.

Any idea what might have went wrong?

dlenski commented 4 years ago

ACS: Unable to collect survey data

It appears that your WiFi adapter simply doesn't support ACS… would be nice to be able to catch this and fallback automatically to CHANNEL=default.

TZubiri commented 4 years ago

Oh, I thought dfs was a purely logical routine? What kind of hardware support does it need? .

dlenski commented 4 years ago

I actually don't know :frown:. I found that I have the same error on another system with a standard nl80211 wifi driver.

I can't find much information on this error or whether it requires specific hardware support, or

https://unix.stackexchange.com/questions/350333/starting-hostapd-fails-acs-unable-to-collect-survey-data

TZubiri commented 4 years ago

I actually don't know :frown:. I found that I have the same error on another system with a standard nl80211 wifi driver.

I can't find much information on this error or whether it requires specific hardware support, or

https://unix.stackexchange.com/questions/350333/starting-hostapd-fails-acs-unable-to-collect-survey-data

The electrical and network stackexchanges seem more appropriate. https://electronics.stackexchange.com/questions/492694/can-all-wifi-emitters-dynamically-select-frequencies-or-is-specific-hardware-su

dlenski commented 4 years ago

The electrical and network stackexchanges seem more appropriate. https://electronics.stackexchange.com/questions/492694/can-all-wifi-emitters-dynamically-select-frequencies-or-is-specific-hardware-su

That question/questioner is quite confused, probably because the name is confusing.

DFS has little-to-nothing to do with selecting an optimal frequency for running your WiFi network. It's something that WiFi hardware has to do to avoid interfering with radar, because it's required by regulatory agencies, and it only applies to the 5 GHz band. A WiFi device can "comply" with DFS by switching to any ol' random non-DFS channel when it detects radar, or by completely powering down. Most hardware doesn't make much more effort than that, as far as I know. :man_shrugging:

ACS survey is a completely different process that's actually focused on finding the channel with least interference for WiFi communication.

I thought it was a purely software-driven process that relies on the hardware only for accurately detecting other networks, but perhaps that's not the case.