You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
This repo contains a toy gossip protocol implementation, basically used for didactic reasons. It canbe used as a base to build and test gossip protocols.
My idea is to be able to use this as a base for crazy ideas and do a little bit of research about gossip and epidemic protocols over a distributed network.
The system contains a java server that listens to incoming calls, everything wrapped in a Docker container.The system also has adocker-compose file to simulate the distributed system.
The gossip protocol is basically a propagation using random IP's from the system range, so there is noassurance that it will work fine in all the cases. The file that contains this decision iscom.github.lant.gossip.GossipStrategy .Modify it to get different results.
Gossip strategy
The current implementation is a very naive and primitivepush based strategy:
The nodes periodically propagate their value to 3 random nodes in the network.
The nodes compare the value they receive with a version, right now it's the timestamp when the value was created by thepropagator
When a node receives a new value it propagates it immediately without waiting for the periodic propagation.
If the value is the same, or an older one it silently ignores it.
These simple features are the basic ones for a proper gossip protocol.
Bootstrapping and peer information propagation
Bootstrapping and peer discovery is also an interesting problem to solve. Currently when a peer starts it checks its networkand starts querying the possible nodes in that network from bottom to top (starting at X.X.X.1 to X.X.X.X) in order to findanother peer.
When it finds a peer they share their contact info. After that the initial bootstrap process is finished.
After the initial bootstrap to set up the system every subsequent interchange of information (value propagation) also containsinformation about the known nodes. So, the propagated values contain the value, the timestamp and information about the knownpeers from every peer. This way we guarantee that the peer contact information is continuously updated in all the peers.
For further ideas and information check the bibliography section.
Execute and test the system
To run the system you need to compile the code:
./gradlew installDist
and after that you can execute the docker:
docker-compose builddocker-compose up --scale node=10
This will start the 10 instances that will listen for new propagation values.
There is a script calledpropagate that's using the class:com.github.lant.gossip.Propagate in order topropagate values. It takes two parameters:port andvalue.
It will propagate thevalue to the node listening to that port. In order to execute it rundocker ps to getthe port mappings:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESb636473bfd3e gossip_node"/bin/sh -c /gossip/…" 17 seconds ago Up 15 seconds 0.0.0.0:7012->7000/tcp gossip_node_99922040ab0b9 gossip_node"/bin/sh -c /gossip/…" 17 seconds ago Up 14 seconds 0.0.0.0:7016->7000/tcp gossip_node_64520094644e3 gossip_node"/bin/sh -c /gossip/…" 17 seconds ago Up 14 seconds 0.0.0.0:7017->7000/tcp gossip_node_10e54d26064f8e gossip_node"/bin/sh -c /gossip/…" 17 seconds ago Up 15 seconds 0.0.0.0:7013->7000/tcp gossip_node_841179de9eec4 gossip_node"/bin/sh -c /gossip/…" 17 seconds ago Up 14 seconds 0.0.0.0:7014->7000/tcp gossip_node_570b2b5cc6831 gossip_node"/bin/sh -c /gossip/…" 17 seconds ago Up 15 seconds 0.0.0.0:7018->7000/tcp gossip_node_711de74af17f6 gossip_node"/bin/sh -c /gossip/…" 17 seconds ago Up 15 seconds 0.0.0.0:7015->7000/tcp gossip_node_4b857e04524eb gossip_node"/bin/sh -c /gossip/…" 8 minutes ago Up 17 seconds 0.0.0.0:7011->7000/tcp gossip_node_325d4bd3acfc0 gossip_node"/bin/sh -c /gossip/…" 8 minutes ago Up 17 seconds 0.0.0.0:7009->7000/tcp gossip_node_1bf28387cf26c gossip_node"/bin/sh -c /gossip/…" 8 minutes ago Up 16 seconds 0.0.0.0:7010->7000/tcp gossip_node_2
and then just use one of the mapped ones:
./propagate -p 7009 --value asdf
This will propagate the valueasdf into the nodes. It will usenode_1 as the initial propagator.