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.

Sensor A sends a confirmed uplink, FCnt 7, at SF7 (61.7 ms on air). GW1 hears it at −80 dBm and GW2 at −105 dBm; GW3 at −128 dBm is too weak. At 111.7 ms both gateways forward it to the network server as UDP PUSH_DATA to port 1700. At 311.7 ms the network server keeps one of the 2 copies and checks the MIC and that FCnt 7 is higher than 6. It sends the still encrypted FRMPayload to the application server, which decrypts moisture 31 % and 17.8 °C. The network server sends a PULL_RESP with the ACK to send through GW1 in RX1, and at 1061.7 ms, 1 s after the uplink, GW1 sends the ACK to the sensor, which then needs no RX2 and stays silent 6.1 s.
Every gateway in range forwards the same frame, the network server keeps one copy, and the ACK must reach the sensor exactly in RX1, 1 s after its uplink.

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.

Time line: an uplink of 61.7 ms, then 1 s of sleep, RX1 on 868.1 MHz SF7, then RX2 2 s after the uplink ended, on 869.525 MHz SF12. A downlink fits only into RX1 or RX2.
The only two moments a class A device listens: RX1 at 1 s and RX2 at 2 s after its uplink ends.

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).

PartHoldsTalks
End deviceDevEUI, AppKey; after joining DevAddr, NwkSKey, AppSKey, FCntradio (LoRa)
Gatewaynothing about devicesradio in, UDP/IP out
Network serverDevAddr, NwkSKey, last FCnt, which gateways heard itIP
Application serverAppSKey: the only one that can read the payloadIP

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):

SFAirtimeGateway needs at leastSilent after it (1%)
SF761.7 ms−123 dBm6.1 s
SF8113.2 ms−126 dBm11.2 s
SF9205.8 ms−129 dBm20.4 s
SF10370.7 ms−132 dBm36.7 s
SF11823.3 ms−134.5 dBm81.5 s
SF121482.8 ms−137 dBm146.8 s
Two bars to scale: SF7 is on air 61.7 ms and reaches GW1 and GW2; SF12 is on air 1482.8 ms, 24 times longer, and reaches GW1, GW2 and GW3 at 11 km. After SF7 the device is silent 6.1 s, after SF12 146.8 s.
SF12 reaches the far gateway, but costs 24 times the airtime and 24 times the silence.

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.

On the mind map

Open the Networking mind mapNetworkingLayers & links: frames on one local networkLayers & linksIP & routing: packets hop between networksIP & routingCore services: address, name and timeCore servicesTCP, UDP & sockets: end to end between two portsTCP, UDP & socketsHTTP & TLS: what a browser does per requestHTTP & TLSAPIs & push: how apps talk to serversAPIs & pushProxies & edge: boxes in the middle of the pathProxies & edgeContainers: virtual networks from Linux partsContainersReal-time media: voice and video over UDPReal-time mediaSecurity at the edge: filter traffic at the borderSecurity at the edgeProtocol layersProtocol layerseach layer wraps the one above in a headerHub vs switch vs routerHub vs switch vs routerL1 repeats, L2 learns MACs, L3 routes IPIGMP multicastIGMP multicastsnooping sends a group only to membersRapid Spanning TreeRapid Spanning TreeAlternate port takes over at onceLACP Link AggregationLACP Link AggregationOne flow rides one link, never moreVLANsVLANs802.1Q tag splits one switch into LANs802.1X and RADIUS802.1X and RADIUSPort stays closed until Access-AcceptARPARPbroadcast who-has IP, reply with the MACCRCCRCXOR division remainder catches bit errorsInternet ChecksumInternet ChecksumSum + NOT sum = 0xFFFF; blind to swapsWi-Fi CSMA/CAWi-Fi CSMA/CAlisten, random backoff, wait for the ACKBluetooth LE and GATTBluetooth LE and GATTWrite CCCD 0x0001, then values get pushedALOHA and CSMA/CDALOHA and CSMA/CDFrame must last 2τ to hear a collisionLoRaWAN class ASend any time, listen only at RX1/RX2Cellular Reuse and HandoverCellular Reuse and HandoverMargin + timer: no ping-pong, no dropDigital modulation (QAM)Digital modulation (QAM)More bits per symbol needs more SNROpen the Networking mind mapNetworkingframes on one local networkLayers & linksProtocol layersProtocol layerseach layer wraps the one above in a headerHub vs switch vs routerHub vs switch vs routerL1 repeats, L2 learns MACs, L3 routes IPIGMP multicastIGMP multicastsnooping sends a group only to membersRapid Spanning TreeRapid Spanning TreeAlternate port takes over at onceLACP Link AggregationLACP Link AggregationOne flow rides one link, never moreVLANsVLANs802.1Q tag splits one switch into LANs802.1X and RADIUS802.1X and RADIUSPort stays closed until Access-AcceptARPARPbroadcast who-has IP, reply with the MACCRCCRCXOR division remainder catches bit errorsInternet ChecksumInternet ChecksumSum + NOT sum = 0xFFFF; blind to swapsWi-Fi CSMA/CAWi-Fi CSMA/CAlisten, random backoff, wait for the ACKBluetooth LE and GATTBluetooth LE and GATTWrite CCCD 0x0001, then values get pushedALOHA and CSMA/CDALOHA and CSMA/CDFrame must last 2τ to hear a collisionLoRaWAN class ASend any time, listen only at RX1/RX2Cellular Reuse and HandoverCellular Reuse and HandoverMargin + timer: no ping-pong, no dropDigital modulation (QAM)Digital modulation (QAM)More bits per symbol needs more SNR
This page on the Networking mind map · 83 pages in 10 branches · open it to see the whole map and test yourself in recall mode.