Search in sources :

Example 1 with RRCState

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

the class TimeRangeAnalysis method performTimeRangeAnalysis.

/**
 * Performs a TimeRangeAnalysis on the trace data.
 * @param analysisData Packet analyzer result object
 */
private void performTimeRangeAnalysis(PacketAnalyzerResult analysisData) {
    if (analysisData != null) {
        List<RrcStateRange> rrcCollection = analysisData.getStatemachine().getStaterangelist();
        List<PacketInfo> packets = analysisData.getTraceresult().getAllpackets();
        if (controller != null) {
            PacketAnalyzerImpl packetAnalyzerImpl = (PacketAnalyzerImpl) (controller.getAROService().getAnalyzer());
            packets = packetAnalyzerImpl.filterPackets(analysisData.getFilter(), packets);
        }
        Profile profile = analysisData.getProfile();
        int packetNum = packets.size();
        for (int i = 0; i < packetNum; i++) {
            PacketInfo packetInfo = packets.get(i);
            if ((!ipv4Present || !ipv6Present) && packetInfo.getPacket() instanceof IPPacket) {
                IPPacket p = (IPPacket) packetInfo.getPacket();
                if (p.getIPVersion() == 4) {
                    ipv4Present = true;
                } else if (p.getIPVersion() == 6) {
                    ipv6Present = true;
                }
            }
            if (!tcpPresent && packetInfo.getPacket() instanceof TCPPacket) {
                tcpPresent = true;
            } else if ((!udpPresent || !dnsPresent) && packetInfo.getPacket() instanceof UDPPacket) {
                UDPPacket p = (UDPPacket) packetInfo.getPacket();
                udpPresent = true;
                if (p.isDNSPacket()) {
                    dnsPresent = true;
                }
            }
            if (packetInfo.getTimeStamp() >= startTime && packetInfo.getTimeStamp() <= endTime) {
                payloadLen += packetInfo.getPayloadLen();
                totalBytes += packetInfo.getLen();
                if (packetInfo.getDir().equals(PacketDirection.UPLINK)) {
                    uplinkBytes += packetInfo.getLen();
                } else if (packetInfo.getDir().equals(PacketDirection.DOWNLINK)) {
                    downlinkBytes += packetInfo.getLen();
                }
            }
        }
        int collectionSize = rrcCollection.size();
        for (int i = 0; i < collectionSize; i++) {
            double beginTime;
            double endTime;
            RrcStateRange rrc = rrcCollection.get(i);
            if (rrc.getEndTime() < this.startTime) {
                continue;
            }
            if (rrc.getBeginTime() > this.endTime) {
                continue;
            }
            if (rrc.getBeginTime() >= this.startTime) {
                beginTime = rrc.getBeginTime();
            } else {
                beginTime = this.startTime;
            }
            if (rrc.getEndTime() <= this.endTime) {
                endTime = rrc.getEndTime();
            } else {
                endTime = this.endTime;
            }
            RRCState rrcState = rrc.getState();
            rrcEnergy += updateEnergy(analysisData, profile, beginTime, endTime, rrcState);
            activeTime += updateActiveTime(profile, beginTime, endTime, rrcState);
        }
    }
}
Also used : RRCState(com.att.aro.core.packetanalysis.pojo.RRCState) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) Profile(com.att.aro.core.configuration.pojo.Profile) IPPacket(com.att.aro.core.packetreader.pojo.IPPacket)

Example 2 with RRCState

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

the class TimeRangeAnalysis method performTimeRangeAnalysis.

/**
 * Performs a TimeRangeAnalysis on the trace data.
 * TODO:  The calculation should not be in the UI - move elsewhere (Core)
 *
 * @return TimeRangeAnalysis The object containing TimeRangeAnalysis
 *         data.
 */
public static TimeRangeAnalysis performTimeRangeAnalysis(PacketAnalyzerResult analysisData, double analyzeBeginTime, double analyzeEndTime) {
    List<RrcStateRange> rrcCollection = analysisData.getStatemachine().getStaterangelist();
    List<PacketInfo> packets = analysisData.getTraceresult().getAllpackets();
    Profile profile = analysisData.getProfile();
    long payloadLength = 0;
    long totalBytes = 0;
    long uplinkBytes = 0;
    long downlinkBytes = 0;
    int packetNum = packets.size();
    for (int i = 0; i < packetNum; i++) {
        PacketInfo packetInfo = packets.get(i);
        if (packetInfo.getTimeStamp() >= analyzeBeginTime && packetInfo.getTimeStamp() <= analyzeEndTime) {
            payloadLength += packetInfo.getPayloadLen();
            totalBytes += packetInfo.getLen();
            if (packetInfo.getDir().equals(PacketDirection.UPLINK)) {
                uplinkBytes += packetInfo.getLen();
            } else if (packetInfo.getDir().equals(PacketDirection.DOWNLINK)) {
                downlinkBytes += packetInfo.getLen();
            }
        }
    }
    double energy = 0.0f;
    double activeTime = 0.0f;
    int collectionSize = rrcCollection.size();
    for (int i = 0; i < collectionSize; i++) {
        double beginTime;
        double endTime;
        RrcStateRange rrc = rrcCollection.get(i);
        if (rrc.getEndTime() < analyzeBeginTime) {
            continue;
        }
        if (rrc.getBeginTime() > analyzeEndTime) {
            continue;
        }
        if (rrc.getBeginTime() >= analyzeBeginTime) {
            beginTime = rrc.getBeginTime();
        } else {
            beginTime = analyzeBeginTime;
        }
        if (rrc.getEndTime() <= analyzeEndTime) {
            endTime = rrc.getEndTime();
        } else {
            endTime = analyzeEndTime;
        }
        RRCState rrcState = rrc.getState();
        IProfileFactory profileFactory = ContextAware.getAROConfigContext().getBean(IProfileFactory.class);
        energy += updateEnergy(analysisData, profile, beginTime, endTime, rrcState, profileFactory);
        activeTime += updateActiveTime(profile, beginTime, endTime, rrcState);
    }
    return new TimeRangeAnalysis(analyzeBeginTime, analyzeEndTime, totalBytes, uplinkBytes, downlinkBytes, payloadLength, activeTime, energy);
}
Also used : RRCState(com.att.aro.core.packetanalysis.pojo.RRCState) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) IProfileFactory(com.att.aro.core.configuration.IProfileFactory) Profile(com.att.aro.core.configuration.pojo.Profile)

Example 3 with RRCState

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

the class RrcPlot method populate.

@Override
public void populate(XYPlot plot, AROTraceData analysis) {
    if (analysis != null) {
        rrcDataCollection.removeAllSeries();
        Map<RRCState, XYIntervalSeries> seriesMap = new EnumMap<RRCState, XYIntervalSeries>(RRCState.class);
        for (RRCState eventType : RRCState.values()) {
            XYIntervalSeries series = new XYIntervalSeries(eventType);
            seriesMap.put(eventType, series);
            rrcDataCollection.addSeries(series);
        }
        List<RrcStateRange> rrcStates = analysis.getAnalyzerResult().getStatemachine().getStaterangelist();
        Iterator<RrcStateRange> iter = rrcStates.iterator();
        while (iter.hasNext()) {
            RrcStateRange currEvent = iter.next();
            RRCState state = currEvent.getState();
            if (state == RRCState.STATE_FACH || state == RRCState.TAIL_FACH) {
                seriesMap.get(state).add(currEvent.getBeginTime(), currEvent.getBeginTime(), currEvent.getEndTime(), 0.25, 0, 0.5);
            } else {
                seriesMap.get(state).add(currEvent.getBeginTime(), currEvent.getBeginTime(), currEvent.getEndTime(), 0.5, 0, 1);
            }
        }
        XYItemRenderer renderer = plot.getRenderer();
        Color dchGreen = new Color(34, 177, 76);
        Color fachOrange = new Color(255, 201, 14);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.STATE_IDLE), Color.white);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.LTE_IDLE), Color.white);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.PROMO_IDLE_DCH), Color.red);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.LTE_PROMOTION), Color.red);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.STATE_DCH), fachOrange);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.LTE_CONTINUOUS), fachOrange);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.TAIL_DCH), getTailPaint(fachOrange));
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.LTE_CR_TAIL), getTailPaint(fachOrange));
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.LTE_DRX_SHORT), getTailPaint(fachOrange));
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.LTE_DRX_LONG), getTailPaint(fachOrange));
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.STATE_FACH), dchGreen);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.TAIL_FACH), getTailPaint(dchGreen));
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.PROMO_FACH_DCH), Color.red);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.WIFI_IDLE), Color.white);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.WIFI_ACTIVE), fachOrange);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.WIFI_TAIL), getTailPaint(fachOrange));
        // Assign ToolTip to renderer
        final Profile profile = analysis.getAnalyzerResult().getProfile();
        renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {
                RRCState eventType = (RRCState) rrcDataCollection.getSeries(series).getKey();
                final String PREFIX = "RRCTooltip.";
                if (eventType == RRCState.LTE_IDLE && profile instanceof ProfileLTE) {
                    return MessageFormat.format(ResourceBundleHelper.getMessageString(PREFIX + eventType), ((ProfileLTE) profile).getIdlePingPeriod());
                }
                return ResourceBundleHelper.getMessageString(PREFIX + eventType);
            }
        });
    }
    plot.setDataset(rrcDataCollection);
// return plot;
}
Also used : Color(java.awt.Color) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) ProfileLTE(com.att.aro.core.configuration.pojo.ProfileLTE) Profile(com.att.aro.core.configuration.pojo.Profile) TexturePaint(java.awt.TexturePaint) Paint(java.awt.Paint) RRCState(com.att.aro.core.packetanalysis.pojo.RRCState) XYIntervalSeries(org.jfree.data.xy.XYIntervalSeries) 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 RRCState

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

the class BurstCollectionAnalysisImpl method normalizeCore.

/**
 * Method orginally found in whatif.cpp
 *
 * @param packets
 *            returns timestampList - List of doubles
 */
private Map<PacketInfo, Double> normalizeCore(List<PacketInfo> packets, List<RrcStateRange> rrcstaterangelist) {
    // Step 1: Identify Promotions
    List<RrcStateRange> promoDelays = new ArrayList<RrcStateRange>();
    for (RrcStateRange rrc : rrcstaterangelist) {
        RRCState state = rrc.getState();
        if ((state == RRCState.PROMO_FACH_DCH) || (state == RRCState.PROMO_IDLE_DCH)) {
            promoDelays.add(rrc);
        }
    }
    Collections.sort(promoDelays);
    PacketTimestamp[] timeStampList = new PacketTimestamp[packets.size()];
    for (int i = 0; i < packets.size(); i++) {
        timeStampList[i] = new PacketTimestamp(packets.get(i));
    }
    // Step 2: Remove all promo delays
    int pdSize = promoDelays.size();
    double timeStampShift = 0.0f;
    int pdKey = 0;
    // "in-the-middle" position
    int pdMiddlePosKey = -1;
    // How to initialize??
    double middlePos = 0;
    for (int i = 0; i < timeStampList.length; i++) {
        double timeStamp = timeStampList[i].timestamp;
        while (pdKey < pdSize && timeStamp >= promoDelays.get(pdKey).getEndTime() - EPS) {
            if (pdMiddlePosKey != -1) {
                // assert (pdMiddlePosKey == pdKey && i > 0 && promoDelays.get(pdKey).getEndTime() >= middlePos);
                timeStampShift += promoDelays.get(pdKey).getEndTime() - middlePos;
                pdMiddlePosKey = -1;
            } else {
                timeStampShift += promoDelays.get(pdKey).getEndTime() - promoDelays.get(pdKey).getBeginTime();
            }
            pdKey++;
        }
        if (pdKey < pdSize && (promoDelays.get(pdKey).getBeginTime() - EPS) < timeStamp && timeStamp < (promoDelays.get(pdKey).getEndTime() + EPS)) {
            if (pdMiddlePosKey == -1) {
                timeStampShift += timeStamp - promoDelays.get(pdKey).getBeginTime();
                middlePos = timeStamp;
                pdMiddlePosKey = pdKey;
            } else {
                // assert (pdMiddlePosKey == pdKey && i > 0);
                // assert (timeStamp >= middlePos);
                timeStampShift += timeStamp - middlePos;
                middlePos = timeStamp;
            }
        }
        timeStampList[i].timestamp = timeStampList[i].timestamp - timeStampShift;
    // assert (i == 0 || timeStampList[i].timestamp >= timeStampList[i - 1].timestamp);
    }
    Map<PacketInfo, Double> result = new LinkedHashMap<PacketInfo, Double>(timeStampList.length);
    for (int i = 0; i < timeStampList.length; ++i) {
        result.put(timeStampList[i].packet, timeStampList[i].timestamp);
    }
    return result;
}
Also used : RRCState(com.att.aro.core.packetanalysis.pojo.RRCState) ArrayList(java.util.ArrayList) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with RRCState

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

the class RrcStateRangeFactoryImpl method create3G.

/**
 * This method contains the main algorithm for creating the List of
 * RrcStateRange for a 3G profile
 *
 * @param analysisData
 *            Analysis data
 * @param profile
 *            3G profile
 * @return list of RRC State range values.
 */
private List<RrcStateRange> create3G(List<PacketInfo> packetlist, Profile3G profile, double traceDuration) {
    List<PacketInfo> packetInfos = packetlist;
    List<RrcStateRange> result = new ArrayList<RrcStateRange>();
    if (packetInfos != null && !packetInfos.isEmpty()) {
        // Get important profile info
        double idleDchPromoAvg = profile.getIdleDchPromoAvg();
        double idleDchPromoMin = profile.getIdleDchPromoMin();
        double idleDchPromoMax = profile.getIdleDchPromoMax();
        double fachDchPromoAvg = profile.getFachDchPromoAvg();
        double fachDchPromoMin = profile.getFachDchPromoMin();
        double fachDchPromoMax = profile.getFachDchPromoMax();
        double dchFachTimer = profile.getDchFachTimer();
        double fachIdleTimer = profile.getFachIdleTimer();
        double timer = 0;
        DchDemotionQueue dchDemotionQueue = new DchDemotionQueue(profile);
        FachQueue fachQueue = new FachQueue(profile);
        // Set up initial packet
        PacketInfo prevPacket = packetInfos.get(0);
        double currTimeStamp = prevPacket.getTimeStamp();
        prevPacket.setStateMachine(RRCState.PROMO_IDLE_DCH);
        // Add initial idle state
        addStateRangeEx(result, 0, Double.MAX_VALUE, RRCState.STATE_IDLE, currTimeStamp);
        for (int i = 1; i <= packetInfos.size(); ++i) {
            PacketInfo packet;
            PacketDirection dir;
            int currLen;
            if (i >= packetInfos.size()) {
                // The last iteration of this loop
                packet = null;
                dir = PacketDirection.UPLINK;
                currTimeStamp = Double.MAX_VALUE;
                currLen = 0;
            } else {
                // Iteration on a packet
                packet = packetInfos.get(i);
                dir = packet.getDir();
                currTimeStamp = packet.getTimeStamp();
                currLen = packet.getLen();
            }
            double prevTimeStamp = (prevPacket == null ? 0.0 : prevPacket.getTimeStamp());
            double deltaTime = currTimeStamp - prevTimeStamp;
            // the next state to be determined
            RRCState state = null;
            RRCState promoState = (prevPacket == null ? RRCState.STATE_IDLE : prevPacket.getStateMachine());
            if (promoState == RRCState.PROMO_IDLE_DCH || promoState == RRCState.PROMO_FACH_DCH) {
                double promoAvg, promoMin, promoMax;
                if (promoState == RRCState.PROMO_IDLE_DCH) {
                    promoAvg = idleDchPromoAvg;
                    promoMin = idleDchPromoMin;
                    promoMax = idleDchPromoMax;
                } else {
                    promoAvg = fachDchPromoAvg;
                    promoMin = fachDchPromoMin;
                    promoMax = fachDchPromoMax;
                }
                if (dir == PacketDirection.UPLINK && timer + deltaTime <= promoMin) {
                    // Case
                    // 1
                    prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, promoState, currTimeStamp);
                    state = promoState;
                    timer += deltaTime;
                } else if (dir == PacketDirection.DOWNLINK && timer + deltaTime <= promoMin) {
                    // TODO: handle an error situation here: a DOWNLINK DCH
                    // packet follows "immediately" after a packet on
                    // FACH/IDLE
                    // promotion
                    prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, promoState, currTimeStamp);
                    state = promoState;
                    timer += deltaTime;
                } else if (timer + deltaTime <= promoMax) {
                    // Case 2
                    prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, promoState, currTimeStamp);
                    state = RRCState.STATE_DCH;
                    dchDemotionQueue.init(currTimeStamp, currLen, dir);
                } else if (timer + deltaTime <= promoAvg + dchFachTimer) {
                    // Case
                    // 3
                    prevTimeStamp = addStateRangeEx(result, prevTimeStamp, promoAvg - timer, promoState, currTimeStamp);
                    prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_DCH, currTimeStamp);
                    state = RRCState.STATE_DCH;
                    dchDemotionQueue.init(currTimeStamp, currLen, dir);
                } else if (timer + deltaTime <= promoAvg + dchFachTimer + fachIdleTimer) {
                    // 4
                    if (dir == PacketDirection.DOWNLINK) {
                        fachQueue.init();
                        if (fachQueue.simFACH(currTimeStamp, dir, currLen)) {
                            // FACH->DCH
                            double tMax0 = currTimeStamp - fachDchPromoAvg;
                            prevTimeStamp = addStateRangeEx(result, prevTimeStamp, promoAvg - timer, promoState, tMax0);
                            prevTimeStamp = addStateRangeEx(result, prevTimeStamp, dchFachTimer, RRCState.TAIL_DCH, tMax0);
                            prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_FACH, tMax0);
                            // promoTime = tMax - tt;
                            prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.PROMO_FACH_DCH, currTimeStamp);
                            state = RRCState.STATE_DCH;
                            dchDemotionQueue.init(currTimeStamp, currLen, dir);
                        } else {
                            prevTimeStamp = addStateRangeEx(result, prevTimeStamp, promoAvg - timer, promoState, currTimeStamp);
                            prevTimeStamp = addStateRangeEx(result, prevTimeStamp, dchFachTimer, RRCState.TAIL_DCH, currTimeStamp);
                            prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_FACH, currTimeStamp);
                            state = RRCState.STATE_FACH;
                        }
                    } else {
                        // downlink
                        fachQueue.init();
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, promoAvg - timer, promoState, currTimeStamp);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, dchFachTimer, RRCState.TAIL_DCH, currTimeStamp);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_FACH, currTimeStamp);
                        if (fachQueue.simFACH(currTimeStamp, dir, currLen)) {
                            state = RRCState.PROMO_FACH_DCH;
                            timer = 0;
                        } else {
                            state = RRCState.STATE_FACH;
                        }
                    }
                } else {
                    // case 5
                    if (dir == PacketDirection.UPLINK) {
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, promoAvg - timer, promoState, currTimeStamp);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, dchFachTimer, RRCState.TAIL_DCH, currTimeStamp);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, fachIdleTimer, RRCState.TAIL_FACH, currTimeStamp);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_IDLE, currTimeStamp);
                        state = RRCState.PROMO_IDLE_DCH;
                        timer = 0;
                    } else {
                        // downlink
                        double tMax0 = currTimeStamp - idleDchPromoAvg;
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, promoAvg - timer, promoState, tMax0);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, dchFachTimer, RRCState.TAIL_DCH, tMax0);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, fachIdleTimer, RRCState.TAIL_FACH, tMax0);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_IDLE, tMax0);
                        // promoTime = tMax - tt;
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.PROMO_IDLE_DCH, currTimeStamp);
                        state = RRCState.STATE_DCH;
                        dchDemotionQueue.init(currTimeStamp, currLen, dir);
                    }
                }
            // break;
            } else if (promoState == RRCState.STATE_DCH) {
                // ***
                double dchTail = dchDemotionQueue.getDCHTail(currTimeStamp);
                if (deltaTime <= dchTail + 1e-5) {
                    // DCH Case 1
                    prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_DCH, currTimeStamp);
                    state = RRCState.STATE_DCH;
                    dchDemotionQueue.update(currTimeStamp, currLen, dir);
                } else if (deltaTime <= dchTail + fachIdleTimer) {
                    // 2
                    if (dir == PacketDirection.DOWNLINK) {
                        // downlink
                        fachQueue.init();
                        if (fachQueue.simFACH(currTimeStamp, dir, currLen)) {
                            double tMax0 = currTimeStamp - fachDchPromoAvg;
                            changeStateRangeBack(result, dchFachTimer - dchTail, RRCState.TAIL_DCH);
                            prevTimeStamp = addStateRangeEx(result, prevTimeStamp, dchTail, RRCState.TAIL_DCH, tMax0);
                            prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_FACH, tMax0);
                            // promoTime = tMax - tt;
                            prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.PROMO_FACH_DCH, currTimeStamp);
                            state = RRCState.STATE_DCH;
                            dchDemotionQueue.init(currTimeStamp, currLen, dir);
                        } else {
                            changeStateRangeBack(result, dchFachTimer - dchTail, RRCState.TAIL_DCH);
                            prevTimeStamp = addStateRangeEx(result, prevTimeStamp, dchTail, RRCState.TAIL_DCH, currTimeStamp);
                            prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_FACH, currTimeStamp);
                            state = RRCState.STATE_FACH;
                        }
                    } else {
                        // uplink
                        fachQueue.init();
                        changeStateRangeBack(result, dchFachTimer - dchTail, RRCState.TAIL_DCH);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, dchTail, RRCState.TAIL_DCH, currTimeStamp);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_FACH, currTimeStamp);
                        if (fachQueue.simFACH(currTimeStamp, dir, currLen)) {
                            state = RRCState.PROMO_FACH_DCH;
                            timer = 0;
                        } else {
                            state = RRCState.STATE_FACH;
                        }
                    }
                } else {
                    // DCH Case 3
                    if (dir == PacketDirection.UPLINK) {
                        // uplink
                        changeStateRangeBack(result, dchFachTimer - dchTail, RRCState.TAIL_DCH);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, dchTail, RRCState.TAIL_DCH, currTimeStamp);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, fachIdleTimer, RRCState.TAIL_FACH, currTimeStamp);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_IDLE, currTimeStamp);
                        state = RRCState.PROMO_IDLE_DCH;
                        timer = 0;
                    } else {
                        // downlink
                        double tMax0 = currTimeStamp - idleDchPromoAvg;
                        changeStateRangeBack(result, dchFachTimer - dchTail, RRCState.TAIL_DCH);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, dchTail, RRCState.TAIL_DCH, tMax0);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, fachIdleTimer, RRCState.TAIL_FACH, tMax0);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_IDLE, tMax0);
                        // promoTime = tMax - tt;
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.PROMO_IDLE_DCH, currTimeStamp);
                        state = RRCState.STATE_DCH;
                        dchDemotionQueue.init(currTimeStamp, currLen, dir);
                    }
                }
            // break;
            } else if (promoState == RRCState.STATE_FACH) {
                if (deltaTime <= fachIdleTimer) {
                    if (dir == PacketDirection.UPLINK) {
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_FACH, currTimeStamp);
                        if (fachQueue.simFACH(currTimeStamp, dir, currLen)) {
                            state = RRCState.PROMO_FACH_DCH;
                            timer = 0;
                        } else {
                            state = RRCState.STATE_FACH;
                        }
                    } else {
                        // downlink
                        if (fachQueue.simFACH(currTimeStamp, dir, currLen)) {
                            double tMax0 = currTimeStamp - fachDchPromoAvg;
                            /*
								 * TODO: ( diff ) handle the case where promo
								 * delay is 0 ( for what - if )
								 */
                            if (tMax0 > prevTimeStamp || fachDchPromoAvg < 1e-6) {
                                prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_FACH, tMax0);
                                // promoTime = tMax - tt;
                                prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.PROMO_FACH_DCH, currTimeStamp);
                            } else {
                                // *** handle an error situation here: a
                                // DOWNLINK DCH packet follows "immediately"
                                // after a packet on FACH
                                // try
                                tMax0 = currTimeStamp - fachDchPromoMin;
                                // y?
                                if (tMax0 > prevTimeStamp) {
                                    prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_FACH, tMax0);
                                    // promoTime = tMax - tt;
                                    prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.PROMO_FACH_DCH, currTimeStamp);
                                } else {
                                    // still not working - try to
                                    // insert a
                                    // promotion after some previous
                                    // packet
                                    boolean bFixed = false;
                                    for (int ii = i - 1; ii > 0; ii--) {
                                        PacketInfo earlierPacket = packetInfos.get(ii);
                                        if (earlierPacket.getStateMachine() == RRCState.STATE_FACH) {
                                            // FACH-DCH promo: from
                                            // packets[ii].ts to
                                            // packets[ii].ts+y
                                            // DCH: from packets[ii].ts+y to
                                            // tMax
                                            double piTimeStamp = packetInfos.get(ii).getTimeStamp();
                                            if (earlierPacket.getDir() == PacketDirection.UPLINK && currTimeStamp >= piTimeStamp + fachDchPromoMin) {
                                                int resultSize = result.size() - 1;
                                                // boolean bDone = false;
                                                for (int jj = resultSize; jj > 0; jj--) {
                                                    // double EPS = 1e-4;
                                                    if (result.get(jj).getBeginTime() == piTimeStamp) {
                                                        for (int k = 0; k < resultSize - jj + 1; k++) {
                                                            result.remove(result.size() - 1);
                                                        }
                                                        double avgDchPromo;
                                                        if (currTimeStamp >= piTimeStamp + fachDchPromoAvg) {
                                                            avgDchPromo = fachDchPromoAvg;
                                                        } else {
                                                            avgDchPromo = fachDchPromoMin;
                                                        }
                                                        result.add(new RrcStateRange(piTimeStamp, piTimeStamp + avgDchPromo, RRCState.PROMO_FACH_DCH));
                                                        result.add(new RrcStateRange(piTimeStamp + avgDchPromo, prevTimeStamp, RRCState.STATE_DCH));
                                                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_DCH, currTimeStamp);
                                                        break;
                                                    }
                                                // #undef EPS
                                                }
                                                bFixed = true;
                                                break;
                                            }
                                        } else {
                                            break;
                                        }
                                    }
                                    if (!bFixed) {
                                        // still not working - force it on
                                        // FACH
                                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_FACH, currTimeStamp);
                                        state = RRCState.STATE_FACH;
                                        fachQueue.init();
                                    }
                                }
                            }
                            // finish handling the error case
                            state = RRCState.STATE_DCH;
                            dchDemotionQueue.init(currTimeStamp, currLen, dir);
                        } else {
                            prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_FACH, currTimeStamp);
                            state = RRCState.STATE_FACH;
                        }
                    }
                } else {
                    if (dir == PacketDirection.UPLINK) {
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, fachIdleTimer, RRCState.TAIL_FACH, currTimeStamp);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_IDLE, currTimeStamp);
                        state = RRCState.PROMO_IDLE_DCH;
                        timer = 0;
                    } else {
                        // downlink
                        double tMax0 = currTimeStamp - idleDchPromoAvg;
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, fachIdleTimer, RRCState.TAIL_FACH, tMax0);
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.STATE_IDLE, tMax0);
                        // promoTime = tMax - tt;
                        prevTimeStamp = addStateRangeEx(result, prevTimeStamp, Double.MAX_VALUE, RRCState.PROMO_IDLE_DCH, currTimeStamp);
                        state = RRCState.STATE_DCH;
                        dchDemotionQueue.init(currTimeStamp, currLen, dir);
                    }
                }
            }
            if (packet != null) {
                packet.setStateMachine(state);
            }
            prevPacket = packet;
        }
    }
    result = compressStateRanges(result);
    // Truncate state ranges at end of trace
    Iterator<RrcStateRange> iter = result.iterator();
    double prevTimeStamp = 0.0;
    while (iter.hasNext()) {
        RrcStateRange rrc = iter.next();
        if (rrc.getBeginTime() >= traceDuration) {
            iter.remove();
        }
        if (rrc.getEndTime() > traceDuration) {
            rrc.setEndTime(traceDuration);
        }
        prevTimeStamp = rrc.getEndTime();
    }
    if (prevTimeStamp < traceDuration) {
        // Add idle time to end of trace
        result.add(new RrcStateRange(prevTimeStamp, traceDuration, RRCState.STATE_IDLE));
    }
    return result;
}
Also used : FachQueue(com.att.aro.core.packetanalysis.pojo.FachQueue) ArrayList(java.util.ArrayList) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) PacketDirection(com.att.aro.core.packetreader.pojo.PacketDirection) DchDemotionQueue(com.att.aro.core.packetanalysis.pojo.DchDemotionQueue) RRCState(com.att.aro.core.packetanalysis.pojo.RRCState) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo)

Aggregations

RRCState (com.att.aro.core.packetanalysis.pojo.RRCState)5 RrcStateRange (com.att.aro.core.packetanalysis.pojo.RrcStateRange)5 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)4 Profile (com.att.aro.core.configuration.pojo.Profile)3 ArrayList (java.util.ArrayList)2 IProfileFactory (com.att.aro.core.configuration.IProfileFactory)1 ProfileLTE (com.att.aro.core.configuration.pojo.ProfileLTE)1 DchDemotionQueue (com.att.aro.core.packetanalysis.pojo.DchDemotionQueue)1 FachQueue (com.att.aro.core.packetanalysis.pojo.FachQueue)1 IPPacket (com.att.aro.core.packetreader.pojo.IPPacket)1 PacketDirection (com.att.aro.core.packetreader.pojo.PacketDirection)1 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)1 UDPPacket (com.att.aro.core.packetreader.pojo.UDPPacket)1 Color (java.awt.Color)1 Paint (java.awt.Paint)1 TexturePaint (java.awt.TexturePaint)1 EnumMap (java.util.EnumMap)1 LinkedHashMap (java.util.LinkedHashMap)1 XYToolTipGenerator (org.jfree.chart.labels.XYToolTipGenerator)1 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)1