CoAP architecture details

CoAP is based on the concept of mimicking and replacing heavy HTTP abilities and usage with a lightweight equivalent for the IoT. It is not an HTTP replacement as it does lack features; HTTP requires more powerful and service-orientated systems. CoAP features can be summarized as follows:

  • HTTP-like
  • Connection-less protocols
  • Security through DTLS rather than TLS in a normal HTTP transmission
  • Asynchronous message exchanges
  • Lightweight design and resource requirements and low header overhead
  • Support for URI and content-types
  • Built upon UDP versus TCP/UDP for a normal HTTP session
  • A stateless HTTP mapping allowing for proxies top bridge to HTTP sessions

CoAP has two basic layers:

  • Request/Response layer: Responsible for sending and receiving RESTful-based queries. REST queries are piggybacked on CON or NON messages. A REST response is piggybacked on the corresponding ACK message.
  • Transactional layer: Handles single message exchanges between endpoints using one of the four basic message types. The transaction layer also supports multicasting and congestion control:
HTTP stack compared to CoAP

CoAP shares context, syntax, and usage similarly to HTTP. Addressing in CoAP is also styled like HTTP. An address extends to the URI structure. As in HTTP URIs, the user must know the address beforehand to gain access to a resource. At the top-most level, CoAP uses requests such as GET, PUT, POST, and DELETE, as in HTTP. Similarly, response codes mimic HTTP, such as: 

  • 2.01: Created
  • 2.02: Deleted
  • 2.04: Changed
  • 2.05: Content
  • 4.04: Not found (resource)
  • 4.05: Method not allowed

The form of a typical URI in CoAP would be:

coap://host[:port]/[path][?query]

A CoAP system has seven main actors:

  • Endpoints: These are the sources and destinations of a CoAP message. The specific definition of an endpoint depends on the transport being used. 
  • Proxies: A CoAP endpoint that is tasked by CoAP clients to perform requests on its behalf. Reducing network load, access sleeping nodes, and providing a layer of security are some of the roles of a proxy. Proxies can be explicitly selected by a client (forward-proxying) or can be used as in-situ servers (reverse-proxying). Alternatively, a proxy can map from one CoAP request to another CoAP request or even translate to a different protocol (cross-proxying). A common situation is an edge router proxying from a CoAP network to HTTP services for cloud-based internet connections.
  • Client: The originator of a request. The destination endpoint of a response.
  • Server: The destination endpoint of a request. The originator of a response.
  • Intermediary: A client acting as both a server and client towards an origin server. A proxy is an intermediary.  
  • Origin servers: The server on which a given resource resides.
  • Observers: An observer client can register itself using a modified GET message. The observer is then connected to a resource and if the state of that resource changes, the server will send a notification back to the observer. 
Observers are unique in CoAP and allow a device to watch for changes to a particular resource. In essence, this is similar to the MQTT subscribe model where a node will subscribe to an event. 

Below is an example of CoAP architecture. Being a lightweight HTTP system allows for CoAP clients to communicate to one another or services in the cloud supporting CoAP. Alternatively, a proxy can be used to bridge to an HTTP service in the cloud. CoAP endpoints can establish relationships with each other, even at the sensor level. Observers allow for subscription-like attributes to resource that change in a similar manner to MQTT. The graphic also illustrates origin servers holding the resource being shared.

The two proxies allow for CoAP to perform HTTP translation or allow forwarding requests on behalf of a client. 

CoAP Architecture. 
CoAP makes use of port 5683. This port must be supported by a server that offers resources since the port is used for resource discovery. Port 5684 is used when DTLS is enabled.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.141.6