Let's talk about ping

Hi guys . I am building a dedicated server manager and have hit a roadblock.

Does anyone know how I could calculate the ping between my client and the dedicated server instance?

My limited understanding of ping is that it’s the return trip time it takes for client to send and then recieve back a message/packet from the server .

Eg Client sendsmessage/packet to the server -> server processes message/packet->server send response back to client

So does this mean it would be as simple as Creating a server rpc call from the client . Start a timer and then when the server sends a mesage back stop the timer ?

Or is it a lot more complicated than that and if so any ideas how I might do it or find more information about it.

Google searches a about the subject arnt providing too much useful info . Thanks

Yea, as far as i know that’s it.
You send a request, get a response, the time taken to do all of this is the ping time.

Edit: If i’m not wrong the shooter demo shows clients ping, you could have a look there

Edit2: By looking at the source, i’ve noticed that the PlayerState get the ping from the engine, you can perhaps override APlayerState::UpdatePing and get the value from the first and only argument (float InPing) https://github.com/EpicGames/UnrealEngine/blob/76085d1106078d8988e4404391428252ba1eb9a7/Engine/Source/Runtime/Engine/Private/PlayerState.cpp

Edit3 (last one, I promise!): Actually the player state class holds and updates a variable called Ping, you can use that one. Cheers



/** Replicated compressed ping for this player (holds ping in msec divided by 4) */
	UPROPERTY(replicated, BlueprintReadOnly, Category=PlayerState)
	uint8 Ping


1 Like