I’m doing some testing with the low level transport layer (UNET) and found out that Network.time is not the same on server and on client.
My understanding is that Network.time is suppose to give you the exact same time on client and server if both were called at the same time.
Now if that is true… then I am wondering how the network transport layer works since there’s about 30 MS time difference between the time on the Server and the time on the Client, keep in mind this is localhost…
question: is there meant to be 30 MS latency on localhost or am I doing something wrong?
I’m using on the client
NetworkTransport.Send ( m_hostId, m_connectionId, reliableChannel, buffer, buffer.Length, out error );
on the server
NetworkEventType networkEvent = NetworkTransport.ReceiveFromHost ( m_hostId, out connectionId, out channelId, buffer, 1500, out receivedSize, out error );
on the server.
Example gif below, first digits is the Network.time
Did a few other tests including System.DateTime.Now.Millisecond and it does appear that there is a 30 MS delay even on localhost… that seems quite high for just 1 message… am I doing something wrong?
Thanks for the response, yeah that seems to be around the 20-30 ms which I was experiencing, I saw that SendDelay is used to combine packets together to reduce network stress but am not sure if I should keep it 10 as I am making a shooter game and adding 20-30 ping to some one could make it a lot less enjoyable for people.
(for movement inputs), i dont mind the 20 ms delay for chat and such.
(EDIT) after setting config.SendDelay to 0 and MinUpdateTimeout from 10 to 2 I still notice around 5-9 ms delay (2 of that would be from MinUpdateTimeout, any idea where that could come from?
right now the framerates are in the hundreds since it’s an empty project with just some network testing, I’m pretty happy with the ms its between 1 and 18 it seems. might be as good as I can get it.
Theres also GlobalConfig.ThreadAwakeTimeout that you can maybe lower to be faster? I dont really know how it works or what its default value is.
Youd pass the GlobalConfig into your NetworkTransport.Init(globalConfig…)
@HiddenMonk is right, try this. Another point - Do you take into account frame rate on receiver? Imagine that my FPS is one frame per hour, in this case latency could vary from 0 to 1 hour, with average 30 min, correct?