Advertisement

ping?

Started by April 13, 2004 08:10 PM
3 comments, last by Hedos 20 years, 10 months ago
I was wondering, the ping shown in most multiplayer game is the time between a packet can be sent from the client to the server or the time for a packet to be sent from the client to the server and then from the server to the client?
Ping is usually the time it takes to get a response. This could depend on several things such as network traffic and server load ( ie it make take a little bit of time for the server to process the ping request ). If you want just the network time then it may be better to have the server time stamp the return ping message with the received and ack''d times and let the client do calculations based on that. Even then, though, it will take the server a little bit of time to process incomming network messages.

==============
Andrew
Advertisement
>>If you want just the network time then it may be better to have the server time stamp the return ping message with the received and ack''d times and let the client do calculations based on that

The clocks on the two computers may not be synchronized so that doesn''t work...

Ping is the time it takes for a packet to go to the server and come back again.
The clocks don''t need to be synchronized, they just need to run at the same speed (which most clocks do, more or less :-)

Here''s how it works:

1) client time-stamps the outgoing packet, at time C-130
2) server time-stamps the incoming packet, at time S-3440
3) server sends response packet at time S-3470; it puts the values "C-130," "S-3440" and "S-3470" into the return packet. (Actually, it only needs to put the value "30" which is the difference between the server timestamps, and the original client time)
4) client receives the return packet at time C-180

The client now knows that it sent a packet at time C-130, it received a packet at time C-180, and the server spent 30 time units processing the packet. Thus, (180-130-30) is the network round trip time (== 20) which makes the one-way propagation time (assuming symmetry) 10.
enum Bool { True, False, FileNotFound };
Maybe i missunderstood but i was under the impression acraig was suggesting the time for the packet to reach the server could be calculated by taking the received time - sent time. Which would work in theory, but not if the clocks arn''t synchronised.

This topic is closed to new replies.

Advertisement