What is CoAP protocol IoT | CoAP Architecture, message format

This page covers CoAP protocol architecture used in IoT (Internet of Things). It mentions CoAP architecture,CoAP message format and CoAP message exchanges between CoAP client and CoAP server. CoAP is the short form of Constrained Application Protocol.

The CoAP protocol is specified in RFC 7252. It is a web transfer protocol which is used in constrained nodes or networks such as WSN, IoT, M2M etc. Hence the name Constrained Application Protocol. The protocol is targetted for Internet of Things (IoT) devices having less memory and less power specifications.

As it is designed for web applications it is also known as "The Web of Things Protocol". It can be used to transport data from few bytes to 1000s of bytes over web applications. It exists between UDP layer and Application layer.

Following are the features of CoAP Protocol:
• It is very efficient RESTful protocol.
• Easy to proxy to/from HTTP.
• It is open IETF standard
• It is Embedded web transfer protocol (coap://)
• It uses asynchronous transaction model.
• UDP is binding with reliability and multicast support.
• GET, POST, PUT and DELETE methods are used.
• URI is supported.
• It uses small and simple 4 byte header.
• Supports binding to UDP, SMS and TCP.
• DTLS based PSK, RPK and certificate security is used.
• uses subset of MIME types and HTTP response codes.
• Uses built in discovery mechanism.

CoAP Architecture

CoAP Architecture

The figure-1 depicts CoAP Architecture. As shown it extends normal HTTP clients to clients having resource constraints. These clients are known as CoAP clients. Proxy device bridges gap between constained environment and typical internet environment based on HTTP protocols. Same server takes care of both HTTP and CoAP protocol messages.

CoAP Message Format | CoAP Header

CoAP message format

The figure-2 depicts CoAP message format consists of 4 bytes header followed by token value (from 0 to 8 bytes). The table below mentions header which consists of 4 bytes i.e. 32 bits.

CoAP message header Description
Ver It is 2 bit unsigned integer. It mentions CoAP version number. Set to one.
T It is 2 bit unsigned integer. Indicates message type viz. confirmable (0), non-confirmable (1), ACK (2) or RESET(3).
TKL It is 4 bit unsigned integer, Indicates length of token (0 to 8 bytes).
Code It is 8 bit unsigned integer, It is split into two parts viz. 3 bit class (MSBs) and 5 bit detail (LSBs).
Message ID 16 bit unsigned integer. Used for matching responses. Used to detect message duplication.

CoAP Protocol Message Exchanges

CoAP message exchange

There are two modes in which CoAP protocol messages get exchanged between CoAP client and CoAP server viz. without separate response and with separate response.

With separate response, server notifies client about receipt of the request message. This will increase processing time but help in avoiding unnecessary retransmissions.

CoAP IoT is unreliable protocol due to use of UDP. Hence CoAP messages reach unordered or will get lost when they arrive at destination.

To make CoAP as reliable protocol, stop and wait with exponential backoff retransmission feature is incorporated in it. Duplicate detection is also introduced.

Vendors of FPGA, DSP, Microcontroller Kits

Refer following pages for FPGA, DSP and microcontroller kits.
DSP and FPGA Evaluation Boards
Microcontroller Kits
DSP Chip Vendors

Link to CoAP IoT Technologies

CoAP vs HTTP    ➤CoAP vs MQTT    ➤Pros and Cons of CoAP    ➤WLAN    ➤THREAD    ➤EnOcean    ➤LoRa    ➤SIGFOX    ➤WHDI    ➤6LoWPAN   ➤Zigbee RF4CE   ➤Z-Wave   ➤NFC   ➤Lonworks   ➤CEBus   ➤UPB  

Tutorials on indoor(WLAN, Zigbee) and outdoor(GSM, CDMA, LTE, WIMAX) wireless technologies

RF and Wireless Terminologies