Search in sources :

Example 1 with RequestResponseTimeline

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

the class WaterfallPanel method refresh.

/**
 * Refreshes the waterfall display with the specified analysis data
 * @param Analyzed data from aro core.
 */
public void refresh(AROTraceData aModel) {
    this.data = aModel;
    this.popup.refresh(null, 0);
    this.popup.setVisible(false);
    // Create sorted list of request/response pairs
    categoryList = new ArrayList<WaterfallCategory>();
    if (aModel != null && aModel.getAnalyzerResult() != null) {
        this.traceDuration = aModel.getAnalyzerResult().getTraceresult().getTraceDuration();
        // add 20% to make sure labels close to the right edge of the screen are visible
        this.traceDuration *= 1.2;
        for (Session tcpSession : aModel.getAnalyzerResult().getSessionlist()) {
            Session thisSession = tcpSession;
            if (!tcpSession.isUdpOnly()) {
                for (HttpRequestResponseInfo reqResInfo : tcpSession.getRequestResponseInfo()) {
                    if (reqResInfo.getDirection() == HttpDirection.REQUEST && reqResInfo.getWaterfallInfos() != null) {
                        categoryList.add(new WaterfallCategory(reqResInfo, thisSession));
                    }
                }
            }
        }
        // Sort and set index
        Collections.sort(categoryList);
        int index = 0;
        for (WaterfallCategory wCategory : categoryList) {
            wCategory.setIndex(++index);
        }
    }
    // Horizontal scroll bar used to scroll through trace duration
    JScrollBar hScrollBar = getHorizontalScroll();
    hScrollBar.setMaximum((int) Math.ceil(this.traceDuration));
    CategoryAxis cAxis = getCategoryAxis();
    cAxis.clearCategoryLabelToolTips();
    DefaultCategoryDataset underlying = new DefaultCategoryDataset();
    for (WaterfallCategory wfc : categoryList) {
        RequestResponseTimeline rrTimeLine = wfc.getReqResp().getWaterfallInfos();
        underlying.addValue(rrTimeLine.getStartTime(), Waterfall.BEFORE, wfc);
        underlying.addValue(rrTimeLine.getDnsLookupDuration(), Waterfall.DNS_LOOKUP, wfc);
        underlying.addValue(rrTimeLine.getInitialConnDuration(), Waterfall.INITIAL_CONNECTION, wfc);
        underlying.addValue(rrTimeLine.getSslNegotiationDuration(), Waterfall.SSL_NEGOTIATION, wfc);
        underlying.addValue(rrTimeLine.getRequestDuration(), Waterfall.REQUEST_TIME, wfc);
        underlying.addValue(rrTimeLine.getTimeToFirstByte(), Waterfall.TIME_TO_FIRST_BYTE, wfc);
        underlying.addValue(rrTimeLine.getContentDownloadDuration(), Waterfall.CONTENT_DOWNLOAD, wfc);
        underlying.addValue(null, Waterfall.HTTP_3XX_REDIRECTION, wfc);
        underlying.addValue(null, Waterfall.HTTP_4XX_CLIENTERROR, wfc);
        int code = wfc.getReqResp().getAssocReqResp().getStatusCode();
        double endTime = this.traceDuration - rrTimeLine.getStartTime() - rrTimeLine.getTotalTime();
        if (code >= 300 && code < 400) {
            underlying.addValue(endTime, Waterfall.AFTER_3XX, wfc);
        } else if (code >= 400) {
            underlying.addValue(endTime, Waterfall.AFTER_4XX, wfc);
        } else {
            underlying.addValue(endTime, Waterfall.AFTER, wfc);
        }
        cAxis.addCategoryLabelToolTip(wfc, wfc.getTooltip());
    }
    // Vertical scroll bar is used to scroll through data
    JScrollBar vScrollBar = getVerticalScroll();
    int count = underlying.getColumnCount();
    vScrollBar.setValue(0);
    vScrollBar.setMaximum(count);
    vScrollBar.setVisibleAmount(count > 0 ? this.dataset.getMaximumCategoryCount() - 1 / count : 1);
    // Add the dataset to the plot
    CategoryPlot plot = getChartPanel().getChart().getCategoryPlot();
    this.dataset = new SlidingCategoryDataset(underlying, 0, CATEGORY_MAX_COUNT);
    plot.setDataset(this.dataset);
    // Set the visible time range
    setTimeRange(startGraphRange, startGraphRange + 100);
    // Place proper colors on renderer for waterfall states
    final CategoryItemRenderer renderer = plot.getRenderer();
    for (Object obj : underlying.getRowKeys()) {
        Waterfall wFall = (Waterfall) obj;
        int index = underlying.getRowIndex(wFall);
        Color paint;
        switch(wFall) {
            case DNS_LOOKUP:
                paint = dnsLoolupColor;
                break;
            case INITIAL_CONNECTION:
                paint = initiaConnColor;
                break;
            case SSL_NEGOTIATION:
                paint = sslNegColor;
                break;
            case REQUEST_TIME:
                paint = requestTimeColor;
                break;
            case TIME_TO_FIRST_BYTE:
                paint = firstByteTimeColor;
                break;
            case CONTENT_DOWNLOAD:
                paint = contentDownloadColor;
                break;
            case INACTIVE:
                paint = inactiveConnectionColor;
                break;
            case AFTER_3XX:
                paint = noneColor;
                renderer.setSeriesItemLabelPaint(index, threexColor);
                renderer.setSeriesVisibleInLegend(index, false);
                break;
            case AFTER_4XX:
                paint = noneColor;
                renderer.setSeriesItemLabelPaint(index, fourxColor);
                renderer.setSeriesVisibleInLegend(index, false);
                break;
            case HTTP_3XX_REDIRECTION:
                paint = threexColor;
                break;
            case HTTP_4XX_CLIENTERROR:
                paint = fourxColor;
                break;
            default:
                renderer.setSeriesItemLabelPaint(index, Color.black);
                renderer.setSeriesVisibleInLegend(index, false);
                paint = noneColor;
        }
        renderer.setSeriesPaint(index, paint);
    }
    // Adding the label at the end of bars
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator() {

        private static final long serialVersionUID = 1L;

        @Override
        public String generateLabel(CategoryDataset dataset, int row, int column) {
            if (Waterfall.AFTER == dataset.getRowKey(row) || Waterfall.AFTER_3XX == dataset.getRowKey(row) || Waterfall.AFTER_4XX == dataset.getRowKey(row)) {
                WaterfallCategory waterfallItem = (WaterfallCategory) dataset.getColumnKey(column);
                RequestResponseTimeline waterfallInfos = waterfallItem.getReqResp().getWaterfallInfos();
                DecimalFormat formatter = new DecimalFormat("#.##");
                int code = waterfallItem.getReqResp().getAssocReqResp().getStatusCode();
                return MessageFormat.format(getMessageString("waterfall.totalTime"), formatter.format(waterfallInfos.getTotalTime()), code > 0 ? waterfallItem.getReqResp().getScheme() + " " + code : getMessageString("waterfall.unknownCode"));
            }
            return null;
        }
    });
    new Thread(() -> setCrosshairs(aModel)).start();
}
Also used : StandardCategoryItemLabelGenerator(org.jfree.chart.labels.StandardCategoryItemLabelGenerator) RequestResponseTimeline(com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) Color(java.awt.Color) DecimalFormat(java.text.DecimalFormat) ResourceBundleHelper.getMessageString(com.att.aro.ui.utils.ResourceBundleHelper.getMessageString) CategoryPlot(org.jfree.chart.plot.CategoryPlot) SlidingCategoryDataset(org.jfree.data.category.SlidingCategoryDataset) JScrollBar(javax.swing.JScrollBar) CategoryAxis(org.jfree.chart.axis.CategoryAxis) SlidingCategoryDataset(org.jfree.data.category.SlidingCategoryDataset) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) WaterfallCategory(com.att.aro.ui.model.waterfall.WaterfallCategory) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 2 with RequestResponseTimeline

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

the class WaterfallPopup method refresh.

// TODO find how to do refresh...once we get the data.
/**
 * Refreshes the popup window with data from the specified request/response
 * @param req The request/response pair.  Direction must be REQUEST and
 * response will be read from request.
 */
public void refresh(HttpRequestResponseInfo req, int index) {
    if (req == null) {
        this.setVisible(false);
    } else {
        this.setAlwaysOnTop(true);
        this.setTitle(MessageFormat.format(ResourceBundleHelper.getMessageString("waterfall.popupTitle"), index));
        // Check to see if request/response is already displayed
        if (req.equals(reqResp)) {
            return;
        }
        // Check for valid argument - only HTTP requests
        if (req.getDirection() != HttpDirection.REQUEST || req.getWaterfallInfos() == null) {
            throw new IllegalArgumentException("Invalid request object");
        }
        RequestResponseTimeline rrTimeLine = req.getWaterfallInfos();
        HttpRequestResponseInfo resp = req.getAssocReqResp();
        NumberFormat secFmt = NumberFormat.getNumberInstance();
        secFmt.setMaximumFractionDigits(3);
        NumberFormat kbFmt = NumberFormat.getNumberInstance();
        kbFmt.setMaximumFractionDigits(1);
        if (req.getObjUri() == null) {
            urlValueLabel.setText(req.getObjName());
        } else {
            urlValueLabel.setText(req.getObjUri().toString());
        }
        // urlValueLabel.setText(req.getObjUri() != null ? req.getObjUri().toString() : req.getObjName());
        hostValueLabel.setText(req.getHostName());
        // ipValueLabel.setText(req.getSession().getRemoteIP().getHostAddress());
        ipValueLabel.setText(req.getFirstDataPacket().getRemoteIPAddress().getHostAddress());
        if (resp.getStatusLine() == null) {
            statusValueLabel.setText(ResourceBundleHelper.getMessageString("waterfall.unknownCode"));
        } else {
            statusValueLabel.setText(resp.getStatusLine());
        }
        // statusValueLabel.setText(resp.getStatusLine() != null ? resp.getStatusLine() : ResourceBundleHelper.getMessageString("waterfall.unknownCode"));
        startValueLabel.setText(MessageFormat.format(W_SECONDS, secFmt.format(rrTimeLine.getStartTime())));
        refreshWaterfallLabel(dnsValueLabel, rrTimeLine.getDnsLookupDuration());
        refreshWaterfallLabel(initConnValueLabel, rrTimeLine.getInitialConnDuration());
        refreshWaterfallLabel(sslValueLabel, rrTimeLine.getSslNegotiationDuration());
        refreshWaterfallLabel(reqTimeValueLabel, rrTimeLine.getRequestDuration());
        refreshWaterfallLabel(firstByteValueLabel, rrTimeLine.getTimeToFirstByte());
        refreshWaterfallLabel(contentValueLabel, rrTimeLine.getContentDownloadDuration());
        bytesInValueLabel.setText(MessageFormat.format(W_KB, kbFmt.format(resp.getRawSizeInKB())));
        bytesOutValueLabel.setText(MessageFormat.format(W_KB, kbFmt.format(req.getRawSizeInKB())));
        getRequestPanel().refresh(req);
        getResponsePanel().refresh(resp);
    }
    this.reqResp = req;
}
Also used : RequestResponseTimeline(com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) NumberFormat(java.text.NumberFormat)

Example 3 with RequestResponseTimeline

use of com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline 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)

Aggregations

HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)3 RequestResponseTimeline (com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline)3 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)1 Session (com.att.aro.core.packetanalysis.pojo.Session)1 WaterfallCategory (com.att.aro.ui.model.waterfall.WaterfallCategory)1 ResourceBundleHelper.getMessageString (com.att.aro.ui.utils.ResourceBundleHelper.getMessageString)1 Color (java.awt.Color)1 DecimalFormat (java.text.DecimalFormat)1 NumberFormat (java.text.NumberFormat)1 JScrollBar (javax.swing.JScrollBar)1 CategoryAxis (org.jfree.chart.axis.CategoryAxis)1 StandardCategoryItemLabelGenerator (org.jfree.chart.labels.StandardCategoryItemLabelGenerator)1 CategoryPlot (org.jfree.chart.plot.CategoryPlot)1 CategoryItemRenderer (org.jfree.chart.renderer.category.CategoryItemRenderer)1 CategoryDataset (org.jfree.data.category.CategoryDataset)1 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)1 SlidingCategoryDataset (org.jfree.data.category.SlidingCategoryDataset)1