Single Socket ICE #99

Closed
opened 2025-11-20 05:06:15 -05:00 by saavagebueno · 1 comment
Owner

Originally created by @braginini on GitHub (Jan 12, 2022).

What?
Support a single socket mode (or reduced number of sockets) in the client app.

We use pion/ice library for NAT traversal (discovering connection candidates for establishing p2p connections).
Currently, the library creates multiple sockets for each candidate type (around 5 per connection). Having many peers causes too many open files on the system which is not very efficient (e.g. 5 x 100 peers = 500 sockets).
The pion/ice library supports UDPMux which allows for a single socket to be reused between candidates. However, it is only used for HOST candidates.

This implementation should support all the candidate types (server reflexive and relayed).
Why?
Having many peers causes too many open files on the system which is not very efficient. On some systems, it causes errors (too many open files).
On top of those 5 sockets, we also open a socket per peer to connect to Wireguard and proxy connection.

How?
Fork pion/ice -> wiretrustee/ice and support SRFLX and RELAY candidates in the UDPMux.
There was some effort done in this branch already https://github.com/wiretrustee/ice/tree/singleport
The idea here is to have a separate UDPMux for each candidate. E.g. UDPMuxSrflx, UDPMuxRelay, etc.

It is important to run tests over 200 peers to check the result.

Originally created by @braginini on GitHub (Jan 12, 2022). **What?** Support a single socket mode (or reduced number of sockets) in the client app. We use [pion/ice](https://github.com/pion/ice) library for NAT traversal (discovering connection candidates for establishing p2p connections). Currently, the library creates multiple sockets for each candidate type (around 5 per connection). Having many peers causes too many open files on the system which is not very efficient (e.g. 5 x 100 peers = 500 sockets). The pion/ice library supports [UDPMux](https://github.com/pion/ice/blob/master/udp_mux.go) which allows for a single socket to be reused between candidates. However, it is only used for HOST candidates. This implementation should support all the candidate types (server reflexive and relayed). **Why?** Having many peers causes too many open files on the system which is not very efficient. On some systems, it causes errors (too many open files). On top of those 5 sockets, we also open a socket per peer to connect to Wireguard and proxy connection. **How?** Fork pion/ice -> wiretrustee/ice and support SRFLX and RELAY candidates in the UDPMux. There was some effort done in this branch already https://github.com/wiretrustee/ice/tree/singleport The idea here is to have a separate UDPMux for each candidate. E.g. UDPMuxSrflx, UDPMuxRelay, etc. It is important to run tests over 200 peers to check the result.
saavagebueno added the enhancementclientneeds-review2022 Q1 labels 2025-11-20 05:06:15 -05:00
Author
Owner

@stv0g commented on GitHub (Jun 16, 2023):

Hi @mlsmaycon,

I am curious, how have you resolved this issue? Do you have a single socket for Host, Srflx and Relay candidates?
Upstream pion/ice still needs multiple using UDPMux and UniversalUDPMux

@stv0g commented on GitHub (Jun 16, 2023): Hi @mlsmaycon, I am curious, how have you resolved this issue? Do you have a single socket for Host, Srflx and Relay candidates? Upstream pion/ice still needs multiple using `UDPMux` and `UniversalUDPMux`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#99