• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Bow_vernon

measuring latency

3 posts in this topic

I know that in order to apply 'smoothin out' algorithm (client side prediction, extrapolation), one has to take into account the latency factor. But it kinda dazzled me as to whom should calculate it and how it is generally measured.

 

1. Who gets the burden?

-Do the server do the calculation and tell the client overtime?

-Do the client do it (since it is him who needs to be smoothened)

-Do the server and client each has their own pingtime?

 

2. How would one calculate it?

right now I simply use the simplistic ping approach (e.g., send "ping" message and teh server quickly throw back the reply).

however, it was too simplistic and pingtime was generally change overtime (they sure are very random). Thus the second question. But if we use the average pingtime, it sometimes won't be correct, right? plus if I have to use average pingtime, that means I have to already have several ping results at hand. What if the game has just begun? should I spend my time calculating pingtime first?

 

3. How was it generally used?

Example scenario:

-client send message that he just pressed "move forward" button. In order to hide latency, he directly moves his avatar forward locally.

-by the time the message reaches the server, however, it's already too late. perhaps by 100 ms. then the server should simulate as if player pressed the button 100 ms ago, thus the server must do "extrapolation" by 100 ms. CMIIW.

-client stopped pressing forward key, thus he sends "stop pressing forward" message to server.

-the server gets the message 100 ms later, oops that means our player is moved too far by 100 ms, so his position must be corrected by 100ms

(pos = pos + vel * -0.1). as such, the server send a position update message to player

-the client received the message, assume it's late by 100 ms. but since this is corrective position, the client simply stick his current position to the server's corrective position. He might also use interpolation (so it looks like sliding over rather than snapping) to alleviate graphical jerkiness.

 

So am I right on number 3?

 

4. bonus question. I recently have a chat with some gamedev over IRC, we were discussing minecraft. I threw a question regarding its networking, and some fellow said that the send rate is very low (a particular guy even said that it's only 5 TIMES A SECOND!! WTF!!). that means it sends every 200 ms. now I wonder about its update rate. since minecraft is kinda "physics"-is, I bet they use at least 30 fps update rate. But since I can't get a look at their sources, I can't confirm my curiousity. Do any of you guys know about this? thanks a lot.

 

Those are my questions, I hope you guys could help this confused guy. Anyway, thanks for your time reading this blocks of text.

0

Share this post


Link to post
Share on other sites

I know that in order to apply 'smoothin out' algorithm (client side prediction, extrapolation), one has to take into account the latency factor. But it kinda dazzled me as to whom should calculate it and how it is generally measured.

 

1. Who gets the burden?

-Do the server do the calculation and tell the client overtime?

-Do the client do it (since it is him who needs to be smoothened)

-Do the server and client each has their own pingtime?

 

2. How would one calculate it?

right now I simply use the simplistic ping approach (e.g., send "ping" message and teh server quickly throw back the reply).

however, it was too simplistic and pingtime was generally change overtime (they sure are very random). Thus the second question. But if we use the average pingtime, it sometimes won't be correct, right? plus if I have to use average pingtime, that means I have to already have several ping results at hand. What if the game has just begun? should I spend my time calculating pingtime first?

 

3. How was it generally used?

Example scenario:

-client send message that he just pressed "move forward" button. In order to hide latency, he directly moves his avatar forward locally.

-by the time the message reaches the server, however, it's already too late. perhaps by 100 ms. then the server should simulate as if player pressed the button 100 ms ago, thus the server must do "extrapolation" by 100 ms. CMIIW.

-client stopped pressing forward key, thus he sends "stop pressing forward" message to server.

-the server gets the message 100 ms later, oops that means our player is moved too far by 100 ms, so his position must be corrected by 100ms

(pos = pos + vel * -0.1). as such, the server send a position update message to player

-the client received the message, assume it's late by 100 ms. but since this is corrective position, the client simply stick his current position to the server's corrective position. He might also use interpolation (so it looks like sliding over rather than snapping) to alleviate graphical jerkiness.

 

So am I right on number 3?

 

4. bonus question. I recently have a chat with some gamedev over IRC, we were discussing minecraft. I threw a question regarding its networking, and some fellow said that the send rate is very low (a particular guy even said that it's only 5 TIMES A SECOND!! WTF!!). that means it sends every 200 ms. now I wonder about its update rate. since minecraft is kinda "physics"-is, I bet they use at least 30 fps update rate. But since I can't get a look at their sources, I can't confirm my curiousity. Do any of you guys know about this? thanks a lot.

 

Those are my questions, I hope you guys could help this confused guy. Anyway, thanks for your time reading this blocks of text.

1. This depends on where and why do you need it. For smoothing out latency in a fps you propably would calculate latency in the server since it needs to know where each client was when one pressed the trigger to see who got shot.

 

2. There are a few ways. Easiest being just to measure how long the server or client takes to respond to a simple short message.

 

3. There are quite a few things you could use the latency for. Movement prediction and correction is perhaps the most common use.

 

4. Minecraft suprisingly doesn't have that much physics in it. And as far as I know its network update rate depends on the servers tickrate so with a lot of mods it can be as low as once in every 2-10 seconds. The tickrate is capped at 20 meaning it would update 20 times a second at most. But the update rate is not that important in a game like minecraft. A 5hz rate would be more than enough. For example battlefield 3 and 4 updates 10 times a second and its a twitch shooter where life and death depends on a few milliseconds. This is exactly where latency corrections and such come into play to smooth things out.

1

Share this post


Link to post
Share on other sites

Hey, thanks for the reply. I really appreciate that. I recently read an old article at flipcode. This is how (I think) the article proposed its method in lag compensation. Sadly it doesn't quite explain the algorithm in detail.

 

1. Assume that we already had latency measured.

2. Client press forward. Send +FORWARD message to server. Do not wait for reply, directly move avatar.

3. Server receive it. Perhaps 100 ms later. Doesn't matter. Start moving player in server's simulation.

4. Server still needs to periodically sends position update, although at a smaller rate. Assume server's tick rate is 5 Hz. so every 200 ms, if player is moving, the server will send its position+velocity.

5. So client got the position update, assume it's at 100 ms latency. Player will calculate new position using extrapolation. So new_pos = pos_update + vel_update * latency.

6. Well, now we got new pos, we need to compare our current position with calculated position. Then we interpolate our current pos to the newly calculated position over time, hopefully the gap won't be too big.

 

Still, I had no experience regarding lag compensation technique. Can anyone suggest another readings/maybe some source code?

0

Share this post


Link to post
Share on other sites

Here is some source code that lets you play with a particular interpolation/extrapolation algorithm on a single computer:

 

http://www.mindcontrol.org/~hplus/epic/ (Entity Position Interpolation Code)

 

It also contains a C++ template you can use for your own interpolation implementation.

Edited by hplus0603
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0