The Past and Present of MQTT: An IoT Protocol

The previous article introduced MQTT, but it felt like something was missing, so here is a complete overview.

The Origin of MQTT

  • Background: In the late 1990s, polling mechanisms were commonly used in the industrial control field to collect device data, but this method was inefficient and placed a high load on the network. At that time, IBM’s Andy Stanford-Clark and Arlen Nipper from Arcom (now Eurotech) were involved in a project connecting sensors and monitoring devices on oil pipelines via satellite. They discovered many shortcomings of traditional polling protocols, such as bandwidth waste and rapid battery consumption of devices, which led to the idea of developing a new protocol.

  • Initial Applications: In 1999, the first version of MQTT was born, initially named “Argo Lightweight Wired Protocol,” later renamed “MQ Integrator Pervasive Device Protocol,” and was applied in fields such as oil pipeline monitoring, successfully solving remote device communication issues. In 2002, the protocol was officially named MQTT.

  • Standardization and Promotion: In 2003, IBM and Eurotech jointly established the MQTT protocol working group to promote protocol standardization. In 2014, MQTT was adopted by OASIS and released as an official standard (version 3.1.1), with OASIS becoming the new home for MQTT development. In 2018, MQTT version 5.0 was released, adding new features such as shared subscriptions and offline messages, making it more suitable for IoT application needs.

Specific Implementation Details of MQTT

  • Protocol Architecture: Based on the TCP/IP protocol suite, it adopts a client/server and publish/subscribe model. Clients can be publishers, sending data to the server (message broker); they can also be subscribers, receiving data from the server. The server receives application messages from publishers and handles the subscription and unsubscription process, pushing application data to clients that are subscribers.

  • Message Format: MQTT control packets are transmitted via TCP, using port 1883, and can also be securely transmitted via TLS on port 8883 or using WebSocket. Each control packet contains a 2-byte fixed header, optional variable header fields, and an optional payload. MQTT v3.1.1 defines 14 different types of control packets, such as CONNECT (client to server connection request), PUBLISH (client to server/server to client publish message), SUBSCRIBE (client to server subscription request), etc.

  • Connection Process: The client sends a CONNECT packet to the server to establish a connection. The server verifies the connection information, such as username and password, and returns a CONNACK packet. Once the client and server establish a connection, the client can publish messages using the PUBLISH packet, which includes the topic and message content. Subscribers send subscription requests to the server using the SUBSCRIBE packet, and the server pushes matching published messages to the subscribers.

  • Message Reliability: It provides three levels of Quality of Service (QoS). QoS 0 is “at most once,” where messages are transmitted once without acknowledgment; QoS 1 is “at least once,” where messages are transmitted at least once and require acknowledgment; QoS 2 is “exactly once,” using a four-phase handshake mechanism to ensure message delivery.

  • Message Topics and Wildcards: Message topics are strings used to categorize messages, structurally similar to file paths, supporting a hierarchical structure. MQTT provides two types of wildcards: “+” matches a single-level topic, and “#” matches multiple levels, facilitating batch subscriptions to related topics by clients.

The Impact or Benefits of MQTT on the Software Industry

  • Promoting IoT Development: The lightweight, low bandwidth consumption, asynchronous communication, and reliability features of MQTT make it very suitable for communication between IoT devices. It effectively addresses issues such as resource constraints of IoT devices and complex network environments, promoting the widespread application of IoT technologies in areas such as smart homes, smart transportation, and industrial IoT, accelerating the process of connecting everything.

  • Enhancing System Architecture Flexibility: Based on the publish/subscribe model, MQTT decouples the dependencies between publishers and subscribers, making the system architecture more flexible. Developers can independently develop and deploy different modules, facilitating system expansion and maintenance, improving the maintainability and scalability of software systems, and reducing the complexity and cost of software development.

  • Improving Resource Utilization Efficiency: In traditional client/server models, servers need to handle numerous client connections and requests simultaneously, leading to high resource consumption. In contrast, MQTT’s message broker can centrally handle message distribution and transmission, allowing clients to communicate only with the broker, reducing the server’s burden and improving resource utilization efficiency, enabling software systems to run more devices and applications under limited resources.

  • Enhancing Software Real-time Performance and Reliability: The MQTT protocol provides various message publishing Quality of Service levels, allowing the selection of appropriate message transmission reliability levels based on different application scenarios, ensuring timely and accurate message transmission. This is significant for software applications with high real-time and reliability requirements, such as industrial automation control and remote medical monitoring, helping to improve software quality and performance.

Future Development Prospects and Expectations for MQTT

  • Continuous Optimization and Evolution: With the continuous development of IoT technology, the MQTT protocol will also be continuously optimized and evolved. For example, further reducing protocol overhead and latency, improving message transmission efficiency; enhancing protocol security to prevent data leakage and malicious attacks; supporting more device types and network environments to adapt to the ever-changing IoT demands.

  • Integration with Emerging Technologies: MQTT is expected to deeply integrate with emerging technologies such as artificial intelligence, big data, and edge computing. For instance, by combining with AI technology, intelligent analysis and processing of IoT data can be achieved, providing users with more precise services; by integrating with edge computing, some data processing and analysis functions can be offloaded to edge devices, reducing the burden on cloud servers and improving system response speed and real-time performance.

  • Expanding Application Scenarios: In addition to existing application scenarios, the application of MQTT in smart homes, smart cities, smart agriculture, and smart healthcare will continue to expand and deepen. For example, achieving smarter device interactions and scene control in smart homes; using it for traffic flow monitoring, environmental monitoring, and public facility management in smart cities; and enabling remote medical device monitoring and data transmission in smart healthcare, providing stronger support for healthcare services.

  • Promoting Collaborative Development in the Industry: The widespread application of the MQTT protocol will promote collaborative development in the IoT industry. Chip manufacturers, device manufacturers, software developers, cloud service providers, and other stakeholders in the industry chain will form closer cooperative relationships around the MQTT protocol, jointly promoting innovation and application of IoT technology, building a more complete IoT ecosystem, and providing users with richer and more convenient IoT products and services.

Leave a Comment