Search in sources :

Example 1 with PacketAnalyzerResult

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

the class AROServiceImpl method analyzeFile.

/**
 * Launches an analysis of a traceFile with the results populating an
 * AROTraceData object
 *
 * @param requests
 *            list of BestPracticeType bestPractices to analyze
 * @param traceFile
 *            path to a pcap trace file, usually traffic.cap
 * @param profile
 *            device profile used as a model of the device when analyzing
 *            trace data
 * @param filter
 *            used for filtering information from a trace analysis based on
 *            a specified time range and set of ApplicationSelection
 *            objects.
 * @return AROTraceData object
 * @throws IOException
 *             if trace file not found
 */
@Override
public AROTraceData analyzeFile(List<BestPracticeType> requests, String traceFile, Profile profile, AnalysisFilter filter) throws IOException {
    AROTraceData data = new AROTraceData();
    try {
        PacketAnalyzerResult result = packetanalyzer.analyzeTraceFile(traceFile, profile, filter);
        if (result == null) {
            data.setError(ErrorCodeRegistry.getTraceFileNotAnalyzed());
        } else {
            if (result.getTraceresult().getAllpackets().size() == 0) {
                // we set on purpose
                data.setError(ErrorCodeRegistry.getUnRecognizedPackets());
                data.setSuccess(false);
            } else {
                List<AbstractBestPracticeResult> bestPractices = analyze(result, requests);
                bestPractices.addAll(createEmptyResults());
                data.setAnalyzerResult(result);
                data.setBestPracticeResults(bestPractices);
                data.setSuccess(true);
            }
        }
    } catch (TsharkException ex) {
        data.setError(ErrorCodeRegistry.getWiresharkError());
    }
    return data;
}
Also used : AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) TsharkException(com.att.aro.core.exception.TsharkException) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) AROTraceData(com.att.aro.core.pojo.AROTraceData)

Example 2 with PacketAnalyzerResult

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

the class AROServiceImpl method analyzeDirectory.

/**
 * Launches an analysis of a trace directory with the results populating an
 * AROTraceData object.
 * <p>
 * Other trace files depend on capture method, platform and version of
 * device.
 * </p>
 *
 * @param requests
 *            list of BestPracticeType bestPractices to analyze
 * @param traceDirectory
 *            path to a trace directory, usually contains traffic.cap
 * @param profile
 *            device profile used as a model of the device when analyzing
 *            trace data
 * @param filter
 *            used for filtering information from a trace analysis based on
 *            a specified time range and set of ApplicationSelection
 *            objects.
 * @return AROTraceData object
 * @throws IOException
 *             if trace file not found
 */
@Override
public AROTraceData analyzeDirectory(List<BestPracticeType> requests, String traceDirectory, Profile profile, AnalysisFilter filter) throws IOException {
    AROTraceData data = new AROTraceData();
    PacketAnalyzerResult result = null;
    if (!filemanager.fileExist(traceDirectory + Util.FILE_SEPARATOR + "traffic.cap")) {
        data.setError(ErrorCodeRegistry.getTrafficFileNotFound());
        data.setSuccess(false);
    } else {
        try {
            result = packetanalyzer.analyzeTraceDirectory(traceDirectory, profile, filter);
        } catch (FileNotFoundException ex) {
            data.setError(ErrorCodeRegistry.getTraceDirNotFound());
            return data;
        } catch (TsharkException ex) {
            data.setError(ErrorCodeRegistry.getWiresharkError());
            return data;
        }
        if (result == null) {
            data.setError(ErrorCodeRegistry.getTraceDirectoryNotAnalyzed());
            data.setSuccess(false);
        } else {
            if (result.getTraceresult() == null) {
                // we set this on purpose
                data.setSuccess(false);
                data.setError(ErrorCodeRegistry.getUnRecognizedPackets());
            } else if (result.getTraceresult().getAllpackets() == null || result.getTraceresult().getAllpackets().size() == 0) {
                data.setSuccess(false);
                data.setError(ErrorCodeRegistry.getPacketsNotFound());
            } else {
                List<AbstractBestPracticeResult> bestPractices = analyze(result, requests);
                bestPractices.addAll(createEmptyResults());
                data.setAnalyzerResult(result);
                data.setBestPracticeResults(bestPractices);
                data.setSuccess(true);
            }
        }
    }
    return data;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) TsharkException(com.att.aro.core.exception.TsharkException) ArrayList(java.util.ArrayList) List(java.util.List) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) AROTraceData(com.att.aro.core.pojo.AROTraceData)

Example 3 with PacketAnalyzerResult

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

the class HtmlReportImpl method reportGenerator.

@Override
public boolean reportGenerator(String resultFilePath, AROTraceData results) {
    if (results == null) {
        return false;
    }
    PacketAnalyzerResult analyzerResults = results.getAnalyzerResult();
    List<AbstractBestPracticeResult> bpResults = results.getBestPracticeResults();
    StringBuilder htmlString = new StringBuilder(200);
    htmlString.append(getHtmlHead());
    htmlString.append("	<body>");
    htmlString.append(System.getProperty(lineSeperator()));
    htmlString.append("		<table class='table'>");
    htmlString.append(System.getProperty(lineSeperator()));
    htmlString.append(getTableHeader(analyzerResults));
    htmlString.append(getTraceRows(analyzerResults));
    htmlString.append(getTimeRangeAnalysisAndStatisticRows(analyzerResults));
    htmlString.append(getBPSummaryRows(bpResults));
    htmlString.append("<tr><th></th><td></td></tr><tr><th>Best Practices Results</th><td></td></tr>\n");
    htmlString.append(getBpRows(bpResults));
    htmlString.append("		</table>");
    htmlString.append(System.getProperty(lineSeperator()));
    htmlString.append(System.getProperty(lineSeperator()));
    htmlString.append("	</body>");
    htmlString.append(System.getProperty(lineSeperator()));
    htmlString.append("</html>");
    try {
        File file = filereader.createFile(resultFilePath);
        PrintWriter writer = new PrintWriter(file);
        writer.println(htmlString.toString());
        writer.close();
        return true;
    } catch (IOException e) {
        LOGGER.info("IOException: " + e);
    }
    return false;
}
Also used : AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) IOException(java.io.IOException) File(java.io.File) PrintWriter(java.io.PrintWriter)

Example 4 with PacketAnalyzerResult

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

the class AROServiceImplTest method analyzeFileNullTest.

@Test
public void analyzeFileNullTest() throws IOException {
    PacketAnalyzerResult analyze = new PacketAnalyzerResult();
    TraceFileResult traceresult = new TraceFileResult();
    List<PacketInfo> allpackets = new ArrayList<PacketInfo>();
    allpackets.add(new PacketInfo(new Packet(0, 0, 0, 0, null)));
    analyze.setTraceresult(traceresult);
    List<BestPracticeType> req = new ArrayList<BestPracticeType>();
    req.add(BestPracticeType.UNNECESSARY_CONNECTIONS);
    AROTraceData testResult = aro.analyzeFile(req, "traffic.cap");
    assertEquals(null, testResult.getBestPracticeResults());
}
Also used : Packet(com.att.aro.core.packetreader.pojo.Packet) ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) BestPracticeType(com.att.aro.core.bestpractice.pojo.BestPracticeType) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) TraceFileResult(com.att.aro.core.packetanalysis.pojo.TraceFileResult) AROTraceData(com.att.aro.core.pojo.AROTraceData) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Example 5 with PacketAnalyzerResult

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

the class BpTestStatisticsPanel method refresh.

@Override
public void refresh(AROTraceData model) {
    PacketAnalyzerResult analyzerResults = model.getAnalyzerResult();
    // Total Data Transferred\:
    totalDataLabel.setText(MessageFormat.format(ResourceBundleHelper.getMessageString("bestPractices.totalDataTransferedValue"), intFormat.format(analyzerResults.getStatistic().getTotalByte())));
    // Total Payload Data Transferred\:
    totalPayloadDataLabel.setText(MessageFormat.format(ResourceBundleHelper.getMessageString("bestPractices.totalPayloadDataValue"), intFormat.format(analyzerResults.getStatistic().getTotalPayloadBytes())));
    // Duration:
    String duration = decFormat.format(analyzerResults.getTraceresult().getTraceDuration() / 60);
    durationLabel.setText(MessageFormat.format(ResourceBundleHelper.getMessageString("bestPractices.durationValue"), duration));
    // Energy Consumed:
    energyConsumedLabel.setText(MessageFormat.format(ResourceBundleHelper.getMessageString("bestPractices.energyConsumedValue"), decFormat.format(analyzerResults.getEnergyModel().getTotalEnergyConsumed())));
    // Attenuator :
    if (TraceResultType.TRACE_DIRECTORY.equals(model.getAnalyzerResult().getTraceresult().getTraceResultType())) {
        TraceDirectoryResult traceResult = (TraceDirectoryResult) model.getAnalyzerResult().getTraceresult();
        CollectOptions collectOptions = traceResult.getCollectOptions();
        if (collectOptions != null) {
            setSpeedThrottleValue(collectOptions);
        }
    } else {
        clearSpeedThrottleValue();
    }
}
Also used : CollectOptions(com.att.aro.core.peripheral.pojo.CollectOptions) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)

Aggregations

PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)37 BaseTest (com.att.aro.core.BaseTest)11 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)11 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)10 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)7 Session (com.att.aro.core.packetanalysis.pojo.Session)7 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)7 AROTraceData (com.att.aro.core.pojo.AROTraceData)6 BestPracticeType (com.att.aro.core.bestpractice.pojo.BestPracticeType)5 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)5 Packet (com.att.aro.core.packetreader.pojo.Packet)5 MainFrame (com.att.aro.ui.view.MainFrame)5 List (java.util.List)5 Profile (com.att.aro.core.configuration.pojo.Profile)4 AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)4 Statistic (com.att.aro.core.packetanalysis.pojo.Statistic)4 File (java.io.File)4 IBestPractice (com.att.aro.core.bestpractice.IBestPractice)3 BPResultType (com.att.aro.core.bestpractice.pojo.BPResultType)3