Wireless Protocols

CoAP

/koh-ap/
The Constrained Application Protocol (CoAP, RFC 7252) is a lightweight RESTful protocol for resource-constrained IoT devices. Uses UDP with a compact 4-byte binary header (vs HTTP's 200+ bytes), supports GET/PUT/POST/DELETE, asynchronous Observe (RFC 7641) for event-driven updates, and block-wise transfer (RFC 7959) for LPWAN payloads. Ideal for LoRaWAN, NB-IoT, and Sigfox where each byte has significant energy cost. Messages are 10 to 20 bytes vs 500+ for HTTP.
Category: Wireless Protocols
Transport: UDP (4-byte header)
Message size: 10 to 20 bytes

Understanding CoAP

The Internet of Things connects billions of devices, many of which are severely resource-constrained: microcontrollers with 10 to 256 KB RAM, running on coin-cell batteries that must last 5 to 10 years, communicating over radio links with 0.3 to 250 kbps bandwidth and 1 to 10 second latency. Standard web protocols (HTTP over TCP/TLS) were designed for powerful computers on reliable, high-bandwidth networks and are fundamentally unsuited for these environments. CoAP was purpose-designed by the IETF CoRE working group to bring RESTful web architecture to constrained devices while respecting their limitations.

CoAP's design philosophy is "web architecture for the constrained." It maps directly to HTTP semantics (GET reads a resource, PUT updates, POST creates, DELETE removes) but replaces HTTP's verbose text headers with a compact binary format. The 4-byte fixed header contains version, message type, token length, request/response code, and message ID. Variable-length options (analogous to HTTP headers) use delta-encoding for compactness. Payloads follow a single-byte 0xFF marker. This minimalism is critical for LPWAN: on LoRaWAN at SF12 (250 bps), transmitting 500 bytes of HTTP takes 16 seconds and drains 32 mJ from the battery, while 20 bytes of CoAP takes 0.64 seconds and 1.3 mJ, a 25x energy reduction for the same application function.

CoAP Protocol Metrics

CoAP Message Size:
Size = 4 (header) + TKL + Options + 1 (marker) + Payload

Energy per Message (LPWAN):
E = Ptx × Tair = Ptx × Size / Bitrate

Observe Savings:
Nsaved = (Tmonitor/Tpoll) - (Nchanges)   (messages saved)

Where TKL = token length (0 to 8 bytes), Options = 0 to ~100 bytes typically. On LoRaWAN SF10 (980 bps): 20-byte CoAP takes 163 ms airtime. Ptx = 50 mW typical, E = 8 mJ per message. At 10 messages/day: 29 mJ/day = ~10 years on 1000 mAh coin cell.

IoT Protocol Comparison

ProtocolTransportMin MessagePatternBest For
CoAPUDP10 to 20 bytesRESTful req/respLPWAN, constrained sensors
MQTTTCP20 to 50 bytesPub/sub (broker)Wi-Fi/cellular, many subs
HTTP/2TCP + TLS200 to 500 bytesRESTful req/respCloud APIs, gateways
LwM2MCoAP/UDP15 to 30 bytesObject/resourceDevice management, NB-IoT
MQTT-SNUDP7 to 20 bytesPub/subZigBee, Bluetooth Mesh
Common Questions

Frequently Asked Questions

Why is CoAP better for LPWAN than HTTP or MQTT?

HTTP text headers exceed 200 bytes; TCP handshake needs 3 round trips at 1 to 10 s latency. MQTT requires TCP (poor on lossy radio links). CoAP uses UDP (no connection overhead), 4-byte header, 10 to 20 byte messages. Observe replaces polling (5 to 50x fewer transmissions). Block-wise transfer fits within LoRaWAN 51 to 242 byte payload limits.

How does CoAP reliability work over UDP?

Confirmable (CON) messages require ACK within 2 to 3 s timeout, with exponential backoff retransmission (up to 4 retries). Non-confirmable (NON) is fire-and-forget for periodic readings. 16-bit message IDs prevent duplicate processing. DTLS adds ~25 bytes encryption overhead vs TLS+TCP's much larger footprint.

How does CoAP compare to MQTT?

CoAP: RESTful, UDP, 10 to 20 bytes, supports multicast and resource discovery (/.well-known/core), adopted by 3GPP for NB-IoT NIDD. MQTT: pub/sub, TCP, 20 to 50 bytes, needs central broker, better for many subscribers. CoAP for constrained devices; MQTT for event distribution on reliable networks.

IoT RF Components

Request a Quote

Need LPWAN modules, IoT antennas, or RF front-ends for your constrained sensor deployment? Contact our team.

Get in Touch