Edge Computing
25 Aug 2020

CoAP and its Role in Edge Computing and IoT

CoAP, the Constrained Application Protocol, allows developers to include simple, constrained devices in modern-day edge computing platforms. With the evolution of networking technologies and the wide-scale rollout of 5G in many parts of the world, the proliferation of solutions that leverage the Internet of Things (IoT) will increase exponentially. However, even with the expected improvement in average network speeds, constrained environments with low bandwidth and availability will exist for the foreseeable future.

IoT Architecture

Before we can understand the need for CoAP in current networks, we need to define the three primary components of a typical IoT solution. A standard IoT implementation starts with an edge network consisting of devices that gather information and control larger interconnected IoT systems. Moving on from the edge, we have the fog network that contains the gateways and high-end servers responsible for data acquisition, processing, and some base analytics. The third component is the cloud network, where other high-performing computing devices consolidate data from various sources for machine learning, central automation, and real-time reporting.

The Need for CoAP in a 5G World

Enhanced speed, resiliency, and flexibility have been at the core of the evolution of networking technologies. However, the rollout of better network connectivity does not necessarily equate to improved transfer rates across a contemporary IoT architecture. In some instances, legacy solutions still play a part as the rate of change is not equal across all industries. In addition to these real-world constraints, some locations across the world offer better network connectivity than others. Although many service providers have commenced their 5G rollouts, researches only expect it to cover approximately 8.9% of mobile devices in 2023. Taking this reality into consideration, it is clear that the need for the CoAP protocol will remain for the foreseeable future.

CoAP Features

CoAP has several features that provide solution architects with the ability to deploy IoT platforms in a constrained location. However, even on well-resourced networks, CoAP still has a vital role to play in improving efficiencies. 

Low Network Overhead

One of the primary benefits of this protocol is that it has a low overhead and parsing data is simple. CoAP achieves this objective as it leverages a web protocol that is similar to HTTP. Its fundamental design enables the reliability needed in environments with low bandwidth and high congestion. Compared to other TCP-based IoT protocols such as Message Queuing Telemetry Transport (MQTT), CoAP continues to function in congested networks with limited connectivity where others fail. 

Leverages HTTP Methods

CoAP achieves its stated reliability by leveraging UDP in a client-server architecture. The protocol’s mechanism allows a client to make a request, and its server responds as one would expect in an HTTP platform. As it leverages the same HTTP RESTful methods in its construction, it allows you to take advantage of other web-based solutions. You can reference applications and devices using a Uniform Resource Identifier (URI) while taking advantage of services such as proxies and web caching.

Asynchronous Message Exchange

The asynchronous message exchange architecture of CoAP is well suited to edge-computing scenarios. In environments where stable network connectivity is not always guaranteed, the ability to send and receive data without a continuous, synchronous connection is vital. It allows devices to store data locally until the server is ready to receive it. This feature ensures any reporting or analytics requirements are accurate as it mitigates the potential risk of lost or missing information.

CoAP Security

As mentioned, CoAP provides the REST services of HTTP with reduced overhead and processing. It also supports proxy functionality and an asynchronous message exchange that allows the transmission of information based on network or device availability. As CoAP solutions typically leverage a three-tier distributed IT architecture, securing traffic from the edge to its final destination in the cloud is vital. Achieving this end-to-end security requires an approach that ensures the confidentiality, integrity, and availability of the data as it traverses the various nodes, networks, and gateways. 

Object Security for Constrained RESTful Environments (OSCORE) is an extension of CoAP that leverages the protocol’s inherent features. Like CoAP itself, its design allows this secure protocol’s use in constrained environments. It has two distinct advantages over other standard IoT security protocols, its payload encryption method and implementation.

Payload Encryption

Unlike other resource-intensive solutions, OSCORE only encrypts the data payload and not the entire network packet. Due to this implementation, it significantly decreases the security overhead on the platform. This design feature allows the transmission of additional data in a constrained environment. It also enhances the power efficiency of edge devices resulting in lower consumption and prolonged battery life.

Pre-Shared Keys

OSCORE utilizes pre-shared keys to encrypt the payload data of a CoAP solution. By leveraging this encryption mechanism, it avoids the resource-intensive process of key negotiation in a typical Public Key Infrastructure (PKI) exchange. This approach minimizes the security overhead on constrained devices and resource challenged environments while improving the network’s overall efficiency. 

CoAP vs MQTT

As IoT continues its exponential growth, Edge Computing in real-world scenarios remains a vital service for the next generation of solutions. End-users demand rapid performance from services, and locating computing devices in a distributed architecture solves this problem. However, from a command and control perspective, edge devices still need to provide analytics to their cloud services. Centralized management is also necessary to ensure full end-to-end control of the distributed solution. 

In the IoT world, two protocols have risen to prominence, MQTT and CoAP. Both are useful and have definitive use cases, but they do have fundamental differences. MQTT requires a long-live TCP connection to its broker, whereas CoAP utilizes UDP, a protocol best suited to constrained environments. However, the use of either MQTT or CoAP ultimately depends on the application. 

CoAP’s Role in Edge Computing

MQTT is a many-to-many communications solution for relaying messages between multiple end devices and a central broker. CoAP, on the other hand, is a one-to-one protocol for sending state information between a client and its server. MQTT is best-suited as a communications bus for live data, whereas CoAP is the logical choice for transferring device state. Ultimately, the application and its architecture will determine which of these protocols is best suited to a particular solution. However, real-world constraints such as low bandwidth and erratic network connectivity mean CoAP will have a significant role to play in current and future IoT solutions.