无法在wireshark中看到OPCUA协议。

问题描述 投票:0回答:1

创建了一个简单的客户端和服务器,并试图在wireshark中捕获动作,但无法看到OPC UA协议在相同的.我已经做了这个代码在windows 10上的pycharm,你可以请指出问题是在哪里看到OPCUA协议在wiresharki已添加服务器代码,我已经使用,并添加客户端代码和附加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

python excel pycharm wireshark opc-ua
1个回答
2
投票

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

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

你可以在这里更新列表。Wireshark - Edit - Preferences - Protocols- OpcUa - TCP Port(s)

Wireshark OPC UA Binary Protocol TCP Ports

© www.soinside.com 2019 - 2024. All rights reserved.