-
Notifications
You must be signed in to change notification settings - Fork 282
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
discv5: NAT traversal via Rendezvous protocol [WIP] #207
Comments
So this means the PING from the "receiver" to the "initiator" is dropped but places the entry in the "receiver's" state table for the "initiator's" PING to the "receiver" to be successful as long as it comes in less than 30 seconds, the timeout of a UDP state table entry in many routers, i.e. the time it takes for the RELAYRESPONSE to reach the "initiator" should be less than 30 seconds? The WHOAREYOU challenge of the "receiver" sent in response then uses the state table entry that the "initiator's" PING places in its state table to finalise the hole punching? |
Nice! A few thoughts:
@emhane - I agree. Typically the round-trip type for requests in discv5 is small, not longer than a few seconds usually, so hoping via an intermediary should be < 30s. I think the initial PING sent by the |
What if the body of the RELAYREQUEST is changed to |
Why not consider wireguard for this? |
Yes, this seems appropriate. I now see that without this, the "receiver" node will not necessarily have enough information to send the PING to the initiator, which would mean they would end up needing to do a lookup for them in the network to find their ENR. 👍 |
I have implemented your protocol outline @pipermerriam with the changes in @AgeManning 's comment above. Furthermore I changed
|
I'm changing the |
This issue proposes a mechanism for NAT traversal via UDP hole punching.
This issue borrows from ethereum/portal-network-specs#144 which in-turn borrows from https://blog.ipfs.io/2022-01-20-libp2p-hole-punching/
Participants
This mechanism involves communication between three nodes:
Detecting whether you are behind a NAT
Borrowed from: https://twurst.com/articles/stun-without-trust.html#org92b7214
A node in the network should maintain a set
E
which contains all of the(ip_address, port)
values for outbound packets that have been sent by this node.When receiving a packet, a node should check whether the packet's
(ip_address, port)
are contained in the setE
.(ip_address, port)
are not inE
then the node is not behind a NAT(ip_address, port)
values that are not inE
within a reasonable amount of time, then the node should assume that they are behind a NAT.Signalling whether you are behind a NAT
We define a new field in the ENR with the key
"nat"
.0
1
Traversing the NAT
We define two new message types:
The rendezvous protocol works as follows:
{from_node_enr: initiator_enr, to_node_id: receiver_node_id}
{response: 1}
to signal that they have accepted this request. They may alternately respond with{response: 0}
if they wish to reject the request. The "receiver" node will also send a PING message to the "initiator" node (this triggers the receiver's NAT to allow and route incoming packets from the initiator's ip/port).TODO: diagram message flow... define edge cases like timeouts and how nodes should behave.
TODO- finish definition of the protocol and convert this to a PR towards the spec so that people can comment on individual lines.
The text was updated successfully, but these errors were encountered: