2
\$\begingroup\$

I'm currently working on a game in which I am considering implementing a networking architecture as described in this article: http://www.gamasutra.com/view/feature/131503/1500_archers_on_a_288_network_.php

In order for the implementation as described in the article to work, all peers need to be interconnected without any exceptions. Like so:

A "star" configuration of peer-to-peer clients in a session.

This works fine when everything is well. But I am wondering how to agree on disconnects in such a network. (Sadly something the article does not go into). It is relatively easy if one client goes down. Just give every client a timeout, and if a client does not respond for a certain time, it is removed from that client.

However, how should the system solve a case in which one client does not respond to another, but still responds to all others. In such a system the following could happen, resulting in a invalid state:

Invalid state

Of course this can be solved by giving one of the clients some kind of "master" role. It being the only one that can decide whether or not to disconnect other clients. But I'm wondering if it can be achieved in a pure p2p network.

Note I realize this case is not one that can likely occur "naturally". But I want to prevent players from being able to ruin a networking game for others by playing a trick like this by using the firewall for example.

\$\endgroup\$
  • 2
    \$\begingroup\$ 'this case is not one that can likely occur "naturally" ' Really? Wouldn't it occur any time you have two peers in the network who are each behind strict NATs? They'd be able to connect to their open-NAT peers by sending the first message and accepting replies, but neither strict-NAT peer would accept an initiating message from the other strict-NAT peer, unless I'm misunderstanding something. \$\endgroup\$ – DMGregory Mar 11 at 14:52
  • \$\begingroup\$ same as @DMGregory, this is very unlikely to occur. It might be that "invalid Network state" might be the one you initialize to, but it's hard to imagine a situation where the previous perfect network would drop down to that \$\endgroup\$ – Hobbamok Mar 13 at 13:43
  • \$\begingroup\$ @Hobbamok This is the reason I write not "naturally". It could occur if someone added a specific rule to a firewall for example. I wouldn't want one client to be able to ruin the whole game. But even if this were not the case the question is not whether it will occur, but rather how such a network would handle it. In my opinion it should. \$\endgroup\$ – Jasper Mar 13 at 19:29
  • \$\begingroup\$ @DMGregory As Hobbamok also pointed out, my case refers to one that happens after initialization. It is unlikely, but I am still curious if it is possible. \$\endgroup\$ – Jasper Mar 13 at 19:30
2
\$\begingroup\$

First of all you need a way of detecting such issues and separate them from simple packet loss. Once you know you really have this happening and really need to work around this, there are several solutions you could try:

  • Simplest solution, just drop the player
  • Allow to re-route messages/packets via different peer (i.e. assign a peer who will send out not only his commands, but other peers commands to "problematic" peer)
  • Upgrade the topology and introduce a stable host that will act as a re-transmitter for all the peers. Optionally it could also become a short-time cache to drastically reduce number of packets in exchange.

P.S. We have RTS topology with all packets routed through the host/server (option #2, to avoid the OP problem in the the first place) and recently started to struggle with packet counts, after raising players count in a game from 8 to 12 - that is 12 players, 10 ticks/sec, each sending message and ack = (1+11+11*2) * 10 = 320 packets/sec for each peer. Applying option #3 about now, iirc. If you have more questions, feel free to contact!

\$\endgroup\$
  • \$\begingroup\$ Thank you for your answer @Kromster. Actually I already went for the host/server solution you mentioned. I was merely curious how one would solve the issue I posted above :) \$\endgroup\$ – Jasper Mar 13 at 19:40
  • \$\begingroup\$ Related to the server topology: Dropping a client is very easy. The server just tells the other clients that the client is gone and the game continues. But have you also implemented a case for dropping the server? In my current implementation, if a client cannot reach the server anymore, it will simply turn into the server or poll the successor server in the topology (the same order for all clients of course) until someone accepts him. This works great (network can even split in half). \$\endgroup\$ – Jasper Mar 13 at 19:42
  • \$\begingroup\$ The only problem I have is hole punching. I think I need to initialize with all holes "punched" and keep the NAT "awake" using keep alive messages between the clients. Although this might be a bit overkill. :) I am curious if you solved this, and if so, how. \$\endgroup\$ – Jasper Mar 13 at 19:43
  • \$\begingroup\$ Can't figure out how to DM you here but I checked out the game linked on your profile page. VERY cool! As a fellow developer I appreciate the hard work you must have put into this. Keep it up! I also added my project to my profile if you want to check it out. The current version is quite old. Planning on uploading a new one in the coming month. \$\endgroup\$ – Jasper Mar 13 at 19:51
  • \$\begingroup\$ @Jasper we haven't had issues with servers dropping. They basically work 24/7 (you can check the servers charts on the kamremake website) and each is quite capable of handling 4-8 rooms. Since it's an RTS, we send "no command" every tick anyway (otherwise peers can not know if there really was no command or it got lost) and it acts as a reliable ping mesurement and "keep-alive". If you have more questions - best way to DM would be the Discord (link on the knightsprovince site). You've got a nice game going too! (reminds me of Planets Under Attack, which I liked quite a lot) \$\endgroup\$ – Kromster Mar 14 at 4:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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