Hypertext Transfer Protocol (HTTP) Madhusri Nayak CISC 856: TCP/IP and Upper Layer Protocols Fall 2004 Thanks to Dr. Amer, UDEL for some of the slides used in this presentation Thanks to Forouzan for some slides used in this presentation
Motivation ? Tim-Berners Lee Created by Tim Berners-Lee at CERN (Centre European pour Rechearche Nucleaire) – physicists, not computer scientists – to share data from physics experiments – because ftp was “too heavy” Standardized and much expanded by IETF Aerial View of CERN
Basic HTTP Protocol HTTP HTTP TCP TCP IP IP Link Link Physical Goal: transfer data Stateless, Application-layer protocol Request-Response Protocol, uses TCP port 80
HTTP Version HTTP/0.9 HTTP/1.0 HTTP/1.1 HTTP/<major>.<minor> HTTP/0.9 HTTP/1.0 HTTP/1.1
Overview of a browser HTTP request TCP connection HTTP response URL User-Agent (browser/client) Origin Server DNS Server DNS query DNS response HTTP request TCP connection HTTP response optional TCP connections
Request Message 3 request methods: A-PDU GET, HEAD, POST request line headers blank line body 3 request methods: GET, HEAD, POST GET /pub/index.html HTTP/1.0 Date: Wed, 20 Mar 2002 10:00:02 GMT From: amer@udel.edu User-Agent: Mozilla/4.03 GET: Retrieves resource indicated by URI HEAD: Retrieves ONLY metadata indicated by URI POST: Pushes the resource in place of the URI (or creates a new one) or inputs the entity (data part) to the program(ex: CGI script) pointed by the URI
Response Message status line headers blank line body HTTP/1.1 200 OK Date: Tue, 08 Oct 2002 00:31:35 GMT Server: Apache/1.3.27 tomcat/1.0 Last-Modified: 7Oct2002 23:40:01 GMT Accept-Ranges: bytes Content-Length: 27723 Keep-Alive: timeout=5, max=300 Connection: Keep-Alive Content-Type: text/html Why a human readeable phrase? To make extensibility easier. You can add new status codes without waiting for a protocol standard
Status Codes Classes: 200 OK 201 Created 202 Accepted 204 No Content 301 Moved Permanently 302 Moved Temporarily 304 Not Modified 400 Bad Request 401 Unauthorized 403 Forbidden 404 Not Found 500 Internal Server Error 501 Not Implemented 502 Bad Gateway 503 Service Unavailable Classes: 1xx: Informational - not used, reserved for future 2xx: Success - action was successfully received, understood, and accepted 3xx: Redirection - further action needed to complete request 4xx: Client Error - request contains bad syntax or cannot be fulfilled 5xx: Server Error - server failed to fulfill an apparently valid request 404, 403, 200, 304
Headers Request Line A Blank Line Body Entity Headers Request Headers General Headers Status Line A Blank Line Body Entity Headers Response Headers General Headers
Example Of Request/Response
Performance Issues
FTP vs. HTTP
FTP vs. HTTP (cont’d)
HTTP/1.0 Nonpersistent Connections Client Server SYN SYN-ACK 3-way handshake ACK GET URI HTTP/1.0 URL ACK OK ACK ACK DATA web page web page transferred client parses HTML web page ACK Nonpersistent Connection (short-lived connection) -- use a new TCP connection for each request; -- seldom get past the “slow-start” region. -- fail to maximize their use of the available bandwidth FIN connection close FIN ACK ACK
HTTP/1.0 Nonpersistent (cont’d) Client Server SYN 3-Way Handshake SYN-ACK ACK URL GET URI HTTP/1.0 OK ACK ACK DATA ACK Web Page with Image1 Web page transfer ACK Client parses HTML web page FIN connect close FIN ACK ACK HTML file gets parsed GET Image 1 will be issued SYN SYN-ACK ACK GET IMAGE1 HTTP/1.0 OK FIN image 1 transfer connect close 3-Way Handshake URL DATA image1
Nonpersistent with parallel Connections (a. k. a Nonpersistent with parallel Connections (a.k.a. Parallel Connections Hack) SYN SYN-ACK ACK Client Server GET URI HTTP/1.0 OK FIN DATA Transfer CONN. Close 3-Way Handshake URL DATA Client initiates new TCP connections for each embedded object after parsing the HTML file SYN SYN-ACK ACK Client Server GET URI HTTP/1.0 OK FIN DATA Transfer CONN. Close 3-Way Handshake URL DATA SYN SYN-ACK ACK Client Server GET URI HTTP/1.0 OK FIN DATA Transfer CONN. Close 3-Way Handshake URL DATA Increases network congestion, burstiness Is not fair for well-behaved connections
HTTP Delay Estimation Non Persistent assume web page with 2 images Non Persistent Non Persistent with Parallel Connections Client Server Client Server Time Delay in RTTs = 4 Delay Due to Connection Request/Handshake Delay Due to HTML Page Request Time Delay in RTTs = 6 Delay Due to Object Request
Potential HTTP 1.0 Inefficiencies v1.0 fetches single URL per TCP connection Mean size of responses only a few thousand bytes inefficient use of available network bandwidth Server resources wasted User perceived latency is high TCP congestion control not used due to short transfers
HTTP/1.1 Default: Persistent Connections SYN SYN-ACK ACK Client Server 3-Way Handshake GET URI HTTP/1.0 OK-ACK ACK DATA DATA Transfer URL GET image 3 GET URI HTTP/1.0 OK-ACK ACK DATA DATA Transfer URL Client parses HTML GET image 1 Conn. timeout GET URI HTTP/1.0 OK-ACK ACK DATA DATA Transfer URL FIN CONN. Close ACK GET image 2 GET URI HTTP/1.0 OK-ACK ACK DATA DATA Transfer URL Either client or server can close the connection
Why Persistent Connections? CPU time is saved in routers and hosts Reduced Network Congestion – fewer packets Reduced perceived latency on subsequent requests
Persistent with pipelining SYN SYN-ACK ACK Client Server 3-Way Handshake GET Image 1 OK-ACK URL Image 1 GET Image 2 GET URI HTTP/1.0 OK-ACK ACK DATA DATA Transfer URL OK-ACK URL Image 2 ACK DATA Transfer Image 1 DATA Client parses HTML ACK DATA Image 2 DATA Transfer FIN CONN. Close ACK
HTTP Delay Estimation (cont’d) Persistent w/o pipelining Persistent with pipelining Client Server Client Server Time Delay in RTTs = 3 Time Delay in RTTs = 4 Delay Due to Connection Request/Handshake Delay Due to HTML Page Request Delay Due to Object Request
Quantifying TCP connection overhead Throughput (bits/second) Connection Length (bytes) Figure 3-2: Throughput vs. connection length, RTT = 70 msec
Experimental Results Network Latency (seconds) (NP HTTP/1.0) Network Latency (seconds) Number of in lined images Figure 6-1: Latencies for a remote server, image size = 2544 bytes
Experimental Results (contd..) (NP HTTP/1.0) Network Latency (seconds) Number of in lined images Figure 6-2: Latencies for a remote server, image size = 45566 bytes
Questions?