Search in sources :

Example 16 with UDPPacket

use of com.att.aro.core.packetreader.pojo.UDPPacket 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 17 with UDPPacket

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

the class SessionManagerImplTest method assembleSessionTest1.

@Test
public void assembleSessionTest1() {
    Date date = new Date();
    /*		InetAddress iAdr = null;
		InetAddress iAdr1 = null;
		try {
			iAdr = InetAddress.getByAddress(new byte[]{89,10,1,1});
			iAdr1 = InetAddress.getByAddress(new byte[]{89,10,1,1});
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}*/
    InetAddress iAdr = Mockito.mock(InetAddress.class);
    Mockito.when(iAdr.getAddress()).thenReturn(new byte[] { 89, 10, 1, 1 });
    Mockito.when(iAdr.getHostAddress()).thenReturn("@att");
    Mockito.when(iAdr.getHostName()).thenReturn("att");
    InetAddress iAdr1 = Mockito.mock(InetAddress.class);
    Mockito.when(iAdr1.getAddress()).thenReturn(new byte[] { 89, 10, 1, 1 });
    Mockito.when(iAdr1.getHostAddress()).thenReturn("@att");
    Mockito.when(iAdr1.getHostName()).thenReturn("att");
    Set<InetAddress> inetSet = new HashSet<InetAddress>();
    inetSet.add(iAdr);
    inetSet.add(iAdr1);
    IPPacket ipPack = Mockito.mock(IPPacket.class);
    Mockito.when(ipPack.getDestinationIPAddress()).thenReturn(iAdr1);
    Mockito.when(ipPack.getSourceIPAddress()).thenReturn(iAdr);
    Mockito.when(ipPack.getLen()).thenReturn(20);
    Mockito.when(ipPack.getPacketLength()).thenReturn(20);
    Mockito.when(ipPack.getPayloadLen()).thenReturn(10);
    DomainNameSystem dns = Mockito.mock(DomainNameSystem.class);
    Mockito.when(dns.getIpAddresses()).thenReturn(inetSet);
    Mockito.when(dns.getDomainName()).thenReturn("www.att.com");
    Mockito.when(dns.isResponse()).thenReturn(true);
    Mockito.when(dns.getCname()).thenReturn("ATT");
    Mockito.when(dns.getPacket()).thenReturn(ipPack);
    // UDP Packet Mock
    UDPPacket udpPacket = Mockito.mock(UDPPacket.class);
    Mockito.when(udpPacket.isDNSPacket()).thenReturn(false);
    Mockito.when(udpPacket.getDns()).thenReturn(dns);
    Mockito.when(udpPacket.getSourcePort()).thenReturn(83);
    Mockito.when(udpPacket.getDestinationPort()).thenReturn(84);
    Mockito.when(udpPacket.getSourceIPAddress()).thenReturn(iAdr);
    Mockito.when(udpPacket.getDestinationIPAddress()).thenReturn(iAdr1);
    PacketInfo packetInfo1 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo1.getPacket()).thenReturn(udpPacket);
    Mockito.when(packetInfo1.getDir()).thenReturn(PacketDirection.UPLINK);
    // Mockito.when(packetInfo1.getDir()).thenReturn(PacketDirection.UNKNOWN);
    // Mockito.when(packetInfo1.getPayloadLen()).thenReturn(10);
    Mockito.when(packetInfo1.getPayloadLen()).thenReturn(20);
    Mockito.when(packetInfo1.getLen()).thenReturn(10);
    Mockito.when(packetInfo1.getAppName()).thenReturn("Test1");
    Mockito.when(packetInfo1.getTcpFlagString()).thenReturn("TestString");
    InetAddress iAdr2 = Mockito.mock(InetAddress.class);
    Mockito.when(iAdr2.getAddress()).thenReturn(new byte[] { 89, 10, 1, 1 });
    Mockito.when(iAdr2.getHostAddress()).thenReturn("@att");
    Mockito.when(iAdr2.getHostName()).thenReturn("att");
    /*		InetAddress iAdr2 = null;
		InetAddress iAdr3 = null;
		try {
			iAdr2 = InetAddress.getByAddress(new byte[]{89,10,1,1});
			iAdr3 = InetAddress.getByAddress(new byte[]{89,10,1,1});
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
*/
    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.getSourceIPAddress()).thenReturn(iAdr2);
    Mockito.when(tcpPacket.getAckNumber()).thenReturn(0L);
    Mockito.when(tcpPacket.getLen()).thenReturn(50);
    Mockito.when(tcpPacket.isSYN()).thenReturn(true);
    Mockito.when(tcpPacket.isFIN()).thenReturn(true);
    Mockito.when(tcpPacket.isRST()).thenReturn(true);
    Mockito.when(tcpPacket.getSequenceNumber()).thenReturn(-3L);
    Mockito.when(tcpPacket.getTimeStamp()).thenReturn((double) date.getTime() - 3000);
    // 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.DOWNLINK);
    Mockito.when(packetInfo2.getTcpInfo()).thenReturn(TcpInfo.TCP_ESTABLISH);
    Mockito.when(packetInfo2.getPayloadLen()).thenReturn(10);
    Mockito.when(packetInfo2.getLen()).thenReturn(15);
    Mockito.when(packetInfo2.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo2.getTcpFlagString()).thenReturn("Test2String");
    InetAddress iAdr3 = Mockito.mock(InetAddress.class);
    Mockito.when(iAdr3.getAddress()).thenReturn(new byte[] { 89, 10, 1, 1 });
    Mockito.when(iAdr3.getHostAddress()).thenReturn("@att");
    Mockito.when(iAdr3.getHostName()).thenReturn("att");
    TCPPacket tcpPacket2 = Mockito.mock(TCPPacket.class);
    Mockito.when(tcpPacket2.getSourcePort()).thenReturn(95);
    Mockito.when(tcpPacket2.getDestinationPort()).thenReturn(99);
    Mockito.when(tcpPacket2.getDestinationIPAddress()).thenReturn(iAdr3);
    Mockito.when(tcpPacket2.getSourceIPAddress()).thenReturn(iAdr3);
    Mockito.when(tcpPacket.getAckNumber()).thenReturn(0L);
    Mockito.when(tcpPacket2.isSYN()).thenReturn(true);
    Mockito.when(tcpPacket2.isFIN()).thenReturn(true);
    Mockito.when(tcpPacket2.isRST()).thenReturn(true);
    Mockito.when(tcpPacket.getSequenceNumber()).thenReturn(1L);
    Mockito.when(tcpPacket2.getTimeStamp()).thenReturn(10000d);
    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_ACK_RECOVER);
    Mockito.when(packetInfo3.getPayloadLen()).thenReturn(30);
    Mockito.when(packetInfo3.getLen()).thenReturn(20);
    Mockito.when(packetInfo3.getAppName()).thenReturn("Test3");
    Mockito.when(packetInfo3.getTcpFlagString()).thenReturn("Test3String");
    /*		
		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);
		
		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);
*/
    InetAddress iAdr4 = Mockito.mock(InetAddress.class);
    InetAddress iAdr5 = Mockito.mock(InetAddress.class);
    Mockito.when(iAdr4.getAddress()).thenReturn(new byte[] { 89, 10, 5, 1 });
    Mockito.when(iAdr4.getHostAddress()).thenReturn("@microfoft");
    Mockito.when(iAdr4.getHostName()).thenReturn("microfoft");
    Mockito.when(iAdr5.getAddress()).thenReturn(new byte[] { 72, 12, 23, 1 });
    Mockito.when(iAdr5.getHostAddress()).thenReturn("@apple");
    Mockito.when(iAdr5.getHostName()).thenReturn("apple");
    Set<InetAddress> inetSet1 = new HashSet<InetAddress>();
    inetSet1.add(iAdr4);
    inetSet1.add(iAdr5);
    IPPacket ipPack1 = Mockito.mock(IPPacket.class);
    Mockito.when(ipPack1.getDestinationIPAddress()).thenReturn(iAdr5);
    Mockito.when(ipPack1.getSourceIPAddress()).thenReturn(iAdr4);
    Mockito.when(ipPack1.getLen()).thenReturn(30);
    Mockito.when(ipPack1.getPacketLength()).thenReturn(40);
    Mockito.when(ipPack1.getPayloadLen()).thenReturn(40);
    DomainNameSystem dns1 = Mockito.mock(DomainNameSystem.class);
    Mockito.when(dns1.getIpAddresses()).thenReturn(inetSet);
    Mockito.when(dns1.getDomainName()).thenReturn("www.microsft.com");
    Mockito.when(dns1.isResponse()).thenReturn(false);
    Mockito.when(dns1.getCname()).thenReturn("microsoft");
    Mockito.when(dns1.getPacket()).thenReturn(ipPack1);
    // UDP Packet Mock
    UDPPacket udpPacket1 = Mockito.mock(UDPPacket.class);
    Mockito.when(udpPacket1.isDNSPacket()).thenReturn(true);
    Mockito.when(udpPacket1.getDns()).thenReturn(dns1);
    Mockito.when(udpPacket1.getSourcePort()).thenReturn(90);
    Mockito.when(udpPacket1.getSourceIPAddress()).thenReturn(iAdr4);
    Mockito.when(udpPacket1.getDestinationPort()).thenReturn(91);
    Mockito.when(udpPacket1.getDestinationIPAddress()).thenReturn(iAdr5);
    PacketInfo packetInfo4 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo4.getPacket()).thenReturn(udpPacket);
    Mockito.when(packetInfo4.getDir()).thenReturn(PacketDirection.DOWNLINK);
    // Mockito.when(packetInfo4.getDir()).thenReturn(PacketDirection.UNKNOWN);
    // Mockito.when(packetInfo1.getDir()).thenReturn(PacketDirection.UPLINK);
    // Mockito.when(packetInfo1.getPayloadLen()).thenReturn(10);
    Mockito.when(packetInfo4.getPayloadLen()).thenReturn(20);
    Mockito.when(packetInfo4.getLen()).thenReturn(10);
    Mockito.when(packetInfo4.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo4.getTcpFlagString()).thenReturn("TestString2");
    PacketInfo packetInfo5 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo5.getPacket()).thenReturn(tcpPacket);
    Mockito.when(packetInfo5.getDir()).thenReturn(PacketDirection.UPLINK);
    Mockito.when(packetInfo5.getTcpInfo()).thenReturn(TcpInfo.TCP_ESTABLISH);
    Mockito.when(packetInfo5.getPayloadLen()).thenReturn(20);
    Mockito.when(packetInfo5.getLen()).thenReturn(15);
    Mockito.when(packetInfo5.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo5.getTcpFlagString()).thenReturn("Test2String");
    // UDP Packet Mock
    UDPPacket udpPacket2 = Mockito.mock(UDPPacket.class);
    Mockito.when(udpPacket2.isDNSPacket()).thenReturn(true);
    Mockito.when(udpPacket2.getDns()).thenReturn(dns1);
    Mockito.when(udpPacket2.getSourcePort()).thenReturn(90);
    Mockito.when(udpPacket2.getSourceIPAddress()).thenReturn(iAdr4);
    Mockito.when(udpPacket2.getDestinationPort()).thenReturn(91);
    Mockito.when(udpPacket2.getDestinationIPAddress()).thenReturn(iAdr5);
    PacketInfo packetInfo6 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo6.getPacket()).thenReturn(udpPacket);
    // Mockito.when(packetInfo6.getDir()).thenReturn(PacketDirection.DOWNLINK);
    Mockito.when(packetInfo6.getDir()).thenReturn(PacketDirection.UNKNOWN);
    // Mockito.when(packetInfo1.getDir()).thenReturn(PacketDirection.UPLINK);
    // Mockito.when(packetInfo1.getPayloadLen()).thenReturn(10);
    Mockito.when(packetInfo6.getPayloadLen()).thenReturn(30);
    Mockito.when(packetInfo6.getLen()).thenReturn(10);
    Mockito.when(packetInfo6.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo6.getTcpFlagString()).thenReturn("TestString2");
    InetAddress iAdr6 = Mockito.mock(InetAddress.class);
    Mockito.when(iAdr6.getAddress()).thenReturn(new byte[] { 60, 100, 1, 1 });
    Mockito.when(iAdr6.getHostAddress()).thenReturn("@hari");
    Mockito.when(iAdr6.getHostName()).thenReturn("hari");
    TCPPacket tcpPacket6 = Mockito.mock(TCPPacket.class);
    Mockito.when(tcpPacket6.getSourcePort()).thenReturn(95);
    Mockito.when(tcpPacket6.getDestinationPort()).thenReturn(96);
    Mockito.when(tcpPacket6.getDestinationIPAddress()).thenReturn(iAdr6);
    Mockito.when(tcpPacket6.getSourceIPAddress()).thenReturn(iAdr6);
    Mockito.when(tcpPacket6.getAckNumber()).thenReturn(1L);
    Mockito.when(tcpPacket6.getLen()).thenReturn(50);
    Mockito.when(tcpPacket6.isSYN()).thenReturn(true);
    Mockito.when(tcpPacket6.isFIN()).thenReturn(true);
    Mockito.when(tcpPacket6.isRST()).thenReturn(false);
    Mockito.when(tcpPacket6.getSequenceNumber()).thenReturn(5L);
    Mockito.when(tcpPacket6.getTimeStamp()).thenReturn((double) date.getTime() - 20000);
    // Mockito.when(tcpPacket.getTimeStamp()).thenReturn((double)date.getTime()-10000);
    PacketInfo packetInfo7 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo7.getPacket()).thenReturn(tcpPacket);
    Mockito.when(packetInfo7.getDir()).thenReturn(PacketDirection.UNKNOWN);
    Mockito.when(packetInfo7.getTcpInfo()).thenReturn(TcpInfo.TCP_ACK_DUP);
    Mockito.when(packetInfo7.getPayloadLen()).thenReturn(10);
    Mockito.when(packetInfo7.getLen()).thenReturn(15);
    Mockito.when(packetInfo7.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo7.getTcpFlagString()).thenReturn("Test2String");
    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);
    packetsList.add(packetInfo6);
    packetsList.add(packetInfo7);
    List<Session> sessionsList = sessionMgr.processPacketsAndAssembleSessions(packetsList);
    assertEquals(5, sessionsList.size());
}
Also used : DomainNameSystem(com.att.aro.core.packetreader.pojo.DomainNameSystem) ArrayList(java.util.ArrayList) UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) Date(java.util.Date) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) InetAddress(java.net.InetAddress) IPPacket(com.att.aro.core.packetreader.pojo.IPPacket) HashSet(java.util.HashSet) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 18 with UDPPacket

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

the class SessionManagerImplTest method assembleSessionTest.

@Test
public void assembleSessionTest() {
    Date date = new Date();
    InetAddress iAdr = null;
    InetAddress iAdr1 = null;
    try {
        iAdr = InetAddress.getByAddress(new byte[] { 89, 10, 1, 1 });
        iAdr1 = InetAddress.getByAddress(new byte[] { 89, 10, 1, 1 });
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
    // Mockito.when(iAdr.getAddress()).thenReturn(new byte[]{89,10,1,1});
    // Mockito.when(iAdr.getHostAddress()).thenReturn("@att");
    // Mockito.when(iAdr.getHostName()).thenReturn("att");
    // Mockito.when(iAdr1.getAddress()).thenReturn(new byte[]{89,10,1,1});
    // Mockito.when(iAdr1.getHostAddress()).thenReturn("@att");
    // Mockito.when(iAdr1.getHostName()).thenReturn("att");
    Set<InetAddress> inetSet = new HashSet<InetAddress>();
    inetSet.add(iAdr);
    inetSet.add(iAdr1);
    IPPacket ipPack = Mockito.mock(IPPacket.class);
    Mockito.when(ipPack.getDestinationIPAddress()).thenReturn(iAdr1);
    Mockito.when(ipPack.getSourceIPAddress()).thenReturn(iAdr);
    Mockito.when(ipPack.getLen()).thenReturn(20);
    Mockito.when(ipPack.getPacketLength()).thenReturn(20);
    Mockito.when(ipPack.getPayloadLen()).thenReturn(20);
    DomainNameSystem dns = Mockito.mock(DomainNameSystem.class);
    Mockito.when(dns.getIpAddresses()).thenReturn(inetSet);
    Mockito.when(dns.getDomainName()).thenReturn("www.att.com");
    Mockito.when(dns.isResponse()).thenReturn(true);
    Mockito.when(dns.getCname()).thenReturn("ATT");
    Mockito.when(dns.getPacket()).thenReturn(ipPack);
    // 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.getSourceIPAddress()).thenReturn(iAdr);
    Mockito.when(udpPacket.getDestinationIPAddress()).thenReturn(iAdr1);
    PacketInfo packetInfo1 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo1.getPacket()).thenReturn(udpPacket);
    Mockito.when(packetInfo1.getDir()).thenReturn(PacketDirection.UPLINK);
    // Mockito.when(packetInfo1.getDir()).thenReturn(PacketDirection.UNKNOWN);
    // Mockito.when(packetInfo1.getPayloadLen()).thenReturn(10);
    Mockito.when(packetInfo1.getPayloadLen()).thenReturn(10);
    Mockito.when(packetInfo1.getLen()).thenReturn(10);
    Mockito.when(packetInfo1.getAppName()).thenReturn("Test1");
    Mockito.when(packetInfo1.getTcpFlagString()).thenReturn("TestString");
    /*		InetAddress iAdr2 = Mockito.mock(InetAddress.class);
		Mockito.when(iAdr2.getAddress()).thenReturn(new byte[]{89,10,1,1});
		Mockito.when(iAdr2.getHostAddress()).thenReturn("@att");
		Mockito.when(iAdr2.getHostName()).thenReturn("att");*/
    InetAddress iAdr2 = null;
    InetAddress iAdr3 = null;
    try {
        iAdr2 = InetAddress.getByAddress(new byte[] { 89, 10, 1, 1 });
        iAdr3 = InetAddress.getByAddress(new byte[] { 89, 10, 1, 1 });
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
    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.getSourceIPAddress()).thenReturn(iAdr2);
    Mockito.when(tcpPacket.getAckNumber()).thenReturn(0L);
    Mockito.when(tcpPacket.getLen()).thenReturn(50);
    Mockito.when(tcpPacket.isSYN()).thenReturn(true);
    Mockito.when(tcpPacket.isFIN()).thenReturn(true);
    Mockito.when(tcpPacket.isRST()).thenReturn(true);
    Mockito.when(tcpPacket.getSequenceNumber()).thenReturn(20L);
    Mockito.when(tcpPacket.getTimeStamp()).thenReturn((double) date.getTime() - 3000);
    // 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(20);
    Mockito.when(packetInfo2.getLen()).thenReturn(15);
    Mockito.when(packetInfo2.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo2.getTcpFlagString()).thenReturn("Test2String");
    /*		InetAddress iAdr3 = Mockito.mock(InetAddress.class);
		Mockito.when(iAdr3.getAddress()).thenReturn(new byte[]{89,10,1,1});
		Mockito.when(iAdr3.getHostAddress()).thenReturn("@att");
		Mockito.when(iAdr3.getHostName()).thenReturn("att");
*/
    TCPPacket tcpPacket2 = Mockito.mock(TCPPacket.class);
    Mockito.when(tcpPacket2.getSourcePort()).thenReturn(95);
    Mockito.when(tcpPacket2.getDestinationPort()).thenReturn(99);
    Mockito.when(tcpPacket2.getDestinationIPAddress()).thenReturn(iAdr3);
    Mockito.when(tcpPacket2.getSourceIPAddress()).thenReturn(iAdr3);
    Mockito.when(tcpPacket.getAckNumber()).thenReturn(0L);
    Mockito.when(tcpPacket2.isSYN()).thenReturn(true);
    Mockito.when(tcpPacket2.isFIN()).thenReturn(true);
    Mockito.when(tcpPacket2.isRST()).thenReturn(true);
    Mockito.when(tcpPacket.getSequenceNumber()).thenReturn(1L);
    Mockito.when(tcpPacket2.getTimeStamp()).thenReturn(10000d);
    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(30);
    Mockito.when(packetInfo3.getLen()).thenReturn(20);
    Mockito.when(packetInfo3.getAppName()).thenReturn("Test3");
    Mockito.when(packetInfo3.getTcpFlagString()).thenReturn("Test3String");
    /*		
		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);
		
		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);
*/
    InetAddress iAdr4 = Mockito.mock(InetAddress.class);
    InetAddress iAdr5 = Mockito.mock(InetAddress.class);
    Mockito.when(iAdr4.getAddress()).thenReturn(new byte[] { 89, 10, 5, 1 });
    Mockito.when(iAdr4.getHostAddress()).thenReturn("@microfoft");
    Mockito.when(iAdr4.getHostName()).thenReturn("microfoft");
    Mockito.when(iAdr5.getAddress()).thenReturn(new byte[] { 72, 12, 23, 1 });
    Mockito.when(iAdr5.getHostAddress()).thenReturn("@apple");
    Mockito.when(iAdr5.getHostName()).thenReturn("apple");
    Set<InetAddress> inetSet1 = new HashSet<InetAddress>();
    inetSet1.add(iAdr4);
    inetSet1.add(iAdr5);
    IPPacket ipPack1 = Mockito.mock(IPPacket.class);
    Mockito.when(ipPack1.getDestinationIPAddress()).thenReturn(iAdr5);
    Mockito.when(ipPack1.getSourceIPAddress()).thenReturn(iAdr4);
    Mockito.when(ipPack1.getLen()).thenReturn(30);
    Mockito.when(ipPack1.getPacketLength()).thenReturn(40);
    Mockito.when(ipPack1.getPayloadLen()).thenReturn(40);
    DomainNameSystem dns1 = Mockito.mock(DomainNameSystem.class);
    Mockito.when(dns1.getIpAddresses()).thenReturn(inetSet);
    Mockito.when(dns1.getDomainName()).thenReturn("www.att.com");
    Mockito.when(dns1.isResponse()).thenReturn(false);
    Mockito.when(dns1.getCname()).thenReturn("ATT");
    Mockito.when(dns1.getPacket()).thenReturn(ipPack1);
    // UDP Packet Mock
    UDPPacket udpPacket1 = Mockito.mock(UDPPacket.class);
    Mockito.when(udpPacket1.isDNSPacket()).thenReturn(true);
    Mockito.when(udpPacket1.getDns()).thenReturn(dns1);
    Mockito.when(udpPacket1.getSourcePort()).thenReturn(90);
    Mockito.when(udpPacket1.getSourceIPAddress()).thenReturn(iAdr4);
    Mockito.when(udpPacket1.getDestinationPort()).thenReturn(91);
    Mockito.when(udpPacket1.getDestinationIPAddress()).thenReturn(iAdr5);
    PacketInfo packetInfo4 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo4.getPacket()).thenReturn(udpPacket);
    Mockito.when(packetInfo4.getDir()).thenReturn(PacketDirection.DOWNLINK);
    // Mockito.when(packetInfo4.getDir()).thenReturn(PacketDirection.UNKNOWN);
    // Mockito.when(packetInfo1.getDir()).thenReturn(PacketDirection.UPLINK);
    // Mockito.when(packetInfo1.getPayloadLen()).thenReturn(10);
    Mockito.when(packetInfo4.getPayloadLen()).thenReturn(30);
    Mockito.when(packetInfo4.getLen()).thenReturn(10);
    Mockito.when(packetInfo4.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo4.getTcpFlagString()).thenReturn("TestString2");
    PacketInfo packetInfo5 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo5.getPacket()).thenReturn(tcpPacket);
    Mockito.when(packetInfo5.getDir()).thenReturn(PacketDirection.DOWNLINK);
    Mockito.when(packetInfo5.getTcpInfo()).thenReturn(TcpInfo.TCP_ESTABLISH);
    Mockito.when(packetInfo5.getPayloadLen()).thenReturn(20);
    Mockito.when(packetInfo5.getLen()).thenReturn(15);
    Mockito.when(packetInfo5.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo5.getTcpFlagString()).thenReturn("Test2String");
    // UDP Packet Mock
    UDPPacket udpPacket2 = Mockito.mock(UDPPacket.class);
    Mockito.when(udpPacket2.isDNSPacket()).thenReturn(true);
    Mockito.when(udpPacket2.getDns()).thenReturn(dns1);
    Mockito.when(udpPacket2.getSourcePort()).thenReturn(90);
    Mockito.when(udpPacket2.getSourceIPAddress()).thenReturn(iAdr4);
    Mockito.when(udpPacket2.getDestinationPort()).thenReturn(91);
    Mockito.when(udpPacket2.getDestinationIPAddress()).thenReturn(iAdr5);
    PacketInfo packetInfo6 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo6.getPacket()).thenReturn(udpPacket);
    // Mockito.when(packetInfo6.getDir()).thenReturn(PacketDirection.DOWNLINK);
    Mockito.when(packetInfo6.getDir()).thenReturn(PacketDirection.UNKNOWN);
    // Mockito.when(packetInfo1.getDir()).thenReturn(PacketDirection.UPLINK);
    // Mockito.when(packetInfo1.getPayloadLen()).thenReturn(10);
    Mockito.when(packetInfo6.getPayloadLen()).thenReturn(30);
    Mockito.when(packetInfo6.getLen()).thenReturn(10);
    Mockito.when(packetInfo6.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo6.getTcpFlagString()).thenReturn("TestString2");
    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);
    packetsList.add(packetInfo6);
    List<Session> sessionsList = sessionMgr.processPacketsAndAssembleSessions(packetsList);
    assertEquals(5, sessionsList.size());
}
Also used : DomainNameSystem(com.att.aro.core.packetreader.pojo.DomainNameSystem) UnknownHostException(java.net.UnknownHostException) ArrayList(java.util.ArrayList) UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) Date(java.util.Date) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) InetAddress(java.net.InetAddress) IPPacket(com.att.aro.core.packetreader.pojo.IPPacket) HashSet(java.util.HashSet) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 19 with UDPPacket

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

the class PacketServiceImplTest method createPacketTest.

@Test
public void createPacketTest() {
    service = (PacketServiceImpl) context.getBean(IPacketService.class);
    ReflectionTestUtils.setField(service, "pcapngHelper", helper);
    byte[] data = new byte[64];
    data[0] = 0;
    data[1] = 0;
    data[2] = 0;
    data[3] = 0;
    ByteBuffer buffer = ByteBuffer.allocate(2);
    // IPV4
    short network = 0x0800;
    buffer.putShort(network);
    buffer.flip();
    byte[] netarr = buffer.array();
    data[12] = netarr[0];
    data[13] = netarr[1];
    data[14] = netarr[0];
    data[15] = netarr[1];
    ByteBuffer datawrap = ByteBuffer.wrap(data);
    short value = datawrap.getShort(12);
    assertEquals(network, value);
    Packet packet = service.createPacketFromPcap(12, 1, 1, 1, data, null);
    packet = service.createPacketFromPcap(1, 1, 1, 1, data, null);
    packet = service.createPacketFromPcap(113, 1, 1, 1, data, null);
    packet = service.createPacketFromPcap(0, 1, 1, 1, data, file.getAbsolutePath());
    packet = service.createPacketFromNetmon(0xe000, 1, 1, 1, data);
    packet = service.createPacketFromNetmon(9, 1, 1, 1, data);
    packet = service.createPacketFromNetmon(8, 1, 1, 1, data);
    packet = service.createPacketFromNetmon(1, 1, 1, 1, data);
    packet = service.createPacketFromNetmon(6, 1, 1, 1, data);
    data[1] = 0x2;
    data[2] = 0x8;
    packet = service.createPacketFromNetmon(6, 1, 1, 1, data);
    // IPV6
    data[6] = 0x6;
    packet = service.createPacket((short) 0x86DD, 1, 1, 1, 0, data);
    boolean ok = false;
    if (packet instanceof TCPPacket) {
        ok = true;
    }
    assertEquals(true, ok);
    data[6] = 0x11;
    packet = service.createPacket((short) 0x86DD, 1, 1, 1, 0, data);
    if (packet instanceof UDPPacket) {
        ok = true;
    }
    assertEquals(true, ok);
    data[6] = 0x8;
    packet = service.createPacket((short) 0x86DD, 1, 1, 1, 0, data);
    // IPV4
    data[9] = 0x6;
    packet = service.createPacket((short) 0x0800, 1, 1, 1, 0, data);
    data[9] = 0x11;
    packet = service.createPacket((short) 0x0800, 1, 1, 1, 0, data);
    data[9] = 0x8;
    packet = service.createPacket((short) 0x0800, 1, 1, 1, 0, data);
    assertNotNull(packet);
}
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) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) ByteBuffer(java.nio.ByteBuffer) 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