Search in sources :

Example 1 with PacketParser

use of com.exalttech.trex.ui.views.streams.viewer.PacketParser in project trex-stateless-gui by cisco-system-traffic-generator.

the class PacketUtil method getPacketInfoData.

/**
     * Decode string and return packet info data
     *
     * @param encodedBinaryPacket
     * @return packet info
     * @throws IOException
     */
public PacketInfo getPacketInfoData(String encodedBinaryPacket) throws IOException {
    // decode binary data
    File pcapFile = trafficProfile.decodePcapBinary(encodedBinaryPacket);
    PacketInfo packetInfo = new PacketInfo();
    PacketParser parser = new PacketParser();
    parser.parseFile(pcapFile.getAbsolutePath(), packetInfo);
    return packetInfo;
}
Also used : PacketParser(com.exalttech.trex.ui.views.streams.viewer.PacketParser) PacketInfo(com.exalttech.trex.ui.models.PacketInfo) File(java.io.File)

Example 2 with PacketParser

use of com.exalttech.trex.ui.views.streams.viewer.PacketParser in project trex-stateless-gui by cisco-system-traffic-generator.

the class ImportedPacketTableView method setPcapFile.

/**
     * Parse pcap file to get all streams
     *
     * @param pcapFile
     * @return
     */
public boolean setPcapFile(File pcapFile) {
    List<PacketInfo> packetInfoList = new ArrayList<>();
    try {
        PacketUpdater.getInstance().reset();
        PcapHandle handler = Pcaps.openOffline(pcapFile.getAbsolutePath());
        PacketParser parser = new PacketParser();
        Packet packet;
        while ((packet = handler.getNextPacketEx()) != null) {
            if (!PacketUpdater.getInstance().validatePacket(packet)) {
                break;
            }
            PacketInfo packetInfo = new PacketInfo();
            packet = PacketUpdater.getInstance().updatePacketSrcDst(packet);
            packetInfo.setPacket(packet);
            packetInfo.setTimeStamp(handler.getTimestamp().getTime());
            parser.parsePacket(packet, packetInfo);
            packetInfoList.add(packetInfo);
        }
    } catch (EOFException e) {
        LOG.info("End of pcap file");
    } catch (PcapNativeException | TimeoutException | NotOpenException ex) {
        LOG.error("Error parsing selectd pcap file", ex);
    }
    setTableData(packetInfoList);
    return PacketUpdater.getInstance().isValidPacket();
}
Also used : PacketParser(com.exalttech.trex.ui.views.streams.viewer.PacketParser) Packet(org.pcap4j.packet.Packet) NotOpenException(org.pcap4j.core.NotOpenException) PcapHandle(org.pcap4j.core.PcapHandle) ArrayList(java.util.ArrayList) EOFException(java.io.EOFException) PacketInfo(com.exalttech.trex.ui.models.PacketInfo) PcapNativeException(org.pcap4j.core.PcapNativeException) TimeoutException(java.util.concurrent.TimeoutException)

Example 3 with PacketParser

use of com.exalttech.trex.ui.views.streams.viewer.PacketParser in project trex-stateless-gui by cisco-system-traffic-generator.

the class PacketBuilderHomeController method initialize.

@Override
public void initialize(URL url, ResourceBundle rb) {
    trafficProfile = new TrafficProfile();
    packetHex = new PacketHex(hexPane);
    nextStreamBtn.setGraphic(new ImageView(new Image("/icons/next_stream.png")));
    prevStreamBtn.setGraphic(new ImageView(new Image("/icons/prev_stream.png")));
    packetInfo = new PacketInfo();
    parser = new PacketParser();
}
Also used : PacketParser(com.exalttech.trex.ui.views.streams.viewer.PacketParser) TrafficProfile(com.exalttech.trex.util.TrafficProfile) PacketInfo(com.exalttech.trex.ui.models.PacketInfo) PacketHex(com.exalttech.trex.ui.views.streams.viewer.PacketHex) ImageView(javafx.scene.image.ImageView) Image(javafx.scene.image.Image)

Aggregations

PacketInfo (com.exalttech.trex.ui.models.PacketInfo)3 PacketParser (com.exalttech.trex.ui.views.streams.viewer.PacketParser)3 PacketHex (com.exalttech.trex.ui.views.streams.viewer.PacketHex)1 TrafficProfile (com.exalttech.trex.util.TrafficProfile)1 EOFException (java.io.EOFException)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 TimeoutException (java.util.concurrent.TimeoutException)1 Image (javafx.scene.image.Image)1 ImageView (javafx.scene.image.ImageView)1 NotOpenException (org.pcap4j.core.NotOpenException)1 PcapHandle (org.pcap4j.core.PcapHandle)1 PcapNativeException (org.pcap4j.core.PcapNativeException)1 Packet (org.pcap4j.packet.Packet)1