Huge, incrementing delay with GetRemoteDelayTimeMS

Hi, I’m trying to find the a message took to travel from one peer to another. I’m using NetworkTransport.GetNetworkTimestamp() and I’m sending the timestamp through a local connection. My connection is a HLAPI but I’m initializing the NetworkTransport when the connection is established. Upon receiving I try to get the delay using NetworkTransport.GetRemoteDelayTimeMS. However, every time I receive the timestamp I get a huge delay (several thousand milliseconds). What is weirder is that the delay keeps getting bigger as I keep pinging the client/server.

Here is the message handler:

    public void ReceiveTimeStamp(NetworkMessage msg)
    {
        IntMessage message = msg.ReadMessage<IntMessage>();
        byte error;
        Debug.Log(NetworkTransport.GetRemoteDelayTimeMS(msg.conn.hostId, msg.conn.connectionId, message.timestamp, out error).ToString() + " MS Delay");
    }

Here’s the code for sending the timestamp:

        if (Input.GetKeyDown(KeyCode.Space))
        {
            IntMessage msg = new IntMessage();
            msg.value = NetworkTransport.GetNetworkTimestamp();
            client.Send((short)99, msg);
        }

Does anybody know why does this happen ? Thanks!

What unity version are you using?

I am using the latest version - 5.2. I know there has been a problem with this method earlier but I read that it has been fixed since then.

P.S. I wanted to add that the messages get received immediately. As I keep pinging the other peer, the messages don’t come slower. Just GetRemoteDelayMS returns big values.

Hmmm, On the first look your code is absolute valid. Hence, I just repeated my tests and could not reproduce this problem :frowning: Is it local network? Anyway report bug please with project attachment and reproducing steps and notify me please via forum when you will done this. I will take a look.

Yes, it’s a local network and this happens even if I connect to localhost. Sometimes in a LAN connection (not on the same machine) I would even get 0 as latency but most of the times I get these huge values.
I submitted a bug report. I got the NetworkManager class from the game and put it in a new project. The issue persists.
https://fogbugz.unity3d.com/default.asp?731542_gvim87kbe8m3uaao This is my bug report. According to it my OS is Windows 8 but it was actually upgraded to 10.

thanks for report, i will take a look on this week and will replay on weekends or early next week

1 Like

@Dreamteck
Hi, there is a problem with your code: you assign timestamp to msg.value but try to find delay using message.timestamp which is always zero…

(BTW, to decrease artificial delay try to set globalconfig.threadawaketimeout = 1; config.minupdatetimeout = 1;)

regards
Alex

1 Like

Wow, this was so obvious and I never saw it. Thank you for pointing that out and sorry for wasting your time. Thanks for the tips too, I’ll make sure I’ll do that!
Cheers!

np :slight_smile: