## 2 Literature Review
### LoRa
#### 2.2.2 LoRa Network Architecture  
Figure 3[40] shows the network architecture of a LoRa. LoRaWAN allows the end nodes or LoRa devices to interact with gateways through LoRa. Gateways send raw LoRaWAN frames from devices to a network server using a higher throughput internet. Gateways are the only bidirectional units also called protocol converters, the network server is responsible for decoding the data packets sent by the LoRa devices and encoding the data into packets that should be sent back to the end nodes. Three classes of LoRa end-devices or nodes are defined based on downlink scheduling, namely class A, class B, and class C. Class A is best suited to battery-operated devices for efficient energy and achieves years of battery life, in LoRaWAN all of the devices support this class and downlink communication is available when the sensor nodes send some data. Class B end devices have timing-based receive slots, and receive a beacon from the gateway at synchronized times. Class C end devices can receive data continuously and stop receiving only when they are transmitting. All of the data sent by end nodes are processed and appropriate action is taken at the application server [41]. Figure 3: Network Architecture of a LoRa. Physical Layer Frame: At the physical (PHY) layer, the preamble is the beginning of the LoRa frame, it is responsible for synchronization and defines the packet modulation technique, and the modulation is to be completed with the same spreading factor for the remaining packets. Ideally, the period of the preamble is 12.25 Ts. After the preamble, a 20-bit PHY Header with Header CRC is encoded using the highly reliable code rate, and the rest of the frame is encoded using the code rate mentioned in the PHY Header. The length of the payload and whether the 16-bit payload CRC is contained within the frame are also included in the PHY header. Payload CRC is present only in the uplink frames in a LoRa network. The MAC Frame is contained in the PHY payload. MAC Layer Frame: A MAC header, a MAC payload, and a Message Integrity Code (MIC) make up the MAC layer packet. Its header specifies two things, the version of the protocol and the message kinds, it can also indicate the management frame or data frame, whether it is sent downlink or uplink, and whether an acknowledgment is required or not, it is also able to indicate that the message is manufacturer-specific. In a join procedure for end-node activation, the MAC Payload might be replaced by join accept or join request messages. The MIC value is computed using the whole MAC Header and MAC Payload portion when using a network session key (Nwk SKey). The MIC value helps to authenticate the end node and prevent message forgery. Application Layer Packet: In an application layer the MAC payload consists of three things, a Frame Header, a Frame Port, and a Frame Payload. Based on the application type, the value of the Frame Port is defined. The application session key (App-SKey) is used to encrypt the Frame Payload value, AES 128 algorithm is used in the encryption. The LoRa network performance analysis is discussed in this section. The analysis begins with the data rate, then the LoRa sensitivity is discussed, and finally the link budget analysis is presented. (i) Spreading Factor (SF): The number of chips utilized to represent a symbol is found by the Spreading Factor (SF) value The greater the SF value, the more chips are used to represent a symbol, implying that the receiver will have more processing gain. As a result, the receiver will be able to accept data signals with a negative (Signal to Noise Ratio) SNR value. CSS uses spreading factors from 7 to 12;  
Figure 4: LoRa Frame Format. (ii) Bandwidth (BW): The frequency range of the chirp signal which carries the baseband data is called the bandwidth;  
(iii) Code Rate (CR): LoRa modulation provides a forward error correction to every data stream (FEC). Encoding 4-bit data along with redundancies into 5-bit, 6-bit, 7-bit, or even 8-bit does this.