-
Notifications
You must be signed in to change notification settings - Fork 1
IMC 101
The IMC protocol defines the serialization of IMC messages (header, payload, and footer). Each message is identified by a unique number id, present in the header. The header also contains fields such as sync number, source, destination, and timestamp. Due to the nature of open-source software, different branches and forks exist, containing different messages and sync numbers. The protocol is compatible as long as the sync numbers used are the same on all ends of the network.
IMC does not define how nodes should connect with each other, so it's up to the application layer to define it. However, the core IMC provides messages to facilitate this communication. These messages are Announce and Heartbeat. Dune and Neptus implement a "Discovery and Announce" protocol, which does not assume the existence of any central/master node.
Each node must announce its existence by periodically (typically, each 10s) sending an IMC Announce message via UDP broadcast or multicast to the ports 30100, 30101, 30102, 30103, 30104. This Announce message contains, among other fields, all the external 'services' that an instance of DUNE is running. Each instance of DUNE should at least announce the imc+udp service, e.g.: imc+udp://10.0.80.10:30100; This imc+udp service represents the UDP socket where DUNE is listening for IMC messages via the UDP protocol. Other services typically announced include ftp servers, tcp sockets, etc.
Each node must listen for IMC Announce messages on the broadcast and multicast channels, in one of the following ports: 30100, 30101, 30102, 30103, 30104. In DUNE this is done by the Transports/Discovery Task. Each node must also maintain an internal list of known/connected nodes. A node should be added to the internal list of Known Nodes when an 'Announce' message is received from it.
For all nodes discovered by the 'Discovery' protocol, you should periodically send a Heartbeat message. If you inspect DUNE, you'll notice that this Heartbeat is periodically dispatched by the 'Daemon' Task. When a message is dispatched, it is captured by all Tasks that have subscribed to that message type using the 'bind' method. In the case of the Heartbeat, it is captured by the 'Transports.UDP' task, which proxies the message to all 'Connected' nodes.
A node X is 'Disconnected' from Y when Y has not receiveded from it any Heartbeat in the last 10s. A node X is 'Known' by Y if Y has ever received an 'Announce' message from X. A node X is 'Connected' to Y if Y has received at least 1 Heartbeat from X in the last 10s.
The Heartbeat message is used to establish and maintain communication between nodes. Both DUNE and Neptus will drop connection to a node when they stop receiving Heartbeats for 10s.