-
Notifications
You must be signed in to change notification settings - Fork 7
Message Delivery
The protocol forwards not only the message itself and a sufficient payment for the relayer but also the responsibility to deliver the message along the path chosen by the creator of a packet. As there is by design no central server that takes care of the message transfer, the clients are connected through a peer-to-peer network to each other.
There is also no explicit role distinction within the network which means that nodes can act not as a sender but also as a relayer and a receiver. This leads to the requirement that each node must be able to send and receive messages from arbitrary other nodes in the network.
It turns out that sending and receiving messages from arbitrary nodes requires us to support bypassing of NATs. Whilst most of the nodes reside behind NATs that allow them to open a port such that they can receive messages from other node, there is also a minority of nodes that reside behind NATs that require some tricks to bypass it. Nowadays, this can be solved by using techniques like WebRTC that automatically finds the right procedure to establish a connection between two clients.
In order to let nodes exchange their connection details and to find a setting that fits for both, WebRTC uses a signaling server to establish a connection. Since the objective of this project is to allow decentralized message delivery, the existence of such a central server contradicts the that objective. For that reason, each node runs a signaling server itself and chooses a few other nodes where it registers itself to be able to receive connections from other nodes. The nodes use the Multiaddr address structure to bundle several addresses under which a node is available.
In order to connect to a previously unknown node, that node searches for the entry of that node in the DHT and iterates through the received list of addresses under which the node is available until both of them are able to establish a connection.