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

asked 2023-05-15 19:29:58 +0000

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.

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')

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()
edit retag flag offensive close merge delete


Well, at the very least, shouldn't your display_filter be set to 'UDP', not 'TCP'?

cmaynard gravatar imagecmaynard ( 2023-05-15 19:45:59 +0000 )edit

I have used MissionPlanner to connect to drone and TCP port 5760 was used. So, I have used udp and it does show some output but the mavlink protocol information need to extracted?

kryptoniancode gravatar imagekryptoniancode ( 2023-05-15 22:13:53 +0000 )edit