Repository navigation
Field Types
Afonso Pereira edited this page Mar 21, 2026
·
1 revision
REF2 classifies each field in a message into one of nine types.
| Type | Description | Example |
|---|---|---|
MAGIC |
Constant bytes at the start of every message, or containing sentinel values like 0xff 0xfe
|
Protocol header de ad
|
CONSTANT |
Same value in every message of this type, but not magic-looking | Version byte that never changes |
ENUM |
Small set of distinct values (2–16), low entropy | Opcode: 01 = HELLO, 02 = DATA, 03 = FIN |
LENGTH |
Integer whose value correlates with the total message length |
u16 length prefix |
SEQUENCE_NUMBER |
Incrementing counter, dense range, low entropy | Per-session packet counter |
NONCE |
High entropy, never repeated | Random session token, nonce, IV |
STRING |
≥80% printable ASCII bytes | Filename, username |
PAYLOAD |
High-entropy variable-length tail | Encrypted or compressed data |
OPAQUE |
Does not fit any of the above | Flags bitmask, checksum |
If the same field position carries a constant value within each message type cluster but a different value across clusters, REF2 automatically promotes all of them to ENUM. This is how opcode bytes get correctly typed — each message type sees its opcode as constant, but they all differ from each other.