Search in sources :

Example 81 with PacketInfo

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

the class RrcStateRangeFactoryImpl method createLTE.

/**
 * This method contains the main algorithm for creating the List of
 * RrcStateRange for a LTE profile
 *
 * @param analysisData
 *            Analysis data
 * @param profile
 *            LTE profile
 * @return list of RRC State range values.
 */
private List<RrcStateRange> createLTE(List<PacketInfo> packetlist, ProfileLTE profile, double traceDuration) {
    // Create results list
    ArrayList<RrcStateRange> result = new ArrayList<RrcStateRange>();
    // Iterate through packets in trace
    if (packetlist == null) {
        result.add(new RrcStateRange(0.0, traceDuration, RRCState.LTE_IDLE));
        return result;
    }
    Iterator<PacketInfo> iter = packetlist.iterator();
    PacketInfo packet;
    if (iter.hasNext()) {
        // Track time of state changes
        double timer = 0.0;
        // Keep timestamp of previous packet in iteration
        packet = iter.next();
        packet.setStateMachine(RRCState.LTE_CONTINUOUS);
        double last = packet.getTimeStamp();
        // First packet starts continuous reception
        timer = promoteLTE(result, timer, last, profile);
        while (iter.hasNext()) {
            packet = iter.next();
            packet.setStateMachine(RRCState.LTE_CONTINUOUS);
            double curr = packet.getTimeStamp();
            // Check to see if we dropped to CR tail
            if (curr - last > profile.getInactivityTimer()) {
                timer = tailLTE(result, timer, last, curr, profile);
                // packet
                if (timer < curr) {
                    timer = promoteLTE(result, timer, curr, profile);
                }
            }
            // Save current packet time as last packet for next iteration
            last = curr;
        }
        // Do final LTE tail
        timer = tailLTE(result, timer, last, traceDuration, profile);
        // Check for final idle time
        if (timer < traceDuration) {
            result.add(new RrcStateRange(timer, traceDuration, RRCState.LTE_IDLE));
        }
    } else {
        // State is idle for the entire trace
        result.add(new RrcStateRange(0.0, traceDuration, RRCState.LTE_IDLE));
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo)

Example 82 with PacketInfo

use of com.att.aro.core.packetanalysis.pojo.PacketInfo 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 83 with PacketInfo

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

Example 84 with PacketInfo

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

the class PacketAnalyzerImpl method getStatistic.

@Override
public Statistic getStatistic(List<PacketInfo> packetInfos) {
    Statistic stat = new Statistic();
    Set<String> appNames = new HashSet<String>();
    if (!packetInfos.isEmpty() && packetInfos.size() > 0) {
        long totalHTTPSBytes = 0;
        long totalBytes = 0;
        long totalTCPBytes = 0;
        long totalPayloadBytes = 0;
        long totalTCPPayloadBytes = 0;
        int totalTCPPackets = 0;
        double minTCPPacketTimestamp = Double.MAX_VALUE;
        double maxTCPPacketTimestamp = Double.MIN_VALUE;
        List<IPPacketSummary> ipPacketSummary = new ArrayList<>();
        List<ApplicationPacketSummary> applicationPacketSummary = new ArrayList<>();
        Map<Integer, Integer> packetSizeToCountMap = new HashMap<>();
        Map<String, PacketCounter> appPackets = new HashMap<>();
        Map<InetAddress, PacketCounter> ipPackets = new HashMap<>();
        for (PacketInfo packetInfo : packetInfos) {
            if (packetInfo != null) {
                totalBytes += packetInfo.getLen();
                totalPayloadBytes += packetInfo.getPacket().getPayloadLen();
                PacketCounter pCounter;
                if (packetInfo.getPacket() instanceof TCPPacket) {
                    ++totalTCPPackets;
                    minTCPPacketTimestamp = Math.min(minTCPPacketTimestamp, packetInfo.getTimeStamp());
                    maxTCPPacketTimestamp = Math.max(maxTCPPacketTimestamp, packetInfo.getTimeStamp());
                    TCPPacket tcp = (TCPPacket) packetInfo.getPacket();
                    totalTCPBytes += tcp.getPacketLength();
                    totalTCPPayloadBytes += tcp.getPayloadLen();
                    if (tcp.isSsl() || tcp.getDestinationPort() == 443 || tcp.getSourcePort() == 443) {
                        totalHTTPSBytes += tcp.getPayloadLen();
                    }
                }
                if (packetInfo.getPacket() instanceof IPPacket) {
                    // Count packets by packet size
                    Integer packetSize = packetInfo.getPacket().getPayloadLen();
                    Integer iValue = packetSizeToCountMap.get(packetSize);
                    if (iValue == null) {
                        iValue = 1;
                    } else {
                        iValue++;
                    }
                    packetSizeToCountMap.put(packetSize, iValue);
                    // Get IP address summary
                    InetAddress ipAddress = packetInfo.getRemoteIPAddress();
                    pCounter = ipPackets.get(ipAddress);
                    if (pCounter == null) {
                        pCounter = new PacketCounter();
                        ipPackets.put(ipAddress, pCounter);
                    }
                    pCounter.add(packetInfo);
                }
                String appName = packetInfo.getAppName();
                appNames.add(appName);
                pCounter = appPackets.get(appName);
                if (pCounter == null) {
                    pCounter = new PacketCounter();
                    appPackets.put(appName, pCounter);
                }
                pCounter.add(packetInfo);
            }
        }
        for (Map.Entry<InetAddress, PacketCounter> ipPacketMap : ipPackets.entrySet()) {
            ipPacketSummary.add(new IPPacketSummary(ipPacketMap.getKey(), ipPacketMap.getValue().getPacketCount(), ipPacketMap.getValue().getTotalBytes(), ipPacketMap.getValue().getTotalPayloadBytes()));
        }
        for (Map.Entry<String, PacketCounter> appPacketMap : appPackets.entrySet()) {
            applicationPacketSummary.add(new ApplicationPacketSummary(appPacketMap.getKey(), appPacketMap.getValue().getPacketCount(), appPacketMap.getValue().getTotalBytes(), appPacketMap.getValue().getTotalPayloadBytes()));
        }
        double packetsDuration = packetInfos.get(packetInfos.size() - 1).getTimeStamp() - packetInfos.get(0).getTimeStamp();
        double tcpPacketDuration = (maxTCPPacketTimestamp > minTCPPacketTimestamp) ? (maxTCPPacketTimestamp - minTCPPacketTimestamp) : 0.0d;
        double avgKbps = packetsDuration != 0 ? totalBytes * 8.0 / 1000.0 / packetsDuration : 0.0d;
        double avgTCPKbps = tcpPacketDuration != 0 ? totalTCPBytes * 8.0 / 1000.0 / tcpPacketDuration : 0.0d;
        stat.setApplicationPacketSummary(applicationPacketSummary);
        stat.setAverageKbps(avgKbps);
        stat.setAverageTCPKbps(avgTCPKbps);
        stat.setIpPacketSummary(ipPacketSummary);
        stat.setPacketDuration(packetsDuration);
        stat.setTcpPacketDuration(tcpPacketDuration);
        stat.setTotalByte(totalBytes);
        stat.setTotalPayloadBytes(totalPayloadBytes);
        stat.setTotalTCPBytes(totalTCPBytes);
        stat.setTotalTCPPayloadBytes(totalTCPPayloadBytes);
        stat.setTotalHTTPSByte(totalHTTPSBytes);
        stat.setTotalPackets(packetInfos.size());
        stat.setTotalTCPPackets(totalTCPPackets);
        stat.setPacketSizeToCountMap(packetSizeToCountMap);
    }
    stat.setAppName(appNames);
    return stat;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PacketCounter(com.att.aro.core.packetanalysis.pojo.PacketCounter) Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) IPPacketSummary(com.att.aro.core.packetanalysis.pojo.IPPacketSummary) HashSet(java.util.HashSet) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) ApplicationPacketSummary(com.att.aro.core.packetanalysis.pojo.ApplicationPacketSummary) InetAddress(java.net.InetAddress) Map(java.util.Map) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) IPPacket(com.att.aro.core.packetreader.pojo.IPPacket)

Example 85 with PacketInfo

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

the class PacketAnalyzerImplTest method Test_analyzeTraceFile_returnIsPacketAnalyzerResult.

@Test
@Ignore
public void Test_analyzeTraceFile_returnIsPacketAnalyzerResult() throws Exception {
    iPacketAnalyzer.setProfileFactory(profilefactory);
    InetAddress iAdr = Mockito.mock(InetAddress.class);
    InetAddress iAdr1 = Mockito.mock(InetAddress.class);
    Mockito.when(iAdr.getAddress()).thenReturn(new byte[] { 89, 10, 1, 1 });
    Mockito.when(iAdr1.getAddress()).thenReturn(new byte[] { 72, 12, 13, 1 });
    Set<InetAddress> inetSet = new HashSet<InetAddress>();
    inetSet.add(iAdr);
    inetSet.add(iAdr1);
    DomainNameSystem dns = Mockito.mock(DomainNameSystem.class);
    Mockito.when(dns.getIpAddresses()).thenReturn(inetSet);
    Mockito.when(dns.getDomainName()).thenReturn("www.att.com");
    UDPPacket udpPacket = Mockito.mock(UDPPacket.class);
    Mockito.when(udpPacket.isDNSPacket()).thenReturn(true);
    Mockito.when(udpPacket.getDns()).thenReturn(dns);
    Mockito.when(udpPacket.getSourcePort()).thenReturn(83);
    Mockito.when(udpPacket.getDestinationPort()).thenReturn(84);
    Mockito.when(udpPacket.getDestinationIPAddress()).thenReturn(iAdr);
    PacketInfo packetInfo1 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo1.getPacket()).thenReturn(udpPacket);
    Mockito.when(packetInfo1.getDir()).thenReturn(PacketDirection.UPLINK);
    Mockito.when(packetInfo1.getPayloadLen()).thenReturn(0);
    Mockito.when(packetInfo1.getLen()).thenReturn(10);
    Mockito.when(packetInfo1.getAppName()).thenReturn("Test1");
    Mockito.when(packetInfo1.getTcpFlagString()).thenReturn("TestString");
    Mockito.when(packetInfo1.getTimeStamp()).thenReturn(500d);
    InetAddress iAdr2 = Mockito.mock(InetAddress.class);
    Mockito.when(iAdr2.getAddress()).thenReturn(new byte[] { 95, 10, 1, 1 });
    TCPPacket tcpPacket = Mockito.mock(TCPPacket.class);
    Mockito.when(tcpPacket.getSourcePort()).thenReturn(81);
    Mockito.when(tcpPacket.getDestinationPort()).thenReturn(82);
    Mockito.when(tcpPacket.getDestinationIPAddress()).thenReturn(iAdr2);
    Mockito.when(tcpPacket.isSYN()).thenReturn(true);
    Mockito.when(tcpPacket.isFIN()).thenReturn(true);
    Mockito.when(tcpPacket.isRST()).thenReturn(true);
    Mockito.when(tcpPacket.getTimeStamp()).thenReturn(1000d);
    PacketInfo packetInfo2 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo2.getPacket()).thenReturn(tcpPacket);
    Mockito.when(packetInfo2.getDir()).thenReturn(PacketDirection.UPLINK);
    Mockito.when(packetInfo2.getTcpInfo()).thenReturn(TcpInfo.TCP_ESTABLISH);
    Mockito.when(packetInfo2.getPayloadLen()).thenReturn(0);
    Mockito.when(packetInfo2.getLen()).thenReturn(15);
    Mockito.when(packetInfo2.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo2.getTcpFlagString()).thenReturn("Test2String");
    Mockito.when(packetInfo2.getTimeStamp()).thenReturn(10d);
    TCPPacket tcpPacket2 = Mockito.mock(TCPPacket.class);
    Mockito.when(tcpPacket2.getSourcePort()).thenReturn(95);
    Mockito.when(tcpPacket2.getDestinationPort()).thenReturn(99);
    Mockito.when(tcpPacket2.getDestinationIPAddress()).thenReturn(iAdr2);
    Mockito.when(tcpPacket2.isSYN()).thenReturn(true);
    Mockito.when(tcpPacket2.isFIN()).thenReturn(true);
    Mockito.when(tcpPacket2.isRST()).thenReturn(false);
    Mockito.when(tcpPacket2.getTimeStamp()).thenReturn(50d);
    Inet4Address address = (Inet4Address) InetAddress.getByName("192.168.1.4");
    PacketInfo packetInfo3 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo3.getPacket()).thenReturn(tcpPacket2);
    Mockito.when(packetInfo3.getDir()).thenReturn(PacketDirection.UPLINK);
    Mockito.when(packetInfo3.getTcpInfo()).thenReturn(TcpInfo.TCP_ESTABLISH);
    Mockito.when(packetInfo3.getPayloadLen()).thenReturn(0);
    Mockito.when(packetInfo3.getLen()).thenReturn(15);
    Mockito.when(packetInfo3.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo3.getTcpFlagString()).thenReturn("Test2String");
    Mockito.when(packetInfo3.getTimeStamp()).thenReturn(10d);
    Mockito.when(packetInfo3.getRemoteIPAddress()).thenReturn(address);
    List<PacketInfo> packetsList = new ArrayList<PacketInfo>();
    // Adding UDP Packet to the list
    packetsList.add(packetInfo1);
    packetsList.add(packetInfo2);
    packetsList.add(packetInfo3);
    TraceFileResult mockTraceResult = mock(TraceFileResult.class);
    List<PacketInfo> filteredPackets = new ArrayList<PacketInfo>();
    filteredPackets.add(mock(PacketInfo.class));
    when(mockTraceResult.getAllpackets()).thenReturn(packetsList);
    CpuActivityList cpuList = new CpuActivityList();
    cpuList.add(new CpuActivity());
    when(mockTraceResult.getCpuActivityList()).thenReturn(cpuList);
    when(tracereader.readTraceFile(any(String.class))).thenReturn(mockTraceResult);
    when(mockTraceResult.getTraceResultType()).thenReturn(TraceResultType.TRACE_FILE);
    ProfileLTE profileLTE = new ProfileLTE();
    when(profilefactory.createLTEdefault()).thenReturn(profileLTE);
    AnalysisFilter filter = mock(AnalysisFilter.class);
    filter.setIpv4Sel(false);
    filter.setIpv6Sel(false);
    filter.setUdpSel(false);
    iPacketAnalyzer.setEnergyModelFactory(energymodelfactory);
    iPacketAnalyzer.setBurstCollectionAnalayzer(burstcollectionanalyzer);
    iPacketAnalyzer.setRrcStateMachineFactory(statemachinefactory);
    RrcStateMachineLTE rrcstate = mock(RrcStateMachineLTE.class);
    EnergyModel energymodel = mock(EnergyModel.class);
    List<RrcStateRange> rrcstatelist = new ArrayList<RrcStateRange>();
    when(statemachinefactory.create(any(List.class), any(Profile.class), any(double.class), any(double.class), any(double.class), any(TimeRange.class))).thenReturn(rrcstate);
    when(rrcstate.getStaterangelist()).thenReturn(rrcstatelist);
    when(rrcstate.getTotalRRCEnergy()).thenReturn(1.0);
    when(energymodelfactory.create(any(Profile.class), any(double.class), any(List.class), any(List.class), any(List.class), any(List.class))).thenReturn(energymodel);
    BurstCollectionAnalysisData burstvalue = mock(BurstCollectionAnalysisData.class);
    when(burstcollectionanalyzer.analyze(any(List.class), any(Profile.class), any(Map.class), any(List.class), any(List.class), any(List.class), any(List.class))).thenReturn(burstvalue);
    // when(pktTimeUtil.getTimeRangeResult(any(AbstractTraceResult.class), any(AnalysisFilter.class)))
    // .thenReturn(value);
    PacketAnalyzerResult testResult = iPacketAnalyzer.analyzeTraceFile("", null, filter);
    assertSame(false, testResult.getFilter().isIpv4Sel());
}
Also used : CpuActivityList(com.att.aro.core.peripheral.pojo.CpuActivityList) DomainNameSystem(com.att.aro.core.packetreader.pojo.DomainNameSystem) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) ArrayList(java.util.ArrayList) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) ProfileLTE(com.att.aro.core.configuration.pojo.ProfileLTE) UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) Profile(com.att.aro.core.configuration.pojo.Profile) RrcStateMachineLTE(com.att.aro.core.packetanalysis.pojo.RrcStateMachineLTE) List(java.util.List) CpuActivityList(com.att.aro.core.peripheral.pojo.CpuActivityList) ArrayList(java.util.ArrayList) CpuActivity(com.att.aro.core.peripheral.pojo.CpuActivity) HashSet(java.util.HashSet) Inet4Address(java.net.Inet4Address) EnergyModel(com.att.aro.core.packetanalysis.pojo.EnergyModel) TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) InetAddress(java.net.InetAddress) TraceFileResult(com.att.aro.core.packetanalysis.pojo.TraceFileResult) Map(java.util.Map) Ignore(org.junit.Ignore) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Aggregations

PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)119 ArrayList (java.util.ArrayList)92 BaseTest (com.att.aro.core.BaseTest)63 Test (org.junit.Test)63 RrcStateRange (com.att.aro.core.packetanalysis.pojo.RrcStateRange)48 Session (com.att.aro.core.packetanalysis.pojo.Session)33 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)30 Profile3G (com.att.aro.core.configuration.pojo.Profile3G)26 Profile (com.att.aro.core.configuration.pojo.Profile)25 InetAddress (java.net.InetAddress)25 RRCState (com.att.aro.core.packetanalysis.pojo.RRCState)21 ProfileLTE (com.att.aro.core.configuration.pojo.ProfileLTE)18 HashSet (java.util.HashSet)16 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)14 UDPPacket (com.att.aro.core.packetreader.pojo.UDPPacket)14 Packet (com.att.aro.core.packetreader.pojo.Packet)11 HashMap (java.util.HashMap)11 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)9 DomainNameSystem (com.att.aro.core.packetreader.pojo.DomainNameSystem)9 IPPacket (com.att.aro.core.packetreader.pojo.IPPacket)9