# Airtime Calculator

**URL:** <https://www.thethingsnetwork.org/forum/t/airtime-calculator/47928>\
**Category:** Uncategorized\
**Created:** [May 22, 2021, 3:31pm UTC](https://www.thethingsnetwork.org/forum/t/airtime-calculator/47928 "2021-05-22T15:31:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![trymjb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/trymjb/32/35697_2.png) [@trymjb](https://www.thethingsnetwork.org/forum/u/trymjb)\
**Post date:** [May 22, 2021, 3:31pm UTC](https://www.thethingsnetwork.org/forum/t/airtime-calculator/47928/1 "2021-05-22T15:31:39Z")

</div>

Hi!

I wanted to investigate the airtime from various SF/payload combinations, so I implemented a python script calculating Time-on-air from the equations presented here [LoRaWAN: Equal time-on-air for different sized payloads - #4 by trymjb](https://www.thethingsnetwork.org/forum/t/lorawan-equal-time-on-air-for-different-sized-payloads/47905/4)

However, when I compare the results to the airtime calculator provided by TTN, the results differ…

One example is with SF=7, payload = 7, BW = 125 kHz and region = EU868. TTN gives me 56.6ms, and my calculations yield 36ms. What could cause this issue?

CRC = 1  
IH = 0  
CR = 1  
DE = 0

---

<div class="post-metadata">

**Author:** ![Jeff-UK](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jeff-uk/32/35697_2.png) [@Jeff-UK](https://www.thethingsnetwork.org/forum/u/Jeff-UK)\
**Post date:** [May 22, 2021, 3:43pm UTC](https://www.thethingsnetwork.org/forum/t/airtime-calculator/47928/2 "2021-05-22T15:43:30Z")

</div>

Have you allowed for the (~13 Byte IIRC) header under LoRaWAN Spec?

---

<div class="post-metadata">

**Author:** ![trymjb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/trymjb/32/35697_2.png) [@trymjb](https://www.thethingsnetwork.org/forum/u/trymjb)\
**Post date:** [May 22, 2021, 4:01pm UTC](https://www.thethingsnetwork.org/forum/t/airtime-calculator/47928/3 "2021-05-22T16:01:34Z")

</div>

> [@Jeff-UK](#):
>
> (~13 Byte IIRC)

Are you reffering to The preamble length? (8+4.25) In that case yes

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [May 22, 2021, 4:11pm UTC](https://www.thethingsnetwork.org/forum/t/airtime-calculator/47928/4 "2021-05-22T16:11:18Z")

</div>

No, not the preamble, the LoRaWAN header - the bit that says what the device is, the count etc.

I think many of us use this for comparing payload changes:

[https://avbentem.github.io/airtime-calculator/ttn/eu868/2](https://avbentem.github.io/airtime-calculator/ttn/eu868/2)

---

<div class="post-metadata">

**Author:** ![trymjb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/trymjb/32/35697_2.png) [@trymjb](https://www.thethingsnetwork.org/forum/u/trymjb)\
**Post date:** [May 22, 2021, 4:19pm UTC](https://www.thethingsnetwork.org/forum/t/airtime-calculator/47928/5 "2021-05-22T16:19:24Z")

</div>

@Jeff-UK @descartes If i understand it correctly, then The header is accounted for in The IH parameter from The equation posted above (IH = 0: enabled)

Yes the header is enabled (explicit

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [May 22, 2021, 4:25pm UTC](https://www.thethingsnetwork.org/forum/t/airtime-calculator/47928/6 "2021-05-22T16:25:49Z")

</div>

Bit hard to tell, the image you uploaded was too big for the forum so I can’t see the whole formula.

But to be clear, if you have IH = 0, that’s enabling the header??

---

<div class="post-metadata">

**Author:** ![trymjb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/trymjb/32/35697_2.png) [@trymjb](https://www.thethingsnetwork.org/forum/u/trymjb)\
**Post date:** [May 22, 2021, 5:39pm UTC](https://www.thethingsnetwork.org/forum/t/airtime-calculator/47928/7 "2021-05-22T17:39:14Z")

</div>

> [@descartes](#):
>
> But to be clear, if you have IH = 0, that’s enabling the header??

Yes.

The equations for total airtime comes from the sx1276 datasheet

This link [LoRaWAN Airtime calculator,LoRa Packet duration calculation](https://www.rfwireless-world.com/calculators/LoRaWAN-Airtime-calculator.html) gives me the same answer that I calculate, however it is different compared to the TTN calculator.

Maybe it is possible to view the source code for the calculator to see how they do it?

---

<div class="post-metadata">

**Author:** ![LoRaTracker](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/loratracker/32/48502_2.png) [@LoRaTracker](https://www.thethingsnetwork.org/forum/u/LoRaTracker)\
**Post date:** [May 22, 2021, 9:30pm UTC](https://www.thethingsnetwork.org/forum/t/airtime-calculator/47928/8 "2021-05-22T21:30:31Z")

</div>

There seems to be a fair bit of confusion here.

At the LoRa level there is an optional header but that only has a small affect on total air time.

LoRaWAN (which is different to LoRa!) adds 13 bytes or so to the length of the actual data payload.

The calculations in the SX127x datasheets know nothing about LoRaWAN.

---

<div class="post-metadata">

**Author:** ![Jeff-UK](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jeff-uk/32/35697_2.png) [@Jeff-UK](https://www.thethingsnetwork.org/forum/u/Jeff-UK)\
**Post date:** [May 22, 2021, 11:16pm UTC](https://www.thethingsnetwork.org/forum/t/airtime-calculator/47928/9 "2021-05-22T23:16:46Z")

</div>

Hi @trymjb now you see why, in 1st reply to your original post after you said

“(I am writing about it in my masters thesis 😃 )”

I suggested

> [@LoRaWAN: Equal time-on-air for different sized payloads](https://www.thethingsnetwork.org/forum/t/lorawan-equal-time-on-air-for-different-sized-payloads/47905/2):
>
> thinking In which case maybe we should leave you to work this out for yourself from the LoRaWAN specs and 1st principles vs telling you the secrets (also GIYF!) spoilers: LoRaWAN Headers, Payload format and structures, Forward error correct/CRC check/Coding scheme etc. yields a SF specific staircase/quantised increase in total payload/on airtime wink

And gave you some big clues

“_from the LoRaWAN specs and 1st principles_” Note Not just the LoRa/Device specs

“_spoilers: LoRaWAN Headers, Payload format and structures, Forward error correct/CRC check/Coding scheme etc. yields a SF specific staircase/quantised increase in total payload/on airtime_”

😉

Good luck with the rest of your thesis 🙂 👍

---

<div class="post-metadata">

**Author:** ![trymjb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/trymjb/32/35697_2.png) [@trymjb](https://www.thethingsnetwork.org/forum/u/trymjb)\
**Post date:** [May 23, 2021, 11:19am UTC](https://www.thethingsnetwork.org/forum/t/airtime-calculator/47928/10 "2021-05-23T11:19:46Z")

</div>

Alright! Now it is more clear

Thanks Jeff 😃
