Skip to main content
GameDev.net gamedev.net
🔒 Locked

Some ballpark figures (packets per second, using Lidgren)

Started by james_lohr Jul 3, 2009 at 5:52 PM 1 replies 1.8k views
Original Post
james_lohr
james_lohr
I'm currently writing a client-server platform for real-time multiplayer games using lidgren/C#. It's going extremely well, with "smooth" results even up to fairly high latency (500ms or so). Anyway, to make some optimization decisions, I need to know a few ballpark figures, namely how many packages per second is reasonable for the server to be sending out (on a single port). The platform works by maintaining an "ExactState" on all clients and on the server. The only data sent across the network is what I call "EventRequests", which are essentially user inputs. This is of course enough to maintain identical "ExactStates". To get smooth motion, I use varioius tricks such as a "predictiveStates", interpolation techniques and other stuff clever stuff like input predictions. Anyway, at the moment it's very efficient: one tiny packet is sent to the server per keypress/release per player. These are set into a fixed order on the server and sent back to the clients in a bundle of around 10 server-ticks (assuming 60hz server, this would be around 6 per second). These ordered bundles of EventRequests I call "GameStateControlPackets". Now the issue here is that an additional, worst case, X ms of latency (where X is the length of time to build a GameStateControlPacket") is introduced between clients. This is because, when another client requests an event, this request must go to the server, and then only gets sent out with the next GameStateControlPacket. Currently this introduces a worst case of 160ms. This is a lot in a real-time game where enemy positions are critical to gameplay, plus it's ontop of the actual network latency. To get around this, I would like to immediately send out "PredictionRequests". These are sent out by the server to all users as soon as any EventRequest is received from a client. Of course, since they're not in a fixed order, identical state cannot be maintained by using them. However they are used in the predictive part of the client. Most of the time they're correct, and when they're not, the resultant "incorrect" state is interpolated into the ermergent ExactState. Looking at a few worst-cases: Let us say the server is hosting 25 games, each with 4 players per game. Now let's say players are going a bit wild and making 10 press/releases (triggering EventRequests) per second. This would mean that the server is sending out (10*4*3 in each game) * 25 = 3000 of these PredictionRequests packets per second. (Note that they are tiny UDP packets, and can be sent unordered and unreliably) I have no idea if this is totally unreasonable. At a glance it does seem like rather a lot; especially when you consider that, without these "PredictionRequests", the server would only be sending out 625 "GameStateControlPackets" for the same scenario (25 games with 4 players each). But actually, even 600 per second seems a lot: The data I'm sending across is often only a few bytes, but I'm sure there is overhead associated with each UDP packet. Any insight would be greatly appreciated. Questions 1) What is considered "a lot" of traffic for a typical server to deal with? 2) Would assigning a separate port per game give better performance? 3) Will Lidgren be sufficient for this? (I'm having a really hard time finding any sort of documentation on the library)
Antheus
Antheus
Quote:
Original post by james_lohr
1) What is considered "a lot" of traffic for a typical server to deal with?


When you approach the limits of what you can handle. As long as you are not CPU bound, tens of thousands per second is not a problem.

Quote:
2) Would assigning a separate port per game give better performance?

For UDP not really, although later (not at 600/sec) they might give you some leeway with regard to network buffers. Perhaps.

Quote:
3) Will Lidgren be sufficient for this? (I'm having a really hard time finding any sort of documentation on the library)


Unless there is some gross inefficiencies, networking related part should not be a problem on any semi-recent machine.

Quote:
The data I'm sending across is often only a few bytes, but I'm sure there is overhead associated with each UDP packet.


Overhead is 28 bytes per packet. It usually pays off to batch the sends, if possible.


But as long as you intend to have dedicated hosting, then the user's connection is what will probably matter more.
hplus0603
hplus0603
Quote:
when another client requests an event


Why would clients *request* events? Isn't it the case that all clients within visibility will want all events they can see? And wouldn't it be more efficient, then, for the server to just send them to the client as soon as possible?

The answers from Anteus are right: don't worry about it. As long as you bundle multiple commands/events into each UDP packet, you're probably doing OK.
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.