MQTT | CoAP | LWM2M |
MQTT is a many-to-many communication protocol for passing messages between multiple clients through a central broker. It decouples producer and consumer by letting clients publish and having the broker decide where to route and copy messages. | CoAP is, primarily, a one-to-one protocol for transferring state information between client and server. While it has support for observing resources, CoAP is best suited to a state transfer model, not purely event based. | CoAP over UDP and SMS Bindings. Provides security, lifecycle management, interoperable system interfaces, data formats, data definitions or device management. |
MQTT clients make a long-lived outgoing TCP connection to a broker. This usually presents no problem for devices behind Network Address Translation (NAT) | CoAP clients and servers both send and receive UDP packets. In NAT environments, tunneling or port forwarding can be used to allow CoAP, or devices may first initiate a connection to the head-end. | LWM2M is not TCP based. Defines the UDP binding with CoAp as mandatory whereas the SMS Binding with CoAP is optional. DTLS (D+TLS) is used to provide a secure channel between Server and Client. |
MQTT provides no support for labelling messages with types or other metadata to help clients understand it. MQTT messages can be used for any purpose, but all clients must know the message formats up-front to allow communication. | CoAP, conversely, provides inbuilt support for content negotiation and discovery allowing devices to probe each other to find ways of exchanging data. | LWM2M is applicable to the transfer of data in addition to device management. MQTT has no standardized Device Management features. |