A Simple Explanation of Using CoAP Protocol in Advanced Metering Infrastructure

A Simple Explanation of Using CoAP Protocol in Advanced Metering Infrastructure

CoAP protocol

This article is sourced from:

https://academy.nordicsemi.com/courses/cellular-iot-fundamentals/lessons/lesson-5-cellular-fundamentals/topic/lesson-5-coap-protocol/

CoAP /käˈæp/ stands for “Constrained Application Protocol,” an application layer protocol based on UDP transmission developed for the Internet of Things (IoT) and IoT devices, defined by the Internet Engineering Task Force (IETF) in RFC 7252.The reason IoT and IoT devices are referred to as constrained networks is due to their limited bandwidth, memory, storage, computational power, and battery life.

CoAP is like a simplified version of the HTTP protocol, specifically designed for constrained IoT and its devices. Similar to HTTP, it is based on a client-server architecture—clients make requests, and servers return responses, which is known as the REST (REpresentational State Transfer) model.

A Simple Explanation of Using CoAP Protocol in Advanced Metering Infrastructure
Figure 1. Client/Server Architecture of CoAP

A Simple Explanation of Using CoAP Protocol in Advanced Metering Infrastructure

01

REST Model

The REST model defines a uniform interface for communication between clients and servers through a series of strict constraints. The most important aspect of the REST model is the resource (the representation of data), which is an abstraction of all types of information.You can use commands like GET, POST, PUT, and DELETE, similar to HTTP, to read, write, and manipulate that resource.Each resource has a Uniform Resource Identifier (URI).

A Simple Explanation of Using CoAP Protocol in Advanced Metering Infrastructure

02

CoAP Messages

The following diagram illustrates the format of CoAP messages.

A Simple Explanation of Using CoAP Protocol in Advanced Metering Infrastructure
Figure 2. CoAP Message Format
It starts with a fixed 4-byte message that contains:
  • Version Ver— Currently 1, other values are reserved for future versions.

  • Type Type— Indicates whether the message is “confirmable,” “non-confirmable,” “acknowledgment,” or “reset.”.

  • Token Length— Represents the length of the “variable-length token” field.

  • Code Code— Divided into two parts, the first 0-7 bits for classification and 8-31 bits for details. Classification includes: “request,” “successful response,” or “error response,” with details providing additional information for the classification.

  • Message ID— The sequential ID of the network message, used to detect duplicates or ensure reliability.

Types of Messages

CoAP messages use UDP for transmission, so packets may arrive out of order, be duplicated, or lost. Therefore, reliability is achieved by marking the message in the CoAP header as “confirmable.” The receiver must confirm or reject the message using the original Message ID (rejected messages are of the reset type).

Code Field

The Code field in the CoAP message header specifies the message category.

In message requests, the following categories exist:
  • GET— Retrieve information corresponding to the resource specified in the CoAP request.

  • POST— Request the server to process the information contained in the request and update the target resource or create a new resource using that information (if the target resource does not already exist).

  • PUT— Similar to a POST request, but the server may choose to create the resource if it does not exist.

  • DELETE— Request to delete the specified resource.

Response messages have more options, but generally, there are three types: “success,” “client error,” or “server error.” For a detailed list of response codes, refer to section 5.9 of RFC 7252 for response code definitions.

Token Field

All CoAP requests also carry a token, which is a sequence of 0-8 bytes that the server echoes in any response. The token is generated by the client and should be unique and random when generated.

Unlike the Message ID, the token is an important random string used to prevent spoofing and can also serve as a local identifier for the client. The Message ID is assigned sequentially, while the token is random.

Option Field

CoAP defines many options that can be included in CoAP messages (requests and responses). For a complete list of options, refer to section 5.4 of RFC 7252.

For example, a GET request for a resource should include an option specifying the URI of that resource.

Security

Since CoAP uses UDP as its transport protocol, “Datagram Transport Layer Security (DTLS)” can be used to protect communications.

DTLS provides the same functionality as TLS (confidentiality, integrity, and authenticity) while adding the capability to handle the connectionless characteristics of UDP.

Differences Between MQTT and CoAP

MQTT is another widely used IoT communication protocol, and the choice between the two depends on various factors.

These two protocols have very different network architectures, as shown in the following diagram:

A Simple Explanation of Using CoAP Protocol in Advanced Metering Infrastructure
Figure 3. Differences Between MQTT and CoAP

MQTT adopts a “publish/subscribe” method, while CoAP uses a “request/response” method.MQTT uses a central broker for communication, whereas CoAP is a one-to-one architecture without intermediaries.CoAP uses UDP, which is less reliable than the TCP-based connections used by MQTT.However, MQTT has higher power consumption because it must maintain the connection between the client and the broker.CoAP is a one-to-one model, while MQTT supports simultaneous connections from multiple nodes.

Unlike TCP-based protocols, CoAP has the advantage of being connectionless, meaning you can communicate between two endpoints without prior arrangement.

MQTT is well-suited for “event-driven” systems, where changes in the status of IoT sensor devices drive subsequent reactions. CoAP, on the other hand, is more suitable for centralized monitoring systems where higher-level information systems query the status of IoT devices as needed.

A Simple Explanation of Using CoAP Protocol in Advanced Metering Infrastructure

03

Discussion on Smart Meters and Advanced Metering Infrastructure

In advanced metering infrastructure, smart meters need to send data to the metering master station system at fixed intervals. This process generally uses the DLMS protocol (Device Language Message Specification) defined by IEC 62056. The “Metering Device Language” based on IPv4 network transmission is defined in IEC 62056-47:2006.

DLMS can be based on TCP connections for websockets transmission or based on UDP for data interaction.

From the perspective of smart meter data properties, the primary application scenario is the uploading of meter data to the collection system, so MQTT would be more suitable for this application scenario in constrained networks.

However, the meter data management system also needs to send requests to the meter for “on-demand reading,” “remote disconnect/reconnect,” “synchronization,” and “sending or querying rates,” making CoAP more effective in these situations.

This is similar to past smart meter data collection master station systems, where we more often used a client-server architecture (C/S architecture); now it is gradually shifting to a browser-server architecture (B/S architecture). This transition process does not change the essence of data collection and control, but to meet customer demands for “thin clients,” today’s product research and development is more based on web applications.

Clearly, in the underlying communication process, whether to use CoAP or directly transmit DLMS requests based on UDP does not make a fundamental difference. CoAP makes future smart meters look more like specific nodes in the ocean of the IoT, no longer cold IP addresses and obscure DLMS service ports, but a unique network address identifier URI. If developed properly, the GET method can be used more, simplifying program development on the master station side.

MQTT and CoAP are not contradictory; they serve different application scenarios. From the application itself, CoAP is not a mandatory option. However, the historical development of the Internet seems to suggest that CoAP will become a trend in the larger IoT world.

A Simple Explanation of Using CoAP Protocol in Advanced Metering Infrastructure
Related Reading:
Accelerating Decarbonization, Balancing, and Fault Transfer in the Power Grid Using 5G and FAN Hybrid Networking
Amazon Sidewalk IoT Program
Centralized Protection Based on Virtual Platforms and Active Distribution Network Management
NB-IoT Based MQTT
Hitachi ABB Power Grids Joins 450MHz Wireless Alliance
The Importance of Wireless Private Networks for Power Grid Modernization
Let’s Collaborate on Wireless Private Networks
NB-IoT Creates New Opportunities in Rural Areas
How to Deploy AMI Systems Based on NB-IoT
Determining the Peak Transmission Rate of NB-IoT
The Past and Present of NB-IoT
Saudi Electricity Company Deploys Data Center Based on ACI Architecture
Polish Energy Company to Deploy 5G-Supported Networks for Distribution Operations
ESB Uses €1.1 Million to Acquire Wireless Spectrum for Smart Grid in Ireland
How Can Telecom Operators Participate in Smart Grid Business?
What Communication Protocols Can IoT Choose?
How Itron Uses CoAP in Mesh Networks
Why Smart Meter Developers Are Confused About MQTT and CoAP Based on NB-IoT?
Field Communication Networks for Electric Utilities | FAN and Wi-SUN (IEEE Std 802.15.4g)
Applications of LTE Wireless Private Networks in Distribution Systems

Leave a Comment