Search in sources :

Example 81 with HttpRequestResponseInfo

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

the class FileCompressionImplTest method runTest_1.

/**
 * tests for a FAIL
 */
@Test
public void runTest_1() {
    tracedata = mock(PacketAnalyzerResult.class);
    session = mock(Session.class);
    sessionlist = new ArrayList<Session>();
    sessionlist.add(session);
    req = mock(HttpRequestResponseInfo.class);
    req.setDirection(HttpDirection.REQUEST);
    List<HttpRequestResponseInfo> reqList = new ArrayList<HttpRequestResponseInfo>();
    reqList.add(req);
    Mockito.when(session.getRequestResponseInfo()).thenReturn(reqList);
    Mockito.when(session.getDomainName()).thenReturn("mock.domain.name");
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionlist);
    // HttpDirection.REQUEST
    Mockito.when(req.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(req.getObjName()).thenReturn("mock.obj.name");
    // condition 1
    Mockito.when(req.getPacketDirection()).thenReturn(PacketDirection.DOWNLINK);
    // condition 2
    Mockito.when(req.getContentLength()).thenReturn(1001024);
    // condition 3 & 4
    // "application/ecmascript" "application/json" "application/javascript" "text/javascript" "message/http"
    Mockito.when(req.getContentType()).thenReturn("message/http");
    Mockito.when(req.getContentEncoding()).thenReturn("identity");
    FileCompressionImpl = (FileCompressionImpl) context.getBean("textFileCompression");
    AbstractBestPracticeResult result = FileCompressionImpl.runTest(tracedata);
    result = FileCompressionImpl.runTest(tracedata);
    assertEquals("Sending compressed files over the network will speed delivery, and unzipping files on a device is a very low overhead operation. Ensure that all your text files are compressed while being sent over the network.", result.getAboutText());
    assertEquals("FILE_COMPRESSION", result.getBestPracticeType().toString());
    assertEquals("Text File Compression", result.getDetailTitle());
    assertEquals("File Download: Text File Compression", result.getOverviewTitle());
    assertEquals(ApplicationConfig.getInstance().getAppShortName() + " detected 100% (977KB of 977KB) of text files were sent without compression. Adding compression will speed the delivery of your content to your customers. (Note: Only files larger than 850 bytes are flagged.)", result.getResultText());
    assertEquals("FAIL", result.getResultType().toString());
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 82 with HttpRequestResponseInfo

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

the class DuplicateContentTablePanel method getJDuplicateContentTable.

/**
 * Initializes and returns the RequestResponseTable.
 */
public DataTable<CacheEntry> getJDuplicateContentTable() {
    if (duplicateContentTable == null) {
        duplicateContentTable = new DataTable<CacheEntry>(duplicateContentTableModel);
        duplicateContentTable.setName(ResourceBundleHelper.getMessageString("overview.duplicate.content.tableName"));
        duplicateContentTable.setAutoCreateRowSorter(true);
        duplicateContentTable.setGridColor(Color.LIGHT_GRAY);
        duplicateContentTable.addMouseListener(this);
        duplicateContentTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent listEvent) {
                CacheEntry entry = duplicateContentTable.getSelectedItem();
                HttpRequestResponseInfo rrInfo = entry != null ? entry.getResponse() : null;
                boolean enabled = rrInfo != null && rrInfo.getContentLength() > 0 && rrInfo.getDirection() == HttpDirection.RESPONSE && entry != null && entry.getSession() != null;
                boolean isContentTypeVideo = (rrInfo != null && rrInfo.getContentType() != null) ? rrInfo.getContentType().contains("video/") : false;
                boolean bVideo = enabled ? isContentTypeVideo : false;
                getViewBtn().setEnabled((bVideo) ? false : enabled);
                getSaveBtn().setEnabled(enabled);
            }
        });
        DataTablePopupMenu popupMenu = (DataTablePopupMenu) duplicateContentTable.getPopup();
        popupMenu.initialize();
    }
    DataTablePopupMenu popupMenu = (DataTablePopupMenu) duplicateContentTable.getPopup();
    popupMenu.initialize();
    return duplicateContentTable;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ListSelectionEvent(javax.swing.event.ListSelectionEvent) DataTablePopupMenu(com.att.aro.ui.model.DataTablePopupMenu) CacheEntry(com.att.aro.core.packetanalysis.pojo.CacheEntry) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 83 with HttpRequestResponseInfo

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

the class VideoTrafficInferencer method prepareCandidates.

private List<Segment> prepareCandidates(Map<Double, HttpRequestResponseInfo> reqMap, VideoManifest manifest) {
    List<Segment> candidateList = new ArrayList<Segment>();
    candidateList.add(new Segment(manifest, null, -1, -1, -1, -1, -1));
    for (HttpRequestResponseInfo req : reqMap.values()) {
        // Reducing 10000 bytes in the minimum to account for lost packets in the traffic file
        double minVideoSegmentSize = (req.getContentLength() - 30000) / TRANSFER_OVERHEAD_HIGH;
        double maxVideoSegmentSize = req.getContentLength() / TRANSFER_OVERHEAD_LOW;
        double minAudioRequestSize = manifest.getMedianAudioTrackSize() * TRANSFER_OVERHEAD_LOW;
        double maxAudioRequestSize = manifest.getMedianAudioTrackSize() * TRANSFER_OVERHEAD_HIGH;
        double minVideoRequestSize = (manifest.getMaxVideoSegmentIndexSize() + 30000) * TRANSFER_OVERHEAD_HIGH;
        if (minAudioRequestSize < req.getContentLength() && req.getContentLength() < maxAudioRequestSize) {
            req.setAudioPossibility(true);
            possibleAudioRequestMap.put(req.getRequestCounterCSI(), req);
        }
        if (req.getContentLength() > minVideoRequestSize) {
            req.setVideoPossibility(true);
        } else {
            nonSegmentRequestMap.put(req.getRequestCounterCSI(), req);
            continue;
        }
        if (manifest != null && manifest.getTracks() != null) {
            for (Track track : manifest.getTracks()) {
                if (track.getMediaType() == MediaType.VIDEO) {
                    int counter = 0;
                    for (int size : track.getSegmentSizes()) {
                        counter++;
                        if (minVideoSegmentSize <= size && size <= maxVideoSegmentSize) {
                            candidateList.add(new Segment(manifest, track, counter, size, req.getKey(), req.getRequestCounterCSI(), candidateList.size() - 1));
                        }
                    }
                }
            }
        }
    }
    candidateList.add(new Segment(manifest, null, -1, -1, -1, -1, candidateList.size() - 1));
    return candidateList;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) Segment(com.att.aro.core.video.pojo.Segment) Track(com.att.aro.core.video.pojo.Track)

Example 84 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo 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)

Example 85 with HttpRequestResponseInfo

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

the class GoogleAnalyticsUtil method reportMimeDataType.

public static void reportMimeDataType(AROTraceData tracedata) {
    if (tracedata.getAnalyzerResult() != null) {
        List<Session> sessionList = tracedata.getAnalyzerResult().getSessionlist();
        Map<String, Integer> dataMimeType = new HashMap<String, Integer>();
        for (Session session : sessionList) {
            for (HttpRequestResponseInfo rri : session.getRequestResponseInfo()) {
                if (rri.getContentType() == null) {
                    continue;
                }
                if (dataMimeType.containsKey(rri.getContentType())) {
                    int count = dataMimeType.get(rri.getContentType());
                    dataMimeType.put(rri.getContentType(), count + 1);
                } else {
                    dataMimeType.put(rri.getContentType(), 1);
                }
            }
        }
        for (String mimetype : dataMimeType.keySet()) {
            getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getDataMimeTypeEvent(), mimetype, String.valueOf(dataMimeType.get(mimetype)));
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HashMap(java.util.HashMap) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) Session(com.att.aro.core.packetanalysis.pojo.Session)

Aggregations

HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)108 Session (com.att.aro.core.packetanalysis.pojo.Session)74 ArrayList (java.util.ArrayList)62 BaseTest (com.att.aro.core.BaseTest)40 Test (org.junit.Test)40 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)29 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)14 IOException (java.io.IOException)10 HashMap (java.util.HashMap)10 TreeMap (java.util.TreeMap)10 File (java.io.File)9 IHttpRequestResponseHelper (com.att.aro.core.packetanalysis.IHttpRequestResponseHelper)5 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)5 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)5 URISyntaxException (java.net.URISyntaxException)5 List (java.util.List)5 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)4 RequestResponseTimeline (com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 InetAddress (java.net.InetAddress)4