shadowsocks-rust icon indicating copy to clipboard operation
shadowsocks-rust copied to clipboard

UDP package limit on ssmanager

Open maximilize opened this issue 3 years ago • 9 comments

The manager communication to ssmanager is done via UDP. This is blazing fast, but it seems that the current implementation can only transfer at maximum 65kb network packets. This leads to infinite waits on client sides or other unwanted behaivor.

How to reproduce

  1. start ssmanager: ssmanager --manager-address 127.0.0.1:1111

  2. start a lot of port listeners: for x in {10000..15000}; do echo 'add: {"server_port": '$x', "password": "passwordpasswordpasswordpasswordpasswordpassword"}'; done | nc -u localhost 1111

  3. issue a list command: echo 'list' | nc -u localhost 1111

You'll see that nc is receiving only a part of the full data.

maximilize avatar Sep 21 '22 22:09 maximilize

A UDP datagram is carried in a single IP packet and is hence limited to a maximum payload of 65,507 bytes for IPv4 and 65,527 bytes for IPv6.

So it is the limitation of UDP.

zonyitoo avatar Sep 22 '22 07:09 zonyitoo

We can send more than 1 package, this is how UDP is usually used. The terminating character is \n in the ss api, so there shouldn't be any issues.

maximilize avatar Sep 22 '22 08:09 maximilize

start a lot of port listeners

I don't think starting thousands of listeners is how you are supposed to use the server. You might want to use Shadowsocks 2022's multi-user mode to add multiple uPSKs to a single port.

but it seems that the current implementation can only transfer at maximum 65kb network packets.

What about using a unix domain socket instead?

The current API is terrible, but we don't have anything better to replace it yet.

database64128 avatar Sep 22 '22 08:09 database64128

We can send more than 1 package, this is how UDP is usually used. The terminating character is \n in the ss api, so there shouldn't be any issues.

How can you ensure that UDP packets arrive to your client in order?

zonyitoo avatar Sep 22 '22 08:09 zonyitoo

@zonyitoo You can't, you have to write this logic yourself. That's why TCP was created.

@database64128 I'll test the multi-user model via uPSK. Thanks for the hint.

maximilize avatar Sep 24 '22 18:09 maximilize

@database64128 With AEAD-2022, is it possible to add and remove users while the server is running?

maximilize avatar Sep 24 '22 19:09 maximilize

It is possible, but the current interface have to remove then readd the server.

zonyitoo avatar Sep 25 '22 00:09 zonyitoo

The current ssmanager interface is quite bad for managing lots of users. A new user management interface is required.

zonyitoo avatar Sep 25 '22 00:09 zonyitoo

I have proposed a new management API for Shadowsocks servers and implemented it in shadowsocks-go.

Shadowsocks-NET/shadowsocks-specs#3

database64128 avatar Mar 12 '23 10:03 database64128