小程序
传感搜
传感圈

A Comparison of IIoT Protocols: MQTT Sparkplug vs. OPC-UA

2023-07-15 15:58:57
关注

Illustration: © IoT For All

Industrial systems rely heavily on efficient and secure communication protocols to exchange data seamlessly. Two prominent contenders in this space are MQTT Sparkplug and OPC UA. We will comprehensively compare MQTT Sparkplug and OPC UA, and their successors, offering a clearer understanding of which protocol aligns best with your specific requirements.

“Industrial systems rely heavily on efficient and secure communication protocols to exchange data seamlessly.”

OPC Classic & OPC UA

The precursor of OPC UA is OPC Classic (also known as OPC DA or OPC Data Access), 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 (PLCs).

However, one of its major drawbacks is that OPC Classic is tightly integrated with the Microsoft Windows operating system and its proprietary DCOM technology. This type of dependency severely compromises the protocol’s usability, scalability, interoperability, security, and platform independence, which is a significant limitation for an open standard.

In response to these limitations, the OPC Foundation started work in 2006 on OPC Unified Architecture (UA) as a successor to the OPC Classic specification. Both specifications have a functionally equivalent protocol but use different underlying communication technologies. In addition, OPC Classic DA 3.0 was released the same year and is still in use today.

IoT-Ready Protocol: Evolution of MQTT

In the late 1990s, Andy Stanford-Clark and Arlen Nipper were working on a pipeline monitoring project that required a lightweight protocol for communicating with remote sensors and devices. The project required monitoring capabilities in a low-power, low-bandwidth environment. However, existing messaging protocols such as HTTP and SMTP were considered too heavy and inefficient for this specific use case.

To address these challenges, MQTT was developed as a publish/subscribe (Pub/Sub) messaging protocol. MQTT was designed with a small code footprint and minimal bandwidth requirements, making it suitable for deployment in low-power, low-bandwidth environments.

Its primary purpose is to facilitate large-scale, real-time data exchange between devices and systems, enabling standardized data communication even when different formats and structures are involved. This characteristic makes MQTT particularly suitable for IoT and M2M (machine-to-machine) applications.

In 2010, MQTT was released as an open standard by OASIS (Organization for the Advancement of Structured Information Standards), making it available to a wide range of organizations and industries.

Then, in 2014, MQTT 3.1.1 was introduced, including several new features such as improved error handling and support for Quality of Service (QoS) levels. Then, in 2019, MQTT 5.0 was released with significant enhancements such as support for custom properties, persistent sessions, and improved error reporting.

Combining the Advantages: OPC UA over MQTT

The MQTT publish/subscribe (pub/sub) model offers several advantages over the classic OPC UA client-server model, including:

  • Scalability: The pub/sub model can effectively handle a large number of devices and systems, making it well-suited for industrial automation and IoT applications.
  • Real-time data exchange: The pub/sub model is specifically designed to facilitate real-time data exchange, enabling devices and systems to promptly respond to environmental changes.
  • Reduced network traffic: The pub/sub model helps reduce network traffic by allowing devices and systems to receive only the data they are interested in, rather than receiving all data from all sources.

The OPC Foundation released the OPC UA Pub/Sub specification in 2018. This specification defines a publish-subscribe communication model for OPC UA, which can be implemented using the MQTT (Message Queuing Telemetry Transport) protocol as a transport mechanism. OPC UA’s Pub/Sub model is a powerful new feature that provides significant benefits for industrial automation and IoT applications.

Enhancing Industrial Connectivity: MQTT Sparkplug Specification

The MQTT protocol has achieved great success in IoT scenarios. However, its applicability to industrial automation systems is limited due to a lack of interoperability. To address this limitation, Cirrus Link Solutions introduced the Sparkplug specification in 2016, aiming to simplify the implementation of MQTT in industrial automation systems. This specification establishes a standardized format for MQTT messages, facilitating the exchange of data between different devices and applications.

One notable feature of Sparkplug is its support for bi-directional communication between devices. This capability enables devices to not only send commands but also receive responses from other devices within the network.

Check out these 5 key concepts that explain why a MQTT Broker is perfect for implementing Sparkplug design principles.

OSI Model Overview

MQTT and OPC UA are the two main popular protocols used in industrial automation and IoT applications, and they have different architectures and designs that reflect their different intended uses. Here is a comparison of MQTT, OPC UA, and their variants in terms of the OSI (Open Systems Interconnection) model:

OSI ModelMQTTOPC UAMQTT SparkplugOPC UA over MQTT
Application LayerPub/Sub mechanismOPC UA communication (60 data types)Sparkplug communication (18 data types)OPC UA pub/sub communication
Presentation Layernot definedUA-JSON
UA-XML
UA-Binary
ProtobufUA-JSON
UA-XML
UA-Binary
Session Layerno sessionClient-server session managementSparkplug session awarenessno session
Transport LayerTCP/IPTCP/IPMQTTMQTT

Transport Layer: Both MQTT and OPC UA utilize TCP/IP as the underlying protocol for communication. For MQTT Sparkplug and OPC UA over MQTT, the transport protocol uses MQTT as transport protocol, because these two protocols take advantage of the MQTT pub/sub model.

Session Layer: OPC UA incorporates a session layer responsible for managing the connection between clients and servers. It handles tasks such as session establishment, authentication, and encryption. In contrast, MQTT does not possess a session layer management feature. However, MQTT Sparkplug addresses this limitation by introducing Sparkplug session awareness at the session layer.

Presentation Layer: OPC UA incorporates a well-defined information model that defines the structure and semantics of exchanged data between clients and servers, such as UA-JSON and UA-binary. On the other hand, MQTT lacks a formal information model but relies on topic-based messaging for data communication between clients and servers. However, MQTT Sparkplug addresses this gap by specifying Google Protobuf as the message format to enhance MQTT’s capabilities.

Application Layer: MQTT and OPC UA diverge significantly in their application layer protocols. MQTT follows a publish/subscribe model that organizes messages using topics, while OPC UA adopts a client/server model and utilizes a hierarchical object model to organize data. The OPC UA pub/sub specification serves as a solution for the OPC UA client/server model.

Comparing MQTT Sparkplug and OPC UA

Both MQTT Sparkplug and OPC UA are popular protocols for Industrial IoT, and they have different strengths and weaknesses that may make one more suitable than the other depending on the specific use case. Here are some key differences between the two protocols and their variants:

CriteriaMQTTMQTT SparkplugOPC UAOPC UA over MQTT
Messaging Modelpub/subpub/subclient-serverpub/sub
Bandwidth Usageminimal overhead
low bandwidth and low power
minimal overhead
low bandwidth and low power
large code
footprint
high bandwidth
large code
footprint
high bandwidth
Message Payloadnot definedlightweight messaging that is typically smaller than OPC UAmore complex data types and its messages can be much larger than MQTT Sparkplug.more complex data types and its messages can be much larger than MQTT Sparkplug.
Interoperabilityno interoperableinteroperable (18 data types)highly interoperable (60 data types)highly interoperable (60 data types)
ScalabilityHigh scalabilityhigh scalability with the ability to handle millions of messages per second.scalable but requires more complex architecture to handle large amounts of databetter scalability than OPC UA client/server model
Ease of Integrationsimple to use and requires minimal configurationsimple to use and requires minimal configurationrequires more setup and configurationrequires more setup and configuration
Quality of ServicesQoS 0 (at most once), QoS 1 (at least once), and QoS 2 (exactly once)QoS 0 (at most once), QoS 1 (at least once), and QoS 2 (exactly once)provides a reliable transport layer that ensures messages are delivered in order and without lossprovides a reliable transport layer that ensures messages are delivered in order and without loss
State AwarenessNoYesYesYes
Auto DiscoveryNoNoYesYes
ApplicationIoT, home automation and M2M applicationsIIoT and M2M applicationsindustrial automationindustrial automation
Real-TimeYesYesYesYes
Securitysecurity features are considered less secure than OPC-UAsecurity features are considered less secure than OPC-UAdigital certificates, digital signatures, data encryption, and secure authenticationdigital certificates, digital signatures, data encryption, and secure authentication
Information Modeldoes not have built-in support for information modelingsupport sophisticated information modeling but not as many as OPC UA.support sophisticated information modeling systems that allow for the creation of complex data structures and modelssupport sophisticated information modeling systems that allow for the creation of complex data structures and models

In short, OPC UA is an open standard that incorporates a well-defined set of data type specifications. On the other hand, MQTT Sparkplug is also an open standard but has fewer efforts in standardizing data types compared to OPC UA. Consequently, MQTT Sparkplug has less protocol overhead during data transmission.

OPC vs. UA

MQTT Sparkplug utilizes a lightweight messaging protocol, making it well-suited for low-bandwidth or unreliable networks. On the other hand, OPC UA employs a more robust messaging protocol capable of handling larger data volumes, which is better suited for high-speed and secure networks.

The competition between OPC UA and MQTT continues to this day.

Tweet

Share

Share

Email

  • Connectivity
  • Industrial Automation
  • Network and Protocols

  • Connectivity
  • Industrial Automation
  • Network and Protocols

参考译文
工业物联网协议对比:MQTT Sparkplug 与 OPC-UA
插图:© IoT For All --> 工业系统高度依赖高效且安全的通信协议,以无缝交换数据。在这一领域,MQTT Sparkplug 和 OPC UA 是两个主要的协议竞争者。我们将全面比较 MQTT Sparkplug 和 OPC UA 及其继任者,帮助您更清晰地了解哪种协议最符合特定需求。 “工业系统高度依赖高效且安全的通信协议,以无缝交换数据。” OPC Classic & OPC UA OPC UA 的前身是 OPC Classic(也称为 OPC DA 或 OPC Data Access),这是由 OPC 基金会开发的一套工业自动化标准。OPC Classic 规范于 1996 年首次发布,定义了软件应用程序与传感器、控制器和可编程逻辑控制器(PLC)等工业硬件设备之间交换数据的标准化方法。然而,其主要缺点之一是 OPC Classic 与微软 Windows 操作系统及其专有的 DCOM 技术紧密集成。这种依赖性严重影响了该协议的可用性、可扩展性、互操作性、安全性以及平台独立性,对于一个开放标准来说,这是显著的局限性。为了解决这些限制,OPC 基金会于 2006 年开始开发 OPC 统一架构(UA),作为 OPC Classic 规范的继任者。这两项规范在功能上是等价的协议,但使用了不同的底层通信技术。此外,OPC Classic DA 3.0 也在同年发布,至今仍在使用中。面向物联网的协议:MQTT 的演变 在 20 世纪 90 年代末,Andy Stanford-Clark 和 Arlen Nipper 正在进行一个管道监测项目,该项目需要一种轻量级协议来与远程传感器和设备进行通信。该项目需要在低功耗、低带宽的环境下进行监控。然而,现有的消息协议(如 HTTP 和 SMTP)被认为在这种特定用例中过于繁重和低效。为了应对这些挑战,MQTT 被开发为一种发布/订阅(Pub/Sub)消息协议。MQTT 设计时具有小代码占用量和最低带宽需求,使其适合部署在低功耗、低带宽的环境中。其主要目的是促进设备和系统之间的大规模实时数据交换,即使在不同格式和结构之间也能实现标准化的数据通信。这一特性使得 MQTT 特别适合于物联网和 M2M(机器对机器)应用。 2010 年,MQTT 由 OASIS(结构化信息标准促进组织)发布为开放标准,使其可供各种组织和行业使用。随后,2014 年推出了 MQTT 3.1.1,包括了改进的错误处理和对服务质量(QoS)级别的支持等新功能。2019 年,MQTT 5.0 发布,带来了诸如对自定义属性的支持、持久会话和改进的错误报告等显著增强功能。结合优势:OPC UA 通过 MQTT OPC UA 的发布/订阅(pub/sub)模型相比传统的 OPC UA 客户端/服务器模型具有多个优势,包括:可扩展性:pub/sub 模型可以有效处理大量设备和系统,使其非常适合工业自动化和物联网应用。实时数据交换:pub/sub 模型专门设计用于促进实时数据交换,使设备和系统能够及时响应环境变化。减少网络流量:pub/sub 模型通过只接收感兴趣的设备和系统的数据,而不是接收所有数据源的数据,从而减少了网络流量。OPC 基金会于 2018 年发布了 OPC UA pub/sub 规范。该规范定义了 OPC UA 的发布-订阅通信模型,可以通过 MQTT(消息队列遥测传输)协议作为传输机制来实现。OPC UA 的 pub/sub 模型是一项强大的新功能,为工业自动化和物联网应用提供了显著优势。增强工业连接性:MQTT Sparkplug 规范 MQTT 协议在物联网场景中取得了巨大成功。然而,由于缺乏互操作性,其在工业自动化系统中的适用性受到一定限制。为了解决这一限制,Cirrus Link Solutions 于 2016 年推出了 Sparkplug 规范,旨在简化 MQTT 在工业自动化系统中的实现。该规范建立了 MQTT 消息的标准化格式,促进了不同设备和应用之间的数据交换。Sparkplug 的一个显著特点是支持设备之间的双向通信。这一功能使设备不仅能够发送命令,还能接收网络中其他设备的响应。了解这五个关键概念,解释为什么 MQTT 代理非常适合实现 Sparkplug 设计原则。OSI 模型概述 MQTT 和 OPC UA 是工业自动化和物联网应用中使用的主要协议,它们有不同的架构和设计,反映了其不同的预期用途。以下是 MQTT、OPC UA 及其变体在 OSI(开放系统互连)模型中的比较: OSI 模型 MQTT OPC UA MQTT Sparkplug OPC UA over MQTT 应用层 Pub/Sub 机制 OPC UA 通信(60 种数据类型) Sparkplug 通信(18 种数据类型) OPC UA pub/sub 通信 表示层 未定义 UA-JSON UA-XML UA-Binary Protobuf UA-JSON UA-XML UA-Binary 会话层 无会话 客户端-服务器会话管理 Sparkplug 会话感知 无会话 传输层 TCP/IP TCP/IP MQTT MQTT 传输层:MQTT 和 OPC UA 都利用 TCP/IP 作为通信的基础协议。对于 MQTT Sparkplug 和 OPC UA over MQTT,传输协议使用 MQTT,因为这两个协议都利用了 MQTT 的 pub/sub 模型。 会话层:OPC UA 包含一个会话层,负责管理客户端和服务器之间的连接。它处理诸如会话建立、认证和加密等任务。相比之下,MQTT 没有会话层管理功能。然而,MQTT Sparkplug 通过在会话层引入 Sparkplug 会话感知,弥补了这一局限。 表示层:OPC UA 包含一个明确的信息模型,定义了客户端和服务器之间交换数据的结构和语义,例如 UA-JSON 和 UA-binary。另一方面,MQTT 没有正式的信息模型,而是依赖主题基础的消息传递进行客户端和服务器之间的数据通信。然而,MQTT Sparkplug 通过指定 Google Protobuf 作为消息格式,弥补了这一差距,增强了 MQTT 的功能。 应用层:MQTT 和 OPC UA 在应用层协议上存在显著差异。MQTT 采用发布/订阅模型,使用主题组织消息,而 OPC UA 采用客户端/服务器模型,并利用层次对象模型来组织数据。OPC UA pub/sub 规范是 OPC UA 客户端/服务器模型的解决方案。比较 MQTT Sparkplug 和 OPC UA 两者都是工业物联网中流行的协议,它们各自有优势和劣势,具体取决于特定的使用场景。以下是这两个协议及其变体之间的一些关键差异: 标准 MQTT MQTT Sparkplug OPC UA OPC UA over MQTT 通信模型 pub/sub pub/sub 客户端/服务器 pub/sub 带宽使用 最小开销 低带宽和低功耗 最小开销 低带宽和低功耗 高带宽 高带宽 消息负载 未定义 通常比 OPC UA 更小的轻量消息 更复杂的数据类型,其消息通常比 MQTT Sparkplug 大得多 更复杂的数据类型,其消息通常比 MQTT Sparkplug 大得多 互操作性 无互操作性 互操作性(18 种数据类型) 高互操作性(60 种数据类型) 高互操作性(60 种数据类型) 可扩展性 高可扩展性 具有每秒处理数百万消息的能力 可扩展但处理大量数据需要更复杂的架构 比 OPC UA 客户端/服务器模型更好地可扩展性 集成简单性 简单使用,配置要求少 简单使用,配置要求少 需要更多设置和配置 需要更多设置和配置 服务质量 QoS 0(最多一次)、QoS 1(至少一次)和 QoS 2(恰好一次) QoS 0(最多一次)、QoS 1(至少一次)和 QoS 2(恰好一次) 状态 无状态 有状态 状态 有状态 状态感知 状态 有状态 状态 消息传递协议 OPC UA 采用更健壮的消息传递协议,能够处理更大的数据量,更适合高速和安全网络。MQTT Sparkplug 则采用轻量级的消息传递协议,使其非常适合低带宽或不可靠的网络。 OPC UA 与 MQTT 的竞争仍在继续。TweetShareShareEmail 连接性 工业自动化 网络与协议 --> 连接性 工业自动化 网络与协议
您觉得本篇内容如何
评分

评论

您需要登录才可以回复|注册

提交评论

广告
提取码
复制提取码
点击跳转至百度网盘