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;
}
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;
}
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;
}
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());
}
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();
}
}
Aggregations