MQTT Protocol Explained: Lightweight IoT Communication
Advertisement
This article explores the basics of MQTT (Message Queuing Telemetry Transport) within the context of the Internet of Things (IoT). MQTT operates at the session layer of the IoT protocol stack.
To effectively leverage the IoT paradigm, interconnected devices require lightweight communication protocols that minimize CPU resource usage. Languages such as C, Python, Java, and MQTT scripting are commonly employed in IoT applications for this purpose.
There are two primary data exchange protocol architectures:
1. Broker-Based Architecture
In this architecture, a central broker manages the distribution of information.
- The broker stores, forwards, filters, and prioritizes public requests from publisher clients to subscriber clients.
- Clients can switch between publisher and subscriber roles depending on the desired functionalities.
Examples of broker-based protocols:
- AMPQ (Advanced Message Queuing Protocol)
- CoAP (Constrained Application Protocol)
- MQTT (Message Queue Telemetry Transport)
- JMS (Java Message Service API)
2. Bus-Based Architecture
In this architecture, clients publish messages to a specific topic, and these messages are directly delivered to the subscribers of that topic. There is no centralized broker or broker-based services involved.
Examples of bus-based protocols:
- DDS (Data Distribution Service)
- REST (Representational State Transfer)
- XMPP (Extensible Messaging and Presence Protocol)

MQTT broker based architecture
The figure above illustrates an MQTT protocol-based architecture.
- MQTT is a lightweight message queueing and transport protocol.
- As the name suggests, MQTT is well-suited for transporting telemetry data (sensor and actuator data).
- Its lightweight nature makes it ideal for M2M (Machine to Machine), WSN (Wireless Sensor Networks), and IoT scenarios, where sensor and actor nodes communicate with applications through an MQTT message broker.
MQTT Protocol Examples
Here are a few examples of how the MQTT protocol can be used:
- A light sensor continuously sends sensor data to the broker.
- A building control application receives sensor data from the broker and decides to activate the blinds.
- The application sends a blind activation message to the blind actuator node through the broker.

MQTT protocol message format
MQTT Message Format
- MQTT messages contain a mandatory fixed-length header (2 bytes) and an optional message-specific variable-length header and message payload.
- Optional fields typically add complexity to protocol processing.
- However, MQTT is optimized for bandwidth-constrained and unreliable networks (typically wireless networks), so optional fields are used to reduce data transmissions as much as possible.
- MQTT uses network byte and bit ordering.
Continue Learning IoT Protocols
- MQTT Architecture: Message Types, Format, Flow
- CoAP Protocol Architecture & Messages Exchanged between client & Server
- DDS Architecture & its protocol stack layers
- AMQP Architecture Components & Frames
- REST Protocol Vs. SoAP
- XMPP Protocol & Server-Client Interaction
- LWM2M : Key Advantages and Disadvantages
- 6LoWPAN Mesh Network & Protocol Stack
- RPL vs CORPL vs CARP: IoT Routing Protocol Comparison
- HTTP Vs. HTTPS : Key Comparison
- FTP Protocol Basics : key advantages & disadvantages
- Ping vs. Ping6: IPv4 and IPv6 Connectivity
- SFTP Vs. SCP : key Differences
- SSL Vs. SSH : Key Comparison
- MPTCP Protocol : Key Advantages & Disadvantages
- What is QUIC (Quick UDP Internet Connections)?
- TCP-IP Packet Format & its fields with example
Compare IoT Protocols
- MQTT Vs. DDS Protocol
- MQTT Vs. REST Protocol
- MQTT Vs. SMQTT
- CoAP Vs. MQTT : Key Differences
- CoAP Vs. HTTP : Comparison between them
- SFTP Vs. FTPS
- FTP Vs. HTTP : Key Differences between them
- FTP Vs. TFTP (Trivial File Transfer Protocol)
- FTP Vs. SMTP
- AMQP (Advanced Message Queuing Protocol) Vs. JMS(Java Message Service)
- TCP Vs. Multipath TCP (MPTCP)
