Archived

This topic is now archived and is closed to further replies.

Eddie T Sehoo

Reducing network latency

Recommended Posts

I recently read an article about Microsoft''s Age of Empires game and how they handled network latency. (Btw, this applies particularly for 2D graphics). Doing it in 3D might differ a bit. A few methods were outlined. To summarize, their method involved the sending of data packets from client to server to synchronize player status with the server and all the other clients connected to the server WHILE the animation frames for that player are being drawn. This would therefore lead me to think : If I have longer animation cycles,or prolong a player''s movement (Eg: say, holding the up key on the keyboard for one second moves the player 10 pixels forward in a networked game while it''ll only move a player 5 pixels forward in a single-player game in 1 sec)would that directly mean I have more time for the server to synchronize with the other clients therefore reducing the chances for network latency ? Is this the way how games like networked FPS-es are being done?) Just another thought : The article also recommended the transmission of user input (mouse clicks, keystrokes), instead of game object statuses. In this sort of paradigm, basically everything in the game will have to abstain from using pure randomly generated numbers, since every game object on every machine in the same world would have to respond in the exact same way to the user input. I find this a pretty efficient way of reducing packet size.. But I''m not sure about the kinda problems you''d encounter with re-synchronizing unsychronized clients. Anyway, anyone with any idea on my question in my 2nd paragraph,pls let me know. Thanks! Regards, Eddie for (i=0;i<=forum_replies;i++) { if (reply.useful==true) { my_knowledge++; } }

Share this post


Link to post
Share on other sites
You don''t have to avoid using random numbers in networked games; in fact there are many cases where this is next to impossible.

The solution is to design your game such that the server generates a list of random numbers. You then send this list of random numbers to each game client as they connect, so that each players local state will be the same as the one on the server (since the server and the client will both run the same game logic, using identical random numbers for both should produce the same simulation +/- a very small percent for rounding error.)

Regarding the player movement, you should design it such that your own game client is responsible for moving itself. Dont rely on the position data the server returns about your local copy to update your own position.

Hope this helps,

neko

Share this post


Link to post
Share on other sites
You don''t need the server to send a list of random numbers. That idea was not lunatic enough to be April Fool''s, but close enough ;-)

Each unit has a unit ID. Each random number is asked for during some timestep in the game. Each unit asks for some number of random numbers in that timestep.

What you should do is make sure that your simulation path is 100% consistent, given the same inputs. Then, you make your random number function take unit id, timestep value, and what random number in sequence it is during this step for that unit, and hash that into a random number (i e, use that as a seed, and return a single random number from that seed).

That way, all the copies of that same unit will generate the same number during the same time step, and will thus make the same decisions.

Be careful to use another random number generator for visual/audible things that don''t affect the simulation, though; particle systems, sound variance, etc.

Share this post


Link to post
Share on other sites
Thanks for the input guys.
On the other question about the animation frames, are animation sequences for objects in the game actually interpolated/extended in a network game to reduce network latency?

Why I ask this is because I used to play networked Command&Conquer on an old 56K connection, and basically, when I moved my unit to a specific location (Clicked on a spot about 3 tiles away from the unit) , the unit would move along the path, and then when it was halfway through, I would click in another direction. However, the unit didn''t respond immediately (like it would in the single-player mode). Its movement would sorta extend and go on for a while, before turning away into that new direction I gave it.
In other words, gameplay becomes smoother due to reduced network latency at the expense of slightly reduced responsiveness to user input.

Is this method commonly used in games? This doesnt just apply to Real time strategy games, I think it might even apply for first person shooters.. I just want to know if this is how they''re doing it to reduce network latency, or maybe, there''s a better way?

Thanks for your help,
Regards
Eddie

for (i=0;i<=forum_replies;i++)
{
if (reply.useful==true)
{
my_knowledge++;
}
}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
In an RTS game, each player runs the exact same simulation and commands are exchanged and synchronized at precise game intervals (in the case of AoE, there is a lag time of about 200ms between command being issued and it being executed in the simulation). Ramdom number sequences are also identical on both sides once the seed is agreed with upon connection. You compensate for delays when the received command''s timestamp is after the current execution timestamp and you must then lenghten the command-to-execution cycle dynamically. When an issued command doesn''t match the game state at all then you know that either the synchronization is gone totally wrong or you are faced with a cheater. In either case you cut the link off because the game is in jeopardy.

In an FPS game, it''s a shouting match between the clients and the server. The server updates each client every 50ms or so, and the client sends movement commands when they are issued by the user. It doesn''t matter if UDP packets gets lost or not because you will always get another update 50ms later. Also, messages are numbered so that you can discard older messages when they come in late.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
for (i=0;i<=forum_replies;i++)
{
if (reply.useful==true)
{
my_knowledge++;
}
}

Mmh... I think it should be:

for (i=0; i<forum_replies; i++)
if (reply.useful())
my_knowledge++;

Share this post


Link to post
Share on other sites
Thanks for the tip, anonymous ...
and for the correction on my signature! =p I wouldn''t have noticed the ''<='' if you hadn''t told me. Now I''ll just pray I didn''t put <= in all the wrong places in my game code.

Regards,
Eddie



for (i=0; i{if (reply.useful)
my_knowledge++;}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Shouldn''t it be:

if (reply.useful())

Share this post


Link to post
Share on other sites
Well, .useful is the boolean property in an array holding a list of Reply Classes, so I didn''t define it as a function. But then again, that would have become
if (reply->useful==true) {my_knowledge++;}

(btw, I''m also quite used to using curly braces...helps me see where the if statement ends)

I''ve decided to just drop that silly signature anyway.
lol..
Regards,
Eddie

Share this post


Link to post
Share on other sites
Well, .useful is the boolean property in an array holding a list of Reply Classes, so I didn''t define it as a function. But then again, that would have become
if (reply->useful==true) {my_knowledge++;}

(btw, I''m also quite used to using curly braces...helps me see where the if statement ends)

I''ve decided to just drop that silly signature anyway.
lol..
Regards,
Eddie


I have no signature. Really.

Share this post


Link to post
Share on other sites