Search in sources :

Example 1 with CapturedPkt

use of com.cisco.trex.stateless.model.capture.CapturedPkt in project trex-stateless-gui by cisco-system-traffic-generator.

the class RecordController method handleSavePkts.

public void handleSavePkts(int monitorId) {
    List<CapturedPkt> capturedPkts = new ArrayList<>();
    int pendingPkts = 1;
    while (pendingPkts > 0) {
        try {
            CapturedPackets capturedPackets = pktCaptureService.fetchCapturedPkts(monitorId, 1000);
            pendingPkts = capturedPackets.getPendingPkts();
            capturedPkts.addAll(capturedPackets.getPkts());
        } catch (PktCaptureServiceException e) {
            LOG.error("Unable to fetch packets.", e);
            break;
        }
    }
    File outFile = fileChooser.showSaveDialog(getScene().getWindow());
    if (outFile != null) {
        try {
            dumpPkts(capturedPkts, outFile.getAbsolutePath());
        } catch (Exception e) {
            LOG.error("Unable to dump packets.", e);
        }
    }
}
Also used : CapturedPackets(com.cisco.trex.stateless.model.capture.CapturedPackets) PktCaptureServiceException(com.cisco.trex.stl.gui.services.capture.PktCaptureServiceException) CapturedPkt(com.cisco.trex.stateless.model.capture.CapturedPkt) File(java.io.File) PktCaptureServiceException(com.cisco.trex.stl.gui.services.capture.PktCaptureServiceException) IllegalRawDataException(org.pcap4j.packet.IllegalRawDataException)

Aggregations

CapturedPackets (com.cisco.trex.stateless.model.capture.CapturedPackets)1 CapturedPkt (com.cisco.trex.stateless.model.capture.CapturedPkt)1 PktCaptureServiceException (com.cisco.trex.stl.gui.services.capture.PktCaptureServiceException)1 File (java.io.File)1 IllegalRawDataException (org.pcap4j.packet.IllegalRawDataException)1