Sign in to follow this  
jamesd128

determining network delay

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
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

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