Meshtastic Lora Packet Size

I saw this meshtastic website :

And I saw a previous forum discussion said the maximum packet size is 256bytes and payload is 237bytes.
So, i use 256 - 237 = 19bytes , and the upper linked table shows that the header adds up to 14bytes. Then 19 - 14 = 5 bytes . I would like to know where the remaining 5 bytes are used ?

In addition , I would like to know the total packet size.
For example, If I send a 1 byte string to another meshtastic device via the meshtastic python CLI, what is the total packet size it sends?

Please correct me if I’ve made any other mistakes that I haven’t noticed.

Thank you.

3 Likes

The protobufs encoding adds some overhead that explains the difference.

Meshtastic also uses text compression in the firmware, so to know the actual payload length, you need to check the serial logs when sending a message (e.g. via Bluetooth connection). Then you have to add the header length to it.

2 Likes

We are doing experiments related to packet size. Is there any way to turn off text compression or fix packet size?
Thank you.

1 Like

I don’t think that’s possible with the current firmware. But if you send the same text every time, the compressed length will be the same and you can check that length in the serial logs.

2 Likes

I still have some questions. :confused:
I would like to know preamble size and does the lora packet size on the serial log include preamble?
Thank you.

1 Like

Preamble length is currently 16 symbols.

No, the packet size of the serial log is only the payload of the packet, it does not include the LoRa preamble.

2 Likes

Ok, I undterstand.

mesh-algo


Furthermore, I would like to confirm whether “physical header size” and “packet size” are different from each other.
Thank you.

1 Like

What you see in the serial logs is only the size of the payload from a Meshtastic data message. On top of that, there is some overhead from the protobufs encoding and the Meshtastic header. Together that forms the payload of a LoRa packet that is given to the LoRa chip together with its size here. If you want to know this size, you would have to add a print statement to the code there. The LoRa chip then adds the LoRa header and preamble.
Depending on what you consider the real application data and what overhead, you can calculate the actual “goodput”.

2 Likes

My devices: SX1262
Channel setting:Long Range / Fast
Data-Rate:0.67 kbps
SF / Symbols: 11 / 2048
Coding Rate: 4/8
Bandwidth:250

SX1262 datasheet

This picture is my current understanding of the LoRa and Meshtastic packet structure by using gnuradio.
gr-lora

However, there are still certain parts that I’m unsure about.
I would greatly appreciate it if you could provide me with information regarding the composition of the preamble and how many bytes it occupies? as well as the structure of the LoRa header on this picture correct ?

Thank you very much for your assistance.

2 Likes

The preamble doesn’t contain any information, it’s only used for packet detection and synchronization. But you can read about the relation between symbols and bytes here.
Meshtastic uses an explicit LoRa header, I think what you have is correct but it’s something handled by the chip and not by the firmware.
Also your Meshtastic header contains 2 ‘align’ bytes, which isn’t correct. The header is only 14 bytes.

1 Like

@wengjiahuang0529 I’m sorry, it seems I was incorrect and there are actually 2 bytes for memory alignment in the Packet Header, so it’s 16 bytes.

1 Like

Thank you for informing me! This is very helpful for me.

I have another question.
The LoRa MTU is set at 256 bytes.
So, if I transmit a payload of 255 bytes, wouldn’t it exceed the MTU limit due to the inclusion of the Preamble , LoRa header and Payloaad CRC ?
However, it still seems to work when I actually try it this way.

Are you sending text messages? The payload size for text messages is closer to 237 bytes, but there is compression.

We use the ‘sendData’ function to directly send text messages.
When the ‘portnums’ value is set to ‘IP_TUNNEL_APP’, I observed through serial logs that the message is not being compressed.

sendData should raise an exception when the data size exceeds DATA_PAYLOAD_LEN, which is 237 bytes: https://github.com/meshtastic/python/blob/master/meshtastic/mesh_interface.py#L315

1 Like