SimTX API/Packets/Ping
Appearance
| Frame | ClientFrame, field 2
|
|---|---|
| Member | ping
|
| Direction | Client → server |
| Session | All roles |
| Roles | All roles, any time after the hello. |
| Permission | None |
| Answered by | Pong |
| Defined in | frames.proto
|
Ping asks the server for a Pong. Use it to measure the round-trip time, to estimate the offset between the client and server clocks, or to check that an otherwise idle connection is alive.
Definition
message Ping { int64 nonce = 1; int64 client_time_ms = 2; }
Fields
| # | Field | Type | Description |
|---|---|---|---|
| 1 | nonce |
int64 |
Any value chosen by the client; echoed in the Pong. |
| 2 | client_time_ms |
int64 |
Client clock when sent, Unix ms; echoed. |
Behaviour
- Every role accepts it at any time after the ServerHello.
- The server answers each ping with one pong. Pongs can arrive between any other frames, so match them by
nonce. - Pings are cheap, but there is no reason to send more than one every few seconds.
Example
Complete frames, including the varint length prefix, from the protocol's golden test vectors (protocol/simtx/v25/testdata/frames.json).
ping (client to server, 12 bytes):
0B frame length 11
12 09 ping (Ping), 9 bytes
08 63 nonce = 99
10 80 94 83 B9 97 34 client_time_ms = 1793000000000