Search in sources :

Example 1 with Throughput

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

the class ProfileFactoryImpl method energyLTE.

@Override
public double energyLTE(double time1, double time2, RRCState state, ProfileLTE prof, List<PacketInfo> packets) {
    double deltaTime = time2 - time1;
    double result = 0.0;
    switch(state) {
        case LTE_PROMOTION:
            return deltaTime * prof.getLtePromotionPower();
        case LTE_CR_TAIL:
            // Assume no throughput
            return deltaTime * prof.getLteBeta();
        case LTE_CONTINUOUS:
            for (Throughput throughput : throughputcalculator.calculateThroughput(time1, time2, prof.getThroughputWindow(), packets)) {
                result += (((prof.getLteAlphaUp() / 1000.0) * throughput.getUploadMbps()) + ((prof.getLteAlphaDown() / 1000.0) * throughput.getDownloadMbps()) + prof.getLteBeta()) * throughput.getSamplePeriod();
            }
            break;
        case LTE_DRX_SHORT:
            return (deltaTime / prof.getDrxShortPingPeriod()) * ((prof.getDrxPingTime() * prof.getDrxShortPingPower()) + ((prof.getDrxShortPingPeriod() - prof.getDrxPingTime()) * prof.getLteTailPower()));
        case LTE_DRX_LONG:
            return (deltaTime / prof.getDrxLongPingPeriod()) * ((prof.getDrxPingTime() * prof.getDrxLongPingPower()) + ((prof.getDrxLongPingPeriod() - prof.getDrxPingTime()) * prof.getLteTailPower()));
        case LTE_IDLE:
            // Add energy for full idle ping periods
            result = ((int) (deltaTime / prof.getIdlePingPeriod())) * ((prof.getIdlePingTime() * prof.getLteIdlePingPower()) + ((prof.getIdlePingPeriod() - prof.getIdlePingTime()) * prof.getLteIdlePower()));
            // Add residual energy for partial idle ping period
            double tres = deltaTime % prof.getIdlePingPeriod();
            result += tres <= prof.getIdlePingTime() ? tres * prof.getLteIdlePingPower() : ((prof.getIdlePingTime() * prof.getLteIdlePingPower()) + ((tres - prof.getIdlePingTime()) * prof.getLteIdlePingPower()));
            break;
        default:
            break;
    }
    return result;
}
Also used : Throughput(com.att.aro.core.packetanalysis.pojo.Throughput)

Example 2 with Throughput

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

the class ThroughputCalculatorImplTest method calculateThroughput_b.

// condition, head.getTimeStamp() > beginTS, tail.getTimeStamp() > maxTS , adjust input the variable
@Test
public void calculateThroughput_b() {
    Date date = new Date();
    List<Throughput> testResult = new ArrayList<Throughput>();
    List<PacketInfo> packets = new ArrayList<PacketInfo>();
    PacketInfo pktInfo01 = Mockito.mock(PacketInfo.class);
    Mockito.when(pktInfo01.getDir()).thenReturn(PacketDirection.UPLINK);
    Mockito.when(pktInfo01.getTimeStamp()).thenReturn(date.getTime() + 20000.0);
    packets.add(pktInfo01);
    PacketInfo pktInfo02 = Mockito.mock(PacketInfo.class);
    Mockito.when(pktInfo02.getDir()).thenReturn(PacketDirection.DOWNLINK);
    Mockito.when(pktInfo02.getTimeStamp()).thenReturn(date.getTime() + 20400.0);
    packets.add(pktInfo02);
    PacketInfo pktInfo03 = Mockito.mock(PacketInfo.class);
    Mockito.when(pktInfo03.getDir()).thenReturn(PacketDirection.DOWNLINK);
    Mockito.when(pktInfo03.getTimeStamp()).thenReturn(date.getTime() + 20500.0);
    packets.add(pktInfo03);
    PacketInfo pktInfo04 = Mockito.mock(PacketInfo.class);
    Mockito.when(pktInfo04.getDir()).thenReturn(PacketDirection.DOWNLINK);
    Mockito.when(pktInfo04.getTimeStamp()).thenReturn(date.getTime() + 41000.0);
    packets.add(pktInfo04);
    PacketInfo pktInfo05 = Mockito.mock(PacketInfo.class);
    Mockito.when(pktInfo05.getDir()).thenReturn(PacketDirection.DOWNLINK);
    Mockito.when(pktInfo05.getTimeStamp()).thenReturn(date.getTime() + 71000.0);
    packets.add(pktInfo05);
    PacketInfo pktInfo06 = Mockito.mock(PacketInfo.class);
    Mockito.when(pktInfo06.getDir()).thenReturn(PacketDirection.UPLINK);
    Mockito.when(pktInfo06.getTimeStamp()).thenReturn(date.getTime() + 72000.0);
    packets.add(pktInfo06);
    testResult = throughputCalculator.calculateThroughput(date.getTime() + 0.0, date.getTime() + 73000.0, 60000.0, packets);
    assertEquals(2, testResult.size());
}
Also used : ArrayList(java.util.ArrayList) Throughput(com.att.aro.core.packetanalysis.pojo.Throughput) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) Date(java.util.Date) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 3 with Throughput

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

the class ThroughputPlot method populate.

public void populate(XYPlot plot, AROTraceData analysis) {
    XYSeries series = new XYSeries(0);
    if (analysis != null) {
        // Get packet iterators
        List<PacketInfo> packets = analysis.getAnalyzerResult().getTraceresult().getAllpackets();
        final double maxTS = analysis.getAnalyzerResult().getTraceresult().getTraceDuration();
        final List<String> tooltipList = new ArrayList<String>(1000);
        Double zeroTime = null;
        double lastTime = 0.0;
        double startTime = analysis.getAnalyzerResult().getFilter().getTimeRange().getBeginTime();
        for (Throughput t : throughputHelper.calculateThroughput(startTime, maxTS, analysis.getAnalyzerResult().getProfile().getThroughputWindow(), packets)) {
            double time = t.getTime();
            double kbps = t.getKbps();
            if (kbps != 0.0) {
                if (zeroTime != null && zeroTime.doubleValue() != lastTime) {
                    series.add(lastTime, 0.0);
                    tooltipList.add(MessageFormat.format(THROUGHPUT_TOOLTIP, 0.0));
                }
                // Add slot to data set
                series.add(time, kbps);
                tooltipList.add(MessageFormat.format(THROUGHPUT_TOOLTIP, kbps));
                zeroTime = null;
            } else {
                if (zeroTime == null) {
                    // Add slot to data set
                    series.add(time, kbps);
                    tooltipList.add(MessageFormat.format(THROUGHPUT_TOOLTIP, kbps));
                    zeroTime = Double.valueOf(time);
                }
            }
            lastTime = time;
        }
        plot.getRenderer().setBaseToolTipGenerator(new XYToolTipGenerator() {

            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {
                // Tooltip displays throughput value
                return tooltipList.get(item);
            }
        });
    }
    plot.setDataset(new XYSeriesCollection(series));
// return plot;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) ArrayList(java.util.ArrayList) Throughput(com.att.aro.core.packetanalysis.pojo.Throughput) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) XYDataset(org.jfree.data.xy.XYDataset) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection)

Example 4 with Throughput

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

the class ThroughputCalculatorImpl method calculateThroughput.

public List<Throughput> calculateThroughput(double startTime, double endTime, double window, List<PacketInfo> packets) {
    List<Throughput> result = new ArrayList<Throughput>();
    List<PacketInfo> split = new ArrayList<>();
    if (window < 0.00001 || endTime - startTime < 0.00001) {
        return Collections.emptyList();
    }
    double splitStart = startTime;
    double splitEnd = startTime + window;
    for (PacketInfo packet : packets) {
        double stamp = packet.getTimeStamp();
        if (stamp < startTime) {
            continue;
        } else if (stamp >= endTime) {
            result.add(getThroughput(splitStart, splitEnd, split));
            break;
        } else if (stamp >= splitEnd) {
            while (stamp >= splitEnd) {
                result.add(getThroughput(splitStart, splitEnd, split));
                splitStart = splitEnd;
                splitEnd = splitStart + window;
                split = new ArrayList<>();
            }
            split.add(packet);
        } else if (stamp >= splitStart) {
            split.add(packet);
        }
    }
    do {
        result.add(getThroughput(splitStart, splitEnd, split));
        splitStart = splitEnd;
        splitEnd = splitStart + window;
        split = new ArrayList<>();
    } while (endTime >= splitStart);
    return result;
}
Also used : ArrayList(java.util.ArrayList) Throughput(com.att.aro.core.packetanalysis.pojo.Throughput) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo)

Example 5 with Throughput

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

the class ThroughputCalculatorImpl method getThroughput.

private Throughput getThroughput(double startTime, double endTime, List<PacketInfo> packets) {
    long up = 0;
    long down = 0;
    for (PacketInfo packet : packets) {
        if (packet.getDir() == null || packet.getDir() == PacketDirection.UNKNOWN) {
            continue;
        } else if (packet.getDir() == PacketDirection.UPLINK) {
            up += packet.getLen();
        } else {
            down += packet.getLen();
        }
    }
    return new Throughput(startTime, endTime, up, down);
}
Also used : PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) Throughput(com.att.aro.core.packetanalysis.pojo.Throughput)

Aggregations

Throughput (com.att.aro.core.packetanalysis.pojo.Throughput)6 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)5 ArrayList (java.util.ArrayList)4 BaseTest (com.att.aro.core.BaseTest)2 Date (java.util.Date)2 Test (org.junit.Test)2 XYToolTipGenerator (org.jfree.chart.labels.XYToolTipGenerator)1 XYDataset (org.jfree.data.xy.XYDataset)1 XYSeries (org.jfree.data.xy.XYSeries)1 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)1