Teeworlds 0.6

Packet layout 0.6.5

This page describes which format the full udp packets have that are sent by client and server. Version 0.6.4 and lower have a different layout. They have no token flag and no token field in the header.

There are three types of messages:
system messages, game messages and control messages

System and game messages have the same layout. There can be multiple game and system messages in one packet payload. And they can also be mixed. Every message has its own chunk header. So "message" and "chunk" can be used as synonyms here.

Control messages on the other hand always fill up the whole packet payload. So there can only be one control message per udp packet. And it does not have a chunk header.

Packet header

The payload of every teeworlds udp packet starts with the teeworlds packet header. In version 0.6.5 its size can vary depending on wether a token is included or not. There is no token if the connection is in backward compability mode. Allowing communication with version 0.6.4 and earlier. It has the following layout:
                
    # Packet header
    +---------+---------+------------------------------+------------------+----------------+
    | Unused  | Flags   | Acknowledged sequence number | Number of chunks | Security token |
    | 1 bit   | 5 bits  | 10 bits                      | 1 byte           | 4 bytes        |
    +---------+---------+------------------------------+------------------+----------------+
                
            
Field Description
Unused Client or server never set this bit and never read its value in all 0.6 versions.
Flags 5 bits in the following order
  • token - 1=use token 0=use no tokens
  • control - 1=control packet 0=system/game message packet
  • conless - 1=connection less 0=connection oriented
  • resend - 1=resend 0=not resend
  • compression - 1=compressed 0=not compressed
For example if the binary value of flags is 01000 It means it is a control packet. Which was not resend and so on.
Acknowledged sequence number Telling the receiver how many vital packets were successfully received.
Number of chunks Number of game and system message chunks. If it is a control packet this value is 0 at all times.
Security token 4 byte random security token to avoid spoofing.