Search in sources :

Example 6 with Session

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

the class SessionManagerImpl method readFileAndPopulateRequestResponse.

private ArrayList<HttpRequestResponseInfo> readFileAndPopulateRequestResponse(Session session, ArrayList<HttpRequestResponseInfo> results, String filePath, PacketDirection packetDirection, HttpDirection httpDirection) throws IOException {
    String dataRead;
    long timeStamp = 0;
    HttpRequestResponseInfo rrInfo = null;
    int requestCount = 0;
    TreeMap<Double, PacketInfo> packetMap;
    BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath));
    Map<Double, PacketInfo> usedPackets = new HashMap<>();
    if (packetDirection == PacketDirection.UPLINK) {
        packetMap = new TreeMap<>(session.getAllPackets().stream().filter(packetInfo -> packetInfo.getDir().equals(PacketDirection.UPLINK)).collect(Collectors.toMap(PacketInfo::getTimeStamp, Function.identity(), (existing, replacement) -> existing)));
    } else {
        packetMap = new TreeMap<>(session.getAllPackets().stream().filter(packetInfo -> packetInfo.getDir().equals(PacketDirection.DOWNLINK)).collect(Collectors.toMap(PacketInfo::getTimeStamp, Function.identity(), (existing, replacement) -> existing)));
    }
    try {
        while ((dataRead = bufferedReader.readLine()) != null) {
            if (dataRead.length() > 0) {
                String comparisonString = "RequestTime: ";
                if (dataRead.startsWith(comparisonString)) {
                    ++requestCount;
                    timeStamp = Long.parseLong(dataRead.substring(comparisonString.length(), dataRead.length()));
                    continue;
                }
                rrInfo = initializeRequestResponseObject(dataRead, session, packetDirection);
                if (rrInfo != null) {
                    rrInfo.setTCP(true);
                    rrInfo.setRawSize(-1);
                    // Converting the System Time in Millis to Seconds and Microsecond format.
                    double time = ((double) timeStamp / 1000) + (((double) timeStamp % 1000) / 1000000.0);
                    // The math below allows the request time to have a start time relative to trace capture.
                    rrInfo.setTime(time - pcapTimeOffset);
                    // TODO: Will Review this after ARO22945-1645
                    if (packetMap.containsKey(rrInfo.getTime()) && !usedPackets.containsKey(rrInfo.getTime())) {
                        rrInfo.setFirstDataPacket(packetMap.get(rrInfo.getTime()));
                        usedPackets.put(rrInfo.getTime(), packetMap.get(rrInfo.getTime()));
                    } else {
                        Map.Entry<Double, PacketInfo> lowKey = packetMap.floorEntry(rrInfo.getTime());
                        Map.Entry<Double, PacketInfo> highKey = packetMap.ceilingEntry(rrInfo.getTime());
                        if (lowKey != null) {
                            setFirstAndLastDataPacket(results, usedPackets, rrInfo, packetMap, lowKey);
                        } else if (highKey != null) {
                            setFirstAndLastDataPacket(results, usedPackets, rrInfo, packetMap, highKey);
                        }
                    }
                    rrInfo.writeHeader(dataRead);
                    while ((dataRead = bufferedReader.readLine()) != null && dataRead.length() != 0) {
                        rrInfo.writeHeader(System.lineSeparator());
                        rrInfo.writeHeader(dataRead);
                        parseHeaderLine.parseHeaderLine(dataRead, rrInfo);
                    }
                    rrInfo.writeHeader(System.lineSeparator());
                    // Check for payload and read
                    File file = new File(filePath + "_" + requestCount);
                    if (file.exists()) {
                        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
                        rrInfo.writePayload(bis);
                        bis.close();
                    }
                    results.add(rrInfo);
                }
            }
        }
    } finally {
        bufferedReader.close();
    }
    return results;
}
Also used : UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) StringUtils(org.apache.commons.lang.StringUtils) BufferedInputStream(java.io.BufferedInputStream) IParseHeaderLine(com.att.aro.core.packetanalysis.IParseHeaderLine) ByteArrayOutputStream(java.io.ByteArrayOutputStream) URISyntaxException(java.net.URISyntaxException) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) HttpPattern(com.att.aro.core.packetanalysis.pojo.HttpPattern) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) Function(java.util.function.Function) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) RequestResponseTimeline(com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline) BufferedOutputStream(java.io.BufferedOutputStream) ArrayList(java.util.ArrayList) InetAddress(java.net.InetAddress) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Logger(org.apache.log4j.Logger) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) DomainNameSystem(com.att.aro.core.packetreader.pojo.DomainNameSystem) Matcher(java.util.regex.Matcher) Packet(com.att.aro.core.packetreader.pojo.Packet) Map(java.util.Map) URI(java.net.URI) TcpInfo(com.att.aro.core.packetanalysis.pojo.TcpInfo) HttpDirection(com.att.aro.core.packetanalysis.pojo.HttpDirection) Util(com.att.aro.core.util.Util) Set(java.util.Set) Session(com.att.aro.core.packetanalysis.pojo.Session) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) Collectors(java.util.stream.Collectors) File(java.io.File) ISessionManager(com.att.aro.core.packetanalysis.ISessionManager) IByteArrayLineReader(com.att.aro.core.packetanalysis.IByteArrayLineReader) List(java.util.List) TreeMap(java.util.TreeMap) Entry(java.util.Map.Entry) Termination(com.att.aro.core.packetanalysis.pojo.Termination) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) LogManager(org.apache.log4j.LogManager) PacketDirection(com.att.aro.core.packetreader.pojo.PacketDirection) Collections(java.util.Collections) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) FileInputStream(java.io.FileInputStream) BufferedInputStream(java.io.BufferedInputStream) BufferedReader(java.io.BufferedReader) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) FileReader(java.io.FileReader) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) File(java.io.File)

Example 7 with Session

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

the class CacheAnalysisImpl method analyze.

@Override
public CacheAnalysis analyze(List<Session> sessionlist) {
    long analysisStartTime = System.currentTimeMillis();
    CacheAnalysis result = new CacheAnalysis();
    long totalRequestResponseBytes = 0;
    long totalRequestResponseDupBytes = 0;
    double duplicateContentBytesRatio = 0.0;
    Map<String, CacheEntry> cacheEntries = new HashMap<String, CacheEntry>();
    Map<String, CacheEntry> dupEntries = new HashMap<String, CacheEntry>();
    Map<String, SortedSet<Range>> rangeEntries = new HashMap<String, SortedSet<Range>>();
    List<CacheEntry> diagnosisResults = new ArrayList<CacheEntry>();
    List<CacheEntry> duplicateContent = new ArrayList<CacheEntry>();
    List<CacheEntry> duplicateContentWithOriginals = new ArrayList<CacheEntry>();
    Map<CacheExpiration, List<CacheEntry>> cacheExpirationResponses = result.getCacheExpirationResponses();
    duplicateEntries = new ArrayList<DuplicateEntry>();
    // Initialize cache expiration lists
    for (CacheExpiration expiration : CacheExpiration.values()) {
        cacheExpirationResponses.put(expiration, new ArrayList<CacheEntry>());
    }
    // Build a sorted list of all of the HTTP request/response in the trace
    List<HttpRequestResponseInfoWithSession> rrInfo = new ArrayList<HttpRequestResponseInfoWithSession>();
    for (Session session : sessionlist) {
        if (!session.isUdpOnly()) {
            // rrInfo.addAll(session.getRequestResponseInfo());
            for (HttpRequestResponseInfo item : session.getRequestResponseInfo()) {
                HttpRequestResponseInfoWithSession itemsession = new HttpRequestResponseInfoWithSession();
                itemsession.setInfo(item);
                itemsession.setSession(session);
                rrInfo.add(itemsession);
            }
        }
    }
    Collections.sort(rrInfo);
    // Iterate through responses looking for duplicates
    for (HttpRequestResponseInfoWithSession httpreqres : rrInfo) {
        HttpRequestResponseInfo response = httpreqres.getInfo();
        Session session = httpreqres.getSession();
        PacketInfo firstPacket = session.getTcpPackets().get(0);
        if (response.getDirection() == HttpDirection.REQUEST) {
            // We only want to process responses
            continue;
        }
        // Check whether response is valid
        int statusCode = response.getStatusCode();
        if (statusCode == 0) {
            diagnosisResults.add(new CacheEntry(null, response, Diagnosis.CACHING_DIAG_INVALID_RESPONSE, 0, firstPacket));
            continue;
        }
        if (statusCode != 200 && statusCode != 206) {
            diagnosisResults.add(new CacheEntry(null, response, Diagnosis.CACHING_DIAG_INVALID_REQUEST, 0, firstPacket));
            continue;
        }
        // [A] Find corresponding request
        HttpRequestResponseInfo request = response.getAssocReqResp();
        if (request == null) {
            diagnosisResults.add(new CacheEntry(request, response, Diagnosis.CACHING_DIAG_REQUEST_NOT_FOUND, 0, firstPacket));
            continue;
        }
        totalRequestResponseBytes += response.getContentLength();
        // Request must by GET, POST, or PUT
        String requestType = request.getRequestType();
        if (!HttpRequestResponseInfo.HTTP_GET.equals(requestType) && !HttpRequestResponseInfo.HTTP_PUT.equals(requestType) && !HttpRequestResponseInfo.HTTP_POST.equals(requestType)) {
            diagnosisResults.add(new CacheEntry(request, response, Diagnosis.CACHING_DIAG_INVALID_REQUEST, 0, firstPacket));
            continue;
        }
        // Check for valid object name and host name
        if (request.getHostName() == null || request.getObjName() == null) {
            diagnosisResults.add(new CacheEntry(request, response, Diagnosis.CACHING_DIAG_INVALID_OBJ_NAME, 0, firstPacket));
            continue;
        }
        // [B] Object cacheable?
        if (response.isNoStore() || request.isNoStore() || HttpRequestResponseInfo.HTTP_POST.equals(requestType) || HttpRequestResponseInfo.HTTP_PUT.equals(requestType)) {
            cacheEntries.remove(getObjFullName(request, response));
            dupEntries.remove(getObjDuplicateName(request, response));
            diagnosisResults.add(new CacheEntry(request, response, Diagnosis.CACHING_DIAG_NOT_CACHABLE, 0, firstPacket));
            continue;
        }
        // [C] Does it hit the cache?
        CacheEntry cacheEntry = cacheEntries.get(getObjFullName(request, response));
        CacheEntry cacheDuplicateEntry = dupEntries.get(getObjDuplicateName(request, response));
        CacheEntry newCacheEntry;
        if (cacheEntry == null) {
            Diagnosis diagnosis = Diagnosis.CACHING_DIAG_CACHE_MISSED;
            newCacheEntry = new CacheEntry(request, response, diagnosis, firstPacket);
            newCacheEntry.setSession(session);
            addToCache(newCacheEntry, rangeEntries, cacheEntries, dupEntries, session);
            newCacheEntry.setCacheCount(1);
            diagnosisResults.add(newCacheEntry);
            if (cacheDuplicateEntry != null) {
                diagnosis = Diagnosis.CACHING_DIAG_ETAG_DUPLICATE;
            }
            duplicateEntries.add(new DuplicateEntry(request, response, diagnosis, firstPacket, session, getContent(response, session)));
            continue;
        } else {
            int oldCount = cacheEntry.getCacheCount();
            cacheEntry.setCacheCount(oldCount + 1);
        }
        CacheExpiration expStatus = cacheExpired(cacheEntry, request.getAbsTimeStamp());
        SortedSet<Range> ranges = rangeEntries.get(getObjFullName(cacheEntry.getRequest(), cacheEntry.getResponse()));
        boolean isfullcachehit = isFullCacheHit(response, ranges);
        if (isfullcachehit) {
            // [D] Is it expired?
            switch(expStatus) {
                case CACHE_EXPIRED:
                case CACHE_EXPIRED_HEURISTIC:
                    newCacheEntry = handleCacheExpired(session, response, request, firstPacket, cacheEntry);
                    diagnosisResults.add(newCacheEntry);
                    break;
                case CACHE_NOT_EXPIRED:
                case CACHE_NOT_EXPIRED_HEURISTIC:
                    newCacheEntry = new CacheEntry(request, response, Diagnosis.CACHING_DIAG_NOT_EXPIRED_DUP, firstPacket);
                    duplicateEntries.add(new DuplicateEntry(request, response, Diagnosis.CACHING_DIAG_NOT_EXPIRED_DUP, firstPacket, session, getContent(response, session)));
                    diagnosisResults.add(newCacheEntry);
                    break;
                default:
                    // Should not occur
                    newCacheEntry = null;
            }
        } else {
            long bytesInCache = getBytesInCache(response, ranges);
            // [D] Is it expired?
            switch(expStatus) {
                case CACHE_EXPIRED:
                case CACHE_EXPIRED_HEURISTIC:
                    newCacheEntry = handleCacheExpiredWithByteInCache(session, response, request, firstPacket, cacheEntry, bytesInCache);
                    diagnosisResults.add(newCacheEntry);
                    break;
                case CACHE_NOT_EXPIRED:
                case CACHE_NOT_EXPIRED_HEURISTIC:
                    newCacheEntry = new CacheEntry(request, response, Diagnosis.CACHING_DIAG_NOT_EXPIRED_DUP_PARTIALHIT, bytesInCache, firstPacket);
                    duplicateEntries.add(new DuplicateEntry(request, response, Diagnosis.CACHING_DIAG_NOT_EXPIRED_DUP, firstPacket, session, getContent(response, session)));
                    diagnosisResults.add(newCacheEntry);
                    break;
                default:
                    // Should not occur
                    newCacheEntry = null;
            }
        }
        cacheExpirationResponses.get(expStatus).add(newCacheEntry);
        if (newCacheEntry != null) {
            newCacheEntry.setCacheHit(cacheEntry);
        }
    // addToCache(newCacheEntry);
    }
    // END: Iterate through responses looking for duplicates
    // Get cache problems
    Set<CacheEntry> dupsWithOrig = new HashSet<CacheEntry>();
    Map<String, DuplicateEntry> duplicateEntriesMap = new HashMap<String, DuplicateEntry>();
    CacheEntry cache;
    for (DuplicateEntry dupEntry : duplicateEntries) {
        if (dupEntry.getContentLength() > 0) {
            String key = dupEntry.getRequest().getHostName() + dupEntry.getHttpObjectName() + dupEntry.getContentLength();
            if (dupEntry.getHttpObjectName() != null) {
                if (!duplicateEntriesMap.containsKey(key)) {
                    dupEntry.setCount(1);
                    duplicateEntriesMap.put(key, dupEntry);
                } else {
                    if (Arrays.equals(duplicateEntriesMap.get(key).getContent(), dupEntry.getContent())) {
                        int count = duplicateEntriesMap.get(key).getCount();
                        if (count == 1) {
                            cache = new CacheEntry(duplicateEntriesMap.get(key).getRequest(), duplicateEntriesMap.get(key).getResponse(), duplicateEntriesMap.get(key).getDiagnosis(), duplicateEntriesMap.get(key).getSessionFirstPacket());
                            cache.setSession(dupEntry.getSession());
                            dupsWithOrig.add(cache);
                        }
                        cache = new CacheEntry(dupEntry.getRequest(), dupEntry.getResponse(), dupEntry.getDiagnosis(), dupEntry.getSessionFirstPacket());
                        dupsWithOrig.add(cache);
                        dupEntry = new DuplicateEntry(dupEntry.getRequest(), dupEntry.getResponse(), dupEntry.getDiagnosis(), dupEntry.getSessionFirstPacket(), dupEntry.getSession(), dupEntry.getContent());
                        dupEntry.setCount(count + 1);
                        duplicateEntriesMap.replace(key, dupEntry);
                    }
                }
            }
        }
    }
    for (Entry<String, DuplicateEntry> cacheEntry2 : duplicateEntriesMap.entrySet()) {
        if (cacheEntry2.getValue().getCount() > 1) {
            int count = cacheEntry2.getValue().getCount();
            cache = new CacheEntry(cacheEntry2.getValue().getRequest(), cacheEntry2.getValue().getResponse(), cacheEntry2.getValue().getDiagnosis(), cacheEntry2.getValue().getSessionFirstPacket());
            cache.setHitCount(count);
            if (count > 2) {
                totalRequestResponseDupBytes += (cacheEntry2.getValue().getHttpRequestResponse().getContentLength() * (count - 1));
            } else {
                totalRequestResponseDupBytes += cacheEntry2.getValue().getHttpRequestResponse().getContentLength();
            }
            duplicateContent.add(cache);
        }
    }
    duplicateContentWithOriginals.addAll(dupsWithOrig);
    Collections.sort(duplicateContentWithOriginals);
    duplicateContentBytesRatio = totalRequestResponseBytes != 0 ? (double) totalRequestResponseDupBytes / totalRequestResponseBytes : 0.0;
    result.setCacheExpirationResponses(cacheExpirationResponses);
    result.setDiagnosisResults(diagnosisResults);
    result.setDuplicateContent(duplicateContent);
    result.setDuplicateContentBytesRatio(duplicateContentBytesRatio);
    result.setDuplicateContentWithOriginals(duplicateContentWithOriginals);
    result.setTotalRequestResponseBytes(totalRequestResponseBytes);
    result.setTotalRequestResponseDupBytes(totalRequestResponseDupBytes);
    GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsTimings(cacheAnalysisTitle, System.currentTimeMillis() - analysisStartTime, analysisCategory);
    return result;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SortedSet(java.util.SortedSet) DuplicateEntry(com.att.aro.core.packetanalysis.pojo.DuplicateEntry) ArrayList(java.util.ArrayList) List(java.util.List) Diagnosis(com.att.aro.core.packetanalysis.pojo.Diagnosis) CacheExpiration(com.att.aro.core.packetanalysis.pojo.CacheExpiration) HashSet(java.util.HashSet) HttpRequestResponseInfoWithSession(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfoWithSession) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) CacheEntry(com.att.aro.core.packetanalysis.pojo.CacheEntry) Range(com.att.aro.core.packetanalysis.pojo.Range) CacheAnalysis(com.att.aro.core.packetanalysis.pojo.CacheAnalysis) ICacheAnalysis(com.att.aro.core.packetanalysis.ICacheAnalysis) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) HttpRequestResponseInfoWithSession(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfoWithSession) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 8 with Session

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

the class ImageExtractor method scanAndExtractImages.

public void scanAndExtractImages(List<Session> sessionlist) {
    if (fileManager.directoryExistAndNotEmpty(imagePath)) {
        return;
    }
    for (Session session : sessionlist) {
        for (HttpRequestResponseInfo reqResp : session.getRequestResponseInfo()) {
            if (reqResp.getDirection() == HttpDirection.RESPONSE && reqResp.getContentType() != null && reqResp.getContentType().contains("image/")) {
                HttpRequestResponseInfo req = reqResp.getAssocReqResp();
                if (req == null) {
                    LOGGER.error(String.format("BROKEN req/resp link @ %s", reqResp.getAllHeaders()));
                    continue;
                }
                if (req.getObjName() == null || reqResp.getAssocReqResp() == null) {
                    LOGGER.error("Probable Request/Response linkage problem with " + req + ", " + reqResp);
                    continue;
                }
                String imageObject = reqResp.getAssocReqResp().getObjName();
                if (imageObject != null && reqResp.getContentType() != null) {
                    if (imageObject.indexOf("?v=") >= 0) {
                        String fullName = Util.extractFullNameFromLink(imageObject);
                        String extension = "." + reqResp.getContentType().substring(reqResp.getContentType().indexOf("image/") + 6, reqResp.getContentType().length());
                        extractImage(session, reqResp, fullName + extension);
                    }
                }
            }
        }
    }
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 9 with Session

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

the class VideoResultSummary method populateSummary.

private void populateSummary(AROTraceData trace) {
    for (AbstractBestPracticeResult bpResult : trace.getBestPracticeResults()) {
        if (bpResult.getClass().getName().contains("AROServiceImpl")) {
            continue;
        }
        BestPracticeType bpType = bpResult.getBestPracticeType();
        switch(bpType) {
            case VIDEO_STALL:
                VideoStallResult result = (VideoStallResult) bpResult;
                stalls = result.getStallResult();
                break;
            case NETWORK_COMPARISON:
                VideoNetworkComparisonResult ntkResult = (VideoNetworkComparisonResult) bpResult;
                ntkComparison = ntkResult.getAvgKbps();
                break;
            case TCP_CONNECTION:
                VideoTcpConnectionResult tcpResult = (VideoTcpConnectionResult) bpResult;
                tcpConnection = tcpResult.getTcpConnections();
                break;
            case BUFFER_OCCUPANCY:
                BufferOccupancyResult bufferResult = (BufferOccupancyResult) bpResult;
                bufferOccupancy = bufferResult.getMaxBuffer();
                populateBufferResult(bufferResult);
                break;
            case CHUNK_SIZE:
                VideoChunkSizeResult segmentSizeResult = (VideoChunkSizeResult) bpResult;
                segmentSize = segmentSizeResult.getSegmentSize();
                segmentCount = segmentSizeResult.getSegmentCount();
                break;
            case CHUNK_PACING:
                VideoChunkPacingResult segmentPacingResult = (VideoChunkPacingResult) bpResult;
                segmentPacing = segmentPacingResult.getChunkPacing();
                break;
            case VIDEO_REDUNDANCY:
                VideoRedundancyResult redundancyResult = (VideoRedundancyResult) bpResult;
                duplicate = redundancyResult.getCountDuplicate();
                redundancy = redundancyResult.getRedundantPercentage();
                break;
            case STARTUP_DELAY:
                VideoStartUpDelayResult startupDelayResult = (VideoStartUpDelayResult) bpResult;
                startUpDelay = startupDelayResult.getStartUpDelay();
                break;
            case VIDEO_CONCURRENT_SESSION:
                VideoConcurrentSessionResult concurrentSessionResult = (VideoConcurrentSessionResult) bpResult;
                concurrentSessions = concurrentSessionResult.getMaxConcurrentSessionCount();
                break;
            default:
                break;
        }
    }
    List<Session> allSessions = trace.getAnalyzerResult().getSessionlist();
    Map<InetAddress, List<Session>> ipSessionsMap = new HashMap<InetAddress, List<Session>>();
    for (Session session : allSessions) {
        InetAddress ipAddress = session.getRemoteIP();
        if (ipSessionsMap.containsKey(ipAddress)) {
            ipSessionsMap.get(ipAddress).add(session);
        } else {
            List<Session> sess = new ArrayList<Session>();
            sess.add(session);
            ipSessionsMap.put(ipAddress, sess);
        }
    }
    ipAddress = ipSessionsMap.keySet().size();
    ipSessions = allSessions.size();
    StreamingVideoData streamingVideoData;
    if ((streamingVideoData = trace.getAnalyzerResult().getStreamingVideoData()) == null) {
        return;
    }
    Collection<VideoStream> selectedVideoStreams = streamingVideoData.getVideoStreams();
    movieMBytes = calculateMBytes(selectedVideoStreams, false);
    totalMBytes = calculateMBytes(selectedVideoStreams, true);
    if (trace.getAnalyzerResult().getStreamingVideoData().getStreamingVideoCompiled().getChunkPlayTimeList().isEmpty()) {
        startupDelayStatus = false;
    } else {
        startupDelayStatus = true;
    }
}
Also used : VideoRedundancyResult(com.att.aro.core.bestpractice.pojo.VideoRedundancyResult) HashMap(java.util.HashMap) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) VideoNetworkComparisonResult(com.att.aro.core.bestpractice.pojo.VideoNetworkComparisonResult) ArrayList(java.util.ArrayList) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) BestPracticeType(com.att.aro.core.bestpractice.pojo.BestPracticeType) VideoStallResult(com.att.aro.core.bestpractice.pojo.VideoStallResult) VideoConcurrentSessionResult(com.att.aro.core.bestpractice.pojo.VideoConcurrentSessionResult) StreamingVideoData(com.att.aro.core.videoanalysis.pojo.StreamingVideoData) VideoTcpConnectionResult(com.att.aro.core.bestpractice.pojo.VideoTcpConnectionResult) BufferOccupancyResult(com.att.aro.core.bestpractice.pojo.BufferOccupancyResult) ArrayList(java.util.ArrayList) List(java.util.List) VideoChunkPacingResult(com.att.aro.core.bestpractice.pojo.VideoChunkPacingResult) VideoChunkSizeResult(com.att.aro.core.bestpractice.pojo.VideoChunkSizeResult) VideoStartUpDelayResult(com.att.aro.core.bestpractice.pojo.VideoStartUpDelayResult) InetAddress(java.net.InetAddress) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 10 with Session

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

the class HttpRequestResponseHelperImplTest method getContent.

@Test
public void getContent() {
    Session session = null;
    session = mock(Session.class);
    HttpRequestResponseInfo req = null;
    req = mock(HttpRequestResponseInfo.class);
    String stringData = "this was compressed";
    byte[] data = stringData.getBytes();
    byte[] gzipped_data = null;
    try {
        ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(data.length / 2);
        GZIPOutputStream gzipOutput = new GZIPOutputStream(byteOutput);
        gzipOutput.write(data);
        gzipOutput.close();
        gzipped_data = byteOutput.toByteArray();
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    SortedMap<Integer, Integer> contentOffsetTreeMap = new TreeMap<Integer, Integer>();
    contentOffsetTreeMap.put(0, gzipped_data == null ? 0 : gzipped_data.length);
    Mockito.when(req.getContentEncoding()).thenReturn("gzip");
    Mockito.when(req.getContentOffsetLength()).thenReturn(contentOffsetTreeMap);
    Mockito.when(req.getPacketDirection()).thenReturn(PacketDirection.DOWNLINK);
    Mockito.when(session.getStorageDl()).thenReturn(gzipped_data);
    Mockito.when(session.getStorageUl()).thenReturn(gzipped_data);
    try {
        assertEquals(stringData, httpRequestResponseHelper.getContentString(req, session));
        Mockito.when(session.getStorageDl()).thenReturn(data);
    } catch (Exception e) {
        assertEquals(null, e.getMessage());
    }
    // bad gzip data
    assertNotNull(gzipped_data);
    gzipped_data[20] = 42;
    Mockito.when(session.getStorageDl()).thenReturn(gzipped_data);
    Mockito.when(session.getStorageUl()).thenReturn(gzipped_data);
    try {
        String thisWasFromCorruptedZip = httpRequestResponseHelper.getContentString(req, session);
        assertEquals("this was bwmpressed", thisWasFromCorruptedZip);
    } catch (Exception e) {
    }
}
Also used : GZIPOutputStream(java.util.zip.GZIPOutputStream) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) TreeMap(java.util.TreeMap) IOException(java.io.IOException) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

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