# LoRaWAN Network for Fire Monitoring in Rural Environments
## 3 LoRa Technology Overview
### LoRaWAN
#### 3.2.1 Network Architecture  
The typical architecture of a LoRaWAN [29] network is based on a star topology (see Figure 3), in which there is a gateway (gateway) that forwards messages between an end device and a central network server. The network server directs the packets of each device in the network to an application server. To provide integrity and confidentiality to the network, the protocol relies on a symmetric model of session keys derived from keys associated with each device (root keys). The keys associated with the devices and the session keys derived from them are stored by the incoming server (Join Server). The network server, the application server, and the Join Server can be hosted on the same machine.  
The gateways are connected to the network server through the conventional TCP/IP SSL network while the end devices, using LoRa or FSK modulation, use LoRaWAN and communicate with one or more gateways, the latter being able to handle up to 6000 devices. The gateway has the function of collecting data from the different motes included in the network and connecting them to the rest of the network. In this process, three different flows can be observed [30]:  
* Downlink flow: the router receives downlink messages from upstream and waits for a gateway near the device to be available. Finally, it builds downlink options from the gateway options and transmits it.
* Uplink flow: the router receives uplink messages from gateways and parses the uplink content for MAC payload and activations. Finally, it computes new downlink windows, finds a broker to transmit the packet to, and transmits the uplink.
* Status messages: the router uses these messages to track the active gateways.  
To generate all these messages and transmit from a gateway to TTN, two different protocols, i.e., the legacy Semtech UDP protocol and the Gateway Connector protocol, are required.  
The Semtech UDP protocol, uplinks, statuses, and downlinks are exchanged in a pseudo-JSON format between the gateway and the network server. The UDP protocol does not provide authentication and, there is no encryption available. For this reason, gateway messages can be intercepted during transport.  
Using the gateway connector protocol, it is possible to provide security to the system. Gateways are identified by an ID and a key. Sending a message to a router requires knowing the correct ID/key combination. With the gateway connector protocol, messages can be exchanged through network protocols such as MQTT/MQTTS or using gRPC (that supports TLS encryption natively), if the hardware and software support it.  
LoRaWAN does not support communication between the end nodes. However, it is possible to combine LoRaWAN with other specifications that do support it. In general, all communications between the devices are bidirectional.  
Figure 3: LoRaWAN network architecture.  
An end device consists of two parts:  
* A radio module with an antenna.
* A microprocessor for data processing (e.g., data from a sensor).  
As mentioned before, given their small consumption, the end devices are powered by batteries. If an end device has sensors and acts as a remote sensor, it is usually called a more.  
A gateway also has two parts:  
* A radio module with an antenna.
* A microprocessor.  
The gateways are powered by the power grid and connected to the TCP/IP network. In addition, they can usually listen on different frequencies and each of the SFs of each frequency simultaneously.