GetNetworkPing() Not Working Properly

In my latest game I’ve started using GetNetworkPing() to display user ping. It seems really inconsistent and doesn’t even correspond to the ping displayed in shift-f3.

My in-game leaderboard displays the value returned from GetNetworkPing() for each player, and as you can see alot of us are way overreporting our ping, and one player is way underreporting.

1 Like

Hi, thanks for the report. I’d like to break this down into two parts.

First, you mentioned that the value of GetNetworkPing() does not correspond to the ping shown in the network debug pane opened with Shift + F3. These ping values actually represent slightly different concepts. The value in GetNetworkPing() is the network latency of individual packets between your computer and the Roblox server, while the ping in the network debug pane should include this value plus latency from the packet deserialization/processing pipeline in the Engine.

The value from GetNetworkPing() should generally be lower than the one in the network pane, but the Engine uses different algorithms to calculate the running average of each ping, which may also cause differences. Do you regularly see GetNetworkPing higher than the ping in the network pane like in your screenshot?

Second, you mention that some players have pings higher than you expect, while others have pings lower than you expect. Can you clarify what baseline value this is in reference to?

3 Likes

Yes I would say it usually over reports than under. Baseline for what I would consider good ping would probably be around 65ms. That’s the ping I get in my own private server and my internet is pretty good.

To see a player in a live server with any less than 50 ping is pretty unheard of, yet GetNetworkPing clearly thinks some players have 20-30 ping.

I’ve already stopped using GetNetworkPing and instead do this:

Server increments a value in workspace every heartbeat. Every 1 second it fires a remote event to the clients, passing the current value.

When the client receives the event, it records the difference between the passed value and the value in workspace. It fires a server event and passes that difference and what the client thinks the current workspace value is.

Lastly when the server gets that information it adds up the time differences and reports that as the user’s ping.

This method is extremely accurate and perfectly consistent with the shift-f3 information. And this is roughly how I would expect GetNetworkPing to work as well.

3 Likes

Hey @CDDevelopment, thank you for reporting this- I am able to reproduce. Am seeing myself get 10s ping sometimes, and other times 20ms ping… :smiling_face_with_tear:. Investigating!

6 Likes

Hm. I’m no longer able to reproduce this issue, but I myself did not release any changes. I am investigating if there were any other changes that went out that could have affected this, but I wanted to check in here to see if you are still experiencing the problem? Thanks again for the report

image

I am still getting strangely low and unrealistic values for GetNetworkPing().

Also I often experience values being returned that are exactly the same as values returned from minutes ago even though there was a shown change in between.

I also do not know how often this value updates as sometimes the returned value will stay exactly the same for quite a while whereas other times it will update frequently making it very inconsistent. Does calling it more frequently prevent a calculation of a new value?

image
(Image showing a more frequent update to the returned value)

image
(Image showing no change to the returned value but is called multiple times)

1 Like

Hey @NevermindBuild, thanks for your post~

These low values are not so abnormal for users with good connections. Our internal data tells us that about 5% of sessions have pings less than 16ms. And 25% of sessions less than 35ms.

The ping that we return for GetNetworkPing() is an average over the last 5 data points we have, which is why the same value might be returned minutes later: ie avg(12, 13, 14, 13, 12) == avg(13, 12, 14, 12, 13)

The reason the value stays the same for quite a while is that we currently only initiate a new ping/pong about every 5 seconds.

And just wanted to reiterate that the ping returned from GetNetworkPing() specifically measures network latency only, and not any of the usual processing latency. Which is why this value will be lower, often much lower, than the ping displayed in shift-f3.

Hope that helps!

8 Likes

Thank you for the information that clears up a lot of confusion. :+1:

I feel like some of this information should be included on the documentation to prevent any confusion in the future. (Currently access to editing engine API documentation is still unavailable)

Good point. We don’t want to put certain implementation details in the API docs, as these could change, however we should definitely add some clarification around what exactly this ping represents. I will message the right people to get this added. Thank you!

1 Like

In general I’d appreciate more networking documentation.

I have a post showcasing a lot of information about Roblox networking that I feel really should be documented: In-Depth Information about Roblox's RemoteEvents, Instance Replication, and Physics Replication (w/ sources!)

I think that this information should be easily accessible on official Roblox documentation, with better accuracy than what I wrote.

2 Likes