Gossip protocol is used to solve the Multicast problem efficiently. As I mentioned in my earlier post Multicast problem can be overcome by implementing Gossip protocol.
The modern distributed systems use this peer to peer gossip protocol to make sure that the information is disseminated to all the members in the network. Gossip protocol is referred to as Epidemic Protocol as it disseminates or spreads the data the same way as an epidemic spreads a virus in a biological habitat.
In the above figure, the source node is looking to transmit the multicast message to all the neighbours. To transmit the multicast message to all the neighbours efficiently gossip protocol can be used.
The multicast message is transmitted to other nodes in the form of gossip message.
The gossip message is a UDP packet which contains the copies of a multicast message.
The b is a gossip parameter here where it will be a typically small number
Working of Gossip Protocol:
- The source node will send the gossip message periodically to b random targets in the network.
2. Once the receivers get the gossip message the nodes are known as infected nodes and these nodes will do the same as the source node and transmit the gossip message to b random targets in the network periodically. The procedure can happen with replacement and the nodes can get multiple, duplicate gossip messages containing the same multicast message.
3. Finally, all the nodes transmit the gossip message and the multicast message will be received by all the receiver nodes in the network.
The nodes that which receives the gossip message are called as infected nodes and the others as uninfected nodes.
The variants in the gossip protocol are:
- Push — In push gossip protocol, once you have a multicast message, you start gossiping about it. If there are multiple multicast messages need to be transmit then, the messages can be sent as individual messages or gossip a random subset of messages or recently-received ones or higher priority ones.
- Pull — In pull gossip protocol, each uninfected node randomly picks another node and, if the selected node is infected, receives its message. The gossip messages that transmitted need not to contain multicast message it can also contain queries.
- Push & Pull — It’s a hybrid variant of push and pull gossip protocol. In push&pull algorithm, all the nodes pick another node at random and exchange their message if either node is informed.