Overview
The Constrained Application Protocol (CoAP) is designed to provide a RESTful interface (similar to HTTP) but with much lower overhead, making it suitable for low-power devices.
Key Characteristics
- UDP-based: Unlike HTTP (which uses TCP), CoAP uses UDP to reduce overhead and simplify implementation.
- Request/Response Model: Uses GET, POST, PUT, and DELETE methods.
- Binary Header: Uses a very small, fixed-length binary header (4 bytes).
- Observe Pattern: Allows a client to 'observe' a resource and receive updates whenever it changes (similar to a subscription).
CoAP vs. MQTT
MQTT is many-to-many (via a broker), while CoAP is primarily one-to-one (client/server). MQTT is better for unreliable links, while CoAP is better for highly constrained devices that need a web-like interface.