📡 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

Gossip Strategies

StrategyMechanismTrade-off
PushInfected nodes send updates to random peersFast initial spread, wastes bandwidth near convergence
PullNodes query random peers for updatesSlower start, efficient near convergence
Push-PullBoth directions in one exchangeBest 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

Related Modules