By Jasper


2019-03-11 14:30:00 8 Comments

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.

1 comments

@Kromster 2019-03-12 07:35:53

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!

@Jasper 2019-03-13 19:40:27

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 :)

@Jasper 2019-03-13 19:42:47

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).

@Jasper 2019-03-13 19:43:37

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.

@Jasper 2019-03-13 19:51:51

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.

@Kromster 2019-03-14 04:38:55

@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)

@Jasper 2019-03-14 19:14:11

Ah, I misunderstood. I have one of the players act as a server. In that case it needs to be redundant so the rest can keep playing after the server player leaves due to a loss/connection problem. If you are interested, I will give you a bump on here if the new network system is in place.

@Kromster 2019-03-15 04:09:47

@Jasper in our case, server and player are "separate". There's a server process and players process (iirc), so it just "happens so" that server and one of the players are on the same physical machine. Typically, when player leaves, we can just save game, let players back into the lobby and restart the game from the save with new server/host.

Related Questions

Sponsored Content

2 Answered Questions

[SOLVED] UDP Netcode Architecture for Fighting Game

1 Answered Questions

0 Answered Questions

RTS Networking in Unity: Client-Server vs. Lockstep

0 Answered Questions

1 Answered Questions

[SOLVED] Unity 5: Use Network Simulator, should I?

2 Answered Questions

[SOLVED] Networking with UDP, should I keep sockets open on the server

0 Answered Questions

client-server network model for top-down WASD game

2 Answered Questions

[SOLVED] Peer-to-peer first person shooter

Sponsored Content