← Lessons

quiz vs the machine

Gold1390

Networking

CoAP For Constrained Devices

How a web style protocol runs on UDP for tiny networks.

5 min read · core · beat Gold to climb

A Web Model For Small Things

CoAP brings the request response style of the web to very constrained devices. It mirrors HTTP methods like get and put but runs over UDP with a tiny binary header so it fits low power radios.

Reliability On UDP

Because UDP does not guarantee delivery, CoAP adds a light layer of its own.

  • A confirmable message asks for an acknowledgement and is retried if none arrives.
  • A non confirmable message is sent once with no acknowledgement.
  • A message identifier lets the sender match acknowledgements and drop duplicates.

This gives optional reliability without the weight of a full transport handshake.

Resources And Observe

Devices expose resources addressed by paths, just like web endpoints. A client can read a sensor with a get request.

  • An observe option lets a client subscribe to a resource and receive updates when its value changes.
  • This avoids constant polling, which saves battery.

Bridging To The Web

CoAP maps cleanly onto HTTP, so a proxy can translate between a constrained network and the wider internet. A phone app can then read a CoAP sensor through a normal web request.

Key idea

CoAP brings web style methods and resources to constrained devices over UDP, adding light confirmable messaging for reliability and an observe option to replace polling.

Check yourself

Answer to earn rating on the learn ladder.

1. Why does CoAP add confirmable messages?

2. What does the CoAP observe option do?

3. Why can CoAP bridge to the web easily?