Search in sources :

Example 1 with TraceTime

use of com.att.aro.core.packetanalysis.pojo.TraceTime in project VideoOptimzer by attdevsupport.

the class TraceDataReaderImpl method readTimes.

/**
 * @param TraceDirectoryResult
 *            res
 * @return
 * @throws IOException
 */
private TraceTime readTimes(TraceDirectoryResult res) throws IOException {
    String filepath = res.getTraceDirectory() + Util.FILE_SEPARATOR + TraceDataConst.FileName.TIME_FILE;
    String[] lines = filereader.readAllLine(filepath);
    TraceTime result = new TraceTime();
    String line;
    if (lines.length > 1) {
        line = (lines[1].contains(",") ? lines[1].replaceAll(",", ".") : lines[1]);
        result.setStartTime(Double.valueOf(line));
    }
    if (lines.length > 2) {
        line = (lines[2].contains(",") ? lines[2].replaceAll(",", ".") : lines[2]);
        result.setEventTime(Double.parseDouble(line) / 1000.0);
    }
    if (lines.length > 3) {
        line = (lines[3].contains(",") ? lines[3].replaceAll(",", ".") : lines[3]);
        Double duration = Double.parseDouble(line) - result.getStartTime();
        result.setDuration(duration);
    }
    if (lines.length > 4) {
        line = (lines[4].contains(",") ? lines[4].replaceAll(",", ".") : lines[4]);
        try {
            result.setTimezoneOffset(Integer.valueOf(line));
        } catch (NumberFormatException e) {
            LOGGER.warn("Unable to parse Collector Timezone Offset - value: " + line);
        }
    }
    return result;
}
Also used : TraceTime(com.att.aro.core.packetanalysis.pojo.TraceTime)

Example 2 with TraceTime

use of com.att.aro.core.packetanalysis.pojo.TraceTime in project VideoOptimzer by attdevsupport.

the class TraceDataReaderImpl method readTimeAndPcap.

/**
 * Reads the PCAP file and the trace times from the time trace file.
 *
 * @throws IOException
 */
private TraceDirectoryResult readTimeAndPcap(TraceDirectoryResult dresult) throws IOException {
    TraceDirectoryResult result = dresult;
    String filepath = result.getTraceDirectory() + Util.FILE_SEPARATOR + TraceDataConst.FileName.TIME_FILE;
    Double startTime = null;
    Double duration = null;
    if (filereader.fileExist(filepath)) {
        TraceTime times = readTimes(result);
        startTime = times.getStartTime();
        if (times.getEventTime() != null) {
            result.setEventTime0(times.getEventTime());
        }
        if (times.getTimezoneOffset() != null) {
            result.setCaptureOffset(times.getTimezoneOffset());
        }
        duration = times.getDuration();
    }
    // Read the pcap files to get default times
    List<Integer> appIds = readAppIDs(result);
    result.setAppIds(appIds);
    result.setTotalNoPackets(appIds.size());
    if (dresult.getTraceFile() != null && !dresult.getTraceFile().equals("")) {
        filepath = result.getTraceFile();
    } else {
        filepath = result.getTraceDirectory() + Util.FILE_SEPARATOR + TraceDataConst.FileName.TRAFFIC + TraceDataConst.FileName.CAP_EXT;
    }
    this.init();
    this.ipCountMap = result.getIpCountMap();
    result = (TraceDirectoryResult) this.readPcapTraceFile(filepath, startTime, duration, result);
    if (result == null) {
        return new TraceDirectoryResult();
    }
    for (int i = 1; ; i++) {
        filepath = result.getTraceDirectory() + Util.FILE_SEPARATOR + TraceDataConst.FileName.TRAFFIC + i + TraceDataConst.FileName.CAP_EXT;
        if (filereader.fileExist(filepath)) {
            result = (TraceDirectoryResult) this.readPcapTraceFile(filepath, startTime, duration, result);
        } else {
            break;
        }
    }
    if (result != null) {
        String secureFilePath = result.getTraceDirectory() + Util.FILE_SEPARATOR + TraceDataConst.FileName.SECURE_PCAP_FILE;
        if (filereader.fileExist(secureFilePath)) {
            try {
                isSecurePcap = true;
                result.setSecureTrace(isSecurePcap);
                this.readSecurePcapTraceFile(secureFilePath, result);
            } finally {
                isSecurePcap = false;
            }
        }
    }
    if (result == null) {
        result = new TraceDirectoryResult();
    }
    result.setAllpackets(this.allPackets);
    this.checkExternalVideoAndTime(result, startTime, duration);
    return result;
}
Also used : TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) TraceTime(com.att.aro.core.packetanalysis.pojo.TraceTime)

Aggregations

TraceTime (com.att.aro.core.packetanalysis.pojo.TraceTime)2 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)1