Expand description
Mobile Protocol Codec (16-byte header)
This module implements the mobile-optimized ZUS RPC protocol with a compact 16-byte header designed for mobile clients with bandwidth constraints.
§Protocol Differences from Standard (40-byte)
| Feature | Standard (40-byte) | Mobile (16-byte) |
|---|---|---|
| Header size | 40 bytes | 16 bytes |
| Magic | 0xD3A7 (2 bytes) | 0xDF (1 byte) |
| Sequence ID | u64 (8 bytes) | u16 (2 bytes) |
| Timeout | u64 (8 bytes) | u16 (2 bytes, seconds) |
| Data CRC | u32 (full CRC32) | u16 (lower 16 bits) |
| Trace ID | u64 (8 bytes) | Not present |
| Compress threshold | 4096 bytes | 256 bytes |
§Header Layout (16 bytes, Big-Endian)
Offset Field Type Size Description
------ ---------- ------ ------ -----------
0 magic u8 1 0xDF
1 version u8 1 Protocol version
2 cmdtype u8 1 Message type (1=REQ, 2=RSP, 3=NOTIFY, 4=SYSRSP)
3 flag u8 1 Flags: bit0=compressed, bit1=encrypted, bit2=fragment
4 headcrc16 u16 2 Header CRC (truncating addition)
6 datacrc u16 2 Data CRC (lower 16 bits of CRC32)
8 seqId u16 2 Sequence ID (0-65535, wraps around)
10 timeout u16 2 Timeout in seconds (not milliseconds!)
12 datalen u32 4 Body length in bytes
Total: 16 bytes§Heartbeat Packet (8 bytes)
Mobile clients send periodic heartbeat packets with magic 0xEF:
Offset Field Type Size Description
------ ---------- ------ ------ -----------
0 magic u8 1 0xEF
1-7 padding [u8;7] 7 Reserved/padding
Total: 8 bytesStructs§
- Mobile
Codec - Mobile Protocol Codec
- Mobile
Heartbeat - Mobile Heartbeat Packet (8 bytes)
- Mobile
Message - Mobile RPC Message
- Mobile
Protocol Header - Mobile Protocol Header (16 bytes)
Enums§
- Mobile
Packet - Decoded packet type from mobile protocol
Constants§
- HEARTBEAT_
MAGIC - Mobile heartbeat magic number (1 byte)
- HEARTBEAT_
SIZE - Heartbeat packet size
- MOBILE_
COMPRESS_ THRESHOLD - Default compression threshold for mobile protocol (256 bytes) Lower than standard (4KB) to optimize for mobile bandwidth
- MOBILE_
HEADER_ SIZE - Mobile protocol header size
- MOBILE_
MAGIC - Mobile protocol magic number (1 byte)