Network documentation

From SRB2 Wiki
(Redirected from SRB2 network documentation)
Jump to navigation Jump to search
This article or section is incomplete. It doesn't have all of the necessary core information on this topic. Please help the SRB2 Wiki by finishing this article.

Header

All of SRB2's packets start out with a specific 8-byte header, consisting of four values and a padding byte:

Data name Data type Description
checksum Unsigned 32-bit Integer The checksum.
ack Unsigned 8-bit Integer The acknowledgment variable. If not null, the server must send whatever is contained here in the next part of the header structure.
ackreturn Unsigned 8-bit Integer The acknowledgment variable's return.
packettype Unsigned 8-bit Integer The packet type.
reserved Null byte Padding.

Checksum calculation

The checksum for all packets is calculated in the function named NetbufferChecksum. This checksum is analyzed when the server receives the packet, and if it does not match what the server is expecting, it discards the packet without a reply.

List of packet types

Decimal ID Hex ID Name Sender → receiver Purpose
0 0x00 PT_NOTHING Server → Client
Client → Server
Sends a no-op through the network.
1 0x01 PT_SERVERCFG Server → Client Sends server configuration to the client. Is considered a positive response to a request to join the server.
2 0x02 PT_CLIENTCMD Client → Server Contains a client's ticcmd.
3 0x03 PT_CLIENTMIS Client → Server Contains a client's ticcmd. Is used when the server missed a ticcmd and the client is sending it again.
4 0x04 PT_CLIENT2CMD Client → Server Contains two clients' ticcmds for splitscreen.
5 0x05 PT_CLIENT2MIS Client → Server Contains two clients' ticcmds for splitscreen. Is used when the server missed a ticcmd and the clients are sending it again.
6 0x06 PT_NODEKEEPALIVE Client → Server Sent to the server to tell that the client is still alive but has nothing to send for this tic.
7 0x07 PT_NODEKEEPALIVEMIS Client → Server Sent to the server to tell that the client is still alive but has nothing to send for this tic. Is used when the server missed a ticcmd and the client is sending it again.
8 0x08 PT_SERVERTICS Server → Client Server sending all the clients' ticcmds and net commands to each other.
9 0x09 PT_SERVERREFUSE Server → Client Sends a refusal notice to a client that wishes to connect, which contains a reason.
10 0x0A PT_SERVERSHUTDOWN Server → Client Sent when the server shuts down, disconnecting all clients in the process.
11 0x0B PT_CLIENTQUIT Client → Server Sent when a client disconnects from the server.
12 0x0C PT_ASKINFO Client → Server Sent when a client requests info from a server.
13 0x0D PT_SERVERINFO Server → Client Sent by the server as one of two replies to PT_ASKINFO. Contains server information.
14 0x0E PT_PLAYERINFO Server → Client Sent by the server as the other one of two replies to PT_ASKINFO. Contains information on all players in the server.
15 0x0F PT_REQUESTFILE Client → Server Sent by the client to request the transfer all important files from the server that they do not already have. If the client has a different version of any needed file (the MD5 sum is bad), the file will also be requested here.
16 0x10 PT_ASKINFOVIAMS N/A Unused – this packet appears to have been identical to PT_ASKINFO, except it tells the server to send PT_SERVERINFO/PT_PLAYERINFO packets to the IP address contained in the packet. However, nothing is designed to send this packet type anymore, if ever at all, so it should be considered obsolete.
17 0x11 PT_WILLRESENDGAMESTATE Server → Client "Hey Client, I am about to resend you the gamestate!"
18 0x12 PT_CANRECEIVEGAMESTATE Client → Server "Okay Server, I'm ready to receive it, you can go ahead."
19 0x13 PT_RECEIVEDGAMESTATE Client → Server "Thank you Server, I am ready to play again!"
20 0x14 PT_SENDINGLUAFILE Server → Client Server telling a client Lua needs to open a file
21 0x15 PT_ASKLUAFILE Client → Server Client telling the server they don't have the file
22 0x16 PT_HASLUAFILE Client → Server Client telling the server they have the file
23 0x17 PT_CANFAIL The packet types below this line can fail to be sent. In addition, these packet types can't occupy all the available ack slots.
23 0x17 PT_FILEFRAGMENT Server → Client A fragment of a file sent by the server to the client. This is either a fragment of an important file sent in reply to PT_REQUESTFILE, or a fragment of $$$.sav (the netgame's savefile).
24 0x18 PT_FILEACK
25 0x19 PT_FILERECEIVED
26 0x1A PT_TEXTCMD Client → Server Extra net commands from the client, e.g. SAY commands.
27 0x1B PT_TEXTCMD2 Client → Server Extra net commands from a splitscreen client.
28 0x1C PT_CLIENTJOIN Client → Server Sent by a client to request to join a server.
29 0x1D PT_NODETIMEOUT Server/Client → self Sent by a client or server, to themselves, to indicate to the game that a client has lost connection to the server.
30 0x1E PT_LOGIN Client → Server Sent by a client to attempt a login. If successful, the player is awarded admin privileges. This is sent when a player uses the login command.
31 0x1F PT_PING Server → Client Sent by the server to inform a client of all the other clients' pings.
  Network documentation [view]
Packet types PT_ASKINFOPT_SERVERINFOPT_PLAYERINFO
Other Net commands