Protocols for structured data and IoT: CoAP and Protocol Buffer (Protobuf)
Published : 09/01/2021 14:30:00
The Internet of Things, especially in the industrial environment, requires specific protocols, libraries and data serialisation methods to ensure reliability and guarantee the durability of the devices that make up the IIoT. The technologies and protocols used are varied and are chosen according to the objectives to be achieved; the experience of Digimax and its industrial partners has identified in the LoRa protocol an optimal solution for covering shorter distances than NB-IoT. The advantages of the LoRa standard are cost certainty, scalability and the possibility of deploying a proprietary network; NB-IoT, on the other hand, guarantees immediate usability and autonomy for each node in the network. Finally, the MQTT protocol has become the communication standard for managing connections between devices (machine to machine).
Internet of Things is constantly developing and billions of devices will be deployed in the near future; this is why it is important to keep up to date with new technologies that allow you to minimise the size of data frames to be sent. Let's take a look at why CoAP and Protobuf are becoming increasingly popular in IoT solutions.
What is CoAP (Constrained Application Protocol) and how is it used?
CoAP is an open protocol for IoT devices; is similar to HTTP but has been redesigned to meet the requirements of battery-powered devices with limited CPU and RAM resources. CoAP uses very small data packets, is simpler than HTTP and has a smaller footprint (the smallest CoAP message is 4 bytes compared to the 26 bytes of the HTTP message). CoAP is designed to be easily converted to HTTP for simplified integration with the Web, as both are based on a client/server model: the client sends a request to the server and the server returns a response. CoAP cannot use SSL/TLS to secure communication (this requires the TCP transport layer). Communication security is provided by the Datagram Transport Layer Security (DTLS) standard, which runs over UDP and provides a high level of security.
Protobuf (Protocol Buffers) cross-platform library for handling structured data
The protocol buffers (or Protobuf) are a method of serialising data that can be transmitted between microservices, applications or used in communication between IoT devices and servers. Protocol buffers serve the same function as JSON and XML, which are well known and widely used, and like the latter are language and platform independent. The key differences between the three methods of data serialisation lie in the fact that Protobuf is optimised to be fast and use as little bandwidth as possible, while minimising the size of the data transmitted. Protobuf is 3 to 10 times smaller and 20 to 100 times faster than XML. This makes Protobuf a perfect choice for serialising data sent from battery-powered IoT devices.
The Protobuf format was created by Google in 2001 and has since been used in almost all Google machine-to-machine communications, as well as for storing and exchanging all kinds of structured information. The binary format increases the speed of data transmission because the message requires less space and network bandwidth, the only disadvantage of this approach, compared to JSON or XML, is that data serialised with Protobuf is not directly readable. Data and context are in fact separate: the context is defined in configuration files called proto files and contain field names together with their types and identifiers while data contains field identifier, field type, value length and value.
How does Efento use CoAP and Protobuf?
Efento NB-IoT and LTE-M industrial sensors send data in Protobuf format using the CoAP protocol. This ensures fast transmissions and small data sizes, resulting in a battery life of up to 10 years. Since CoAP and Protobuf are widespread standards, it is easy to integrate Efento wireless sensors with any cloud platform or customised application, developing your own smart industry project..