You are on page 1of 95

Персонални и ад-хок мрежи

The Long Range Wide Area Network -


LoraWAN
https://www.lora-alliance.org/
Igor Mishkovski, PhD
Faculty of Computer Science and Engineering
Lang Range Communication
Technologies

2 MQTT
Cellular IoT Operators
 Value proposition
 Lowest TCO (Total Cost of Ownership)
 Lowest Energy Consumption
 Out of the box connectivity
 Global Reach

3 MQTT
LoraWAN Architecture

 Association-less, cellular-like architecture


 End devices: field devices
 Gateways: receive and forward messages from end devices (and network
server)
 Network server: where all the intelligence is
 Remove duplicate messages, manages ACKs, manages radio link parameters, etc.

4 MQTT
LoRaWAN IoT

5 MQTT
LoraWAN Protocol Stack

6 MQTT
LoRaWAN Network providers
 Senet
 Commercial network
 The Things Network
 Crowdsourced

7 MQTT
PHY Layer
 In wired protocols: voltage,
timing and wiring defining 1s an
0s
 In wireless: patterns of energy
being send over RF medium
 Manipulate RF
 With radio
 Hardware vs Software defined
(CPU or FPGA)
 What is modulation?
 Digital modulation:
 Symbols: discrete RF energy
state representing some quantity
of information

8 MQTT
Symbols illustrated
 Top: FSK
 Bottom: OOK/ASK

 Compare with analog


modulation
 Analog = infinite possible
symbols
 Digital = finite number of
possible symbols

9 MQTT
More complicated IoT PHYS

 Spread spectrum
 Databits are encoded at a higher data rate and occupy more
spectrum
 Resilient to RF noise

 Examples
 802.15.4
 Bluetooth
 BLE

10 MQTT
LoRaTM Modulation (Semtech)
 Proprietary chirp-based spread spectrum
 uses frequency chirps with a linear variation of frequency over
time in order to encode information
 Chirp signals are used as carrier signals
 Signal is chipped at a higher data rate and modulated onto
a chirp signal
 Chirp is a signal of continuously increasing or decreasing
frequencies
 Lora is the PHY (Closed)
 LoRaWAN: MAC, NWK and APP built on LORA

11 MQTT
Lora Chirps

Chirp = it is a code for 1, 2... bits (on the upper Figure there
is one chirp in time domain)

12 MQTT
Lora Chirps
 Different Spreading Factors – number of received Chrips
in seconds (SF 9 е побавно од SF 7)

13 MQTT
Examining the LORA Phy frame
 Repeated upchirps
 Preamble/Training sequence
 2.25 downchirps
 Start of frame delimiter (SFD)
 Choppy upchirps of varying length
 Data!

14 MQTT
Demodulating the PHY
1. Identify the beginning of a frame
2. Find the beginning of the PHY data
unit
3. Extract data from instantaneous
frequency transitions

15 MQTT
Example

16 MQTT
CSS advantages
 Resilient to interference
 Performance at low power

 Resistant to
 Multi-path (urban applications)
 Doppler effect (mobile applications)

 We use chirps with radars

17 MQTT
Lora Scalability

18 MQTT
Lora Scalability

19 MQTT
Lora Settings
 Spreading Factor (SF)
 Programmable SF: 7, 8, 9, 10, 11, 12
 The higher the SF the more information transmitted per bit;
therefore higher processing gain
 Bandwidth (BW)
 Programmable signal BW settings: 125 kHz, 250 kHz, 500 kHz
 For a given SF, a narrower BW = increased receive sensitivity;
however, increased time on air
 Forward Error Correction (FEC) Code Rate (CR)
 Additional coding rate provides more redundancy to detect
errors and correct them

20 MQTT
Lora Settings in Europe
 Longest distance on LoRa Modulation
 Data Rate (DR) = 0
 LoRa® modulation
 Spreading Factor (SF) = SF12
 Bandwidth (BW) = 125 kHz
 Coding Rate (CR) = 4/5
 Bit Rate = 292 bps
 Max Application Payload Size = 51 bytes
 Time On Air = 2466 ms

21 MQTT
Lora Settings in Europe
 Highest Bit Rate on LoRa Modulation
 Data Rate (DR) = 6
 LoRa® modulation
 Spreading Factor (SF) = SF7
 Bandwidth (BW) = 250 kHz
 Coding Rate (CR) = 4/5
 Bit Rate = 10937 bps
 Max Application Payload Size = 222 bytes
 Time On Air = 185 ms

22 MQTT
Lora Settings in Europe
 Highest Bit Rate on GFSK Modulation
 Data Rate (DR) = 7
 FSK Modulation
 Bit Rate = 50 kbps
 Max Application Payload Size = 222 bytes
 Time On Air = 39 ms

23 MQTT
Chip rate
 BW=Rc = chip rate (chips/s)
 BW=125KHz
 Rc = 125000 chips/s

SF=9
Symbol carries 9 raw bits of information
Symbol holds 2SF=29 = 512 chips
24 MQTT
Symbol rate
 Rs = BW / 2SF = Rc / 2SF
 BW=125KHz, SF=7
 Rs=125000/27 = 977 symbols/sec

25 MQTT
Chip and bit rates
 The nominal bit rate [bit/s]:

 Where BW is the reference bandwidth and SF is the


adopted spreading factor

26 MQTT
How to Choose?
 Two contrasting objectives:
 Rate: “I want to go fast” (low SF)
 Reliability: “I want to go safe” (high SF)

27 MQTT
What is LoRaWAN Protocol?
 Low Power Wide Area Network (LPWAN)
 Bidirectional
 Simple Star Network Topology
 Low data rate l Low cost
 Long battery life
 Ideal for:
 Internet of Things (IoT)
 Machine-to-Machine (M2M)
 Industrial Automation
 Low Power Applications
 Battery Operated Sensors
 Smart City
 Smart Meter
 Smart Agriculture

28 MQTT
LoRaWAN Network

29 MQTT
LoRaWAN Topology

30 MQTT
LoRaWAN Topology

31 MQTT
The end device
 Single-hop wireless communication to one or many
Gateway(s)

32 MQTT
Gateway
 Interface the LoRaWAN RF Network to LoRaWAN
Backend Services
 `Data is “passed through” to Servers
 Connected to Network Server via standard IP
connection

33 MQTT
The network server
 Network Server authenticates data
 If data is addressed to Network Server, data is processed
 l Else data will be forwarded to Application Server
 Connected to the Application Server via standard IP
connection.

34 MQTT
The application server
 Consumer of data
 Application Server decrypts data
 Multiple Application Servers can exist within the same
LoRaWAN Network

35 MQTT
Example

36 MQTT
End-Device Classes
 Each end-device class has different behavior depending on
the choice of optimization:
 Battery Powered – Class A
 Low Latency – Class B
 No Latency – Class C

37 MQTT
LoraWAN End Devices
 Class A:
 Downlink “slots” following
uplink transmissions
 ALOHA-like access in the
uplink
 Class B:
 “extra” downlink ”slots”
available in a scheduled fashion
 Class C:
 Almost continuous downlink
“slots”

38 MQTT
Battery Powered – Class A
 Bidirectional communications
 Unicast messages
 Small payloads
 Long intervals
 End-device initiates communication (uplink)
 Receiver Initiated Transmission
 Server communicates with end-device (downlink) during
predetermined response windows:

39 MQTT
Low Latency – Class B
 Bidirectional with scheduled receive slots
 Unicast and Multicast messages
 Small payloads
 Long intervals
 Periodic beacon from gateway
 Extra receive window (ping slot)
 Server can initiate transmission at fixed intervals
 Ex: Battery powered actuator end-device
 Coordinated Sample Listening

40 MQTT
No Latency – Class C
 Bidirectional communications
 Unicast and Multicast messages
 Small payloads
 Server can initiate transmission at any time
 End-device is constantly receiving
 low-latency actuator end-device
 Continuous Listening

41 MQTT
42 MQTT
End-Device Activation (Joining)
 Before an end-device can communicate on the
LoRaWAN network, it must be activated
 The following information is required:
 Device Address (DevAddr)
 Network Session Key (NwkSKey)
 Application Session Key (AppSKey)

43 MQTT
End-Device Activation (Joining)
 Device Address (DevAddr)
 32-bit identifier
 Unique within the network
 Present in each data frame
 Shared between End-device, Network Server, and Application
Server
 Differentiates nodes within the network, allowing
the network to use the correct encryption keys
and properly interpret the data

44 MQTT
End-Device Activation (Joining)
 Network Session Key (NwkSKey)
 128-bit AES encryption key
 Unique per end-device
 Shared between end-device and Network Server
 Provides message integrity for the communication
 Provides security for end-device to Network Server
communication

45 MQTT
End-Device Activation (Joining)
 Application Session Key (AppSKey)
 128-bit AES encryption key
 Unique per end-device
 Shared between end-device and Application Server
 Used to encrypt / decrypt application data messages
 Provides security for application payload

46 MQTT
End-Device Activation (Joining)
 To exchange this information, two activation methods are
available:

47 MQTT
Over-the-Air-Activation (OTAA)
 End-device transmits Join Request to application server containing:
 Globally unique end-device identifier (DevEUI)
 Sometimes Build in
 Application identifier (AppEUI)
 Identifies application server, similar to port number
 Authentication with Application key (AppKey)
 The server needs to have the AppKey
 AES 128 bit symmetric key, it generates Message Integrity Code
 End-device receives Join Accept from application server
 End-device authenticates Join Accept
 End-device decrypts Join Accept
 End-device extracts and stores Device Address (DevAddr)
 End-device derives:
 Network Session Key (NwkSKey)
 Application Session Key (AppSKey)

48 MQTT
OTAA

49 MQTT
Activation By Personalization (ABP)
 The following information is configured at production
time:
 Device Address (DevAddr)
 Network Session Key (NwkSKey)
 Application Session Key (AppSKey)
 Device is ready to communicate on the network without
any additional procedure.
 Note that the end result is the same, the DevAddr and
security keys are now known to the end-device

50 MQTT
End-Device Data Communications (Class A)
 Uplink Message
 End-Device to Network Server relayed by one or many
Gateways

51 MQTT
End-Device Data Communications (Class A)
 Downlink Message
 Sent by the Network Server to only one End-Device and is
relayed by a single Gateway

52 MQTT
End-Device Data Communications (Class A)
 Unconfirmed-Data Message

53 MQTT
End-Device Data Communications (Class A)
 Unconfirmed-Data Message

54 MQTT
End-Device Data Communications (Class A)
 Unconfirmed-Data Message

55 MQTT
End-Device Data Communications (Class A)
 Unconfirmed-Data Message

56 MQTT
End-Device Data Communications (Class A)
 Confirmed-Data Message

57 MQTT
End-Device Data Communications (Class A)
 Confirmed-Data Message

58 MQTT
End-Device Data Communications (Class A)
 Confirmed-Data Message

59 MQTT
End-Device Data Communications (Class A)
 Confirmed-Data Message

60 MQTT
End-Device Data Communications (Class A)
 Confirmed-Data Message

61 MQTT
End-Device Data Communications (Class A)
 Confirmed-Data Message

62 MQTT
End-Device Data Communications (Class A)
 Application Server Data Message
 If the Application Server has a Data Message for the End-
Device…
 the Application Server has to wait until the End-Device initiates
a transmission

63 MQTT
End-Device Data Communications (Class A)
 Application Server Data Message

64 MQTT
End-Device Data Communications (Class A)
 Application Server Data Message

65 MQTT
End-Device Data Communications (Class A)
 Application Server Data Message

66 MQTT
End-Device Data Communications (Class A)
 Application Server Data Message

67 MQTT
End-Device Data Communications (Class A)
 Application Server Data Message

68 MQTT
End-Device Data Communications (Class A)
 Application Server Data Message

69 MQTT
End-Device Data Communications (Class A)
 Application Server Data Message

70 MQTT
End-Device Data Communications (Class A)
 Application Server Data Message

71 MQTT
Adaptive Data Rate
 LoRaWAN can manage
 data rate and
 RF power output
 for each end-device to
 Optimize for fastest data rate,
 Maximize battery life, and
 Maximize network capacity
 based on range from gateway

72 MQTT
LoRaWAN Class A Uplink TX example

 ALOHA-like procedure to handle channel access and


retransmissions
 If a confirmed message is not acknowledged, the message is
retransmitted after a random time-out (ACK_TIMEOUT)
 ACK_TIMEOUT is randomly drawn in the interval 1[s]-3[s] and
starts at the end of Receive_window2

73 MQTT
TTN Hello World Example
Send and receive your first message via The
Things Network.
 Download and install the latest Arduino Software (IDE).
 Navigate to Sketch > Include Library > Manage
Libraries….
 Search for TheThingsNetwork and click the result to
select it.
 Click the Install button which should appear:

75
Connect your Device
 Use the included Micro-USB cable to connect The Things
Uno to an USB port of your computer.
 In Arduino IDE select Tools > Board > Arduino
Leonardo.
 Navigate to Tools > Port and select the port that
identifies as Arduino Leonardo.

76
Create a Sketch (1)
 In the Arduino IDE, select File > New

77
Create a Sketch (2)
 Select Sketch >
Include Library >
TheThingsNetwork.

78
Get your Device EUI
 In the Arduino IDE, select Sketch > Upload
 Within 10 seconds, select Tools > Serial Monitor

79
Create an Account
 Go to account.thethingsnetwork.org and click create an
account.
 Select Console from the top menu
 From the top right menu, select your name and
then Settings from the dropdown menu to change the
default Handler if the one currently selected is not where
you’ll be deploying most of your devices.

80
Add an Application
 On console.thethingsnetwork.org, click add application.
 For Application ID, choose a unique ID of lower case,
alphanumeric characters and non-consecutive – and _
 For Description, enter anything you like.
 Leave the checkbox enabled to automatically register the
application to your default region.

81
Register your Device

82
Activate your Device
 In the console, scroll down the device’s screen
to Example Code and copy the keys:

 Paste the keys right after the #include of your sketch.


 In the setup() function, copy the following code just
after ttn.showStatus():

83
Activation Output

84
Message the application
 In the Arduino IDE, go back to your sketch and replace
the loop() function with:

85
Monitor & Decode Messages (1)
 From the application’s screen in the console,
select Data from the top right menu.

86
Monitor & Decode Messages (2)
 Select Payload Functions from the top right menu.
 Leave decoder selected and copy-paste

87
Testing the input
 Use the input field and Test button to see how various
payloads of hex-formatted, space-separated bytes are
decoded by selecting the first byte (as number) for a field
called led

88
Convertor

89
Validator

 Invalid messages will be dropped and not published to


services that have subscribed to this application’s
messages.

90
Decoded, converted and valid payload

91
Message your device
 There are different classes of LoRa devices
 In the Arduino IDE, add the following line to setup()
function to let it know what function to call when a
message comes in:

92
Message your device

93
Encoder

94
Discussions

95

You might also like