Search in sources :

Example 1 with ApplicationSelection

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

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

the class FilterApplicationsAndIpDialog method getOkButton.

/**
 * Initializes and returns the ok Button.
 */
private JButton getOkButton() {
    if (okButton == null) {
        okButton = new JButton();
        okButton.setText(ResourceBundleHelper.getMessageString(DialogItem.Button_ok));
        okButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (ipv4Selection || ipv6Selection) {
                    if (tcpSelection || udpSelection || dnsSelection) {
                        if (getCurrentPktAnalyzerResult().getFilter() != null) {
                            AnalysisFilter filter = getCurrentPktAnalyzerResult().getFilter();
                            Map<InetAddress, String> domainNames = filter.getDomainNames();
                            Map<String, ApplicationSelection> appSelections = new HashMap<String, ApplicationSelection>(filter.getAppSelections().size());
                            for (ApplicationSelection sel : filter.getAppSelections().values()) {
                                if (domainNames != null) {
                                    sel.setDomainNames(domainNames);
                                }
                                appSelections.put(sel.getAppName(), new ApplicationSelection(sel));
                            }
                            filter.setIpv4Sel(ipv4Selection);
                            filter.setIpv6Sel(ipv6Selection);
                            filter.setTcpSel(tcpSelection);
                            filter.setUdpSel(udpSelection);
                            filter.setDnsSelection(dnsSelection);
                            if (!selectionReturnsData()) {
                                noResultsError(ResourceBundleHelper.getMessageString("filter.noResultData.error"));
                            } else {
                                ((MainFrame) parent).updateFilter(filter);
                                dispose();
                            }
                        }
                    } else {
                        noResultsError(ResourceBundleHelper.getMessageString("filter.noProtocolSelection.error"));
                    }
                } else {
                    noResultsError(ResourceBundleHelper.getMessageString("filter.noIpSelection.error"));
                }
            }

            private void noResultsError(String error) {
                MessageDialogFactory.getInstance().showErrorDialog(FilterApplicationsAndIpDialog.this, error);
            }
        });
    }
    return okButton;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) JButton(javax.swing.JButton) ApplicationSelection(com.att.aro.core.packetanalysis.pojo.ApplicationSelection) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with ApplicationSelection

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

the class FilterApplicationsAndIpDialog method cloneFilter.

/*
	 * Make a copy of the filter before selection changes 
	 * made update the filter. We can then revert the 
	 * updated filter using this copy when user clicks
	 * the cancel button.
	 */
private void cloneFilter() {
    AnalysisFilter filter = getCurrentPktAnalyzerResult().getFilter();
    Collection<ApplicationSelection> appSel = filter.getApplicationSelections();
    HashMap<String, ApplicationSelection> applications = new HashMap<String, ApplicationSelection>(appSel.size());
    for (ApplicationSelection aSel : appSel) {
        ApplicationSelection clonedAP = new ApplicationSelection(aSel);
        applications.put(clonedAP.getAppName(), clonedAP);
    }
    initialFilter = new AnalysisFilter(applications, filter.getTimeRange(), filter.getDomainNames());
    initialFilter.setIpv4Sel(filter.isIpv4Sel());
    initialFilter.setIpv6Sel(filter.isIpv6Sel());
    initialFilter.setIpv6Sel(filter.isTcpSel());
    initialFilter.setUdpSel(filter.isUdpSel());
}
Also used : HashMap(java.util.HashMap) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) ApplicationSelection(com.att.aro.core.packetanalysis.pojo.ApplicationSelection)

Example 4 with ApplicationSelection

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

the class FilterApplicationsAndIpDialog method selectionReturnsData.

/*
	 * Compares user selection to trace data to determine 
	 * if all the trace data will be filtered out if user
	 * selection is applied. 
	 */
private boolean selectionReturnsData() {
    AnalysisFilter filter = getCurrentPktAnalyzerResult().getFilter();
    if (!filter.isIpv4Sel() && !filter.isIpv6Sel() && !filter.isTcpSel() && !filter.isUdpSel() && !filter.isDnsSelection()) {
        return false;
    }
    Collection<ApplicationSelection> appSel = filter.getApplicationSelections();
    List<IPAddressSelection> ipSel = new ArrayList<IPAddressSelection>();
    List<IPAddressSelection> ipSelChecked = new ArrayList<IPAddressSelection>();
    for (ApplicationSelection aSel : appSel) {
        ipSel.addAll(aSel.getIPAddressSelections());
    }
    for (IPAddressSelection iSel : ipSel) {
        if (iSel.isSelected()) {
            ipSelChecked.add(iSel);
        }
    }
    if (ipSelChecked.size() == 0) {
        return false;
    }
    List<PacketInfo> packetsInfo = getInitialPktAnalyzerResult().getTraceresult().getAllpackets();
    PacketAnalyzerImpl pktAnalyzer = (PacketAnalyzerImpl) ((MainFrame) parent).getController().getAROService().getAnalyzer();
    if (pktAnalyzer.filterPackets(filter, packetsInfo).size() > 0) {
        return true;
    }
    return false;
}
Also used : PacketAnalyzerImpl(com.att.aro.core.packetanalysis.impl.PacketAnalyzerImpl) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) ApplicationSelection(com.att.aro.core.packetanalysis.pojo.ApplicationSelection) ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) IPAddressSelection(com.att.aro.core.packetanalysis.pojo.IPAddressSelection)

Example 5 with ApplicationSelection

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

the class FilterApplicationsAndIpDialog method initialize.

/**
 * Initializes the dialog.
 */
private void initialize() {
    PacketAnalyzerResult currentTraceResult = ((MainFrame) parent).getController().getTheModel().getAnalyzerResult();
    PacketAnalyzerResult initialTraceResult = ((MainFrame) parent).getController().getCurrentTraceInitialAnalyzerResult();
    if (currentTraceResult == null) {
        LOGGER.error("Trace result error! ");
        MessageDialogFactory.getInstance().showErrorDialog(FilterApplicationsAndIpDialog.this, "wrong..");
    } else {
        setCurrentPktAnalyzerResult(currentTraceResult);
        setInitialPktAnalyzerResult(initialTraceResult);
        // Save a copy of the filter before user makes any changes to the selection
        cloneFilter();
        this.jIpAddressesTableModel = new FilterIpAddressesTableModel(currentTraceResult.getFilter());
        this.jApplicationsTableModel = new FilterApplicationsTableModel(currentTraceResult.getFilter());
        this.jApplicationsTableModel.addTableModelListener(new TableModelListener() {

            @Override
            public void tableChanged(TableModelEvent e) {
                if (e.getColumn() == FilterApplicationsTableModel.SELECT_COL || e.getColumn() == FilterApplicationsTableModel.COLOR_COL) {
                    for (int row = e.getFirstRow(); row <= e.getLastRow(); ++row) {
                        if (row >= 0 && row < jApplicationsTableModel.getRowCount()) {
                            ApplicationSelection as = jApplicationsTableModel.getValueAt(row);
                            String appName = as.getAppName();
                            for (FilterIpAddressesTableModel.AppIPAddressSelection is : jIpAddressesTableModel.getData()) {
                                if (appName == is.getAppName() || (appName != null && appName.equals(is.getAppName()))) {
                                    if ((as.isSelected() || !is.getIpSelection().isSelected()) && e.getColumn() == FilterApplicationsTableModel.COLOR_COL) {
                                        is.getIpSelection().setColor(as.getColor());
                                    }
                                    if (e.getColumn() == FilterApplicationsTableModel.SELECT_COL) {
                                        is.getIpSelection().setSelected(as.isSelected());
                                    }
                                }
                            }
                        }
                    }
                    jIpAddressesTableModel.fireTableDataChanged();
                }
            }
        });
        this.jIpAddressesTableModel.addTableModelListener(new TableModelListener() {

            @Override
            public void tableChanged(TableModelEvent e) {
                if (e.getColumn() == FilterIpAddressesTableModel.SELECT_COL) {
                    for (int row = e.getFirstRow(); row <= e.getLastRow(); ++row) {
                        if (row >= 0 && row < jIpAddressesTableModel.getRowCount()) {
                            FilterIpAddressesTableModel.AppIPAddressSelection ipSel = jIpAddressesTableModel.getValueAt(row);
                            String appName = ipSel.getAppName();
                            boolean b = ipSel.getIpSelection().isSelected();
                            if (b) {
                                for (FilterIpAddressesTableModel.AppIPAddressSelection is : jIpAddressesTableModel.getData()) {
                                    if (appName == is.getAppName() || (appName != null && appName.equals(is.getAppName()))) {
                                        b &= is.getIpSelection().isSelected();
                                    }
                                }
                            }
                            for (ApplicationSelection as : jApplicationsTableModel.getData()) {
                                if (appName != null && appName.equals(as.getAppName())) {
                                    as.setSelected(b);
                                    break;
                                }
                            }
                            jApplicationsTableModel.fireTableDataChanged();
                        }
                    }
                }
            }
        });
    }
    this.setSize(600, 420);
    this.setModal(true);
    this.setTitle(ResourceBundleHelper.getMessageString(DialogItem.filter_title));
    this.setLayout(new BorderLayout());
    this.add(getMainPanel(), BorderLayout.CENTER);
    this.setLocationRelativeTo(getOwner());
    new EnableEscKeyCloseDialog(getRootPane(), this);
}
Also used : BorderLayout(java.awt.BorderLayout) EnableEscKeyCloseDialog(com.att.aro.ui.commonui.EnableEscKeyCloseDialog) TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener) ApplicationSelection(com.att.aro.core.packetanalysis.pojo.ApplicationSelection) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) MainFrame(com.att.aro.ui.view.MainFrame)

Aggregations

ApplicationSelection (com.att.aro.core.packetanalysis.pojo.ApplicationSelection)10 AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)6 HashMap (java.util.HashMap)5 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)3 IPAddressSelection (com.att.aro.core.packetanalysis.pojo.IPAddressSelection)2 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)2 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)2 Session (com.att.aro.core.packetanalysis.pojo.Session)2 InetAddress (java.net.InetAddress)2 ArrayList (java.util.ArrayList)2 BestPracticeType (com.att.aro.core.bestpractice.pojo.BestPracticeType)1 Profile (com.att.aro.core.configuration.pojo.Profile)1 PacketAnalyzerImpl (com.att.aro.core.packetanalysis.impl.PacketAnalyzerImpl)1 AbstractRrcStateMachine (com.att.aro.core.packetanalysis.pojo.AbstractRrcStateMachine)1 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)1 EnergyModel (com.att.aro.core.packetanalysis.pojo.EnergyModel)1 Statistic (com.att.aro.core.packetanalysis.pojo.Statistic)1 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)1 TraceTimeRange (com.att.aro.core.peripheral.pojo.TraceTimeRange)1 EnableEscKeyCloseDialog (com.att.aro.ui.commonui.EnableEscKeyCloseDialog)1