Jump to content
  • Advertisement
Sign in to follow this  
jamesd128

determining network delay

This topic is 3480 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to write an online game using C# and don't know too much about networking. The way I have it planned out, I need to know the delay in ms between when I send a packet and when one of the other players receives it. So, I have two questions: Does the TCP protocol already contain information on how long it took for the other socket to receive the packet (if so how do I extract it from C# Socket class? Is the time to send from A -> B roughly equal the time to send from B -> A? i.e. could I send a message there and back then take the time / 2 as the delay?

Share this post


Link to post
Share on other sites
Advertisement
Bouncing a message off the server and halving the latency is one common way of determining your ping. As long as nothing is bandwidth saturated the travel time in each direction is likely to be similar.

Share this post


Link to post
Share on other sites
Careful what you're using that information for. I have no problem delaying my outgoing packets if it'll let me speedhack around your world. ;)

Share this post


Link to post
Share on other sites
Yeah you shouldn't allow clients to bend the rules just because they have high latency. Things should be checked on the server when they arrive. But knowing the latency is useful for things like determining how often to send updates, which games to recommend the player join (or not) – you would recommend a high latency player not to join a turbo game, for example.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!