Search code examples
pythonpython-3.xnetworkingtsharkpyshark

How to decode a packet in PyShark as decode_as


In Wireshark GUI, we can decode a UPD packet as RTP, and the same can be done in tshark using d <layer type>==<selector>,<decode-as protocol>

How can i do the same in PyShark ? I tried doing the following

import pyshark

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

But it shows the following error

AttributeError: 'str' object has no attribute 'items'

Solution

  • decode_as argument should be a dict and not str Example:

    decode_as={'udp.port==1234':'rtp'}