Calculate LoRaWAN airtime and Class A receive-window budgets
Calculate how spreading factor, payload size and report interval affect modeled airtime and Class A receive-window timing.

Radio Remi
Use the LoRaWAN operations chapter to prepare and review evidence for device-class timing and slow-data-rate payload decisions.
Predict the reading, then compare it with the measurement.
Python 3 in your browser (JupyterLite)
Python · no installOpen the notebook in your browser and run each Python cell; no install or account is needed.
Three ways to run: use JupyterLite here with no install; run main.py locally from the downloadable lab folder; or open the same notebook in Google Colab.
Steps
Step 1
- Do
- In the notebook editor, run the Step 1 notebook cell. Freeze the hypothetical LoRa radio inputs.
- You will see
Run the cell. You should see:
- The run prints 21 PHYPayload bytes, 125000 Hz bandwidth, coding rate 4/5 and eight preamble symbols.
- Why it matters
- A timing result needs its framing assumptions.
Code for step 1#!/usr/bin/env python3 """Deterministic LoRa airtime and Class A receive-window planning model. The output is calculated from hypothetical inputs, not a transmitted LoRaWAN frame. """ import argparse import math def show(number, title, rows): lines = [title, *rows] assert 4 <= len(lines) <= 15 print("\n".join(lines)) def airtime_ms(payload_bytes, sf, bw_hz=125000, cr=1, preamble=8): """LoRa explicit header, CRC on, coding rate 4/(4+cr); payload includes PHYPayload.""" low_rate = int(sf >= 11 and bw_hz == 125000) symbol_s = 2**sf / bw_hz numerator = 8 * payload_bytes - 4 * sf + 28 + 16 payload_symbols = 8 + max(math.ceil(numerator / (4 * (sf - 2 * low_rate))) * (cr + 4), 0) return (preamble + 4.25 + payload_symbols) * symbol_s * 1000 def stage1(): show(1, "Step 1 | Freeze hypothetical radio inputs", [ "PHYPayload=21 bytes; bandwidth=125000 Hz; coding rate=4/5", "Explicit header and payload CRC on; preamble=8 symbols", "SF7 and SF12 are compared at one fixed payload size.", "These are calculated LoRa timings, not transmitted packets.", ]) def stage2(): rows = ["SF symbol_ms airtime_ms"] for sf in (7, 9, 12): rows.append(f"{sf:>2} {2**sf / 125000 * 1000:>9.3f} {airtime_ms(21, sf):>10.3f}") rows.append("SF12 uses low-data-rate optimisation at 125 kHz.") show(2, "Step 2 | Compute modulation airtime", rows) def stage3(): rows = ["payload_bytes SF7_ms SF12_ms"] for size in (13, 21, 35): rows.append(f"{size:>13} {airtime_ms(size, 7):>6.3f} {airtime_ms(size, 12):>7.3f}") rows.append("Larger PHYPayloads increase symbols at fixed radio settings.") show(3, "Step 3 | Change payload size", rows) def stage4(): tx_end_s = airtime_ms(21, 12) / 1000 show(4, "Step 4 | Place Class A receive windows", [ f"SF12 uplink starts at t=0.000 s and ends at t={tx_end_s:.3f} s.", f"Assumed RX1 opening: uplink end +1 s = t={tx_end_s+1:.3f} s.", f"Assumed RX2 opening: uplink end +2 s = t={tx_end_s+2:.3f} s.", "Openings are timing offsets; actual window duration depends on radio/server settings.", ]) def stage5(): rows = ["interval_s SF7_pct SF12_pct SF12_1pct_limit"] for interval in (60, 300, 900): a7, a12 = airtime_ms(21, 7), airtime_ms(21, 12) rows.append(f"{interval:>10} {a7/interval/10:>7.3f} {a12/interval/10:>8.3f} {'PASS' if a12 / (interval*1000) <= .01 else 'EXCEEDS'}") rows.append("1% is a hypothetical channel budget, not a universal legal limit.") show(5, "Step 5 | Compare interval and airtime share", rows) def stage6(): a7, a12 = airtime_ms(21, 7), airtime_ms(21, 12) show(6, "Step 6 | Make a bounded Class A decision", [ f"At 60 s: SF7={a7/600:.3f}% and SF12={a12/600:.3f}% airtime share.", f"At 300 s: SF12={a12/3000:.3f}% airtime share.", "A slower SF consumes more airtime and shifts receive openings later.", "Check regional channel rules, network scheduling, payload size, and retries.", "Decision: lengthen interval if the assumed 1% budget is exceeded.", ]) STAGES = (stage1, stage2, stage3, stage4, stage5, stage6) import platform try: import pyodide runtime = f"Python {platform.python_version()} / Pyodide {pyodide.__version__}" except ImportError: runtime = f"Python {platform.python_version()} (local or Colab)" print(f"Runtime: {runtime}") print("Runner check: Python calculation from this notebook") stage1()
Step 1 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 2
- Do
- In the notebook editor, run the Step 2 notebook cell. Compute airtime at SF7, SF9 and SF12.
- You will see
Run the cell. You should see:
- The SF7 and SF12 airtimes are 56.576 ms and 1482.752 ms for 21 bytes.
- Why it matters
- A slower data rate can change channel occupancy sharply.
Code for step 2stage2()
Step 2 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 3
- Do
- In the notebook editor, run the Step 3 notebook cell. Change the payload size.
- You will see
Run the cell. You should see:
- At 35 bytes, SF7 uses 77.056 ms and SF12 uses 1810.432 ms.
- Why it matters
- Payload growth must be reviewed at the slowest allowed setting.
Code for step 3stage3()
Step 3 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 4
- Do
- In the notebook editor, run the Step 4 notebook cell. Place RX1 and RX2 after the uplink.
- You will see
Run the cell. You should see:
- The modeled SF12 uplink ends at 1.483 s; RX1 opens at 2.483 s and RX2 at 3.483 s.
- Why it matters
- Class A downlink timing follows the uplink end.
Code for step 4stage4()
Step 4 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 5
- Do
- In the notebook editor, run the Step 5 notebook cell. Compare three report intervals against a hypothetical 1% budget.
- You will see
Run the cell. You should see:
- At 60 s, SF12 airtime share is 2.471% and exceeds the assumed budget; at 300 s it is 0.494%.
- Why it matters
- The interval can determine whether a chosen radio setting is feasible.
Code for step 5stage5()
Step 5 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Step 6
- Do
- In the notebook editor, run the Step 6 notebook cell. Record a bounded Class A design decision.
- You will see
Run the cell. You should see:
- The run recommends lengthening the interval when the hypothetical 1% budget is exceeded.
- Why it matters
- A model cannot replace regional rule, network or field checks.
Code for step 6stage6()
Step 6 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture.
Chapter checks
These questions refer to the chapter’s examples. Use the return links to review their answers.
A LoRaWAN deployment has missing readings after devices move from the lab bench to final placement. Which first review step keeps the diagnosis bounded?
Return to the chapter’s knowledge checkA payload works near the gateway but fails after final installation when the network selects a slower data rate. How should the team respond to the installed payload failure at a slower data rate?
Return to the chapter’s knowledge check
Caution
Before you start
Read this before you start.
These are hypothetical LoRa calculations, not transmitted LoRaWAN frames or a regional compliance verdict. Verify regional rules and network settings.
Technical details
- Version tested
- Version tested: Python 3.12.7 / Pyodide 0.27.6 in JupyterLite 0.6.4; Chromium 151.0.7922.34; captureSource playwright:jupyterlite. Date: 2026-10-08.
https://iotclass.org/labs/lorawan-airtime-rx-windows.html