Monday, January 6, 2014

Browser is getting smarter!


    For performance testing professionals,  packet sniffer (like wireshark) is a good friend.  It can help us troubleshooting issues that are otherwise hard to do. For example, in an earlier blog, we showed how to use wireshark to find out whether a delay in server response is due to the network or due to server infrastructure.

   Today I want to share how packet sniffer helped me to realize that my browser has become smarter.   It all started with a surprise in seeing my Chrome browser tried to setup two TCP connections simultaneously when I tried to visit a web site.   I had expected the browser to do the following:

  • starts with only one TCP connection,
  • send HTTP request and download the main page,
  • set up more concurrent TCP connections to download other resources.

    Did some search and found this message thread which shed some light.  To paraphrase what was mentioned there,  setting up multiple TCP connections can have two-fold benefits.
  • In case one connection took longer to set up (say, due to packet drops), the other connection(s) can be used to download main HTML page.  
  • The extra TCP connection can be used to download resource files (css, js, image etc).
    While both can help with improving page loading time, the first one can help more in some cases because when a TCP SYN or SYNACK packet was dropped, the re-transmission may kick in after 3 seconds on some platforms,   making TCP setup time much longer.

    The following is a summary of the packet capture.  We filtered out the packets that are not relevant.

 Timestamp       Source IP      srcPort      Dest IP  dstPort   Protocol msg      
 0.000000000     192.168.5.105     54486     1.1.1.1     80     SYN  
 0.000230000     192.168.5.105     54487     1.1.1.1     80     SYN  
 0.066502000     1.1.1.1     80     192.168.5.105     54486     SYN, ACK  
 0.066862000     192.168.5.105     54486     1.1.1.1     80     GET / HTTP/1.1   
 0.070695000     1.1.1.1     80     192.168.5.105     54487     SYN, ACK  
 0.188546000     192.168.5.105     54488     1.1.1.1     80     SYN  
 0.189143000     192.168.5.105     54487     1.1.1.1     80     GET /css/screen.css HTTP/1.1   
 0.255478000     1.1.1.1     80     192.168.5.105     54488     SYN, ACK  
 0.255785000     192.168.5.105     54488     1.1.1.1     80     GET /css/jquery.fancybox.css HTTP/1.1   
 0.348672000     1.1.1.1     80     192.168.5.105     54486     HTTP/1.1 200 OK (text/html)  
 0.351507000     192.168.5.105     54490     1.1.1.1     80     SYN  
 0.353380000     192.168.5.105     54491     1.1.1.1     80     SYN  
 0.389387000     1.1.1.1     80     192.168.5.105     54488     HTTP/1.1 200 OK (text/css)  
 0.421846000     1.1.1.1     80     192.168.5.105     54490     SYN, ACK  
 0.422441000     192.168.5.105     54490     1.1.1.1     80     GET /js/site.js HTTP/1.1   
 0.425096000     1.1.1.1     80     192.168.5.105     54491     SYN, ACK  
 0.425724000     192.168.5.105     54491     1.1.1.1     80     GET /js/homepage.js HTTP/1.1   
 0.494837000     1.1.1.1     80     192.168.5.105     54491     HTTP/1.1 200 OK (application/x-javascript)  
 0.750929000     1.1.1.1     80     192.168.5.105     54487     HTTP/1.1 200 OK (text/css)  
 1.014032000     1.1.1.1     80     192.168.5.105     54490     HTTP/1.1 200 OK (application/x-javascript)  
 1.027851000     192.168.5.105     54496     1.1.1.1     80     SYN  
 1.027970000     192.168.5.105     54497     1.1.1.1     80     SYN  
 1.028081000     192.168.5.105     54498     1.1.1.1     80     SYN  
 1.028166000     192.168.5.105     54499     1.1.1.1     80     SYN  
 1.028249000     192.168.5.105     54500     1.1.1.1     80     SYN  
 1.048127000     192.168.5.105     54501     1.1.1.1     80     SYN  
 1.096886000     1.1.1.1     80     192.168.5.105     54496     SYN, ACK  
 1.097185000     192.168.5.105     54496     1.1.1.1     80     GET /images/oldBrowser-bg.png HTTP/1.1   
 1.098732000     1.1.1.1     80     192.168.5.105     54498     SYN, ACK  
 1.098952000     192.168.5.105     54498     1.1.1.1     80     GET /images/logo.jpg HTTP/1.1   
 1.100747000     1.1.1.1     80     192.168.5.105     54497     SYN, ACK  
 1.100963000     192.168.5.105     54497     1.1.1.1     80     GET /images/body_bg.jpg HTTP/1.1   
 1.102099000     1.1.1.1     80     192.168.5.105     54499     SYN, ACK  
 1.102248000     192.168.5.105     54499     1.1.1.1     80     GET /images/header_bg.png HTTP/1.1   
 1.104004000     1.1.1.1     80     192.168.5.105     54500     SYN, ACK  
 1.104228000     192.168.5.105     54500     1.1.1.1     80     GET /images/utility_divider.gif HTTP/1.1   
 1.118830000     1.1.1.1     80     192.168.5.105     54501     SYN, ACK  
 1.119053000     192.168.5.105     54501     1.1.1.1     80     GET /css/linux.css HTTP/1.1   
 1.165477000     1.1.1.1     80     192.168.5.105     54496     HTTP/1.1 200 OK (PNG)  
 1.166331000     192.168.5.105     54503     1.1.1.1     80     SYN  
 1.179595000     1.1.1.1     80     192.168.5.105     54500     HTTP/1.1 200 OK (GIF89a) (GIF89a) (image/gif)  
 1.180519000     192.168.5.105     54504     1.1.1.1     80     SYN  
 1.239261000     1.1.1.1     80     192.168.5.105     54498     HTTP/1.1 200 OK (JPEG JFIF image)  
 1.239636000     192.168.5.105     54505     1.1.1.1     80     SYN  
 1.249838000     1.1.1.1     80     192.168.5.105     54499     HTTP/1.1 200 OK (PNG)  
 1.250503000     192.168.5.105     54506     1.1.1.1     80     SYN  
 1.300834000     1.1.1.1     80     192.168.5.105     54501     HTTP/1.1 200 OK (text/css)  
 1.302668000     192.168.5.105     54509     1.1.1.1     80     SYN  
 1.306116000     1.1.1.1     80     192.168.5.105     54503     SYN, ACK  
 1.306922000     192.168.5.105     54503     1.1.1.1     80     GET /images/sprite/icons.png HTTP/1.1   
 1.308188000     1.1.1.1     80     192.168.5.105     54504     SYN, ACK  
 1.308516000     192.168.5.105     54504     1.1.1.1     80     GET /images/secondary_nav_arrow.png HTTP/1.1   
 1.310150000     1.1.1.1     80     192.168.5.105     54505     SYN, ACK  
 1.310330000     192.168.5.105     54505     1.1.1.1     80     GET /images/resource-nav-bdr.png HTTP/1.1   
 1.318582000     1.1.1.1     80     192.168.5.105     54506     SYN, ACK  
 1.318908000     192.168.5.105     54506     1.1.1.1     80     GET /js/trackalyze.js HTTP/1.1   
 1.371181000     1.1.1.1     80     192.168.5.105     54509     SYN, ACK  
 1.371670000     192.168.5.105     54509     1.1.1.1     80     GET /images/resources/videos/small-pen-testing-sap.jpg HTTP/1.1   
 1.378268000     1.1.1.1     80     192.168.5.105     54504     HTTP/1.1 200 OK (PNG)  
 1.380136000     192.168.5.105     54511     1.1.1.1     80     SYN  
 1.384338000     1.1.1.1     80     192.168.5.105     54505     HTTP/1.1 200 OK (JPEG JFIF image)  
 1.385775000     1.1.1.1     80     192.168.5.105     54506     HTTP/1.1 200 OK (application/x-javascript)  
 1.385953000     192.168.5.105     54512     1.1.1.1     80     SYN  
 1.387611000     192.168.5.105     54513     1.1.1.1     80     SYN  
 1.442571000     1.1.1.1     80     192.168.5.105     54509     HTTP/1.1 200 OK (JPEG JFIF image)  
 1.442854000     192.168.5.105     54516     1.1.1.1     80     SYN  
 1.451614000     1.1.1.1     80     192.168.5.105     54511     SYN, ACK  
 1.451893000     192.168.5.105     54511     1.1.1.1     80     GET /images/slider_bg.png HTTP/1.1   
 1.456305000     1.1.1.1     80     192.168.5.105     54512     SYN, ACK  
 1.456679000     192.168.5.105     54512     1.1.1.1     80     GET /images/slides/slide_1.png HTTP/1.1   
 1.460844000     1.1.1.1     80     192.168.5.105     54513     SYN, ACK  
 1.461305000     192.168.5.105     54513     1.1.1.1     80     GET /images/slides/slide_8.png HTTP/1.1   
 1.519412000     1.1.1.1     80     192.168.5.105     54516     SYN, ACK  
 1.519879000     192.168.5.105     54516     1.1.1.1     80     GET /images/slides/slide_2.png HTTP/1.1   
 1.669946000     1.1.1.1     80     192.168.5.105     54516     HTTP/1.1 200 OK (PNG)  
 1.673090000     192.168.5.105     54547     1.1.1.1     80     SYN  
 1.678979000     1.1.1.1     80     192.168.5.105     54503     HTTP/1.1 200 OK (PNG)  
 1.679257000     192.168.5.105     54549     1.1.1.1     80     SYN  
 1.695996000     1.1.1.1     80     192.168.5.105     54513     HTTP/1.1 200 OK (PNG)  
 1.696478000     192.168.5.105     54551     1.1.1.1     80     SYN  
 1.715088000     1.1.1.1     80     192.168.5.105     54497     HTTP/1.1 200 OK (JPEG JFIF image)  
 1.715935000     192.168.5.105     54552     1.1.1.1     80     SYN  
 1.741428000     1.1.1.1     80     192.168.5.105     54547     SYN, ACK  
 1.741790000     192.168.5.105     54547     1.1.1.1     80     GET /images/slides/slide_3.png HTTP/1.1   
 1.753093000     1.1.1.1     80     192.168.5.105     54549     SYN, ACK  
 1.753296000     192.168.5.105     54549     1.1.1.1     80     GET /images/slides/slide_4.png HTTP/1.1   
 1.762919000     1.1.1.1     80     192.168.5.105     54551     SYN, ACK  
 1.763151000     192.168.5.105     54551     1.1.1.1     80     GET /images/sec-nav-outer-bg.png HTTP/1.1   
 1.787654000     1.1.1.1     80     192.168.5.105     54552     SYN, ACK  
 1.787985000     192.168.5.105     54552     1.1.1.1     80     GET /images/torso_bg.jpg HTTP/1.1   
 1.798214000     1.1.1.1     80     192.168.5.105     54512     HTTP/1.1 200 OK (PNG)  
 1.798825000     192.168.5.105     54556     1.1.1.1     80     SYN  
 1.837648000     1.1.1.1     80     192.168.5.105     54551     HTTP/1.1 200 OK (PNG)  
 1.839507000     192.168.5.105     54559     1.1.1.1     80     SYN  
 1.869998000     1.1.1.1     80     192.168.5.105     54556     SYN, ACK  
 1.872545000     192.168.5.105     54556     1.1.1.1     80     GET /images/torso_bg.png HTTP/1.1   
 1.875444000     1.1.1.1     80     192.168.5.105     54547     HTTP/1.1 200 OK (PNG)  
 1.875845000     192.168.5.105     54560     1.1.1.1     80     SYN  
 1.927286000     1.1.1.1     80     192.168.5.105     54549     HTTP/1.1 200 OK (PNG)  
 1.928296000     1.1.1.1     80     192.168.5.105     54559     SYN, ACK  
 1.928822000     192.168.5.105     54559     1.1.1.1     80     GET /images/home/nexpose.png HTTP/1.1   
 1.929061000     192.168.5.105     54561     1.1.1.1     80     SYN  
 1.944633000     1.1.1.1     80     192.168.5.105     54560     SYN, ACK  
 1.945062000     192.168.5.105     54560     1.1.1.1     80     GET /images/blue_button_bg.gif HTTP/1.1   
 2.004818000     1.1.1.1     80     192.168.5.105     54559     HTTP/1.1 200 OK (PNG)  
 2.007275000     192.168.5.105     54562     1.1.1.1     80     SYN  
 2.008405000     1.1.1.1     80     192.168.5.105     54561     SYN, ACK  
 2.009310000     192.168.5.105     54561     1.1.1.1     80     GET /images/forward-separator.png HTTP/1.1   
 2.010527000     1.1.1.1     80     192.168.5.105     54552     HTTP/1.1 200 OK (JPEG JFIF image)  
 2.017098000     1.1.1.1     80     192.168.5.105     54556     HTTP/1.1 200 OK (PNG)  
 2.018256000     192.168.5.105     54563     1.1.1.1     80     SYN  
 2.019943000     1.1.1.1     80     192.168.5.105     54560     HTTP/1.1 200 OK (GIF89a) (GIF89a) (image/gif)  
 2.021165000     192.168.5.105     54564     1.1.1.1     80     SYN  
 2.023154000     192.168.5.105     54565     1.1.1.1     80     SYN  
 2.049434000     1.1.1.1     80     192.168.5.105     54511     HTTP/1.1 200 OK (PNG)  
 2.051055000     192.168.5.105     54566     1.1.1.1     80     SYN  
 2.079561000     1.1.1.1     80     192.168.5.105     54562     SYN, ACK  
 2.079953000     192.168.5.105     54562     1.1.1.1     80     GET /images/home/metasploit.png HTTP/1.1   
 2.082981000     1.1.1.1     80     192.168.5.105     54563     SYN, ACK  
 2.085419000     1.1.1.1     80     192.168.5.105     54561     HTTP/1.1 200 OK (PNG)  
 2.089268000     1.1.1.1     80     192.168.5.105     54564     SYN, ACK  
 2.091658000     192.168.5.105     54563     1.1.1.1     80     GET /images/home/control-insight-logo.png HTTP/1.1   
 2.091795000     192.168.5.105     54564     1.1.1.1     80     GET /images/home/risk-rater-logo.png HTTP/1.1   
 2.092606000     192.168.5.105     54567     1.1.1.1     80     SYN  
 2.094013000     1.1.1.1     80     192.168.5.105     54565     SYN, ACK  
 2.096614000     192.168.5.105     54565     1.1.1.1     80     GET /images/grey_btn_bg.jpg HTTP/1.1   
 2.118005000     1.1.1.1     80     192.168.5.105     54566     SYN, ACK  
 2.118322000     192.168.5.105     54566     1.1.1.1     80     GET /images/home/user-insight-logo.png HTTP/1.1   
 2.146947000     1.1.1.1     80     192.168.5.105     54562     HTTP/1.1 200 OK (PNG)  
 2.149641000     192.168.5.105     54568     1.1.1.1     80     SYN  
 2.159017000     1.1.1.1     80     192.168.5.105     54563     HTTP/1.1 200 OK (PNG)  
 2.162342000     1.1.1.1     80     192.168.5.105     54567     SYN, ACK  
 2.162830000     192.168.5.105     54569     1.1.1.1     80     SYN  
 2.163137000     1.1.1.1     80     192.168.5.105     54564     HTTP/1.1 200 OK (PNG)  
 2.164078000     192.168.5.105     54567     1.1.1.1     80     GET /images/customer_bg.jpg HTTP/1.1   
 2.166080000     192.168.5.105     54570     1.1.1.1     80     SYN  
 2.167307000     1.1.1.1     80     192.168.5.105     54565     HTTP/1.1 200 OK (JPEG JFIF image)  
 2.169436000     192.168.5.105     54571     1.1.1.1     80     SYN  
 2.184629000     1.1.1.1     80     192.168.5.105     54566     HTTP/1.1 200 OK (PNG)  
 2.186997000     192.168.5.105     54572     1.1.1.1     80     SYN  
 2.219819000     1.1.1.1     80     192.168.5.105     54568     SYN, ACK  
 2.220139000     192.168.5.105     54568     1.1.1.1     80     GET /images/customers/carnegie_mellon.png HTTP/1.1   
 2.229254000     1.1.1.1     80     192.168.5.105     54569     SYN, ACK  
 2.229573000     192.168.5.105     54569     1.1.1.1     80     GET /images/customers/bcbs.png HTTP/1.1   
 2.242789000     1.1.1.1     80     192.168.5.105     54570     SYN, ACK  
 2.243155000     192.168.5.105     54570     1.1.1.1     80     GET /images/customers/lizclaiborne.png HTTP/1.1   
 2.244391000     1.1.1.1     80     192.168.5.105     54571     SYN, ACK  
 2.244762000     192.168.5.105     54571     1.1.1.1     80     GET /images/customers/usps.png HTTP/1.1   
 2.256889000     1.1.1.1     80     192.168.5.105     54572     SYN, ACK  
 2.257271000     192.168.5.105     54572     1.1.1.1     80     GET /images/customers/teradyne.png HTTP/1.1   
 2.287763000     1.1.1.1     80     192.168.5.105     54568     HTTP/1.1 200 OK (PNG)  
 2.289285000     192.168.5.105     54573     1.1.1.1     80     SYN  
 2.299719000     1.1.1.1     80     192.168.5.105     54569     HTTP/1.1 200 OK (PNG)  
 2.301075000     192.168.5.105     54574     1.1.1.1     80     SYN  
 2.314113000     1.1.1.1     80     192.168.5.105     54571     HTTP/1.1 200 OK (PNG)  
 2.315071000     1.1.1.1     80     192.168.5.105     54570     HTTP/1.1 200 OK (PNG)  
 2.329298000     1.1.1.1     80     192.168.5.105     54572     HTTP/1.1 200 OK (PNG)  
 2.358191000     1.1.1.1     80     192.168.5.105     54573     SYN, ACK  
 2.358506000     192.168.5.105     54573     1.1.1.1     80     GET /images/footer_bg.gif HTTP/1.1   
 2.369443000     1.1.1.1     80     192.168.5.105     54574     SYN, ACK  
 2.370632000     192.168.5.105     54574     1.1.1.1     80     GET /images/trustee_logo.jpg HTTP/1.1   
 2.429726000     1.1.1.1     80     192.168.5.105     54573     HTTP/1.1 200 OK (GIF89a) (GIF89a) (image/gif)  
 2.441633000     1.1.1.1     80     192.168.5.105     54574     HTTP/1.1 200 OK (JPEG JFIF image)  
 2.531537000     1.1.1.1     80     192.168.5.105     54567     HTTP/1.1 200 OK (JPEG JFIF image)  
 2.538506000     192.168.5.105     54575     1.1.1.1     80     SYN  
 2.605481000     1.1.1.1     80     192.168.5.105     54575     SYN, ACK  
 2.605965000     192.168.5.105     54575     1.1.1.1     80     GET /css/print.css HTTP/1.1   
 2.677186000     1.1.1.1     80     192.168.5.105     54575     HTTP/1.1 200 OK (text/css)  
 2.890407000     192.168.5.105     54577     1.1.1.1     80     SYN  
 2.961928000     1.1.1.1     80     192.168.5.105     54577     SYN, ACK  
 2.962359000     192.168.5.105     54577     1.1.1.1     80     GET /favicon.ico HTTP/1.1   
 3.030690000     1.1.1.1     80     192.168.5.105     54577     HTTP/1.1 200 OK (image/x-icon)  

     From this packet capture, we can observe a few things that our performance test professionals should take notes:

     First, as mentioned earlier, a browser may start with more than one tcp connections, whichever completes first will be used to do the HTTP transaction that downloads the main HTTP page.

     Secondly,  it will not wait for the main HTTP transaction to complete before sending HTTP requests to download the resource files. it can happen as soon as the URL for the resource file is available from the partial HTML page. See packet at timestamp 0.189143000.

     Thirdly, it can start up 6 connections at the same time to download resource files, see the TCP SYN packets starting at timestamp  1.027851000.  It's possible that the number "6" is configurable, but it shows that a test platform needs to be able to use multiple concurrent sessions to download resource files.   It can maintain 6 outstanding requests by starting a new request as soon one of the 6 transactions completes, see the connection started at timestamp 1.166331000.

     Now that the browser has become smarter,  we, the performance testing professionals,  need to be smarter too.

 

No comments:

Post a Comment