Thursday, April 16, 2015

CoAP

CoAP is a constrained Application protocol from CoRE (Constrained Resource Environment) IETF Group

Architecuture of CoAP 
Like HTTP, CoAP is a document transfer protocol. Unlike HTTP CoAP is designed for the needs of constrained devices. 
CoAP packets are much smaller than HTTP TCP flows. Bitfields and mappings from strings to integers are used extensively to save space. 
Packets are simple to generate and can be parsed without much RAM in constrained devices. 
CoAP runs over UDP, not TCP. Clients and servers communicate through connectionless datagrams. Retries and Recordings are implemented 
in the application stack. Removing the need of TCP may allow full IP networking in small micro controllers. CoAP alows UDP broadcast and multicast
to be used for addressing. 

CoAP follows a client server model, clients request to servers, servers send back responses. Clients may GET, PUT, POST and DELETE resources. 
CoAP is designed to interoperate with HTTP and the RESTful web at large through simple proxies. 
Because CoAP is datagram based, it may be used on top of SMS and other packet based communication protocols. 

Application Level QoS 
Requests and response message may be marked as confirmable or non confirmable. Confirmable messages must be acknowledged by the receiver with an ack packet. 

non confirmable messages are fire and forget 

Content Negotiation 
Like HTTP, CoAP supports Content negotiation. Client uses Accept option to express a preferred presentation of a resource and servers reply with a Content-Type option to tell clients what they are getting. As with HTTP, this allows client and server to evolve independently adding new representations without affecting each other. 

CoAP requests may use query strings in form ?a=b&c=d. These can be used to provide search, paging and other features to clients. 

Security. Because CoAP is built on top of UDP and not TCP, TLS/SSL is not possible for providing security. DTLS, Datagram Transport Layer Security provides the same assurance as TLS. Typically CoAP supported devices will support RSA and AES or ECC and AES. 

Observe: CoAP extends the HTTP request model with the ability to observe a resource. When the observe flag is set on a CoAP GET request, server might continue to reply after the initial document has been transferred. This allows servers to stream states as  they occur. 

Resource Discovery 
CoAP defines a standard mechanism for a resource discovery. Servers provides a list of their resource at a well known core. 

NAT issues: In CoAP, a sensor mode is typically a server, not a client (though it may be both). The sensor (or actuator) provides resources which can be accessed by clients to read or alter the state of the sensor. 

as CoAP sensors are servers, they must be able to to receive inbound packets. To function properly behind NAT, a device may first send a request out to the server, as done in LWM2M, allowing the router to associate the two. Although CoAP does not require IPv6, it is easiest used in IP environment where device are directly routable. 

References:

No comments:

Post a Comment