MQTT

from Wikipedia, the free encyclopedia

Message Queuing Telemetry Transport ( MQTT ) is an open network protocol for machine-to-machine communication (M2M) that enables the transmission of telemetry data in the form of messages between devices, despite high delays or limited networks. Corresponding devices range from sensors and actuators , mobile phones, embedded systems in vehicles or laptops to fully developed computers.

The MQTT protocol is also known under older names such as " WebSphere MQTT" (WMQTT), " SCADA protocol" or "MQ Integrator SCADA Device Protocol" (MQIsdp).

The Internet Assigned Numbers Authority (IANA) reserves ports 1883 and 8883 for MQTT. MQTT messages can be encrypted using the TLS protocol.

It is interesting that an MQTT server (“broker”) holds the entire data situation of its communication partners and can thus be used as a status database. It is thus possible to connect small, non-performing MQTT devices to an MQTT broker, whereby the devices collect data and / or receive commands, while a complex picture of the situation is only created on the MQTT broker and can be evaluated here or by a high-performance communication partner . Control interventions can be transmitted to the MQTT broker by one or more high-performance instances and distributed to the individual devices. This makes MQTT very suitable for automation solutions and is widely used in the IoT area because of its simple use.

history

The protocol was developed by Andy Stanford-Clark from IBM and Arlen Nipper from Cirrus Link Solutions.

Since 2013, MQTT has been standardized as the Internet of Things protocol by the Organization for the Advancement of Structured Information Standards (OASIS) .

specification

The MQTT specification differentiates between TCP / IP -based and non-TCP / IP networks.

Main specification
The protocol enables an observer behavior pattern in a very simple way . It is particularly suitable for connections that only allow a small amount of administrative data. The OASIS standardization process is based on version 3.1 of the MQTT specification. Version 5 was released in January 2018, which should make it more convenient for developers to use.
Specification of MQTT-SN (formerly MQTT-S), version 1.2 (MQTT for sensor devices)
Designed for embedded devices in non-TCP / IP networks, such as ZigBee . MQTT-SN is a message protocol based on the observer pattern for sensor networks . It extends MQTT for use beyond the TCP / IP infrastructure and is particularly optimized for use with sensor and actuator solutions. The original name was MQTT-S. However, this generated misunderstandings (s for secure?), So that in 2013 the name was changed to MQTT-SN (SN for Sensor Networks).

protocol

Sample sequence of an MQTT connection with publish and subscribe. The first message from client B is saved by the broker based on the set retain flag.

MQTT is a client-server protocol . After the connection is established, clients send the server (“broker”) messages with a topic that classifies the message hierarchically; for example Küche/Kühlschrank/Temperaturor Auto/Rad/3/Luftdruck. Clients can subscribe to these topics, and the server forwards the received messages to the appropriate subscribers.

Messages always consist of a topic and the message content. Messages are sent with a definable Quality of Service : at most once (the message is sent once and may not arrive if the connection is interrupted), at least once (the message is sent until receipt is confirmed and can be sent several times to the recipient arrive) and exactly once (this ensures that the message arrives exactly once even if the connection is interrupted). In addition, the retain flag can be used to instruct the server to temporarily store the message for this topic. Clients who subscribe to this topic for the first time receive the cached message.

When establishing a connection, clients can define a “last will” in the form of a message. If the connection to the client is lost, this message is published and sent to the relevant subscribers.

MQTT is usually used over TCP and has a 2-byte header. The first byte contains the message type (4 bits), the quality of service (2 bits) and a retain flag.

There are the following types of messages:

  • CONNECT
  • CONNACK
  • PUBLISH
  • PUBACK
  • PUBREC
  • PUBREL
  • PUBCOMP
  • SUBSCRIBE
  • SUBACK
  • UNSUBSCRIBE
  • UNSUBACK
  • PINGREQ
  • PINGRESP
  • DISCONNECT

The second byte contains the length of the rest of the MQTT packet.

This is followed by a variable part that contains the MQTT topic, i.e. the topic. Finally comes the payload, i.e. the data content that is published under the topic.

The topics are organized hierarchically. For example:

Neujahrsansprache/1984/audio/ogg
Neujahrsansprache/1984/audio/mp3
Neujahrsansprache/1984/video
Neujahrsansprache/1984/text/ascii
Neujahrsansprache/1984/text/odt

With the # character, everything and what is below can be received from a hierarchy level.

With a + a hierarchy level can be set as a wildcard .


For example:

New Years Address / 1984 / # All of the 1984 New Year's Address
New Years Address / + / text / ascii   The ASCII texts of all New Year's addresses
New Years Address / + / audio / # All audio formats of all New Years speeches

Implementations

Web links

Wiktionary: MQTT  - explanations of meanings, word origins, synonyms, translations

Individual evidence

  1. http://blogs.vmware.com/vfabric/2013/02/choosing-your-messaging-protocol-amqp-mqtt-or-stomp.html
  2. MQTT Frequently Asked Questions: "How does MQTT relate to SCADA protocol and MQIsdp?" (Accessed on April 21, 2015)
  3. M2M protocol MQTT is to become the Internet standard - iX
  4. http://denisseidel.de/mqtt-eine-einfuhrung/
  5. https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=mqtt
  6. MQTT V3.1 Protocol Specification. Retrieved April 29, 2019 .
  7. Evolution of IoT communication: MQTT 5. In: heise.de . January 16, 2018, accessed April 29, 2019 .
  8. MQTT version 5.0. Retrieved April 29, 2019 .
  9. MQTT for Sensor Networks - MQTT-SN. Accessed July 3, 2020.