The idea: a few bytes, many kilometres, years on a battery
A soil sensor in a field sends a few bytes every few minutes, and its battery must last for years. LoRaWAN is built for that. The sensor (an end device) talks by radio to gateways, which can be kilometres away. A gateway does not own a device: every gateway that hears a frame passes it on over the internet to one network server. The network server passes the data to the application server, the program that wants the readings.
The page has two sensors, A and B, three gateways (GW1 at 1 km, GW2 at 4 km, GW3 at 11 km), a network server and an application server. The timeline below the map shows what is on the air, second by second.
Class A: send any time, listen twice
A class A device sleeps almost all the time. When it has data, it wakes up and sends an uplink at once. It does not listen first to check whether the channel is free: it behaves like ALOHA. Listening costs energy, and with long range a device could not hear most of the others anyway.
After the uplink the device opens two short receive windows. RX1
opens 1 s after the end of the uplink (RECEIVE_DELAY1), on the same channel and the same
spreading factor. If nothing came in RX1, RX2 opens 2 s after the end
(RECEIVE_DELAY2) on a fixed channel: 869.525 MHz at SF12 in Europe. A downlink can only
reach a class A device in one of these two windows. A device that got its answer in RX1 does not open RX2.
A confirmed uplink (message type Confirmed Data Up) asks for an ACK, a downlink with
the ACK bit set in FCtrl. An unconfirmed uplink asks for nothing.
The network server must get the ACK to the gateway before the window opens. With a slow backhaul it
can miss RX1 and use RX2 instead (Demo 4: slow backhaul).
Many gateways, one frame
Every gateway in range decodes the same uplink and forwards it. The common gateway software, the
Semtech packet forwarder, sends it as a UDP PUSH_DATA to port 1700, with the radio data
(frequency, SF, RSSI, time). The network server waits a short de-duplication window
(200 ms on this page) and treats all copies with the same DevAddr and frame counter
FCnt as one frame. It checks the MIC (a signature made with the
NwkSKey) and that FCnt is higher than the last one, so an old frame cannot be replayed. Then it sends
the payload to the application server once. The list of gateways is not thrown away: the one with the
best signal sends the reply (Demo 1).
| Part | Holds | Talks |
|---|---|---|
| End device | DevEUI, AppKey; after joining DevAddr, NwkSKey, AppSKey, FCnt | radio (LoRa) |
| Gateway | nothing about devices | radio in, UDP/IP out |
| Network server | DevAddr, NwkSKey, last FCnt, which gateways heard it | IP |
| Application server | AppSKey: the only one that can read the payload | IP |
Joining with OTAA
A new device has no address yet. With over-the-air activation (OTAA) it sends a
Join-request holding its JoinEUI, its DevEUI and a
DevNonce that it never uses twice, signed with its secret AppKey.
The network server checks it and answers with a Join-accept: a DevAddr,
a fresh AppNonce and the NetID, encrypted with the AppKey. The Join-accept
comes in a later window: RX1 5 s after the request (JOIN_ACCEPT_DELAY1), or RX2 at 6 s.
Both sides then compute the same two session keys from AppKey, AppNonce, NetID and DevNonce:
NwkSKey for the network and AppSKey for the data. The keys
themselves never go over the air (Demo 2: OTAA join).
Spreading factor: airtime against range
LoRa sends each symbol as a chirp, a tone that sweeps across the 125 kHz channel. The spreading factor (SF7 to SF12) sets how slow the chirp is: each step up doubles the time per symbol. A slower signal can be decoded when it is weaker, so it reaches farther gateways, but it stays on the air longer. Semtech's formula gives the airtime for this page's uplink (11 bytes of data, 24 bytes in all, 125 kHz, coding rate 4/5):
| SF | Airtime | Gateway needs at least | Silent after it (1%) |
|---|---|---|---|
| SF7 | 61.7 ms | −123 dBm | 6.1 s |
| SF8 | 113.2 ms | −126 dBm | 11.2 s |
| SF9 | 205.8 ms | −129 dBm | 20.4 s |
| SF10 | 370.7 ms | −132 dBm | 36.7 s |
| SF11 | 823.3 ms | −134.5 dBm | 81.5 s |
| SF12 | 1482.8 ms | −137 dBm | 146.8 s |
On this page sensor A reaches GW3 at −128 dBm: too weak for SF7 and SF8, enough from SF9 up (Demo 3: SF12). Real networks use adaptive data rate: the network server tells devices close to a gateway to use a low SF, to save airtime and battery.
The 1% duty cycle
In Europe, LoRaWAN uses the free 868 MHz band, and the law limits each device to a duty cycle of 1% in the 868.0–868.6 MHz sub-band. After sending for T, a device must stay silent for 99 × T on that sub-band. One SF7 uplink means 6.1 s of silence; one SF12 uplink means almost 2.5 minutes. Press Send Uplink twice in a row and the second one waits. Gateways have the same limit for their downlinks, which is one reason downlinks should be rare.
Collisions: ALOHA without listening
Because nobody listens before sending, two devices can send at the same time. If two frames on the same channel and the same SF overlap and arrive about equally strong, the gateway decodes neither (Demo 5: collision). Nobody tells the senders: the network server never saw the frames. A confirmed uplink would notice the missing ACK and resend later; an unconfirmed reading is simply lost. Different spreading factors are almost independent, so frames at SF7 and SF9 on the same channel both get through (Demo 6). Long airtime makes collisions more likely, another reason to use the lowest SF that works.
See also ALOHA and CSMA/CD for why sending without listening wastes most of a busy channel.
See also Wi-Fi CSMA/CA for a radio network that does listen before talking.
See also MQTT QoS levels for how IoT data often travels on from the application server.
What the page leaves out
- The real uplink channels: devices hop between 868.1, 868.3 and 868.5 MHz (and up to 8 channels from the CFList in the Join-accept); the page uses 868.1 MHz only.
- Adaptive data rate, MAC commands (LinkADRReq, DevStatusReq …), FOpts, frame pending, and the RX1 data-rate offset.
- The capture effect: a frame about 6 dB stronger than the other can survive a collision.
- Classes B (scheduled windows with beacons) and C (always listening), ABP activation, LoRaWAN 1.1 with its separate join server and four session keys, and roaming between networks.
- Retransmissions of confirmed uplinks, the exact AES operations, and the gateway's own duty cycle and transmit power.