Skip to content

Net libraries

Marek Franciszkiewicz edited this page Feb 9, 2020 · 2 revisions

Rust P2P libraries

The goal of this short document is to present a set of libraries / tech stacks which may serve as a foundation for the yagna networking layer.

Requirements:

  • a fully fledged yagna network node may be executed in a browser
  • message relaying / NAT traversal support

Secondary requirements:

  • implemented in Rust
  • stateless connections (e.g. mobile clients, frequently changing network addresses), i.e. based on a UDP protocol

WebRTC

UDP-based DataChannels, a part of the WebRTC specification, provide connectivity between clients executed within web browsers. Channel specification does not cover delivery guarantees, packet sequencing and ordering.

According to crates.io, there exists no production-grade WebRTC library.

Recommendation: webrtc-unreliable should serve as a foundation for future development of a WebRTC-based networking layer.

webrtc-unreliable

github

Unreliable, unordered WebRTC data channels between a browser and a server. Provides an implementation of server-side UDP/DTLS/SCTP data channels.

The most complete known Rust WebRTC implementation. A working example is provided in the repository.

Known issues:

  • closing a channel times out in Firefox (works properly in Safari)
  • server-side only, no client-side channel initialization
  • thus, no proper ICE support

Featured protocols:

  • SDP (partial)
  • SCTP (partial)
  • STUN (partial; parse_stun_binding_request, write_stun_success_response)

webrtc-sctp

github

Abandoned, in-progress Rust SCTP implementation.

May serve as a knowledge base of documents describing SCTP.

webrtc-sdp

github

A SDP parser written in Rust specifically aimed to handle WebRTC SDP offers and answers.

Developed by mozilla, may prove useful for further SDP-related development.

QUIC, HTTP/3

Due to enforcement of TLSv3, browser clients will require to be presented with a valid SSL certificate by the server (i.e. any peer that the client is connecting to), signed by a "known" Certificate Authority. Thus, this solution is not fit for hybrid networking nodes.

quic-p2p

github

Based on quinn QUIC protocol implementation.

QUIC proved connection security via the use of TLS 1.3. This library allows 3 different connection types with regard to encryption and validation.

  1. Require peers have certificates from an agreed certificate authority.
  2. Allow use of a private certificate authority.
  3. Allow no identity validation of peers, but do encrypt connections.

quiche

github

Provides an implementation of both QUIC and HTTP/3 protocols.

Similarly, SSL certificate validation may be turned off by calling SSL_CTX_set_verify with SSL_VERIFY_NONE.

WebSockets

Full-duplex communication channels over a single TCP connection built into all popular web browsers. WebSockets do not provide means to communicate via UDP.

Reliable UDP

An overlay built on top of the UDP protocol, providing ordering and delivery guarantees. Can be used together with WebRTC to provide reliable message exchange and connectivity between peers.

laminar

github

Laminar is an application-level transport protocol which provides configurable reliability and ordering guarantees built on top of UDP. Laminar was designed to be used within the Amethyst game engine.

  • feature-rich
  • tested

PoC of laminar working on non-UDP, virtual sockets can be found here.