Ask Your Question

Revision history [back]

How to extract packet captured with lua plugin for mavlink protocol in python?

I have used this to generate lua plugin for wireshark to capture mavlink packets. I have captured mavlink packets but shows error and has been discussed on GitHub.

https://github.com/mavlink/mavlink/issues/1978

Now my question is how to extract information from packets which have been exported from wireshark. I have tried this code but it does not show any output.

import pyshark

capture = pyshark.FileCapture('mavlink/mission.pcapng', display_filter='TCP')
capture.set_debug()

for packet in capture:
    src_ip = packet.ip.src
    dst_ip = packet.ip.dst
    src_port = packet.udp.srcport
    dst_port = packet.udp.dstport
    mavlink_payload = packet.mavlink.payload

    print(f'Source IP: {src_ip}, Destination IP: {dst_ip}, '
          f'Source Port: {src_port}, Destination Port: {dst_port}, '
          f'Mavlink Payload: {mavlink_payload}')

capture. Close()