@CMarastoni @timjohansson How should I get accurate game ping in real time from dots netcode package? I want to implement display game ping feature that most networking usually have that will tell player the current ping value in ms unit on real time. Is there some kind of ping component that I just get it to do this? I use something called ackcomponent but it’s not really accurate. Do u have much accurate component to do game ping?
We agree that this should be an out of the box feature. For 0.50, you can grab the NetworkSnapshotAckComponent
’s EstimatedRTT
value. Note, this estimate is only updated when receiving snapshots, so - for this value to update - you must be “in-game” and you must have ghosts in your scene.
In other words: Sending and receiving RPC’s only will not give you a reliable ping value. It’s a common gotcha. If you need RPC ping too (I’d recommend against this), you can find transport level stats in the ReliableUtility
’s ``RTTInfo`.
See example here: https://docs-multiplayer.unity3d.com/transport/0.8.0/pipelines/index.html#debug-information
To communicate these values to other clients, I’d recommend assigning the EstimatedRTT
to a [GhostField] so that it’s automatically replicated. Sending ping changes via RPC’s is another option, but we don’t recommend it for frequently-changed data (as that’s what GhostFields are designed for).
In 0.5 they also update when receiving rpcs (on the client) and commands (on the server), not only when snapshot are received.
How do you know it is not accurate, what are you comparing it too and how incorrect is it?
That ping should be fairly accurate - but it is higher than just the “raw” ping since we only poll for received packets once per frame which adds up to 2 frames extra RTT. That is representative of the ping the game will see though.
Also keep in mind that the delay specified in the playmode tools simulation window is applied to both send and receive packets, so the ping you get will be 2*specified delay + some overhead
I observe the ping i.e. EstimatedRTT at real android build that connects to game session server and it’s quite higher comparing with the ping value I just ping with game session server with windows cmd. My expectation is both should almost nearly the same ping but it’s differ quite much. Or maybe I should EstimatedRTT -
DeviationRTT to get much accurate ping?