Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Explaining LoRaWAN

DZone's Guide to

Explaining LoRaWAN

Here's everything you wanted to know about LoRAWAN, an IoT protocol finding use in the industrial Internet designed for long ranges and low power consumption.

· IoT Zone
Free Resource

Learn how Bluetooth mesh helps you create industrial-grade networks. Download the mesh overview.

Beginning in the early 1990s, connecting to the Internet began as a simple, direct path. Nowadays, things have advanced and become more complex, but also more capable. Instead of a single Ethernet connection to the Internet, microcontrollers and other devices can now connect through a long list of protocols: Bluetooth, Wi-Fi, BLE, ZigBee, 3G, 4G, 5G, NFC, RFID, SigFox, DigiMesh, Thread, and 6LoWPAN to name a few. Each of these connections plays a valuable role for device connection and data transmission, but one budding protocol we would like to highlight is LoRaWAN.

Like those listed above, LoRaWAN is a wireless connection network for data communication to the Internet. LoRaWan is quickly setting itself apart as it becomes known and tailored to IoT applications that require long-range and low-power connectivity to the Internet without WiFi. LoRaWan is a great answer for remote battery-powered sensors or devices that communicate over long distances or in remote places. LoRaWAN packages data, which is sent, when needed, over long distances to the nearest, most available gateway, which forwards said packets of data to the server for storage, computation, or visualization.

To become more familiar with LoRaWAN, let's go back to 2009, when the precursor to LoRaWAN, called LPWAN, began in France:

  • LPWAN is a wireless telecommunication wide area network designed to allow long range communications at a low bitrate for connected objects, such as sensors operating on battery with low power requirements.
  • LPWAN enables connectivity for networks of devices that require less bandwidth than standard home equipment provides.
  • LPWAN networks also support more devices over a larger coverage area than consumer mobile technologies and have better bi-directionality capabilities.
  • Networks like Wi-Fi and Bluetooth are adequate for consumer-level IoT applications, but LPWAN is more abundant in industrial IoT, civic and commercial applications.

LPWAN is the cumulative network that encompasses LoRaWAN. Hence, the two are not synonymous, but are instead two separate networks. LPWAN came first, and then adopted several networks that each had their own unique historical upbringing. Some of these adopted networks include AlarmNet (which was later taken under ownership by Honeywell), the 2G network, and LoRaWAN, which was created by a group called the LoRa Alliance in 2014 and is amongst the leading and favorite protocols for connected devices. 

How LoRaWAN Works

Take a look at this diagram, particularly the trash can. We'll come back to it later.

Image title

Note: A list of common terms and definitions have been included at the end of this post as a glossary. To help, you'll see bolded terms throughout the article. Those terms are defined int he glossary.

Using the infographic above, sensors connecting to the internet are referred to as end-devices. Whenever the sensor takes a reading, the device conditionally sends a signal (data packet) that the gateways use to capture the data. That data at the gateway uses FSK (Frequency Shift Keying) to transmit as efficiently as possible to the server using a process called the Chirp Spread Spectrum (CSS). As the data packet from the end device enters the circuitry of the gateway, it comes in "chirps," or symbols that represent digital information (like below). The chirp is then parsed down to the frequency domain, then to a modulated signal for efficient data transport. 

Image title

Image title

The LoRa hardware, after converting the input signal to the frequency domain, is searching within the frequency band for other, better frequency channels that can carry the signal. Once the gateway finds one, this whole process modulates the input signal's frequency to make it more energy efficient, and then "shifts" (hence the "S" in FSK) the signal to that channel for quick data transmission.

The end-devices and gateways continuously interact with each other so that the data transmission can "hop" to other frequency channels that best suit the system's power, speed, duty cycle, and range restraints.

During this frequency modulation, other integrated circuits within the LoRa gateway perform other "improvement" modulations, like filtering out noise, or the jaggedness that you see in a signal.

Image title 

Another reason why LoRaWAN is a low-power, long-range network is thanks to a process called ADR (Adaptive Data Rate). Just like how the FSK process "shifts" the input signal frequency to boost efficiency, ADR "talks" to the LoRaWAN network server to boost the data rate. This is how the "talking" is done between device and server: 

  1. The end-devices (nodes) constantly send uplink messages to the network server of LoRaWAN. These uplink messages are comprised of lots of information about the node's past 20 signals.
  2. The network server analyzes the recent history of the node and makes comparisons to see how much "margin" there is to make changes.
  3. The network may observe that there is a "margin" for sacrificing range for something more useful, like a faster data rate. (Notice from the first diagram in the article that the trash can is sending its data to more gateways than any of the other devices) 
  4. Instead of sending slower messages to far off gateways, the server would rather have the end device send a quicker message to one gateway nearby.
  5. Hence, the ADR process takes advantage of opportunities that will boost the data rate. If the sacrifices being made helps the system operate more efficiently, then the sacrifice will be made using ADR. 

After a gateway receives and interprets a data packet using LoRa technology, the gateway forwards the data to the network server via standard IP connections, like Ethernet or 3G. If the network server receives the same data packet from several gateways, it will only process one of them, disregarding the copies. Hence, if a server receives three of the same data packet (think of the trash can in our illustration), then only one of these data packets will be processed, making for a highly accurate and very efficient data transfer. 

Tradeoffs

As in every engineering application, there are tradeoffs in the world of LoRaWAN when it comes to power, speed, and range. This simple diagram below displays the points of consideration.

Image title

  • Increasing time of data bit -------> reduces data rate -------> lower speed

  • Decreasing time of data bit -------> increases data rate -------> higher speed

  • Increasing the range and reducing power -------> lower speed

  • Increasing the range and quickening the speed --------> requires higher power

  • Increasing the speed and reducing power-------> shorter range 

Frequency Bands

LoRaWAN uses lower radio frequencies at a longer range, and the frequency bands differ between countries.  

  • Europe: 863-870 MHz and 433 MHz bands (868 MHz used by The Things Network). Three common 125 kHz channels for the 868 MHz band (868.10, 868.30 and 868.50 MHz) must be supported by all devices and networks. 
  • USA: 902-928 MHz band, divided into 8 sub bands. Each of these sub bands has eight 125 kHz uplink channels, one 500 kHz uplink channel and one 500 kHz downlink channel. As opposed to Europe's frequency channels, those of USA are classified as uplink and downlink channels
  • Australia: 915-928 MHz band. Uplink frequencies in Australia are on higher frequencies than in the US band. However, the downlink frequencies are the same as in the US band.
  • China: 779-787 MHz band, with three common 125 kHz channels (779.5, 779.7 and 779.9 MHz), and also there exists a 470-510 MHz band, with 96 uplink channels and 48 downlink channels

Classes

LoRaWAN categorizes its end-devices into three different classes to address the different needs reflected in the wide range of applications.  

Class A

  • These devices support bi-directional communication between a device and a gateway.
  • Lowest power category.
  • Class A devices function only in applications where they send an uplink transmission and wait for downlink communication from the server shortly after.
  • Uplink messages can be sent at any time.
  • After sending an uplink message, Class A devices open two receive windows at specified times.
  • The server can respond in either window.
  • The transmission slot (time slot) scheduled for each window by the end-device is based on its own communication needs.
  • If the server does not respond in either of these two receive windows, the next opportunity will be after the next uplink transmission.

Image title

The first line in the diagram is the chronological process of the Class A end-device uplink/downlink process. First, it sends an uplink signal, then waits, then opens up the first receive window; waits again, then opens up a second receive window. The next two lines demonstrate a successful reception of a downlink signal after the downlink signals are captured by the receive window. The last line demonstrates an unsuccessful reception of a downlink signal because it is not captured by the end-device in either receive window. 

Class B

  • Class B end-devices are bi-directional with scheduled receive slots, like Class A.
  • The difference: Class B devices open extra receive windows at scheduled times in addition to Class A's receive windows.
  • Unlike Class A devices, which open their receive windows based on their own communication needs, Class B devices receive a time synchronized beacon from the gateway, allowing the server to know when the end-device is "listening".

Class C

  • Class C devices are bi-directional with maximal receive slots.
  • These devices almost have continuously open receive windows, which are only closed when transmitting.
  • This allows for low-latency communication but is many times more energy consuming than devices in Class A or Class B.

Over-the-Air-Activation (OTAA)

To participate in a LoRaWAN network, each end-device has to be personalized and activated. The functionality of this process is summarized in these steps:

  1. For over-the-air activation, end-devices must follow a join procedure prior to participating in data exchanges with the network server. 
  2. The join procedure requires the end-device to be personalized with the following information before it starts the join procedure: a globally unique end-device identifier (DevEUI), the application identifier (AppEUI), and an AES-128 key (AppKey). 
  3. The join procedure consists of two MAC (media access control) messages exchanged with the server, namely a join request and a join accept
  4. The end-device sends the join-request message consisting of AppEUI and DevEUI of the end-device followed by the DevNonce. 
  5. The join-request message can be transmitted using any data rate and following an efficient frequency hopping sequence across the specified join channels. 
  6. The network server will respond to the join-request message with a join-accept message if the end-device is permitted to join a network. 
  7. After activation, the following information is stored in the end-device: a device address (DevAddr), an application identifier (AppEUI), a network session key (NwkSKey), and an application session key (AppSKey). 

If step 7 is successful, OTAA is accomplished.

Activation by Personalization (ABP)

Under certain circumstances, end-devices can be activated by personalization. Activation by personalization directly ties an end-device to a specific network, by-passing the join request - join accept procedure. So, as opposed to OTAA, the DevAddr and the two session keys NwkSKey and AppSKey are directly stored into the end-device instead of the DevEUI, AppEUI and the AppKey. Simply put, the end-device is already equipped with the required information for participating in a specific LoRa network when started.

The advantage of ABP is that it is easy to connect to the network because the device can be made operational in little time, which is very suitable for certain applications. The disadvantage is that the encryption keys enabling communication with the network are pre-configured in the device, which weakens security.

Glossary

Refer to this section for definitions of technical terms to aid you in understanding LoRaWAN.

Adaptive data rate (ADR): mechanism for optimizing data rates, airtime, and energy consumption in the network 

AppEUI: a global application ID that addresses space and uniquely identifies the application provider (owner) of the end-device

AppKey: an AES-128 application key specific for the end-device that is assigned by the application owner. The AppKey is used to derive the session keys NwkSKey and AppSKey specific for that end-device to encrypt and verify network communication and application data

AppSKey: is used by both the network server and the end-device to encrypt and decrypt the payload field of application-specific data messages

Band: a range of frequencies with a specific least frequency and greatest frequency

Bandwidth: how much data can be sent over a specific connection in a given amount of time (synonymous with data rate)

Chirp Spread Spectrum: a type of modulation technology that is responsible for the reliability of the transmission as well as low power consumption 

Cloud: a platform designed to store and process IoT data. The platform is built to process massive volumes of data generated by devices, sensors, websites, applications, customers and partners and initiate actions for real-time responses.

Data rate: the amount of digital data that is moved from one place to another in a given time; can be viewed as the speed of travel of a given amount of data from one place to another, based on how wide the bandwidth is

DevAddr: contains a network identifier (NwkID) to separate addresses of territorially overlapping networks of different network operators and to remedy roaming issues. It also contains a network address (NwkAddr) of the end-device.

DevEUI: a global end-device ID address space that uniquely identifies the end-device

DevNonce: a random value associated with an end-device. If an end-device tries connecting to the server with a DevNonce value that it has already used before, the server will ignore the request, preventing a system catastrophe known as replay attacks.

Downlink: the link (connection) from a satellite to a ground station. Frequency of downlink signals tend to be broader to cover a large area on Earth and to provide as many services as possible

Duty Cycle: the percentage of the ratio of the pulse duration, or pulse width (PW) to the total period (T) of the waveform. Duty Cycle = PW/T * 100% 

Here's a diagram to help you better visualize what a duty cycle is:

Image title

End-device/Node/End-point: an Internet-capable computer hardware device. The term can refer to desktop computers, laptops, smartphones, tablets, thin clients, printers, or literally any object that can connect to the internet

Frequency channel: when a band is channelized, that means there are specific discrete frequencies that a device (like a radio) will use and transmit data on. Instead of arbitrarily choosing random frequencies to use within the band, a device or network will stick to a certain step size to boost efficiency and avoid wasting gaps between different frequencies. For example, for a band 28-29 MHz, three different 100KHz channels could be 28.1 MHz, 28.2 MHz, 28.3 MHz, etc

LoRa: a proprietary Chirp Spread Spectrum (CSS) radio modulation technology for LPWAN used by LoRaWAN. LoRa is the physical layer, LoRaWAN is the network

LoRaWAN (Long Range Wide Area Network): a media access control (MAC) layer protocol for managing communication between LPWAN gateways and end-node devices, maintained by the LoRa Alliance

LPWAN (Low-Power Wide Area Network): a wireless wide area network technology that is specialized for interconnecting devices with low-bandwidth connectivity, focusing on range and power efficiency

NwkSKey: used by both the network server and the end-device to calculate and verify the MIC (message integrity code) of all data messages to ensure data integrity.

Throughput: a measure of how many units of information a system can process in a given amount of time

Uplink: the link (connection) from a ground station up to a satellite. In IoT applications, signals must cross the atmosphere where attenuation is inevitable (from rain, for example). To avoid as much attenuation as possible, stations on earth boost their uplink signals with more power so that the frequency is narrower (so the signal could "fit" through obstructions in the environment). Hence, uplink signals generally have higher frequencies than downlink signals.

For a deeper look into Bluetooth mesh, check out this technical insight for developers.

Topics:
iot ,lorawan ,lora alliance ,iot protocols ,tutorial

Published at DZone with permission of Thomas Michalski, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}