# Secure Data Distribution Architecture in IoT Using MQTT
## 1 Introduction  
Message Queuing Telemetry Transport (MQTT) is a standard application layer protocol for Internet of Things (IoT) ecosystems [1], organizing a set of clients around a central broker that distributes messages between clients. It is based on the publish/subscribe paradigm where clients can be publishers or subscribers of topics. A topic can be viewed as a channel that clients listen or push data through. When data are put on the channel (published) by a client, all the clients listening (subscribing) on that channel receive the data. The MQTT broker keeps track of all the publishers and subscribers and handles all the details of delivering data between the clients end to end. MQTT brokers were originally designed to work independently, where information published under a certain topic does not propagate across brokers [2]. However, broker cooperation is essential for building scalable systems based on MQTT, because as the number of clients increases beyond the capabilities of a single broker, more brokers could be introduced to handle a portion of the clients. Hence, a mechanism for cooperation isneeded that allows a set of brokers to cooperate and share data seamlessly. This is performed by popular implementations of the standard support broker cooperation through bridging which allow a pair of brokers to share all or part of their topic space (e.g., [3]). The idea of bridging has been used in the literature to build different types of architectures [4] increasing client anonymity and scalability [5]. However, bridging works by making one broker a client of the other, which places a significant burden on the latter as more brokers bridge to it. This centralizes all cross broker communication through that broker making it a single point of failure while limiting scalability in the process. Another issue associated with broker cooperation is broker discovery. It is a more fundamental issue than cooperation, because brokers need to know one another before they can cooperate. To the best of our knowledge, other architectures have tackled this problem through peer-to-peer discovery as in [5], while other architectures assume the brokers are known or a fixed topology for the network as in [6]. Therefore, we propose a new Service-Oriented Architecture (SOA) that attempts to address the problems of broker discovery and cooperation. It uses a discovery service for broker, topic and interest tracking and peer-to-peer communication between brokers to disseminate data. Hence, new brokers communicate with the discovery service and negotiate participating in the network of brokers. Furthermore, participating brokers also provide the service of exposing their internal publications and metadata to potential consumers through a standard interface. Thus, the brokers consume the discovery service by sending updates about their interests dynamically by aggregating the interests of their local clients. Furthermore, the brokers consume the services provided by other brokers to obtain data they are interested in. For example, a certain client subscribes to topic A within a given broker, then the broker sends this information to the discovery service, which in turn notifies all brokers that manage publishers of topic A. This has the following benefits:  
1. Transparency to clients: All the details of how data are collected and sent is hidden from the clients. In other words, the client does not distinguish between local and global data. This allows the client to move between brokers while maintaining access to their data. 2. Unified global access: Clients can instantly subscribe or publish new topics globally across all brokers without having to do any extra work. 3. Scalability: SOA ensures that individual services can be scaled individually without affecting the rest of the system. 4. Interoperability: Communication between the services is performed using HTTP WebSockets, which maximizes interoperability with many existing webservices and web technologies. 5.