Search in sources :

Example 96 with HttpRequestResponseInfo

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

the class SessionManagerImpl method populateWaterfallContent.

private void populateWaterfallContent(Session session) {
    Double sslNegotiationDuration = null;
    double contentDownloadDuration = 0;
    double requestDuration = 0;
    double timeToFirstByte = 0;
    Double dnsTime = null;
    Double synTime = null;
    if (session.getDnsRequestPacket() != null && session.getDnsResponsePacket() != null) {
        dnsTime = session.getDnsRequestPacket().getTimeStamp();
    }
    Double sslNegTime = null;
    PacketInfo handshake = session.getLastSslHandshakePacket();
    if (handshake != null) {
        sslNegTime = handshake.getTimeStamp();
    }
    for (HttpRequestResponseInfo rrinfo : session.getRequestResponseInfo()) {
        if (rrinfo.getDirection() != HttpDirection.REQUEST || rrinfo.getAssocReqResp() == null || rrinfo.getFirstDataPacket() == null) {
            // Only process non-HTTPS request/response pairs
            continue;
        }
        double startTime = -1;
        double firstReqPacket = rrinfo.getFirstDataPacket().getTimeStamp();
        PacketInfo lastPkt = rrinfo.getLastDataPacket();
        double lastReqPacket = lastPkt != null ? lastPkt.getTimeStamp() : -1;
        HttpRequestResponseInfo resp = rrinfo.getAssocReqResp();
        // check getAssocReqResp firstDataPacket and lastDataPacket packet
        if (resp == null || resp.getFirstDataPacket() == null || resp.getLastDataPacket() == null) {
            continue;
        }
        double firstRespPacket = resp.getFirstDataPacket().getTimeStamp();
        double lastRespPacket = resp.getLastDataPacket().getTimeStamp();
        // Add DNS and initial connect to fist req/resp pair only
        Double dnsDuration = null;
        if (dnsTime != null) {
            startTime = dnsTime.doubleValue();
            if (synTime != null) {
                dnsDuration = synTime.doubleValue() - dnsTime.doubleValue();
            } else {
                dnsDuration = firstReqPacket - dnsTime.doubleValue();
            }
            // Prevent from being added again
            dnsTime = null;
        }
        Double initConnDuration = null;
        if (synTime != null) {
            initConnDuration = firstReqPacket - synTime;
            if (startTime < 0.0) {
                startTime = synTime.doubleValue();
            }
            // Prevent from being added again
            synTime = null;
        }
        // Calculate request time
        if (startTime < 0.0) {
            startTime = firstReqPacket;
        }
        // Store waterfall in request/response
        if (sslNegTime != null && lastRespPacket >= sslNegTime) {
            sslNegotiationDuration = sslNegTime - firstReqPacket;
            contentDownloadDuration = lastRespPacket - sslNegTime;
        } else {
            if (firstRespPacket >= lastReqPacket && lastReqPacket != -1) {
                contentDownloadDuration = lastRespPacket - firstRespPacket;
                requestDuration = lastReqPacket - firstReqPacket;
                timeToFirstByte = firstRespPacket - lastReqPacket;
            } else {
                contentDownloadDuration = lastRespPacket - firstReqPacket;
            }
        }
        RequestResponseTimeline reqRespTimeline = new RequestResponseTimeline(startTime, dnsDuration, initConnDuration, sslNegotiationDuration, requestDuration, timeToFirstByte, contentDownloadDuration);
        rrinfo.setWaterfallInfos(reqRespTimeline);
        rrinfo.getWaterfallInfos().setLastRespPacketTime(lastRespPacket);
    }
}
Also used : RequestResponseTimeline(com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo)

Example 97 with HttpRequestResponseInfo

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

the class Http10UsageImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    Http10UsageResult result = new Http10UsageResult();
    int http10HeaderCount = 0;
    Session http10Session = null;
    for (Session session : tracedata.getSessionlist()) {
        for (HttpRequestResponseInfo httpreq : session.getRequestResponseInfo()) {
            if (HttpRequestResponseInfo.HTTP10.equals(httpreq.getVersion())) {
                ++http10HeaderCount;
                if (http10Session == null) {
                    http10Session = session;
                }
            }
        }
    }
    result.setHttp10Session(http10Session);
    result.setHttp10HeaderCount(http10HeaderCount);
    if (http10HeaderCount == 0) {
        result.setResultType(BPResultType.PASS);
        result.setResultText(MessageFormat.format(textResultPass, ApplicationConfig.getInstance().getAppShortName(), http10HeaderCount));
    } else {
        // ref. old analyzer give warning in this best practice
        result.setResultType(BPResultType.WARNING);
        result.setResultText(MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), http10HeaderCount));
    }
    result.setAboutText(aboutText);
    result.setDetailTitle(detailTitle);
    result.setLearnMoreUrl(learnMoreUrl);
    result.setOverviewTitle(overviewTitle);
    result.setExportAllHttpHeaderDesc(exportAllHttpHeaderDesc);
    return result;
}
Also used : Http10UsageResult(com.att.aro.core.bestpractice.pojo.Http10UsageResult) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 98 with HttpRequestResponseInfo

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

the class Http3xxCodeImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    Http3xxCodeResult result = new Http3xxCodeResult();
    SortedMap<Integer, Integer> httpRedirectCounts3XX = new TreeMap<Integer, Integer>();
    Map<Integer, HttpRequestResponseInfo> firstResMap = new HashMap<Integer, HttpRequestResponseInfo>();
    List<HttpCode3xxEntry> httprescodelist = new ArrayList<HttpCode3xxEntry>();
    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() >= 300 && req.getStatusCode() < 400) {
                Integer code = req.getStatusCode();
                Integer count = httpRedirectCounts3XX.get(code);
                if (count != null) {
                    httpRedirectCounts3XX.put(code, count + 1);
                } else {
                    httpRedirectCounts3XX.put(code, 1);
                    firstResMap.put(code, req);
                }
                httprescodelist.add(new HttpCode3xxEntry(req, lastRequestObj, session.getDomainName()));
            }
        }
    }
    if (httpRedirectCounts3XX.isEmpty()) {
        result.setResultType(BPResultType.PASS);
        result.setResultText(textResultPass);
        result.setResultExcelText(BPResultType.PASS.getDescription());
    } else {
        result.setResultType(BPResultType.FAIL);
        result.setResultText(Http3xx4xxHelper.createFailResult(httpRedirectCounts3XX, textResults, errorPlural, errorSingular));
        result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), Http3xx4xxHelper.formatErrorCodesToText(httpRedirectCounts3XX)));
    }
    result.setAboutText(aboutText);
    result.setDetailTitle(detailTitle);
    result.setLearnMoreUrl(learnMoreUrl);
    result.setOverviewTitle(overviewTitle);
    result.setExportAllHttpError(exportAllHttpError);
    result.setHttp3xxResCode(httprescodelist);
    result.setHttpRedirectCounts3XX(httpRedirectCounts3XX);
    result.setFirstResMap(firstResMap);
    return result;
}
Also used : HashMap(java.util.HashMap) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) Http3xxCodeResult(com.att.aro.core.bestpractice.pojo.Http3xxCodeResult) TreeMap(java.util.TreeMap) HttpCode3xxEntry(com.att.aro.core.bestpractice.pojo.HttpCode3xxEntry) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 99 with HttpRequestResponseInfo

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

the class ImageFormatImpl method formatImages.

private void formatImages() {
    ExecutorService exec = Executors.newFixedThreadPool(5);
    for (final Session session : tracedataResult.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)) {
                        formatImage(extractedImage);
                    }
                }
            }
        }
    }
    try {
        // Time out after 10 minutes
        exec.shutdown();
        exec.awaitTermination(10, TimeUnit.MINUTES);
    } catch (InterruptedException e) {
        LOGGER.error("Image Format execution exception : ", 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 100 with HttpRequestResponseInfo

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

the class PeriodicTransferImpl method findPeriodicalBursts.

/**
 * Loops through all the HTTP requests in all TCP session.
 * If the host/object in the HTTP request is in the provided list of hosts/objects and
 * the first data packet associated with the HTTP request is the first uplink payload packet from the burst then
 * increase periodic count by one and mark the burst periodical.
 *
 * @param hostPeriodicInfoSet
 * @param hostList
 * @param objList
 * @param burst
 * @param firstUplinkPayloadPacket
 */
private int findPeriodicalBursts(Set<String> hostPeriodicInfoSet, Set<String> hostList, Set<String> objList, Burst burst, PacketInfo firstUplinkPayloadPacket, List<Session> sessionlist) {
    int periodicCount = 0;
    for (Session session : sessionlist) {
        if (!session.isUdpOnly()) {
            for (HttpRequestResponseInfo httpInfo : session.getRequestResponseInfo()) {
                if (httpInfo.getDirection() == HttpDirection.REQUEST && (hostList.contains(httpInfo.getHostName()) || objList.contains(httpInfo.getObjNameWithoutParams())) && (httpInfo.getFirstDataPacket() == firstUplinkPayloadPacket)) {
                    // remove nested if statement because PMD rule
                    periodicCount++;
                    burst.setBurstInfo(BurstCategory.PERIODICAL);
                    burst.setFirstUplinkDataPacket(firstUplinkPayloadPacket);
                    if (hostList.contains(httpInfo.getHostName())) {
                        hostPeriodicInfoSet.add(httpInfo.getHostName());
                    } else {
                        hostPeriodicInfoSet.add(httpInfo.getObjNameWithoutParams());
                    }
                    continue;
                }
            }
        }
    }
    return periodicCount;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) Session(com.att.aro.core.packetanalysis.pojo.Session)

Aggregations

HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)108 Session (com.att.aro.core.packetanalysis.pojo.Session)74 ArrayList (java.util.ArrayList)62 BaseTest (com.att.aro.core.BaseTest)40 Test (org.junit.Test)40 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)29 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)14 IOException (java.io.IOException)10 HashMap (java.util.HashMap)10 TreeMap (java.util.TreeMap)10 File (java.io.File)9 IHttpRequestResponseHelper (com.att.aro.core.packetanalysis.IHttpRequestResponseHelper)5 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)5 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)5 URISyntaxException (java.net.URISyntaxException)5 List (java.util.List)5 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)4 RequestResponseTimeline (com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 InetAddress (java.net.InetAddress)4