Search in sources :

Example 1 with BurstCollectionAnalysisData

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

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

the class PacketAnalyzerImpl method finalResult.

protected PacketAnalyzerResult finalResult(AbstractTraceResult result, Profile profile, AnalysisFilter filter) {
    PacketAnalyzerResult data = new PacketAnalyzerResult();
    if (filter == null) {
        double endTime = result.getAllpackets().size() > 0 ? Math.max(result.getAllpackets().get(result.getAllpackets().size() - 1).getTimeStamp(), result.getTraceDuration()) : 0.0;
        result.setTimeRange(new TimeRange("Full", TimeRange.TimeRangeType.FULL, 0.0, endTime));
    } else {
        result.setTimeRange(filter.getTimeRange());
    }
    // List of packets included in analysis (application filtered)
    List<PacketInfo> filteredPackets;
    Profile aProfile = profile;
    if (aProfile == null) {
        // if the user doesn't load any profile.....
        aProfile = profilefactory.createLTEdefault();
        aProfile.setName("AT&T LTE");
    }
    // for the situation, filter out all no-ip packets and caused the allpackets is empty, need to refactor
    if (result != null && result.getAllpackets() != null && result.getAllpackets().size() == 0) {
        data.setTraceresult(result);
        return data;
    }
    /* Purpose of this code block is to finish building out the filter, if needed, for TimeRange analysis
		 * 
		 * This code block is excuted when:
		 *  1: time-range.json exists in trace folder
		 *  	a: and the json contains an entry with RangeType.AUTO
		 *  2: A TimeRange object was created and launched in TimeRangeEditorDialog
		 *  
		 *  AroController will have created an AnalysisFilter and so filter will not be null
		 *  
		 */
    try {
        if ((filter != null && filter.getTimeRange() != null && filter.getTimeRange().getPath() != null) || result.getAllAppNames().size() == 1) {
            String app = TraceDataReaderImpl.UNKNOWN_APPNAME;
            if (filter != null && filter.getAppSelections() != null && filter.getAppSelections().containsKey(app) && filter.getAppSelections().get(app).getIPAddressSelections().isEmpty()) {
                LOGGER.debug("AUTO Time Range analysis: add all found appIps to " + app + ", then store in the filter");
                ApplicationSelection appSelection = new ApplicationSelection(app, result.getAppIps().get(app));
                filter.getAppSelections().put(app, appSelection);
            }
        }
    } catch (Exception e) {
        LOGGER.error("Error handling TimeRange JSON data", e);
    }
    TimeRange timeRange = null;
    boolean isCSI = false;
    filteredPackets = new ArrayList<PacketInfo>();
    if (filter == null) {
        if (result != null) {
            filteredPackets = result.getAllpackets();
        }
    } else {
        // do the filter
        if (filter.isCSI() && filter.getManifestFilePath() != null) {
            isCSI = true;
        }
        timeRange = filter.getTimeRange();
        if (result != null) {
            filteredPackets = filterPackets(filter, result.getAllpackets());
        }
    }
    // Fix for Sev 2 Time Range Analysis Issue - DE187848
    if (result != null) {
        result.setAllpackets(filteredPackets);
        SessionManagerImpl sessionMangerImpl = (SessionManagerImpl) sessionmanager;
        sessionMangerImpl.setPcapTimeOffset(result.getPcapTimeOffset());
        // for iOS trace
        sessionmanager.setiOSSecureTracePath(result.getTraceDirectory());
        // Check if secure trace path exists
        if (result instanceof TraceDirectoryResult) {
            File file = new File(((SessionManagerImpl) sessionmanager).getTracePath());
            if (file.exists()) {
                ((TraceDirectoryResult) result).setSecureTrace(true);
            }
        }
    }
    Statistic stat = this.getStatistic(filteredPackets);
    List<Session> sessionList = sessionmanager.processPacketsAndAssembleSessions(filteredPackets);
    generateGetRequestMapAndPopulateLatencyStat(sessionList, stat);
    if (result != null && stat.getAppName() != null && stat.getAppName().size() == 1 && stat.getAppName().contains(TraceDataReaderImpl.UNKNOWN_APPNAME)) {
        stat.setAppName(new HashSet<String>(result.getAppInfos()));
    }
    // get Unanalyzed HTTPS bytes
    boolean isSecureTrace = result instanceof TraceDirectoryResult ? ((TraceDirectoryResult) result).isSecureTrace() : false;
    if (isSecureTrace) {
        stat.setTotalHTTPSBytesNotAnalyzed(getHttpsBytesNotAnalyzed(sessionList));
    } else {
        stat.setTotalHTTPSBytesNotAnalyzed(stat.getTotalHTTPSByte());
    }
    // stat is used to get some info for RrcStateMachine etc
    if (result != null) {
        LOGGER.debug("Starting pre processing in PAI");
        AbstractRrcStateMachine statemachine = statemachinefactory.create(filteredPackets, aProfile, stat.getPacketDuration(), result.getTraceDuration(), stat.getTotalByte(), timeRange);
        EnergyModel energymodel = energymodelfactory.create(aProfile, statemachine.getTotalRRCEnergy(), result.getGpsInfos(), result.getCameraInfos(), result.getBluetoothInfos(), result.getScreenStateInfos());
        BurstCollectionAnalysisData burstcollectiondata = burstcollectionanalyzer.analyze(filteredPackets, aProfile, stat.getPacketSizeToCountMap(), statemachine.getStaterangelist(), result.getUserEvents(), result.getCpuActivityList().getCpuActivities(), sessionList);
        data.clearBPResults();
        try {
            List<BestPracticeType> videoBPList = BestPracticeType.getByCategory(BestPracticeType.Category.VIDEO);
            data.setStreamingVideoData(videoTrafficCollector.clearData());
            if (CollectionUtils.containsAny(SettingsUtil.retrieveBestPractices(), videoBPList)) {
                if (isCSI || csiDataHelper.doesCSIFileExist(result.getTraceDirectory())) {
                    data.setStreamingVideoData(videoTrafficInferencer.inferVideoData(result, sessionList, (filter != null && filter.getManifestFilePath() != null) ? filter.getManifestFilePath() : result.getTraceDirectory()));
                } else {
                    data.setStreamingVideoData(videoTrafficCollector.collect(result, sessionList, requestMap));
                }
            }
        } catch (Exception ex) {
            LOGGER.error("Error in Video usage analysis :", ex);
            // Guarantee that StreamingVideoData is empty
            data.setStreamingVideoData(videoTrafficCollector.clearData());
            data.getStreamingVideoData().setFinished(true);
        }
        try {
            List<BestPracticeType> imageBPList = new ArrayList<>();
            imageBPList.add(BestPracticeType.IMAGE_MDATA);
            imageBPList.add(BestPracticeType.IMAGE_CMPRS);
            imageBPList.add(BestPracticeType.IMAGE_FORMAT);
            imageBPList.add(BestPracticeType.IMAGE_COMPARE);
            if (CollectionUtils.containsAny(SettingsUtil.retrieveBestPractices(), imageBPList)) {
                imageExtractor.execute(result, sessionList, requestMap);
            }
        } catch (Exception ex) {
            LOGGER.error("Error in Image extraction:" + ex.getMessage(), ex);
        }
        htmlExtractor.execute(result, sessionList, requestMap);
        // Calculate time range analysis
        double beginTime = 0.0d;
        double endTime = 0.0d;
        if (filter != null && filter.getTimeRange() != null) {
            beginTime = filter.getTimeRange().getBeginTime();
            endTime = filter.getTimeRange().getEndTime();
        } else {
            endTime = result.getTraceDuration();
        }
        data.setBurstCollectionAnalysisData(burstcollectiondata);
        data.setEnergyModel(energymodel);
        data.setSessionlist(sessionList);
        data.setStatemachine(statemachine);
        data.setStatistic(stat);
        data.setTraceresult(result);
        data.setProfile(aProfile);
        data.setFilter(filter);
        data.setDeviceKeywords(result.getDeviceKeywordInfos());
        data.setTimeRangeAnalysis(new TimeRangeAnalysis(beginTime, endTime, data));
    }
    return data;
}
Also used : ApplicationSelection(com.att.aro.core.packetanalysis.pojo.ApplicationSelection) ArrayList(java.util.ArrayList) BestPracticeType(com.att.aro.core.bestpractice.pojo.BestPracticeType) Profile(com.att.aro.core.configuration.pojo.Profile) Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) AbstractRrcStateMachine(com.att.aro.core.packetanalysis.pojo.AbstractRrcStateMachine) EnergyModel(com.att.aro.core.packetanalysis.pojo.EnergyModel) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) File(java.io.File) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 3 with BurstCollectionAnalysisData

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

the class ScreenRotationImplTest method runTest_resIsNoErr_Pass.

@Test
public void runTest_resIsNoErr_Pass() {
    tracedata = Mockito.mock(PacketAnalyzerResult.class);
    burstCollectionAnalysisData = Mockito.mock(BurstCollectionAnalysisData.class);
    burst01 = mock(Burst.class);
    Mockito.when(burst01.getBurstCategory()).thenReturn(BurstCategory.UNKNOWN);
    Mockito.when(burst01.getBeginTime()).thenReturn(1.0);
    List<Burst> burstCollection = new ArrayList<Burst>();
    burstCollection.add(burst01);
    Mockito.when(tracedata.getBurstCollectionAnalysisData()).thenReturn(burstCollectionAnalysisData);
    Mockito.when(burstCollectionAnalysisData.getBurstCollection()).thenReturn(burstCollection);
    screenRotationImpl = (ScreenRotationImpl) context.getBean("screenRotation");
    AbstractBestPracticeResult result = screenRotationImpl.runTest(tracedata);
    assertEquals(BPResultType.PASS, result.getResultType());
}
Also used : Burst(com.att.aro.core.packetanalysis.pojo.Burst) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 4 with BurstCollectionAnalysisData

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

the class PeriodicTransferImplTest method runTest_AresultIsPass.

@Test
public void runTest_AresultIsPass() {
    PacketAnalyzerResult tracedata01 = new PacketAnalyzerResult();
    Date date = new Date();
    List<Burst> burstCollection = new ArrayList<Burst>();
    BurstCollectionAnalysisData burstcollectionAnalysisData = new BurstCollectionAnalysisData();
    InetAddress remoteIP = null;
    InetAddress localIP = null;
    try {
        localIP = InetAddress.getLocalHost();
        remoteIP = InetAddress.getLocalHost();
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
    int remotePort = 80;
    int localPort = 80;
    byte[] d1 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 0, 69, 0, 0, 52, -99, -87, 64, 0, 64, 6, -27, -25, 10, -27, 77, 114, 74, 125, 20, 95, -90, 2, 1, -69, -108, -18, 20, 87, -4, -110, -105, -88, -128, 16, 6, 88, 51, 24, 0, 0, 1, 1, 8, 10, -1, -1, -87, 50, 101, -15, -111, -73 };
    Packet packet01 = new Packet(1, 1418242722L, 324000, 66, d1);
    byte[] d2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 0, 69, 0, 0, 52, 0, 0, 64, 0, 64, 6, -125, -111, 74, 125, 20, 95, 10, -27, 77, 114, 1, -69, -90, 2, 0, 0, 0, 0, -108, -18, 20, 87, -128, 4, 0, 0, 119, -98, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    Packet packet02 = new Packet(1, 1418242722L, 325000, 63, d2);
    PacketInfo packetInfo01 = new PacketInfo(packet01);
    PacketInfo packetInfo02 = new PacketInfo(packet02);
    packetInfo01.setTcpInfo(TcpInfo.TCP_ESTABLISH);
    packetInfo01.setTimestamp((double) date.getTime());
    packetInfo02.setTcpInfo(TcpInfo.TCP_ACK);
    List<PacketInfo> packetlist = new ArrayList<PacketInfo>();
    packetlist.add(packetInfo01);
    packetlist.add(packetInfo02);
    Burst burst01 = new Burst(packetlist);
    burst01.setFirstUplinkDataPacket(packetInfo01);
    burst01.setBurstInfo(BurstCategory.CLIENT_APP);
    burstCollection.add(burst01);
    Session session01 = new Session(localIP, remoteIP, remotePort, localPort, "");
    session01.setUdpOnly(false);
    session01.setTcpPackets(packetlist);
    HttpRequestResponseInfo httpRequestResponseInfo01 = new HttpRequestResponseInfo();
    httpRequestResponseInfo01.setFirstDataPacket(packetInfo01);
    httpRequestResponseInfo01.setDirection(HttpDirection.REQUEST);
    httpRequestResponseInfo01.setHostName("yahoo.com");
    httpRequestResponseInfo01.setObjName("");
    List<HttpRequestResponseInfo> httpRequestResponseInfolist = new ArrayList<HttpRequestResponseInfo>();
    httpRequestResponseInfolist.add(httpRequestResponseInfo01);
    session01.setRequestResponseInfo(httpRequestResponseInfolist);
    List<Session> sessionlist = new ArrayList<Session>();
    sessionlist.add(session01);
    ProfileLTE profileLTE = new ProfileLTE();
    profileLTE.setPeriodMinCycle(10.0);
    profileLTE.setPeriodCycleTol(1.0);
    profileLTE.setPeriodMinSamples(3);
    profileLTE.setCloseSpacedBurstThreshold(0.0);
    burstcollectionAnalysisData.setBurstCollection(burstCollection);
    tracedata01.setSessionlist(sessionlist);
    tracedata01.setBurstCollectionAnalysisData(burstcollectionAnalysisData);
    tracedata01.setProfile(profileLTE);
    AbstractBestPracticeResult result01 = periodicTransferImpl.runTest(tracedata01);
    assertEquals(BPResultType.PASS, result01.getResultType());
}
Also used : Packet(com.att.aro.core.packetreader.pojo.Packet) UnknownHostException(java.net.UnknownHostException) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) ProfileLTE(com.att.aro.core.configuration.pojo.ProfileLTE) Date(java.util.Date) Burst(com.att.aro.core.packetanalysis.pojo.Burst) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) InetAddress(java.net.InetAddress) Session(com.att.aro.core.packetanalysis.pojo.Session) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Example 5 with BurstCollectionAnalysisData

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

the class PeriodicTransferImplTest method runTest_resultIsFail.

@Test
public void runTest_resultIsFail() {
    PacketAnalyzerResult tracedata = new PacketAnalyzerResult();
    Profile3G profile3g = new Profile3G();
    profile3g.setPeriodMinCycle(10.0);
    profile3g.setPeriodCycleTol(1.0);
    profile3g.setPeriodMinSamples(3);
    profile3g.setCloseSpacedBurstThreshold(-50.0);
    InetAddress remoteIP = null;
    InetAddress localIP = null;
    try {
        localIP = InetAddress.getLocalHost();
        remoteIP = InetAddress.getLocalHost();
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
    InetAddress remoteIP01 = null;
    try {
        remoteIP01 = InetAddress.getByName("google.com");
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
    int remotePort = 80;
    int localPort = 80;
    Session session01 = new Session(localIP, remoteIP, remotePort, localPort, "");
    Session session02 = new Session(localIP, remoteIP01, remotePort, localPort, "");
    byte[] d1 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 0, 69, 0, 0, 52, -87, -63, 64, 0, 64, 6, 76, -121, 10, 120, 0, 1, 74, 125, -17, -123, -104, 53, 1, -69, 91, 8, 7, 120, 25, -21, 51, -84, -128, 16, 5, 123, 105, -6, 0, 0, 1, 1, 8, 10, -1, -1, -86, -80, 53, -38, -104, 57, 5, 7, 0, 6, 7 };
    Packet packet01 = new Packet(1, 1418242726L, 234000, 50, d1);
    byte[] d2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 0, 69, 0, 0, 52, 0, 0, 64, 0, 64, 6, -125, -111, 74, 125, 20, 95, 10, -27, 77, 114, 1, -69, -90, 2, 0, 0, 0, 0, -108, -18, 20, 87, -128, 4, 0, 0, 119, -98, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    Packet packet02 = new Packet(1, 1418242722L, 325000, 50, d2);
    byte[] d3 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 0, 69, 0, 0, 52, -97, 67, 64, 0, 64, 6, -28, 77, 10, -27, 77, 114, 74, 125, 20, 95, -58, -91, 1, -69, 22, 2, 7, 25, -69, -41, -92, -13, -128, 17, 8, 86, -98, -14, 0, 0, 1, 1, 8, 10, -1, -1, -87, 51, 96, 102, -56, 95 };
    Packet packet03 = new Packet(1, 1418242722L, 325000, 50, d3);
    byte[] d4 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 0, 69, 0, 0, 52, -97, 68, 64, 0, 64, 6, -28, 76, 10, -27, 77, 114, 74, 125, 20, 95, -58, -91, 1, -69, 22, 2, 7, 25, -69, -41, -92, -13, -128, 17, 8, 86, -98, -43, 0, 0, 1, 1, 8, 10, -1, -1, -87, 80, 96, 102, -56, 95 };
    Packet packet04 = new Packet(1, 1418242722L, 625000, 50, d4);
    byte[] d5 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 0, 69, 0, 0, 52, -97, 69, 64, 0, 64, 6, -28, 75, 10, -27, 77, 114, 74, 125, 20, 95, -58, -91, 1, -69, 22, 2, 7, 25, -69, -41, -92, -13, -128, 17, 8, 86, -98, -101, 0, 0, 1, 1, 8, 10, -1, -1, -87, -118, 96, 102, -56, 95 };
    Packet packet05 = new Packet(1, 1418242723L, 226000, 50, d5);
    byte[] d6 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 0, 69, 0, 0, 52, -97, 70, 64, 0, 64, 6, -28, 74, 10, -27, 77, 114, 74, 125, 20, 95, -58, -91, 1, -69, 22, 2, 7, 25, -69, -41, -92, -13, -128, 17, 8, 86, -98, 39, 0, 0, 1, 1, 8, 10, -1, -1, -87, -2, 96, 102, -56, 95 };
    Packet packet06 = new Packet(1, 1418242724L, 328000, 50, d6);
    byte[] d7 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 0, 69, 0, 0, 60, -87, -69, 64, 0, 64, 6, 76, -123, 10, 120, 0, 1, 74, 125, -17, -123, -104, 53, 1, -69, 91, 8, 3, -57, 0, 0, 0, 0, -96, 2, -1, -1, 96, 73, 0, 0, 2, 4, 5, -76, 4, 2, 8, 10, -1, -1, -86, 124, 0, 0, 0, 0, 1, 3, 3, 6 };
    Packet packet07 = new Packet(1, 1418242725L, 730000, 50, d7);
    byte[] d8 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 0, 69, 0, 0, 60, 0, 0, 64, 0, 64, 6, -10, 64, 74, 125, -17, -123, 10, 120, 0, 1, 1, -69, -104, 53, 25, -21, 49, 103, 91, 8, 3, -56, -96, 18, -1, -1, 72, 11, 0, 0, 2, 4, 5, -76, 4, 2, 8, 10, 53, -38, -105, 0, -1, -1, -86, 124, 1, 3, 3, 6 };
    Packet packet08 = new Packet(1, 1418242725L, 731000, 50, d8);
    byte[] d9 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 0, 69, 0, 0, 52, -87, -68, 64, 0, 64, 6, 76, -116, 10, 120, 0, 1, 74, 125, -17, -123, -104, 53, 1, -69, 91, 8, 3, -56, 25, -21, 49, 104, -128, 16, 5, 89, 113, 119, 0, 0, 1, 1, 8, 10, -1, -1, -86, -126, 53, -38, -105, 0 };
    Packet packet09 = new Packet(1, 1418242725L, 731000, 50, d9);
    PacketInfo packetInfo01 = new PacketInfo(packet01);
    PacketInfo packetInfo02 = new PacketInfo(packet02);
    PacketInfo packetInfo03 = new PacketInfo(packet03);
    PacketInfo packetInfo04 = new PacketInfo(packet04);
    PacketInfo packetInfo05 = new PacketInfo(packet05);
    PacketInfo packetInfo06 = new PacketInfo(packet06);
    PacketInfo packetInfo07 = new PacketInfo(packet07);
    PacketInfo packetInfo08 = new PacketInfo(packet08);
    PacketInfo packetInfo09 = new PacketInfo(packet09);
    List<PacketInfo> packetlist01 = new ArrayList<PacketInfo>();
    List<PacketInfo> packetlist02 = new ArrayList<PacketInfo>();
    packetInfo01.setTcpInfo(TcpInfo.TCP_ESTABLISH);
    packetInfo02.setTcpInfo(TcpInfo.TCP_ACK);
    packetInfo01.setDir(PacketDirection.UPLINK);
    packetInfo02.setDir(PacketDirection.UPLINK);
    packetInfo03.setDir(PacketDirection.UPLINK);
    packetInfo04.setDir(PacketDirection.UPLINK);
    packetInfo05.setDir(PacketDirection.UPLINK);
    packetInfo06.setDir(PacketDirection.UPLINK);
    packetInfo07.setDir(PacketDirection.UPLINK);
    packetInfo08.setDir(PacketDirection.UPLINK);
    packetInfo01.setTimestamp(0.0);
    packetInfo02.setTimestamp(10.0);
    packetInfo03.setTimestamp(20.0);
    packetInfo04.setTimestamp(30.0);
    packetInfo05.setTimestamp(10.0);
    packetInfo06.setTimestamp(20.0);
    packetInfo07.setTimestamp(30.0);
    packetInfo08.setTimestamp(40.0);
    packetInfo09.setTimestamp(50.0);
    packetlist01.add(packetInfo01);
    packetlist01.add(packetInfo02);
    packetlist01.add(packetInfo03);
    packetlist01.add(packetInfo04);
    packetlist02.add(packetInfo05);
    packetlist02.add(packetInfo06);
    packetlist02.add(packetInfo07);
    packetlist02.add(packetInfo08);
    packetlist02.add(packetInfo09);
    session01.setUdpOnly(false);
    session01.setTcpPackets(packetlist01);
    session02.setUdpOnly(false);
    session02.setTcpPackets(packetlist02);
    HttpRequestResponseInfo httpRequestResponseInfo01 = new HttpRequestResponseInfo();
    httpRequestResponseInfo01.setFirstDataPacket(packetInfo01);
    httpRequestResponseInfo01.setDirection(HttpDirection.REQUEST);
    httpRequestResponseInfo01.setHostName("yahoo.com");
    httpRequestResponseInfo01.setObjName("");
    HttpRequestResponseInfo httpRequestResponseInfo02 = new HttpRequestResponseInfo();
    httpRequestResponseInfo02.setFirstDataPacket(packetInfo02);
    httpRequestResponseInfo02.setDirection(HttpDirection.REQUEST);
    httpRequestResponseInfo02.setHostName("google.com");
    httpRequestResponseInfo02.setObjName("");
    HttpRequestResponseInfo httpRequestResponseInfo03 = new HttpRequestResponseInfo();
    httpRequestResponseInfo03.setFirstDataPacket(packetInfo04);
    httpRequestResponseInfo03.setDirection(HttpDirection.REQUEST);
    httpRequestResponseInfo03.setHostName("cnn.com");
    httpRequestResponseInfo03.setObjName("");
    List<HttpRequestResponseInfo> httpRequestResponseInfolist = new ArrayList<HttpRequestResponseInfo>();
    httpRequestResponseInfolist.add(httpRequestResponseInfo01);
    httpRequestResponseInfolist.add(httpRequestResponseInfo02);
    httpRequestResponseInfolist.add(httpRequestResponseInfo02);
    httpRequestResponseInfolist.add(httpRequestResponseInfo03);
    session01.setRequestResponseInfo(httpRequestResponseInfolist);
    Burst burst01 = new Burst(packetlist01);
    burst01.setFirstUplinkDataPacket(packetInfo01);
    burst01.setBurstInfo(BurstCategory.CLIENT_APP);
    Burst burst02 = new Burst(packetlist01);
    burst02.setFirstUplinkDataPacket(packetInfo01);
    burst02.setBurstInfo(BurstCategory.PERIODICAL);
    Burst burst03 = new Burst(packetlist02);
    burst03.setFirstUplinkDataPacket(packetInfo02);
    burst03.setBurstInfo(BurstCategory.CLIENT_APP);
    Burst burst04 = new Burst(packetlist02);
    burst04.setFirstUplinkDataPacket(packetInfo02);
    burst04.setBurstInfo(BurstCategory.PERIODICAL);
    Burst burst05 = new Burst(packetlist02);
    burst05.setFirstUplinkDataPacket(packetInfo02);
    burst05.setBurstInfo(BurstCategory.CLIENT_APP);
    Burst burst06 = new Burst(packetlist01);
    burst06.setFirstUplinkDataPacket(packetInfo03);
    burst06.setBurstInfo(BurstCategory.PERIODICAL);
    Burst burst07 = new Burst(packetlist01);
    burst07.setBurstInfo(BurstCategory.CLIENT_APP);
    Burst burst08 = new Burst(packetlist02);
    burst08.setBurstInfo(BurstCategory.PERIODICAL);
    Burst burst09 = new Burst(packetlist02);
    burst09.setBurstInfo(BurstCategory.CLIENT_APP);
    Burst burst10 = new Burst(packetlist01);
    burst10.setBurstInfo(BurstCategory.PERIODICAL);
    List<Burst> burstCollection = new ArrayList<Burst>();
    burstCollection.add(burst01);
    burstCollection.add(burst02);
    burstCollection.add(burst03);
    burstCollection.add(burst04);
    burstCollection.add(burst06);
    burstCollection.add(burst07);
    burstCollection.add(burst08);
    burstCollection.add(burst09);
    burstCollection.add(burst10);
    BurstCollectionAnalysisData burstcollectionAnalysisData = new BurstCollectionAnalysisData();
    burstcollectionAnalysisData.setBurstCollection(burstCollection);
    List<Session> sessionlist = new ArrayList<Session>();
    sessionlist.add(session01);
    sessionlist.add(session02);
    sessionlist.add(session01);
    sessionlist.add(session01);
    sessionlist.add(session01);
    sessionlist.add(session01);
    sessionlist.add(session01);
    sessionlist.add(session02);
    sessionlist.add(session01);
    tracedata.setSessionlist(sessionlist);
    tracedata.setBurstCollectionAnalysisData(burstcollectionAnalysisData);
    tracedata.setProfile(profile3g);
    AbstractBestPracticeResult result = periodicTransferImpl.runTest(tracedata);
    assertEquals(BPResultType.FAIL, result.getResultType());
}
Also used : Packet(com.att.aro.core.packetreader.pojo.Packet) UnknownHostException(java.net.UnknownHostException) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Burst(com.att.aro.core.packetanalysis.pojo.Burst) Profile3G(com.att.aro.core.configuration.pojo.Profile3G) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) InetAddress(java.net.InetAddress) Session(com.att.aro.core.packetanalysis.pojo.Session) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Aggregations

BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)12 ArrayList (java.util.ArrayList)10 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)9 BaseTest (com.att.aro.core.BaseTest)8 Test (org.junit.Test)8 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)7 Session (com.att.aro.core.packetanalysis.pojo.Session)7 InetAddress (java.net.InetAddress)6 Burst (com.att.aro.core.packetanalysis.pojo.Burst)5 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)4 RrcStateRange (com.att.aro.core.packetanalysis.pojo.RrcStateRange)4 DomainNameSystem (com.att.aro.core.packetreader.pojo.DomainNameSystem)4 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)4 UDPPacket (com.att.aro.core.packetreader.pojo.UDPPacket)4 CpuActivity (com.att.aro.core.peripheral.pojo.CpuActivity)4 HashSet (java.util.HashSet)4 ProfileLTE (com.att.aro.core.configuration.pojo.ProfileLTE)3 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)3 UserEvent (com.att.aro.core.peripheral.pojo.UserEvent)3 HashMap (java.util.HashMap)3