Skip to content

Commit 4df432e

Browse files
author
Emilia Hane
committed
Keep hole punched theory
1 parent 58c1cba commit 4df432e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

discv5/discv5-theory.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,22 @@ ENR as its potential relay, the longer time that has passed since a peer sent us
405405
the less guarantee we have that the peer is in fact connected to the owner of that ENR and
406406
hence of its ability to relay.
407407
408+
### Job of keeping the hole punched falls on Bob and Bob's incentives to do so
409+
410+
UDP session table entry lifetimes are configurable, though a common lower bound is 20
411+
seconds[^1]. Bob must periodically reset the session table entry for Alice in its NAT to
412+
keep the hole for Alice punched. If Alice too is behind a NAT, it must do the same for Bob.
413+
Implementations must ensure, when a node behind a NAT does not send a packet to a peer
414+
within the entry lifetime then an empty packet is sent that is dropped by the peer.
415+
416+
NAT hole punching unavoidably creates overhead for all nodes in the network but once a
417+
hole is punched, keeping it punched requires no interaction between peers. The incentive
418+
for nodes behind a NAT to keep holes for its peers punched is to avoid reestablishing a
419+
session. If there is no hole for Alice in Bob's NAT when Alice carries out a
420+
[liveness check], Bob is considered offline and the session to Bob useless. If the node
421+
behind a NAT intends to frequently communicate with a peer, reestablishing the session is
422+
more costly than managing the interval of sent packets to that peer.
423+
408424
[EIP-778]: ../enr.md
409425
[identity scheme]: ../enr.md#record-structure
410426
[message packet]: ./discv5-wire.md#ordinary-message-packet-flag--0
@@ -420,6 +436,7 @@ hence of its ability to relay.
420436
421437
[UDP communication]: ./discv5-wire.md#udp-communication
422438
[Sessions]: ./discv5-theory.md#sessions
439+
[liveness check]: ./discv5-theory.md#table-maintenance-in-practice
423440
424441
[^1]: https://pdos.csail.mit.edu/papers/p2pnat.pdf
425442
[^2]: https://datatracker.ietf.org/doc/html/rfc4787

0 commit comments

Comments
 (0)