Search in sources :

Example 36 with Session

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

the class VideoTrafficInferencer method generateRequestMap.

public Map<Double, HttpRequestResponseInfo> generateRequestMap(List<Session> sessionList) {
    TreeMap<Double, HttpRequestResponseInfo> requestMap = new TreeMap<>();
    int counter = 0;
    for (Session session : sessionList) {
        List<HttpRequestResponseInfo> rriList = session.getRequestResponseInfo();
        for (HttpRequestResponseInfo rrInfo : rriList) {
            if (rrInfo.getContentLength() > 0 && rrInfo.getDirection() == HttpDirection.RESPONSE) {
                rrInfo.setKey(getReqInfoKey(rrInfo.getTimeStamp(), ++counter));
                requestMap.put(rrInfo.getKey(), rrInfo);
            }
        }
    }
    counter = 0;
    for (HttpRequestResponseInfo rrInfo : requestMap.values()) {
        firstRequestTimeStamp = rrInfo.getTimeStamp();
        rrInfo.setRequestCounterCSI(counter++);
    }
    return requestMap;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) TreeMap(java.util.TreeMap) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 37 with Session

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

the class HttpsUsageImplTest method testUDPSessionNotConsidered.

@Test
public void testUDPSessionNotConsidered() {
    Session session1 = mock(Session.class);
    Session session2 = mock(Session.class);
    InetAddress ipAddr = mock(InetAddress.class);
    when(ipAddr.getHostAddress()).thenReturn("157.56.19.80");
    when(session1.isUdpOnly()).thenReturn(true);
    when(session2.getRemoteIP()).thenReturn(ipAddr);
    when(session2.getDomainName()).thenReturn("www.hotmail.com");
    TCPPacket tcpPacket1 = mock(TCPPacket.class);
    TCPPacket tcpPacket2 = mock(TCPPacket.class);
    when(tcpPacket1.containsSSLRecord()).thenReturn(false);
    when(tcpPacket2.containsSSLRecord()).thenReturn(false);
    PacketInfo packetInfo_tcp1 = mock(PacketInfo.class);
    PacketInfo packetInfo_tcp2 = mock(PacketInfo.class);
    when(packetInfo_tcp1.getPayloadLen()).thenReturn(1);
    when(packetInfo_tcp1.getPacket()).thenReturn(tcpPacket1);
    when(packetInfo_tcp2.getPayloadLen()).thenReturn(1);
    when(packetInfo_tcp2.getPacket()).thenReturn(tcpPacket2);
    List<PacketInfo> packetsInfo = new ArrayList<PacketInfo>();
    packetsInfo.add(packetInfo_tcp1);
    packetsInfo.add(packetInfo_tcp2);
    when(session2.getTcpPackets()).thenReturn(packetsInfo);
    List<Session> sessions = new ArrayList<Session>();
    sessions.add(session1);
    sessions.add(session2);
    pktAnalyzerResult.setSessionlist(sessions);
    Statistic statistic = new Statistic();
    statistic.setTotalByte(123);
    statistic.setTotalHTTPSByte(123);
    statistic.setTotalHTTPSBytesNotAnalyzed(123);
    pktAnalyzerResult.setStatistic(statistic);
    httpsUsageResult = (HttpsUsageResult) httpsUsageImpl.runTest(pktAnalyzerResult);
    httpsUsageEntries = httpsUsageResult.getResults();
    assertEquals(1, httpsUsageEntries.size());
}
Also used : Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) InetAddress(java.net.InetAddress) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 38 with Session

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

the class HttpsUsageImplTest method testIsSSLSessionsAlteration.

@Test
public void testIsSSLSessionsAlteration() {
    Session session1 = mock(Session.class);
    Session session2 = mock(Session.class);
    Session session3 = mock(Session.class);
    InetAddress ipAddrA = mock(InetAddress.class);
    InetAddress ipAddrB = mock(InetAddress.class);
    when(ipAddrA.getHostAddress()).thenReturn("157.56.19.80");
    when(ipAddrB.getHostAddress()).thenReturn("216.58.194.196");
    when(session1.getRemoteIP()).thenReturn(ipAddrA);
    when(session1.getDomainName()).thenReturn("www.gstatic.com");
    when(session2.getRemoteIP()).thenReturn(ipAddrA);
    when(session2.getDomainName()).thenReturn("ssl.gstatic.com");
    when(session3.getRemoteIP()).thenReturn(ipAddrB);
    when(session3.getDomainName()).thenReturn("www.arotest.com");
    TCPPacket tcpPacket1_1 = mock(TCPPacket.class);
    TCPPacket tcpPacket1_2 = mock(TCPPacket.class);
    TCPPacket tcpPacket2 = mock(TCPPacket.class);
    TCPPacket tcpPacket3 = mock(TCPPacket.class);
    when(tcpPacket1_1.containsSSLRecord()).thenReturn(false);
    when(tcpPacket1_2.containsSSLRecord()).thenReturn(true);
    when(tcpPacket2.containsSSLRecord()).thenReturn(false);
    when(tcpPacket3.containsSSLRecord()).thenReturn(true);
    PacketInfo packetInfo1_1 = mock(PacketInfo.class);
    PacketInfo packetInfo1_2 = mock(PacketInfo.class);
    PacketInfo packetInfo2 = mock(PacketInfo.class);
    PacketInfo packetInfo3 = mock(PacketInfo.class);
    when(packetInfo1_1.getPayloadLen()).thenReturn(1);
    when(packetInfo1_1.getPacket()).thenReturn(tcpPacket1_1);
    when(packetInfo1_2.getPayloadLen()).thenReturn(1);
    when(packetInfo1_2.getPacket()).thenReturn(tcpPacket1_2);
    when(packetInfo2.getPayloadLen()).thenReturn(1);
    when(packetInfo2.getPacket()).thenReturn(tcpPacket2);
    when(packetInfo3.getPayloadLen()).thenReturn(1);
    when(packetInfo3.getPacket()).thenReturn(tcpPacket3);
    List<PacketInfo> packetsInfo1 = new ArrayList<PacketInfo>();
    List<PacketInfo> packetsInfo2 = new ArrayList<PacketInfo>();
    List<PacketInfo> packetsInfo3 = new ArrayList<PacketInfo>();
    packetsInfo1.add(packetInfo1_1);
    packetsInfo1.add(packetInfo1_2);
    packetsInfo2.add(packetInfo2);
    packetsInfo3.add(packetInfo3);
    when(session1.getTcpPackets()).thenReturn(packetsInfo1);
    when(session2.getTcpPackets()).thenReturn(packetsInfo2);
    when(session3.getTcpPackets()).thenReturn(packetsInfo3);
    List<Session> sessions = new ArrayList<Session>();
    sessions.add(session1);
    sessions.add(session2);
    sessions.add(session3);
    pktAnalyzerResult.setSessionlist(sessions);
    Statistic statistic = new Statistic();
    statistic.setTotalByte(123);
    statistic.setTotalHTTPSByte(123);
    statistic.setTotalHTTPSBytesNotAnalyzed(123);
    pktAnalyzerResult.setStatistic(statistic);
    httpsUsageResult = (HttpsUsageResult) httpsUsageImpl.runTest(pktAnalyzerResult);
    httpsUsageEntries = httpsUsageResult.getResults();
    assertEquals(1, httpsUsageEntries.size());
    assertEquals("gstatic.com", httpsUsageEntries.get(0).getParentDomainName());
}
Also used : Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) InetAddress(java.net.InetAddress) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 39 with Session

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

the class MinificationImplTest method runTest_4.

/**
 * tests Javascript compression
 */
@Test
public void runTest_4() {
    List<Session> sessionlist;
    Session session_1;
    HttpRequestResponseInfo req_1;
    HttpRequestResponseInfo rr_2;
    session_1 = mock(Session.class);
    sessionlist = new ArrayList<Session>();
    sessionlist.add(session_1);
    req_1 = mock(HttpRequestResponseInfo.class);
    rr_2 = mock(HttpRequestResponseInfo.class);
    List<HttpRequestResponseInfo> reqList_1 = new ArrayList<HttpRequestResponseInfo>();
    reqList_1.add(req_1);
    reqList_1.add(rr_2);
    Mockito.when((TraceDirectoryResult) tracedata.getTraceresult()).thenReturn(dirdata);
    Mockito.when(dirdata.getTraceResultType()).thenReturn(TraceResultType.TRACE_DIRECTORY);
    Mockito.when(session_1.getRequestResponseInfo()).thenReturn(reqList_1);
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionlist);
    Mockito.when(req_1.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(req_1.getContentLength()).thenReturn(5);
    MinificationImpl = (MinificationImpl) context.getBean("minify");
    Mockito.when(rr_2.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(req_1.getContentType()).thenReturn("text/javascript");
    Mockito.when(rr_2.getAssocReqResp()).thenReturn(req_1);
    Mockito.when(rr_2.getContentLength()).thenReturn(5);
    Mockito.when(req_1.getAssocReqResp()).thenReturn(rr_2);
    Mockito.when(rr_2.getObjName()).thenReturn("/images/travel_buying_guide1.jpg");
    IHttpRequestResponseHelper reqhelper = mock(IHttpRequestResponseHelper.class);
    MinificationImpl.setHttpRequestResponseHelper(reqhelper);
    try {
        String aSession = "" + "/*! jQuery v1.7.1 jquery.com | jquery.org/license */" + "" + "(function(a, b) {\r\n	function myFunction(p1, p2) {\r\n	    return p1 * p2;\r\n	}\r\n})(window);" + "";
        Mockito.when(reqhelper.isJavaScript("text/javascript")).thenReturn(true);
        Mockito.when(reqhelper.isCss("text/css")).thenReturn(false);
        Mockito.when(reqhelper.getContentString(rr_2, session_1)).thenReturn(aSession);
        Mockito.when(reqhelper.getContentString(req_1, session_1)).thenReturn(aSession);
        Mockito.when(req_1.getObjName()).thenReturn("/en/top100-css-websites.html");
        Mockito.when(session_1.getDomainName()).thenReturn("www.google.com");
    } catch (Exception e) {
        e.printStackTrace();
    }
    result = MinificationImpl.runTest(tracedata);
    assertEquals("Many text files contain excess whitespace to allow for better human coding. Run these files through a minifier to remove the whitespace in order to reduce file size.", result.getAboutText());
    assertEquals("Minify CSS, JS and HTML", result.getDetailTitle());
    assertEquals("File Download: Minify CSS, JS and HTML", result.getOverviewTitle());
    assertEquals("MINIFICATION", result.getBestPracticeType().toString());
    assertEquals("FAIL", result.getResultType().toString());
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) Session(com.att.aro.core.packetanalysis.pojo.Session) IHttpRequestResponseHelper(com.att.aro.core.packetanalysis.IHttpRequestResponseHelper) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 40 with Session

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

the class MinificationImplTest method runTest_2.

/**
 * tests html compression
 */
@Test
public void runTest_2() {
    List<Session> sessionlist;
    Session session_1;
    HttpRequestResponseInfo req_1;
    HttpRequestResponseInfo rr_2;
    // Session session_2;
    session_1 = mock(Session.class);
    // session_2 = mock(Session.class);
    sessionlist = new ArrayList<Session>();
    sessionlist.add(session_1);
    // sessionlist.add(session_2);
    req_1 = mock(HttpRequestResponseInfo.class);
    rr_2 = mock(HttpRequestResponseInfo.class);
    List<HttpRequestResponseInfo> reqList_1 = new ArrayList<HttpRequestResponseInfo>();
    reqList_1.add(req_1);
    reqList_1.add(rr_2);
    Mockito.when((TraceDirectoryResult) tracedata.getTraceresult()).thenReturn(dirdata);
    Mockito.when(dirdata.getTraceResultType()).thenReturn(TraceResultType.TRACE_DIRECTORY);
    Mockito.when(session_1.getRequestResponseInfo()).thenReturn(reqList_1);
    // Mockito.when(session_2.getRequestResponseInfo()).thenReturn(reqList_2);
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionlist);
    Mockito.when(req_1.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(req_1.getContentLength()).thenReturn(5);
    // Mockito.when(req_1.getContentType()).thenReturn("text/javascript");
    MinificationImpl = (MinificationImpl) context.getBean("minify");
    Mockito.when(rr_2.getDirection()).thenReturn(HttpDirection.RESPONSE);
    // "application/ecmascript"
    Mockito.when(rr_2.getContentType()).thenReturn("text/html");
    // "application/json"
    // "application/javascript"
    // "text/javascript"
    // "message/http"
    Mockito.when(rr_2.getAssocReqResp()).thenReturn(req_1);
    Mockito.when(rr_2.getContentLength()).thenReturn(5);
    Mockito.when(req_1.getAssocReqResp()).thenReturn(rr_2);
    Mockito.when(rr_2.getObjName()).thenReturn("/images/travel_buying_guide1.jpg");
    IHttpRequestResponseHelper reqhelper = mock(IHttpRequestResponseHelper.class);
    MinificationImpl.setHttpRequestResponseHelper(reqhelper);
    try {
        String aSession = "GET /b?s=792600146&_R=&_L=m%06refresh-announcement%01l%06refresh-banner-dismiss%02refresh-banner-line1%02refresh-banner-line1%02refresh-banner-whats-new-cta%08m%06global-nav%01l%06Logo-main%02Signup-main%02Explore-main%02Explore-recent_photos%02Explore-the_commons%02Explore-getty_collection%02Explore-galleries%02Explore-world_map%02Explore-app_garden%02Explore-camera_finder%02Explore-flickr_blog%02Upload-main%02Account-sign_in%08m%06photo-container%01l%06action-menu-click%02%23%02%23comments%02share-menu-click%02prev_button%02lightbox%02next_button%08m%06comments%01l%06%2Fphotos%2F%2F%02%2Fhtml.gne%3Ftighten%3D0%26type%3Dcomment&t=1370377426&_P=2.9.4%05A_pn%03%2Fphoto.gne%04A_sid%03QhIPpAes0Fti%04_w%03www.flickr.com%2Fphotos%2F92457242%40N04%2F8404052962%2F%04A_%031 HTTP/1.1\r\nHost: geo.yahoo.com\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/536.29.13 (KHTML, like Gecko) Version/6.0.4 Safari/536.29.13\r\nAccept: */*\r\nReferer: http://www.flickr.com/photos/92457242@N04/8404052962/\r\nAccept" + "-Language: en-us\r\nAccept-Encoding: gzip, deflate\r\nCookie: ucs=bnas=0; B=actnnip8iv3a6&b=3&s=4l\r\nConnection: keep-alive\r\n\r\n" + "                                                                                                                                                                               " + "HTTP/1.1 200 OK\r\nDate: Tue, 04 Jun 2013 20:23:44 GMT\r\nP3P: policyref=\"http://info.yahoo.com/w3c/p3p.xml\", CP=\"CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV\"\r\nCache-Control: no-cache, no-store, private\r\nPragma: no-cache\r\nContent-Length: 43\r\nConnection: close\r\nContent-Type: image/gif\r\n\r\nGIF89a��������!��,D;";
        Mockito.when(reqhelper.isJavaScript("text/html")).thenReturn(false);
        Mockito.when(reqhelper.isHtml("text/html")).thenReturn(true);
        Mockito.when(reqhelper.getContentString(rr_2, session_1)).thenReturn(aSession);
        Mockito.when(reqhelper.getContentString(req_1, session_1)).thenReturn(aSession);
        Mockito.when(req_1.getObjName()).thenReturn("/en/top100-css-websites.html");
        Mockito.when(session_1.getDomainName()).thenReturn("www.google.com");
    } catch (Exception e) {
        e.printStackTrace();
    }
    result = MinificationImpl.runTest(tracedata);
    assertEquals("Many text files contain excess whitespace to allow for better human coding. Run these files through a minifier to remove the whitespace in order to reduce file size.", result.getAboutText());
    assertEquals("Minify CSS, JS and HTML", result.getDetailTitle());
    assertEquals("File Download: Minify CSS, JS and HTML", result.getOverviewTitle());
    assertEquals("MINIFICATION", result.getBestPracticeType().toString());
    assertEquals("FAIL", result.getResultType().toString());
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) Session(com.att.aro.core.packetanalysis.pojo.Session) IHttpRequestResponseHelper(com.att.aro.core.packetanalysis.IHttpRequestResponseHelper) 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