-
Notifications
You must be signed in to change notification settings - Fork 6
Network Discovery Protocol
This document will outline the protocol to find and connect to the network using TCP.
When an instance of DDB comes online, it should scan the devices on the router by sending a greeting message to all avaliable IPs on the same port of this of DDB. If an IP is hit where an instance of DDB exists, that instance will respond and confirm the greeting. The new instnace should take note of all IPs where another instance DDB exists. See network discovery config for the structure of the network config file.
The greeting message will be a short JSON.
{
"command": "greetings",
"name": <Unique name>,
"ip": <New instance IP>
}
The response to the greeting will be an equally short JSON.
{
"command": "and to you",
"name": <Unique name>,
"ip": <Old instance IP>,
}
The new instance will then take all the responding IPs and store them so it knows who else is part of the network. The existing instances of DDB should also take note of the new instance's IP to expand their knowledge of the network.
When an instance of DDB is expected to go down, it should send a farewell message to every known node in the network to inform them of it's passing. Those nodes will then have the opportunity to acknowledge the farewell and pay their respects. While it won't be received since the dying node will probably have died, it is only courteous.
{
"command": "farewell",
"name": <Unique name>
}
Nodes in the network may crash. Since crashing in computers happens very quickly, the crashing node won't really have time to tell the rest of the network its going down; the responsibility will fall on the rest of the network to know about fallen comrades.
To accomplish this, every 3 min of inactivity, a "checking of the vitals" pulse is to be sent to all the nodes on the known nodes list. When a node receives one of these vital checks, it should respond with a "im not dead yet, piss off" message.
{
"command": "finally we get the inheritance"
}
{
"command": "im not dead yet, piss off"
"name": <Unique name>
}