GetRemoteDelayTimeMS - Weird Results

Hey,

I am currently adapting my game to use the new low level Network API, but I noticed a little problem regarding the GetRemoteDelayTimeMS function.

I am sending the timestamp to a connected client, receive it there and then I am trying to use this timestamp to find out the message delivery time with the above mentioned function - like I would’ve used NetworkMessageInfo’s timestamp to find the delay in RakNet.

NetworkTransport.GetRemoteDelayTimeMS(client.HostID, client.ConnectionID, timestamp, out error);

The “client” object is a class containing the on connect event received hostID and connectionID, timestamp is received from the message. However, this results in really high numbers like 2971368 - in local testing, where I assume it should be close to zero*.* The timestamp is definitely the same as send from the server.

Am I misunderstanding this function? If so, how would I get the delay from Sending->Receiving?
(I want to find the clock offset by sending the server utc time, adding the message delay and then subtracting the client utc time, so I can later use TimeDate to define match start times/end times and more.)

@ReiAyanami I had maybe the same problem. Here is a snippet of how I am doing it in a test for testing client latency when firing a weapon to then do hitbox rewinding on server…

When client fires weapon, send client time…

MyMessages.FireWeaponMessage shot = new MyMessages.FireWeaponMessage();
shot.timeStamp = NetworkTransport.GetNetworkTimestamp(); // timeStamp is an int in message class
NetworkManager.singleton.client.Send((short) MyMessages.MyMessageTypes.FIRE_SHOT, shot);

In the server handler for fire weapon messages calculate this clients shot latency… unpack the clients time and pass it to the GetRemoteDelayTimeMS() on server

private void OnServerShotMessage(NetworkMessage netMsg)
    {
        MyMessages.FireWeaponMessage msg = netMsg.ReadMessage<MyMessages.FireWeaponMessage>();
        byte error;
        int delay = NetworkTransport.GetRemoteDelayTimeMS(netMsg.conn.hostId, netMsg.conn.connectionId, msg.timeStamp, out error);
        Debug.Log("Remote latency from client: " + delay + "ms");
    }

This is logging seemingly accurate latency times. Local client/host logs “0ms”… “remote”(on same machine) is logging between “5ms” to “30ms” while bullets are flying. I’m going to hook it up with the network simulator then to make sure everything is actually accurate then. I could be do something wrong. I just threw it together

Thanks for the message!

It’s exactly the way I am doing it, except that I am using the low level API so I don’t use the NetworkMessage :slight_smile: Mine still fails with really weird delay times.

I also encountered a new problem, I have a setup message that I send to the server when the client successfully connected. When I use the ReliableSequenced channel type, it only works once - disconnecting and then reconnecting will send the message, but the server never receives it. Just using the Reliable channel type always works. It’s not a problem for this specific message, but I wonder what that would do the message where I rely on the order (other setup stuff, that requires other things to be setup before).
Any ideas about that, anyone?

Hi Rei
It was long time ago when I did implement that probably something has been broken. So, report the bug please about timestamp (and attach your project please as i will need to check other digits).

Other problem (about ReliableSequenced ) is definitely bug and it has been already fixed and will be in patch 1.

sorry for bugs :frowning:
Alex

1 Like

I have exactly the same problem in Unity 5.1. GetRemoteDelayTimeMS reports delays close to ~1200 ms between app instances on my local machine.

@ReiAyanami If you’ve filled a bug request, can you post a link to it?

@aabramychev
@zuzzu

Just did! Case number is 704521 and here is a link to the bugtracker: http://fogbugz.unity3d.com/default.asp?704521_sa7jrocrgrd5hpko

Noticed something else while creating the minimal example (changed the low level example slightly for that) - it only appears on the client, and the received delay time slowly approaches a normal value after a while. (Which is still a problem for my case, as I only need the delay once at the beginning)

As far as I can see the bug tracker does not openly display my code, so in case you want to check the code, here it is: using System;using UnityEngine;using UnityEngine.Networking;/* * Simpl - Pastebin.com

I just ran into this issue as well, will wait for Alex. Thanks for bringing this up!

I just noticed I was still encountering this same problem even after updating to 5.1.1p2. Can anyone else confirm whether this has been fixed in the latest version.

Not fixed yet. I will inform when it will be fixed

is NetworkTransport.GetCurrentRtt also not working? - is there currently any way on getting an accurate h/rtt ?

ok, timing service has been fixed and will be available in 5.1.2 patch 1.
rtt measurement and other low level statistic function have been fixed as well and most probably will be available in 5.1.2 patch 1 (or less probably patch 2)

note that rtt exposed is measured by 8 last probes, each probe came from ping, so it is average value from last 8 ping timeout periods

woohooo!

awaits patch 2 :frowning:

NetworkTransport.GetCurrentRtt() always return 0 in 5.1.2 patch 3. Do I miss any thing? Any one help me

Any news on this? I am on 5.3 and NetworkTransport.GetCurrentRtt returns 0 for remote player on local machine.

Bump NetworkTransport.GetCurrentRtt keeps returning 0.