Skip to content

MQTT UDP protocol specification

Dmitry Zavalishin edited this page Feb 15, 2019 · 12 revisions

MQTT/UDP protocol specification

MQTT/UDP tries to be compatible as far as it is possible with MQTT. Network byte order, string encoding, etc is the same. See MQTT 3.1.1 specfication

Specific for MQTT/UDP is:

Packet types

Publish

Packet format is just the same as in MQTT, but packet identifier field. Flag bits as of now are supposed to be zero. It is possible though to use QoS flags as a request for destination to send PUBACK packet back to acknowledge communication. This way some more reliable communication can be established.

Details: Packet type: PUBLISH

Subscribe

In MQTT/UDP SUBSCRIBE packet is used to request other party to publish topic right now.

Details: Packet type: SUBSCRIBE

Ping

PINGREQ packet is used to find all working nodes.

PINGRESP is sent by current protocol implementations as responce.

Details: Packet type: PINGREQ/PINGRESP

PubAck

NB! Work in progress.

PUBACK packet is sent as answer to PUBLISH packet with non-zero QoS field ((flags & 0x6) >> 1). PUBACK contains 'reply-to' TTR with packet ID of PUBLISH packet we reply to. PUBACK packet's QoS field is QoS of packet we reply to, but limited by sender application settings.

Sender is supposed to decide that PUBLISH message is delivered if:

  • There is PUBACK received with correct reply-to and QoS equal to QoS of sent PUBLISH.
  • There are multiple PUBACKs received with QoS less by one that QoS of sent PUBLISH. By default two such PUBACKS are needed. It is pretty OK to get PUBACK with QoS of zero.