Skip to content

Commit 5be09ff

Browse files
authored
Merge pull request #375 from mattsains/packet-structure
Create packet_structure.md
2 parents 1b32853 + 9d53fc2 commit 5be09ff

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

docs/packet_structure.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Packet Structure
2+
3+
| Field | Size (bytes) | Description |
4+
|----------|----------------------------------|-----------------------------------------------------------|
5+
| header | 1 | Contains routing type, payload type, and payload version. |
6+
| path_len | 1 | Length of the path field in bytes. |
7+
| path | up to 64 (`MAX_PATH_SIZE`) | Stores the routing path if applicable. |
8+
| payload | up to 184 (`MAX_PACKET_PAYLOAD`) | The actual data being transmitted. |
9+
10+
Note: see the [payloads doc](./payloads.md) for more information about the content of payload.
11+
12+
## Header Breakdown
13+
14+
| Bits | Mask | Field | Description |
15+
|-------|--------|-----------------|-----------------------------------------------|
16+
| 0-1 | `0x03` | Route Type | Flood, Direct, Reserved - see below. |
17+
| 2-5 | `0x0F` | Payload Type | Request, Response, ACK, etc. - see below. |
18+
| 6-7 | `0x03` | Payload Version | Versioning of the payload format - see below. |
19+
20+
## Route Type Values
21+
22+
| Value | Name | Description |
23+
|--------|------------------------|--------------------------------------|
24+
| `0x00` | `ROUTE_TYPE_RESERVED1` | Reserved for future use. |
25+
| `0x01` | `ROUTE_TYPE_FLOOD` | Flood routing mode (builds up path). |
26+
| `0x02` | `ROUTE_TYPE_DIRECT` | Direct route (path is supplied). |
27+
| `0x03` | `ROUTE_TYPE_RESERVED2` | Reserved for future use. |
28+
29+
## Payload Type Values
30+
31+
| Value | Name | Description |
32+
|--------|---------------------------|-----------------------------------------------|
33+
| `0x00` | `PAYLOAD_TYPE_REQ` | Request (destination/source hashes + MAC). |
34+
| `0x01` | `PAYLOAD_TYPE_RESPONSE` | Response to REQ or ANON_REQ. |
35+
| `0x02` | `PAYLOAD_TYPE_TXT_MSG` | Plain text message. |
36+
| `0x03` | `PAYLOAD_TYPE_ACK` | Acknowledgment. |
37+
| `0x04` | `PAYLOAD_TYPE_ADVERT` | Node advertisement. |
38+
| `0x05` | `PAYLOAD_TYPE_GRP_TXT` | Group text message (unverified). |
39+
| `0x06` | `PAYLOAD_TYPE_GRP_DATA` | Group datagram (unverified). |
40+
| `0x07` | `PAYLOAD_TYPE_ANON_REQ` | Anonymous request. |
41+
| `0x08` | `PAYLOAD_TYPE_PATH` | Returned path. |
42+
| `0x0F` | `PAYLOAD_TYPE_RAW_CUSTOM` | Custom packet (raw bytes, custom encryption). |
43+
44+
## Payload Version Values
45+
46+
| Value | Version | Description |
47+
|--------|---------|---------------------------------------------------|
48+
| `0x00` | 1 | 1-byte src/dest hashes, 2-byte MAC. |
49+
| `0x01` | 2 | Future version (e.g., 2-byte hashes, 4-byte MAC). |
50+
| `0x02` | 3 | Future version. |
51+
| `0x03` | 4 | Future version. |

0 commit comments

Comments
 (0)