如何在 PyShark 中将数据包解码为decode_as

dvs*_*dvs 1 python networking python-3.x tshark pyshark

在 Wireshark GUI 中,我们可以将 UPD 数据包解码为 RTP,并且可以在 tshark 中使用以下命令完成相同的操作 d <layer type>==<selector>,<decode-as protocol>

我怎样才能在 PyShark 中做同样的事情?我尝试执行以下操作

import pyshark

cap = pyshark.FileCapture("Test.pcap", display filter='udp', decode_as='rtp')
for pkt in cap:
   print(pkt)
Run Code Online (Sandbox Code Playgroud)

但它显示以下错误

AttributeError: 'str' object has no attribute 'items'
Run Code Online (Sandbox Code Playgroud)

bal*_*man 5

debug_as 参数应该是 dict 而不是 str 示例:

decode_as={'udp.port==1234':'rtp'}
Run Code Online (Sandbox Code Playgroud)