Recently I've done with some simple test using Cirrus and then trying to apply it onto my project.
Before using Cirrus, each client hear from each other through the broadcast message from a socket server. Now I make them joining the same group to talk directly.
After test and verfied the function, then I added a logic to calculate the network latency like this:
1. A client is picked up as the group host.
2. It will call group.post() to send the Ping message every 10 sec.
3. Each client handles the post messge by response group.sendToNearest() to the host.
4. The host calculate the latency using the send time and receive time.
Actually, these two clients are on the same computer, but the result latency is around 500 to 1000 milisecond which is very slow and confused me a lot.
Would anyone please explain this to me? Or what could be the problem that I did wrong and not noticed.
posting does not propagate through a group instantaneously. the posting system is tuned for a reasonable tradeoff between overhead, fairness, and timeliness, for the scenario where every member of a group may post something every once in a while (which was the case for which it was designed).
sendToNearest/sendToNeighbor/sendToAllNeighbors perform immediately. note that for sendToAllNeighbors, a "neighbor" is a directly connected peer in the group, and you may not be directly connected to all members of the group (especially when the group has more than 10-15 members).
That really helps!