SimTX API v24/Connection and handshake: Difference between revisions
SimTX API documentation |
Archive the v24 protocol reference: use the v24 templates, links and categories |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{SimTX API navigation}} | {{SimTX API v24 navigation}} | ||
Every SimTX game connection begins the same way: a TLS connection to the host and port from the [[SimTX API/Server directory|server directory]], a [[SimTX API/Packets/Handshake|Handshake]] from the client, and a [[SimTX API/Packets/HandshakeResult|HandshakeResult]] from the server. What follows depends on the '''role''' the client asked for. | Every SimTX game connection begins the same way: a TLS connection to the host and port from the [[SimTX API v24/Server directory|server directory]], a [[SimTX API v24/Packets/Handshake|Handshake]] from the client, and a [[SimTX API v24/Packets/HandshakeResult|HandshakeResult]] from the server. What follows depends on the '''role''' the client asked for. | ||
== Transport == | == Transport == | ||
| Line 14: | Line 14: | ||
| Protocol version || 24. Must match exactly. | | Protocol version || 24. Must match exactly. | ||
|- | |- | ||
| Byte order || Big-endian. See [[SimTX API/Data types|Data types]]. | | Byte order || Big-endian. See [[SimTX API v24/Data types|Data types]]. | ||
|- | |- | ||
| Framing || <code>u8 packetId</code> followed by the body. No length prefix. See [[SimTX API/Packet list#Framing|Framing]]. | | Framing || <code>u8 packetId</code> followed by the body. No length prefix. See [[SimTX API v24/Packet list#Framing|Framing]]. | ||
|} | |} | ||
| Line 44: | Line 44: | ||
! Byte !! Name !! Purpose !! Authentication | ! Byte !! Name !! Purpose !! Authentication | ||
|- | |- | ||
| 1 || <code>RECEIVER</code> || Receive IQ at a location. See [[SimTX API/Receiver session|Receiver session]]. || Anonymous or ticket (<code>receiver</code>) | | 1 || <code>RECEIVER</code> || Receive IQ at a location. See [[SimTX API v24/Receiver session|Receiver session]]. || Anonymous or ticket (<code>receiver</code>) | ||
|- | |- | ||
| 2 || <code>TX_AUDIO</code> || Transmit audio or IQ streamed by the client. See [[SimTX API/Transmitter session|Transmitter session]]. || Ticket (<code>tx-audio</code>) with <code>game.transmit</code> | | 2 || <code>TX_AUDIO</code> || Transmit audio or IQ streamed by the client. See [[SimTX API v24/Transmitter session|Transmitter session]]. || Ticket (<code>tx-audio</code>) with <code>game.transmit</code> | ||
|- | |- | ||
| 3 || <code>TX_GENERATED</code> || Transmit a source generated by the server (white noise). || Ticket (<code>tx-generated</code>) with <code>game.transmit</code> | | 3 || <code>TX_GENERATED</code> || Transmit a source generated by the server (white noise). || Ticket (<code>tx-generated</code>) with <code>game.transmit</code> | ||
|- | |- | ||
| 4 || <code>CONTROL</code> || Station list, banners, health, maps, catalog, own-transmitter monitor. See [[SimTX API/Control session|Control session]]. || Anonymous or ticket (<code>control</code>) | | 4 || <code>CONTROL</code> || Station list, banners, health, maps, catalog, own-transmitter monitor. See [[SimTX API v24/Control session|Control session]]. || Anonymous or ticket (<code>control</code>) | ||
|- | |- | ||
| 5 || <code>MODERATION</code> || Moderator tools. See [[SimTX API/Moderation session|Moderation session]]. || Ticket (<code>moderation</code>) with <code>moderation.manage</code> | | 5 || <code>MODERATION</code> || Moderator tools. See [[SimTX API v24/Moderation session|Moderation session]]. || Ticket (<code>moderation</code>) with <code>moderation.manage</code> | ||
|- | |- | ||
| 6 || <code>TIMESTAMPED_RECEIVER</code> || Receiver whose IQ blocks carry UTC timestamps. || Anonymous only | | 6 || <code>TIMESTAMPED_RECEIVER</code> || Receiver whose IQ blocks carry UTC timestamps. || Anonymous only | ||
| Line 62: | Line 62: | ||
== Handshake results == | == Handshake results == | ||
The server answers every well-formed handshake with a [[SimTX API/Packets/HandshakeResult|HandshakeResult]]. Status <code>0</code> means the connection is accepted and the session may begin. Any other status is followed by the server closing the connection. | The server answers every well-formed handshake with a [[SimTX API v24/Packets/HandshakeResult|HandshakeResult]]. Status <code>0</code> means the connection is accepted and the session may begin. Any other status is followed by the server closing the connection. | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 87: | Line 87: | ||
== Accounts on the connection == | == Accounts on the connection == | ||
For an authenticated connection, the HandshakeResult carries the account's UUID, handle, display name and effective [[SimTX API/Permissions|permissions]]. Software should use these for display and to show limits such as the maximum transmitter power, rather than asking the account service separately. | For an authenticated connection, the HandshakeResult carries the account's UUID, handle, display name and effective [[SimTX API v24/Permissions|permissions]]. Software should use these for display and to show limits such as the maximum transmitter power, rather than asking the account service separately. | ||
Authenticated connections carry a '''lease''' of about 12 hours, given as <code>leaseExpiresAtEpochMillis</code>. When it runs out, the server closes the connection without a message. A long-running client should reconnect with a fresh ticket before the lease expires. Changes to the account, such as a revoked device, a new restriction or a ban, can close all of its connections at any moment, also without a message. | Authenticated connections carry a '''lease''' of about 12 hours, given as <code>leaseExpiresAtEpochMillis</code>. When it runs out, the server closes the connection without a message. A long-running client should reconnect with a fresh ticket before the lease expires. Changes to the account, such as a revoked device, a new restriction or a ban, can close all of its connections at any moment, also without a message. | ||
| Line 93: | Line 93: | ||
== Connection limits == | == Connection limits == | ||
* At most 32 simultaneous connections per client IP address, and 256 per server in total. A connection over either limit is closed straight away without a reply. | * At most 32 simultaneous connections per client IP address, and 256 per server in total. A connection over either limit is closed straight away without a reply. | ||
* Further limits on receivers and transmitters apply once a session is requested. See [[SimTX API/Limits and errors]]. | * Further limits on receivers and transmitters apply once a session is requested. See [[SimTX API v24/Limits and errors]]. | ||
== Example == | == Example == | ||
| Line 120: | Line 120: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{SimTX API navbox}} | {{SimTX API v24 navbox}} | ||
[[Category:SimTX API]] | [[Category:SimTX API v24]] | ||
[[Category:SimTX API sessions]] | [[Category:SimTX API v24 sessions]] | ||
Latest revision as of 16:13, 24 October 2026
Every SimTX game connection begins the same way: a TLS connection to the host and port from the server directory, a Handshake from the client, and a HandshakeResult from the server. What follows depends on the role the client asked for.
Transport[edit | edit source]
| Property | Value |
|---|---|
| Transport | TCP |
| Security | TLS 1.3 or TLS 1.2, required. Verify the server certificate against the system's public CA store and the host name from the directory.
|
| Port | From the server directory. The public deployment currently uses 5556. |
| Protocol version | 24. Must match exactly. |
| Byte order | Big-endian. See Data types. |
| Framing | u8 packetId followed by the body. No length prefix. See Framing.
|
Recommended socket options are TCP_NODELAY (packets are small and latency matters) and SO_KEEPALIVE. The protocol has no application-level ping or heartbeat. A dead connection is detected by TCP keepalive and by the server's stall timers.
Unencrypted connections are accepted only by a development server explicitly configured for it and bound to the loopback address. Public servers never accept them.
Connection sequence[edit | edit source]
client server
| ---- TCP connect, TLS handshake -------------------> |
| ---- Handshake (no ID byte) -----------------------> |
| <--- [30] HandshakeResult -------------------------- | status 0 = ACCEPTED
| |
| role 1 / 6: [1] ReceiverSessionRequest ---> |
| role 2 / 3: [2] TransmitterSessionRequest --> |
| role 4: <--- [8] ControlAck, [17] Banner? |
| role 5: moderation requests |
The handshake and the first session request must arrive promptly. Through the public gateway the limit is 5 seconds from connecting until the session request has been read and admitted; a server reached directly allows 15 seconds. Send both immediately after the TLS handshake completes.
Roles[edit | edit source]
The role byte in the handshake selects the kind of session. It cannot be changed later on the same connection.
| Byte | Name | Purpose | Authentication |
|---|---|---|---|
| 1 | RECEIVER |
Receive IQ at a location. See Receiver session. | Anonymous or ticket (receiver)
|
| 2 | TX_AUDIO |
Transmit audio or IQ streamed by the client. See Transmitter session. | Ticket (tx-audio) with game.transmit
|
| 3 | TX_GENERATED |
Transmit a source generated by the server (white noise). | Ticket (tx-generated) with game.transmit
|
| 4 | CONTROL |
Station list, banners, health, maps, catalog, own-transmitter monitor. See Control session. | Anonymous or ticket (control)
|
| 5 | MODERATION |
Moderator tools. See Moderation session. | Ticket (moderation) with moderation.manage
|
| 6 | TIMESTAMPED_RECEIVER |
Receiver whose IQ blocks carry UTC timestamps. | Anonymous only |
A TIMESTAMPED_RECEIVER connection that presents a ticket is rejected with CREDENTIAL_INVALID, because no ticket can be issued for that role.
An authenticated receiver behaves exactly like an anonymous one, except that receiver limits and permissions such as monitor.any are evaluated against the account.
Handshake results[edit | edit source]
The server answers every well-formed handshake with a HandshakeResult. Status 0 means the connection is accepted and the session may begin. Any other status is followed by the server closing the connection.
| Status | Name | Typical cause |
|---|---|---|
| 0 | ACCEPTED |
|
| 1 | VERSION_UNSUPPORTED |
The client's version is not 24. The message names the required version. |
| 2 | AUTHENTICATION_REQUIRED |
The role needs a ticket and none was sent. |
| 3 | CREDENTIAL_INVALID |
The ticket is unknown, expired, already used, or issued for another server or role. |
| 4 | ACCOUNT_RESTRICTED |
The account is suspended or under a restriction that covers this action. |
| 5 | ROLE_FORBIDDEN |
The account lacks the permission the role requires. |
| 6 | SERVER_UNAVAILABLE |
The server could not reach the account service, or cannot take the connection. |
| 7 | IP_BANNED |
The client address is banned. The message gives the reason. |
A handshake that is malformed, such as one with the wrong magic number, an unknown authentication kind, or an illegal credential string, is closed without any reply.
Accounts on the connection[edit | edit source]
For an authenticated connection, the HandshakeResult carries the account's UUID, handle, display name and effective permissions. Software should use these for display and to show limits such as the maximum transmitter power, rather than asking the account service separately.
Authenticated connections carry a lease of about 12 hours, given as leaseExpiresAtEpochMillis. When it runs out, the server closes the connection without a message. A long-running client should reconnect with a fresh ticket before the lease expires. Changes to the account, such as a revoked device, a new restriction or a ban, can close all of its connections at any moment, also without a message.
Connection limits[edit | edit source]
- At most 32 simultaneous connections per client IP address, and 256 per server in total. A connection over either limit is closed straight away without a reply.
- Further limits on receivers and transmitters apply once a session is requested. See SimTX API v24/Limits and errors.
Example[edit | edit source]
An anonymous receiver handshake, as bytes:
53 49 4D 54 magic "SIMT"
00 00 00 18 version 24
01 role RECEIVER
00 authKind ANONYMOUS
00 00 credential "" (UTF, length 0)
A successful anonymous reply:
1E packet ID 30 HandshakeResult
00 status ACCEPTED
00 00 message ""
00 hasAccount false
00 00 handle ""
00 00 displayName ""
00 permissionCount 0
00 00 00 00 00 00 00 00 authorizationRevision 0
00 00 00 00 00 00 00 00 leaseExpiresAtEpochMillis 0