Just now, I wanted to do some bandwidth calculations for LoRa, but I couldn’t find any easy to use tables with examples or online calculators (and didn’t want to download some Windows-only LoRa Calculator tool). So I took the formula from an application note from Semtech and put it into a spreadsheet, which seems to work fine.
Something I’m trying to do with the lora calculator with LoRaWAN.
Assume that payload is the encrypted?
If so how are getting the encrypted payload length?
Also I thought Explicit header needs to be on?
One remark to prevent confusion: the payload size in your spreadsheet is the LoRa payload, so including LoraWAN header. A user should add 13 bytes to his own payload to get the correct numbers.
@thomas I think usually at least 13 [ MHDR (1) + DevAddr (4) + FCtrl (1) + FCnt (2) + Fport(1) + MIC(4) ] in a packet with no options @iikaw they payload size is independent from the encryption.
The preamble is taken into account (you specify the number of preamble symbols in the sheet). The PHDR and (header) CRC are included if you specify “disable header” as 0 in the sheet. The payload CRC is part of the payload.
I guess not, but: is there any option in The Things Network to skip the LoRaWAN headers?
Like in a pet finder use case, one cannot send coordinates too often, due to the 1% duty cycle and 30 seconds/day Fair Access Policy. But even sending an empty “alive” message (for which a Class A node could then receive some specific reply to start sending coordinates) would take 1.16 seconds on SF12, for just the 13 bytes of the LoRaWAN header, hence would be limited to 26 empty packets a day…
I’ve adjusted this nice sheet a bit, to split application payload and LoRaWAN headers, to show the results of all spread factors, and to include the maximum number of messages to adhere to the TTN Fair Access Policy.
Good to see how the number of symbols decreases when the connection quality drops (assuming that is correct…), and how it only partly depends on the application payload. And scary how on low data rates the TTN Fair Access Policy is really limiting.
@matthijs, if you like these changes then maybe copy them into your sheet, to keep the existing URL? I can then delete this very post.
LoRaWAN might have a fixed coding rate of 1? (So, CR=1.) I cannot find that in the specification. Even more: it does mention it explicitly for transmission of Class B beacons, so I doubt it’s also fixed for other operations?
As LoRaWAN includes its own header, the explicit LoRa header might not be needed? (So, H=1.) That would indeed need a fixed coding rate to start with (which otherwise would be set in the LoRa header). But it would also need some way to determine the payload length (which is in the LoRa header, but not in the LoRaWAN header). I think the LoRaWAN specification claims the LoRa header is always included though:
3.1 Uplink Messages
[…]
Uplink messages use the LoRa radio packet explicit mode in which the LoRa physical header (PHDR) plus a header CRC (PHDR_CRC) are included.
To avoid issues surrounding drift of the crystal reference oscillator due to either temperature change or motion, the low data rate optimization bit is used. Specifically for 125 kHz bandwidth and SF = 11 and 12, this adds a small overhead to increase robustness to reference frequency variations over the timescale of the LoRa packet.
Does anyone know if this is automatically enabled by the chipset or the LoRaWAN stack, for SF11 and SF12? In ttntool this is currently indeed the case:
Okay, I’ve changed my copy of the sheet to auto-enable low data rate correction for SF11…12, and to also make clear that SF6 is not used in LoRaWAN. So basically LoRaWAN users only need to adjust the value for application payload to see the results.
(@matthijs, if you ever copy those changes in your sheet at the original URL then let me know, so I can delete these posts.)
@matthijs@arjanvanb
First of all, thank you very much for the sheet! Very useful for indication!
I have a question about payload comment in the sheet.
‘For LoRaWAN: maximum 55 for low data rates (SF12), up to about 222 bytes for best conditions (SF7).’
In the LoRaWAN spec (7.1.6 EU863-870 Maximum payload size) DR0 - DR2 have a maximum payload of 51 bytes (absence of Fopt)
Would this be a maximum of 51 for SF12 (DR0) according to this table, or am I missing something? Could you please elaborate?
@bvanderpol, that comment is something I added to the original sheet, and took from the FAQ.
The numbers were added to the FAQ after another discussion. But reading it again, that discussion is clear about the maximum, and indeed also mentions 55 but does not explicitly state that’s the minimum. So maybe the minimum in the FAQ is indeed wrong. (I also think the figures are slightly different for different regions? I’m not sure though.)
I am still not quite sure how to calculate the header and payload sizes though. I am using a Waspmote to send frames containing sensor data. The frame is converted into a hexadecimal array—which is the required format by the LoRaWAN.sendUnconfirmed(...) function—by using the following util function:
htdvisser’s ttntool calculated the air time to be 174.3ms, which working backwards in the spreadsheet suggests a payload of 87-90 bytes (if the header is 13 bytes).
So my question is simply: how do I know my payload and header sizes without working backwards based on air time calculated?
Note that there are some minor bugs there as mentioned above, for which I promised a pull request which I still did not create… Not sure how much that affects the result though.
As far as I know, the headers are always 13 bytes (as explained above), and the payload is just a number of bytes too, so 105 in your example. So in matthijs’ original sheet that’s 118 in total; in my version it’s 105 and 13.