Vehicle Gossip Architecture - rpi-nsl/NSL-Spindle GitHub Wiki

The gossip code uses a layered architecture. Each 'layer' should implement INetworkObserver and INetworkSender. This makes it easy to add new layers.

The gossip 'logic' has two components, an IGossip which stores and formats the data and an IGossipProtocol which implements the actual gossip communication protocol. The IGossip doesn't necessarily need to be aware of the protocol and vice versa.

You can have several queries, each using different gossip protocols, data or operations. These protocols sit behind the QueryRouter which routes messages to the proper locations.

Gossip happens over Epochs. The EpochRouter caches messages from future epochs, throws out messages from old epochs and allows messages from the current Epoch to continue. It sits immediately below the query router on the message order.

Finally, the Network sends messages over the proper communication interfaces to the targets.

This whole process is managed by the Manager. It tracks the epochs, sets up and tears down protocols and coordinates queries.

The IGossipMessageData contains a raw data object and a UUID. As a message goes through the layers it is "build up" by nesting the original message in a new message type. When it is received these layers are pulled back.

A couple of notes:

  • You should be careful implementing any locking schemes that impact both the send and receive sides of a layer.
  • The code is crammed into the Spindle reducer logic. You need to be careful about changing this.
  • Docker bridges are used for networking and node discovery. For example, if we have a container named "node1" at ip 172.17.0.2 and want to connect to a service on port 8085 docker bridges make node1:8085 a valid address.