COAP vs MQTT | Difference between COAP and MQTT protocols
This page compares COAP vs MQTT and mentions difference between COAP and MQTT protocols.
• CoAP stands for Constrained Application Protocol.
• It is specified in RFC 7252.It is open IETF standard
• It is very efficient RESTful protocol.
• Easy to proxy to/from HTTP.
• It is Embedded web transfer protocol (coap://)
• It uses asynchronous transaction model.
• UDP is binding with reliability and multicast support.
• GET, POST, PUT and DELETE methods are used.
• URI is supported.
• It uses small and simple 4 byte header.
• Supports binding to UDP, SMS and TCP.
• DTLS based PSK, RPK and certificate security is used.
• uses subset of MIME types and HTTP response codes.
• Uses built in discovery mechanism.
Refer CoAP Protocol>> for more information.
The figure-1 depicts simple MQTT protocol architecture (broker based).
Following are the features of MQTT protocol:
• It is over TCP.
• It uses SSL/TLS for security.
• There are many messages used in MQTT protocol such as CONNECT, PUBLISH, SUBSCRIBE, DISCONNECT etc.
• Username/Password is used in 'connect' message.
• It encrypts payload i.e. it is payload agnostic.
• 1883 port is used by MQTT protocol.
Refer tutorial on MQTT Protocol>> for more information.
Following table compares various features of COAP vs MQTT and tabulates difference between CoAP and MQTT protocols.
|Full Form||Constrained Application Protocol||Message Queue Telemetry Transport|
|Model used for communication||Request-Response, Publish-Subscribe||Publish-Subscribe|
|Transport layer||Preferably UDP, TCP can also be used.||Preferably TCP, UDP can also be used (MQTT-S).|
|Header Size||4 Bytes||2 Bytes|
|Number of message types used||4||16|
|Messaging||Asynchronous & Synchronous||Asynchronous|
|Application Reliability||2 Levels||3 Levels|
|Security||IPSEC or DTLS||Not defined in the standard|
|LLN Suitability (thousand nodes)||Excellent||Fair|
|Application success stories||Utility Field Area Networks||Extending enterprise messaging into IoT applications|