netbird icon indicating copy to clipboard operation
netbird copied to clipboard

Single Socket ICE

Open braginini opened this issue 2 years ago • 0 comments

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.

braginini avatar Jan 12 '22 19:01 braginini