290 likes | 306 Views
Dive into the details of HTTP, a lightweight and fast protocol for client-server communication over TCP connections. Learn about request/response formats, status codes, persistent connections, and more. Explore variations like persistent connections and nonpersistent connections with parallel requests.
E N D
HyperText Transfer Protocol (HTTP) Deepti Kulkarni CISC 856: TCP/IP and Upper Layer Protocols Fall 2008 Acknowledgements Professor Amer Richi Gupta
Motivation ? • Single informational network • Light protocol • Speed Tim-Berners Lee Director of the W3C HTTP Versions Format : HTTP/<major>.<minor> • HTTP/0.9 – No RFC • HTTP/1.0 – RFC 1945 • HTTP/1.1 – RFC 2616 2
Position of HTTP in the TCP/IP Protocol suite Application-layer Transport layer IGMP ICMP Network layer IP ARP RARP Data link layer Physical layer
Quick overview of HTTP • Generic protocol for communication • Stateless protocol • In-band protocol • control information is sent in-band (unlike FTP) • Pull protocol • pulls information from the server (unlike SMTP which is push protocol)
Client-Server protocol Server running Apache Web server HTTP Request/Response are over TCP connections HTTP Response HTTP Request PC running Explorer/MAC running Navigator
Request Line Status Line General Headers General Headers Request Headers Response Headers Entity Headers Entity Headers A Blank Line A Blank Line Body Body A-PDU format Request Message Response Message Note: Each line ends with ‘cr lf ‘ control characters.
A-PDU format (cont’d) space space Request Line Request Type URL HTTP version Request Type GET, HEAD, POST, PUT , TRACE , CONNECT , OPTION space Header Name : Header Value Header format Date , Pragma, Cache control ,Connection, MIME-version, Upgrade, Transfer encoding General Header From, Referer, User-agent, Authorization, If-Modified-Since, Accept Request Header Entity Header Content-length, Content-type, Content- encoding, Last-modified, Expires, Upgrade Response Header Location, Age, Retry-after, Server
A-PDU format (cont’d)… space space Status Line HTTP Version Status Code Status Phrase 1xx: Informational Continue (100) , Switching Protocols(101) 2xx: Success - action was successfully received, understood, and accepted Created (201), Accepted (202), No Content (204), OK (200) 3xx: Redirection - further action needed to complete request Moved Permanently (301) , Moved Temporarily (302), Not Modified (304) 4xx: Client Error - request contains bad syntax or cannot be fulfilled Bad Request (400), Unauthorized (401), Forbidden (403), Not Found (404) 5xx: Server Error - server failed to fulfill an apparently valid request Internal Server Error (500), Not Implemented (501), Bad Gateway (502), Service Unavailable (503)
Variations of HTTP • Nonpersistent connections • with serial connections • with parallel connections • Persistent connections • without pipelining • with pipelining
OK Client Server SYN SYN-ACK 3-way handshake ACK GET web page HTTP/1.0 Get web page Web page Web page transferred Client parses HTML web page FIN Ack Data ACK Connection close FIN ACK 1.Found referenced object “Image 1” 2. Found referenced object “Image 2”
FIN FIN ACK ACK FIN FIN ACK ACK Nonpersistent (cont’d) Client Client Server Server SYN SYN SYN-ACK SYN-ACK 3-Way Handshake 3-Way Handshake ACK ACK Get image2 Get image1 GET image1 HTTP/1.0 GET image2 HTTP/1.0 Image2 Image1 OK OK Image 2 Transferred Image 1 Transferred Connection close Connection close Ack Data
Key points • Connection does not persist for other objects • Connections are sequential
Rough calculation for number of RTTS Client Server Web Page Can we reduce the number of RTTS? Image 1 Image 2 Delay due to connection request/handshake Time delay in RTTs = 6 Delay Due to HTML Page Request Delay Due to Object Request
FIN FIN FIN ACK ACK ACK FIN FIN FIN ACK ACK ACK Client Server Client Client Server Server SYN SYN SYN SYN-ACK SYN-ACK SYN-ACK 3-Way Handshake 3-Way Handshake 3-Way Handshake ACK ACK GET web page HTTP/1.0 GET image2 HTTP/1.0 GET image1 HTTP/1.0 Get image2 Get image1 Get web page Client parses HTML web page Web page OK OK OK Image2 Image1 Image 1 Transferred Image 2 Transferred Web page Transferred 1. Referenced object “Image 1” 2. Referenced object “Image 2” Connection close Connection close Connection close Parallel connections Ack Data
Rough calculation Client Server Web page Image1 & Image2 Time delay in RTTs = 4 Delay due to connection request/handshake Delay due to HTML page request Delay due to object request
Disadvantages: • Overhead of multiple TCP connections. • A busy server could end up with lots of connections in the ‘TIME-WAIT’ state • Rarely does each connection get past the ‘slow-start’ region • Failure to use the full end-to-end available bandwidth • Extra time opening connections increases user-perceived latency
Connection close FIN ACK FIN ACK Client Server GET image2 HTTP/1.1 SYN Get image2 SYN-ACK 3-Way Handshake OK Get web page GET web page HTTP/1.1 GET image1 HTTP/1.1 Image 2 Transferred Get image1 Image2 Image1 OK OK Web page Web page Transferred Image 1 Transferred Timer started Timer started Timer started Timer started Time Out Ack Data Note: 1) Requests are sequential 2) Timer is at application layer 20
Rough calculation Client Server Web page Image1 Image2 Time delay in RTTs = 4 Delay due to connection request/handshake Delay due to HTML page request Delay due to object request
Image 1 Connection close Image 1 FIN ACK FIN ACK Client Server SYN GET image1 HTTP/1.1 SYN-ACK 3-Way Handshake Get image1 GET image2 HTTP/1.1 Get web page GET webpage HTTP/1.1 Get image2 ACK ACK OK Web page Web page Transferred OK Back to back requests Client parses web page; Gets Image 1 Gets Image 2 Image 2 OK Timer started Timer started Image 2 Time Out Note: Requests are serviced in order Ack Data
Rough calculation Client Server Web page 24 Image1 & Image2 Time delay in RTTs = 3 Delay due to connection request/handshake Delay due to HTML page request Delay due to object request
Advantages: • Fewer connections • Reduced network traffic • CPU time is saved in routers and hosts • Less overhead for the servers • Reduced perceived latency for clients on subsequent requests • Either client or server can close the connection • Disadvantages: • Connections stay open longer at the server
Experimental Results (NP HTTP/1.0) without parallel connections (Persistent without pipelining) (Persistent with pipelining) Network Latency (seconds) Number of in lined images Figure 6-1: Latencies for a remote server, image size = 2544 bytes
Experimental Results (cont’d) (NP HTTP/1.0) without parallel connections (Persistent without pipelining) (Persistent with pipelining) Network Latency (seconds) Number of in lined images Figure 6-2: Latencies for a remote server, image size = 45566 bytes
Questions? Thanks
Example Of Request/Response Lets have a live demo! • telnet cis.poly.edu 80 • GET /~ross/ HTTP/1.1 Host: cis.poly.edu