Skip to content

Commit 0d78df1

Browse files
committed
minor changes and fixes to docs
1 parent 5b1c7fe commit 0d78df1

File tree

2 files changed

+36
-25
lines changed

2 files changed

+36
-25
lines changed

docs/packet_structure.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,22 @@ Note: see the [payloads doc](./payloads.md) for more information about the conte
1111

1212
## Header Breakdown
1313

14+
bit 0 means the lowest bit (1s place)
15+
1416
| Bits | Mask | Field | Description |
1517
|-------|--------|-----------------|-----------------------------------------------|
1618
| 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+
| 2-5 | `0x3C` | Payload Type | Request, Response, ACK, etc. - see below. |
20+
| 6-7 | `0xC0` | Payload Version | Versioning of the payload format - see below. |
1921

2022
## Route Type Values
2123

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. |
24+
| Value | Name | Description |
25+
|--------|-------------------------------|--------------------------------------|
26+
| `0x00` | `ROUTE_TYPE_TRANSPORT_FLOOD` | Flood routing mode + transport codes |
27+
| `0x01` | `ROUTE_TYPE_FLOOD` | Flood routing mode (builds up path). |
28+
| `0x02` | `ROUTE_TYPE_DIRECT` | Direct route (path is supplied). |
29+
| `0x03` | `ROUTE_TYPE_TRANSPORT_DIRECT` | direct route + transport codes |
2830

2931
## Payload Type Values
3032

@@ -39,6 +41,7 @@ Note: see the [payloads doc](./payloads.md) for more information about the conte
3941
| `0x06` | `PAYLOAD_TYPE_GRP_DATA` | Group datagram (unverified). |
4042
| `0x07` | `PAYLOAD_TYPE_ANON_REQ` | Anonymous request. |
4143
| `0x08` | `PAYLOAD_TYPE_PATH` | Returned path. |
44+
| `0x09` | `PAYLOAD_TYPE_TRACE` | trace a path, collecting SNI for each hop. |
4245
| `0x0F` | `PAYLOAD_TYPE_RAW_CUSTOM` | Custom packet (raw bytes, custom encryption). |
4346

4447
## Payload Version Values

docs/payloads.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
# Meshcore payloads
22
Inside of each [meshcore packet](./packet_structure.md) is a payload, identified by the payload type in the packet header. The types of payloads are:
33

4+
* Node advertisement.
5+
* Acknowledgment.
6+
* Returned path.
47
* Request (destination/source hashes + MAC).
58
* Response to REQ or ANON_REQ.
69
* Plain text message.
7-
* Acknowledgment.
8-
* Node advertisement.
10+
* Anonymous request.
911
* Group text message (unverified).
1012
* Group datagram (unverified).
11-
* Anonymous request.
12-
* Returned path.
1313
* Custom packet (raw bytes, custom encryption).
1414

1515
This document defines the structure of each of these payload types
1616

17+
## Important concepts:
18+
19+
* Node/channel hash: the first byte of the node or channel's public key
20+
1721
# Node advertisement
1822
This kind of payload notifies receivers that a node exists, and gives information about the node
1923

2024
| Field | Size (bytes) | Description |
2125
|---------------|-----------------|----------------------------------------------------------|
22-
| public key | 32 | Ed25519 public key |
26+
| public key | 32 | Ed25519 public key of the node |
2327
| timestamp | 4 | unix timestamp of advertisement |
2428
| signature | 64 | Ed25519 signature of public key, timestamp, and app data |
2529
| appdata | rest of payload | optional, see below |
@@ -45,12 +49,18 @@ Appdata Flags
4549
| `0x80` | name | appdata contains a node name |
4650

4751
# Acknowledgement
52+
53+
An acknowledgement that a message was received. Note that for returned path messages, an acknowledgement will be sent in the "extra" payload (see [Returned Path](#returned-path)) and not as a discrete ackowledgement. CLI commands do not require an acknowledgement, neither discrete nor extra.
54+
4855
| Field | Size (bytes) | Description |
4956
|----------|--------------|------------------------------------------------------------|
5057
| checksum | 4 | CRC checksum of message timestamp, text, and sender pubkey |
5158

5259

5360
# Returned path, request, response, and plain text message
61+
62+
Returned path, request, response, and plain text messages are all formatted in the same way. See the subsection for more details about the ciphertext's associated plaintext representation.
63+
5464
| Field | Size (bytes) | Description |
5565
|------------------|-----------------|------------------------------------------------------|
5666
| destination hash | 1 | first byte of destination node public key |
@@ -60,11 +70,13 @@ Appdata Flags
6070

6171
## Returned path
6272

73+
Returned path messages provide a description of the route a packet took from the original author. Receivers will send returned path messages to the author of the original message.
74+
6375
| Field | Size (bytes) | Description |
6476
|-------------|--------------|----------------------------------------------------------------------------------------------|
6577
| path length | 1 | length of next field |
66-
| path | see above | a list of node hashes (one byte each) describing the route from us to the packet author |
67-
| extra type | 1 | extra, bundled payload type, eg., acknowledgement or response. See packet structure spec |
78+
| path | see above | a list of node hashes (one byte each) |
79+
| extra type | 1 | extra, bundled payload type, eg., acknowledgement or response. Same values as in [packet structure](./packet_structure.md) |
6880
| extra | rest of data | extra, bundled payload content, follows same format as main content defined by this document |
6981

7082
## Request
@@ -156,18 +168,14 @@ Plaintext message
156168

157169
# Group text message / datagram
158170

159-
| Field | Size (bytes) | Description |
160-
|--------------|-----------------|------------------------------------------|
161-
| channel hash | 1 | TODO |
162-
| cipher MAC | 2 | MAC for encrypted data in next field |
163-
| ciphertext | rest of payload | encrypted message, see below for details |
171+
| Field | Size (bytes) | Description |
172+
|--------------|-----------------|--------------------------------------------|
173+
| channel hash | 1 | the first byte of the channel's public key |
174+
| cipher MAC | 2 | MAC for encrypted data in next field |
175+
| ciphertext | rest of payload | encrypted message, see below for details |
164176

165-
Plaintext for text message
177+
The plaintext contained in the ciphertext matches the format described in [plain text message](#plain-text-message). Specifically, it consists of a four byte timestamp, a flags byte, and the message. The flags byte will generally be `0x00` because it is a "plain text message". The message will be of the form `<sender name>: <message body>` (eg., `user123: I'm on my way`).
166178

167-
| Field | Size (bytes) | Description |
168-
|-----------|-----------------|----------------------------------|
169-
| timestamp | 4 | send time (unix timestamp) |
170-
| content | rest of message | plain group text message content |
171179

172180
TODO: describe what datagram looks like
173181

0 commit comments

Comments
 (0)