Industrial IoT protocol comparison: MQTT Sparkplug vs OPC-UA

introduction

Industrial systems need to ensure the seamless exchange of data and therefore rely heavily on efficient and secure communication protocols. MQTT Sparkplug and OPC UA are two industrial protocols that are often mentioned. This article will make a comprehensive comparison of MQTT Sparkplug and OPC UA and their derivatives to help you understand more clearly which protocol is more suitable for your needs.

OPC Classic 和 OPC UA

OPC UA, formerly known as OPC Classic (also known as OPC DA or OPC Data Access), is a set of industrial automation standards developed by the OPC Foundation. First published in 1996, the OPC Classic specification defines a standardized method for exchanging data between software applications and industrial hardware devices such as sensors, controllers, and programmable logic controllers.

However, OPC Classic has a significant disadvantage: it is tightly coupled to the Microsoft Windows operating system and its proprietary DCOM technology. This dependency seriously affects the usability, scalability, interoperability, security, and platform independence of the protocol, which is a huge constraint for an open standard.

To overcome these limitations, the OPC Foundation started developing OPC UA (OPC Unified Architecture) in 2006 as the successor to the OPC Classic specification. The two specifications are functionally equivalent but use different underlying communication techniques. In addition, OPC Classic DA 3.0 was released in the same year and is still in use today.

A Protocol for the Internet of Things: The Evolution of MQTT

In the late 1990s, Andy Stanford-Clark and Arlen Nipper worked on a project on pipeline monitoring that required a lightweight protocol for communicating with remote sensors and equipment. This project requires the monitoring function to be implemented in a low-power, low-bandwidth environment. However, the messaging transport protocols of the time, such as HTTP and SMTP, were considered too bloated and inefficient for this particular scenario.

In order to meet these challenges, a publish/subscribe mode message transmission protocol MQTT came into being. MQTT is known for its simplified code and extremely low bandwidth consumption, so it has significant advantages in low power consumption and low bandwidth scenarios. Its main goal is to achieve large-scale real-time data exchange between devices and systems, and to ensure the standardization of data communication even in the face of different data formats and structures. This feature makes MQTT ideal for IoT and machine-to-machine (M2M) applications.

MQTT was published as an open standard by the Organization for the Advancement of Structured Information Standards (OASIS) in 2010, making it a communication protocol that can be used by various organizations and industries. Subsequently, MQTT 3.1.1 was released in 2014, introducing several new features such as improved error handling and support for Quality of Service (QoS) levels. Later, MQTT 5.0 was released in 2019, with major improvements, including support for custom attributes, implementation of persistent sessions, and optimization of error reporting.

Complementary advantages: OPC UA over MQTT

The MQTT publish/subscribe model has the following advantages over the classic OPC UA client-server model:

  • Scalability: The publish/subscribe model can efficiently handle large numbers of devices and systems, making it ideal for industrial automation and IoT applications.
  • Real-time data exchange: The publish/subscribe model is specially designed for real-time data exchange, which enables devices and systems to sense and adapt to environmental changes in a timely manner.
  • Reduced network traffic: The publish/subscribe model can effectively reduce network traffic by delivering only the data that devices and systems need, rather than all data.

In 2018, the OPC Foundation released the OPC UA Publish/Subscribe Specification, which developed a publish/subscribe communication model for OPC UA, which can use the MQTT protocol as a transmission method. The OPC UA publish/subscribe model is very powerful and brings great benefits to industrial automation and IoT applications.

Boosting Industrial Connectivity: The MQTT Sparkplug Specification

The MQTT protocol has achieved great success in IoT scenarios, but its application in industrial automation systems has been limited due to insufficient interoperability. To solve this problem, Cirrus Link Solutions launched the Sparkplug specification in 2016, which aims to simplify the deployment and use of MQTT in industrial automation systems. This specification defines a standardized format for MQTT messages, enabling data exchange between different devices and applications.

A notable feature of Sparkplug is that it supports bi-directional communication between devices. This capability allows devices to not only send commands, but also receive feedback from other devices in the network.

This blog explains why MQTT Broker is an ideal choice to implement the design principles of Sparkplug by introducing 5 key concepts: 5 key concepts about MQTT Broker in Sparkplug specification.

OSI Model Overview

MQTT and OPC UA, two protocols commonly used in industrial automation and IoT applications, have different architectures and designs, reflecting their respective uses. Here is a comparison of MQTT, OPC UA and its variants in terms of the Open Systems Interconnection (OSI) model:

OSI model MQTT OPC UA MQTT Sparkplug OPC UA over MQTT
application layer publish/subscribe mechanism OPC UA communication (60 data types) Sparkplug communication (18 data types) OPC UA
publish/subscribe communication
presentation layer undefined UA-JSON
UA-XML
UA-Binary
Protobuf UA-JSON
UA-XML
UA-Binary
session layer no session Client-Server Session Management Sparkplug session awareness no session
transport layer TCP/IP TCP/IP MQTT MQTT

Transport layer : Both MQTT and OPC UA use TCP/IP as the underlying communication protocol. MQTT Sparkplug and OPC UA over MQTT use MQTT as the transport protocol, and they both adopt the MQTT publish/subscribe model.

Session layer : OPC UA includes a session layer responsible for managing connections between clients and servers, handling tasks such as session establishment, authentication, and encryption. In contrast, MQTT does not have session layer management capabilities. However, MQTT Sparkplug makes up for this deficiency by introducing Sparkplug session awareness at the session layer.

Presentation layer : OPC UA has a well-defined information model that defines the structure and semantics of data exchanged between clients and servers, such as UA-JSON and UA-binary. In contrast, MQTT lacks a formal information model and instead relies on topic-based messages for data communication between clients and servers. MQTT Sparkplug bridges this gap by specifying Google Protobuf as the message format to enhance the capabilities of MQTT.

Application layer : There are obvious differences between MQTT and OPC UA in the application layer protocol. MQTT uses a publish/subscribe model to organize messages through topics, while OPC UA uses a client/server model to organize data through a hierarchical object model. The OPC UA Publish/Subscribe specification is an extension to the OPC UA client/server model.

Comparison of MQTT Sparkplug and OPC UA

MQTT Sparkplug and OPC UA have their own advantages and disadvantages, so in different usage scenarios, there may be situations where one protocol is more suitable than the other. Some of the key differences between the two protocols and their derivatives are as follows:

index MQTT MQTT Sparkplug OPC UA OPC UA over MQTT
message transfer model publish/subscribe publish/subscribe client/server publish/subscribe
bandwidth usage Minimal overhead, low bandwidth and low power consumption Minimal overhead, low bandwidth and low power consumption High code footprint, high bandwidth High code footprint, high bandwidth
message payload undefined Lightweight messages, typically smaller than OPC UA Complex data types whose message size can be much larger than MQTT Sparkplug Complex data types whose message size can be much larger than MQTT Sparkplug
Interoperability not interoperable Interoperable (18 data types) High interoperability (60 data types) High interoperability (60 data types)
Scalability highly scalable Highly scalable, capable of processing millions of messages per second Scalability is better, but requires a more complex architecture to handle large amounts of data Better scalability than OPC UA client/server model
Integration convenience Simple to use with minimal configuration requirements Simple to use with minimal configuration requirements Requires more installation and configuration Requires more installation and configuration
service quality QoS 0 (at most once), QoS 1 (at least once) and QoS 2 (only once) QoS 0 (at most once), QoS 1 (at least once) and QoS 2 (only once) Provide a reliable transport layer to ensure that messages are delivered in order and not lost Provide a reliable transport layer to ensure that messages are delivered in order and not lost
state awareness no yes yes yes
automatic discovery no no yes yes
Application field IoT, Home Automation and M2M Applications Industrial IoT and M2M Applications automated industry automated industry
real-time yes yes yes yes
safety Less secure than OPC-UA Less secure than OPC-UA Digital certificates, digital signatures, data encryption and security authentication Digital certificates, digital signatures, data encryption and security authentication
information model Does not have built-in support for information modeling Supports complex information modeling, but not as much as OPC UA Support for complex information modeling systems, allowing the creation of complex data structures and models Support for complex information modeling systems, allowing the creation of complex data structures and models

In short, OPC UA is an open standard that consists of a set of well-defined data type specifications. MQTT Sparkplug is also an open standard, but it does not do enough to standardize data types. Therefore, during data transmission, MQTT Sparkplug generates less protocol overhead.

epilogue

MQTT Sparkplug uses a lightweight message transmission protocol, which is very suitable for low-bandwidth or unstable network environments. OPC UA uses a more powerful message transmission protocol, can handle more data volume, and is more suitable for high-speed and secure network environments.

The competition between OPC UA and MQTT continues to this day. Currently, EMQ is launching the MQTT over QUIC protocol for the automotive industry, and the OPC Foundation has also released OPC UA over TSN. OPC UA over TSN provides a standardized method of transporting real-time data over Ethernet and aims to simplify complex industrial automation and control systems.

Copyright statement: This article is original by EMQ, please indicate the source for reprinting.
Original link: https://www.emqx.com/zh/blog/a-comparison-of-iiot-protocols-mqtt-sparkplug-vs-opc-ua

Guess you like

Origin blog.csdn.net/emqx_broker/article/details/131576516