package com.owens.omavlinkanalyzer; import java.io.IOException; import java.util.logging.Logger; import io.pkts.PacketHandler; import io.pkts.Pcap; import io.pkts.buffer.Buffer; import io.pkts.framer.UDPFramer; import io.pkts.packet.Packet; import io.pkts.packet.TCPPacket; import io.pkts.packet.UDPPacket; import io.pkts.protocol.Protocol; public class AppPkts2 { private static final Logger LOG = Logger.getLogger(AppPkts2.class.getName()); public static void main(String[] args) { String filename = "/Users/sean/Documents/mavlinkproject_wireshark_data/jmavsim_px4_commander_startup2.pcap"; try { System.err.println("Opening file = " + filename); final Pcap pcap = Pcap.openStream(filename); pcap.loop(new PacketHandler() { @Override public boolean nextPacket(final Packet packet) throws IOException { if (packet.hasProtocol(Protocol.UDP)) { System.out.println(packet.getPacket(Protocol.UDP).getPayload()); } else { LOG.severe("Packet is not UDP, protocol = " + packet.getProtocol()); } return true; } }); System.err.println("Done"); } catch (IOException ex) { System.out.println(ex.getMessage()); } } }