Search in sources :

Example 1 with UDPPacket

use of com.att.aro.core.packetreader.pojo.UDPPacket in project VideoOptimzer by attdevsupport.

the class SessionManagerImpl method processPacketsAndAssembleSessions.

/**
 * Entry point into SessionManager from PacketAnalyzerImpl
 *
 * returns List<Session> sessionList
 */
public List<Session> processPacketsAndAssembleSessions(List<PacketInfo> packets) {
    LOGGER.warn("processPacketsAndAssembleSessions -> Trace path: " + tracePath);
    List<Session> sessions = new ArrayList<>();
    List<PacketInfo> udpPackets = new ArrayList<>();
    Map<InetAddress, String> hostMap = new HashMap<>();
    Map<String, Session> udpSessions = new LinkedHashMap<>();
    Map<String, PacketInfo> dnsRequestDomains = new HashMap<>();
    Map<String, List<Session>> tcpSessions = new LinkedHashMap<>();
    Map<InetAddress, PacketInfo> dnsResponsePackets = new HashMap<>();
    if (packets != null) {
        for (PacketInfo packetInfo : packets) {
            Packet packet = packetInfo.getPacket();
            if (packet instanceof UDPPacket) {
                // UDP
                udpPackets.add(packetInfo);
                if (((UDPPacket) packet).isDNSPacket()) {
                    DomainNameSystem dns = ((UDPPacket) packet).getDns();
                    if (dns != null && dns.isResponse()) {
                        for (InetAddress inet : dns.getIpAddresses()) {
                            hostMap.put(inet, dns.getDomainName());
                            dnsResponsePackets.put(inet, packetInfo);
                        }
                    } else if (dns != null && !dns.isResponse()) {
                        dnsRequestDomains.put(dns.getDomainName(), packetInfo);
                    }
                }
                associatePacketToUDPSessionAndPopulateCollections(sessions, udpSessions, packetInfo, (UDPPacket) packet);
            } else if (packet instanceof TCPPacket) {
                // TCP
                TCPPacket tcpPacket = (TCPPacket) packet;
                packetInfo.setTcpInfo(null);
                Session session = associatePacketToTCPSessionAndPopulateCollections(sessions, tcpSessions, packetInfo, tcpPacket);
                populateTCPPacketInfo(packetInfo, tcpPacket);
                session.setSsl(session.isSsl() ? session.isSsl() : tcpPacket.isSsl());
                if (tcpPacket.isDecrypted()) {
                    tcpPacket.setDataOffset(0);
                    session.setDecrypted(true);
                }
                if (session.getDnsResponsePacket() == null && dnsResponsePackets.containsKey(session.getRemoteIP())) {
                    session.setDnsResponsePacket(dnsResponsePackets.get(session.getRemoteIP()));
                    session.setDomainName((((UDPPacket) (session.getDnsResponsePacket()).getPacket()).getDns()).getIpAddresses().stream().findFirst().get().getHostName());
                }
                if (session.getDnsRequestPacket() == null && StringUtils.isNotBlank(session.getDomainName()) && dnsRequestDomains.containsKey(session.getDomainName())) {
                    session.setRemoteHostName(session.getDomainName());
                    session.setDnsRequestPacket(dnsRequestDomains.get(session.getDomainName()));
                } else {
                    session.setRemoteHostName(hostMap.get(session.getRemoteIP()));
                }
                if (tcpPacket.isSslHandshake()) {
                    session.setLastSslHandshakePacket(packetInfo);
                    if (tcpPacket.isClientHello() && StringUtils.isNotBlank(tcpPacket.getServerNameIndication())) {
                        session.setServerNameIndication(tcpPacket.getServerNameIndication());
                    }
                }
                if (packetInfo.getAppName() != null) {
                    session.getAppNames().add(packetInfo.getAppName());
                }
                if (!session.isSessionComplete() && (packetInfo.getTcpFlagString().contains("R") || packetInfo.getTcpFlagString().contains("F"))) {
                    session.setSessionComplete(true);
                }
                session.setLatency((!session.getSynAckPackets().isEmpty() && !session.getSynPackets().isEmpty()) ? calculateLatency(session) : -1);
            }
        }
    }
    Collections.sort(sessions);
    analyzeRequestResponses(sessions);
    return sessions;
}
Also used : UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) Packet(com.att.aro.core.packetreader.pojo.Packet) DomainNameSystem(com.att.aro.core.packetreader.pojo.DomainNameSystem) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) LinkedHashMap(java.util.LinkedHashMap) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) ArrayList(java.util.ArrayList) List(java.util.List) InetAddress(java.net.InetAddress) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 2 with UDPPacket

use of com.att.aro.core.packetreader.pojo.UDPPacket in project VideoOptimzer by attdevsupport.

the class SessionManagerImpl method extractHttpRequestResponseInfo.

private HttpRequestResponseInfo extractHttpRequestResponseInfo(ArrayList<HttpRequestResponseInfo> results, Session session, PacketInfo packetInfo, PacketDirection packetDirection, PacketInfo previousPacketInfo, int addToOffset) {
    TCPPacket tcpPacket = null;
    UDPPacket udpPacket = null;
    HttpRequestResponseInfo rrInfo = null;
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    BufferedOutputStream bufferedStream = new BufferedOutputStream(stream);
    int carryoverPayloadLength = 0;
    if (packetInfo.getPacket() instanceof TCPPacket) {
        tcpPacket = (TCPPacket) packetInfo.getPacket();
        try {
            if (previousPacketInfo != null) {
                TCPPacket previousTCPPacket = (TCPPacket) previousPacketInfo.getPacket();
                carryoverPayloadLength = previousTCPPacket.getData().length - (previousTCPPacket.getDataOffset() + addToOffset);
                bufferedStream.write(previousTCPPacket.getData(), (previousTCPPacket.getDataOffset() + addToOffset), carryoverPayloadLength);
            }
            bufferedStream.write(tcpPacket.getData(), tcpPacket.getDataOffset(), tcpPacket.getData().length - tcpPacket.getDataOffset());
        } catch (Exception exception) {
            LOGGER.error("Error Reading Data from TCP Packet: ", exception);
        }
    } else {
        udpPacket = (UDPPacket) packetInfo.getPacket();
        try {
            if (previousPacketInfo != null) {
                UDPPacket previousUDPPacket = (UDPPacket) previousPacketInfo.getPacket();
                carryoverPayloadLength = previousUDPPacket.getData().length - (previousUDPPacket.getDataOffset() + addToOffset);
                bufferedStream.write(previousUDPPacket.getData(), (previousUDPPacket.getDataOffset() + addToOffset), carryoverPayloadLength);
            }
            bufferedStream.write(udpPacket.getData(), udpPacket.getDataOffset(), udpPacket.getData().length - udpPacket.getDataOffset());
        } catch (Exception exception) {
            LOGGER.error("Error Reading Data from UDP Packet: ", exception);
        }
    }
    try {
        bufferedStream.flush();
        byte[] streamArray = stream.toByteArray();
        storageReader.init(streamArray);
        return getLastRRInfo(streamArray, packetInfo, tcpPacket, previousPacketInfo, carryoverPayloadLength, session, results, packetDirection);
    } catch (IOException e) {
        LOGGER.error(e);
    }
    return rrInfo;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) BufferedOutputStream(java.io.BufferedOutputStream) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Example 3 with UDPPacket

use of com.att.aro.core.packetreader.pojo.UDPPacket in project VideoOptimzer by attdevsupport.

the class PacketAnalyzerImplTest method test_getStatisticResult.

@Test
public void test_getStatisticResult() throws UnknownHostException {
    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);
    Statistic testResult = iPacketAnalyzer.getStatistic(packetsList);
    assertEquals(3, testResult.getTotalPackets());
}
Also used : Inet4Address(java.net.Inet4Address) DomainNameSystem(com.att.aro.core.packetreader.pojo.DomainNameSystem) Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) InetAddress(java.net.InetAddress) UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) HashSet(java.util.HashSet) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Example 4 with UDPPacket

use of com.att.aro.core.packetreader.pojo.UDPPacket in project VideoOptimzer by attdevsupport.

the class BurstCollectionAnalysisImplTest method analyzeTest.

@Test
public void analyzeTest() {
    // Date date = new Date();
    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");
    // UDP Packet Mock
    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(30);
    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);
    // Mockito.when(tcpPacket.getTimeStamp()).thenReturn((double)date.getTime()-10000);
    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(25);
    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);
    PacketInfo packetInfo3 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo3.getPacket()).thenReturn(tcpPacket2);
    Mockito.when(packetInfo3.getDir()).thenReturn(PacketDirection.DOWNLINK);
    Mockito.when(packetInfo3.getTcpInfo()).thenReturn(TcpInfo.TCP_ACK_RECOVER);
    Mockito.when(packetInfo3.getPayloadLen()).thenReturn(15);
    Mockito.when(packetInfo3.getLen()).thenReturn(20);
    Mockito.when(packetInfo3.getAppName()).thenReturn("Test3");
    Mockito.when(packetInfo3.getTcpFlagString()).thenReturn("Test3String");
    Mockito.when(packetInfo3.getTimeStamp()).thenReturn(700d);
    PacketInfo packetInfo4 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo4.getPacket()).thenReturn(tcpPacket2);
    Mockito.when(packetInfo4.getDir()).thenReturn(PacketDirection.DOWNLINK);
    Mockito.when(packetInfo4.getTcpInfo()).thenReturn(TcpInfo.TCP_ACK);
    Mockito.when(packetInfo4.getTimeStamp()).thenReturn(90d);
    Mockito.when(packetInfo4.getPayloadLen()).thenReturn(10);
    PacketInfo packetInfo5 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo5.getPacket()).thenReturn(tcpPacket2);
    Mockito.when(packetInfo5.getDir()).thenReturn(PacketDirection.DOWNLINK);
    Mockito.when(packetInfo5.getTcpInfo()).thenReturn(TcpInfo.TCP_DATA_RECOVER);
    Mockito.when(packetInfo5.getTimeStamp()).thenReturn(750d);
    Mockito.when(packetInfo5.getPayloadLen()).thenReturn(5);
    List<PacketInfo> packetsList = new ArrayList<PacketInfo>();
    // Adding UDP Packet to the list
    packetsList.add(packetInfo1);
    // Adding TCP Packet to the list
    packetsList.add(packetInfo2);
    packetsList.add(packetInfo3);
    packetsList.add(packetInfo4);
    packetsList.add(packetInfo5);
    ProfileWiFi profile = Mockito.mock(ProfileWiFi.class);
    Mockito.when(profile.getBurstTh()).thenReturn(50d);
    Mockito.when(profile.getLongBurstTh()).thenReturn(40.0d);
    Mockito.when(profile.getLargeBurstDuration()).thenReturn(150d);
    Mockito.when(profile.getLargeBurstSize()).thenReturn(50);
    Mockito.when(profile.getProfileType()).thenReturn(ProfileType.WIFI);
    Mockito.when(profile.getWifiTailTime()).thenReturn(25.0d);
    Mockito.when(profile.getWifiIdlePower()).thenReturn(50.0d);
    Mockito.when(profile.getWifiTailTime()).thenReturn(75.0d);
    Map<Integer, Integer> packetSizeToCountMap = new HashMap<Integer, Integer>();
    packetSizeToCountMap.put(1001, 10);
    packetSizeToCountMap.put(2002, 20);
    packetSizeToCountMap.put(3003, 30);
    RrcStateRange rrcStateRange1 = Mockito.mock(RrcStateRange.class);
    Mockito.when(rrcStateRange1.getBeginTime()).thenReturn(500d);
    Mockito.when(rrcStateRange1.getEndTime()).thenReturn(490d);
    Mockito.when(rrcStateRange1.getState()).thenReturn(RRCState.TAIL_DCH);
    RrcStateRange rrcStateRange2 = Mockito.mock(RrcStateRange.class);
    Mockito.when(rrcStateRange2.getBeginTime()).thenReturn(8.30d);
    Mockito.when(rrcStateRange2.getEndTime()).thenReturn(12.30d);
    Mockito.when(rrcStateRange2.getState()).thenReturn(RRCState.PROMO_FACH_DCH);
    RrcStateRange rrcStateRange3 = Mockito.mock(RrcStateRange.class);
    Mockito.when(rrcStateRange3.getBeginTime()).thenReturn(0.0d);
    Mockito.when(rrcStateRange3.getEndTime()).thenReturn(-2.0d);
    Mockito.when(rrcStateRange3.getState()).thenReturn(RRCState.TAIL_DCH);
    RrcStateRange rrcStateRange4 = Mockito.mock(RrcStateRange.class);
    Mockito.when(rrcStateRange4.getBeginTime()).thenReturn(25d);
    Mockito.when(rrcStateRange4.getEndTime()).thenReturn(75d);
    Mockito.when(rrcStateRange4.getState()).thenReturn(RRCState.WIFI_TAIL);
    RrcStateRange rrcStateRange5 = Mockito.mock(RrcStateRange.class);
    Mockito.when(rrcStateRange5.getBeginTime()).thenReturn(55d);
    Mockito.when(rrcStateRange5.getEndTime()).thenReturn(95d);
    Mockito.when(rrcStateRange5.getState()).thenReturn(RRCState.PROMO_IDLE_DCH);
    List<RrcStateRange> rrcstaterangelist = new ArrayList<RrcStateRange>();
    rrcstaterangelist.add(rrcStateRange1);
    rrcstaterangelist.add(rrcStateRange2);
    rrcstaterangelist.add(rrcStateRange3);
    rrcstaterangelist.add(rrcStateRange4);
    rrcstaterangelist.add(rrcStateRange5);
    UserEvent uEvent1 = Mockito.mock(UserEvent.class);
    Mockito.when(uEvent1.getEventType()).thenReturn(UserEventType.SCREEN_LANDSCAPE);
    Mockito.when(uEvent1.getPressTime()).thenReturn(503d);
    Mockito.when(uEvent1.getReleaseTime()).thenReturn(6d);
    UserEvent uEvent2 = Mockito.mock(UserEvent.class);
    Mockito.when(uEvent2.getEventType()).thenReturn(UserEventType.SCREEN_PORTRAIT);
    Mockito.when(uEvent2.getPressTime()).thenReturn(14d);
    Mockito.when(uEvent2.getReleaseTime()).thenReturn(2000d);
    UserEvent uEvent3 = Mockito.mock(UserEvent.class);
    Mockito.when(uEvent3.getEventType()).thenReturn(UserEventType.KEY_RED);
    Mockito.when(uEvent3.getPressTime()).thenReturn(497d);
    Mockito.when(uEvent3.getReleaseTime()).thenReturn(499d);
    UserEvent uEvent4 = Mockito.mock(UserEvent.class);
    Mockito.when(uEvent4.getEventType()).thenReturn(UserEventType.EVENT_UNKNOWN);
    Mockito.when(uEvent4.getPressTime()).thenReturn(25d);
    Mockito.when(uEvent4.getReleaseTime()).thenReturn(4d);
    UserEvent uEvent5 = Mockito.mock(UserEvent.class);
    Mockito.when(uEvent5.getEventType()).thenReturn(UserEventType.KEY_SEARCH);
    Mockito.when(uEvent5.getPressTime()).thenReturn(752d);
    Mockito.when(uEvent5.getReleaseTime()).thenReturn(30000d);
    List<UserEvent> uEventList = new ArrayList<UserEvent>();
    uEventList.add(uEvent1);
    uEventList.add(uEvent2);
    uEventList.add(uEvent3);
    uEventList.add(uEvent4);
    uEventList.add(uEvent5);
    CpuActivity cActivity1 = Mockito.mock(CpuActivity.class);
    Mockito.when(cActivity1.getTimeStamp()).thenReturn(23000d);
    Mockito.when(cActivity1.getTotalCpuUsage()).thenReturn(5000d);
    CpuActivity cActivity2 = Mockito.mock(CpuActivity.class);
    Mockito.when(cActivity2.getTimeStamp()).thenReturn(24000d);
    Mockito.when(cActivity2.getTotalCpuUsage()).thenReturn(6000d);
    CpuActivity cActivity3 = Mockito.mock(CpuActivity.class);
    Mockito.when(cActivity3.getTimeStamp()).thenReturn(25000d);
    Mockito.when(cActivity3.getTotalCpuUsage()).thenReturn(6000d);
    List<CpuActivity> cpuActivityList = new ArrayList<CpuActivity>();
    cpuActivityList.add(cActivity1);
    cpuActivityList.add(cActivity2);
    cpuActivityList.add(cActivity3);
    Session aSession = Mockito.mock(Session.class);
    List<Session> sessionList = new ArrayList<Session>();
    sessionList.add(aSession);
    BurstCollectionAnalysisData bcaData = aBurstCollectionAnalysis.analyze(packetsList, profile, packetSizeToCountMap, rrcstaterangelist, uEventList, cpuActivityList, sessionList);
    assertEquals(2, bcaData.getBurstAnalysisInfo().size());
    assertEquals(3, bcaData.getBurstCollection().size());
    assertEquals(0, bcaData.getLongBurstCount());
    assertEquals(0, (int) bcaData.getTotalEnergy());
}
Also used : DomainNameSystem(com.att.aro.core.packetreader.pojo.DomainNameSystem) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) UserEvent(com.att.aro.core.peripheral.pojo.UserEvent) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) ProfileWiFi(com.att.aro.core.configuration.pojo.ProfileWiFi) InetAddress(java.net.InetAddress) CpuActivity(com.att.aro.core.peripheral.pojo.CpuActivity) HashSet(java.util.HashSet) Session(com.att.aro.core.packetanalysis.pojo.Session) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Example 5 with UDPPacket

use of com.att.aro.core.packetreader.pojo.UDPPacket in project VideoOptimzer by attdevsupport.

the class DomainNameParserImplTest method parseDomain.

@Test
public void parseDomain() {
    parser = (DomainNameParserImpl) context.getBean(IDomainNameParser.class);
    UDPPacket packet = new UDPPacket(1393515429, 547730, 288, 16, null, null, dnsresponsedata);
    DomainNameSystem dns = parser.parseDomainName(packet);
    assertNotNull(dns);
}
Also used : DomainNameSystem(com.att.aro.core.packetreader.pojo.DomainNameSystem) UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Aggregations

UDPPacket (com.att.aro.core.packetreader.pojo.UDPPacket)19 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)16 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)12 DomainNameSystem (com.att.aro.core.packetreader.pojo.DomainNameSystem)10 ArrayList (java.util.ArrayList)10 BaseTest (com.att.aro.core.BaseTest)9 InetAddress (java.net.InetAddress)9 Test (org.junit.Test)9 HashSet (java.util.HashSet)8 IPPacket (com.att.aro.core.packetreader.pojo.IPPacket)7 Session (com.att.aro.core.packetanalysis.pojo.Session)6 RrcStateRange (com.att.aro.core.packetanalysis.pojo.RrcStateRange)5 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)4 Packet (com.att.aro.core.packetreader.pojo.Packet)4 CpuActivity (com.att.aro.core.peripheral.pojo.CpuActivity)4 HashMap (java.util.HashMap)4 UserEvent (com.att.aro.core.peripheral.pojo.UserEvent)3 Inet4Address (java.net.Inet4Address)3 Date (java.util.Date)3 Profile (com.att.aro.core.configuration.pojo.Profile)2