CSS 432 Applications Textbook Ch 9 1 and
CSS 432 Applications Textbook Ch 9. 1 and 9. 3. 1 Professor: Munehiro Fukuda CSS 432: Applications 1
Applications n Client – Server Paradigm ¨ ¨ n Client: initiates contact with server Server: provides client with a response Client Server outlook browser mail/web server Applications use their corresponding protocol SMTP, HTTP, FTP Defined in RFC by Internet Engineering Task Force (http: //www. ietf. org/) ¨ Implemented on top of TCP or UDP SMTP, HTTP, FTP ¨ Applications Protoc ol RFC Port Name service DNS 1035 53 Email SMTP IMAP 821 25 143 Web HTTP 2616 80 File transfer FTP 959 21 Remote terminal access telnet 854 23 socket TCP with buffers, variables CSS 432: Applications Internet 2
DNS Name Service Name • Variable length and mnemonic • Location independent n Name Server Hosts cheltenham. cs. princeton. edu 192. 12. 69. 17 n 192. 12. 69. 17 80: 23: A 8: 33: 5 B: 9 F Files /usr/llp/tmp/foo n Value • System-provided fixed value • Location dependent (server, inode) Users Larry Peterson llp@cs. princeton. edu (UID + host IP) CSS 432: Applications 3
DNS Name service (cont) n lpr/a 2 ps commands User 1 lpr –Puw 1 -320 -p 1 manual. ps 2 uw 1 -320 -p 1 Name server lpr program 216. 186. 75. 218 4 3 TCP 216. 186. 75. 218 5 IP n Unix system call struct hostent h = gethostbyname( const char *hostname ); ¨ *(struct in_addr *)*h->h_addr_list; // returns IP list ¨ CSS 432: Applications 4
DNS Domain Naming System n Hierarchy edu washington… mit bothell cs com gov cisco … yahoo nasa …nsf mil org arpa …navy acm …ieee net uk fr u uw 1 -320 -00 medusa homer goodall n Name uw 1 -320 -00. bothell. washington. edu (Currently, uw 1 -320 -00. uwb. edu) CSS 432: Applications 5
DNS Name Servers n administrative unit Partition hierarchy into zones Network Information Center manages edu washington… mit bothell cs com gov cisco … yahoo nasa …nsf mil org arpa …navy acm …ieee uk fr u Managed by UW C&C uw 1 -320 -00 medusa homer goodall n net Root name server Each zone implemented by two or more name servers washington name server bothell name server CSS 432: Applications … … Cisco name server cs name server 6
Resource Records n DNS Each name server maintains a collection of resource records (Name, Value, Type, Class, TTL) n n Name/Value: not necessarily host names to IP addresses Type A: Value returns IP address ¨ NS: Value returns the corresponding name server’s name ¨ CNAME: Value returns aliases. ¨ MX: Value returns the domain name of this host’s mail ¨ n n Class: IN (Internet class) TTL: how long the resource record is valid CSS 432: Applications 7
Name Servers From Root to Bottom Level n Find a root name server ¨ dig edu ns n n n edu a. gtld-server. net NS IN a. gtld-server. net 192. 5. 6. 30 A IN Find uwb. edu’s name servers ¨ dig @192. 5. 6. 30 uwb. edu ns n n n DNS uwb. edu, dns 2. uwb. edu NS IN uwb. edu, dns 4. uwb. edu NS IN dns 2. uwb. edu 69. 91. 206. 28 A dns 4. uwb. edu 69. 91. 206. 29 A Find mercury. uwb. edu ¨ dig @69. 91. 206. 28 metis. uwb. edu A n metis. uwb. edu 69. 91. 206. 17 A CSS 432: Applications 8
DNS Name Resolution n Client ¨ Initialized with its local name server’s address ¨ appends its domain name to a given name before a submission. Client 1 cicada. cs. princeton. edu 192. 12. 69. 60 8 n Local name server Local server ¨ needs to know root at only one place (not each host). ¨ caches recent responses from remote servers. CSS 432: Applications Root 2 name u server. ed n 3 o 3 et 8. 2 nc i 2 r. 1 3. p 96. cs 1 a. ad 28 , 1 cic u d n. e o t e 4 nc i r p cicada. cs. princeton. edu Princeton name server cs. princeton. edu, 192. 12. 69. 5 5 cic ad a. c cic s. p 19 ada rin 2. 1. c ce 2. 6 s. pr ton 9. 6 inc. ed 6 e 0 ton u. ed u, 7 CS name server 9
Email Electronic Mail (SMTP, MIME, IMAP) n n user agents (client) ¨ a. k. a. “mail reader” ¨ composing, editing, reading mail messages ¨ e. g. , Eudora, Outlook, elm, Netscape Messenger, Thunderbird mail servers (server) ¨ outgoing, incoming messages stored on server SMTP IMAP user agent mail server outgoing mail queue User mailbox user agent User mailbox SMTP/TCP CSS 432: Applications user agent 10
Email SMTP n n TCP port 25 – Persistent connection Email sending protocol From User agent to his/her local mail server ¨ From a local to an intermediate/destination mail server (direct transfer) ¨ From an intermediate to a destination server (relay) Three phases of transfer ¨ Handshaking: HELO ¨ Transfer of messages: MAIL FROM, RCPT TO, and DATA ¨ Closure: QUIT Command/response interaction ¨ Commands: ASCII text ¨ Response: status code and phrase ¨ n n CSS 432: Applications 11
SMTP Example Email [mfukuda@uw 1 -320 -20]$ telnet smtp. washington. edu 25 Trying 140. 142. 33. 9… Connected to smpt. washington. edu (140. 142. 33. 9). Escape character is ‘^]’. 220 smtp. washington. edu ESMTP Sendmail 8. 12. 11+UW 04. 02/8. 12. 11+UW 04. 02; Sat, 21 Feb 2004 20: 00: 56 -0800 HELO mfukuda 250 smtp. washington. edu Hello UW 1 -320 -20. bothell. washington. edu [216. 186. 75. 195] , pleased to meet you MAIL FROM: mfukuda@u. washington. edu 250 2. 1. 0 <mfukuda@u. washington. edu>. . . Sender ok RCPT TO: Munehiro. Fukuda@yahoo. net 250 2. 1. 5 Munehiro. Fukuda@yahoo. net. . . Recipient ok DATA 354 Enter mail, end with “. ” on a line by iteself Blah blah… …etc. . 250 2. 0. 0 i 1 M 40 uc 3013699 Message accepted fro delivery QUIT 221 2. 0. 0 smtp. washington. edu closing connection Connection closed by foreign host. [mfukuda@uw 1 -320 -20]$ _ CSS 432: Applications 12
RFC 822 Message Format Email Header n n n Header ¨ A series of line<crlf>s Body ¨ ASCII characters only. Then, what about multimedia information? To: Subject: Date: From: Received: A blank line Body CSS 432: Applications 13
Email MIME n n MIME: multimedia mail extension, RFC 2045, 2056 Additional lines in msg header declare MIME content type MIME-Version: 1. 0 Content-Type: multipart/mixed; boundary=“-------417 CA 6 E 2 DE 4 ABCAFBC 5” From: mfukuda@u. washington. edu To: css 432 a_au 04@u. washington. edu Carry more than one data type Subject: promised material Date: Mon, 01 Apr 2004 12: 34: 56 -0800 -------417 CA 6 E 2 DE 4 ABCAFBC 5 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7 bit Type of the data How the data is encoded Dear CSS 432 students, Here is the jpeg image and draft report I promised. -- Fukuda Definitions for content types -------417 CA 6 E 2 DE 4 ABCAFBC 5 Content-Type: image/jpeg Content-Transfer-Encoding: base 64 3 bytes = 3 * 8 bits = 24 bits = 4 * 6 bit-chars, each mapped onto one of 64 ASCII chars (A~Z, a~z, 0~9, +, /) … Unreadable encoding of a jpeg figure -------417 CA 6 E 2 DE 4 ABCAFBC 5 Content-Type: application/postscript; name=“draft. ps” Content-Transfer-Encoding: 7 bit … Readable encoding of a postscript document CSS 432: Applications 14
Email Mail Reader - IMAP TCP to 143 Connection established Server greeting Server: OK Server: PREAUTH Server: BYE Not authenticated Client LOGOUT Client: LOGIN or AUTHENTICATE Authenticated Client LOGOUT Client: CLOSE Client SELECT or EXAMINE Selected Client: FETCH, STORE, DELETE, EXPUNGE Client LOGOUT Logout Both sides close the connection CSS 432: Applications 15
FTP File Transfer Protocol FTP user client interface TCP port 21 for control (persistent) TCP port 20 for data transfer (not persistent) local file system n n n FTP server remote file system Transfer file to/from remote host Client/server model ¨ Client: initiates a control TCP connection to a server on port 21. ¨ Client: sends a user ID and password as part of FTP commands. ¨ Server: authorizes the client ¨ Client: opens a data TCP connection to a server on port 20. ¨ Server: maintains state: current directory, earlier authentication. A ftp client is allowed to initiate a transfer between two ftp servers. CSS 432: Applications 16
FTP Commands n n FTP <CRLF> delimits each command (and reply). Commands consist of four uppercase ASCII characters, some with optional arguments: USER username : sends a user identification to server. PASS password : sends the user password to the server. PASV: requests the server to send back its IP and port on which it listens to a data TCP connection from the user. ¨ LIST : ask the server to send back its current directory contents through the data connection. ¨ RETR filename : gets a file from the current remote directory. ¨ STOR filename : stores a file into the current remote directory. ¨ ¨ ¨ n Each command is followed by a reply: ¨ ¨ 331 Username OK, password required 125 Data connection already open; transfer starting 425 Can't open data connection 452 Error writing file CSS 432: Applications 17
FTP Example FTP [mfukuda@uw 1 -320 -20]$ telnet ftp. tripod. com 21 Trying 209. 202. 240. 80… Connected to ftp. tripod. com (209. 202. 240. 80). Escape character is ‘^]’. 220 Welcome to Tripod FTP. USER css 432 331 Username set to css 432. Now enter your password. PASS **** 230 User ‘css 432’ logged on. LIST 425 Can’t open data connection for LIST. PASV 227 Entering Passiv Mode (209, 202, 240, 80, 195, 210) // Open another xterm and telnet 209. 202. 240. 80 50130 (=195*256+210) // Trying 209. 202. 240. 80… // Connected to ftp. tripod. com (209. 202. 240. 80). // Escape character is ‘^]’. // drwxr-xr-x 1 css 432 Tripod 0 Sep 15 21: 22 cgi-bin // -rw-r--r-1 css 432 Tripod 26169 Sep 16 18: 28 ttcp. c // -rw-r--r-1 css 432 Tripod 8236 Sep 15 21: 22 index. htm // drwxr-xr-x 1 css 432 Tripod 0 Sep 16 18: 33 project // Connection closed by foreign host. LIST 150 Opening ASCII mode data connection for LIST. 226 Transfer complete. QUIT 221 Goodbye Connection closed by foreign host. [mfukuda@uw 1 -320 -20]$ _ CSS 432: Applications 18
FTP passive mode TCP port 21 for control (persistent) Client request: connect( ), USER, PASS, LIST FTP client Server Reply: 220 server ready, 331 send password, 230 login ok, 425 connection timeout FTP server TCP port 20 for data transfer (one time) TCP port 21 for control (persistent) Client request: connect( ), USER, PASS, PASV, LIST FTP client Server Reply: 220 server ready, 331 send password, 230 login ok, 227 Entering Passive Mode (140, 142, 173, 195, 54), 226 complete FTP server TCP port 195*256 + 54 = 49974 for data transfer (one time) data CSS 432: Applications 19
FTP proxy command (3’) 227 Entering Passive Mode (140, 142, 173, 195, 54) FTP client (1) USER, PASS, SYST (2) USER, PASS, SYST (3) TYPE I, PASV (4) TYPE I, PORT (140, 142, 173, 195, 54), STOR file (5) RETR file ftp> open server 1 ftp> proxy open server 2 ftp> proxy get file FTP Server 1 …(1) …(2) …(3)~(5) TCP port 195*256 + 54 = 49974 for data transfer (one time) FTP Server 2 data CSS 432: Applications 20
World Wide Web - HTTP Netscape TCP port 80 (one-time connection) HTTP request ) HTTP response ction e onn c e tim e (on 0 8 ort p P TC Web HTTP server /public_html IE n n n Hypertext Transfer Protocol: onetime TCP port 80 connection for each response/reply client: Browser requests, receives, and displays Web objects server: Web server sends objects in response to the request CSS 432: Applications 21
HTTP Commands n Web Client ¨ Initiates a TCP connection to a server on port 80. ¨ Sends an HTTP request over this TCP connection n n n OPTIONS: request information about available options GET: retrieve document identified in URL HEAD: retrieve document metainformation in URL POST: give inofrmation (annotation, servlet invocation) to server PUT: store document under specified URL DELETE, TRACE, CONNECT Receives an HTTP response Server ¨ Accepts a TCP connection from a client on port 80. ¨ Receives an HTTP request ¨ Returns an HTTP response and disconnects the connection. ¨ n n n 1 xx: Informational 2 xx: success 3 xx: Redirection 4 xx: Client error 5 xx: Server error CSS 432: Applications 22
Web HTTP Example [mfukuda@uw 1 -320 -20]$ telnet www. washington. edu 80 Trying 140. 142. 11. 167. . . Connected to www. washington. edu (140. 142. 11. 167). Escape character is '^]'. GET HTTP/1. 1 200 OK Date: Sun, 22 Feb 2004 09: 06: 17 GMT Server: Apache/1. 3. 28 (Unix) PHP/4. 3. 3 mod_perl/1. 29 mod_backhand/1. 2. 2 Connection: close Content-type: text/html <!doctype html public “-//W 3 C/DTD HTML 4. 0 Transitional//EN”> <html><head> … </body></html> Connection closed by foreign host. [mfukuda@uw 1 -320 -20]$ _ CSS 432: Applications 23
Web Performance Improvement in Web n Persistent TCP connections ¨ Advantages n n ¨ Disadvantages n n Eliminate the connection setup overhead Eliminate repetitions of slow start phase Need to know the time period of connection – server times out the connection. Caching Recently access pages can be cached at browsers and ISPs ¨ Advantages ¨ n ¨ Reduce the number of HTTP accesses Disadvantages n Need to purge out-of-date version of pages – use expiration date and cache directives to cache or not to cache a given page CSS 432: Applications 24
n Reviews ¨ RFC ¨ Naming service: DNS ¨ Email: SMTP, MIME, and IMAP ¨ File transfer: FTP ¨ WWW: HTTP n Exercises: try the following examples by yourself. ¨ Slide p 8 (DNS) ¨ Slide p 12 (SMTP) ¨ Slide p 18 (FTP) ¨ Slide p 21 (HTTP) CSS 432: Applications 25
- Slides: 25