I am working on a P2P game in Flash and I'm wondering what network topology would be most robust for dealing with people randomly joining/leaving. I was thinking the first user to join could be the host, but if the host leaves the whole session would be killed. I am looking for a way to deal with this with no (or little) disruption.

up vote 8 down vote accepted

If you're using a model where there's a "host", you pretty much have star topology, however you dress it up. Recovery from loss of the central node in that model requires that all the nodes be able to find each other in that event (which makes it sound like mesh topology but it isn't), and either all of them have sufficient state to be able to take over the host role or they can reconstruct that state between them. Then you elect a new host by whatever method you like (I suggest lowest average ping to the rest of the nodes).

You can potentially do that with no disruption if the host leaves "nicely"; you start the host-role transfer process when they hit Quit and let them leave when it's done. If they leave by network interruption, force-quit, power loss, etc. there will be disruption.

If you do actual mesh topology, where each node has its own full state model and communicates about changes made to that out to everybody it's connected to, then you avoid the host role and the vulnerability that comes with it. The fun part then is conflict resolution -- working out what happens when two nodes try to propagate changes that contradict each other.

  • 2
    If players joining and leaving is a frequent event, it would likely be better to chose as the central host not based on ping, but based on "likeliness to not disconnect". (how to determine that value, is up to you) – o0'. Feb 20 '11 at 11:19
  • 2
    Lots of P2P networks use the metric that the longer a peer has been around, the less likely they are to leave. This probably doesn't hold for games, but it would be a good starting point. – Martin Feb 21 '11 at 1:32

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.