SimTX API/Packets/Pong
Appearance
| Frame | ServerFrame, field 2
|
|---|---|
| Member | pong
|
| Direction | Server → client |
| Session | All roles |
| Roles | All roles. |
| Permission | None |
| Answers | Ping |
| Defined in | frames.proto
|
Pong answers a Ping. It echoes the ping's fields and adds the server clock.
Definition
message Pong { int64 nonce = 1; int64 client_time_ms = 2; int64 server_time_ms = 3; }
Fields
| # | Field | Type | Description |
|---|---|---|---|
| 1 | nonce |
int64 |
The ping's nonce.
|
| 2 | client_time_ms |
int64 |
The ping's client_time_ms.
|
| 3 | server_time_ms |
int64 |
Server clock when the ping was answered, Unix ms. |
Usage
Round-trip time is now − client_time_ms. An estimate of the server clock offset is server_time_ms − (client_time_ms + now) / 2.
Example
Complete frames, including the varint length prefix, from the protocol's golden test vectors (protocol/simtx/v25/testdata/frames.json).
pong (server to client, 19 bytes):
12 frame length 18
12 10 pong (Pong), 16 bytes
08 63 nonce = 99
10 80 94 83 B9 97 34 client_time_ms = 1793000000000
18 8C 94 83 B9 97 34 server_time_ms = 1793000000012