Search in sources :

Example 96 with Session

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

the class UnsecureSSLVersionImplTest method getPacketAnalyzerResult.

private PacketAnalyzerResult getPacketAnalyzerResult(Set<String> unsecureSSLVersions) {
    Session session = mock(Session.class);
    PacketInfo info = mock(PacketInfo.class);
    TCPPacket tcpPacket = mock(TCPPacket.class);
    InetAddress address = mock(InetAddress.class);
    String ipAddress = "127.0.0.1";
    int port = 8080;
    List<Session> sessions = new ArrayList<>();
    sessions.add(session);
    List<PacketInfo> packetInfos = new LinkedList<>();
    packetInfos.add(info);
    packetAnalyzerResult.setSessionlist(sessions);
    when(session.getTcpPackets()).thenReturn(packetInfos);
    when(info.getPacket()).thenReturn(tcpPacket);
    when(tcpPacket.getUnsecureSSLVersions()).thenReturn(unsecureSSLVersions);
    when(address.getHostAddress()).thenReturn(ipAddress);
    when(session.getRemoteIP()).thenReturn(address);
    when(session.getRemotePort()).thenReturn(port);
    return packetAnalyzerResult;
}
Also used : TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) InetAddress(java.net.InetAddress) LinkedList(java.util.LinkedList) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 97 with Session

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

the class AROController method initializeFilter.

/**
 * <pre>
 * Create an AnalysisFilter
 * Creates default maps of domainNames and applications
 * Combined with the supplied TimeRange or a default TimeRange to create the AnalysisFilter
 *
 * This filter will be stored in the current PacketAnalyzerResult
 *
 * @param timeRangeParam is optional
 */
private void initializeFilter(TimeRange... timeRangeParam) {
    Collection<String> appNames = theModel.getAnalyzerResult().getTraceresult().getAllAppNames();
    Map<String, Set<InetAddress>> map = theModel.getAnalyzerResult().getTraceresult().getAppIps();
    Map<InetAddress, String> domainNames = new HashMap<InetAddress, String>();
    for (Session tcpSession : theModel.getAnalyzerResult().getSessionlist()) {
        if (!domainNames.containsKey(tcpSession.getRemoteIP())) {
            domainNames.put(tcpSession.getRemoteIP(), tcpSession.getDomainName());
        }
    }
    HashMap<String, ApplicationSelection> applications = new HashMap<String, ApplicationSelection>(appNames.size());
    ApplicationSelection appSelection;
    for (String app : appNames) {
        appSelection = new ApplicationSelection(app, map.get(app));
        appSelection.setDomainNames(domainNames);
        for (IPAddressSelection ipAddressSelection : appSelection.getIPAddressSelections()) {
            ipAddressSelection.setDomainName(domainNames.get(ipAddressSelection.getIpAddress()));
        }
        applications.put(app, appSelection);
    }
    TimeRange timeRange = timeRangeParam != null && timeRangeParam.length == 1 && timeRangeParam[0] != null ? timeRangeParam[0] : null;
    if (timeRange == null) {
        timeRange = new TimeRange(0.0, theModel.getAnalyzerResult().getTraceresult().getTraceDuration());
    }
    AnalysisFilter initFilter = new AnalysisFilter(applications, timeRange, domainNames);
    currentTraceInitialAnalyzerResult = theModel.getAnalyzerResult();
    currentTraceInitialAnalyzerResult.setFilter(initFilter);
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) ApplicationSelection(com.att.aro.core.packetanalysis.pojo.ApplicationSelection) TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) TraceTimeRange(com.att.aro.core.peripheral.pojo.TraceTimeRange) IPAddressSelection(com.att.aro.core.packetanalysis.pojo.IPAddressSelection) InetAddress(java.net.InetAddress) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 98 with Session

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

the class DuplicateContentTablePanel method getViewBtn.

/**
 * Returns the view button.
 */
private JButton getViewBtn() {
    if (viewBtn == null) {
        viewBtn = new JButton(ResourceBundleHelper.getMessageString("button.View"));
        viewBtn.setEnabled(false);
        viewBtn.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                try {
                    CacheEntry cEntry = duplicateContentTable.getSelectedItem();
                    if (cEntry != null) {
                        if (!cEntry.getResponse().getContentType().contains("video")) {
                            if (cEntry.getResponse().getRawSize() < 5242880) {
                                ContentViewer.getInstance().viewContent(getSession(cEntry), cEntry.getResponse());
                            } else {
                                MessageDialogFactory.getInstance().showErrorDialog(new Window(new Frame()), ResourceBundleHelper.getMessageString("Error.fileSize"));
                            }
                        }
                    }
                } catch (Exception ioExp) {
                    MessageDialogFactory.showMessageDialog(DuplicateContentTablePanel.this.getTopLevelAncestor(), ioExp);
                }
            }

            private Session getSession(CacheEntry cEntry) {
                Session session = cEntry.getRequest().getSession();
                if (session == null) {
                    session = cEntry.getSession();
                }
                return session;
            }
        });
    }
    return viewBtn;
}
Also used : Window(java.awt.Window) Frame(java.awt.Frame) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) CacheEntry(com.att.aro.core.packetanalysis.pojo.CacheEntry) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 99 with Session

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

the class OverviewTabTableSplitPane method getExpandedDomainContentTable.

/**
 * Initializes and returns the RequestResponseTable.
 */
public JTable getExpandedDomainContentTable() {
    if (expandedDataTable == null) {
        expandedDataTable = new DataTable<Session>(expandedDomainModel);
        expandedDataTable.setName(ResourceBundleHelper.getMessageString("overview.domain.tcp.sessions.tableName"));
        expandedDataTable.setAutoCreateRowSorter(true);
        expandedDataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        expandedDataTable.setGridColor(Color.LIGHT_GRAY);
        expandedDataTable.addMouseListener(this);
        TableRowSorter<TableModel> sorter = new TableRowSorter<>(expandedDomainModel);
        expandedDataTable.setRowSorter(sorter);
        sorter.setComparator(1, Util.getDomainSorter());
        DataTablePopupMenu popupMenu = (DataTablePopupMenu) expandedDataTable.getPopup();
        popupMenu.initialize();
    }
    return expandedDataTable;
}
Also used : DataTablePopupMenu(com.att.aro.ui.model.DataTablePopupMenu) AccessedDomainsTableModel(com.att.aro.ui.model.overview.AccessedDomainsTableModel) TableModel(javax.swing.table.TableModel) ExpandedDomainTableModel(com.att.aro.ui.model.overview.ExpandedDomainTableModel) TableRowSorter(javax.swing.table.TableRowSorter) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 100 with Session

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

the class VideoTrafficInferencer method inferVideoData.

public StreamingVideoData inferVideoData(AbstractTraceResult result, List<Session> sessionlist, String manifestFilePath) {
    videoRequestMap = new HashSet<>();
    nonSegmentRequestMap = new HashMap<>();
    possibleAudioRequestMap = new TreeMap<>();
    streamingVideoData = new StreamingVideoData(result.getTraceDirectory());
    boolean flag = false;
    File manifestFile;
    if (result.getTraceDirectory().equals(manifestFilePath)) {
        CSIManifestAndState csiState = csiDataHelper.readData(manifestFilePath + System.getProperty("file.separator") + "CSI");
        if (csiState.getAnalysisState().equals("Fail")) {
            return streamingVideoData;
        }
        manifestFile = csiDataHelper.generateManifestPath(manifestFilePath, csiState.getManifestFileName());
    } else {
        flag = true;
        manifestFile = new File(manifestFilePath);
    }
    byte[] fileContent;
    VideoManifest videoManifest = new VideoManifest();
    List<Track> tracks = new ArrayList<>();
    String fileExtName = FilenameUtils.getExtension(manifestFile.getPath());
    requestMap = generateRequestMap(sessionlist);
    if (manifestFile.exists() && fileExtName != null) {
        switch(fileExtName) {
            case "json":
                ObjectMapper mapper = new ObjectMapper();
                mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
                try {
                    videoManifest = mapper.readValue(manifestFile, VideoManifest.class);
                } catch (IOException ioe) {
                    LOGGER.error("Exception while parsing Manifest JSON for CSI", ioe);
                }
                break;
            case "mpd":
                try {
                    fileContent = Files.readAllBytes(manifestFile.toPath());
                    ManifestBuilderDASH manifestBuilderDASH = new ManifestBuilderDASH();
                    manifestBuilderDASH.create(requestMap.values().iterator().next(), fileContent, "blank");
                    for (ChildManifest cManifest : manifestBuilderDASH.getManifestCollection().getSegmentChildManifestListInOrder()) {
                        Track sTrack = new Track();
                        List<Integer> segmentSizes = new ArrayList<Integer>();
                        List<Double> segmentDurations = new ArrayList<Double>();
                        sTrack.setMediaType(cManifest.isVideo() ? MediaType.VIDEO : MediaType.AUDIO);
                        sTrack.setMediaBandwidth((float) cManifest.getBandwidth());
                        cManifest.getSegmentInfoTrie().values().forEach((segment) -> segmentSizes.add(segment.getSize()));
                        cManifest.getSegmentInfoTrie().values().forEach((segment) -> segmentDurations.add(segment.getDuration()));
                        sTrack.setSegmentSizes(segmentSizes);
                        sTrack.setSegmentDurations(segmentDurations);
                        tracks.add(sTrack);
                    }
                } catch (IOException ioe) {
                    LOGGER.error("Exception while parsing MPD for CSI", ioe);
                }
                videoManifest.setTracks(tracks);
            case "m3u8":
                try {
                    videoManifest = hlsManifestParseImpl.getManifest(videoManifest, manifestFile);
                } catch (Exception e) {
                    LOGGER.error(e.getMessage());
                }
                break;
            default:
                break;
        }
    }
    List<Segment> candidateList = prepareCandidates(requestMap, videoManifest);
    Map<Integer, List<Segment>> edgeDistanceMap = calculateDistancesAndPopulateAdjacencyList(candidateList, requestMap);
    TreeMap<Integer, List<Integer>> lastNodes = findShortestPath(candidateList, edgeDistanceMap);
    if (!lastNodes.isEmpty()) {
        VideoStream videoStream = new VideoStream();
        videoStream.setManifest(createManifest(FilenameUtils.getBaseName(manifestFile.getPath()), ManifestType.MASTER, ContentType.MUXED));
        streamingVideoData.addVideoStream(firstRequestTimeStamp, videoStream);
        List<Segment> solution = getLikelySequences(candidateList, edgeDistanceMap, lastNodes);
        Manifest manifest;
        if (!solution.isEmpty()) {
            for (Segment segment : solution) {
                manifest = createManifest(FilenameUtils.getBaseName(manifestFile.getPath()), ManifestType.CHILD, ContentType.VIDEO);
                ChildManifest childManifest = new ChildManifest();
                childManifest.setManifest(manifest);
                VideoEvent videoEvent = new VideoEvent(getDefaultThumbnail(), manifest, segment, requestMap.get(segment.getRequestKey()));
                videoRequestMap.add(requestMap.get(segment.getRequestKey()));
                videoEvent.setChildManifest(childManifest);
                videoStream.addVideoEvent(videoEvent);
            }
            int segmentIndex = 0;
            Track audioTrack;
            if ((audioTrack = videoManifest.getTracks().stream().filter(track -> (track.getMediaType()).equals(MediaType.AUDIO)).findFirst().get()) != null) {
                for (HttpRequestResponseInfo rrInfo : possibleAudioRequestMap.values()) {
                    if (!videoRequestMap.contains(rrInfo) && rrInfo.getTime() > videoStream.getFirstSegment().getDLTime()) {
                        Segment audioSegment = new Segment(videoManifest, videoManifest.getAudioTrack(), ++segmentIndex, audioTrack.getSegmentSizes().get(segmentIndex - 1), rrInfo.getKey(), rrInfo.getRequestCounterCSI(), -1);
                        manifest = createManifest(FilenameUtils.getBaseName(manifestFile.getPath()), ManifestType.CHILD, ContentType.AUDIO);
                        ChildManifest childManifest = new ChildManifest();
                        childManifest.setManifest(manifest);
                        VideoEvent videoEvent = new VideoEvent(getDefaultThumbnail(), manifest, audioSegment, rrInfo);
                        videoEvent.setChildManifest(childManifest);
                        videoStream.addVideoEvent(videoEvent);
                    }
                }
            }
        }
    }
    if (flag) {
        saveCSIManifestAndState(manifestFile.toString());
    }
    videoSegmentAnalyzer.process(result, streamingVideoData);
    return streamingVideoData;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) IFileManager(com.att.aro.core.fileio.IFileManager) AbstractTraceResult(com.att.aro.core.packetanalysis.pojo.AbstractTraceResult) Track(com.att.aro.core.video.pojo.Track) HLSManifestParserForCSI(com.att.aro.core.videoanalysis.csi.parsers.HLSManifestParserForCSI) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) ManifestBuilderDASH(com.att.aro.core.videoanalysis.impl.ManifestBuilderDASH) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) MediaType(com.att.aro.core.videoanalysis.pojo.MediaType) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Logger(org.apache.log4j.Logger) VideoSegmentAnalyzer(com.att.aro.core.videoanalysis.impl.VideoSegmentAnalyzer) CSIManifestAndState(com.att.aro.core.videoanalysis.csi.pojo.CSIManifestAndState) Manifest(com.att.aro.core.videoanalysis.pojo.Manifest) Map(java.util.Map) Path(java.nio.file.Path) Segment(com.att.aro.core.video.pojo.Segment) HttpDirection(com.att.aro.core.packetanalysis.pojo.HttpDirection) Files(java.nio.file.Files) Util(com.att.aro.core.util.Util) VideoManifest(com.att.aro.core.video.pojo.VideoManifest) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Set(java.util.Set) Session(com.att.aro.core.packetanalysis.pojo.Session) IOException(java.io.IOException) File(java.io.File) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) List(java.util.List) Component(org.springframework.stereotype.Component) StreamingVideoData(com.att.aro.core.videoanalysis.pojo.StreamingVideoData) TreeMap(java.util.TreeMap) Paths(java.nio.file.Paths) ContentType(com.att.aro.core.videoanalysis.pojo.Manifest.ContentType) PreferenceHandlerImpl(com.att.aro.core.preferences.impl.PreferenceHandlerImpl) ChildManifest(com.att.aro.core.videoanalysis.pojo.ChildManifest) LogManager(org.apache.log4j.LogManager) Comparator(java.util.Comparator) Collections(java.util.Collections) ManifestType(com.att.aro.core.videoanalysis.pojo.Manifest.ManifestType) FilenameUtils(org.apache.commons.io.FilenameUtils) ArrayList(java.util.ArrayList) StreamingVideoData(com.att.aro.core.videoanalysis.pojo.StreamingVideoData) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent) Segment(com.att.aro.core.video.pojo.Segment) ChildManifest(com.att.aro.core.videoanalysis.pojo.ChildManifest) ArrayList(java.util.ArrayList) List(java.util.List) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) CSIManifestAndState(com.att.aro.core.videoanalysis.csi.pojo.CSIManifestAndState) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) VideoManifest(com.att.aro.core.video.pojo.VideoManifest) IOException(java.io.IOException) Manifest(com.att.aro.core.videoanalysis.pojo.Manifest) VideoManifest(com.att.aro.core.video.pojo.VideoManifest) ChildManifest(com.att.aro.core.videoanalysis.pojo.ChildManifest) IOException(java.io.IOException) ManifestBuilderDASH(com.att.aro.core.videoanalysis.impl.ManifestBuilderDASH) File(java.io.File) Track(com.att.aro.core.video.pojo.Track)

Aggregations

Session (com.att.aro.core.packetanalysis.pojo.Session)130 ArrayList (java.util.ArrayList)86 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)74 BaseTest (com.att.aro.core.BaseTest)49 Test (org.junit.Test)49 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)32 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)31 InetAddress (java.net.InetAddress)26 HashMap (java.util.HashMap)19 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)17 HashSet (java.util.HashSet)11 TreeMap (java.util.TreeMap)11 List (java.util.List)10 Statistic (com.att.aro.core.packetanalysis.pojo.Statistic)9 File (java.io.File)9 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)8 DomainNameSystem (com.att.aro.core.packetreader.pojo.DomainNameSystem)8 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)7 HttpRequestResponseInfoWithSession (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfoWithSession)7 UDPPacket (com.att.aro.core.packetreader.pojo.UDPPacket)7