You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: webrtc/browser-to-browser.md
+26-49Lines changed: 26 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -6,62 +6,45 @@
6
6
7
7
## Motivation
8
8
9
-
1.**Hole punching in the browser**: Enable two browsers or a browser and a
10
-
server node to connect even though one or both are behind a NAT / firewall.
9
+
1.**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.
11
10
12
11
TODO: Doucment use-case where A is a browser and B is a non-browser but behind firewall and/or NAT.
13
12
14
13
## Connection Establishment
15
14
16
15
### Browser to Browser
17
16
18
-
Scenario: Browser _A_ wants to connect to Browser node _B_ with the help of
19
-
server node _R_. Both _A_ and _B_ can not listen for incoming connections due to
20
-
the restriction of the browser platform and being behind a NAT and/or firewall.
17
+
Scenario: Browser _A_ wants to connect to Browser node _B_ with the help of server node _R_.
18
+
Both _A_ and _B_ can not listen for incoming connections due to the restriction of the browser platform and being behind a NAT and/or firewall.
21
19
22
-
TODO: Define which node on a relayed connection is _A_ and which one is _B_,
23
-
i.e. which one initiates (offer) and which one responds (answer).
20
+
TODO: Define which node on a relayed connection is _A_ and which one is _B_, i.e. which one initiates (offer) and which one responds (answer).
24
21
25
-
1._A_ and _B_ establish a relayed connection through some protocol, e.g. the
26
-
Circuit Relay v2 protocol. Note that further steps depend on the relayed
27
-
connection to be authenticated, i.e. that data send on the relayed connection
28
-
can be trusted.
22
+
1._A_ and _B_ establish a relayed connection through some protocol, e.g. the Circuit Relay v2 protocol.
23
+
Note that further steps depend on the relayed connection to be authenticated, i.e. that data send on the relayed connection can be trusted.
29
24
30
-
2._A_ creates an `RTCPeerConnection`. See [#STUN] on what STUN servers to
31
-
configure at creation time. _A_ creates an SDP offer via
32
-
`RTCPeerConnection.createOffer()`. _A_ initiates the signaling protocol to _B_
33
-
via the relayed connection from (1), see [#Signaling protocol] and sends the
34
-
offer to _B_.
25
+
2._A_ creates an `RTCPeerConnection`.
26
+
See [#STUN] on what STUN servers to configure at creation time.
27
+
_A_ creates an SDP offer via `RTCPeerConnection.createOffer()`.
28
+
_A_ initiates the signaling protocol to _B_ via the relayed connection from (1), see [#Signaling protocol] and sends the offer to _B_.
35
29
36
-
3._B_ creates an `RTCPeerConnection`. Again see [#STUN] on what STUN servers to
37
-
configure at creation time. _B_ receives _A_'s offer send in (2) via the
38
-
signaling protocol stream and provides the offer to its `RTCPeerConnection`
39
-
via `RTCPeerConnection.setRemoteDescription`. _B_ then creates an answer via
40
-
`RTCPeerConnection.createAnswer` and sends it to _A_ via the existing
41
-
signaling protocol stream (see [#signaling protocol]).
30
+
3._B_ creates an `RTCPeerConnection`.
31
+
Again see [#STUN] on what STUN servers to configure at creation time.
32
+
_B_ receives _A_'s offer send in (2) via the signaling protocol stream and provides the offer to its `RTCPeerConnection` via `RTCPeerConnection.setRemoteDescription`.
33
+
_B_ then creates an answer via `RTCPeerConnection.createAnswer` and sends it to _A_ via the existing signaling protocol stream (see [#signaling protocol]).
42
34
43
-
4._A_ receives _B_'s answer via the signaling protocol stream and sets it
44
-
locally via `RTCPeerConnection.setRemoteDescription`.
35
+
4._A_ receives _B_'s answer via the signaling protocol stream and sets it locally via `RTCPeerConnection.setRemoteDescription`.
45
36
46
37
5. TODO: Define ICE candidate exchange.
47
38
48
-
5. Messages on `RTCDataChannel`s on the established `RTCPeerConnection` are
49
-
framed using the message framing mechanism described in
50
-
[Multiplexing](#multiplexing).
39
+
5. Messages on `RTCDataChannel`s on the established `RTCPeerConnection` are framed using the message framing mechanism described in [Multiplexing](#multiplexing).
51
40
52
-
The above browser-to-browser WebRTC connection establishment replaces the
- Instead of using trickle ICE, we could as well wait for the candidate gathering.
46
+
See https://github.com/pion/webrtc/blob/c1467e4871c78ee3f463b50d858d13dc6f2874a4/examples/insertable-streams/main.go#L141-L142 as one example.
47
+
In the browser, one can wait for the [`icegatheringstatechange` event](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/icegatheringstatechange_event).
65
48
66
49
## STUN
67
50
@@ -73,9 +56,7 @@ TODO: Extend
73
56
74
57
Protocol id `/webrtc-direct`
75
58
76
-
Messages are sent prefixed with the message length in bytes, encoded as an
77
-
unsigned variable length integer as defined by the [multiformats unsigned-varint
78
-
spec][uvarint-spec].
59
+
Messages are sent prefixed with the message length in bytes, encoded as an unsigned variable length integer as defined by the [multiformats unsigned-varint spec][uvarint-spec].
79
60
80
61
```protobuf
81
62
// TODO: Support for offer, answer and ICE candidates
@@ -85,13 +66,9 @@ spec][uvarint-spec].
85
66
86
67
- Why is there no additional Noise handshake needed?
87
68
88
-
This specification (browser-to-browser) requires _A_ and _B_ to exchange their
89
-
SDP offer and answer over an authenticated channel. Offer and answer contain
90
-
the TLS certificate fingerprint. The browser validates the TLS certificate
91
-
fingerprint through the TLS handshake on the direct connection.
69
+
This specification (browser-to-browser) requires _A_ and _B_ to exchange their SDP offer and answer over an authenticated channel.
70
+
Offer and answer contain the TLS certificate fingerprint.
71
+
The browser validates the TLS certificate fingerprint through the TLS handshake on the direct connection.
92
72
93
-
In contrast, the browser-to-server specification allows exchange of the
94
-
server's multiaddr, containing the server's TLS certificate fingerprint, over
95
-
unauthenticated channels. In other words, the browser-to-server specification
96
-
does not consider the TLS certificate fingerprint in the server's multiaddr to
97
-
be trusted.
73
+
In contrast, the browser-to-server specification allows exchange of the server's multiaddr, containing the server's TLS certificate fingerprint, over unauthenticated channels.
74
+
In other words, the browser-to-server specification does not consider the TLS certificate fingerprint in the server's multiaddr to be trusted.
0 commit comments