Scalability issues (UDP)

Started by
4 comments, last by brokilodeluxe 10 years, 10 months ago

I'm designing an online top down fighting game with the XNA C# framework. It uses the host/joiner architecture common in first person shooter games. It's supposed to support up to 16 players.

The game works fine up to ~6 players. After that, every player besides the host (all the joiners) starts getting bad latency issues for some reason. I've had my nose in server/client code for months, and I'm honestly at a loss. Is there a certain tool besides Visual Studio that specializes in analyzing server/client communication?

The fact that the host works completely fine despite everyone else lagging concerns me. I know the server isn't getting bottlenecked since the host has a client just like anyone else, and has to communicate with it, even if it is just through the loopback address. My packet sizes also tend to stay under 1kB so I dunno.


Logic is:

Game.Update:

  • Client.Update;
  • If you're the host: Server.Update;


Server.Update:

  • Check for inputs;
  • Assign inputs to players;
  • Level.Update;
  • Send level data unreliable sequenced to all clients;

Client.Update:

  • Check for server messages
  • Fill in level with message data
  • Level.Update
  • Send input unreliable sequenced to server
Advertisement

You are likely saturating your network bandwidth on the Server.

Remember that additional clients are a geometric bandwidth progression.

Server + one client: Network traffic for AI (if applicable) plus the activities of the server player sent to one client, bandwidth on the order of (AI + P)

Server + two clients: Network traffic for AI (if applicable) plus the activities of two players sent to two clients, bandwidth on the order of (AI + 2P) * 2

Server + three clients: Network traffic for AI (if applicable) plus the activities of three players sent to three clients, bandwidth on the order of (AI + 3P) * 3

Looking at this, you can see that traffic is going up approximately by the square of the number of connected clients. So going from 5 connected clients (6 players) to 6 means that we go from (AI + 5P) * 5 to (AI + 6P) * 6, roughly a 50% increase in bandwidth required.

The host player is fine because they aren't going over the overburdened network connection.

So from what I've read, that means I should basically try to cut down on my byte size, right?

So it doesn't get all multiplicative and evil.

another typical strategy used in action games is to send updates with different rates based on the distance between players.

So, for example, player A would get the 5 closest enemies at the highest possible rate and plus up to 5 more in a round robin fashion.. so you know that your server bandwidth cost becomes linear once you go over 10 players.

But ya.. most of the work is trying to reduce packet size and rate anyway.

Stefano Casillo
TWITTER: [twitter]KunosStefano[/twitter]
AssettoCorsa - netKar PRO - Kunos Simulazioni

The art of the network engineer is knowing what not to send, and how often to not send it.

So, first, look for everything that can be inferred by another piece of information. If a specific gun firing always generates the same sound, and you know what gun the actor has, then you don't send both a FireGun message and a PlaySound message, the one is inferred from the other.

Next, measure. What packets are you sending the most often. Optimize these down to as compact a form as you can.

Next, throttle. If you send a change of direction packet for the player every time their vector changes slightly then human mouse interactions are going to generate a lot of unneeded traffic. So for an FPS, you want to send an updated movement packet (here is my facing, position, speed) at a throttled rate, with exceptions for things like starting and stopping which will be really obvious if held.

Then, affinity filtering. Send information based on what they need to know. In the original Rainbow Six, every actor in the game had its position updated in the game over a reliable channel to all players on a 1 hz strobe. However, if another actor was in the same room, in an adjacent room, or there was a line of sight relationship (these were cached by the engine anyway), you would get unreliable updates (throttled as above) for them as movement changed.

Alright, thanks for the info guys! I think I understand what to do now.

Back to the grindstone.

This topic is closed to new replies.

Advertisement