# A LoRaWAN Network Architecture with MQTT2 MULTICAST
## 8 Conclusions  
In this article, we present the design of an IoT network architecture oriented to the collection, processing and visualization of environmental variables. This network is composed of a radio access network and a core network. The RAN is based on LoRaWAN due to its characteristics of low power consumption, high coverage, easy scalability and license free operation, which makes it adequate for massive IoT communications. The core network is based on Software Defined Networking, which provides great flexibility and easy of development. This SDN network provides connectivity between the LoRaWAN networks and other entities required for data distribution, processing and visualization. Most of these functionalities are expected to be deployed in remote clouds or edge resources. One of the most relevant protocols for data distribution in IoT applications is MQTT, which is based on the publish/subscribe paradigm. Leveraging SDN for enhancing MQTT, we propose MQTT2 MULTICAST. Our solution employs MQTT brokers at the edge nodes, which act as MQTT brokers to local clients and multicast MQTT publications (using UDP instead of TCP) to other proxies that have subscribers for the specific topic. For that purpose, MQTT proxies utilize the MQTT2 MULTICAST protocol to ask a server for a mapping between MQTT topics and their corresponding multicast IP addresses. The MQTT2 MULTICAST server is implemented as an SDN controller application, which creates the required multicast routing trees within the SDN. These multicast routing trees are source-based, so the shortest paths between the publishers and the proxies are created by enforcing flow and group entries in the required SDN switches. Once the routing trees are created, the MQTT proxies can start multicasting the Publish messages. We implemented this network architecture using Mininet for the SDN network, RYU as the SDN controller, and implementing (1) the MQTT proxies in Python with the Scapy library, (2) the MQTT2 MULTICAST server as a RYU application, and (3) source-based multicast routing also as part of the RYU application. We tested its proper behaviour  
Figure 17: Total number of paths and Time to generate all possible multicast paths. using real applications (mosquitto_sub and mosquito_pub) and also by implementing a proof of concept with real equipment, i.e., a LoRaWAN network with nodes, gateways, LoRaWAN servers (using the Chirpstack platform) and data visualization (using InfluxDB and Grafana). We released our testbed environment as an open-source project [3], allowing for reproducible research. Finally, we conducted experiments to assess the performance of our prototype. We improved the publication delay approx. by 90% by eliminating non-required signaling and their corresponding round-trip times. In the scenario under evaluation (a tree topology with 16 edge nodes), we reduced the number of packets within the SDN network by 55% (or 77.5% if we consider TCP ACKs) and we almost eliminated the signaling related to multicast routing (compared to other multicast routing protocols such as PIM-SSM). Moreover, we conducted experiments to analyze the scalability of our proposal, showing that the architecture is able to accommodate tens of thousands of LoRaWAN gateways. Conceptualization, [PERSON], [PERSON]-R., [PERSON] and [PERSON]; methodology, [PERSON] and [PERSON]; software, [PERSON]-O. and [PERSON]-R.; validation, [PERSON]-O., [PERSON]-R. and [PERSON]; formal analysis, [PERSON]-O. and [PERSON]-R.; investigation, [PERSON]-O., [PERSON]-R., [PERSON] and [PERSON]-[PERSON]; resources, J.N.-O. and [PERSON]-R.; writing--review and editing, [PERSON]-O., [PERSON]-R., [PERSON] and [PERSON]. All authors have read and agreed to the published version of the manuscript.