Skip to content

Commit

Permalink
webrtc/: Remove browser-to-browser use-case
Browse files Browse the repository at this point in the history
This will be specified in a second iteration of this specification.
  • Loading branch information
mxinden committed Oct 14, 2022
1 parent 1cb4093 commit a46919c
Showing 1 changed file with 0 additions and 65 deletions.
65 changes: 0 additions & 65 deletions webrtc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Interest Group: [@marten-seemann]
- [Addressing](#addressing)
- [Connection Establishment](#connection-establishment)
- [Browser to public Server](#browser-to-public-server)
- [Browser to Browser](#browser-to-browser)
- [Open Questions](#open-questions)
- [Multiplexing](#multiplexing)
- [Ordering](#ordering)
- [Head-of-line blocking](#head-of-line-blocking)
Expand All @@ -38,9 +36,6 @@ Interest Group: [@marten-seemann]
certificate. Nor can we establish a plain TCP or QUIC connection from within
a browser.

2. **Hole punching in the browser**: Enable two browsers or a browser and a
server node to connect even though one or both are behind a NAT / firewall.

## Addressing

WebRTC multiaddresses are composed of an IP and UDP address component, followed
Expand Down Expand Up @@ -141,66 +136,6 @@ reachable but _B_ does not have a TLS certificate trusted by _A_.
WebRTC can run both on UDP and TCP. libp2p WebRTC implementations MUST support
UDP and MAY support TCP.

### Browser to Browser

Scenario: Browser _A_ wants to connect to Browser node _B_ with the help of
server node _R_.

_Note that this section is a draft only for now, will be removed before merging
the first iteration of the specification (browser-to-server) and reintroduced in
the second iteration i.e. sufficiently specifying browser-to-server._

1. _B_ runs inside a browser and can thus not listen for incoming connections.
_B_ connects to a public server node _R_ and uses the Circuit Relay v2
protocol to make a reservation.

2. _B_ advertises its relayed address through some external mechanism.

3. _A_ discovers _B_'s relayed address. _A_ connects to _R_ and establishes a
relayed connection to _B_ via the Circtui Relay v2 protocol.

4. _A_ and _B_ both create a `RTCPeerConnection` and generate an _offer_ and an
_answer_ respectively. See `icegatheringstatechange` below on how these may
already contain the addresses of the loca node.

5. _A_ and _B_ exchange the generated _offer_ and _answer_ through some protocol
(e.g. an altered DCUtR) via the relayed connection.

6. _A_ and _B_ set the exchanged _offer_ and _answer_ and thus initiate the
connection establishment.

7. Messages on the established `RTCDataChannel` are framed using the message
framing mechanism described in [Multiplexing](#multiplexing).

8. The remote is authenticated via an additional Noise handshake. See
[Connection Security](#connection-security).

The above browser-to-browser WebRTC connection establishment replaces the
existing [libp2p WebRTC star](https://github.com/libp2p/js-libp2p-webrtc-star)
and [libp2p WebRTC direct](https://github.com/libp2p/js-libp2p-webrtc-direct)
protocols.

#### Open Questions

- Can _Browser_ control the lifecycle of its local TLS certificate, i.e. can
_Browser_ use the same TLS certificate for multiple WebRTC connections?

Yes. For the lifetime of the page, one can generate a certificate once and
reuse it across connections. See also
https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection#using_certificates

- Can two _Browsers_ exchange their SDP packets via a third server node using
Circuit Relay v2 and DCUtR? Instead of exchanging the original SDP packets,
could they exchange their multiaddr and construct the remote's SDP packet
based on it?

- Instead of using trickle ICE, we could as well wait for the candidate
gathering. See
https://github.com/pion/webrtc/blob/c1467e4871c78ee3f463b50d858d13dc6f2874a4/examples/insertable-streams/main.go#L141-L142
as one example. In the browser, one can wait for the
[`icegatheringstatechange`
event](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/icegatheringstatechange_event).

## Multiplexing

The WebRTC browser APIs do not support half-closing of streams nor resets of the
Expand Down

0 comments on commit a46919c

Please sign in to comment.