无法在 wireshark 中看到 OPCUA 协议

Unable to see OPCUA protocol in wireshark

创建了一个简单的客户端和服务器并尝试在 wireshark 中捕获操作,但无法在其中看到 OPC UA 协议。 我在 windows 10 上的 pycharm 中完成了这段代码 你能指出问题出在哪里吗 在 wireshark 中查看 OPCUA 协议 我添加了我使用过的服务器代码,还添加了客户端代码并将 wireshark 图像附加为 png 文件 服务器代码:

from opcua import Server
from random import randint
from xlwt import Workbook
import datetime
import time

server = Server()
workbook = Workbook()
sheet = workbook.add_sheet('sheet 1')
#sheet.write(j, 0, time.time())
#workbook.save("sub_ohio_latency_ACK.xls")
url = "opc.tcp://LAPTOP-9UCODEJ5:48020"

server.set_endpoint(url)
name = "OPCUA_Server"
addspace = server.register_namespace(name)

node = server.get_objects_node()

Param = node.add_object(addspace, "Parameters")

Temp = Param.add_variable(addspace, "Temperature",0)
Time = Param.add_variable(addspace, "Time",0)
i = Param.add_variable(addspace, "TagID", 0)

Temp.set_writable()
Time.set_writable()


l = server.get_objects_node()
p = server.get_node(Temp)
k = server.get_node(Time)
j = server.get_node(i)

print(k)
print(p)
print(l)
print(j)

server.start()
print("server started at ()".format(url))
c = 0
while True:

    Temperature = randint(0,20)
    TIME = datetime.datetime.now()
    TagID = c
    print(Temperature, TIME, c)

    Temp.set_value(Temperature)
    Time.set_value(TIME)
    i.set_value(c)
    c += 1
    #time.sleep(2)

客户代码

from opcua import Client
import time
from xlwt import Workbook

workbook =Workbook()
#workbook2=Workbook()
sheet = workbook.add_sheet('sheet 1')

url = "opc.tcp://192.168.0.108:48020"

client = Client(url)
client.connect()
print("client connected")

for i in range(2000):
    objects = client.get_objects_node()
    l = client.get_node("ns=2;i=2")
    Temperature = l.get_value()
    #print(Temperature)
    k = client.get_node("ns=2;i=3")
    Time = k.get_value()
    j = client.get_node("ns=2;i=4")
    msg_tag = j.get_value()
    sheet.write(i, 0, msg_tag)
    sheet.write(i, 1, Temperature)
    sheet.write(i, 2, Time)
    sheet.write(i,3,time.time())
    workbook.save("test_client.xls")
    #print(Time)
    #print(msg_tag)
    #print(objects)
    #time.sleep(5)
client.disconnect()
print("client disconnected")

WIreshark Ref

默认情况下,Wireshark OPC UA 显示过滤器仅适用于默认 OPC UA TCP 端口 (4840)

由于您使用另一个端口 (48020),您需要更新将与 OPC UA 二进制协议关联的 TCP 端口列表,以便让 Wireshark 知道它需要将这些端口上的数据包解码为 OPC UA数据包。

您可以在此处更新列表: Wireshark - 编辑 - 首选项 - 协议 - OpcUa - TCP 端口