Network Applications: HyperText Transfer Protocol

Slides:



Advertisements
Similar presentations
HTTP HyperText Transfer Protocol. HTTP Uses TCP as its underlying transport protocol Uses port 80 Stateless protocol (i.e. HTTP Server maintains no information.
Advertisements

HyperText Transfer Protocol (HTTP)
Application Layer-11 CSE401N: Computer Networks Lecture-4 Application Layer Overview HTTP.
Chapter 2: Application Layer
HyperText Transfer Protocol (HTTP) Computer Networks Computer Networks Spring 2012 Spring 2012.
9/16/2003-9/18/2003 The Application Layer and Java Programming September 16-18, 2003.
Chapter 2 Application Layer Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley, July.
Web, HTTP and Web Caching
Application Layer  We will learn about protocols by examining popular application-level protocols  HTTP  FTP  SMTP / POP3 / IMAP  Focus on client-server.
Application Layer  We will learn about protocols by examining popular application-level protocols  HTTP  FTP  SMTP / POP3 / IMAP  Focus on client-server.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
EEC-484/584 Computer Networks Lecture 4 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
PL-IV- Group A HTTP Request & Response Header
HTTP; The World Wide Web Protocol
CS 3830 Day 7 Introduction : Application Layer 2 Processes communicating Process: program running within a host. r within same host, two processes.
FTP (File Transfer Protocol) & Telnet
Mail (smtp), VoIP (sip, rtp)
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
2: Application Layer1 CS 4244: Internet Software Development Dr. Eli Tilevich.
Application Layer 2 Figures from Kurose and Ross
Rensselaer Polytechnic Institute Shivkumar Kalvanaraman, Biplab Sikdar 1 The Web: the http protocol http: hypertext transfer protocol Web’s application.
20-1 Last time □ NAT □ Application layer ♦ Intro ♦ Web / HTTP.
2: Application Layer1 Internet apps: their protocols and transport protocols Application remote terminal access Web file transfer streaming multimedia.
Week 11: Application Layer1 Web and HTTP First some jargon r Web page consists of objects r Object can be HTML file, JPEG image, Java applet, audio file,…
2: Application Layer1 Web and HTTP First some jargon Web page consists of base HTML-file which includes several referenced objects Object can be HTML file,
1 Computer Communication & Networks Lecture 28 Application Layer: HTTP & WWW p Waleed Ejaz
Network Applications: The Web and High-Performance Web Servers Y. Richard Yang 9/24/2013.
1 HTTP EECS 325/425, Fall 2005 September Chapter 2: Application layer r 2.1 Principles of network applications m app architectures m app requirements.
CIS679: Lecture 13 r Review of Last Lecture r More on HTTP.
CSx760 Computer Networks1 HTTP. CSx760 Computer Networks2 The Web: Some Jargon r Web page: m consists of “objects” m addressed by a URL r Most Web pages.
2: Application Layer1 Chapter 2 Application Layer Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
Important r There will be NO CLASS on Friday 1/30/2015! r Please mark you calendars 1.
2: Application Layer 1 Chapter 2: Application layer r 2.1 Principles of network applications  app architectures  app requirements r 2.2 Web and HTTP.
1 COMP 431 Internet Services & Protocols HTTP Persistence & Web Caching Jasleen Kaur February 11, 2016.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 7 Omar Meqdadi Department of Computer Science and Software Engineering University of.
EEC-484/584 Computer Networks Lecture 4 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
COMP2322 Lab 2 HTTP Steven Lee Jan. 29, HTTP Hypertext Transfer Protocol Web’s application layer protocol Client/server model – Client (browser):
World Wide Web r Most Web pages consist of: m base HTML page, and m several referenced objects addressed by a URL r URL has two components: host name and.
Data Communication EDA344, DIT420 Description of Lab 1 and Optional Programming HTTP Assignment Bapi Chatterjee Prajith R G.
Week 11: Application Layer 1 Web and HTTP r Web page consists of objects r Object can be HTML file, JPEG image, Java applet, audio file,… r Web page consists.
Network Applications: Network App Programming: HTTP/1.1/2; High-performance Server Design Y. Richard Yang 2/15/2016.
© Janice Regan, CMPT 128, Jan 2007 CMPT 371 Data Communications and Networking HTTP 0.
Network Applications: HTTP; High-Perf HTTP Server 2/2/2012.
Lecture 5 Internet Core: Protocol layers. Application Layer  We will learn about protocols by examining popular application-level protocols  HTTP 
Network Applications: HTTP/1.0
2: Application Layer 1 Chapter 2 Application Layer These ppt slides are originally from the Kurose and Ross’s book. But some slides are deleted and added.
Data Communication EDA344, DIT420 Description of Lab 1 and Optional Programming HTTP Assignment Aras Atalar Prajith R G.
Block 5: An application layer protocol: HTTP
WWW and HTTP King Fahd University of Petroleum & Minerals
HTTP – An overview.
HTTP request message: general format
Lecture 2 Dr. Richard Spillman Fall 2009
COMP2322 Lab 2 HTTP Steven Lee Feb. 8, 2017.
Hypertext Transport Protocol
Internet transport protocols services
Network Applications: HTTP/1
Computer Communication & Networks
HTTP Hypertext Transfer Protocol
EEC-484/584 Computer Networks
لایه ی کاربرد مظفر بگ محمدی 2: Application Layer.
CS 5565 Network Architecture and Protocols
Data Communication EDA344, DIT420 Description of Lab 1 and Optional Programming HTTP Assignment Aras Atalar Prajith R G 24/01/2018.
EE 122: HyperText Transfer Protocol (HTTP)
Hypertext Transfer Protocol (HTTP)
EEC-484/584 Computer Networks
The Application Layer: HTTP
3: Application Protocols: HTTP
HTTP Hypertext Transfer Protocol
CSCI-351 Data communication and Networks
Presentation transcript:

Network Applications: HyperText Transfer Protocol Y. Richard Yang http://zoo.cs.yale.edu/classes/cs433/ 9/27/2018

Admin Assignment 2 status?

Recap: Basic Socket Programming UDP: DatagramSocket, MulticastSocket TCP: ServerSocket, Socket The main function of socket is multiplexing/demultiplexing to application processes UDP uses (dst IP, port) -- roughly TCP uses (src IP, src port, dst IP, dst port) Welcome socket, ServerSocket, Socket Always pay attention to encoding/decoding

Recap: FTP Features A stateful protocol Multiple TCP connections state established by commands such as USER/PASS, CWD, TYPE Multiple TCP connections A control connection commands specify parameters for the data connection: (1) data port, transfer mode, representation type, and file structure; (2) nature of file system operation e.g., store, retrieve, append, delete, etc. Data connections Two approaches: PORT vs PASV to establish data connections FTP client server Server initiates TCP data connection server:20 clientip:cport PORT clientip:cport RETR index.html USER xxx PASS xxx CWD home Stream mode issues is inherently unreliable (depends on connection close to indicate end of transfer) Connection is not reusable

Recap: FTP Evaluation request reply application transport network data link physical reply request Key questions to ask about a C-S application - Is the application extensible? - Is the application scalable? - How does the application handle server failures (being robust)? - How does the application provide security?

FTP Extensions FTP with extensions are being used extensively in large data set transfers (e.g., LHC)

Data Transfer Structure See GridFTP to FTP extensions http://www.ogf.org/documents/GFD.20.pdf http://www.ogf.org/documents/GFD.21.pdf Goal of GridFTP: allow parallel, high-throughput data transfer Discussion: What features do we need to add to FTP to allow parallel transfers?

Outline Admin and recap HyperText Transfer Protocol (HTTP)

HTTP Basic Service: From Opaque Files to Web Pages authored in HTML addressed by a URL URL has two components: host name, port number and path name Most Web pages consist of: base HTML page, and several referenced objects (e.g., js, css, images) http request User agent: Explorer http response http request Server running Apache Web server http://www.cs.yale.edu:80/index.html http response User agent: Firefox The Web pages are requested through HTTP: hypertext transfer protocol

See one page: https://www.w3.org/Protocols/HTTP/AsImplemented.html HTTP Design Evolution See one page: https://www.w3.org/Protocols/HTTP/AsImplemented.html RFC 2068->2616 RFC 1945 RFC 7540

Thought Experiment How about we use FTP as (underlying protocol to implement) HTTP? FTP client server TCP control connection port 21 at server Server initiates TCP data connection server:20 clientip:cport PORT clientip:cport RETR index.html FTP client server TCP control connection port 21 at server Client initiates TCP data connection of PASV returned serverip:sport PASV RETR index.html serverip:sport Content negotiation, content type indication

HTTP Msg Flow vs FTP Msg Flow HTTP1.0 servers are stateless servers: each request is self-contained; FTP assumes always starts with user/pass FTP client server Server initiates TCP data connection server:20 clientip:cport PORT clientip:cport RETR index.html USER xxx PASS xxx CWD home HTTP server HTTP client GET /home/index.html USER: xxx PASS: xxx Server sends file on same connection

HTTP Requires Content Management Capabilities (e. g HTTP Requires Content Management Capabilities (e.g., Content Negotiation) When request /somedir/page.html Specify, content negotiation properties such as - User-agent (Mozilla/4.0) - Format: text/html, image/gif, image/jpeg,… - Locality: English, … In response: Provide content meta information such as Format: text/html, image/gif, image/jpeg,… Last modification time,

Outline Admin and recap HTTP Basic service Basic protocol

HTTP Request Message: General Format Simple methods Rich headers to support functions such as content negotiation

Trying out HTTP (client side) for yourself 1. Telnet to your favorite Web server: telnet www.cs.yale.edu 80 Opens TCP connection to port 80 (default http server port) at www.cs.yale.edu. Anything typed in sent to port 80 at www.cs.yale.edu 2. Type in a GET http request: By typing this in (hit carriage return twice), you send this minimal (but complete) GET request to http server GET /index.html HTTP/1.0 3. Look at response message sent by the http server.

Trying out HTTP (client side) for yourself Try telnet GET on zoo.cs.yale.edu to fetch class home page www.cs.yale.edu www.yale.edu

HTTP Request Message Example: GET Virtual host multiplexing request line (GET, POST, HEAD, PUT, DELETE, TRACE … commands) GET /somedir/page.html HTTP/1.0 Host: www.somechool.edu Connection: close User-agent: Mozilla/4.0 Accept: text/html, image/gif, image/jpeg Accept-language: en (extra carriage return, line feed) Connection management header lines Content negotiation Carriage return, line feed indicates end of message

HTTP Response Message status line (protocol status code status phrase) HTTP/1.0 200 OK Date: Wed, 23 Jan 2008 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data ... header lines data, e.g., requested html file

HTTP Response Status Codes In the first line of the server->client response message. A few sample codes: 200 OK request succeeded, requested object later in this message 301 Moved Permanently requested object moved, new location specified later in this message (Location:) 400 Bad Request request message not understood by server 404 Not Found requested document not found on this server 505 HTTP Version Not Supported

Outline Admin and recap HTTP Basic service Basic protocol Basic HTTP client/server workflow

Simple Design Exercise Workflow of an HTTP client/server processing

HTTP Basic Message Flow 0. http server at host www.cs.yale.edu waiting for TCP connection at port 80. Suppose user enters URL www.cs.yale.edu/index.html 1a. http client initiates TCP connection to http server (process) at www.cs.yale.edu. Port 80 is default for http server. 1b. server “accepts” connection, ack. client 2. http client sends http request message (containing URL) into TCP connection socket 3. http server receives request message, forms response message containing requested object (index.html), sends message into socket time

HTTP Basic Message Flow (cont.) 4. http server closes TCP connection. 5. http client receives response message containing html file, parses html file, finds embedded image time 6. Steps 1-5 repeated for each of the embedded images

Basic HTTP Server Workflow Create ServerSocket(6789) TCP socket space state: listening address: {*.6789, *.*} completed connection queue: sendbuf: recvbuf: 128.36.232.5 128.36.230.2 address: {*.25, *.*} completed connection queue: sendbuf: state: established address: {128.36.232.5:6789, 198.69.10.10.1500} connSocket = accept() read request from connSocket Map URL to file Read from file/ write to connSocket close connSocket

Example Code See BasicWebServer.java Try using telnet and real browser, and fetch file1.html index.html what difference in behavior?

URL as Content Abstraction Create ServerSocket(6789) connSocket = accept() It does not have to be a static file read request from connSocket Map URL to file Read from file/ write to connSocket close connSocket

Dynamic Content Pages There are multiple approaches to make dynamic web pages: Embed code into pages (server side include) http server includes an interpreter for the type of pages Invoke external programs (http server is agnostic to the external program execution) http://www.cs.yale.edu/index.shtml http://www.cs.yale.edu/cgi-bin/ureserve.pl http://www.google.com/search?q=Yale&sourceid=chrome

Example SSI See programming/examples-java-socket/BasicWebServer/ssi/index.shtml, header.shtml, … https://httpd.apache.org/docs/2.2/howto/ssi.html

Example SSI See programming/examples-java-socket/BasicWebServer/ssi/index.shtml, header.shtml, … To enable ssi, need configuration to tell the web server (see conf/apache-htaccess) https://httpd.apache.org/docs/2.2/howto/htaccess.html (Server Side Includes example) https://httpd.apache.org/docs/2.2/howto/ssi.html

CGI: Invoking External Programs Two issues Input: Pass HTTP request parameters from server to the external program Output: Get external program output to server (to client)

Example: Typical CGI Implementation Starts the executable as a child process Passes HTTP request as environment variables http://httpd.apache.org/docs/2.2/env.html CGI standard: http://www.ietf.org/rfc/rfc3875 Example GET /search?q=Yale&sourceid=chrome HTTP/1.0 setup environment variables, in particular $QUERY_STRING=q=Yale&sourceid=chrome Redirects input/output of the child process to the socket Read this before Assignment Three https://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html

https://httpd.apache.org/docs/2.2/howto/htaccess.html (CGI Example) http://172.28.229.215/BasicWebServer/cgi/price.cgi?appl #!/usr/bin/perl -w $company = $ENV{'QUERY_STRING'}; print "Content-Type: text/html\r\n"; print "\r\n"; print "<html>"; print "<h1>Hello! The price is "; if ($company =~ /appl/) { my $var_rand = rand(); print 450 + 10 * $var_rand; } else { print "150"; } print "</h1>"; print "</html>"; https://httpd.apache.org/docs/2.2/howto/htaccess.html

Outline Admin and recap HTTP Basic service Basic protocol Basic HTTP client/server workflow Stateful interaction using stateless HTTP

Stateful User-server Interaction: Cookies client server Goal: no explicit application level session Server sends “cookie” to client in response msg Set-cookie: 1678453 Client presents cookie in later requests Cookie: 1678453 Server matches presented-cookie with server-stored info authentication remembering user preferences, previous choices usual http request msg usual http response + Set-cookie: # usual http request msg Cookie: # cookie- specific action usual http response msg usual http request msg Cookie: # cookie- specific action usual http response msg

Authentication of Client Request server Authentication goal: control access to server documents stateless: client must present authorization in each request authorization: typically name, password Authorization: header line in request if no authorization presented, server refuses access, sends WWW-authenticate: header line in response usual http request msg 401: authorization req. WWW-authenticate: usual http request msg + Authorization:line usual http response msg usual http request msg + Authorization:line time usual http response msg Browser caches name & password so that user does not have to repeatedly enter it.

Recap So Far: HTTP C-S app serving Web pages message format request/response line, header lines, entity body simple methods, rich headers message flow stateless server, thus states such as cookie and authentication are needed in each message Wide use of HTTP for Web applications Example: RESTful API http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm HTTP Ethernet Cable/DSL Wireless TCP UDP WebMail WebApp…

Outline Admin and recap HTTP Basic service Basic protocol Basic HTTP client/server workflow Stateful interaction using stateless HTTP HTTP ”acceleration”

Latency of Basic HTTP Protocol Msg Flow >= 2 RTTs per object: TCP handshake --- 1 RTT client request and server responds --- at least 1 RTT (if object can be contained in one packet) TCP SYN TCP/ACK; HTTP GET TCP ACK base page TCP SYN TCP/ACK; HTTP GET TCP ACK image 1 Typical approaches to reduce latency: parallel TCP connections persistent HTTP cache and conditional GET

Web Request Structures https://httparchive.org/reports/page-weight 75 requests, 1525KB /page 5 css requests, 50 KB 4 font requests, 97KB 5 HTML requests, 28KB 33 image requests, 651KB 20 javascript requests, 406KB 2 video requests, 2662KB 3 others, 0.5KB Typical approaches to reduce latency: parallel TCP connections persistent HTTP cache and conditional GET Discussion: How to reduce HTTP latency?

Substantial Efforts to Speedup Basic HTTP/1.0 Reduce the number of objects fetched [Browser cache] Reduce data volume [Compression of data] Header compression [HTTP/2] Reduce the latency to the server to fetch the content [Proxy cache] Remove the extra RTTs to fetch an object [Persistent HTTP, aka HTTP/1.1] Increase concurrency [Multiple TCP connections] Asynchronous fetch (multiple streams) using a single TCP [HTTP/2] Server push [HTTP/2]

Browser Cache and Conditional GET client server Goal: don’t send object if client has up-to-date stored (cached) version client: specify date of cached copy in http request If-modified-since: <date> server: response contains no object if cached copy up-to-date: HTTP/1.0 304 Not Modified http request msg If-modified-since: <date> object not modified http response HTTP/1.0 304 Not Modified http request msg If-modified-since: <date> object modified http response HTTP/1.1 200 OK … <data>

Web Caches (Proxy) Goal: satisfy client request without involving origin server client Proxy server http request http response origin

Typically in the same network as the server http://www.celinio.net/techblog/?p=1027 Two Types of Proxies Typically in the same network as the client Typically in the same network as the server

Benefits of Forward Proxy origin servers Assume: cache is “close” to client (e.g., in same network) smaller response time: cache “closer” to client decrease traffic to distant servers link out of institutional/local ISP network often is bottleneck public Internet 1.5 Mbps access link institutional network 10 Mbps LAN institutional cache

No Free Lunch: Problems of Web Caching The major issue of web caching is how to maintain consistency Two ways pull Web caches periodically pull the web server to see if a document is modified push whenever a server gives a copy of a web page to a web cache, they sign a lease with an expiration time; if the web page is modified before the lease, the server notifies the cache

Demo Load class home page zoo.cs.yale.edu and capture traffic using wireshark

HTTP/1.1: Persistent (keepalive/pipelining) HTTP HTTP/1.0 allows a single request outstanding, while HTTP/1.1 allows request pipelining On same TCP connection: server parses request, responds, parses new request, … Client sends requests for all referenced objects as soon as it receives base HTML Benefit Fewer RTTs See Joshua Graessley WWDC 2012 talk: 3x within iTunes

HTTP/1.0, Keep-Alive, Pipelining Is this the best we can do? https://httpd.apache.org/docs/2.2/howto/ssi.html Source: http://chimera.labs.oreilly.com/books/1230000000545/ch11.html

HTTP/2 Basic Idea: Remove Head-of-Line Blocking in HTTP/1.1 Data flows for sequential to parallel: two requests must be processed concurrently. https://httpd.apache.org/docs/2.2/howto/ssi.html Source: http://chimera.labs.oreilly.com/books/1230000000545/ch11.html

HTTP/2 Adoption https://httparchive.org/reports/state-of-the-web#h2