mirror of
https://github.com/meshtastic/meshtastic.git
synced 2024-11-10 07:34:11 -08:00
Update according to device PR #1500
This commit is contained in:
parent
bed5db2ba6
commit
c96e820219
|
@ -6,14 +6,14 @@ sidebar_label: Mesh algorithm
|
|||
|
||||
## Current Algorithm
|
||||
|
||||
The routing protocol for Meshtastic is really quite simple (and suboptimal). It is heavily influenced by the mesh routing algorithm used in [RadioHead](https://www.airspayce.com/mikem/arduino/RadioHead) (which was used in very early versions of this project). It has four conceptual layers.
|
||||
The routing protocol for Meshtastic is really quite simple (and suboptimal). If you want to test its theoretical performance, you can have a look at the [simulator](https://github.com/GUVWAF/Meshtasticator). The protocol is heavily influenced by the mesh routing algorithm used in [RadioHead](https://www.airspayce.com/mikem/arduino/RadioHead) (which was used in very early versions of this project). It has four conceptual layers.
|
||||
|
||||
### A Note About Protocol Buffers
|
||||
|
||||
Because we want our devices to work across various vendors and implementations, we use [Protocol Buffers](https://github.com/meshtastic/Meshtastic-protobufs) pervasively. For information on how the protocol buffers are used with respect to API clients see [sw-design](/docs/software/other/sw-design), for purposes of this document you mostly only
|
||||
need to consider the MeshPacket and Subpacket message types.
|
||||
|
||||
### Later 0: LoRa Radio
|
||||
### Layer 0: LoRa Radio
|
||||
|
||||
All data is converted into LoRa symbols which are sent to the radio for transmission. The details are described elsewhere, but it is worth noting that in addition to the converted packet bytes described below, there is also a preamble sent at the start of any data packet.
|
||||
|
||||
|
@ -51,26 +51,9 @@ This layer is conventional non-reliable LoRa packet transmission. The transmitte
|
|||
|
||||
- **Payload:** An encrypted and packed protobuf encoding of the SubPacket protobuf. Only the SubPacket is encrypted, while headers are not. This allows the option of eventually allowing nodes to route packets without knowing anything about the encrypted payload. For more information, see the [encryption](/docs/developers/firmware/encryption) and [protobufs](/docs/developers/protobufs/api) documentation. Any data past the maximum length is truncated.
|
||||
|
||||
#### Collision Avoidance
|
||||
#### Carrier-Sense Multiple Access with Collision Avoidance (CSMA/CA)
|
||||
|
||||
All transmitters must listen before attempting to transmit. If another node is heard transmitting, the listening node will reattempt transmission after a calculated delay. The delay depends on various settings and is based on Semtech's [LoRa Modem Design Guide](/documents/LoRa_Design_Guide.pdf), section 4 and implemented in `RadioInterface::getPacketTime`. The following tables contains some calculated values for how long it takes to transmit a packet, which is used to calculate the delay.
|
||||
|
||||
| Payload Bytes | Spreading Factor | Bandwidth | Coding Rate | Time |
|
||||
| ------------- | ---------------- | --------- | ----------- | ----------------- |
|
||||
| 0 | 7 | 125 kHz | 4/5 | 13 ms |
|
||||
| 237 | 7 | 125 kHz | 4/5 | 100 ms |
|
||||
| 0 | 7 | 500 kHz | 4/5 | 4 ms |
|
||||
| 237 | 7 | 500 kHz | 4/5 | 25 ms |
|
||||
| 0 | 10 | 250 kHz | 4/7 | 51 ms |
|
||||
| 237 | 10 | 250 kHz | 4/7 | 391 ms |
|
||||
| 0 | 11 | 250 kHz | 4/6 | 101 ms |
|
||||
| 237 | 11 | 250 kHz | 4/6 | 633 ms |
|
||||
| 0 | 9 | 31.25 kHz | 4/8 | 201 ms |
|
||||
| 237 | 9 | 31.25 kHz | 4/8 | 2.413 **seconds** |
|
||||
| 0 | 12 | 125 kHz | 4/8 | 402 ms |
|
||||
| 237 | 12 | 125 kHz | 4/8 | 3.482 **seconds** |
|
||||
|
||||
The actual delay calculation is a random value between 100ms (a hardcoded minimum) and the time taken to transmit just the header, which is given in the table as a 0 Byte payload.
|
||||
Meshtastic adopts CSMA/CA, similar as to what is used in Wi-Fi. This means that all transmitters must perform Channel Activity Detection (CAD) before attempting to transmit. If the channel is considered busy, the node will wait until it is not anymore. Since once the channel becomes idle multiple nodes might want to start transmitting, a node has to wait a random multiple of slot times. The slot time is the time needed to reliably perform CAD. The amount of slot times to wait is randomly picked from a contention window (CW), which size depends on the current channel utilization. The contention window is larger for a higher channel utilization, in order to limit the chance of collisions.
|
||||
|
||||
### Layer 2: Reliable Zero Hop Messaging
|
||||
|
||||
|
@ -89,10 +72,10 @@ If a transmitting node does not receive an ACK (or NAK) packet after a certain e
|
|||
|
||||
Given our use-case for the initial release, most of our protocol is built around [flooding](<https://en.wikipedia.org/wiki/Flooding_(computer_networking)>). The implementation is currently 'naive' and doesn't try to optimize flooding, except by abandoning retransmission once a node has seen a nearby receiver ACK the packet it's trying to flood. This means that up to N retransmissions of a packet could occur in an N node mesh.
|
||||
|
||||
If any mesh nodes see a packet with a HopLimit other than zero, it will decrement that HopLimit and attempt retransmission on behalf of the original sending node.
|
||||
If any mesh node sees a packet with a HopLimit other than zero, it will decrement that HopLimit and attempt retransmission on behalf of the original sending node. In order to promote letting nodes that are further away flood the message, such that the message eventually reaches farther, the contention window (see Layer 1) for a flooding message depends on the Signal-to-Noise Ratio (SNR) of the received packet. The CW size is small for a low SNR, such that nodes that are further away are more likely to flood first and closer nodes that hear this will refrain from flooding.
|
||||
|
||||
:::note
|
||||
A node being in router mode does **not** currently change this behavior, but is intended to be used for future versions of the meshing algorithm. For an explanation of what router mode currently does, see [settings](/docs/settings/router#enabledisable-router-mode).
|
||||
A node being in router mode will have a CW size that is a fraction of that of a normal node at the same SNR, such that it is more likely to flood first. For an explanation of what router mode does additionally, see [settings](/docs/settings/router#enabledisable-router-mode).
|
||||
:::
|
||||
|
||||
### Layer 4: DSR for Multi-Hop Unicast Messaging
|
||||
|
|
Loading…
Reference in a new issue