📡 Gossip Protocol Simulator
Epidemic-style information dissemination across distributed nodes
Overview
Gossip protocols (epidemic protocols) spread information through a network by having each node periodically share data with random peers — much like how rumors spread in a social network. They provide probabilistic guarantees of consistency with O(log n) convergence rounds and remarkable resilience to node failures and network partitions.
This simulator implements push, pull, and push-pull strategies with convergence tracking, partition simulation, anti-entropy repair, and an autonomous protocol advisor.
Concepts Demonstrated
- Epidemic algorithms — SIR (susceptible-infected-removed) model for data spread
- Push vs Pull vs Push-Pull — trade-offs between bandwidth and convergence speed
- Fanout tuning — number of peers contacted per round affects reliability
- Network topologies — full mesh, ring, random graph
- Anti-entropy — consistency repair via full state exchange
- Partition tolerance — behavior under network splits and healing
Gossip Strategies
| Strategy | Mechanism | Trade-off |
|---|---|---|
| Push | Infected nodes send updates to random peers | Fast initial spread, wastes bandwidth near convergence |
| Pull | Nodes query random peers for updates | Slower start, efficient near convergence |
| Push-Pull | Both directions in one exchange | Best convergence — O(log log n) rounds |
How It Works
(* Create a network of 100 nodes *)
let net = Network.create ~topology:FullMesh ~size:100
(* Infect node 0 with a rumor *)
let net = Network.infect net 0 { id = "breaking-news"; data = "..." }
(* Run gossip rounds until convergence *)
let result = Gossip.run net ~strategy:PushPull ~fanout:3
(* result.rounds = ~7 (log₂ 100 ≈ 7) *)
(* result.coverage = 1.0 — all nodes received the rumor *)
(* Simulate a network partition *)
let net = Network.partition net ~groups:[[0..49]; [50..99]]
(* Gossip within partitions converges; healing merges knowledge *)
let net = Network.heal net
let result = Gossip.anti_entropy net (* repair any inconsistencies *)
Real-World Uses
- Cassandra / DynamoDB — failure detection and schema propagation
- Consul / Serf — cluster membership via SWIM gossip
- Bitcoin — transaction and block propagation
- CockroachDB — node liveness and range metadata
Related Modules
- CRDTs — data structures that merge without coordination
- Raft — consensus via leader election (stronger guarantees)
- Consistent Hashing — distributing data across nodes