I want to write a simple implementation of the Gossip Algorithm in Java, but I'm having trouble figuring out where to get started. I'm very new to this kind of network programming and don't know where to get started. The concept is that I want to create a code that will simulate temperature sensors in a building that collects heat in Kelvin. Using gossip algorithm, it will use a push-sum protocol that collects the average of the temperatures in the building using this algorithm: si is the inital sum and wi is the inital weight
1: Let {(Sr, Wr)} be all pairs sent to i in round t – 1 (Previous round)
2: Let st, i := ∑〖Sr, Wt,i〗 = ∑Wr (Sum of all received pairs)
3: Choose a target ft(i) uniformly at random
4: Send the pair (1/2st,I , 1/2wt,I ) to ft(i) and i (yourself)
5: (St,i)/(Wt,i) is the estimate of the average in step t
the algorithm should allow for new sensors to be added without changing any code
I've done a lot of looking up and don't really know how I'll be able to set up this basic communication between the sensors (They all must run the same code). If possible, I would appreciate a point in the right direction on how to set this up properly, a good starting point and I should be able to get the rest of it done myself, thanks!