How can I limit the maximum connected users?

Posted by m3fisto 
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Now, this forum is in read-only mode. You find details Details hereContinue on /r/PirateBox
How can I limit the maximum connected users?
June 29, 2017 08:14AM
Also posted this on reddit
[www.reddit.com]

I am using Pi1B with Piratebox 1.1.3 on a sandisk class 10 sd, a TP-LINK TL-WN722N (v1 with the Atheros chip) and a 128GB Sandisk fast usb flash disk. I am lately taking my piratebox at crowded places like concerts or beaches. After an hour or so of working flawlessly, it seems that no one can connect anymore. After a reboot, it works again for a few minutes but then again the wifi is discoverable, but no one can connect. I believe that this combo of HW cannot handle more than 30-40 connections at the time, so I think of trying the following:
dhcp lease time: down to 30m
IPSTART=192.168.1.20 IPEND=192.168.1.40
Will this just limit available IPs lets say from 20-40, so only 20 devices can connect at a time? Does the 30m lease time means that after 30minutes, the connection will be dropped?



Edited 1 time(s). Last edit at 07/04/2017 07:06AM by m3fisto.
Re: How can I limit the maximum connected users?
June 29, 2017 09:23AM
Hi,
thanks for cross posting. I am only checking the PirateBox forum and not reddit for questions.

You should try to verify the root cause of the connection issues. Try to connect to your device using a static IP address (192.168.1.2), get a ssh connection and have a look at the journal while others try to connect:

sudo journalctl -n 50 -f
(cancel with CTRL+C or leave out the -f option).

You should see a message about "no free lease" or something like this. A reboot cleans up the lease cache and could solve the issue.

I totally sounds like a lease time issue. The default is for about 12h lease time. This means one particular IP address is reserved for 12 hours to one mac address. If you have over 240 different clients connected during that time window, the client with the 241th client won't get an IP address.
This will look like a looong connecting process and then dropping of the network.

I recommend to set down the lease time down to 30 minutes, and not the IP range. The result is, that the DHCP server discards not renewed IP leases after 30 minutes, which makes room for new clients.
Reducing the IPs is not a real connection limit on the wifi limit.

As a second step, you can try to limit the amount of connection in hostapd ( /opt/piratebox/conf/hostapd.conf ), you can try the following settings (see example hostapd.conf)

# Maximum number of stations allowed in station table. New stations will be
# rejected after the station table is full. IEEE 802.11 has a limit of 2007
# different association IDs, so this number should not be larger than that.
# (default: 2007)
# ~~~ Matthias, 20 client connections only
max_num_sta=20

# The station can associate again with the AP if it is still in range;
# this inactivity poll is just used as a nicer way of verifying
# inactivity; i.e., client will not report broken connection because
# disassociation frame is not sent immediately without first polling
# the STA with a data frame.
# default: 300 (i.e., 5 minutes)
# ~~~ Matthias only wait 2minutes
ap_max_inactivity=120

# Disassociate stations based on excessive transmission failures or other
# indications of connection loss. This depends on the driver capabilities and
# may not be available with all drivers.
# ~~~ Matthias , try to test this
disassoc_low_ack=1


Hope that helps,
best regards
Matthias
Re: How can I limit the maximum connected users?
June 29, 2017 10:08AM
thank you very much Matthias.
I am gonna test the hostapd.conf settings next sunday on the beach and see how it goes. I will let you know