COAP vs MQTT: Protocol Comparison
Advertisement
This article compares the Constrained Application Protocol (COAP) and Message Queue Telemetry Transport (MQTT) protocols, highlighting their key differences.
COAP Protocol
- Full Name: Constrained Application Protocol
- Specified in RFC 7252; an open IETF standard.
- A highly efficient RESTful protocol, easily proxied to/from HTTP.
- Utilizes an embedded web transfer protocol (
coap://
). - Employs an asynchronous transaction model.
- Binds with UDP, offering reliability and multicast support.
- Uses familiar methods like GET, POST, PUT, and DELETE.
- URI support is included.
- Features a small, simple 4-byte header.
- Supports binding to UDP, SMS, and TCP.
- DTLS-based PSK, RPK, and certificate security.
- Utilizes a subset of MIME types and HTTP response codes.
- Includes a built-in discovery mechanism.
MQTT Protocol
Figure 1 depicts a simple broker-based MQTT protocol architecture. Key features include:
- Operates over TCP.
- Uses SSL/TLS for security.
- Defines various message types like CONNECT, PUBLISH, SUBSCRIBE, DISCONNECT, etc.
- Utilizes Username/Password within the ‘connect’ message.
- Payload agnostic, meaning it encrypts the payload regardless of its content.
- Typically uses port 1883.
COAP vs MQTT: Feature Comparison
The following table compares features of COAP and MQTT:
Features | CoAP | MQTT |
---|---|---|
Full Form | Constrained Application Protocol | Message Queue Telemetry Transport |
Model used for communication | Request-Response, Publish-Subscribe | Publish-Subscribe |
RESTful | Yes | No |
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 |
Intermediaries | YES | YES (MQTT-S) |
LLN Suitability (thousand nodes) | Excellent | Fair |
Application success stories | Utility Field Area Networks | Extending enterprise messaging into IoT applications |