CoAP (Constrained Application Protocol) and the Deep Dive Approach

nashik Blogger

CoAP (Constrained Application Protocol) and the Deep Dive Approach

CoAP (Constrained Application Protocol) and the Deep Dive Approach

CoAP stands for Constrained Application Protocol and it is a special type of internet Application protocol for the IoT Devices having constrained like low power consumption and lower bandwidth and it is standardized and defined in RFC 7252.

If we go with the definition provided by  CoAP Technology then its easy to understand.

so the definition is

The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with constrained nodes and constrained networks in the Internet of Things. The protocol is designed for machine-to-machine (M2M) applications such as smart energy and building automation.”

If we go through the definition then we can understand the CoAP. It is a specialized protocol developed for the low power and bandwidth and suitable for the “Internet of Things” devices.

CoAP is also working with SMS where internet connectivity is not possible or broken to save the power. If you want to know details you can check this link CoAP over SMS

Deep Dive Approach :

In our previous blog, we discussed on MQTT(Message Queuing Telemetry Transport) and also deep dive from definition to the practical approach but CoAP is also one of the contestants which have the ability to compete with MQTT but we need to understand first where this protocol best suited.

If we go with the MQTT then we know its a Publish and Subscribe type of protocol and you can compare this protocol to the Twitter, where you subscribe for the topic in which you are interested and get the info as they publish. It also comes with configuration for the guaranteed delivery.

CoAP is somewhat different and it looks like a client-server type of architecture, where you request for the desired resources and sometimes submits some data for the further processing. One more thing which makes this protocol different than the MQTT is, it is more compatible with the HTTP and we know HTTP is the power of the internet. We can also configure this protocol to deal with the proxy server and also configure it to work with the constraints.

On which layer :

CoAP is a service Layer protocol and we know the service layer is a conceptual layer and its work is to provide middleware interface that serves third-party VAS. This layer is responsible to provide access through open and secure API by application layer server which may be owned by the third-party data provider. The biggest advantage of this layer is, it provides the interface to the core network with minimum resources or lower resource layer.

Why CoAP :

One more advantage of the CoAP is, it is designed in such a way that we can use it with HTTP for our convenience. It also supports multicast. It means data transmission is addressed to a group of destination nodes at the same time. It can also send the data one node at a time or many to many also possible. And as an Internet of things enthusiast, you know the advantages of simple coding and multicasting.

One more thing which I like about the CoAP is its ability to work with UDP because sometimes we just required to send the data as quickly as possible without any acknowledgement and here CoAP wins the heart.

CoAP is also very much closely resemble the (HyperText Transfer Protocol) HTTP where it is similar in the form of REST model, it uses GET, POST, DELETE and PUT method for data transfer. It is a network-oriented protocol. We know that HTTP is based on TCP protocol using P to P communication model and its not made for the services like push notification for the IoT devices and also it is too much complex for such devices, that's why HTTP based on UDP and instead of using complex bottleneck control mechanism used in TCP and uses REST model.

But UDP is not reliable! But  CoAP defines a retransmission mechanism and provide resource discovery mechanism with resource description.

Here in CoAP Message Layer Model is as Follows :

CoAP supports four types of Message and these are….

  1. CON (Confirmable)

  2. NON (Non-Confirmable)

  3. ACK (Acknowledgement)

  4. RST (Reset)

The first mode of communication called Reliable message transport where CoAP continues to retransmit the data until it gets ACK from the receiver e.g 0x8c67 until the default timeout ends as per the CON message was sent. If the receiver fails to get the message then it response by RST instead ACK.

The second mode of communication called Unreliable message transport where transmitter sends the data with NON and do not hope for the ACK signal but it also has its message ID for supervising in case of retransmission. Here if the receiver fails to get the message then it replies with RST and retransmission begins.

For the implementation plz refer this Git link