FAForever/server

Perform client time sync on login

Askaholic opened this issue · 5 comments

We would like to send absolute times (ISO timestamps) instead of timedeltas, however, it turns out that a significant number of people have their system time configured incorrectly for whatever reason, which makes the computed deltas show up incorrectly on the client. To mitigate this we should send the current time to the client on login. The client can then compute the difference between this timestamp and the system time and adjust all future timestamps sent by the server using this offset. This should even help to adjust for client latency to the server assuming that the latency is relatively stable.

  • Add current_time to the command welcome sent to the client on login.

If you do this would need to send the current time more than once in other messages as there are plenty of people who leave clients open for days and there may be drift or other inconsistencies introduced

I'm not sure that's really necessary. Drift over a few days shouldn't be noticeable, and if they're going around messing with their system time manually, shouldn't the client be able to handle that on its own?

If the change their system time then the client couldn't readjust unless it got another message from the server with what the time is. Otherwise it has no reference point because it can't know how the time has changed as it doesn't get notifications of when the system time is changed externally.

Which I think fits the use case as the problem is caused by a misconfigured time in the first place. And if the client could work around that then the current_time wouldn't be needed at all. At least without the client needing to have a separate task that tracks the elapsed time since start up

Coudn't the client use 'Network Time Protocol' to sync time with any ntp server ?

The client can then compute the difference between this timestamp and the system time and adjust all future timestamps sent by the server using this offset. This should even help to adjust for client latency to the server assuming that the latency is relatively stable.

Notice this method will work only with several assumptions:

  • latency is 0
  • jitter is 0
  • client time cant jump

all of which are wrong is real life.