Search in sources :

Example 16 with AROTraceData

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

the class AROController method updateModel.

/**
 * <p>
 * This is the main entry point for requesting an analysis of a trace.
 * </p>
 * <p>
 *
 * <em>path</em> is the file or folder containing the trace raw data if we load tracefile , the path include the file name ex, ......\traffic.cap if we load
 * tracefolder, the path include the folder name ex, .....\tracefolder
 *
 * @param path Where the trace directory or .cap file is located
 * @param profile The Profile to use for this analysis - LTE if null
 * @param filter The filters to use - can be empty for no filtering specified
 */
public void updateModel(String path, Profile profile, AnalysisFilter filter) {
    try {
        if (path != null) {
            AROTraceData model = runAnalyzer(path, profile, filter);
            if (!model.isSuccess()) {
                AROTraceData tempModel = theModel;
                theModel = model;
                theView.refresh();
                theModel = tempModel;
            } else {
                theModel = model;
                if (filter == null) {
                    // when the first loading traces, set the filter
                    initializeFilter();
                } else if (filter.getDomainNames() == null || filter.getDomainNames().isEmpty()) {
                    /* 
						 * For when there is a TimeRange added to an otherwise empty AnalysisFilter.
						 * Caused by the analysis flow from opening a trace with an active timerange.json selection
						 * see: AROController.propertyChange(PropertyChangeEvent)
						 */
                    initializeFilter(filter.getTimeRange());
                }
                theView.refresh();
            }
        }
    } catch (Exception ex) {
        LOG.info("Error Log:" + ex.getMessage());
        LOG.error("Exception : ", ex);
    }
    (new Thread(() -> GoogleAnalyticsUtil.reportMimeDataType(theModel))).start();
}
Also used : AROTraceData(com.att.aro.core.pojo.AROTraceData) IOException(java.io.IOException)

Example 17 with AROTraceData

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

the class DataDump method startDataDump.

/**
 * Starts dumping data in CSV file for the provided trace files.
 *
 * @param traceFolders
 *            - List of trace folder names.
 * @return A FileWriter object.
 * @throws IOException
 */
private FileWriter startDataDump(List<File> traceFolders) throws IOException, ProfileException {
    FileWriter writer = new FileWriter(fileToSave);
    try {
        List<File> validFolderList = new ArrayList<File>();
        Set<AROTraceData> analysis = new LinkedHashSet<AROTraceData>();
        getValidFolderList(traceFolders, validFolderList);
        for (File traceDirectory : validFolderList) {
            try {
                analysis.add(controller.runAnalyzer(traceDirectory.getAbsolutePath(), controller.getTheModel().getAnalyzerResult().getProfile(), null));
            } catch (Exception e) {
                LOG.warn("Unable to run analysis on folder: " + traceDirectory, e);
            }
        }
        try {
            new ObjectMapper().writeValue(fileToSave, analysis);
        } catch (JsonGenerationException e) {
            LOG.error(e.getMessage());
            new MessageDialogFactory().showUnexpectedExceptionDialog(MSG_WINDOW, e);
        } catch (JsonMappingException e) {
            LOG.error(e.getMessage());
            new MessageDialogFactory().showUnexpectedExceptionDialog(MSG_WINDOW, e);
        } catch (IOException e) {
            LOG.error(e.getMessage());
            new MessageDialogFactory().showUnexpectedExceptionDialog(MSG_WINDOW, e);
        }
        userPreferences.setLastTraceDirectory(traceDir);
    } finally {
        writer.close();
    }
    return writer;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) IOException(java.io.IOException) AROTraceData(com.att.aro.core.pojo.AROTraceData) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) ProfileException(com.att.aro.ui.view.menu.profiles.ProfileException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 18 with AROTraceData

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

the class GraphPanel method filterFlowTable.

// In 4.1.1, the method called refreshGraph()
public void filterFlowTable() {
    AROTraceData filteredSessionTraceData = getTraceData();
    double filteredStartTime = 0.0;
    double filteredEndTime = 0.0;
    double filteredDuration = filteredSessionTraceData.getAnalyzerResult().getTraceresult().getTraceDuration();
    List<Session> tcpsessionsList = new ArrayList<Session>();
    if (getTraceData() == null) {
        return;
    } else {
        TCPUDPFlowsTableModel model = (TCPUDPFlowsTableModel) parent.getJTCPFlowsTable().getModel();
        Map<String, Session> subSessionMap = model.getSessionMap();
        Map<String, Boolean> subcheckboxMap = model.getCheckboxMap();
        for (Map.Entry<String, Boolean> entry : subcheckboxMap.entrySet()) {
            if (entry.getValue()) {
                tcpsessionsList.add(subSessionMap.get(entry.getKey()));
            }
        }
        filteredSessionTraceData.getAnalyzerResult().setSessionlist(tcpsessionsList);
    }
    List<PacketInfo> packetsForSelectedSession = new ArrayList<PacketInfo>();
    for (Session tcpSession : tcpsessionsList) {
        if (tcpSession.getTcpPackets() != null) {
            packetsForSelectedSession.addAll(tcpSession.getTcpPackets());
        }
    }
    // when generating graph, make sure session is ordered by time stamp
    Collections.sort(packetsForSelectedSession, new Comparator<PacketInfo>() {

        @Override
        public int compare(PacketInfo p1, PacketInfo p2) {
            return (int) (p1.getTimeStamp() * 1000 - p2.getTimeStamp() * 1000);
        }
    });
    boolean selectedAllPackets = false;
    // Adding the TCP packets to the trace for getting redoing the analysis
    if (packetsForSelectedSession.size() > 0) {
        if (tcpsessionsList.size() == getAllTcpSessions()) {
            // For select all use all exiting packets
            filteredSessionTraceData.getAnalyzerResult().getTraceresult().setAllpackets(getAllPackets());
            selectedAllPackets = true;
        } else {
            // Collections.sort(packetsForSelectedSession);//?
            filteredSessionTraceData.getAnalyzerResult().getTraceresult().setAllpackets(packetsForSelectedSession);
        }
    }
    if (selectedAllPackets) {
        filteredStartTime = -0.01;
        filteredEndTime = filteredDuration;
    } else {
        int index = 0;
        for (Session tcpSession : tcpsessionsList) {
            if (tcpSession.getTcpPackets().size() != 0) {
                if (index == 0) {
                    filteredStartTime = tcpSession.getTcpPackets().get(0).getTimeStamp();
                    filteredEndTime = tcpSession.getTcpPackets().get(0).getTimeStamp();
                }
                if (filteredStartTime > tcpSession.getTcpPackets().get(0).getTimeStamp()) {
                    filteredStartTime = tcpSession.getTcpPackets().get(0).getTimeStamp();
                }
                if (filteredEndTime < tcpSession.getTcpPackets().get(0).getTimeStamp()) {
                    filteredEndTime = tcpSession.getTcpPackets().get(0).getTimeStamp();
                }
                index++;
            }
        }
        if (index == 0) {
            filteredStartTime = 0.0;
            filteredEndTime = 0.0;
        }
    }
    // for Analysis data particular time of the graph, some number is not clear..
    if (filteredStartTime > 0) {
        // adjust the time line axis number
        filteredStartTime = filteredStartTime - 2;
        if (filteredStartTime < 0) {
            filteredStartTime = -0.01;
        }
    }
    if (filteredStartTime < 0) {
        filteredStartTime = -0.01;
    }
    if (!selectedAllPackets) {
        if (filteredEndTime > 0) {
            // adjust the time line axis number
            filteredEndTime = filteredEndTime + 15;
        }
        if (filteredEndTime > filteredDuration) {
            filteredEndTime = filteredDuration;
        }
    }
    this.startTime = filteredStartTime;
    this.endTime = filteredEndTime;
    if (getTraceData() != null) {
        TimeRange timeRange = new TimeRange(filteredStartTime, filteredEndTime);
        AnalysisFilter filter = filteredSessionTraceData.getAnalyzerResult().getFilter();
        filter.setTimeRange(timeRange);
        filteredSessionTraceData.getAnalyzerResult().setFilter(filter);
        Statistic stat = ContextAware.getAROConfigContext().getBean(IPacketAnalyzer.class).getStatistic(packetsForSelectedSession);
        long totaltemp = 0;
        for (Session byteCountSession : tcpsessionsList) {
            totaltemp += byteCountSession.getBytesTransferred();
        }
        stat.setTotalByte(totaltemp);
        AbstractRrcStateMachine statemachine = ContextAware.getAROConfigContext().getBean(IRrcStateMachineFactory.class).create(packetsForSelectedSession, filteredSessionTraceData.getAnalyzerResult().getProfile(), stat.getPacketDuration(), filteredDuration, stat.getTotalByte(), timeRange);
        BurstCollectionAnalysisData burstcollectiondata = new BurstCollectionAnalysisData();
        if (stat.getTotalByte() > 0) {
            burstcollectiondata = ContextAware.getAROConfigContext().getBean(IBurstCollectionAnalysis.class).analyze(packetsForSelectedSession, filteredSessionTraceData.getAnalyzerResult().getProfile(), stat.getPacketSizeToCountMap(), statemachine.getStaterangelist(), filteredSessionTraceData.getAnalyzerResult().getTraceresult().getUserEvents(), filteredSessionTraceData.getAnalyzerResult().getTraceresult().getCpuActivityList().getCpuActivities(), tcpsessionsList);
        }
        filteredSessionTraceData.getAnalyzerResult().getStatistic().setTotalByte(stat.getTotalByte());
        filteredSessionTraceData.getAnalyzerResult().setStatemachine(statemachine);
        filteredSessionTraceData.getAnalyzerResult().setBurstCollectionAnalysisData(burstcollectiondata);
        refresh(filteredSessionTraceData);
    }
}
Also used : TCPUDPFlowsTableModel(com.att.aro.ui.model.diagnostic.TCPUDPFlowsTableModel) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) ArrayList(java.util.ArrayList) Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) AbstractRrcStateMachine(com.att.aro.core.packetanalysis.pojo.AbstractRrcStateMachine) IPacketAnalyzer(com.att.aro.core.packetanalysis.IPacketAnalyzer) AROTraceData(com.att.aro.core.pojo.AROTraceData) Point(java.awt.Point) TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) Map(java.util.Map) EnumMap(java.util.EnumMap) TreeMap(java.util.TreeMap) IRrcStateMachineFactory(com.att.aro.core.packetanalysis.IRrcStateMachineFactory) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 19 with AROTraceData

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

the class AROToolMenu method openPcapAnalysis.

private void openPcapAnalysis() {
    // Open PCAP analysis tool
    AROTraceData traceData = ((MainFrame) parent).getController().getTheModel();
    IFileManager fileManager = ContextAware.getAROConfigContext().getBean(IFileManager.class);
    File dir = fileManager.createFile(traceData.getAnalyzerResult().getTraceresult().getTraceDirectory());
    File[] trafficFiles;
    if (fileManager.isFile(dir.getAbsolutePath())) {
        trafficFiles = new File[] { new File(dir.getAbsolutePath()) };
    } else {
        trafficFiles = getTrafficTextFiles(dir);
    }
    if (trafficFiles != null && trafficFiles.length > 0) {
        try {
            for (File trafficFile : trafficFiles) {
                if (trafficFile.getName().equals(TraceDataConst.FileName.PCAP_FILE)) {
                    Desktop.getDesktop().open(trafficFile);
                    break;
                }
            }
        } catch (NullPointerException e) {
            MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.tools.error.noPcap"));
        } catch (IllegalArgumentException e) {
            MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.tools.error.noPcap"));
        } catch (IOException e) {
            MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.tools.error.noPcapApp"));
        }
    }
}
Also used : IOException(java.io.IOException) AROTraceData(com.att.aro.core.pojo.AROTraceData) File(java.io.File) MainFrame(com.att.aro.ui.view.MainFrame) IFileManager(com.att.aro.core.fileio.IFileManager)

Example 20 with AROTraceData

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

the class Application method runAnalyzer.

/**
 * Analyze a trace and produce a report either in json or html<br>
 *
 * <pre>
 * Required command:
 *   --analyze with path to trace directory of traffic.cap
 *   --output output file, error if missing
 *   --format html or json, if missing defaults to json
 *
 * @param context
 *            - Spring ApplicationContext
 * @param cmds
 *            - user commands
 */
void runAnalyzer(ApplicationContext context, Commands cmds) {
    String trace = cmds.getAnalyze();
    IAROService serv = context.getBean(IAROService.class);
    AROTraceData results = null;
    // analyze trace file or directory?
    OutSave outSave = prepareSystemOut();
    ImHereThread imHereThread = new ImHereThread(outSave.getOut(), Logger.getRootLogger());
    try {
        if (serv.isFile(trace)) {
            try {
                results = serv.analyzeFile(retrieveBestPractices(), trace);
            } catch (IOException | TsharkException e) {
                errln("Error occured analyzing trace, detail: " + e.getMessage());
                System.exit(1);
            }
        } else {
            try {
                results = serv.analyzeDirectory(retrieveBestPractices(), trace);
            } catch (IOException e) {
                errln("Error occured analyzing trace directory, detail: " + e.getMessage());
                System.exit(1);
            }
        }
        if (results != null && results.isSuccess()) {
            outSave = prepareSystemOut();
            if (cmds.getFormat().equals("json")) {
                if (serv.getJSonReport(cmds.getOutput(), results)) {
                    outln("Successfully produced JSON report: " + cmds.getOutput());
                } else {
                    errln("Failed to produce JSON report.");
                }
            } else {
                if (serv.getHtmlReport(cmds.getOutput(), results)) {
                    println("Successfully produced HTML report: " + cmds.getOutput());
                } else {
                    errln("Failed to produce HTML report.");
                }
            }
        } else {
            printError(results == null ? new ErrorCode() : results.getError());
        }
    } finally {
        imHereThread.endIndicator();
        while (imHereThread.isRunning()) {
            Thread.yield();
        }
        restoreSystemOut(outSave);
    }
    System.exit(0);
}
Also used : IAROService(com.att.aro.core.IAROService) OutSave(com.att.aro.console.printstreamutils.OutSave) TsharkException(com.att.aro.core.exception.TsharkException) IOException(java.io.IOException) ErrorCode(com.att.aro.core.pojo.ErrorCode) AROTraceData(com.att.aro.core.pojo.AROTraceData) ImHereThread(com.att.aro.console.printstreamutils.ImHereThread)

Aggregations

AROTraceData (com.att.aro.core.pojo.AROTraceData)24 BaseTest (com.att.aro.core.BaseTest)10 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)9 IOException (java.io.IOException)8 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)6 BestPracticeType (com.att.aro.core.bestpractice.pojo.BestPracticeType)5 AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)5 Profile (com.att.aro.core.configuration.pojo.Profile)4 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)4 IVideoBestPractices (com.att.aro.core.IVideoBestPractices)3 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)3 TsharkException (com.att.aro.core.exception.TsharkException)3 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)3 Packet (com.att.aro.core.packetreader.pojo.Packet)3 File (java.io.File)3 IAROService (com.att.aro.core.IAROService)2 PeriodicTransferResult (com.att.aro.core.bestpractice.pojo.PeriodicTransferResult)2 IPacketAnalyzer (com.att.aro.core.packetanalysis.IPacketAnalyzer)2 Session (com.att.aro.core.packetanalysis.pojo.Session)2