P2P Lab
Two browsers, one relay, nothing kept. Open this page in two tabs or send the room link to someone: each tab starts a real libp2p node, the two find each other through a circuit relay running inside this site’s server, and then one asks the other for a block of bytes by its content identifier and checks the answer itself.
Loading the libp2p node…
Room
Open this link in a second tab or another browser to join the same room:
The connection, as libp2p reports it
Every value below is read from the live connection object in this tab every two seconds. Nothing here is filled in by the server.
| This tab’s peer ID | — |
|---|---|
| Other peer’s ID | — |
| Relay’s peer ID | — |
| Path to the other peer | — |
| Remote address | — |
| Encryption and multiplexing | — |
| Round trip | — |
| Relay limit left on this connection | — |
| Fetch-protocol bytes this tab | — |
| Direct connection attempt | — |
| What the relay counts | — |
Share a block
Text or a file up to 64 KiB. This tab computes its CID and keeps the bytes in memory, in this tab only, until you close it.
Last shared CID:
Fetch a block by CID
CID of the bytes that arrived:
What the relay can and cannot see
Your browser cannot accept incoming connections, so the two tabs start by both connecting out to a relay: a libp2p node running inside this site’s server, reached over a secure WebSocket on the same address as this page. The relay joins the two connections end to end. The two peers then run their own Noise handshake through it, so the stream is encrypted end to end between the peers and the relay forwards ciphertext. If the tabs then reach each other directly, that connection is encrypted by WebRTC’s built-in DTLS, and the offer that set it up crossed the relay inside the Noise-encrypted stream. What the relay does see is connection metadata: both peer IDs, when the circuit opened and closed, and how many bytes crossed it — the counters in the last row of the panel are exactly that, read from the relay. It never sees the text, the file or the CID you ask for.
Nothing is kept. The room list holds peer IDs in the server’s memory for 30 seconds after the last heartbeat and is written nowhere. Blocks live in the memory of the tab that shared or fetched them and are gone when it closes. The relay talks to no other network: it has no bootstrap list, joins no distributed hash table, and refuses to dial anything; it only forwards between peers that connected to it.
Content addressing
A CID is a name computed from the bytes themselves. This page uses
CIDv1 with the raw codec and a sha2-256 hash, printed
in base32. The same bytes always give the same CID, and changing a single bit gives a different one.
That is what makes fetching by CID safe from an untrusted peer: the receiver does not have to trust
the sender, it hashes what arrived and accepts it only if the result is the CID it asked for. Turn
on “serve tampered bytes” in one tab and fetch from the other to watch a wrong block
rejected.
Worked example, computed by the server from the same rule:
hello from pigfox → bafkreieauc3hqmmnooxcotg5rbfrvka2dkv67awu2dfpros3i7wifrz7ea.
The request travels over a small protocol of this page’s own,
/pigfox/p2p-lab/fetch/1.0.0: one length-prefixed message carrying the CID, answered by a status
and the block.
Direct connections
After the relayed connection is up, the tab with the lower peer ID tries to upgrade to a direct WebRTC connection, using the relay only to exchange the connection offer. This page configures no STUN or TURN servers, so it contacts no one but this site, and the browsers can only try their own local addresses. Two tabs on one machine, or two machines on one network, can often connect that way; two browsers on different home networks usually cannot, and then the transfer stays on the relay. The panel reports which happened, and why an attempt failed, from the connection itself.
Limits
- Blocks are capped at 64 KiB, in both the sending and the receiving tab.
- A relayed connection carries at most 1 MiB in each direction and lasts at most 10 minutes before the relay resets it.
- The relay holds at most 64 reservations at once, and accepts at most 4 open sockets from one address.
- A room lists at most 4 peers; this page connects to the most recent other one.