# UDP Packet Format

The packet contains the following data:

1. Format version number (one byte), set to 1.
2. A list of data items. Each item has the following format:
   1. Data type number (one byte, must not be zero)
   2. Data length (one byte: N)
   3. N bytes of binary data
3. A zero byte.

Due to UDP transmission limits, the total packet length is limited to 512 bytes.

## Item Types

Type | Bytes | Symbol | Description
--- | --- | --- | ---
0 | 0 | END | End of packet marker
1 | 0 | REQUEST | Flag indicating this is a request packet
2 | 0 | RESPONSE | Flag indicating this is a response packet
3 | VAR | TIMESTAMP | ASCII decimal timestamp, represented as number of seconds since the UNIX epoch, with fractional seconds. The timestamp is used to make each packet unique (making the hash unique), as well as to eliminate replay attacks. Response packets copy the timestamp from the request packet.
4 | 4 | IPV4 | Raw IP (version 4) address, in network byte order.
5 | 16 | IPV6 | Raw IP (version 6) address, in network byte order (not yet supported).
6 | VAR | ENV | Environment variable, formatted as "`NAME=VALUE`".
7 | 32 | SHA | SHA-256 hash of all the data in the packet up to but not including this item, plus the shared secret.