IT Definition

What is MQTT?

The open MQTT (Message Queue Telemetry Transport) protocol has proven to be the most popular approach for secure communication in the Internet of Things (IoT) and thus also Machine to Machine (M2M) communication. Learn more about it here.
 

What is MQTT?


 
MQTT is a protocol for IoT or M2M communication between devices and applications. It differs from request/response protocols such as HTTP or CoAP instead it decouples all communication participants: For data exchange, messages are sent to the participants via a central distributor(BROKER), which is why there is no need to have in-depth knowledge of receiving applications.
 

 
The MQTT protocol was originally developed for low-resource devices that have poor connectivity and is therefore extremely slim. This makes MQTT ideally suited for embedded development.

Since its introduction in 1999, MQTT has continued to develop, now version 3.1.1 is an official OASIS and ISO standard. The successor, MQTT 5, was specified in 2018.
 

How does MQTT work in Machine to Machine communication (M2M)?

MQTT implements 1:N communication, i.e. a subscriber sends a message that several subscribers can receive. A participant can both send and receive data. All communication takes place via a central distributor which is called MQTT Message Broker.
 


 
The publisher (producer of messages) and the subscriber (recipient of the messages) are thus decoupled. In addition to the “Topic”, a message contains the actual user data. Like a file system path, the topic can represent a hierarchy with main and subordinate topics. If an MQTT client wants to receive messages for a topic, it subscribes to it at the message broker. A subscription can be made directly for a concrete topic, or subtrees of the topic hierarchy can be subscribed to using so-called wildcards. The interested clients are notified by the broker when new messages arrive, instead of requesting changes from the server themselves. Sending and receiving clients remain connected to the MQTT broker via a standing TCP connection. The clients establish the connection themselves and, unlike the broker, do not need an IP address.
 
 
The MQTT broker can now push a message to clients without delay. In this way, MQTT implements the publish/subscribe pattern and guarantees highly efficient communication between the participants.

Protocols for M2M communication have to be lightweights. MQTT therefore does not contain any cryptographic procedures but uses external protocols to secure them or leaves them to the application.
 

Properties and special features of MQTT

MQTT is ideal for exchanging small messages in large numbers at a high frequency. The bandwidth-saving push communication and the simplicity in implementation and use is one of the special features of the message protocol.

In addition, MQTT offers further protocol features, including:

  • Quality of service levels to ensure the receipt of a message (even if the connection has been disconnected in the meantime)
  • Retained Messages: The last message sent can be stored with the broker and sent immediately to new subscribers.
  • Last Will and Testament: This can be used to indicate to a client device network that a client has unexpectedly logged off. To this end, a client leaves a “Last Will” message with the broker, which sends this to all subscribers if the client has not properly logged off.
  • Persistent Sessions: The broker can hold all missed messages to a disconnected client and send them to him as soon as he reconnects.

As an enterprise protocol, MQTT lacks features such as transactions and custom headers. Enterprise applications can easily be connected through a broker that supports multiple protocols. There are numerous broker and client libraries available for many platforms and programming languages, as well as tools such as protocol analyzers.
Special brokers such as the HiveMQ Broker provide a plug-in system that can be used to retrofit application logic to the broker, such as storing messages in databases. One of the public brokers can be used for test purposes.

MQTT 5 brings simplifications for highly scalable systems, such as improved error handling, simplifications for developing your own client libraries, improved authentication, and authorization mechanisms as well as the identification and formalization of typical communication patterns.
Brokers like HiveMQ offer a compatibility layer between the different protocol versions.
 

 

How can I use MQTT in development?

Production-ready implementations are available for all common programming languages. To start, the developer needs an MQTT broker and an MQTT client library. It is recommended e.g. the MQTT broker Mosquitto, which is written in C and ideal for operation on low-resource hardware. The broker HiveMQ, which was specially designed for professional environments and high availability, is suitable for cloud deployment.

The Eclipse Paho project is popular for application development. MQTT implementations can be found here for various programming languages. The MQTT library MQTT Bee is available for cloud backend services.
 

Conclusion

Today’s most popular open communication protocol for the Internet of Things, with its lightweight push functionality, offers many functions that make life easier for application developers to implement secure, high-performance, and easy-to-maintain application communication with and between other devices.
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *