Search code examples
networkingp2pdhtkademliagossip

Use a DHT for a gossip protocol?


I've been digging about DHTs and especially kademlia for some time now already. I'm trying to implement a p2p network working on a Kademlia DHT. I want to be able to gossip a message to the whole network. from my research for that gossip protocols are used, but it seems odd to add another completely new protocol to spread messages when I already use the dht to store peers. Is there a gossip protocol that works over or with a DHT topology like Kademlia ?


Solution

  • How concerned are you about efficiency? As a lower bound someone has to send a packet to all N nodes in the network to propagate an update to all nodes.

    The most naive approach is to simply forward every message to all entries in your routing table. This will not do since it obviously leads to forwarding storms.

    The second most naive approach is to forward updates, i.e. newer data. This will result in N * log(N) traffic.

    If all your nodes are trusted and you don't care about the last quantum of efficiency you can already stop here.

    If nodes are not trusted you will need a mechanism to limit who can send updates and to verify packets.

    If you also care about efficiency you can add randomized backoff before forwarding and tracking which routing table entry already has which version to prune unnecessary forwarding attempts.

    If you don't want to gossip with the whole network but only a subset thereof you can implement subnetworks which interested nodes can join, i.e. subscribe to. Bittorrent Enhancement Proposal 50 describes such an approach.