Latency
Catid says:
Source: http://catid.ssihosting.com/files/addendum.txt
Most people wonder what causes lag. It's pretty simple. When your average ping (the mean of a series of round trip packet times) is very different than your current ping (the last time between when a packet was sent and when a response was received), you are "laggy" because when the SubSpace client predicts the next location of someone.. ie.
-> = your ship's position Your PC -> Server -> Remote client -> -> ^^ ^^ Where your ship is on your screen. ^^ What the remote client knows for sure, the rest must be predicted.
...that number is affected by your average ping and not your current (true ping). In the diagram above, your ship should be where that last arrow is on other clients' screens. However, the packet that was sent by you took a while to reach that other computer so the location remote machines see is different than your actual location. This is described by the equation: ActualXCoord = SentXCoord + (RateInXDirection * LagTime)
Since it is impossible to know the time it took to send a packet (yes, it is impossible), all of the players on your screen are actually at their predicted position instead of actual. Using the loopback IP, 127.0.0.1, ping times less than 1 ms are very likely, but even then the time it takes to send a packet is impossible to determine.
Mr Ekted says:
Source: http://forums.powerballzone.com/read.php?board=5&id=42371
There's no way to know one-way latency on a network; you can only estimate it. The Subspace protocol does this as follows:
- The client sends a packet with its current time (in milliseconds) to the server every 5 seconds.
- When the server receives this packet, it immediately replies, sending back the client's time and the current server time.
- When (if) the client receives this reply, it now knows: how long it took (round trip) for the sync exchange, and the server time at some point in the "middle".
Example:
Client send time: 100 Client receive time: 300 Server time: 1000 (remember that the 2 internal clocks are not the same values) Round trip: 200 Server time estimate (at client time 300): 1000 + (300 - 100) / 2 = 1100
The actual clients do not use 50%, but 60%. Don't ask me why.
All packets that require time use the server time. This includes movement, weapons, and ball packets. If the sync packet exchange suffers an extra delay of 1000ms at the C rounter (from my picture), you would get something like this:
Client send time: 100 Client receive time: 1300 Server time: 1000 Round trip: 1200 Server time estimate (at client time 1300): 1000 + (1300 - 100) / 2 = 1600 Actual server time (at client time 1300): 2100
This creates "fake" C2S latency. So for the next 5 seconds, the client will send estimated times that are early by about 500ms, making the server think they were sent much further in the past than they were. If the client were allowed to continue to play under these circumstances, their ship would be displayed incorrectly by about 160 pixels at full speed in PB, and even more for weapons. Even though this latency is "fake", the sync issue is still bad enough that the client cannot be allowed to stay in game.