MQ Telemetry Transport (MQTT) is a lightweight broker-based publish/subscribe messaging protocol.
MQTT is designed to be open, simple, lightweight and easy to implement.
• These characteristics make MQTT ideal for use in constrained environments, for example in IoT.
- Where the network is expensive, has low bandwidth or is unreliable
- When run on an embedded device with limited processor or memory resources;
A small transport overhead (the fixed-length header is just 2 bytes), and protocol exchanges minimised to reduce network traffic
MQTT was developed by Andy Stanford-Clark of IBM, and Arlen Nipper of Cirrus Link Solutions.
It supports publish/subscribe message pattern to provide one-to-many message distribution and decoupling of applications
A messaging transport that is agnostic to the content of the payload
The use of TCP/IP to provide basic network connectivity
Three qualities of service for message delivery:
At most once", where messages are delivered according to the best efforts of the underlying TCP/IP network. Message loss or duplication can occur.
This level could be used, for example, with ambient sensor data where it does not matter if an individual reading is lost as the next one will be published soon after.
"At least once", where messages are assured to arrive but duplicates may occur.
- • The message header for each MQTT command message contains a fixed header.
- • Some messages also require a variable header and a payload.
- • The format for each part of the message header:
- — DUP: Duplicate delivery
- — QoS: Quality of Service
- — RETAIN: RETAIN flag
- — This flag is only used on PUBLISH messages. When a client sends a PUBLISH to a server, if the Retain flag is set (1), the server should hold on to the message after it has been delivered to the current subscribers.
- — This allows new subscribers to instantly receive data with the retained, or Last Known Good, value.