Core Design Principles of CoAP
03 Uses UDP Instead of a complex transport stack, CoAP uses UDP on IP
04 A 4 byte fixed header and a compact encoding of options enables small
Fixed Header messages that cause no or little fragmentation on the link layer
4 Byte Fixed Header
0 2 4 8 16 31
Version Type Token Length Code Message ID
Token (if any, TKL bytes) …….
Options (if any) ……
Payload (if any) ………
CoAP Message Format
Architecture of CoAP
Used to deal with UDP and the Application
Message asynchronous nature of the
Layer interactions
Request/Response Layer
CoAP
CoAP
Message Layer
In charge of mapping requests to
Request/
responses and their interactions
Response using Method and Response Codes
Layer Transport - UDP
CoAP Methods
Methods indicate the type of interaction a client wants to have with a resource on the server
GET POST PUT DELETE OBSERVE
Used to retrieve the Used to submit data to Used to update or Used to request the Used to monitor the state
current state or value the server for create a resource on removal of a resource of a resource over time
of a resource from the processing. the server with the from the server. and enables clients to
server. provided data. observe resources with a
defined query, i.e., to
retrieve a representation
It is a safe method that It can be used to create a It replaces the current It signifies the intent of a resource
doesn't cause any new resource or trigger a state of the resource to remove the
modification on the specific action on the with the new data. specified resource This method is not
server. server. present in HTTP but
only in CoAP
Types of CoAP
messages
CON NON ACK RST
Confirmable Message Non- Confirmable Message Acknowledgement Reset
Used for reliable communication, Used for faster communication Sent in response to CON messages Sent to cancel a pending CON
ensuring that the recipient sends without requiring acknowledgment to acknowledge their receipt. message that hasn't yet been
an acknowledgment. acknowledged.
CoAP Request Response Example
CoAP Server 1
(Thermostat in Living Room)
CoAP client
Requests the resource CoAP Server 2
(Thermostat in Bedroom)
Name of the
protocol
coap://myhome.in:5683/nest_livingroom/temp
CoAP Request Response Example
CoAP Server 1
(Thermostat in Living Room)
CoAP client
Requests the resource CoAP Server 2
(Thermostat in Bedroom)
Domain
coap://myhome.in:5683/nest_livingroom/temp