MQTT Over QUIC: The Next-Gen IoT Messaging Protocol

Why MQTT over QUIC is the next generation standard protocol for IoT messaging and how it will empower IoT scenarios.

What is the QUIC Protocol?

QUIC (Quick UDP Internet Connections) is a transport layer protocol developed by Google that is based on the User Datagram Protocol (UDP), designed to improve the speed and reliability of network connections, replacing the widely used Transmission Control Protocol (TCP) in current internet infrastructure.

QUIC provides higher security and faster data transmission through encryption and multiplexing techniques. It supports parallel transmission of multiple data streams over a single connection, thus reducing latency and increasing throughput.

QUIC also has mechanisms such as congestion control and flow control to cope with network congestion and ensure the stability of data transmission. The Internet Engineering Task Force (IETF) has completed the standardization of QUIC, and mainstream web browsers and servers are gradually adopting it.

Compared to TCP, QUIC can significantly improve webpage loading speeds and reduce connection interruptions in high-latency and unstable network environments, such as mobile networks, making the web experience smoother.

Basic Characteristics of the QUIC Protocol

Independent Logical Streams

Independent logical streams are one of the core features of QUIC. It allows multiple data streams to be transmitted in parallel over a single connection, and each stream can be handled independently. In contrast, TCP only supports a single data stream, requiring packets to be received and acknowledged in the order they were sent. Through multiplexing, applications can send and receive data more efficiently and make better use of network bandwidth and other resources.

Consistent Security

Another important feature of QUIC is that it provides end-to-end security protection. All data sent over QUIC is encrypted by default and plaintext communication is not supported. This helps prevent data from being eavesdropped on and other forms of attack.

QUIC uses the Transport Layer Security (TLS) protocol to establish and maintain secure connections and end-to-end encryption.

Low Latency

The design of the QUIC protocol aims to reduce the latency required to establish connections, allowing data to be sent and received quickly between endpoints. This is particularly important in high-latency network environments such as mobile networks. To achieve this goal, QUIC minimizes the number of round trips required to establish a connection and uses smaller packets to send data. Traditional internet protocols often suffer from latency issues, such as round-trip times between the US and Europe sometimes reaching 300 or 400 milliseconds.

Reliability

QUIC is based on UDP but can provide reliable transmission capabilities. Similar to TCP, it is a connection-oriented transport protocol.

The QUIC protocol has message loss recovery and retransmission capabilities during data transmission, ensuring data integrity and accuracy. In addition, QUIC can guarantee that packets arrive in the order they were sent, avoiding data errors caused by out-of-order packets.

Eliminating HOL Blocking

QUIC addresses the HOL blocking issue by supporting multiple data streams. This allows messages from different applications to be transmitted independently, avoiding delays that may occur while waiting for other applications.

Introduction to MQTT over QUIC

MQTT is a lightweight messaging protocol suitable for low-bandwidth, high-latency, or unstable network environments. It operates at the application layer and is mainly used for machine-to-machine (M2M) communication and IoT scenarios.MQTT adopts a publish/subscribe model, where devices send messages to a Broker (i.e., publishing), and other devices receive these messages based on topics (i.e., subscribing).

For web applications, QUIC focuses on improving performance and security, while MQTT provides a lightweight and efficient messaging solution for resource-constrained network environments. MQTT based on QUIC can significantly enhance performance and reduce latency without the additional overhead of TLS. Since most QUIC stack implementations are done in user space, they can customize QUIC data transmission according to application layer requirements to adapt to different network environments.

Comparison of MQTT over TCP/TLS

MQTT over TCP/TLS refers to the MQTT protocol using TCP as the transport layer. TCP is a reliable, connection-oriented protocol that ensures the correct delivery of packets between devices.TLS is an encryption protocol that provides secure communication over the network by encrypting the data transmitted between two endpoints. Typically, TLS is used as an upper layer protocol to TCP, establishing and maintaining a connection between two endpoints and encrypting the data transmitted over that connection.

MQTT Over QUIC: The Next-Gen IoT Messaging Protocol

MQTT over QUIC has significant advantages over MQTT over TCP/TLS:

Connection Establishment:

MQTT over TCP/TLS: MQTT over TCP/TLS follows the TLS 1.2 specification, requiring a handshake at both the TCP layer and the TLS layer. This means that two to three round trips are needed before data exchange can begin at the application layer.

MQTT over QUIC: MQTT over QUIC follows the TLS 1.3 specification, allowing for zero or one round trips (0-RTT or 1-RTT) to quickly establish connections, reducing latency during connection establishment.

Latency and Performance:

MQTT over TCP/TLS: Provides reliable data transmission, but TCP‘s HOL blocking issues and congestion control mechanisms may lead to increased latency and reduced performance, especially in unreliable network environments.

MQTT over QUIC: Combines the reliability of TCP with the low-latency characteristics of UDP. The multiplexing feature of QUIC helps minimize HOL blocking issues, thus improving performance in packet loss or high-latency network environments.

Security:

MQTT over TCP/TLS: To ensure the security of MQTT communication, it is usually combined with TLS, which provides encryption and authentication functions. However, this incurs additional overhead during connection establishment and data transmission.

MQTT over QUIC: QUIC implements built-in encryption using TLS 1.3, providing secure communication without the need for additional configuration or overhead.

Client Connection Migration:

MQTT over TCP/TLS: If the MQTT client or server changes its IP address or network, the existing TCP connection must be terminated and re-established, which increases the difficulty of exception handling and can easily lead to various bugs caused by handling exceptions.

MQTT over QUIC: Supports smooth connection migration, allowing clients or servers to change their IP address, port, or network without affecting ongoing communication.

Applications and Support:

MQTT over TCP/TLS: Has been widely adopted and supported, with many platforms and programming languages implementing MQTT brokers, clients, and libraries.

MQTT over QUIC: So far, due to QUIC still being an emerging protocol, MQTT over QUIC has not been widely adopted and supported.

How MQTT over QUIC Optimizes Mobile Communication for IoT

With the address migration, stream multiplexing, flow control, and lower connection establishment latency provided by QUIC, we hope to completely resolve connection issues in mobile IoT scenarios.

MQTT Over QUIC: The Next-Gen IoT Messaging Protocol

QUIC can detect address changes and automatically rebuild connections using 0-RTT, making the client and server unaware of changes to the IP address, thus completely avoiding the series of problems mentioned above.

More Applications of MQTT over QUIC in IoT

In IoT scenarios, MQTT over QUIC can bring many advantages, as low-latency, reliable, and secure communication is crucial for various applications. Since QUIC combines the strengths of both TCP and UDP, and provides built-in encryption, it can significantly improve the performance and security of MQTT-based IoT applications.

Scenarios for using MQTT over QUIC in IoT include:

Vehicle-to-Infrastructure (V2I) Communication: The low latency and reliable data transmission of QUIC can enhance communication efficiency between vehicles and infrastructure components (such as traffic lights, toll systems, or smart parking systems).

Vehicle-to-Everything (V2X) Communication: V2X communication integrates vehicles, infrastructure, and other road users, aiming to improve road safety and traffic efficiency. MQTT over QUIC can provide reliable communication and reduce latency, ensuring timely exchange of critical information.

In-Vehicle Infotainment and Remote Diagnostics Systems: MQTT over QUIC can enhance the performance of infotainment systems, enabling faster media streaming, navigation updates, and real-time traffic information while ensuring communication security.

Fleet Management and Tracking: Real-time tracking and management of fleets require efficient communication between vehicles and management systems. MQTT over QUIC can provide reliable and secure communication for real-time updates on vehicle location, diagnostics, and driving behavior.

OTA Updates: Secure and reliable OTA updates are crucial for updating vehicle firmware and software. MQTT over QUIC can provide the necessary security and reliability to deliver these updates without interrupting vehicle operations.

Emergency Response: In emergencies, reliable and rapid communication is critical. MQTT over QUIC can ensure timely and secure information exchange between emergency vehicles, response teams, and control centers.

EMQX: The First MQTT Broker to Implement MQTT over QUIC

EMQX is a leading open-source MQTT broker with a high-performance real-time message processing engine that powers massive IoT device event stream processing. Starting from version 5.0, EMQX supports MQTT over QUIC, becoming the first MQTT broker to support MQTT over QUIC. It not only provides a more efficient and secure way for MQTT message transmission in modern complex networks but can also significantly enhance MQTT performance in certain scenarios.

EMQX supports replacing the transport layer with QUIC streams, allowing clients to initiate connections and create bidirectional streams for more efficient and reliable communication.EMQX supports two operating modes:

Single Stream Mode is a basic mode that encapsulates MQTT messages in a bidirectional QUIC stream. This mode provides fast handshake, ordered data transmission, connection recovery, 0-RTT, client address migration, and enhanced packet loss detection and recovery features. This mode makes communication between clients and brokers faster and more efficient while maintaining order, quickly recovering connections, and supporting local address migration without affecting client communication.

Multi-Stream Mode utilizes the multiplexing feature of QUIC, allowing MQTT messages to be transmitted over multiple streams. This enables a single MQTT connection to transmit data for multiple topics in parallel without interference. This mode also provides several optimizations, such as decoupling connection control and MQTT data exchange, avoiding HOL blocking, separating upstream and downstream data, prioritizing different types of data, improving concurrency, enhancing robustness, allowing traffic control on data streams, and reducing subscription latency.

MQTT Over QUIC: The Next-Gen IoT Messaging Protocol

Using the NanoSDK Client to Connect to MQTT over QUIC

NanoSDK is the first SDK developed based on C language that supports MQTT over QUIC, fully compatible with EMQX 5.0. The main features of NanoSDK include asynchronous I/O, mapping MQTT connections to QUIC streams, low-latency 0-RTT handshake, and multi-core parallel processing.

Additionally, EMQX also provides client SDKs for various programming languages to support MQTT over QUIC, including:

NanoSDK-Python: NanoSDK Python binding

NanoSDK-Java: NanoSDK Java JNA binding

emqtt – Erlang MQTT Client: An MQTT client developed using Erlang that supports QUIC.

Leave a Comment