## 1 Introduction
### LoRaWAN  
Many IoT applications, especially in rural regions, need to span considerable range while consuming as little power as possible. LoRa modulation can achieve these goals by spreading the transmission spectrum to, say 125 kHz, but limiting the throughput to a few kilobits per second at most. The relationship between these two variables is called the spreading factor (SF) and it can be varied to suit different needs. A low SF allows higher throughput while a high SF allows decoding signals even below the receiver's noise floor, thus permitting ranges of dozens of kilometers in unencumbered environments and a few kilometers even in urban areas. LoRaWAN is an open media access control (MAC) layer protocol that provides all the functionalities for a complete solution, based on multiple end-nodes that communicate to one or more LoRaWAN Gateways. Gateways in turn connect to a Network Server (NS) using any kind of IP protocol based links. For instance the Gateway might have a cellular modem and SIM card, to connect to the Network server, or it might use a WiFi transceiver and a high gain antenna, or have an Ethernet port to connect to a local wired infrastructure. It can also use a satellite link, by paying the corresponding connection fees. The NS also connects to the  
Figure 1: Why LoRa? LoRa has a greater power budget than Cellular or WiFi and therefore can achieve a greater range or deeper in building coverage, by using a much lower data rate.  
Application Servers (APs) using the IP protocol over whatever infrastructure is available as shown in Figure 2. Gateways are transparent bridges relaying messages between end-devices and one or more network servers. Payload is encrypted by the end-node using the 128-bit Advanced Encryption Standard (AES), so each application is isolated from the others. Traffic is bidirectional, but mostly upward, from the end-node to the Gateways with very little in the downlink direction. A significant advantage of LoRaWAN is the fact that it uses unlicensed bands and open protocols so that it can be implemented by any organization independently from any commercial service providers.  
The LoRaWAN specification defines three device types [3]. All LoRaWAN devices must implement Class A, whereas Class B and Class C are extensions to the specification of Class A devices. A class A device will only listen for possible downlink messages from the Gateway after completing the transmission of its up link messages, and only for two briefs time windows. This will allow the device to sleep most of the time, therefore achieving the maximum battery duration. A class B device will also wake up at certain specified intervals, so its battery will last less. Class C devices will be listening whenever they are not transmitting, so their consumption is the highest, and they are normally meant to be attached to the power grid or a photovoltaic system. All devices and applications have a 64 bit unique identifier (DevEUI and AppEUI). When a device joins the network, it receives a dynamic (non-unique) 32-bit address (DevAddr). The NwkSKey is used to validate the integrity of each message by its Message Integrity Code (MIC) and the AppSKey is used for encryption of the application payload.