Skip to content

Instantly share code, notes, and snippets.

@JFreegman
Last active November 22, 2021 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JFreegman/d001756561ba717a57b08238396b5573 to your computer and use it in GitHub Desktop.
Save JFreegman/d001756561ba717a57b08238396b5573 to your computer and use it in GitHub Desktop.
NGC handshake protocol
1. Peer A receives Peer B's announcement from DHT:
A -> B send handshake request GH_REQUEST & HS_INVITE_REQUEST
B -> A send handshake response GH_RESPONSE & HS_INVITE_REQUEST
A -> B send invite request GP_INVITE_REQUEST
B -> A send invite response GP_INVITE_RESPONSE
A -> B send sync request GP_SYNC_REQUEST
B -> A send sync response GP_SYNC_RESPONSE
B -> A send all other peer announcements [goto: 2]
A -> Connection State = CS_CONNECTED
A -> C send GH_REQUEST & HS_PEER_INFO_EXCHANGE to all received announcements
A -> B [goto: peer info exchange]
2. Peer A sends Peer C a handshake request via sync response from peer B
A -> C send handshake request GH_REQUEST & HS_PEER_INFO_EXCHANGE
C -> A send handshake response GH_RESPONSE & HS_PEER_INFO_EXCHANGE
A -> C [goto: peer info exchange]
Peer info exchange:
A -> B send peer info request GP_PEER_INFO_REQUEST
A -> B send self info response GP_PEER_INFO_RESPONSE
B -> peer A confirmed
B -> A send self info response GP_PEER_INFO_RESPONSE
A -> peer B confirmed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment