tomp2p / TomP2P

A P2P-based high performance key-value pair storage library
http://tomp2p.net
Apache License 2.0
438 stars 122 forks source link

Broadcast messages gossip style #102

Closed lmatteis closed 9 years ago

lmatteis commented 9 years ago

Hello! I need a way to broadcast a messages to all the nodes in the network as quickly as possible. Can this be accomplished directly using the DHT (how would that work?) or does TomP2P provide facilities to enable gossip-style message broadcasting?

tbocek commented 9 years ago

The latest beta contains an efficient way to broadcast to all peers. Before Beta7, I had a random walk implemented, but you could not reach all peers and the overhead was quite high. Since Beta7, there is now a structured broadcast as explained in http://www.hiradastechnika.hu/data/upload/file/2009/2009%20I/Pages_from_HT0901a_2.pdf

With no churn, you can achieve a perfect broadcast, e.g., sending 20'000 messages for 20'000 peers. As in the network there will be churn, I set the redundancy level to 3.

There is a testcase for the structured broadcast: net.tomp2p.p2p.TestBroadcast.

Please feel free to open another issue if there is a problem with the structured broadcast

lsteffenel commented 8 years ago

Hello Thomas. I checked the example on net.tomp2p.p2p.TestBroadcast but I can't see how to send a message (the call to broadcast() accepts only a Number160 as parameter). Is there something missing?

tbocek commented 8 years ago

In BroadcastBuilder, you can set a dataMap. The BroadcastRPC checks for the dataMap, and if there is a map, then it is set in the message. The BroadcastHandler will take the Message for the parameter, where the dataMap can be accessed.