Presentation is loading. Please wait.
1 K. Salah Module 2.1: Application Layer Application-level protocols provide high-level services –Web and HTTP –DNS –Electronic mail –Remote login –FTP –telnet –SNMP –Multimedia - VoIP –All of these applications use client-server architecture
2 K. Salah World Wide Web Hypertext model (HTML) Use of hypertext in World Wide Web (WWW) WWW client-server model Use of TCP/IP protocols in WWW Nice tutorials on HTML and HTTP can be found on course web source in resources section.
3 K. Salah Identifying a page Page identified by: –Protocol used to access page –Computer on which page is stored –TCP port to access page –Pathname of file on server Specific syntax for Uniform Resource Locator (URL): protocol://computer_name:port/document_name –Protocol can be http, ftp, file, mailto –Computer name is DNS name –(Optional) port is TCP port –document_name is path on computer to page
4 K. Salah Client Architecture Browser has the following components: Display driver for painting screen HTML interpreter for HTML-formatted documents Other interpreters (e.g., Shockwave, JVM, VB runtime environment) for other items HTTP client to fetch HTML documents from WWW server Other clients for other protocols (e.g., ftp, telnet) Controller to accept input from user –Must be multi-threaded
5 K. Salah HTTP overview HTTP: hypertext transfer protocol Web’s application layer protocol client/server model –client: browser that requests, receives, “displays” Web objects –server: Web server sends objects in response to requests HTTP 1.0: RFC 1945 HTTP 1.1: RFC 2068 PC running Explorer Server running Apache Web server Mac running Navigator HTTP request HTTP response
6 K. Salah HTTP overview (continued) Uses TCP (socket programming): Server listens on port 80 or 8080 for accepting connections from client client initiates TCP connection (creates socket) to server, port 80 server accepts TCP connection from client, and creates thread to handle accepted connection Connection is established now between client and server thread HTTP messages between Client and Server are exchanged TCP connection closed Meanwhile server keeps listening for new connections HTTP is “stateless” server maintains no information about past client requests, as each request is process independently, without knowledge of the old requests. Server does not know who the client is? Or is it? We will illustrate this further in TCP layer. aside
7 K. Salah Sample HTTP1.0 Exchange To retrieve the file at the URL http://www.somehost.com/path/file.html first open a socket to the host www.somehost.com, port 80 (use the default port of 80 because none is specified in the URL). Then, send something like the following through the socket: GET /path/file.html HTTP/1.0 From: firstname.lastname@example.org User-Agent: HTTPTool/1.0 [blank line here] The server should respond with something like the following, sent back through the same socket: HTTP/1.0 200 OK Date: Fri, 31 Dec 1999 23:59:59 GMT Content-Type: text/html Content-Length: 1354 Happy New Millennium! (more file contents). After sending the response, the server closes the socket servicing only one request per connection.
8 K. Salah HTTP request message: general format
9 K. Salah HTTP request message two types of HTTP messages: request, response HTTP request message: –ASCII (human-readable format) GET /somedir/page.html HTTP/1.1 Host: www.someschool.edu User-agent: Mozilla/4.0 Connection: close Accept-language:fr (extra carriage return, line feed) request line (GET, POST, HEAD commands) header lines Carriage return, line feed indicates end of message
10 K. Salah HTTP response message HTTP/1.1 200 OK Connection close Date: Thu, 06 Aug 1998 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... status line (protocol status code status phrase) header lines data, e.g., requested HTML file
11 K. Salah HTTP connections Nonpersistent HTTP At most one object is sent over a TCP connection. HTTP/1.0 uses nonpersistent HTTP Persistent HTTP Multiple objects can be sent over single TCP connection between client and server. HTTP/1.1 uses persistent connections in default mode with pipelining. Without pipelining client has to issue one request at a time. It can not issue a new request until it receives the response of the previous one. With pipelining client doesn’t have to wait for first response. Client can request multiple objects. HTTP Transaction –HTTP request and response HTTP Hit –For server statistics –Server sends one object to client What is?
12 K. Salah HTTP 1.1 and higher As of early 1997, the Web is moving from HTTP 1.0 to HTTP 1.1. Whenever practical, use HTTP 1.1. It's more efficient overall. WHY? HTTP1.0 Client Request telnet www.ccse.kfupm.edu.sa 80 GET http://www.ccse.kfupm.edu.sa/~salah/ics432/index.html HTTP1.1 Client Request telnet www.ccse.kfupm.edu.sa 80 GET http://www.ccse.kfupm.edu.sa/~salah/ics432/index.html HTTP/1.1 Host: www.ccse.kfupm.edu.sa:80 HTTP1.2 Client Request telnet www.ccse.kfupm.edu.sa 80 GET http://www.ccse.kfupm.edu.sa/~salah/ics432/index.html HTTP/1.2 No need to have Host: field for every request.
13 K. Salah Uploading form input Post method: Web page often includes form input Input is uploaded to server in entity body URL method: Uses GET method Input is uploaded in URL field of request line: www.somesite.com/animalsearch?monkeys&banana
14 K. Salah Method types HTTP/1.0 GET POST HEAD –asks server to leave requested object out of the response. Headers is only sent. Used for debugging. HTTP/1.1 GET, POST, HEAD PUT –uploads file in entity body to path specified in URL field DELETE –deletes file specified in the URL field
16 K. Salah Cookies: keeping “state” (cont.) client server usual http request msg usual http response + Set-cookie: 1678 usual http request msg cookie: 1678 usual http response msg usual http request msg cookie: 1678 usual http response msg cookie- specific action cookie- spectific action Amazon server creates ID 1678 for user entry in backend database access Cookie file amazon: 1678 ebay: 8734 Cookie file ebay: 8734 Cookie file amazon: 1678 ebay: 8734 one week later:
17 K. Salah Cookies (continued) What cookies can bring: authorization shopping carts recommendations user session state (Web e- mail) Cookies and privacy: cookies permit sites to learn a lot about you you may supply name and e- mail to sites search engines use redirection & cookies to learn yet more advertising companies obtain info across sites aside
18 K. Salah Web caches (proxy server) user sets browser: Web accesses via cache browser sends all HTTP requests to cache –object in cache: cache returns object –else cache requests object from origin server, then returns object to client Goal: satisfy client request without involving origin server client Proxy server client HTTP request HTTP response HTTP request HTTP response origin server origin server Web proxies can be multipurpose: cache, Firewall Monitor and log activites NAT
19 K. Salah More about Web caching Local cache can be used to hold copies of visited pages Cache acts as both client and server Cache can do up-to-date check using If-modified- since HTTP header HTTP response messages has Age header. –Specifies how long the info is valid for. Typically cache is installed by ISP (university, company, residential ISP) Why Web caching? Reduce response time for client request. Downloading HTML documents from servers may be slow –Internet congested –Dialup connection –Server busy Reduce traffic on an institution’s access link.
20 K. Salah Conditional GET: client-side caching Goal: don’t send object if client has up-to-date cached version client: specify date of cached copy in HTTP request If-modified-since: server: response contains no object if cached copy is up-to- date: HTTP/1.0 304 Not Modified client server HTTP request msg If-modified-since: HTTP response HTTP/1.0 304 Not Modified object not modified HTTP request msg If-modified-since: HTTP response HTTP/1.0 200 OK object modified This is basically what happens when you hit “Refresh” or “update” button on the browser, I.e. GET with If- modified-since of current date.
© 2023 SlidePlayer.com Inc.
All rights reserved.