[GH-ISSUE #188] Single Socket ICE #457

Open
opened 2026-08-05 00:38:45 -04:00 by saavagebueno · 0 comments
Owner

Originally created by @braginini on GitHub (Jan 12, 2022).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/188

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). Original GitHub issue: https://github.com/netbirdio/netbird/issues/188 **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 2026-08-05 00:38:45 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#457