Overview
CoAP (Constrained Application Protocol) is a specialized web transfer protocol designed for resource-constrained IoT devices. It provides familiar RESTful semantics (GET, PUT, POST, DELETE) in a compact binary format running over UDP, enabling web-style APIs on microcontrollers with as little as 2KB RAM.
This comprehensive chapter has been organized into focused topics for easier learning. Select a topic below based on your learning goals.
Chapter Contents
Core Concepts
| CoAP Introduction |
Why CoAP exists, comparison with HTTP and MQTT, design philosophy |
Beginner |
| Message Format |
4-byte header structure, options encoding, response codes, tokens |
Intermediate |
| Message Types and Reliability |
CON, NON, ACK, RST messages, retransmission, exponential backoff |
Intermediate |
Advanced Features
| Observe Extension |
Server push notifications, observer management, bandwidth savings |
Intermediate |
| Advanced Features |
Block-wise transfer, resource discovery, CoAP over TCP, DTLS security |
Advanced |
Key Takeaway
CoAP is βHTTP for constrained devicesβ - it provides familiar RESTful semantics (GET, PUT, POST, DELETE on URIs) but compresses everything into a compact binary format running over UDP. Where HTTP requires hundreds of bytes of headers and a TCP connection, CoAP uses just 4 bytes of fixed header and no connection state. The protocol offers two message types: Confirmable (CON) for reliable delivery with acknowledgments, and Non-confirmable (NON) for fire-and-forget efficiency.
Quick Comparison
| Transport |
UDP |
TCP |
TCP |
| Header Size |
4 bytes |
100+ bytes |
2 bytes |
| Pattern |
Request-response |
Request-response |
Publish-subscribe |
| Broker |
No |
No |
Yes |
| Best For |
Constrained devices |
Web integration |
Multiple subscribers |