Professional IoT solution equipment supplier

Internet of Things Communication Protocol – MQTT

Custom Solutions 2022-08-25 6 views

Overview

IoT applications vary widely, and numerous protocols exist. Among the many IoT communication protocols, MQTT is arguably designed specifically for the Internet of Things, even though it wasn't called that at the time. The official MQTT 3.1.1 specification describes it as: "MQTT is a Client Server publish/subscribe messaging transport protocol. It is light weight, open, simple, and designed to be easy to implement. These characteristics make it ideal for use in many situations, including constrained environments such as for communication in Machine to Machine (M2M) and Internet of Things (IoT) contexts where a small code footprint is required and/or network bandwidth is at a premium." Its features include:

  • · Use of the publish/subscribe message pattern which provides one-to-many message distribution and decoupling of applications.
  • · A messaging transport that is agnostic to the content of the payload.
  • · Three qualities of service for message delivery: 0 (at most once), 1 (at least once), 2 (exactly once).
  • · A small transport overhead and protocol exchanges minimized to reduce network traffic.
  • · A mechanism to notify interested parties when an abnormal disconnection occurs.

History

In 1999, Andy Stanford-Clark of IBM and Arlen Nipper of Arcom (now Cirrus Link) invented and designed a protocol to address connectivity and communication for satellites and oil pipelines, aiming for minimal battery drain and bandwidth usage. The protocol had several explicit requirements:

  • Simple and convenient implementation
  • Reliable quality of service for data transmission
  • Lightweight and bandwidth-efficient
  • Data-agnostic
  • Persistent session awareness

In 2010, after a decade of internal discussion, IBM officially released the free version of MQTT 3.1, welcoming everyone to implement and use the protocol.

In 2013, OASIS, an open standards organization, officially announced the standardization of MQTT. After a year of continuous effort by the standardization committee, MQTT became an officially approved OASIS standard on October 29, 2014.

In March 2019, OASIS approved the new MQTT 5 specification. The new specification introduces features needed for IoT applications deployed on cloud platforms, as well as messaging requiring higher reliability and lower error rates.

The "MQ" in MQTT refers to IBM's MQ series of products developed to support telemetry transmission. In other words, "MQ" is merely a brand name and holds no inherent meaning. It is incorrect for many articles to label MQTT as a "Message Queue Protocol." A clear example is that a message queue protocol typically allows a message to be consumed by only one client, whereas in MQTT, every subscriber can receive the message.

MQTT Publish/Subscribe Model

MQTT Publish/Subscribe Architecture

The publish/subscribe model decouples the client sending messages (publisher) from the client receiving messages (subscriber). The connection between them is handled by a third component (broker). This specification addresses issues of space, time, and synchronization.

  • Space: Publishers and subscribers do not need to know each other; they do not need to exchange IP addresses and ports.
  • Time: Publishers and subscribers do not need to be active simultaneously.
  • Synchronization: Operations of publishing or receiving do not need to be interrupted during message transmission or reception.

The publish/subscribe model removes direct communication between the message publisher and the recipient/subscriber, allowing clients and servers to scale better and operate with high parallelism. Message caching and intelligent routing enhance the scalability of IoT architectures. Through the filtering activities of the MQTT server broker, it can be controlled which client/subscriber receives which message. The broker has the following three filtering options:

Topic-based filtering: Clients subscribe based on topics. Topics have a hierarchical structure and allow filtering using a limited number of wildcard expressions.

Content-based filtering: Receiving clients can subscribe to messages of interest. However, the issue is that the message content needs to be known in advance and cannot be encrypted.

Type-based filtering: Filtering based on the type/class of the message (event).

MQTT's Three Quality of Service Levels

QoS (Quality of Service) is an important metric in MQTT. It is an agreement between the message sender and receiver, defining the delivery guarantee for a specific message.

QoS 0: At Most Once

Messages are delivered on a best-effort basis according to the operating environment. There is no guarantee that the receiver will receive the data; message loss may occur. This level is suitable where losing a single reading is not critical, as the next reading will be published soon. Service Level 0 is often referred to as "fire and forget."

QoS 0

QoS 1: At Least Once

QoS Level 1 guarantees that a message is delivered at least once to the receiver. The sender stores the message until it receives a PUBACK packet from the receiver acknowledging receipt. The message may be sent or delivered multiple times.

QoS 1

QoS 2: Exactly Once

QoS 2 is the highest service level in MQTT. This level guarantees that each message is received by the recipient exactly once. QoS 2 is the safest but slowest quality of service level. The guarantee is provided by at least two request/response flows (a four-part handshake) between the sender and receiver. The sender and receiver use the packet identifier of the original publish message to coordinate the delivery of the message.

QoS 2

Resource Links

MQTT.org Website

MQTT Specification

OASIS MQTT Technical Committee

EMQ X: A free online MQTT 5 server provided by EMQ X Cloud. To optimize access speed for domestic users in China, two endpoints are provided: overseas and domestic. EMQ X is deployed on AWS in the US, while EMQ X (Domestic) is deployed on Tencent Cloud in the Shanghai region, offering stable network channels for domestic access.

Eclipse: Provides a free online MQTT server.

Mosquitto: A free online MQTT server provided by the Mosquitto community.

HiveMQ: Founded in 2012 and headquartered in Landshut, Germany, in the heart of Munich's wine country. Its flagship product, HiveMQ, is an MQTT-based messaging platform designed for fast, efficient, and reliable bidirectional data movement between devices and the cloud.

Cirrus Link’s: Cirrus Link solutions are based on the efficient, open-standard MQTT protocol co-created by its CTO, Arlen Nipper.

MQTT Use Cases Across Various Industries

Editor-in-Chief:

Content Reviewer:
online_customer_service
welcome_to_customer_service