Search in sources :

Example 91 with PacketInfo

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

the class BurstCollectionAnalysisImplTest method analyze3Test.

@Test
public void analyze3Test() {
    // 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(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);
    // 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(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);
    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(0);
    Mockito.when(packetInfo3.getLen()).thenReturn(20);
    Mockito.when(packetInfo3.getAppName()).thenReturn("Test3");
    Mockito.when(packetInfo3.getTcpFlagString()).thenReturn("Test3String");
    Mockito.when(packetInfo3.getTimeStamp()).thenReturn(0d);
    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(0);
    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(0);
    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);
    ProfileLTE profile = Mockito.mock(ProfileLTE.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.LTE);
    Mockito.when(profile.getBurstTh()).thenReturn(25.0d);
    Mockito.when(profile.getCarrier()).thenReturn("ATT");
    Mockito.when(profile.getCloseSpacedBurstThreshold()).thenReturn(45d);
    Mockito.when(profile.getDrxLongPingPeriod()).thenReturn(50.0d);
    Mockito.when(profile.getDrxLongPingPower()).thenReturn(75d);
    Mockito.when(profile.getDrxLongTime()).thenReturn(75d);
    Mockito.when(profile.getDevice()).thenReturn("lg");
    Mockito.when(profile.getDrxShortPingPeriod()).thenReturn(100d);
    Mockito.when(profile.getDrxShortPingPower()).thenReturn(200d);
    Mockito.when(profile.getDrxShortTime()).thenReturn(50d);
    Mockito.when(profile.getLargeBurstDuration()).thenReturn(500d);
    Mockito.when(profile.getLargeBurstSize()).thenReturn(1000);
    Mockito.when(profile.getLongBurstTh()).thenReturn(250d);
    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(590d);
    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(105d);
    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);
    if (bcaData != null) {
        assertEquals(3, 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) ProfileLTE(com.att.aro.core.configuration.pojo.ProfileLTE) 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) 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 92 with PacketInfo

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

the class BurstCollectionAnalysisImplTest method analyze2Test.

@Test
public void analyze2Test() {
    // 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(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);
    // 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(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);
    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(0);
    Mockito.when(packetInfo3.getLen()).thenReturn(20);
    Mockito.when(packetInfo3.getAppName()).thenReturn("Test3");
    Mockito.when(packetInfo3.getTcpFlagString()).thenReturn("Test3String");
    Mockito.when(packetInfo3.getTimeStamp()).thenReturn(0d);
    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(0);
    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(0);
    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);
    Profile3G profile = Mockito.mock(Profile3G.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.T3G);
    Mockito.when(profile.getBurstTh()).thenReturn(25.0d);
    Mockito.when(profile.getCarrier()).thenReturn("ATT");
    Mockito.when(profile.getCloseSpacedBurstThreshold()).thenReturn(45d);
    Mockito.when(profile.getDchFachTimer()).thenReturn(50.0d);
    Mockito.when(profile.getDchTimerResetSize()).thenReturn(75);
    Mockito.when(profile.getDchTimerResetWin()).thenReturn(75d);
    Mockito.when(profile.getDevice()).thenReturn("lg");
    Mockito.when(profile.getFachDchPromoAvg()).thenReturn(100d);
    Mockito.when(profile.getFachDchPromoMax()).thenReturn(200d);
    Mockito.when(profile.getIdleDchPromoMin()).thenReturn(50d);
    Mockito.when(profile.getLargeBurstDuration()).thenReturn(500d);
    Mockito.when(profile.getLargeBurstSize()).thenReturn(1000);
    Mockito.when(profile.getLongBurstTh()).thenReturn(250d);
    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(590d);
    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(105d);
    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);
    if (bcaData != null) {
        assertEquals(3, 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) Profile3G(com.att.aro.core.configuration.pojo.Profile3G) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) 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 93 with PacketInfo

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

the class CacheAnalysisImplTest method analyze_2.

@Test
public void analyze_2() {
    List<PacketInfo> packets = new ArrayList<PacketInfo>();
    pktInfo01 = Mockito.mock(PacketInfo.class);
    pktInfo02 = Mockito.mock(PacketInfo.class);
    for (int i = 0; i < 60; i++) {
        httpRequestInfoArray[i] = mock(HttpRequestResponseInfo.class);
    }
    for (int i = 0; i < 20; i++) {
        when(httpRequestInfoArray[i].isNoStore()).thenReturn(true);
        if (i % 2 == 1) {
            when(httpRequestInfoArray[i].getDirection()).thenReturn(HttpDirection.REQUEST);
            when(httpRequestInfoArray[i].getHostName()).thenReturn("www.google.com");
            when(httpRequestInfoArray[i].getObjName()).thenReturn(Util.getCurrentRunningDir());
            when(httpRequestInfoArray[i].getContentLength()).thenReturn(5);
        } else {
            when(httpRequestInfoArray[i].getDirection()).thenReturn(HttpDirection.RESPONSE);
            when(httpRequestInfoArray[18].getStatusCode()).thenReturn(304);
        }
    }
    for (int i = 20; i < 60; i++) {
        when(httpRequestInfoArray[i].isNoStore()).thenReturn(false);
        when(httpRequestInfoArray[i].getHostName()).thenReturn("www.google.com" + i);
        when(httpRequestInfoArray[i].getObjName()).thenReturn(Util.getCurrentRunningDir());
        when(httpRequestInfoArray[i - 2].isRangeResponse()).thenReturn(true);
        when(httpRequestInfoArray[i].getContentLength()).thenReturn(5);
        if ((i - 20) % 2 == 1) {
            when(httpRequestInfoArray[i].getDirection()).thenReturn(HttpDirection.REQUEST);
        } else {
            when(httpRequestInfoArray[i].getDirection()).thenReturn(HttpDirection.RESPONSE);
            when(httpRequestInfoArray[i].getStatusCode()).thenReturn(206);
        }
    }
    when(httpRequestInfoArray[2].getAssocReqResp()).thenReturn(null);
    when(httpRequestInfoArray[4].getAssocReqResp()).thenReturn(httpRequestInfoArray[3]);
    when(httpRequestInfoArray[6].getAssocReqResp()).thenReturn(httpRequestInfoArray[5]);
    when(httpRequestInfoArray[8].getAssocReqResp()).thenReturn(httpRequestInfoArray[7]);
    when(httpRequestInfoArray[10].getAssocReqResp()).thenReturn(httpRequestInfoArray[9]);
    when(httpRequestInfoArray[12].getAssocReqResp()).thenReturn(httpRequestInfoArray[11]);
    when(httpRequestInfoArray[14].getAssocReqResp()).thenReturn(httpRequestInfoArray[13]);
    for (int i = 18; i < 60; i++) {
        when(httpRequestInfoArray[i].getAssocReqResp()).thenReturn(httpRequestInfoArray[i - 1]);
    }
    for (int i = 50; i < 60; i++) {
        when(httpRequestInfoArray[i].isRangeResponse()).thenReturn(false);
        when(httpRequestInfoArray[i].isChunked()).thenReturn(true);
        when(httpRequestInfoArray[i].getContentLength()).thenReturn(5);
    }
    for (int i = 0; i < 50; i++) {
        when(httpRequestInfoArray[i].isRangeResponse()).thenReturn(true);
    }
    when(httpRequestInfoArray[7].getHostName()).thenReturn(null);
    when(httpRequestInfoArray[7].getObjName()).thenReturn(null);
    when(httpRequestInfoArray[0].getStatusCode()).thenReturn(0);
    when(httpRequestInfoArray[2].getStatusCode()).thenReturn(200);
    when(httpRequestInfoArray[4].getStatusCode()).thenReturn(200);
    when(httpRequestInfoArray[6].getStatusCode()).thenReturn(200);
    when(httpRequestInfoArray[8].getStatusCode()).thenReturn(206);
    when(httpRequestInfoArray[10].getStatusCode()).thenReturn(206);
    when(httpRequestInfoArray[12].getStatusCode()).thenReturn(206);
    when(httpRequestInfoArray[14].getStatusCode()).thenReturn(304);
    when(httpRequestInfoArray[16].getStatusCode()).thenReturn(304);
    when(httpRequestInfoArray[18].getStatusCode()).thenReturn(304);
    when(httpRequestInfoArray[1].getRequestType()).thenReturn(HttpRequestResponseInfo.UTF8);
    when(httpRequestInfoArray[3].getRequestType()).thenReturn(HttpRequestResponseInfo.HTTP_POST);
    when(httpRequestInfoArray[5].getRequestType()).thenReturn(HttpRequestResponseInfo.HTTP_PUT);
    when(httpRequestInfoArray[7].getRequestType()).thenReturn(HttpRequestResponseInfo.HTTP_GET);
    when(httpRequestInfoArray[9].getRequestType()).thenReturn(HttpRequestResponseInfo.HTTP_POST);
    when(httpRequestInfoArray[11].getRequestType()).thenReturn(HttpRequestResponseInfo.HTTP_GET);
    when(httpRequestInfoArray[13].getRequestType()).thenReturn(HttpRequestResponseInfo.HTTP_GET);
    when(httpRequestInfoArray[15].getRequestType()).thenReturn(HttpRequestResponseInfo.HTTP_POST);
    when(httpRequestInfoArray[17].getRequestType()).thenReturn(HttpRequestResponseInfo.HTTP_PUT);
    when(httpRequestInfoArray[19].getRequestType()).thenReturn(HttpRequestResponseInfo.HTTP_PUT);
    when(httpRequestInfoArray[20].getRequestType()).thenReturn(HttpRequestResponseInfo.HTTP_GET);
    when(httpRequestInfoArray[21].getRequestType()).thenReturn(HttpRequestResponseInfo.HTTP_GET);
    for (int i = 22; i < 60; i++) {
        if (i % 2 == 1) {
            when(httpRequestInfoArray[i].getRequestType()).thenReturn(HttpRequestResponseInfo.HTTP_GET);
        }
    }
    // Friday, January 16, 2015
    Date date01 = new Date(1421384400000L);
    // 5:00:00 AM GMT
    Date date02 = new Date(1421384400000L - 76400000L);
    Date date03 = new Date(1421384400000L - 86400000L);
    Date date04 = new Date(1421383400000L - 176400000L);
    for (int i = 0; i < 60; i++) {
        when(httpRequestInfoArray[i].getMaxAge()).thenReturn(86400000L);
    }
    for (int i = 0; i < 60; i++) {
        if (i % 2 == 1) {
            when(httpRequestInfoArray[i].getExpires()).thenReturn(date03);
            when(httpRequestInfoArray[i].getDate()).thenReturn(date02);
            when(httpRequestInfoArray[i].getAbsTimeStamp()).thenReturn(date02);
            when(httpRequestInfoArray[i].getLastModified()).thenReturn(date);
        } else {
            if (i < 40) {
                when(httpRequestInfoArray[i].getLastModified()).thenReturn(date01);
                when(httpRequestInfoArray[i].getRangeFirst()).thenReturn(0);
                when(httpRequestInfoArray[i].getRangeLast()).thenReturn(5);
                when(httpRequestInfoArray[i].getAbsTimeStamp()).thenReturn(date02);
                when(httpRequestInfoArray[i].getExpires()).thenReturn(date);
                when(httpRequestInfoArray[i].getDate()).thenReturn(date03);
            } else {
                when(httpRequestInfoArray[i].getLastModified()).thenReturn(date02);
                when(httpRequestInfoArray[i].getExpires()).thenReturn(date04);
                when(httpRequestInfoArray[i].getDate()).thenReturn(date);
                when(httpRequestInfoArray[i].getAbsTimeStamp()).thenReturn(date);
                when(httpRequestInfoArray[i].getRangeFirst()).thenReturn(0);
                when(httpRequestInfoArray[i].getRangeLast()).thenReturn(13);
            }
        }
    }
    when(httpRequestInfoArray[30].isRangeResponse()).thenReturn(false);
    when(httpRequestInfoArray[31].isRangeResponse()).thenReturn(false);
    when(rrhelper.getActualByteCount(any(HttpRequestResponseInfo.class), any(Session.class))).thenReturn(2L);
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    for (int i = 0; i < 60; i++) {
        value.add(httpRequestInfoArray[i]);
    }
    packets.add(pktInfo01);
    packets.add(pktInfo02);
    when(session01.getRequestResponseInfo()).thenReturn(value);
    when(session01.isUdpOnly()).thenReturn(false);
    when(session01.getTcpPackets()).thenReturn(packets);
    when(session02.isUdpOnly()).thenReturn(false);
    when(session02.getRequestResponseInfo()).thenReturn(value);
    when(session02.getTcpPackets()).thenReturn(packets);
    List<Session> sessionList = new ArrayList<Session>();
    sessionList.add(session01);
    sessionList.add(session02);
    CacheAnalysis testResult = cacheAnalysis.analyze(sessionList);
    assertEquals(4, testResult.getCacheExpirationResponses().size());
    assertEquals(60, testResult.getDiagnosisResults().size());
    assertEquals(95, testResult.getDuplicateContentBytes());
    assertEquals(0.475, testResult.getDuplicateContentBytesRatio(), 0.225);
    assertEquals(38, testResult.getDuplicateContentWithOriginals().size());
}
Also used : CacheAnalysis(com.att.aro.core.packetanalysis.pojo.CacheAnalysis) ICacheAnalysis(com.att.aro.core.packetanalysis.ICacheAnalysis) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) Date(java.util.Date) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 94 with PacketInfo

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

the class RrcStateMachineFactoryImplTest method create_LTEStateIsLTE_CR_TAIL.

@Test
public void create_LTEStateIsLTE_CR_TAIL() {
    ProfileLTE profile06 = mock(ProfileLTE.class);
    when(profile06.getProfileType()).thenReturn(ProfileType.LTE);
    when(profilefactory.energyLTE(any(double.class), any(double.class), any(RRCState.class), any(ProfileLTE.class), any(ArrayList.class))).thenReturn(5.0);
    List<PacketInfo> packetlist1 = new ArrayList<PacketInfo>();
    List<RrcStateRange> staterangelist = new ArrayList<RrcStateRange>();
    RrcStateRange[] rrcStateRangeArray = new RrcStateRange[5];
    for (int i = 0; i < 5; i++) {
        rrcStateRangeArray[i] = mock(RrcStateRange.class);
        when(rrcStateRangeArray[i].getState()).thenReturn(RRCState.LTE_CR_TAIL);
        when(rrcStateRangeArray[i].getBeginTime()).thenReturn((double) date.getTime() + 2 * i * 1000);
        when(rrcStateRangeArray[i].getEndTime()).thenReturn((double) date.getTime() + (2 * i + 1) * 1000.0);
    }
    for (int i = 0; i < 5; i++) {
        staterangelist.add(rrcStateRangeArray[i]);
    }
    when(staterange.create(any(ArrayList.class), any(Profile.class), any(double.class))).thenReturn(staterangelist);
    RrcStateMachineLTE rrcStateMachineLTE = (RrcStateMachineLTE) machineFactoryimpl.create(packetlist1, profile06, packetDuration, traceDuration, totalBytes * 200, null);
    assertEquals(1.25, rrcStateMachineLTE.getJoulesPerKilobyte(), 0.0);
    assertEquals(5000, rrcStateMachineLTE.getLteCrTailTime(), 0.0);
    assertEquals(25, rrcStateMachineLTE.getLteCrTailEnergy(), 0.0);
}
Also used : RrcStateMachineLTE(com.att.aro.core.packetanalysis.pojo.RrcStateMachineLTE) RRCState(com.att.aro.core.packetanalysis.pojo.RRCState) ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) ProfileLTE(com.att.aro.core.configuration.pojo.ProfileLTE) Profile(com.att.aro.core.configuration.pojo.Profile) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Example 95 with PacketInfo

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

the class RrcStateMachineFactoryImplTest method create_T3GStateIsSTATE_FACH.

@Test
public void create_T3GStateIsSTATE_FACH() {
    List<PacketInfo> packetlist1 = new ArrayList<PacketInfo>();
    when(profilefactory.energy3G(any(double.class), any(double.class), any(RRCState.class), any(Profile3G.class))).thenReturn(100.0);
    Profile3G profile12 = mock(Profile3G.class);
    when(profile12.getProfileType()).thenReturn(ProfileType.T3G);
    List<RrcStateRange> staterangelist = new ArrayList<RrcStateRange>();
    RrcStateRange[] rrcStateRangeArray = new RrcStateRange[5];
    for (int i = 0; i < 5; i++) {
        rrcStateRangeArray[i] = mock(RrcStateRange.class);
        when(rrcStateRangeArray[i].getState()).thenReturn(RRCState.STATE_FACH);
        when(rrcStateRangeArray[i].getBeginTime()).thenReturn((double) date.getTime() + 2 * i * 500);
        when(rrcStateRangeArray[i].getEndTime()).thenReturn((double) date.getTime() + (2 * i + 1) * 500.0);
    }
    for (int i = 0; i < 5; i++) {
        staterangelist.add(rrcStateRangeArray[i]);
    }
    when(staterange.create(any(ArrayList.class), any(Profile.class), any(double.class))).thenReturn(staterangelist);
    RrcStateMachine3G rrcStateMachine3G = (RrcStateMachine3G) machineFactoryimpl.create(packetlist1, profile12, packetDuration, traceDuration, totalBytes * 100, null);
    assertEquals(50.0, rrcStateMachine3G.getJoulesPerKilobyte(), 0.0);
    assertEquals(2500, rrcStateMachine3G.getFachTime(), 0.0);
    assertEquals(500, rrcStateMachine3G.getFachEnergy(), 0.0);
}
Also used : RrcStateMachine3G(com.att.aro.core.packetanalysis.pojo.RrcStateMachine3G) RRCState(com.att.aro.core.packetanalysis.pojo.RRCState) ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) Profile3G(com.att.aro.core.configuration.pojo.Profile3G) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) Profile(com.att.aro.core.configuration.pojo.Profile) 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