RFC 7252 - The Constrained Application Protocol (CoAP)
Published: June 2014
Status: Standards Track
Authors: Z. Shelby, K. Hartke, C. Bormann
Abstract
The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with constrained nodes and constrained (e.g., low-power, lossy) networks. The nodes often have 8-bit microcontrollers with small amounts of ROM and RAM, while constrained networks such as IPv6 over Low-Power Wireless Personal Area Networks (6LoWPANs) often have high packet error rates and a typical throughput of 10s of kbit/s. The protocol is designed for machine-to-machine (M2M) applications such as smart energy and building automation.
CoAP provides a request/response interaction model between application endpoints, supports built-in discovery of services and resources, and includes key concepts of the Web such as URIs and Internet media types. CoAP is designed to easily interface with HTTP for integration with the Web while meeting specialized requirements such as multicast support, very low overhead, and simplicity for constrained environments.
Contents
- 1. Introduction
- 1.1 Features
- 1.2 Terminology
- 2. Constrained Application Protocol
- 2.1 Messaging Model
- 2.2 Request/Response Model
- 2.3 Intermediaries and Caching
- 2.4 Resource Discovery
- 3. Message Format
- 3.1 Option Format
- 3.2 Option Value Formats
- 4. Message Transmission
- 4.1 Messages and Endpoints
- 4.2 Messages Transmitted Reliably
- 4.3 Messages Transmitted without Reliability
- 4.4 Message Correlation
- 4.5 Message Deduplication
- 4.6 Message Size
- 4.7 Congestion Control
- 4.8 Transmission Parameters
- 5. Request/Response Semantics
- 5.1 Requests
- 5.2 Responses
- 5.3 Request/Response Matching
- 5.4 Options
- 5.5 Payloads and Representations
- 5.6 Caching
- 5.7 Proxying
- 5.8 Method Definitions
- 5.9 Response Code Definitions
- 5.10 Option Definitions
- 6. CoAP URIs
- 6.1 coap URI Scheme
- 6.2 coaps URI Scheme
- 6.3 Normalization and Comparison Rules
- 6.4 Decomposing URIs into Options
- 6.5 Composing URIs from Options
- 7. Discovery
- 7.1 Service Discovery
- 7.2 Resource Discovery
- 8. Multicast CoAP
- 8.1 Messaging Layer
- 8.2 Request/Response Layer
- 9. Securing CoAP
- 9.1 DTLS-Secured CoAP
- 10. Cross-Protocol Proxying
- 10.1 CoAP-HTTP Proxying
- 10.2 HTTP-CoAP Proxying
- 11. Security Considerations
- 12. IANA Considerations
- 13. Acknowledgements
- 14. References
Related Resources
- Official Text: RFC 7252
- Official Page: RFC 7252 DataTracker
- Errata: RFC Editor Errata
Quick Reference
What is CoAP?
CoAP (Constrained Application Protocol) is a specialized web protocol designed for Internet of Things (IoT) devices and constrained environments.
Key Features
- ✅ Lightweight - Suitable for resource-constrained devices
- ✅ UDP-based - Uses UDP transport with optional DTLS security
- ✅ RESTful - HTTP-like request/response model
- ✅ Observable Resources - Supports publish/subscribe pattern
- ✅ Built-in Discovery - Resource and service discovery mechanisms
- ✅ Multicast Support - Efficient device discovery
CoAP vs HTTP
| Feature | HTTP | CoAP |
|---|---|---|
| Transport | TCP | UDP |
| Header Overhead | Large (hundreds of bytes) | Small (4-byte fixed) |
| Methods | GET/POST/PUT/DELETE... | GET/POST/PUT/DELETE |
| Response Codes | 3-digit | 2-digit |
| Caching | Supported | Supported |
| Proxying | Supported | Supported |
| Security | TLS | DTLS |
| Use Cases | Web applications | IoT devices |
Application Scenarios
- 🏠 Smart Home - Lights, thermostats, sensors
- 🏭 Industrial Automation - Device monitoring and control
- ⚡ Smart Grid - Energy management
- 🏢 Building Automation - HVAC, lighting systems
- 📡 Low-Power Networks - 6LoWPAN, LoRa, etc.