Skip to content

Commit 5089268

Browse files
authored
Create packet_structure.md
As mentioned by @mofosyne at issue #72
1 parent 808d393 commit 5089268

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

docs/packet_structure.md

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

0 commit comments

Comments
 (0)