Skip to content

Commit 65da49b

Browse files
committed
Add sequence diagram and start description
1 parent 1a9d5a3 commit 65da49b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

discv5/discv5-theory.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,35 @@ advertisement, but samples the average number of results from TOPICQUERY instead
525525
average time to registration. The radius estimation value can be shared with the
526526
registration algorithm if the same topic is being registered and searched for.
527527

528+
## Hole punch asymmetric NATs
529+
530+
The protocol introduces the notification packet kind. There are 4 total message
531+
containers, these are abbreviated in the sequence diagram below as follows:
532+
- m - message packet
533+
- whoareyou - WHOEAREYOU packet
534+
- hm - handshake message packet
535+
- n - notification packet
536+
537+
```mermaid
538+
sequenceDiagram
539+
Relay-->>Alice: m(NODES[Bob's ENR])
540+
Alice->>Bob: m(nonce,FINDNODE)
541+
Note left of Alice:Hole punched in Alice's NAT for Bob
542+
Alice->>Relay: n(RELAYINIT[nonce])
543+
Relay->>Bob:n(RELAYMSG[nonce])
544+
Bob-->>Alice: whoareyou(nonce)
545+
Note right of Bob: Hole punched in Bob's NAT for Alice
546+
```
547+
Bob is behind a NAT. Bob is in Relay's kbuckets, they have a session together.
548+
549+
As part of a periodic recursive query to fill its kbuckets, Alice sends a FINDNODE
550+
request to Bob, who's ENR it received from Relay. By making an outgoing request to
551+
Bob, if Alice is behind a NAT, Alice's NAT adds the filtering rule
552+
`(Alice's-LAN-ip, Alice's-LAN-port, Bob's-WAN-ip, Bob's-WAN-port)`[^1] to it's UDP table.
553+
The request to Bob times out as Bob is behind a NAT.
554+
555+
556+
528557
[EIP-778]: ../enr.md
529558
[identity scheme]: ../enr.md#record-structure
530559
[handshake message packet]: ./discv5-wire.md#handshake-message-packet-flag--2
@@ -535,3 +564,4 @@ registration algorithm if the same topic is being registered and searched for.
535564
[REGTOPIC]: ./discv5-wire.md#regtopic-request-0x07
536565
[REGCONFIRMATION]: ./discv5-wire.md#regconfirmation-response-0x09
537566
[TOPICQUERY]: ./discv5-wire.md#topicquery-request-0x0a
567+
[^1]: https://datatracker.ietf.org/doc/html/rfc4787

0 commit comments

Comments
 (0)