Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add webrtc sequence diagram #615

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: add webrtc sequence diagram
  • Loading branch information
2color authored May 16, 2024
commit 2d0c9a9482e3c8a922730bee67c86f0ab7805885
24 changes: 24 additions & 0 deletions webrtc/webrtc.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,30 @@ On a historical note, this specification replaces the existing [libp2p WebRTC st

9. Messages on `RTCDataChannel`s on the established `RTCPeerConnection` are framed using the message framing mechanism described in [multiplexing].

### Diagram

```mermaid
sequenceDiagram
participant a as Browser A
participant cr as CircuitRelayV2Peer
participant b as Browser B
participant stun as STUN Server
b->>cr: Establish Relayed Connection (WebTransport, WebRTC)
b-->>a: Shares its own relayed webrtc multiaddress (out of band)
a->>b: Establishes a relayed connection to Browser 2
a-->>a: Creates RTCPeerConnection with STUN server config, init DataChannel and SDP offer
a->>b: Initiates libp2p /webrtc-signaling/0.0.1 protocol stream over relayed conection and sends SDP
b-->>b: Creates RTCPeerConnection with STUN server config, sets Browser1's SDP offer, and creates SDP answer
b->>a: Sends SDP answer over signaling stream
a-->>a: Set SDP answer with RTCPeerConnection.setRemoteDescription
a->>+stun: What's my public IP and port
stun->>-a: Browser A observed ip and port: 8.8.8.1:63333
b->>+stun: What's my public IP and port
stun->>-b: Browser B observed ip and port: 6.6.6.1:52222
b->a: exchange ICE candidates over signalling stream pass to RTCPeerConnection.addIceCandidate()
b->a: Establish direct connection
```

## STUN

A node needs to discover its public IP and port, which is forwarded to the remote node in order to connect to the local node.
Expand Down