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

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

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

我怎么能在PyShark中做同样的事情?我尝试过以下操作

import pyshark

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

但它显示以下错误

AttributeError: 'str' object has no attribute 'items'
python python-3.x networking tshark pyshark
1个回答
2
投票

decode_as参数应该是一个dict而不是str例如:

decode_as={'udp.port==1234':'rtp'}
© www.soinside.com 2019 - 2024. All rights reserved.