Fact-checked by Grok 2 weeks ago

Constrained Application Protocol

The Constrained Application Protocol (CoAP) is a specialized transfer designed for use with constrained nodes, such as low-power microcontrollers with limited and capabilities, and constrained networks, including low-power and lossy networks (LLNs) like , where high packet error rates and low throughput (e.g., tens of kbit/s) are common. Defined in 7252 by the (IETF), CoAP enables efficient machine-to-machine (M2M) communications in resource-limited environments, such as the (IoT), by supporting a RESTful model with methods like GET, , PUT, and DELETE, while minimizing overhead through its UDP-based design and a compact 4-byte header. CoAP's primary purpose is to facilitate simple, scalable interactions between constrained devices for applications including smart energy systems, building automation, and intelligent transportation, where traditional web protocols like HTTP would be inefficient due to their higher resource demands. It incorporates built-in mechanisms for service and resource discovery using URIs and media types, supports multicast requests for group communications (as extended in RFC 7390), and allows for asynchronous message exchanges, including confirmable and non-confirmable options to handle unreliable networks. For interoperability with broader web architectures, CoAP includes a mapping to HTTP, enabling proxies to translate between the two protocols without altering core functionality. Security is integrated via (DTLS), using the "coaps" URI scheme on UDP port 5684, while unsecured communications use the "coap" scheme on port 5683. Standardized in June 2014 as part of the IETF's Constrained RESTful Environments () efforts, CoAP has been extended through subsequent s to address specific needs in constrained settings, such as observing resources for push notifications ( 7641), block-wise transfers for large payloads ( 7959), and support for alternative transports like and WebSockets ( 8323), along with more recent advancements such as robust block-wise transfers ( 9177, 2022), hop-limit options ( 8768, 2020), and EAP authentication ( 9820, 2025), with ongoing work in the IETF on and new transports. These features ensure CoAP's suitability for diverse deployments, promoting low-latency, energy-efficient operations while maintaining compatibility with standards.

Introduction

Overview

The Constrained Application Protocol (CoAP) is a specialized web transfer designed for use with constrained nodes and constrained networks, such as those in low-power and lossy environments. It operates over and enables resource-oriented interactions in a lightweight manner, making it suitable for resource-limited devices that cannot support more heavyweight protocols like HTTP. CoAP's primary use cases include machine-to-machine (M2M) communications in the (IoT), sensor networks, and other resource-constrained setups, including low-power wide-area networks (LPWANs). It facilitates efficient data exchange between devices, such as smart sensors reporting environmental data or actuators responding to remote commands, without the overhead that could drain batteries or in such ecosystems. Key benefits of CoAP include its minimal overhead, with a fixed header size of just four bytes, support for addressing to reach multiple recipients efficiently, and RESTful semantics akin to HTTP but optimized for tiny devices. This design ensures low latency and energy consumption, enabling reliable operation in unreliable networks. In its basic client-server model, CoAP clients initiate requests using methods like GET, , PUT, and DELETE to access or manipulate server resources, while servers respond with status codes and optional payloads, often in formats like or for compactness. CoAP also incorporates messaging reliability mechanisms, such as confirmable messages, to handle potential packet loss over .

History and Development

The Constrained Application Protocol (CoAP) originated from efforts within the (IETF) to create a lightweight application-layer protocol for resource-constrained devices and networks, where traditional web protocols like HTTP proved inefficient due to high overhead in terms of bandwidth, power, and processing. The IETF's (CoRE) Working Group, formed in 2010 as a successor to the 6LoWPAN Application Protocols (6lowapp) BOF activities that began around 2009, initiated the development of CoAP to enable RESTful interactions in such environments. Key contributors to CoAP's design included primary authors Zach Shelby, Carsten Bormann, and Klaus Hartke, who drew inspiration from Roy Fielding's architectural principles to ensure CoAP's stateless, resource-oriented nature. Significant input also came from Cullen Jennings and others, as acknowledged in the core specification, with early drafts emerging in 2010 to address machine-to-machine communication needs in low-power, lossy networks. The foundational specification, RFC 7252, was published in June 2014, defining CoAP's core messaging over with confirmable and non-confirmable options for reliability. Subsequent RFCs built upon this: 7390 (October 2014) introduced group communication via ; 7641 (September 2015) added resource observation for efficient state monitoring; 7959 (August 2016) enabled block-wise transfers for handling larger payloads; and later updates like 8974 (January 2021) for extended tokens, 9175 (February 2022) for echo, request-tag, and token processing to enhance security and efficiency, 9482 (November 2023) for CoAP transfer of the (CMP), and 9820 (September 2025) for an authentication service using the (EAP) over CoAP. Ongoing evolution includes the active IETF draft "Constrained Application Protocol (CoAP): Corrections and Clarifications" (draft-ietf-core-corr-clar-02, last updated June 2025), which addresses ambiguities and adds clarifications to prior RFCs. CoAP's adoption has grown in the , with integration into the oneM2M standard's CoAP protocol binding (ITU-T Y.4500.8, March 2018) for service layers and the protocol stack, where CoAP serves as the application protocol for and device management.

Design Principles

Core Concepts

The Constrained Application Protocol (CoAP) is designed as a lightweight web transfer protocol tailored for resource-constrained devices and networks, enabling efficient machine-to-machine (M2M) interactions in environments such as the (IoT). It adopts core principles from the (REST) architectural style to facilitate simple, scalable communication while minimizing overhead. At its foundation, CoAP employs a RESTful architecture where resources are identified using Uniform Resource Identifiers (URIs), such as those with the "coap://" or "coaps://" schemes, allowing endpoints to address and interact with specific data or services. This model supports standard methods analogous to HTTP for common operations: GET to retrieve a resource representation, POST to process an enclosed representation (e.g., creating a new resource), PUT to update or replace an existing resource, and DELETE to remove a resource. These methods enable CRUD (Create, Read, Update, Delete) operations in a structured manner, promoting and ease of integration with web-based systems. CoAP operates in a stateless manner, meaning each request from a client to a is independent and contains all necessary information for processing, without the maintaining session state across interactions. This design reduces complexity and resource demands on constrained devices, aligning with the protocol's goal of simplicity. Complementing statelessness, CoAP incorporates asynchrony to handle unreliable networks effectively; it supports non-blocking interactions through confirmable messages, which require acknowledgments for reliability, and non-confirmable messages for scenarios where immediate delivery confirmation is unnecessary. To address deployment challenges in constrained settings, CoAP includes built-in support for proxying and caching, which aids in traversing network address translators (NATs) and firewalls while optimizing data transfer. Proxies can forward requests on behalf of clients, and caching mechanisms use attributes like Max-Age to indicate response freshness, enabling intermediaries to store and reuse representations without repeated server queries. Proxy is facilitated through well-known URIs, allowing clients to locate intermediaries dynamically. The protocol targets constrained nodes, defined as devices with severe limitations in processing power, memory, and energy, often operating on batteries or energy-harvesting sources. Specifically, these include nodes with very limited (e.g., less than 10 KiB for the most constrained Class 0 devices), restricted code space (e.g., less than 100 KiB), and tight power budgets that prohibit energy-intensive operations. Such nodes typically function within constrained networks, characterized by high rates, variable latency, low (e.g., tens of kbit/s), and asymmetric links where large packets incur significant penalties. For broader web integration, CoAP provides a direct mapping to HTTP and REST paradigms, allowing CoAP messages to be converted to equivalent HTTP requests and responses via stateless proxies. This equivalence supports hybrid environments, where "coap://" URIs can be proxied to "http://" endpoints, enabling constrained devices to participate in the larger ecosystem without protocol silos. The Constrained Application Protocol (CoAP) differs from HTTP primarily in its design for resource-constrained environments, employing a compact header of at least 4 bytes compared to HTTP's text-based headers that often exceed hundreds of bytes, which reduces overhead in low-bandwidth networks. While HTTP relies on for reliable, ordered delivery, CoAP uses as its default transport, enabling lower latency and simpler operation but requiring application-level mechanisms for reliability, such as confirmable messages. This foundation also supports native communication in CoAP, a feature absent in standard HTTP, facilitating efficient group interactions in scenarios like sensor networks. In contrast to , which follows a publish-subscribe model with a central broker for event-driven messaging, CoAP adopts a request-response aligned with RESTful principles, making it more suitable for direct and manipulation in client-server interactions. operates over with built-in quality-of-service levels and message queuing for offline clients, whereas CoAP lacks inherent queuing capabilities, prioritizing lightweight, peer-to-peer exchanges over with optional reliability extensions. Consequently, CoAP excels in scenarios requiring low-latency queries to individual resources, while is preferred for scalable, asynchronous data dissemination across many devices. Compared to AMQP, CoAP is significantly lighter-weight and UDP-oriented, with minimal header overhead (typically 4-16 bytes including options) versus AMQP's more complex, feature-rich framing that supports advanced queuing, transactions, and routing but demands greater computational resources. AMQP, designed for enterprise messaging systems, includes robust broker-mediated patterns and multiple transport options, making it heavier for constrained nodes where CoAP's simplicity enables deployment on devices with limited memory and power. Trade-offs include CoAP's reduced functionality in complex routing scenarios, where AMQP provides richer semantics at the cost of higher and demands. CoAP enhances interoperability with these protocols through standardized proxies, such as those mapping CoAP to HTTP for seamless integration with web services, as outlined in guidelines for URI translation, media type conversion, and response handling. Hybrid systems can also employ CoAP over WebSockets for browser-compatible environments, extending its reach while preserving core semantics. In constrained settings, CoAP offers advantages like lower power consumption by avoiding TCP's three-way handshake and supporting multicast without additional infrastructure, unlike HTTP or MQTT. However, limitations include the absence of built-in queuing or broker persistence found in MQTT and AMQP, necessitating external solutions for durable messaging, and reliance on DTLS for security rather than HTTP's integrated HTTPS.

Protocol Specification

Message Structure

The Constrained Application Protocol (CoAP) employs a compact binary message format designed for resource-constrained environments, consisting of a fixed 4-byte header followed by an optional , zero or more options, and an optional . This structure supports both requests and responses, enabling efficient exchange over unreliable transports like . CoAP defines four message types to handle different reliability and interaction needs: Confirmable (CON), which requires an acknowledgment to ensure delivery; Non-confirmable (NON), sent without expecting a response for fire-and-forget scenarios; Acknowledgement (ACK), a simple response confirming receipt of a CON message; and Reset (RST), signaling that a message was received but could not be processed. These types are encoded in the header's Type field. Each CoAP message includes a 16-bit , an unsigned integer that uniquely identifies the message within a conversation for matching responses to requests and detecting duplicates. Requests and responses use 8-bit codes to denote methods or status: for requests, common methods include GET (0.01) for retrieving a representation, (0.02) for creating or updating a based on the enclosed representation, PUT (0.03) for replacing the target with the request , and DELETE (0.04) for removing the . Later extensions introduce FETCH (0.05), a safe and idempotent method for retrieving representations using parameters in the request , and (0.06), a non-idempotent method for partial updates to a . Responses use codes like 2.05 () to indicate successful delivery of a representation or 4.04 (Not Found) for unavailable . The in a CoAP message is treated as opaque and follows the options; if present, it is preceded by a single-byte marker (0xFF) to distinguish it from options, while its absence implies a zero-length . The 's interpretation depends on the message code and any Content-Format option, but it remains application-specific.

Header Format

The Constrained Application Protocol (CoAP) employs a compact message format designed for resource-constrained environments, beginning with a fixed-size 4-byte header that encapsulates essential for message processing. This header is mandatory for all CoAP messages and precedes any variable-length , options, or , ensuring efficient on low-power devices with limited computational resources. The header's structure is rigidly defined to minimize overhead, with all fields encoded in network byte order (big-endian) for consistent interpretation across endpoints. The header's first byte allocates bits as follows: the 2 most significant bits (bits 7-6 in the byte, but logically positions 0-1 from the left) for the Version field, the next 2 bits (positions 2-3) for the Type field, and the remaining 4 bits (positions 4-7) for the Token Length field. The second byte is dedicated entirely to the 8-bit Code field, while the third and fourth bytes form the 16-bit field. This layout allows for straightforward byte-aligned parsing without variable-length complications in the header itself.
FieldSize (bits)Position in HeaderDescription
Version2Byte 0, bits 7-6Protocol version identifier.
Type2Byte 0, bits 5-4Message type (0=Confirmable, 1=Non-confirmable, 2=Acknowledgement, 3=).
Token Length4Byte 0, bits 3-0Length of the subsequent token in bytes (0-8).
8Byte 1Request or response code.
Message ID16Bytes 2-3 for the message.
The field, set to 1 (binary 01) in the current specification, indicates the CoAP version and facilitates by allowing future versions to potentially alter the message format while ignoring unrecognized versions. Receivers process messages only if the Version matches the expected value; otherwise, they may discard them to prevent misinterpretation. The Type field specifies the reliability semantics of the message: Confirmable (CON) for messages requiring acknowledgment, Non-confirmable (NON) for fire-and-forget delivery, Acknowledgement (ACK) to confirm receipt, and Reset (RST) to signal errors or disinterest. This 2-bit encoding enables lightweight handling of reliability over unreliable transports like UDP. The Token Length field indicates the size of the optional token that follows the header, ranging from 0 to 8 bytes; values 9-15 are reserved and trigger a format error if encountered. The Code field serves dual purposes for requests and responses, structured as a 3-bit (bits 7-5) and 5-bit detail (bits 4-0). For requests, 0 encodes methods such as GET (0.01), (0.02), PUT (0.03), and DELETE (0.04), with detail bits providing method-specific codes. Responses use classes 2 (success, e.g., 2.05 ), 4 (client error, e.g., 4.04 Not Found), or 5 (server error, e.g., 5.01 Internal Server Error), while 0 with detail 0 (0.00) denotes an empty message. Classes 1, 3, 6, and 7 are unassigned in the base protocol, though extensions may use 7 for signaling messages. The 16-bit Message ID field provides a generated randomly or sequentially by the sender, primarily for matching confirmable messages with their acknowledgments or resets and for detecting duplicates during retransmissions. and RST messages copy the Message ID from the corresponding confirmable or non-confirmable message to enable matching. This mechanism supports reliable delivery without excessive state maintenance on constrained nodes.

Options and Tokens

In CoAP, the token is an opaque value consisting of 0 to 8 bytes that enables clients to match responses to their corresponding requests, particularly in asynchronous communication scenarios where multiple requests may be outstanding. The client generates the for each request and includes it in the message, while the server echoes it unchanged in any matching response; a zero-length is used for requests that do not require a response or for simple confirmations. The length of the is specified by the 4-bit Token Length (TKL) in the message header, and are recommended to be randomly generated to mitigate risks such as spoofing attacks. Following the token in a CoAP , zero or more options provide extensible , such as request URIs, content types, or caching directives, without altering the fixed-size header. Each option is encoded in a compact type-length-value (TLV) : the option begins with a single byte where the high 4 bits represent the (the difference between the current option number and the previous one, ranging from 0 to 12 or extended), and the low 4 bits indicate the short length (0 to 12 bytes for the option value, or 13-15 signaling an extended length in the next 0-2 bytes). The value itself follows immediately and can be empty (length 0), an opaque byte string (1-269 bytes maximum), an unsigned integer (0-4 bytes in network byte order), or a string (up to 255 bytes), depending on the . Options are processed in ascending order of their numbers, with deltas allowing efficient encoding of gaps between numbers; for the first option, the delta is from 0. Option numbers are assigned by the IANA as 16-bit unsigned integers in the range 0 to , enabling extensibility while maintaining a small message footprint suitable for constrained devices. Key options include Uri-Path (number 11), which carries one or more string segments of the resource's absolute path (e.g., "sensors" or "temp" for /sensors/temp); Content-Format (number 12), an unsigned integer specifying the payload's , such as 0 for text/plain or 40 for application/link-format; (number 4), an opaque 1-8 byte entity tag for versioning and caching representations; If-Match (number 1), an opaque 0-8 byte precondition that succeeds only if it matches the resource's current ; and Max-Age (number 14), an unsigned integer (0-4 bytes, default 60 seconds) indicating the response's cache lifetime. Options are classified as critical or elective based on the most significant bit of their number: odd numbers denote critical options, which must be recognized and processed by the recipient, or else the is with a 4.02 Bad Option (for confirmable messages) or silently dropped (for non-confirmable ones); even numbers indicate elective options, which may be safely ignored if unrecognized. This distinction ensures robustness in heterogeneous networks, where unknown critical options could break compliance, while elective ones allow for optional features like caching hints. Additionally, options are categorized as proxy-unsafe or safe-to-forward, affecting how intermediaries handle them, but all options form a continuous chain after the token, separated from the by a marker (0xFF) only if a payload follows.
Option NumberNameTypeLength (bytes)Description
1If-Matchopaque0-8Conditional request based on match.
4opaque1-8Entity tag for resource representation.
11Uri-Pathstring1-255 (per segment)URI path segments.
12Content-Formatuint0-2Payload (e.g., 0=text/plain).
14Max-Ageuint0-4Maximum cache age in seconds (default 60).

Transport and Messaging

UDP Binding and Reliability

The Constrained Application Protocol (CoAP) operates over as its default , providing a lightweight alternative to for resource-constrained devices in (IoT) environments. This binding leverages 's connectionless nature to minimize overhead, supporting both IPv4 and , with implicit compatibility for low-power wireless personal area networks (LoWPANs) via header compression. Unsecured CoAP messages use port 5683, while secure communications over (DTLS) utilize port 5684, enabling end-to-end security without altering the core semantics. To ensure reliability over the unreliable transport, CoAP employs confirmable () messages, which require an acknowledgement () from the recipient to confirm delivery. If no ACK is received, the sender retransmits the CON message using an mechanism: the initial retransmission timeout is randomized between 2 seconds (ACK_TIMEOUT) and 3 seconds (ACK_TIMEOUT multiplied by ACK_RANDOM_FACTOR of 1.5), doubling with each subsequent attempt up to a maximum of 4 retransmissions (MAX_RETRANSMIT). This process spans up to 93 seconds (MAX_TRANSMIT_WAIT), after which the exchange is considered failed, balancing reliability with avoidance in lossy networks. In contrast, messages follow a model, requiring no and thus incurring no retransmission overhead, making them ideal for or scenarios like where acknowledgements would be impractical. For duplicate detection, servers maintain a short-term history of recent messages, checking the 16-bit (for responses to the same ) and the optional (for matching requests to responses) within lifetimes of 145 seconds for NON messages and 247 seconds for CON, , and reset (RST) messages (EXCHANGE_LIFETIME and NON_LIFETIME, respectively). This window, approximately 1 to 4 minutes, prevents redundant processing without excessive state retention on constrained devices. Congestion control in CoAP is rudimentary and optional, relying on the random generation of tokens to minimize collision risks and the in CON retransmissions to avoid network overload, without implementing full TCP-like flow or congestion window mechanisms. Multicast communication supports addressing (e.g., addresses like FF0X::FD) exclusively for NON messages, as the base specification prohibits confirmable multicast to prevent ACK storms. Error handling includes RST messages to signal critical failures or unprocessable requests, prompting immediate termination of the exchange, while piggybacked responses—where a server embeds a full response within an ACK to a CON request—enhance efficiency by reducing round-trip times in interactive scenarios.

Group Communication

The Constrained Application Protocol (CoAP) supports group communication to enable efficient one-to-many interactions in constrained () networks, particularly for scenarios requiring simultaneous resource access across multiple s. Defined as an update to the original experimental specification in RFC 7390, this feature leverages to allow a single CoAP client to send requests to a group of servers without individual transmissions. A standards-track update is in progress as of 2025 (draft-ietf-core-groupcomm-bis). It is particularly suited for resource discovery and notifications, where a client can query multiple endpoints for shared , such as capabilities or status updates. Group communication operates exclusively with (non-confirmable) message types to avoid reliability overhead in environments. Addressing in CoAP group communication relies on IP multicast addresses integrated into group Uniform Resource Identifiers (URIs), such as coap://[FF02::FD]:5683/.well-known/core for link-local scope targeting all CoAP nodes. The address FF02::FD is the well-known IPv6 multicast address for all CoAP nodes within a link-local scope, while other scopes like site-local (e.g., FF05::FD) may be used for broader reach; IPv4 equivalents include 224.0.1.187. Servers join relevant multicast groups upon startup, and requests are sent to the group's IP address and default UDP port 5683, with responses returned via unicast to the client to prevent multicast response storms. Border proxies play a crucial role by aggregating multiple client group requests into a single multicast transmission, thereby reducing network traffic in dense IoT deployments, and can translate unicast requests from external clients into multicast for internal groups. Security for CoAP group communication remains challenging, as standard DTLS is designed for pairwise connections and lacks native support for multicast groups, leading many implementations to operate in an unsecured NoSec mode for simplicity and low overhead, though this exposes risks like eavesdropping and amplification attacks. Alternatives include application-layer protections or pre-shared keys for lightweight authentication, but these are not standardized for groups. An extension via Group Object Security for Constrained RESTful Environments (Group OSCORE) addresses these gaps by providing end-to-end security for multicast messages using symmetric keys and partial processing to minimize overhead in constrained devices. Common use cases include network-wide resource discovery, where clients multicast GET requests to /.well-known/core to enumerate available resources across devices, and bulk operations like firmware updates distributed to multiple endpoints simultaneously. However, limitations persist: multicast offers no delivery confirmability or retransmissions, increasing the risk of implosion from uncoordinated unicast responses overwhelming the client, which necessitates rate limiting and response suppression mechanisms. Congestion control is adapted for groups with leisure times such as the DEFAULT_LEISURE of 5 seconds (or a computed MAX_SERVER_RESPONSE_DELAY) to mitigate traffic bursts in lossy networks.

Security

DTLS Integration

The Constrained Application Protocol (CoAP) integrates () to provide secure communication over , analogous to how secures over . version 1.2, as defined in , or version 1.3, as defined in , operates directly over to deliver through , via message authentication codes, and replay protection using sequence numbers and optional anti-replay windows. This integration ensures that CoAP messages are protected against eavesdropping, tampering, and unauthorized access in constrained environments. DTLS supports multiple authentication modes tailored to resource-constrained devices: (PSK) mode uses symmetric keys for lightweight ; (RPK) mode employs asymmetric keys without full certificates for reduced overhead; and certificate-based mode utilizes certificates or smaller equivalents, such as ECDSA with elliptic curves, for stronger . These modes are profiled in 7925 to optimize for (IoT) use cases, mandating cipher suites like TLS_PSK_WITH_AES_128_CCM_8 for PSK and TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 for RPK and certificates. The security handshake in DTLS is performed over , initiating with a client hello and proceeding through and before establishing a secure session. Once completed, subsequent CoAP messages are encapsulated as application data records within the DTLS layer, allowing seamless protection without altering the CoAP protocol structure. For secure CoAP endpoints, the default port is 5684, and the URI is "coaps://" to distinguish secured resources from unsecured "coap://" ones on port 5683. DTLS's record layer manages the encapsulation, adding approximately 13 bytes of overhead per datagram for headers and tags in typical configurations, while handling fragmentation and reassembly of large messages to fit packet sizes. This complements CoAP's block-wise transfer mechanism ( 7959), which addresses fragmentation separately, enabling efficient handling of oversized in constrained networks. 7252 mandates DTLS support for secure CoAP implementations, while 7925 provides a detailed analyzing transport-level requirements and optimizations for deployments. Although DTLS introduces computational and bandwidth overhead from cryptographic operations and additional headers—essential for in vulnerable environments—alternatives like OSCORE (RFC 8613) offer optimizations by providing object-level directly within CoAP messages, reducing proxy-related exposure and enabling end-to-end protection without relying solely on transport-layer .

Security Modes and Issues

CoAP supports four primary security modes to accommodate varying levels of protection in constrained environments, as defined in its core specification. The NoSec mode provides no protocol-level security and is intended solely for testing or internal network use, relying on lower-layer mechanisms like for protection; it uses the "coap://" URI scheme and port 5683. In contrast, the (PSK) mode employs symmetric via DTLS with shared secrets, suitable for simple deployments but limited by the need for pairwise . For scalability, asymmetric modes include (RPK), which uses public keys without certificates to reduce overhead, and Certificate mode, which integrates certificates for support, both leveraging DTLS for and . Authorization in CoAP lacks built-in primitives and depends on server-side validation using DTLS-provided identities or application-specific checks, such as the If-Match option to verify resource preconditions before allowing modifications. Servers may enforce lists during provisioning, but intermediaries handle only if explicitly configured, emphasizing the protocol's reliance on . Known security issues in CoAP include amplified distributed denial-of-service (DDoS) attacks, particularly through requests that can trigger response floods from multiple servers, exacerbating strain in constrained networks. Replay attacks pose risks if device clocks are unsynchronized, potentially allowing duplicated messages despite DTLS's epoch-based protections, though proper implementation mitigates this within sessions. Additionally, the 2014 vulnerability in implementations affected DTLS-enabled CoAP deployments by enabling memory disclosure during handshakes, underscoring the importance of timely library updates. Privacy risks are prominent in NoSec mode, where unsecured communications expose metadata such as resource URIs and client identities to eavesdroppers, facilitating resource enumeration via discovery requests. Even in secured modes, proxy intermediaries may access plaintext headers unless end-to-end protection is applied, leading to potential leakage in multi-hop scenarios. Best practices recommend mandating the "coaps://" URI scheme and DTLS in production environments to ensure confidentiality and integrity, while using Object Security for Constrained RESTful Environments (OSCORE) for end-to-end security that bypasses proxy visibility. Devices should employ randomized tokens and rate limiting to deter spoofing and flooding, with servers delaying multicast responses via mechanisms like Leisure to prevent implosion. Recent IETF drafts from 2025, including clarifications on CoAP corrections and attacks, address ambiguities in secure option handling and token validation to enhance robustness against evolving threats. CoAP-specific attacks include option number exhaustion, where adversaries overload servers with excessive options to deplete processing resources, and malformed tokens causing denial-of-service by triggering parsing errors, both mitigated through updated processing rules in subsequent specifications.

Implementations and Applications

Protocol Implementations

Several open-source libraries provide robust implementations of the protocol stack, enabling developers to build clients and servers for constrained environments. These libraries adhere to the core specifications in , supporting essential features such as request-response messaging, and often extend to block-wise transfers () and observe notifications (). Eclipse Californium, developed under the , is a mature Java-based implementation targeting both constrained and unconstrained devices, with a focus on scalability for cloud services. It remains actively maintained as of 2025, with the 4.0.0-M6 milestone release in August 2025 providing bug fixes, API cleanups, and enhancements including support for anonymous clients from earlier milestones like 4.0.0-M3 in February. The library covers core CoAP messaging, block-wise operations, and observe functionality, and integrates DTLS for security. It is suitable for desktop and server platforms, with support for IPv6. aiocoap is an asynchronous library designed for network-enabled constrained devices, providing a straightforward for CoAP interactions. Active in 2025 with version 0.4.17 released in November, it implements 7252 compliance, including core messaging, and extends to block-wise transfers and observe options for efficient resource handling in applications. It supports desktop and mobile platforms via Python's asyncio framework, with compatibility. libcoap offers a lightweight C implementation optimized for resource-constrained devices, emphasizing low memory and bandwidth usage. As of 2025, it is actively developed, with version 4.3.5 released in February supporting multithreading, fully compliant with 7252, and includes support for block-wise ( 7959) and observe ( 7641) features, as well as asynchronous responses. It runs on embedded platforms like and , high-end systems, and integrates and for low-power networks. For embedded IoT operating systems, Contiki-NG provides a C-based CoAP integrated into its , tailored for wireless sensor networks. Active in 2025, it ensures RFC 7252 compliance with core messaging capabilities, and supports block-wise and observe extensions, alongside and for constrained-node networks. It targets embedded hardware such as ARM-based motes. RIOT OS features GCoAP, a high-level C interface for CoAP messaging within its real-time kernel for IoT devices. Updated in 2024 with an overhauled stack and further discussions in 2025, it complies with RFC 7252, incorporating block-wise and observe support through its sock API. The implementation runs on embedded platforms including and AVR, with native and integration. node-coap is a JavaScript library for Node.js environments, facilitating CoAP communication in web and server-side applications. Released as of November 2025 (version 1.5.0), it implements 7252 core features, with extensions for block-wise and observe, and supports on desktop and potentially mobile platforms via . CoAPthon serves as a -based testing tool and library, aligned with 7252 for compliance validation. Primarily for Python 2.7 (original implementation), forks such as CoAPthon3 for 3 and ongoing usage persist into 2025 for development and testing of CoAP stacks, covering core messaging and select extensions like observe. It aids in verifying implementations across desktop platforms. While some older Java implementations have been merged into or deprecated, the surveyed libraries remain active and widely tested against the 7252 conformance suite as of 2025.

Proxy and Gateway Implementations

CoAP proxies and gateways serve as intermediaries to enable communication between constrained devices and broader networks, facilitating and overcoming network constraints. Forwarding proxies operate between CoAP endpoints, relaying messages without to support scenarios like in lossy networks. Translating proxies map between CoAP and HTTP, allowing web clients to access CoAP resources, as specified in the guidelines for HTTP-to-CoAP implementations. Reverse proxies, conversely, expose CoAP servers to HTTP clients, enabling legacy web applications to interact with devices. Open-source implementations provide robust support for these proxy roles. The Copper (Cu) extension for web browsers, implemented in Java, acts as a lightweight CoAP client and , enabling direct browser access to CoAP resources via a Java-based Cu for cross-origin handling; however, it is a legacy tool no longer actively maintained since around 2019. Libcoap includes built-in functionality through its coap-proxy module, which handles request forwarding and response matching for CoAP-to-CoAP operations. Californium offers a mode in its Java framework, including the cf-proxy example for translating and forwarding requests in environments. These implementations support key functions such as by rewriting s and handling port mappings, caching responses using the Max-Age option to reduce in constrained networks, and load balancing across multiple servers. For group communications, proxies can aggregate requests into forwards, optimizing in multicast-enabled setups. Standards governing proxy operations are outlined in RFC 7252, which defines core proxy behaviors including URI transformation from coap:// to http:// schemes. RFC 8075 provides detailed guidelines for translating proxies, ensuring consistent mapping of methods, headers, and payloads between HTTP and CoAP. In applications, gateways integrate CoAP with protocols like and for smart home systems, where border routers expose resources via CoAP over IPv6. Cloud-based proxies, such as those interfacing with AWS Core, forward CoAP messages to endpoints for scalable management. Challenges in proxying include balancing end-to-end , preserved via options like OSCORE, against hop-by-hop for intermediary , as hop-by-hop models limit caching and translation. Performance issues arise in constrained environments due to overhead from message buffering and retransmissions, necessitating designs to avoid exacerbating resource limitations. Proxy capabilities are integrated in platforms like through the node-red-contrib-coap package (last updated 2022), which supports proxy-like flows for request handling and integration with other protocols, though it lacks recent maintenance as of 2025.

Projects and Use Cases

CoAP has been integrated into Google's OpenThread implementation, an open-source version of the networking protocol, to facilitate low-power in applications during the 2020s. This integration enables efficient communication for resource-constrained devices in wireless sensor networks, as demonstrated in projects combining OpenThread with CoAP and the RTOS for building scalable sensor deployments. In research contexts, CoAP has been extensively applied within frameworks for wireless sensor networks, enabling connectivity over low-power personal area networks. Studies have analyzed CoAP's in such setups, showing its suitability for sleepy operations in environmental systems using RPL . The EU-funded -A project, which developed an architectural reference model for interoperability, incorporated CoAP as a key for constrained environments, influencing subsequent standards for device communication. Commercially, IoT Suite employed CoAP for bidirectional device management until its discontinuation in mid-2024, allowing resource-limited devices to connect directly to the cloud via a dedicated CoAP adapter. Apple's ecosystem supports CoAP indirectly through proxies and / integrations, where networks leverage CoAP-based messaging for smart home device control. Key use cases for CoAP include , where sensors transmit data on air quality and water levels using CoAP's lightweight RESTful interface over . In industrial automation, mappings of OPC UA over CoAP enable secure, efficient data exchange in IIoT settings, reducing overhead for constrained industrial devices. Automotive applications utilize CoAP for V2X messaging, mapping ITS protocols to CoAP via EdgeX for probabilistic risk-aware communications in vehicular networks. As of 2025, CoAP contributes to the deployment of billions of devices through standards like , an IP-based connectivity specification that runs over networks such as leveraging CoAP for messaging, with projections estimating over 5.5 billion Matter-compliant devices shipping cumulatively by 2030 and global IoT connections reaching 39 billion. Deployment challenges for CoAP include ensuring across diverse devices and protocols, as well as to massive networks without compromising low-power . Notably, CoAP enables browser-based access to resources in the (WoT), supporting end-to-end communications without intermediaries through proxy integrations and RESTful semantics.

Extensions

Resource Discovery

In the Constrained Application Protocol (CoAP), resource discovery enables clients to identify available resources hosted on servers within constrained networks. The core mechanism involves clients sending a GET request to the well-known URI /.well-known/core on a CoAP , which responds with a payload in the CoRE Link Format as defined in RFC 6690. This format uses the media type application/link-format, assigned Content-Format ID 40 in CoAP, to list resources as hyperlinks with associated attributes. For instance, a response might include </sensors/temp>;rt="temperature-c";ct=0, indicating a temperature sensor resource that returns . Path-based discovery builds on the Uri-Path option (option number 11), which allows clients to construct hierarchical queries by specifying path segments in requests, facilitating targeted exploration of resource trees. Additionally, query strings appended to the enable filtering of the link-format response; for example, /.well-known/[core](/page/core)?rt=[light](/page/Light) returns only resources of type "light". These approaches support both and requests, with addressing the "All CoAP Nodes" (FF0X::FD) for broader discovery in local networks. Proxy-based discovery leverages the Location-Options in server responses, such as Location-Path and Location-Query, to redirect clients to alternative resource URIs, often used in gateway scenarios to resolve paths dynamically. For centralized discovery, the (RD) defined in 9176 provides a lookup service where endpoints register their resources via POST requests to an RD URI, including parameters like endpoint name (ep) and lifetime (lt). Clients then perform lookups with GET requests to RD-specific paths, such as /rd-lookup/res?rt=light, supporting pagination and filtering to handle large-scale deployments efficiently. Link attributes in the CoRE format enhance discoverability by providing metadata about resources. Key attributes include:
  • rt (resource type): Specifies semantic categories, e.g., rt="sensor".
  • if (interface description): Indicates supported interaction interfaces, e.g., if="read".
  • sz (size estimate): Offers a hint on maximum response size in bytes, e.g., sz="1024".
  • ct (content type): Denotes acceptable media types, e.g., ct="40" for link-format.
These attributes allow clients to select resources based on capabilities without full retrieval. Security for resource discovery is typically lightweight, with many implementations leaving /.well-known/core accessible over unsecured CoAP to minimize overhead in constrained environments. However, sensitive deployments integrate (DTLS) to encrypt requests and responses, preventing unauthorized resource enumeration. Resource Directories enforce additional protections, such as mutual DTLS authentication for registrations and OSCORE for end-to-end in lookups, to mitigate denial-of-service risks. Common use cases include dynamic in ad-hoc networks, where devices join and leave frequently, relying on or for peer detection. Integration with DNS Service (DNS-SD) extends CoAP to hybrid environments, mapping CoRE links to DNS records for cross-protocol in or building systems. Limitations of CoAP resource include the absence of a standardized mechanism for cross-domain queries, requiring custom proxies or directories for internet-scale operations. It also depends on for group-based , which can suffer from poor reliability in lossy networks and inefficiency with sleeping nodes, often necessitating centralized RDs as a workaround.

Observe and Notifications

The Observe option in CoAP enables clients to register interest in resource state changes, allowing servers to push notifications without repeated polling, as defined in RFC 7641 published in 2015. Clients initiate this by including the Observe option (number ) in a GET request, which the server acknowledges and uses to maintain an observation relationship identified by a unique token. Upon detecting a relevant change—such as a resource representation update—the server sends a notification containing the current state, typically including a fresh for validation. This mechanism supports efficient, real-time communication in constrained environments by minimizing client-initiated requests. Notifications can be piggybacked on the initial confirmatory (CON) response or sent as separate CON messages, ensuring they leverage CoAP's reliability features where confirmable messages are retransmitted if no acknowledgment (ACK) is received, though servers do not queue notifications for offline clients. Each notification inherits the security context of the original request, such as a DTLS session, but implementations must guard against denial-of-service attacks from clients registering excessive observations, potentially overwhelming server resources. For freshness, notifications may include a Max-Age option to indicate response lifetime, helping clients assess staleness without additional queries. To cancel an observation, a client sends a (RST) message in response to a notification or issues a new GET request without the Observe option, prompting the server to remove the corresponding from its list; servers may also proactively evict stale entries based on timeouts or constraints. This option integrates with block-wise transfers (via the Block2 option) to handle notifications for large payloads, allowing segmented delivery while maintaining the link. In practice, Observe reduces overhead in scenarios like monitoring readings for environmental data or detecting button presses in devices, where frequent polling would drain limited life. Overall, these features make Observe a cornerstone for event-driven interactions in CoAP, building on the protocol's confirmable messaging for reliable delivery without introducing persistent connections. A draft specification from October 2025 defines mechanisms for sending observe notifications as responses, updating RFC 7252 and RFC 7641 to better support group observations in scenarios.

References

  1. [1]
    RFC 7252 - The Constrained Application Protocol (CoAP)
    The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with constrained nodes and constrained (eg, low-power, lossy) ...
  2. [2]
    RFC 7390 - Group Communication for the Constrained Application ...
    RFC 7390 Group Communication for CoAP October 2014 ; 3.6. Commissioning the Network Based on Resource Directory ...<|control11|><|separator|>
  3. [3]
    RFC 7641 - Observing Resources in the Constrained Application ...
    This document specifies a simple protocol extension for CoAP that enables CoAP clients to "observe" resources, ie, to retrieve a representation of a resource.<|control11|><|separator|>
  4. [4]
    RFC 8323 - CoAP (Constrained Application Protocol) over TCP, TLS ...
    This document outlines the changes required to use CoAP over TCP, TLS, and WebSockets transports. It also formally updates RFC 7641 for use with these ...
  5. [5]
    CORE WG - Constrained RESTful Environments Wiki
    The Constrained RESTful Environments (CoRE) WG was created out of the 6LowApp activity (see concluded 6lowapp WG for historical information). This wiki is used ...Missing: formed | Show results with:formed
  6. [6]
  7. [7]
  8. [8]
    History for draft-ietf-core-coap -18
    The recommendation in Section 4.6 about the path MTU is generally valid only for IPv6. For IPv4, 567 bytes is the safe area to work without fragmentation, ...
  9. [9]
    RFC 7959 - Block-Wise Transfers in the Constrained Application ...
    This specification extends basic CoAP with a pair of "Block" options for transferring multiple blocks of information from a resource representation in multiple ...
  10. [10]
    RFC 8974 - Extended Tokens and Stateless Clients in the ...
    Extended Tokens and Stateless Clients in the Constrained Application Protocol (CoAP). Abstract. This document provides considerations for alleviating ...
  11. [11]
    RFC 9175 - Constrained Application Protocol (CoAP)
    This document specifies enhancements to the Constrained Application Protocol (CoAP) that mitigate security issues in particular use cases.
  12. [12]
    draft-ietf-core-corr-clar-02 - Constrained Application Protocol (CoAP)
    Jun 20, 2025 · The present document provides corrections, additions, and clarifications to the RFCs cited; this document thus updates these RFCs.
  13. [13]
    RFC 7228 - Terminology for Constrained-Node Networks
    This document provides a number of basic terms that have been useful in the standardization work for constrained-node networks.
  14. [14]
    Messaging Protocols for IoT Systems—A Pragmatic Comparison
    Oct 18, 2021 · RFC 7252 defines the core CoAP specification, and several other RFCs define CoAP extensions. ... Naik [36], a short comparison of MQTT, CoAP, AMQP ...
  15. [15]
  16. [16]
  17. [17]
  18. [18]
  19. [19]
  20. [20]
  21. [21]
  22. [22]
  23. [23]
  24. [24]
  25. [25]
  26. [26]
  27. [27]
  28. [28]
  29. [29]
  30. [30]
  31. [31]
  32. [32]
  33. [33]
  34. [34]
  35. [35]
  36. [36]
  37. [37]
  38. [38]
  39. [39]
  40. [40]
  41. [41]
  42. [42]
  43. [43]
  44. [44]
  45. [45]
  46. [46]
  47. [47]
  48. [48]
  49. [49]
  50. [50]
  51. [51]
  52. [52]
  53. [53]
  54. [54]
  55. [55]
  56. [56]
  57. [57]
    RFC 7925 - Transport Layer Security (TLS) / Datagram Transport ...
    This document defines a Transport Layer Security (TLS) and Datagram Transport Layer Security (DTLS) 1.2 profile that offers communications security for this ...
  58. [58]
    RFC 8613 - Object Security for Constrained RESTful Environments ...
    This document defines Object Security for Constrained RESTful Environments (OSCORE), a method for application-layer protection of the Constrained Application ...
  59. [59]
    OpenSSL 'Heartbleed' vulnerability (CVE-2014-0160) | CISA
    Oct 5, 2016 · This flaw allows an attacker to retrieve private memory of an application that uses the vulnerable OpenSSL library in chunks of 64k at a time.Missing: CoAP | Show results with:CoAP
  60. [60]
    Attacks on the Constrained Application Protocol (CoAP)
    Jun 24, 2025 · This document identifies a set of known CoAP attacks and shows that simply using CoAP with a security protocol is not always enough for secure operation.
  61. [61]
    Object Security for Constrained RESTful Environments (OSCORE)
    This document defines Object Security for Constrained RESTful Environments (OSCORE), a method for application-layer protection of the Constrained Application ...
  62. [62]
    Eclipse Californium (Cf) CoAP Framework | projects.eclipse.org
    Eclipse Californium (Cf) is an open source implementation of the Constrained Application Protocol (CoAP). It is written in Java and targets unconstrained ...
  63. [63]
    eclipse-californium/californium: CoAP/DTLS Java Implementation
    Eclipse Californium is a Java implementation of RFC7252 - Constrained Application Protocol for IoT Cloud services. Thus, the focus is on scalability and ...Missing: active | Show results with:active
  64. [64]
    Eclipse Californium (Cf) CoAP Framework 4.0.0-M3
    Feb 20, 2025 · The milestone release 4.0.0-M3 comes with further cleanups and better support for systems using anonymous clients.Missing: implementation | Show results with:implementation
  65. [65]
    aiocoap – The Python CoAP library — aiocoap 0.4.17.post0 ...
    The aiocoap package is an implementation of CoAP, the Constrained Application Protocol. It facilitates writing applications that talk to network enabled ...
  66. [66]
    libCoAP
    libcoap implements a lightweight application-protocol for devices that are constrained their resources such as computing power, RF range, memory, bandwith, or ...
  67. [67]
    obgm/libcoap: A CoAP (RFC 7252) implementation in C - GitHub
    libcoap is a C implementation of a lightweight application-protocol for devices that are constrained their resources such as computing power, RF range, memory, ...
  68. [68]
    CoAP — Constrained Application Protocol | Implementations
    A small-but-capable C-based CoAP stack suitable for embedded environments. It supports observing, asynchronous responses to requests, and more.
  69. [69]
    CoAP — Contiki-NG documentation
    CoAP is an application-layer protocol similar to HTTP but is transported over UDP instead of TCP. CoAP is defined in RFC 7252.
  70. [70]
    CoAP - Contiki-NG Documentation
    This tutorial will show you how to set up a Contiki-NG node that runs a CoAP server (see doc:coap). We will need a CoAP client on the Unix side.
  71. [71]
    GCoAP - RIOT Documentation
    Detailed Description. High-level interface to CoAP messaging. gcoap provides a high-level interface for writing CoAP messages via RIOT's sock networking API.Missing: integration | Show results with:integration
  72. [72]
    Overhauled CoAP Stack and API #20792 - RIOT-OS/RIOT - GitHub
    Jul 19, 2024 · The new CoAP library should provide a unified, versatile CoAP API for RIOT that is both easily extensible and beginner-friendly. Until a final, ...
  73. [73]
    Integrate libCoAP into RIOT
    Apr 1, 2025 · unicoap aims to solve many issues with nanoCoAP and GCoAP: a modular transport abstraction, more versatile functions for CoAP options, easier ...Weekly coordination meeting - Community - RIOT OSCoAP-CoAPs in RIOT - archive - RIOT OSMore results from forum.riot-os.org
  74. [74]
  75. [75]
    CoAPthon is a python library to the CoAP protocol aligned ... - GitHub
    CoAPthon is a python 2.7 library to the CoAP protocol compliant with the RFC. Branch is available for the Twisted framework.
  76. [76]
    Building wireless sensor networks with OpenThread, CoAP, and ...
    May 9, 2024 · It explains the code used for a variety of basic Thread applications based on Constrained Application Protocol (CoAP). This includes advanced ...
  77. [77]
    [PDF] CoAP infrastructure for IoT - CORE
    The IPv6 over Low-Power Wireless Area Networks (6LoWPAN) standards [67, 57] now enable IPv6 on very constrained networks, which makes integration of sensors and.
  78. [78]
    [PDF] Understanding Energy Consumption in Real-World E-IoT Systems ...
    In this experiment, our objective is to analyse the energy consumption of a sleepy E-IoT system using CoAP, RPL, and 6LoWPAN based on RIOT-OS. This aims to ...<|separator|>
  79. [79]
    [PDF] Internet of Things - Architecture IoT-A Deliverable D1.3
    a.k.a.. Also Known as. API. Application-programming interface. ARM. Architectural Reference Model. AuthN. Authentication. AuthS. Authorisation.
  80. [80]
    An overview of IoT architectures, technologies, and existing open ...
    The Constrained Application Protocol (CoAP) [43] is a specialized protocol intended for use in constrained environments (e.g., low-power devices or lossy ...
  81. [81]
    2022-07-08 - CoAP Adapter now available with free plan
    Jul 8, 2022 · Bosch IoT Device Management supports CoAP based bi-directional communication: device-to-cloud and cloud-to-device. The devices may be connected ...
  82. [82]
  83. [83]
    Understanding CoAP: Key Features, Uses, and Its Importance in IoT ...
    Environmental Monitoring: CoAP is used in environmental monitoring systems to collect data from distributed sensors that track air quality, water levels, and ...Missing: OPC V2X
  84. [84]
    A CoAP-based OPC UA Transmission Scheme for Resource ...
    Jan 29, 2021 · The CoAP protocol is specially designed for resource-constrained devices, and it has better suitability in the IoT environment than HTTP.
  85. [85]
    V2X Messaging with CoAP and EdgeX for Probabilistic Risk-Aware ...
    Sep 10, 2025 · This article presents a standards-based architecture for V2X communication using CoAP and EdgeX Foundry. By mapping ETSI ITS messages to ...
  86. [86]
    Matter: The Future of Smart Homes | IoT For All
    With a projection of more than 5.5 billion Matter devices shipping between now and 2030, Matter's importance will be undeniable.What's The Matter? · Challenge Of Broad Adoption... · Potential Concerns For...
  87. [87]
    Number of connected IoT devices growing 14% to 21.1 billion globally
    Oct 28, 2025 · Number of connected IoT devices growing 14% to 21.1 billion globally in 2025. Estimated to reach 39 billion in 2030, a CAGR of 13.2% [...]Missing: Matter | Show results with:Matter
  88. [88]
    Build With Matter | Smart Home Device Solution - CSA-IOT
    Matter is a unifying, IP-based connectivity protocol built on proven technologies, helping you connect to and build reliable, secure IoT ecosystems.Missing: CoAP | Show results with:CoAP
  89. [89]
    Everything You Need to Know About Web of Things (WoT)
    Mar 28, 2024 · The problems of adopting WoT include managing a range of devices and protocols, addressing scalability issues as the number of connected devices ...
  90. [90]
    [PDF] Toward Interoperability in a Web of Things
    Sep 8, 2013 · In this position paper we explore the challenges and issues around interoperability in the web of things. ... These larger scale 'WoT hubs'.
  91. [91]
    Enabling end-to-end CoAP-based communications for the Web of ...
    This paper proposes a flexible and scalable embedded CoAP solution for Web applications that offers full integration with browsers and Web-clients, without the ...
  92. [92]
  93. [93]
  94. [94]
  95. [95]
  96. [96]
  97. [97]
  98. [98]
  99. [99]
  100. [100]
  101. [101]
  102. [102]
  103. [103]
  104. [104]
  105. [105]
  106. [106]