Search in sources :

Example 1 with BurstCategory

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

the class BurstCollectionAnalysisImpl method analyzeBurstStat.

/**
 * Method to assign the states for all the bursts.
 *
 * @param analyzeBeginTime
 * @param analyseEndTime
 * @return
 */
private List<BurstAnalysisInfo> analyzeBurstStat(List<Burst> burstCollection) {
    Map<BurstCategory, Double> burstCategoryToEnergy = new EnumMap<BurstCategory, Double>(BurstCategory.class);
    Map<BurstCategory, Long> burstCategoryToPayload = new EnumMap<BurstCategory, Long>(BurstCategory.class);
    Map<BurstCategory, Double> burstCategoryToActive = new EnumMap<BurstCategory, Double>(BurstCategory.class);
    List<BurstAnalysisInfo> burstAnalysisInfo = new ArrayList<BurstAnalysisInfo>();
    long totalPayload = 0;
    double totalAct = 0.0;
    double totalEnergy = 0.0;
    for (Burst aBurst : burstCollection) {
        BurstCategory category = aBurst.getBurstCategory();
        double energy = aBurst.getEnergy();
        totalEnergy += energy;
        Double catEnergy = burstCategoryToEnergy.get(category);
        double catEnergygValue = catEnergy != null ? catEnergy.doubleValue() : 0.0;
        catEnergygValue += energy;
        burstCategoryToEnergy.put(category, catEnergygValue);
        int bPayLoadLength = getPayloadLength(aBurst, false);
        totalPayload += bPayLoadLength;
        Long payload = burstCategoryToPayload.get(category);
        long payLoadValue = payload != null ? payload.longValue() : 0L;
        payLoadValue += bPayLoadLength;
        burstCategoryToPayload.put(category, payLoadValue);
        double activeTime = aBurst.getActiveTime();
        totalAct += activeTime;
        Double catAct = burstCategoryToActive.get(category);
        catEnergygValue = catAct != null ? catAct.doubleValue() : 0.0;
        catEnergygValue += activeTime;
        burstCategoryToActive.put(category, catEnergygValue);
    }
    for (Map.Entry<BurstCategory, Double> entry : burstCategoryToEnergy.entrySet()) {
        BurstCategory categ = entry.getKey();
        long catPayload = burstCategoryToPayload.get(categ);
        double catEnergy = burstCategoryToEnergy.get(categ);
        double catActive = burstCategoryToActive.get(categ);
        Double jpkb = catPayload > 0 ? catEnergy / (catPayload * 8 / 1000.0f) : null;
        burstAnalysisInfo.add(new BurstAnalysisInfo(categ, catPayload, totalPayload > 0 ? (((double) catPayload / totalPayload) * 100.0) : 0, catEnergy, totalEnergy > 0.0 ? ((catEnergy / totalEnergy) * 100.0) : 0.0, catActive, totalAct > 0.0 ? ((catActive / totalAct) * 100.0) : 0.0, jpkb));
    }
    return burstAnalysisInfo;
}
Also used : ArrayList(java.util.ArrayList) BurstCategory(com.att.aro.core.packetanalysis.pojo.BurstCategory) BurstAnalysisInfo(com.att.aro.core.packetanalysis.pojo.BurstAnalysisInfo) Burst(com.att.aro.core.packetanalysis.pojo.Burst) EnumMap(java.util.EnumMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) EnumMap(java.util.EnumMap)

Example 2 with BurstCategory

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

the class ConnectionStatisticsChartPanel method generateDataForChart.

private ConnectionStatisticsInfo generateDataForChart() {
    ConnectionStatisticsInfo connectionStatisticsPojo = new ConnectionStatisticsInfo();
    double sessionTermPct = 0.0;
    int longBurstCount = 0;
    if (traceDataModel != null && traceDataModel.getAnalyzerResult() != null) {
        int termSessions = 0;
        int properTermSessions = 0;
        for (Session tcpSession : traceDataModel.getAnalyzerResult().getSessionlist()) {
            if (!tcpSession.isUdpOnly()) {
                Termination termination = tcpSession.getSessionTermination();
                if (termination != null) {
                    ++termSessions;
                    if (termination.getSessionTerminationDelay() <= SESSION_TERMINATION_THRESHOLD) {
                        ++properTermSessions;
                    }
                }
            }
        }
        if (termSessions > 0) {
            sessionTermPct = 100.0 * properTermSessions / termSessions;
        }
        longBurstCount = traceDataModel.getAnalyzerResult().getBurstCollectionAnalysisData().getLongBurstCount();
    }
    connectionStatisticsPojo.setSessionTermPct(sessionTermPct);
    double tightlyCoupledTCPPct = 0.0;
    if (traceDataModel != null && traceDataModel.getAnalyzerResult() != null) {
        int burstSize = traceDataModel.getAnalyzerResult().getBurstCollectionAnalysisData().getBurstCollection().size();
        int periodicBurstCount = 0;
        for (Burst burstInfo : traceDataModel.getAnalyzerResult().getBurstCollectionAnalysisData().getBurstCollection()) {
            BurstCategory bCategory = burstInfo.getBurstCategory();
            if (bCategory == BurstCategory.PERIODICAL) {
                periodicBurstCount += 1;
            }
        }
        double nonPeriodicBurstPct = 100 - 100.0 * periodicBurstCount / burstSize;
        connectionStatisticsPojo.setNonPeriodicBurstPct(nonPeriodicBurstPct);
        int tightlyCoupledBurstCount = 0;
        for (AbstractBestPracticeResult abstractResult : traceDataModel.getBestPracticeResults()) {
            if (abstractResult.getBestPracticeType().equals(BestPracticeType.UNNECESSARY_CONNECTIONS) && abstractResult.getResultType() != BPResultType.NONE) {
                UnnecessaryConnectionResult unnecessaryConnt = (UnnecessaryConnectionResult) abstractResult;
                tightlyCoupledBurstCount = unnecessaryConnt.getTightlyCoupledBurstCount();
            }
        }
        tightlyCoupledTCPPct = 100.0 * tightlyCoupledBurstCount / burstSize;
        connectionStatisticsPojo.setTightlyCoupledTCPPct(tightlyCoupledTCPPct);
        double longBurstPct = 0.0;
        longBurstPct = 100.0 * longBurstCount / burstSize;
        connectionStatisticsPojo.setLongBurstPct(longBurstPct);
    }
    return connectionStatisticsPojo;
}
Also used : UnnecessaryConnectionResult(com.att.aro.core.bestpractice.pojo.UnnecessaryConnectionResult) BurstCategory(com.att.aro.core.packetanalysis.pojo.BurstCategory) ConnectionStatisticsInfo(com.att.aro.ui.model.overview.ConnectionStatisticsInfo) Burst(com.att.aro.core.packetanalysis.pojo.Burst) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Termination(com.att.aro.core.packetanalysis.pojo.Termination) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 3 with BurstCategory

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

the class BurstPlot method populate.

public void populate(XYPlot plot, AROTraceData analysis) {
    if (analysis != null) {
        burstDataCollection.removeAllSeries();
        Map<BurstCategory, XYIntervalSeries> seriesMap = new EnumMap<BurstCategory, XYIntervalSeries>(BurstCategory.class);
        final Map<BurstCategory, List<Burst>> burstMap = new HashMap<BurstCategory, List<Burst>>();
        for (BurstCategory eventType : BurstCategory.values()) {
            XYIntervalSeries series = new XYIntervalSeries(eventType);
            seriesMap.put(eventType, series);
            burstDataCollection.addSeries(series);
            burstMap.put(eventType, new ArrayList<Burst>());
        }
        final List<Burst> burstStates = analysis.getAnalyzerResult().getBurstCollectionAnalysisData().getBurstCollection();
        Iterator<Burst> iter = burstStates.iterator();
        while (iter.hasNext()) {
            Burst currEvent = iter.next();
            if (currEvent != null) {
                BurstCategory burstState = currEvent.getBurstCategory();
                if (burstState != null) {
                    seriesMap.get(burstState).add(currEvent.getBeginTime(), currEvent.getBeginTime(), currEvent.getEndTime(), 0.5, 0, 1);
                    burstMap.get(burstState).add(currEvent);
                }
            }
        }
        Color myGreen = new Color(34, 177, 76);
        Color lightGreen = new Color(134, 232, 162);
        XYItemRenderer renderer = plot.getRenderer();
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.TCP_PROTOCOL), Color.blue);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.TCP_LOSS_OR_DUP), Color.black);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.USER_INPUT), myGreen);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.SCREEN_ROTATION), lightGreen);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.CLIENT_APP), Color.red);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.SERVER_NET_DELAY), Color.yellow);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.LONG), Color.gray);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.PERIODICAL), Color.magenta);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.CPU), Color.cyan);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.UNKNOWN), Color.darkGray);
        // Assign ToolTip to renderer
        renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {
                BurstCategory eventType = (BurstCategory) burstDataCollection.getSeries(series).getKey();
                Burst b;
                int size = burstMap.get(eventType).size();
                if (size > item) {
                    b = burstMap.get(eventType).get(item);
                } else {
                    b = burstMap.get(eventType).get(size);
                }
                final String PREFIX = "BurstCategory.";
                return MessageFormat.format(ResourceBundleHelper.getMessageString(PREFIX + eventType.ordinal()), b.getPackets().size(), b.getBurstBytes(), b.getBurstThroughPut());
            }
        });
    }
    plot.setDataset(burstDataCollection);
// return plot;
}
Also used : HashMap(java.util.HashMap) Color(java.awt.Color) BurstCategory(com.att.aro.core.packetanalysis.pojo.BurstCategory) XYIntervalSeries(org.jfree.data.xy.XYIntervalSeries) Burst(com.att.aro.core.packetanalysis.pojo.Burst) ArrayList(java.util.ArrayList) List(java.util.List) XYDataset(org.jfree.data.xy.XYDataset) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) EnumMap(java.util.EnumMap)

Example 4 with BurstCategory

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

the class BurstCollectionAnalysisImpl method analyzeBursts.

/**
 * Assigns burst category to each burst in a collection of bursts.
 * The collection of bursts have been populated prior to this API call.
 */
private int analyzeBursts(List<Burst> burstCollection, List<UserEvent> userEvents, List<CpuActivity> cpuEvents, Profile profile) {
    int userEventsSize = userEvents.size();
    int cpuEventsSize = cpuEvents.size();
    int userEventPointer = 0;
    int cpuPointer = 0;
    int longBurstCount = 0;
    // Analyze each burst
    Burst burst = null;
    Burst lastBurst;
    for (Iterator<Burst> iterator = burstCollection.iterator(); iterator.hasNext(); ) {
        lastBurst = burst;
        burst = iterator.next();
        List<PacketInfo> burstPacketCollection = new ArrayList<PacketInfo>(burst.getPackets().size());
        int burstPayloadLen = 0;
        Set<TcpInfo> burstPacketTcpInfo = new HashSet<TcpInfo>();
        for (PacketInfo pInfo : burst.getPackets()) {
            burstPayloadLen += pInfo.getPayloadLen();
            burstPacketCollection.add(pInfo);
            TcpInfo tcp = pInfo.getTcpInfo();
            if (tcp != null) {
                burstPacketTcpInfo.add(tcp);
            }
        }
        PacketInfo pkt0 = null;
        TcpInfo info0 = null;
        double time0 = 0;
        if (!burstPacketCollection.isEmpty()) {
            pkt0 = burstPacketCollection.get(0);
            info0 = pkt0.getTcpInfo();
            time0 = pkt0.getTimeStamp();
        }
        /*
			 * Mark the burst as Long Burst based on the
			 * burst duration and size of the payload. 
			 */
        if (burst.getEndTime() - burst.getBeginTime() > profile.getLargeBurstDuration() && burstPayloadLen > profile.getLargeBurstSize()) {
            burst.setBurstInfo(BurstCategory.LONG);
            ++longBurstCount;
            continue;
        }
        /*
			 * For bursts with no payload assign burst type based on
			 * the the type of TCP packets. 
			 */
        if (burstPayloadLen == 0) {
            if (burstPacketTcpInfo.contains(TcpInfo.TCP_CLOSE) || burstPacketTcpInfo.contains(TcpInfo.TCP_ESTABLISH) || burstPacketTcpInfo.contains(TcpInfo.TCP_RESET) || burstPacketTcpInfo.contains(TcpInfo.TCP_KEEP_ALIVE) || burstPacketTcpInfo.contains(TcpInfo.TCP_KEEP_ALIVE_ACK) || burstPacketTcpInfo.contains(TcpInfo.TCP_ZERO_WINDOW) || burstPacketTcpInfo.contains(TcpInfo.TCP_WINDOW_UPDATE)) {
                burst.setBurstInfo(BurstCategory.TCP_PROTOCOL);
                continue;
            }
            if (info0 == TcpInfo.TCP_ACK_RECOVER || info0 == TcpInfo.TCP_ACK_DUP) {
                burst.setBurstInfo(BurstCategory.TCP_LOSS_OR_DUP);
                continue;
            }
        }
        if (pkt0 == null) {
            continue;
        }
        // Step 4: Server delay
        if (pkt0.getDir() == PacketDirection.DOWNLINK && (info0 == TcpInfo.TCP_DATA || info0 == TcpInfo.TCP_ACK)) {
            burst.setBurstInfo(BurstCategory.SERVER_NET_DELAY);
            continue;
        }
        // Step 5: Loss recover
        if (info0 == TcpInfo.TCP_ACK_DUP || info0 == TcpInfo.TCP_DATA_DUP) {
            burst.setBurstInfo(BurstCategory.TCP_LOSS_OR_DUP);
            continue;
        }
        if (info0 == TcpInfo.TCP_DATA_RECOVER || info0 == TcpInfo.TCP_ACK_RECOVER) {
            burst.setBurstInfo(BurstCategory.TCP_LOSS_OR_DUP);
            continue;
        }
        // Step 6: User triggered
        final double USER_EVENT_SMALL_TOLERATE = profile.getUserInputTh();
        if (burstPayloadLen > 0) {
            UserEvent uevent = null;
            while ((userEventPointer < userEventsSize) && ((uevent = userEvents.get(userEventPointer)).getReleaseTime() < (time0 - USER_EVENT_TOLERATE))) {
                ++userEventPointer;
            }
            BurstCategory userInputBurst = null;
            if (uevent != null) {
                if (uevent.getEventType() == UserEventType.SCREEN_LANDSCAPE || uevent.getEventType() == UserEventType.SCREEN_PORTRAIT) {
                    userInputBurst = BurstCategory.SCREEN_ROTATION;
                } else {
                    userInputBurst = BurstCategory.USER_INPUT;
                }
            }
            int userEventCount = userEventPointer;
            double minGap = Double.MAX_VALUE;
            while (userEventCount < userEventsSize) {
                UserEvent uEvent = userEvents.get(userEventCount);
                if (withinTolerate(uEvent.getPressTime(), time0)) {
                    double gap = time0 - uEvent.getPressTime();
                    if (gap < minGap) {
                        minGap = gap;
                    }
                }
                if (withinTolerate(uEvent.getReleaseTime(), time0)) {
                    double gap = time0 - uEvent.getReleaseTime();
                    if (gap < minGap) {
                        minGap = gap;
                    }
                }
                if (uEvent.getPressTime() > time0) {
                    break;
                }
                userEventCount++;
            }
            if (minGap < USER_EVENT_SMALL_TOLERATE) {
                burst.setBurstInfo(userInputBurst);
                continue;
            } else if (minGap < USER_EVENT_TOLERATE && (lastBurst == null || lastBurst.getEndTime() < burst.getBeginTime() - minGap)) {
                double cpuBegin = time0 - minGap;
                double cpuEnd = time0;
                // Check CPU usage
                while (cpuPointer < cpuEventsSize) {
                    double eventTimeStamp = cpuEvents.get(cpuPointer).getTimeStamp();
                    if (eventTimeStamp < burst.getBeginTime() - USER_EVENT_TOLERATE) {
                        ++cpuPointer;
                    } else {
                        break;
                    }
                }
                int cpuActivityKey = cpuPointer;
                double totalCpuUsage = 0.0f;
                int cEventsCount = 0;
                while (cpuActivityKey < cpuEventsSize) {
                    CpuActivity cpuAct = cpuEvents.get(cpuActivityKey);
                    double caTimeStamp = cpuAct.getTimeStamp();
                    if (caTimeStamp > cpuBegin && caTimeStamp < cpuEnd) {
                        totalCpuUsage += cpuAct.getTotalCpuUsage();
                        cEventsCount++;
                    }
                    if (caTimeStamp >= cpuEnd) {
                        break;
                    }
                    cpuActivityKey++;
                }
                if (cEventsCount > 0 && (totalCpuUsage / cEventsCount) > AVG_CPU_USAGE_THRESHOLD) {
                    burst.setBurstInfo(BurstCategory.CPU);
                    continue;
                } else {
                    burst.setBurstInfo(userInputBurst);
                    continue;
                }
            }
        }
        // Step 7: Client delay
        if (burstPayloadLen == 0) {
            burst.setBurstInfo(BurstCategory.UNKNOWN);
            continue;
        } else {
            burst.setBurstInfo(BurstCategory.CLIENT_APP);
            continue;
        }
    }
    return longBurstCount;
}
Also used : TcpInfo(com.att.aro.core.packetanalysis.pojo.TcpInfo) ArrayList(java.util.ArrayList) UserEvent(com.att.aro.core.peripheral.pojo.UserEvent) BurstCategory(com.att.aro.core.packetanalysis.pojo.BurstCategory) Burst(com.att.aro.core.packetanalysis.pojo.Burst) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) CpuActivity(com.att.aro.core.peripheral.pojo.CpuActivity) HashSet(java.util.HashSet)

Aggregations

Burst (com.att.aro.core.packetanalysis.pojo.Burst)4 BurstCategory (com.att.aro.core.packetanalysis.pojo.BurstCategory)4 ArrayList (java.util.ArrayList)3 EnumMap (java.util.EnumMap)2 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)1 UnnecessaryConnectionResult (com.att.aro.core.bestpractice.pojo.UnnecessaryConnectionResult)1 BurstAnalysisInfo (com.att.aro.core.packetanalysis.pojo.BurstAnalysisInfo)1 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)1 Session (com.att.aro.core.packetanalysis.pojo.Session)1 TcpInfo (com.att.aro.core.packetanalysis.pojo.TcpInfo)1 Termination (com.att.aro.core.packetanalysis.pojo.Termination)1 CpuActivity (com.att.aro.core.peripheral.pojo.CpuActivity)1 UserEvent (com.att.aro.core.peripheral.pojo.UserEvent)1 ConnectionStatisticsInfo (com.att.aro.ui.model.overview.ConnectionStatisticsInfo)1 Color (java.awt.Color)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1