Search in sources :

Example 26 with Session

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

the class UnsecureSSLVersionImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    Set<UnsecureSSLVersionEntry> entries = new HashSet<>();
    try {
        List<Session> sessions = tracedata.getSessionlist();
        for (Session session : sessions) {
            Set<String> unsecureSSLVersions = getUnsecureSSLVersionsInSession(session);
            if (!unsecureSSLVersions.isEmpty()) {
                String unsecureSSLVersionsStr = stringifyUnsecureSSLVersions(unsecureSSLVersions);
                UnsecureSSLVersionEntry entry = populateEntry(session, unsecureSSLVersionsStr);
                entries.add(entry);
            }
        }
    } catch (Exception e) {
        LOGGER.error("Error happened when running unsecure SSL Versions test :: Caused by: " + e.getMessage());
    }
    return getTestResult(entries);
}
Also used : UnsecureSSLVersionEntry(com.att.aro.core.bestpractice.pojo.UnsecureSSLVersionEntry) HashSet(java.util.HashSet) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 27 with Session

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

the class ScriptsImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    ScriptsResult result = new ScriptsResult();
    for (Session session : tracedata.getSessionlist()) {
        for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
            if (req.getDirection() == HttpDirection.RESPONSE && req.getContentLength() > 0 && req.getContentType() != null && reqhelper.isHtml(req.getContentType())) {
                result = analyzeHtml(req, session, result);
            }
        }
    }
    String text = "";
    if (result.getFirstFailedHtml() == null) {
        result.setResultType(BPResultType.PASS);
        text = MessageFormat.format(textResultPass, result.getNumberOfFailedFiles());
        result.setResultText(text);
        result.setResultExcelText(BPResultType.PASS.getDescription());
    } else {
        result.setResultType(BPResultType.FAIL);
        text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), result.getNumberOfFailedFiles());
        result.setResultText(text);
        result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), result.getNumberOfFailedFiles()));
    }
    result.setAboutText(aboutText);
    result.setDetailTitle(detailTitle);
    result.setLearnMoreUrl(learnMoreUrl);
    result.setOverviewTitle(overviewTitle);
    result.setExportAllNumberOfScriptsFiles(exportAllNumberOfScriptsFiles);
    return result;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ScriptsResult(com.att.aro.core.bestpractice.pojo.ScriptsResult) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 28 with Session

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

the class Http4xx5xxImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    Http4xx5xxResult result = new Http4xx5xxResult();
    Map<Integer, HttpRequestResponseInfo> firstErrorRespMap4XX = new HashMap<Integer, HttpRequestResponseInfo>();
    SortedMap<Integer, Integer> httpErrorCounts4XX = new TreeMap<Integer, Integer>();
    List<Http4xx5xxStatusResponseCodesEntry> httpResCodelist = new ArrayList<Http4xx5xxStatusResponseCodesEntry>();
    HttpRequestResponseInfo lastRequestObj = null;
    for (Session session : tracedata.getSessionlist()) {
        lastRequestObj = null;
        for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
            if (req.getDirection() == HttpDirection.REQUEST) {
                lastRequestObj = req;
            }
            if (req.getDirection() == HttpDirection.RESPONSE && HttpRequestResponseInfo.HTTP_SCHEME.equals(req.getScheme()) && req.getStatusCode() >= 400 && req.getStatusCode() < 600) {
                Integer code = req.getStatusCode();
                Integer count = httpErrorCounts4XX.get(code);
                if (count != null) {
                    httpErrorCounts4XX.put(code, count + 1);
                } else {
                    httpErrorCounts4XX.put(code, 1);
                    firstErrorRespMap4XX.put(code, req);
                }
                httpResCodelist.add(new Http4xx5xxStatusResponseCodesEntry(req, lastRequestObj, session.getDomainName()));
            }
        }
    }
    if (httpErrorCounts4XX.isEmpty()) {
        result.setResultType(BPResultType.PASS);
        result.setResultText(textResultPass);
        result.setResultExcelText(BPResultType.PASS.getDescription());
    } else {
        result.setResultType(BPResultType.FAIL);
        result.setResultText(Http3xx4xxHelper.createFailResult(httpErrorCounts4XX, textResults, errorPlural, errorSingular));
        result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), Http3xx4xxHelper.formatErrorCodesToText(httpErrorCounts4XX)));
    }
    result.setAboutText(aboutText);
    result.setDetailTitle(detailTitle);
    result.setLearnMoreUrl(learnMoreUrl);
    result.setOverviewTitle(overviewTitle);
    result.setExportAllHttpError(exportAllHttpError);
    result.setFirstErrorRespMap4XX(firstErrorRespMap4XX);
    result.setHttpErrorCounts4XX(httpErrorCounts4XX);
    result.setHttpResCodelist(httpResCodelist);
    return result;
}
Also used : Http4xx5xxStatusResponseCodesEntry(com.att.aro.core.bestpractice.pojo.Http4xx5xxStatusResponseCodesEntry) HashMap(java.util.HashMap) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) Http4xx5xxResult(com.att.aro.core.bestpractice.pojo.Http4xx5xxResult) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 29 with Session

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

the class ImageCompressionImpl method compressImages.

private void compressImages() {
    ExecutorService exec = Executors.newFixedThreadPool(5);
    for (final Session session : packetResult.getSessionlist()) {
        for (final HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
            if (req.getDirection() == HttpDirection.RESPONSE && req.getContentType() != null && req.getContentType().contains("image/")) {
                String extractedImage = ImageHelper.extractFullNameFromRRInfo(req);
                if ((!extractedImage.isEmpty() && !(extractedImage.contains(".jpeg") || extractedImage.contains(".jpg"))) && req.getContentType().contains("jpeg")) {
                    extractedImage = Util.parseImageName(extractedImage, req);
                }
                File imgFile = new File(imageFolderPath + extractedImage);
                if (imgFile.exists() && !imgFile.isDirectory()) {
                    int posExtn = extractedImage.lastIndexOf(".");
                    String imgExtn = extractedImage.substring(posExtn + 1, extractedImage.length());
                    if (Util.isJPG(imgFile, imgExtn)) {
                        final String imageFile = extractedImage;
                        exec.submit(new Runnable() {

                            @Override
                            public void run() {
                                compressImage(imageFolderPath, imageFile);
                            }
                        });
                    }
                }
            }
        }
    }
    try {
        // Time out after 10 minutes
        exec.shutdown();
        exec.awaitTermination(10, TimeUnit.MINUTES);
    } catch (InterruptedException e) {
        LOGGER.error(e.getMessage(), e);
    }
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ExecutorService(java.util.concurrent.ExecutorService) File(java.io.File) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 30 with Session

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

the class VideoNetworkComparisonImpl method getAvgThroughput.

private double getAvgThroughput(PacketAnalyzerResult tracedata) {
    double avgKbps;
    int curMaxLength = 0;
    for (Session session : tracedata.getSessionlist()) {
        double startTime = 0;
        int tempLength = 0;
        for (PacketInfo packetInfo : session.getTcpPackets()) {
            if (startTime == 0) {
                // give the initial value
                startTime = packetInfo.getTimeStamp();
            }
            if (startTime + 1 > packetInfo.getTimeStamp()) {
                tempLength += packetInfo.getPayloadLen();
            } else {
                if (curMaxLength < tempLength) {
                    curMaxLength = tempLength;
                    LOGGER.debug("packetInfo: " + packetInfo.getPacketId() + " packet Time: " + packetInfo.getTimeStamp() + " find the bigger max: " + curMaxLength);
                }
                // reset value
                tempLength = packetInfo.getPayloadLen();
                startTime = packetInfo.getTimeStamp();
            }
        }
    }
    // kbps
    avgKbps = (double) curMaxLength * 8 / 1024;
    return avgKbps;
}
Also used : PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) Session(com.att.aro.core.packetanalysis.pojo.Session)

Aggregations

Session (com.att.aro.core.packetanalysis.pojo.Session)130 ArrayList (java.util.ArrayList)86 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)74 BaseTest (com.att.aro.core.BaseTest)49 Test (org.junit.Test)49 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)32 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)31 InetAddress (java.net.InetAddress)26 HashMap (java.util.HashMap)19 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)17 HashSet (java.util.HashSet)11 TreeMap (java.util.TreeMap)11 List (java.util.List)10 Statistic (com.att.aro.core.packetanalysis.pojo.Statistic)9 File (java.io.File)9 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)8 DomainNameSystem (com.att.aro.core.packetreader.pojo.DomainNameSystem)8 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)7 HttpRequestResponseInfoWithSession (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfoWithSession)7 UDPPacket (com.att.aro.core.packetreader.pojo.UDPPacket)7