Skip to main content

Ping beacons

What are Ping Beacons

Ping beacons are small echo servers deployed in each of our regions. These servers are made available for game client to send UDP packets to and measure latency to each of our region. The primary use is for QoS Matchmaking, game clients would send their latency measurement for each region to the game's Matchmaker, allowing the Matchmaker to choose the best region queue to put the players in.

info

Reach out to your Account Management team to get access ot this feature and get the QoS endpoint list.

How to use Ping Beacons

Your game client will be able to reach out to every region your allocations are deployed into. Send UDP packets to the beacons and you'll receive an echo of your request back Ping beacons at the time do not require any authentication, but certain limitation applies:

  • Each client is rate limited to 20 requests per second.
  • You need to add a ‘magic’ ASCII string ping-beacon at the start of your UDP packet.
  • Maximum packet size is 1024 bytes (including magic).

Here is an example of how to call the beacons:

import socket
import time

bufferSize = 64
bytesToSend = str.encode("ping-beacon")

UDPClientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)


def print_avg_ping(beacon_endpoint):
runs = 10
total_time = 0
for i in range(0, runs):
start = time.perf_counter()
UDPClientSocket.sendto(bytesToSend, (beacon_endpoint, 4230))
UDPClientSocket.recvfrom(bufferSize)
stop = time.perf_counter()
ping_time = stop - start
print(f"Ping time to {beacon_endpoint} is {ping_time * 1000:0.0f} ms")
total_time = total_time + ping_time
print(f"Average ping time to {beacon_endpoint} is {total_time * 1000 / runs:0.0f} ms")
print("")


if __name__ == "__main__":
print_avg_ping("example.qos.ims.improbable.io")

Best practices

There are some practices that you should follow when implementing latency measurement in your game. A few things to keep in mind are:

  • An accurate latency measurement consists of multiple pings, take the outliers out.
  • Call multiple beacons, and send multiple latency requests to each beacons at the same time. Ensure that your thread management isn't impeding on the latency measurement.
  • Use a UDP packet size that is close to your usual game's packet size.
  • Ensure the endpoints are not hardcoded in your client. Your Matchmaker or backend should dynamically inform the clients what the endpoints are. This allows for changing the endpoints dynamically.