Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number of wireless clients in AP mode is very limited #3010

Open
martignoni opened this issue Jun 11, 2019 · 71 comments
Open

Number of wireless clients in AP mode is very limited #3010

martignoni opened this issue Jun 11, 2019 · 71 comments

Comments

@martignoni
Copy link

martignoni commented Jun 11, 2019

I'm reporting this on Jamesh's advice (see this forum discussion).

Describe the bug
On RPi 3B+, on can expect an optimistic max. of 20-30 devices connected simultaneously via Wi-Fi, even when no under-voltage event occurs.

To reproduce
Use case: the RPi serves as a wifi AP and a web server, that's all. No user is logged in the RPi in production use. An official Raspberry Foundation power supply and cable is used, so that no under-voltage event occurs.

Nginx and php-fpm are optimized so that memory is not a problem. Flooding the web server using ApacheBench shows that memory is not a problem: available memory remains at around 600M at any time, even with 100 concurrent http requests! Swap is never used.

The limitation experienced is uniquely caused by concurrent wifi connections to the AP (hostapd). For that reason, I'm suspecting it's a wifi driver issue.

Expected behaviour
More client devices than a mere 20 can be simultaneously connected to the RPi in AP mode.

Actual behaviour
When about 20 devices are connected to the RPi in AP mode, the RPi freezes.

System

  • Model: Pi3B+
  • OS and version: Raspberry Pi reference 2019-04-08
  • Firmware: version 2e98b31d18547962e564bdf88e57b3df7085c29b (clean) (release) (start_cd)
  • Kernel: Linux moodlebox 4.19.42-v7+ system freeze while unplug r8152 usb2network card #1219 SMP Tue May 14 21:20:58 BST 2019 armv7l GNU/Linux

Logs
Not applicable.

Additional context
This is the content of my /etc/hostapd/hostapd.conf:

# Set country code
country_code=US
# Name of the Wi-Fi interface
interface=wlan0
# Use the nl80211 driver
driver=nl80211
# Wi-Fi network name (SSID)
ssid2=4d6f6f646c65426f78
utf8_ssid=1
# Show or hide SSID
ignore_broadcast_ssid=0
# Use the 2.4GHz band
hw_mode=g
# The Wi-Fi channel
channel=11
# Enable 802.11n
ieee80211n=1
# Enable WMM
wmm_enabled=1
# Enable 40 MHz channels with short guard interval for 20 Mhz
#ht_capab=[MAX-AMSDU-3839][HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
# Accept all MAC addresses
macaddr_acl=0
# Use WPA authentication
auth_algs=1
# Use WPA2
wpa=2
# Use a pre-shared key
wpa_key_mgmt=WPA-PSK
# The network passphrase
wpa_passphrase=moodlebox
# Use AES, instead of TKIP
rsn_pairwise=CCMP
# Enable hostapd_cli
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
@martignoni martignoni changed the title Wireless clients in AP mode is very limited Number of wireless clients in AP mode is very limited Jun 11, 2019
@Choupinounours
Copy link

Mhhh I meet the same problem ! Could be really useful to fix it !

@marcusdiy
Copy link

I can connect only 9 devices with RPi 3B+ ...

@marcusdiy
Copy link

marcusdiy commented Jul 28, 2019

Seems like every time, before reaching the quota, there is like some kind undervoltage issue...

Jul 28 20:49:07 dnsmasq-dhcp[896]: DHCPACK(ap0) 10.3.141.110 xx:xx:xx:xx:xx:xx HUAWEI_P9_lite
Jul 28 20:49:12 spherae kernel: [ 440.556265] Under-voltage detected! (0x00050005)
Jul 28 20:49:16 spherae kernel: [ 444.716262] Voltage normalised (0x00000000)
Jul 28 20:49:21 dnsmasq-dhcp[896]: DHCPDISCOVER(ap0) xx:xx:xx:xx:xx:xx
Jul 28 20:49:21 dnsmasq-dhcp[896]: DHCPOFFER(ap0) 10.3.141.108 xx:xx:xx:xx:xx:xx
Jul 28 20:49:21 dnsmasq-dhcp[896]: DHCPREQUEST(ap0) 10.3.141.108 xx:xx:xx:xx:xx:xx
Jul 28 20:49:21 dnsmasq-dhcp[896]: DHCPACK(ap0) 10.3.141.108 xx:xx:xx:xx:xx:xx Galaxy-S7
Jul 28 20:50:48 spherae kernel: [ 536.727290] brcmfmac: send_key_to_dongle: wsec_key error (-52)

I'm using a duracell power bank rated for 2.4A, with no peripherals other than a LAN cable

@martignoni
Copy link
Author

martignoni commented Jul 28, 2019

@marcusdiy You should absolutely be certain to use a adequate power supply and cable before any testing, so that not under-voltage issue occurs in these testing.

I'll edit my bug report to positively indicate that a limited number of clients occurs even when no under-voltage event occurs.

Edit: though, thank you for the confirmation that under-voltage has an drastic effect on the number of wireless clients

@christian-westphal
Copy link

RPI is a very nice plateform for a lot of "boxes" (moodlebox, piratebox etc) so this resolution willy be very usefull...

Thanks

@marcusdiy
Copy link

I were able to connect more than 20+ devices using ubuntu mate + snap wifi-ap
It is some kind of software limit that we got there...

@ghost
Copy link

ghost commented Nov 14, 2019

Any news about this?

I manage to get exactly 19 connections on a Rpi 3b and 14 connections on a Rpi 3b+ with the following hostapd conf on Raspbian Stretch:

interface=wlan0
driver=nl80211
ssid=xxxx
hw_mode=g
channel=7
macaddr_acl=0
auth_algs=3

I will soon proceed to new tests on Raspbian Buster.

@pelwell
Copy link
Contributor

pelwell commented Nov 14, 2019

Both 43438 and 43455 are designed for "mobile or handheld wireless system[s]". As such, 19 and 14 sounds pretty good. I suspect they both have relatively small RAMs that also need to contain the firmware, so resources are going to be limited.

@leond08
Copy link

leond08 commented Mar 9, 2020

any news about this?

@martignoni
Copy link
Author

Some reports seem to indicate that the issue is worse on RPi 4 hardware, where max. number of wireless clients is sometimes less than 10!

Ref: https://discuss.moodlebox.net/d/198-wifi-client-advice/6

@ghost
Copy link

ghost commented Aug 18, 2020

Same results here, 8 devices connected with a Rapsberry Pi 4 on Buster... but same with a 3b+
Having a few Rapsberry Pi in production for more than a year now with hostapd, the real dropdown in number of users connected simultaneously was seen by upgrading from Stretch to Buster.

@fabrizioromanelli
Copy link

Some reports seem to indicate that the issue is worse on RPi 4 hardware, where max. number of wireless clients is sometimes less than 10!

Ref: https://discuss.moodlebox.net/d/198-wifi-client-advice/6

In my case I have a Raspberry Pi 4, I have tried your same configuration for /etc/hostapd/hostapd.conf and can connect just 5 devices simultaneously. As soon as I disconnect a device, another one can connect without any problem. All the devices are in range.

@greenorca
Copy link

greenorca commented Oct 13, 2020

Same problem here on Raspi4. Hostapd worked well when testing with 2 clients back home, failed utterly when using it in school during my Web-Dev class...

If there is any information I can provide to help solving this issue, pls let me know.
Many thanks!

@andrew-d-l-nelson
Copy link

I have also just encountered this issue with a Raspi4 (both 4 and 8 GB ram) using Buster. Can't get more than 7 other raspis to connect... Also, I don't know if this is pertinent, but it seems like power save mode is automatically enabled for the brcm wifi driver. I saw in earlier iterations that this may cause clients to get dropped?

@brandonyb
Copy link

I am using Raspberry Pi 4 (1 GB Ram), and only able to connect 1 client to it...

@guillain
Copy link

guillain commented Dec 19, 2020

Hi,

Same issue, no more than 8 devices connected in same time on Raspbian with RaspAP :(

Even if I can put some devices on sleep and wait events to wake up them, others devices need permanent connection (like the camera).

Apparently people have successfully connected close to 20 devices (my target for the number of device connected in same time).
https://raspberrypi.stackexchange.com/questions/50162/maximum-wi-fi-clients-on-pi-3-hotspot

Any idea/workaround to move forward ? because apparently this will not be fixed in 2020 ^^

Thanks and take care!

@pelwell
Copy link
Contributor

pelwell commented Dec 19, 2020

I think there is no possibility of a "fix" - every change to the firmware (vulnerability patch, etc.) takes up more of the limited RAM, resulting in less space to host AP clients. If you really care about AP clients then you'll have to either use an old firmware or buy a USB dongle (which might give you higher performance as well).

@ziesemer
Copy link

I think there is no possibility of a "fix" - every change to the firmware (vulnerability patch, etc.) takes up more of the limited RAM, resulting in less space to host AP clients.

Can we please clarify, is this system RAM, or RAM specific to the chipset / wireless chip? I.E., having a Pi with 1 vs. 8 GB of RAM doesn't seem to make any difference here?

@pelwell
Copy link
Contributor

pelwell commented Dec 19, 2020

The RAM on the WiFi part, into which the firmware is loaded, and which is also used for the running state of the device.

@huan
Copy link

huan commented Dec 20, 2020

buy a USB dongle (which might give you higher performance as well).

@pelwell using a USB dongle is considering an alternative solution for me.

Could you please share which USB dongle can handle more wifi clients, with brand and model specs?

Thank you very much!

Update

I have an answer on StackExchange for the question Maximum Wi-Fi clients on Pi

@ziesemer
Copy link

Could you please to share which usb dongle can handle more wifi clients, with brand and model specs?

FYI, there is the reference at https://elinux.org/RPi_USB_Wi-Fi_Adapters . It would be nice to see included a number of supported WiFi clients, etc. - might be a good place to start. Would also be nice to have a cross-reference as to which support various features such as which wireless bands and WiFi versions are supported in AP mode, which support external antennas, etc.

I previously had high hopes of using a "utility" Pi that I carry in my bag as a "can meet any need" device. Given these issues, I had to also include a separate "travel router" for serving as an AP. It easily serves 12+ WiFi clients, but the CPU was lacking for NAT + routing. I could use the 2 together, and use the travel router as just a "dumb AP", and then let the Pi do the rest of the networking - but it would be nice to consolidate this all together.

I'm also interested in any specific product recommendations here.

@guillain
Copy link

guillain commented Dec 23, 2020

Yep,

Since my message I've buyed the USB key BossTrend AC1200 based on the chipset RTL8812AU and now I've ~15 devices connected without issue.

It works like a charm with the driver https://github.com/cilynx/rtl88x2bu.git.
Just one thing to monitor, after reboot an high process consumption:

  • RTW_CMD_THREAD
  • writing commands to Realtek-based network devices
  • ~25% of CPU
  • 2/3 minutes

If I've new I'll let you know there.

Enjoy and take care.

@ericbeaudry
Copy link

buy a USB dongle (which might give you higher performance as well).

@pelwell using a usb dongle is considering an alternative solution for me.

Could you please to share which usb dongle can handle more wifi clients, with brand and model specs?

Thank you very much!

Got hit by that new limitation too. The maximum Wifi connection I've reached on a Pi4 is 7 as opposed to about 30 on a Pi3 18 months ago. I have no idea where and why that limitation got added but it's rendering the Pi pretty useless in my scenario.
On the bright side, I ordered a couple of external antennas with the RT5370 chipset (no driver to install with this chipset) and the first I plugged in is already sustaining 21 steady connections. I intend to push and see the limit in the next couple of days. Here's the antenna that looks promising RT5370 Antenna

@ziesemer
Copy link

@guillain and @ericbeaudry - Could each of you please share which Pi and OS versions you are seeing your latest results with?

@guillain
Copy link

guillain commented Dec 23, 2020

Hi Ziesemer,
You've it there: #3010 (comment)

@martignoni
Copy link
Author

@ericbeaudry says:

Got hit by that new limitation too. The maximum Wifi connection I've reached on a Pi4 is 7 as opposed to about 30 on a Pi3 18 months ago.

This leads to think there's indeed something wrong either in Pi4 hardware or in Raspberry Pi OS or drivers (which is the purpose of this issue). Humbly suggesting we stick to this, and talk about dongles elsewhere (e.g. on RPi forums).

@ziesemer: I'm getting poor results with RPi4 since many versions of Raspberry Pi OS, and disappointing results with RPi 3B too (see #3010 (comment)). But I could not test on a large scale if the new wifi drivers shipped with last image (version 2020-12-02) have changed anything. I'd be glad to have some feedback about this.

@Bec-k
Copy link

Bec-k commented Jan 14, 2022

Have you tried the "minimal" firmware? It supports up to 19 clients.

https://github.com/RPi-Distro/firmware-nonfree/tree/bullseye/debian/config/brcm80211/cypress

Daaamn, it is really working. Thank you very much, for sharing this, but in any case, i need to consider some better wifi-adapter, this will be fine as a temporary fix. Solution is not for production for sure.

@XECDesign
Copy link
Contributor

@pelwell Any idea how frequently that firmware is used? Since apt updates to the package will overwrite the user's changes, I was wondering whether it's worth adding and documenting a mechanism to switch between them properly (https://wiki.debian.org/DebianAlternatives).

@pelwell
Copy link
Contributor

pelwell commented Jan 14, 2022

If there is a recognised way to support such user choices then that would be awesome - the priority was to get the firmware out there.

@JamesH65
Copy link
Contributor

Have you tried the "minimal" firmware? It supports up to 19 clients.
https://github.com/RPi-Distro/firmware-nonfree/tree/bullseye/debian/config/brcm80211/cypress

Daaamn, it is really working. Thank you very much, for sharing this, but in any case, i need to consider some better wifi-adapter, this will be fine as a temporary fix. Solution is not for production for sure.

Can I ask why you think this is not suitable for production?

@chradams
Copy link

With a Raspberry Pi Zero W Linux 5.10.60+ armv6l getting about 10 clients. 9 ESP32 devices and a Windows 10 desktop.
The 10th ESP32 is reporting a WiFi disconnect, Reason: 2 - AUTH_EXPIRE
During this interval an Android phone also is unable to connect as the 10th or 11th device.
Goal would be for 30 clients on a Raspberry Pi AP.
Might try the suggested FW to at least observe results.

@pelwell
Copy link
Contributor

pelwell commented Jan 14, 2022

The Zero W is a different WLAN chip - less capable than the 43455, and not compatible with its firmware.

@pelwell
Copy link
Contributor

pelwell commented Jan 14, 2022

Goal would be for 30 clients on a Raspberry Pi AP.

You can set your goal as high as you like, but it's not achievable on what is essentially a 10 year old mobile phone class WLAN chip.

@Bec-k
Copy link

Bec-k commented Jan 14, 2022

Have you tried the "minimal" firmware? It supports up to 19 clients.
https://github.com/RPi-Distro/firmware-nonfree/tree/bullseye/debian/config/brcm80211/cypress

Daaamn, it is really working. Thank you very much, for sharing this, but in any case, i need to consider some better wifi-adapter, this will be fine as a temporary fix. Solution is not for production for sure.

Can I ask why you think this is not suitable for production?

Because it is not yet tested by me for some period of time. Time will show. :)

@briantbutton
Copy link

Just to say: @pelwell, thank for 'cyfmac43455-sdio-minimal.bin'. Exactly what the doctor ordered. Grateful for that. We popped it in and will start testing today.
For the record, our environment is Ubuntu 22.04, the installation is done with scripts and we do not allow unattended upgrades. So this will be great if it works as intended.

@dave-andersen
Copy link

btw, just to make this concrete for others searching: We ran into this bug recently as well with a slightly different manifestation, using a cm4. We're having the CM4 be both a wifi client and running hostapd.

(1) If the chip is in station (STA) mode and connected to an AP, then only one client can connect to the CM4. Other clients are instantly rejected.

(2) If the chip is in STA but searching for an AP - but not connected - then several clients can connect but they get transiently disconnected every minute or so as the chip tries again to find its AP to associate with.

(3) If the chip is NOT in STA mode / not trying to associate, then several clients can connect.

We have yet to try the minimized firmware mentioned above to see if it fixes either the disconnect behavior or allows more clients to connect while in station mode. But this may explain why a few people in this thread observed as little as 1 client able to connect to hostap. I hadn't seen (2) reported previously but I assume it's related to a lack of memory resources on the chip as well.

@martignoni
Copy link
Author

@dave-andersen IIRC, STA and AP mode must use the same channel for AP+STA to work correctly. But I suppose you've already checked this.

@dave-andersen
Copy link

Yeah, we're pinning everything to ch1 for now, but I suspect the AP scanning is breaking clients transiently for the reason you note: It's almost certainly looking at all channels.

@briantbutton
Copy link

Does anyone have any foresight into the possibility that the RPi 5 will be different that the RPi4 in this respect?

Integral WiFi station limits on the RPi4 is so much lower than our market needs that we are testing USB dongles. If the RPi 5 is gonna be markedly better, that would be a big factor for us.

@ziesemer
Copy link

Does anyone have any foresight into the possibility that the RPi 5 will be different that the RPi4 in this respect?

Integral WiFi station limits on the RPi4 is so much lower than our market needs that we are testing USB dongles. If the RPi 5 is gonna be markedly better, that would be a big factor for us.

I haven't received one to test with yet. However, combined with that neither the Pi 4 or 5 have an external antenna connector :-(, I've started to default to using USB dongles whenever I'm not otherwise cabled.

@JamesH65
Copy link
Contributor

The Pi 5 uses the same wireless chip as the Pi 4.

@pelwell
Copy link
Contributor

pelwell commented Oct 31, 2023

Yes - the same chip and the same firmware(s), but the SDIO interface runs faster so you should be able to achieve a higher throughput.

@briantbutton
Copy link

Thank you, gentlemen. We ship a portable module that can run on a power pack; people access it through WiFi. Sometimes a lot of people, even if not all at once. The integral wireless has been relegated to being an "admin" port and we use a USB dongle to deliver user services.

It sounds like it will stay that way.

@martignoni
Copy link
Author

@briantbutton Could you share the model of your USB wifi dongle?

@briantbutton
Copy link

@martignoni it would be my pleasure. In fact, I posted the larger journey here: morrownr/USB-WiFi#296 The larger repo has tons of information about USB dongles and drivers, and maintains some drivers. Invaluable really.

The chipset underlying is really the keys thing that determines functionality and driver compatibility. https://github.com/morrownr/USB-WiFi holds tables that disclose what chipsets go with what models of adapter. You should be able to find all you need there.

@martignoni
Copy link
Author

Thank you, much appreciated. I've already read thoroughly https://github.com/morrownr/USB-WiFi, but your "journey" will be very helpful.

@briantbutton
Copy link

Glad to hear. The adapter we tested with, that gave good results was the Alpha AWUS036AC. I liked it because we wanted range and it emphasized range. We got the driver off morrownr and it has worked fine and the range is very good. Ages ago, antenna diversity was emphasized to me. It has two antenna.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests