Search in sources :

Example 11 with TraceDirectoryResult

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

the class PacketAnalyzerImpl method analyzeTraceDirectory.

@Override
public PacketAnalyzerResult analyzeTraceDirectory(String traceDirectory, Profile profile, AnalysisFilter filter) throws FileNotFoundException {
    long bpStartTime = System.currentTimeMillis();
    TraceDirectoryResult result = tracereader.readTraceDirectory(traceDirectory);
    if (filter != null) {
        TimeRange tempTimeRange = filter.getTimeRange();
        if (tempTimeRange != null) {
            TraceDirectoryResult tempResult = (TraceDirectoryResult) pktTimeUtil.getTimeRangeResult(result, tempTimeRange);
            result.setAlarmInfos(tempResult.getAlarmInfos());
            result.setBatteryInfos(tempResult.getBatteryInfos());
            result.setBluetoothInfos(tempResult.getBluetoothInfos());
            result.setCameraInfos(tempResult.getCameraInfos());
            result.setGpsInfos(tempResult.getGpsInfos());
            result.setNetworkTypeInfos(tempResult.getNetworkTypeInfos());
            result.setRadioInfos(tempResult.getRadioInfos());
            result.setScreenStateInfos(tempResult.getScreenStateInfos());
            result.setUserEvents(tempResult.getUserEvents());
            result.setTemperatureInfos(tempResult.getTemperatureInfos());
            result.setLocationEventInfos(tempResult.getLocationEventInfos());
            result.setWifiInfos(tempResult.getWifiInfos());
            result.getCpuActivityList().updateTimeRange(tempTimeRange.getBeginTime(), tempTimeRange.getEndTime());
            result.setDeviceKeywordInfos(tempResult.getDeviceKeywordInfos());
            result.setAttenautionEvent(tempResult.getAttenautionEvent());
        }
    }
    PacketAnalyzerResult res = finalResult(result, profile, filter);
    result.setMetaData(metaDataHelper.initMetaData(res));
    GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsTimings(pktAnalysisTitle, System.currentTimeMillis() - bpStartTime, analysisCategory);
    LOGGER.debug(String.format("Time to process PacketAnalyzerImpl %s :%12.4f", pktAnalysisTitle, ((float) (System.currentTimeMillis() - bpStartTime)) / 3600.0));
    return res;
}
Also used : TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)

Example 12 with TraceDirectoryResult

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

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

the class PktAnazlyzerTimeRangeImpl method getTimeRangeResult.

@Override
public AbstractTraceResult getTimeRangeResult(TraceDirectoryResult result, TimeRange timeRange) {
    TraceDirectoryResult resultForTimeRange = result;
    getUserEventsForTheTimeRange(resultForTimeRange, timeRange.getBeginTime(), timeRange.getEndTime());
    getScreenInfosForTheTimeRange(resultForTimeRange, timeRange.getBeginTime(), timeRange.getEndTime());
    getBluetoothInfosForTheTimeRange(resultForTimeRange, timeRange.getBeginTime(), timeRange.getEndTime());
    getGpsInfosForTheTimeRange(resultForTimeRange, timeRange.getBeginTime(), timeRange.getEndTime());
    getRadioInfosForTheTimeRange(resultForTimeRange, timeRange.getBeginTime(), timeRange.getEndTime());
    getBatteryInfosForTheTimeRange(resultForTimeRange, timeRange.getBeginTime(), timeRange.getEndTime());
    getWifiInfosForTheTimeRange(resultForTimeRange, timeRange.getBeginTime(), timeRange.getEndTime());
    getNetworkInfosForTheTimeRange(resultForTimeRange, timeRange.getBeginTime(), timeRange.getEndTime());
    getCameraInfosForTheTimeRange(resultForTimeRange, timeRange.getBeginTime(), timeRange.getEndTime());
    return resultForTimeRange;
}
Also used : TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)

Example 14 with TraceDirectoryResult

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

the class TraceDataReaderImpl method readTraceDirectory.

/**
 * read all kind of trace file in a directory
 *
 * @param directoryPath
 *            full path to physical directory
 * @throws FileNotFoundException
 */
public TraceDirectoryResult readTraceDirectory(String directoryPath) throws FileNotFoundException {
    if (!filereader.directoryExist(directoryPath)) {
        throw new FileNotFoundException("Not found directory: " + directoryPath);
    }
    TraceDirectoryResult result = new TraceDirectoryResult();
    result.setTraceDirectory(directoryPath);
    // readAppInfo(result);
    AppInfo app = appinforeader.readData(result.getTraceDirectory());
    result.setAppVersionMap(app.getAppVersionMap());
    result.setAppInfos(app.getAppInfos());
    // Read the time file and PCAP trace
    try {
        result = readTimeAndPcap(result);
    } catch (IOException e1) {
        LOGGER.error("Failed to read file", e1);
        // no need to continue, everything else is useless without packet data
        return null;
    }
    if (result == null) {
        return null;
    }
    readDeviceDetails(result);
    // merge several methods to one method
    readFileUtil(result);
    readAlarmDumpsysTimestamp(result);
    try {
        readAlarmAnalysisInfo(result);
    } catch (IOException e) {
        LOGGER.info("*** Warning: no alarm dumpsys information found ***");
    }
    readWakelockInfo(result);
    readVideoTime(result);
    readSSLKeys(result);
    readPrivateData(result);
    readAttenuationEvent(result);
    readThrottleEvent(result);
    return result;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) IOException(java.io.IOException) AppInfo(com.att.aro.core.peripheral.pojo.AppInfo)

Example 15 with TraceDirectoryResult

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

the class MinificationImplTest method runTest_4.

/**
 * tests Javascript compression
 */
@Test
public void runTest_4() {
    List<Session> sessionlist;
    Session session_1;
    HttpRequestResponseInfo req_1;
    HttpRequestResponseInfo rr_2;
    session_1 = mock(Session.class);
    sessionlist = new ArrayList<Session>();
    sessionlist.add(session_1);
    req_1 = mock(HttpRequestResponseInfo.class);
    rr_2 = mock(HttpRequestResponseInfo.class);
    List<HttpRequestResponseInfo> reqList_1 = new ArrayList<HttpRequestResponseInfo>();
    reqList_1.add(req_1);
    reqList_1.add(rr_2);
    Mockito.when((TraceDirectoryResult) tracedata.getTraceresult()).thenReturn(dirdata);
    Mockito.when(dirdata.getTraceResultType()).thenReturn(TraceResultType.TRACE_DIRECTORY);
    Mockito.when(session_1.getRequestResponseInfo()).thenReturn(reqList_1);
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionlist);
    Mockito.when(req_1.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(req_1.getContentLength()).thenReturn(5);
    MinificationImpl = (MinificationImpl) context.getBean("minify");
    Mockito.when(rr_2.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(req_1.getContentType()).thenReturn("text/javascript");
    Mockito.when(rr_2.getAssocReqResp()).thenReturn(req_1);
    Mockito.when(rr_2.getContentLength()).thenReturn(5);
    Mockito.when(req_1.getAssocReqResp()).thenReturn(rr_2);
    Mockito.when(rr_2.getObjName()).thenReturn("/images/travel_buying_guide1.jpg");
    IHttpRequestResponseHelper reqhelper = mock(IHttpRequestResponseHelper.class);
    MinificationImpl.setHttpRequestResponseHelper(reqhelper);
    try {
        String aSession = "" + "/*! jQuery v1.7.1 jquery.com | jquery.org/license */" + "" + "(function(a, b) {\r\n	function myFunction(p1, p2) {\r\n	    return p1 * p2;\r\n	}\r\n})(window);" + "";
        Mockito.when(reqhelper.isJavaScript("text/javascript")).thenReturn(true);
        Mockito.when(reqhelper.isCss("text/css")).thenReturn(false);
        Mockito.when(reqhelper.getContentString(rr_2, session_1)).thenReturn(aSession);
        Mockito.when(reqhelper.getContentString(req_1, session_1)).thenReturn(aSession);
        Mockito.when(req_1.getObjName()).thenReturn("/en/top100-css-websites.html");
        Mockito.when(session_1.getDomainName()).thenReturn("www.google.com");
    } catch (Exception e) {
        e.printStackTrace();
    }
    result = MinificationImpl.runTest(tracedata);
    assertEquals("Many text files contain excess whitespace to allow for better human coding. Run these files through a minifier to remove the whitespace in order to reduce file size.", result.getAboutText());
    assertEquals("Minify CSS, JS and HTML", result.getDetailTitle());
    assertEquals("File Download: Minify CSS, JS and HTML", result.getOverviewTitle());
    assertEquals("MINIFICATION", result.getBestPracticeType().toString());
    assertEquals("FAIL", result.getResultType().toString());
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) Session(com.att.aro.core.packetanalysis.pojo.Session) IHttpRequestResponseHelper(com.att.aro.core.packetanalysis.IHttpRequestResponseHelper) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Aggregations

TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)51 ArrayList (java.util.ArrayList)16 BaseTest (com.att.aro.core.BaseTest)14 Test (org.junit.Test)14 TraceResultType (com.att.aro.core.packetanalysis.pojo.TraceResultType)13 XYToolTipGenerator (org.jfree.chart.labels.XYToolTipGenerator)10 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)10 XYDataset (org.jfree.data.xy.XYDataset)10 Session (com.att.aro.core.packetanalysis.pojo.Session)9 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)8 CollectOptions (com.att.aro.core.peripheral.pojo.CollectOptions)7 XYIntervalSeries (org.jfree.data.xy.XYIntervalSeries)7 XYSeries (org.jfree.data.xy.XYSeries)7 AbstractTraceResult (com.att.aro.core.packetanalysis.pojo.AbstractTraceResult)5 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)5 File (java.io.File)5 IHttpRequestResponseHelper (com.att.aro.core.packetanalysis.IHttpRequestResponseHelper)4 AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)4 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)4 IOException (java.io.IOException)4