# A Survey of LoRaWAN for IoT: From Technology to Application
## 2 Introduction to LoRa and LoRaWAN
### LoRaWAN MAC Layer  
The LoRaWAN medium access control (MAC) protocol is an open source protocol standardized by the LoRa Alliance [7] that runs on top of LoRa [1] physical layer. The LoRaWAN MAC layer provides the medium access control mechanism that enables communication between multiple devices and network gateway(s).  
The LoRaWAN network architecture has a star topology, where the end devices can only communicate with LoRaWAN gateways and not directly with each other. Multiple gateways are connected to a central network server. The LoRaWAN gateways are only responsible for forwarding raw data packets from end nodes towards the network server encapsulating them in UDP/IP packets. The network server is responsible for sending downlink packets and MAC commands towards end devices, if needed. Further, the communication terminates at the application servers that can be owned by third parties. Multiple application layers can be connected to a single network server. The resulting LoRaWAN network architecture is shown in Figure 3.  
The LoraWAN standard defines three classes of end devices, Classes A-C. Features of Class A devices are basic sets of options that every end device needs to implement in order to join a LoRaWAN network. To enable bidirectional communication, each uplink transmission of a Class A device is followed by two short downlink receive windows during which the end device will listen for possible downlink traffic. Consequently, the downlink communication is triggered by the end device, meaning that each downlink frame needs to wait for an uplink communication. The first and second downlink receive windows start 1 and 2 s, respectively, after the end of the uplink transmission. If the downlink transmission happens during the first window then the same channel that is used for uplink is used for downlink too, while SF is determined based on the _RX1 DROOffset_ parameter [8]. In case the second receive window is used for the downlink transmission, then a fixed SF and channel are used. This is typically the 125 kHz channel centered at 869.525 MHz using SF12, which has a 10% duty cycle and high transmit power of 24 dBm. It is the responsibility of the network server to schedule the downlink  
Figure 2: LoRa frame structure.  
traffic at the exact time and to perform the timing control. Class A end devices consume the least power since most of the time they are asleep.  
To increase the downlink possibilities, Class B end devices will open additional receive windows at scheduled times. Gateways will transmit beacons in downlink for Class B end devices to get synchronized and for the network server to know when a certain end device will listen for downlink traffic. Class B devices consume higher power compared to Class A devices as they need to open more receive windows, even if those windows might not be used for downlink traffic at all. Class C devices will open continuous receive windows, practically being all the time available for downlink traffic except the time when they are transmitting [9].  
LoRaWAN protocol specifies a number of mechanisms that ensures reliable and secure communication. In the following subsections, we describe the adaptive data rate (ADR) mechanism as well as network joining procedures for end nodes.