Time synchronisation

Hello,

Because Network.Time doesn’t work in Unet, i have a big problem of time synchronisation between server and clients.

I build this to compensate the lack of time synchronisation :

        void BaseOnTimestampSynchronisation(NetworkMessage netMsg)
        {
            byte error;

            if (!NetworkServer.active)
            {
                timestampDelta = netMsg.ReadMessage<IntegerMessage>().value;
                timestampDelta += NetworkTransport.GetRemoteDelayTimeMS(client.connection.hostId, client.connection.connectionId, timestampDelta, out error);
                timestampDelta = timestampDelta - NetworkTransport.GetNetworkTimestamp();
            }
            else
                timestampDelta = 0;

        }

The server send it’Timestamp on client who connect. The client calcul the difference between Timestamp + time to receive this TimeStamp and it’s current NetworkTransport.TimeStamp.

When i want the server Timestamp on a client i do :

        public int ServerTimestamp
        {
            get { return NetworkTransport.GetNetworkTimestamp() + timestampDelta; }
        }

Is this correct ? I have some doubts and i need a very accurate server time since i want movement synchronisation dead reckoning technique.

To be honest, I dont exactly know what the functions above do but it seems logically.
But if you rely on precision keep in mind the network is NO fixed system. Pingtimes change. When you sync the time and due to whatever reason you have a ping of 2000ms, your future timestamps will be off 2000-x ms
Also transfertimes from server/client and client/server may vary
Here is a similar algorithm Cristian's algorithm - Wikipedia
Maybe this will interest you, but it is a bit more complicate: Precision Time Protocol - Wikipedia