Search in sources :

Example 16 with Burst

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

the class BurstCollectionAnalysisImpl method analyze.

@Override
public BurstCollectionAnalysisData analyze(List<PacketInfo> packets, Profile profile, Map<Integer, Integer> packetSizeToCountMap, List<RrcStateRange> rrcstaterangelist, List<UserEvent> usereventlist, List<CpuActivity> cpuactivitylist, List<Session> sessionlist) {
    BurstCollectionAnalysisData data = new BurstCollectionAnalysisData();
    Set<Integer> mss = calculateMssLargerPacketSizeSet(packetSizeToCountMap);
    List<Burst> burstCollection = groupIntoBursts(packets, profile, mss, rrcstaterangelist);
    data.setBurstCollection(burstCollection);
    if (!burstCollection.isEmpty()) {
        int longBurstCount = analyzeBursts(burstCollection, usereventlist, cpuactivitylist, profile);
        data.setLongBurstCount(longBurstCount);
        double totalEnergy = computeBurstEnergyRadioResource(rrcstaterangelist, burstCollection, profile);
        data.setTotalEnergy(totalEnergy);
        List<BurstAnalysisInfo> burstAnalysisInfo = analyzeBurstStat(burstCollection);
        data.setBurstAnalysisInfo(burstAnalysisInfo);
        PacketInfo shortestPacket = findShortestPeriodPacketInfo(burstCollection);
        data.setShortestPeriodPacketInfo(shortestPacket);
    }
    return data;
}
Also used : BurstAnalysisInfo(com.att.aro.core.packetanalysis.pojo.BurstAnalysisInfo) Burst(com.att.aro.core.packetanalysis.pojo.Burst) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)

Example 17 with Burst

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

the class BurstCollectionAnalysisImpl method computeBurstEnergyRadioResource.

/**
 * Computes the total burst energy.
 * @return
 */
private double computeBurstEnergyRadioResource(List<RrcStateRange> rrcstaterangelist, List<Burst> burstCollection, Profile profile) {
    List<RrcStateRange> rrcCollection = rrcstaterangelist;
    int rrcCount = rrcCollection.size();
    if (rrcCount == 0) {
        return 0;
    }
    int pCount = 0;
    double time2 = -1;
    double totalEnergy = 0.0f;
    Iterator<Burst> iter = burstCollection.iterator();
    Burst currentBurst = iter.next();
    double time1 = rrcCollection.get(0).getBeginTime();
    while (true) {
        Burst nextBurst = iter.hasNext() ? iter.next() : null;
        time2 = nextBurst != null ? nextBurst.getBeginTime() : rrcCollection.get(rrcCount - 1).getEndTime();
        double energy = 0.0f;
        double activeTime = 0.0f;
        while (pCount < rrcCount) {
            RrcStateRange rrCntrl = rrcCollection.get(pCount);
            if (rrCntrl.getEndTime() < time1) {
                pCount++;
            } else {
                if (time2 > rrCntrl.getEndTime()) {
                    if (profile.getProfileType() == ProfileType.T3G) {
                        energy += profilefactory.energy3G(time1, rrCntrl.getEndTime(), rrCntrl.getState(), (Profile3G) profile);
                    } else if (profile.getProfileType() == ProfileType.LTE) {
                        energy += rrCntrl.getEnergy();
                    } else if (profile.getProfileType() == ProfileType.WIFI) {
                        energy += profilefactory.energyWiFi(time1, rrCntrl.getEndTime(), rrCntrl.getState(), (ProfileWiFi) profile);
                    }
                    if ((rrCntrl.getState() == RRCState.STATE_DCH || rrCntrl.getState() == RRCState.TAIL_DCH) || (rrCntrl.getState() == RRCState.LTE_CONTINUOUS || rrCntrl.getState() == RRCState.LTE_CR_TAIL) || (rrCntrl.getState() == RRCState.WIFI_ACTIVE || rrCntrl.getState() == RRCState.WIFI_TAIL)) {
                        activeTime += rrCntrl.getEndTime() - time1;
                    }
                    pCount++;
                }
                break;
            }
        }
        while (pCount < rrcCount) {
            RrcStateRange rrCntrl = rrcCollection.get(pCount);
            if (rrCntrl.getEndTime() < time2) {
                if (profile.getProfileType() == ProfileType.T3G) {
                    energy += profilefactory.energy3G(Math.max(rrCntrl.getBeginTime(), time1), rrCntrl.getEndTime(), rrCntrl.getState(), (Profile3G) profile);
                } else if (profile.getProfileType() == ProfileType.LTE) {
                    energy += rrCntrl.getEnergy();
                } else if (profile.getProfileType() == ProfileType.WIFI) {
                    energy += profilefactory.energyWiFi(Math.max(rrCntrl.getBeginTime(), time1), rrCntrl.getEndTime(), rrCntrl.getState(), (ProfileWiFi) profile);
                }
                if ((rrCntrl.getState() == RRCState.STATE_DCH || rrCntrl.getState() == RRCState.TAIL_DCH) || (rrCntrl.getState() == RRCState.LTE_CONTINUOUS || rrCntrl.getState() == RRCState.LTE_CR_TAIL) || (rrCntrl.getState() == RRCState.WIFI_ACTIVE || rrCntrl.getState() == RRCState.WIFI_TAIL)) {
                    activeTime += rrCntrl.getEndTime() - Math.max(rrCntrl.getBeginTime(), time1);
                }
                pCount++;
            } else {
                if (profile.getProfileType() == ProfileType.T3G) {
                    energy += profilefactory.energy3G(Math.max(rrCntrl.getBeginTime(), time1), time2, rrCntrl.getState(), (Profile3G) profile);
                } else if (profile.getProfileType() == ProfileType.LTE) {
                    energy += rrCntrl.getEnergy();
                } else if (profile.getProfileType() == ProfileType.WIFI) {
                    energy += profilefactory.energyWiFi(Math.max(rrCntrl.getBeginTime(), time1), time2, rrCntrl.getState(), (ProfileWiFi) profile);
                }
                if ((rrCntrl.getState() == RRCState.STATE_DCH || rrCntrl.getState() == RRCState.TAIL_DCH) || (rrCntrl.getState() == RRCState.LTE_CONTINUOUS || rrCntrl.getState() == RRCState.LTE_CR_TAIL) || (rrCntrl.getState() == RRCState.WIFI_ACTIVE || rrCntrl.getState() == RRCState.WIFI_TAIL)) {
                    activeTime += time2 - Math.max(rrCntrl.getBeginTime(), time1);
                }
                break;
            }
        }
        currentBurst.setEnergy(energy);
        totalEnergy += energy;
        currentBurst.setActiveTime(activeTime);
        time1 = time2;
        if (nextBurst != null) {
            currentBurst = nextBurst;
        } else {
            break;
        }
    }
    return totalEnergy;
}
Also used : Burst(com.att.aro.core.packetanalysis.pojo.Burst) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) Profile3G(com.att.aro.core.configuration.pojo.Profile3G) ProfileWiFi(com.att.aro.core.configuration.pojo.ProfileWiFi)

Example 18 with Burst

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

the class BurstCollectionAnalysisImpl method findShortestPeriodPacketInfo.

/**
 * Method to find the different periodic connection and periodic duration.
 */
private PacketInfo findShortestPeriodPacketInfo(List<Burst> burstCollection) {
    int burstSize = burstCollection.size();
    Burst lastPeriodicalBurst = null;
    int periodicPacketCounter = 0;
    double minRepeatTime = Double.MAX_VALUE;
    PacketInfo pktId = null;
    double time = 0;
    for (int i = 0; i < burstSize; i++) {
        Burst burst = burstCollection.get(i);
        if (burst.getBurstCategory() == BurstCategory.PERIODICAL) {
            if (periodicPacketCounter != 0) {
                time = burst.getBeginTime() - ((lastPeriodicalBurst != null) ? lastPeriodicalBurst.getBeginTime() : 0);
                if (time < minRepeatTime) {
                    minRepeatTime = time;
                    pktId = burst.getFirstUplinkDataPacket();
                    if (null == pktId) {
                        pktId = burst.getBeginPacket();
                    }
                }
            }
            periodicPacketCounter++;
            lastPeriodicalBurst = burst;
        }
    }
    return pktId;
}
Also used : Burst(com.att.aro.core.packetanalysis.pojo.Burst) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo)

Example 19 with Burst

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

the class BurstCollectionAnalysisImpl method groupIntoBursts.

/**
 * Groups packets into Burst Collections
 * @return
 */
private List<Burst> groupIntoBursts(List<PacketInfo> packets, Profile profile, Set<Integer> mss, List<RrcStateRange> rrcstaterangelist) {
    List<Burst> burstCollection;
    // Validate that there are packets
    if (packets == null || packets.isEmpty()) {
        burstCollection = Collections.emptyList();
        return burstCollection;
    }
    ArrayList<Burst> result = new ArrayList<Burst>();
    double burstThresh = profile.getBurstTh();
    double longBurstThresh = profile.getLongBurstTh();
    List<PacketInfo> burstPackets = new ArrayList<PacketInfo>();
    // Step 1: Build bursts using burst time threshold
    PacketInfo lastPacket = null;
    for (PacketInfo packet : packets) {
        if ((lastPacket == null || (packet.getTimeStamp() - lastPacket.getTimeStamp() > burstThresh && !mss.contains(lastPacket.getPayloadLen()))) && (!burstPackets.isEmpty())) {
            result.add(new Burst(burstPackets));
            burstPackets.clear();
        }
        burstPackets.add(packet);
        lastPacket = packet;
    }
    result.add(new Burst(burstPackets));
    // Step 2: Remove promotion delays and merge bursts if possible
    Map<PacketInfo, Double> timestampList = normalizeCore(packets, rrcstaterangelist);
    List<Burst> newBurstColl = new ArrayList<Burst>(result.size());
    int size = result.size();
    Burst newBurst = result.get(0);
    for (int i = 0; i < size - 1; i++) {
        Burst bnext = result.get(i + 1);
        double time1 = timestampList.get(newBurst.getEndPacket());
        double time2 = timestampList.get(bnext.getBeginPacket());
        if ((time2 - time1) < burstThresh) {
            newBurst.merge(bnext);
        } else {
            newBurstColl.add(newBurst);
            newBurst = bnext;
        }
    }
    newBurstColl.add(newBurst);
    burstCollection = newBurstColl;
    // determine short/long IBTs
    size = burstCollection.size();
    for (int i = 0; i < size; i++) {
        Burst aBurst = burstCollection.get(i);
        // assert (aBurst.getEndTime() >= aBurst.getBeginTime());
        if (i < size - 1) {
            double ibt = burstCollection.get(i + 1).getBeginTime() - aBurst.getEndTime();
            // assert (ibt >= burstThresh);
            aBurst.setbLong((ibt > longBurstThresh));
        } else {
            aBurst.setbLong(true);
        }
    }
    return burstCollection;
}
Also used : Burst(com.att.aro.core.packetanalysis.pojo.Burst) ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo)

Example 20 with Burst

use of com.att.aro.core.packetanalysis.pojo.Burst 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)22 ArrayList (java.util.ArrayList)11 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)8 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)8 BaseTest (com.att.aro.core.BaseTest)7 Test (org.junit.Test)7 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)5 BurstCategory (com.att.aro.core.packetanalysis.pojo.BurstCategory)4 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)4 Session (com.att.aro.core.packetanalysis.pojo.Session)3 Packet (com.att.aro.core.packetreader.pojo.Packet)3 InetAddress (java.net.InetAddress)3 Profile3G (com.att.aro.core.configuration.pojo.Profile3G)2 BurstAnalysisInfo (com.att.aro.core.packetanalysis.pojo.BurstAnalysisInfo)2 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)2 UnknownHostException (java.net.UnknownHostException)2 Date (java.util.Date)2 EnumMap (java.util.EnumMap)2 HashSet (java.util.HashSet)2 ConnectionClosingResult (com.att.aro.core.bestpractice.pojo.ConnectionClosingResult)1