View
215
Download
0
Category
Tags:
Preview:
Citation preview
CSS432: Applications 1
CSS432 ApplicationsTextbook Ch 9.1
Professor: Munehiro Fukuda
Augmented by Rob Nash
Protocols and Companions
HTTP defines a GET/PUT protocolFor file distribution
HTML defines the data formatA companion descriptor or protocol
SMTP – defines a mail moving protocolRFC 822 – companion format description ASCIIMIME – companion to extend ASCII
CSS432: Applications 2
CSS432: Applications 3
Applications Client – Server Paradigm
Client: initiates contact with server Server: provides client with a
response Applications use their corresponding
protocol Defined in RFC by Internet
Engineering Task Force(http://www.ietf.org/)
Implemented on top of TCP or UDP
Applications Protocol
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
TCP withbuffers,variables
socket
TCP withbuffers,variables
socket
Internet
mail/webserver
SMTP, HTTP, FTP
outlookbrowser
SMTP, HTTP, FTP
Client Server
CSS432: Applications 4
Name Service
Hostscheltenham.cs.princeton.edu 192.12.69.17
192.12.69.17 80:23:A8:33:5B:9F Files
/usr/llp/tmp/foo (server, inode)
Users Larry Peterson llp@cs.princeton.edu
(UID + host IP)
Name ServerName• Variable length and mnemonic• Location independent
Value• System-provided fixed value• Location dependent
DNS
CSS432: Applications 5
Name service (cont) lpr/a2ps commands
Unix system call struct hostent h = gethostbyname( const char *hostname ); *(struct in_addr *)*h->h_addr_list; // returns IP list
Nameserver
lprprogram
User
TCP
IP
2uw1-320-p1
216.186.75.218
3
lpr –Puw1-320-p1 manual.ps1
216.186.75.218 4
216.186.75.218 5
DNS
CSS432: Applications 6
Domain Naming System Hierarchy
Nameuw1-320-00.bothell.washington.edu
edu com
washington … mit
ucs
uw1-320-00 medusa
bothell
cisco … yahoo nasa … nsf arpa … navy acm … ieee
gov mil org net uk fr
homer goodall
DNS
CSS432: Applications 7
Name Servers Partition hierarchy into zones
Rootname server
washingtonname server
Cisconame server
bothellname server
csname server
…
…
Each zone implemented by two or more name servers
edu com
washington … mit
ucs
uw1-320-00 medusa
bothell
cisco … yahoo nasa … nsf arpa … navy acm … ieee
gov mil org net uk fr
homer goodall
Network Information Center manages
Managed by UW C&C
administrativeunit
DNS
CSS432: Applications 8
Resource Records Each name server maintains a collection of resource
records
(Name, Value, Type, Class, TTL)
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
Class: IN (Internet class) TTL: how long the resource record is valid
DNS
CSS432: Applications 9
Name Servers From Root to Bottom Level
Find a root name server dig edu ns
edu a3.nstld.com NS IN a3.nstld.com 192.5.6.32 A IN
Find uwb.edu’s name servers dig @192.5.6.32 uwb.edu ns
uwb.edu, DNS1.uwb.edu NS IN uwb.edu, DNS2.uwb.edu NS IN DNS1.uwb.edu 216.186.73.6 A DNS2.uwb.edu 216.186.73.7 A
Find mercury.uwb.edu dig @216.186.73.6 mercury.uwb.edu A
mercury.uwb.edu 216.186.72.15 A
DNS
CSS432: Applications 10
Name Resolution Client
Initialized with its local name server’s address
appends its domain name to a given name before a submission.
Local server needs to know root at only one place
(not each host). caches recent responses from
remote servers.
Rootnameserver
Princetonnameserver
CSnameserver
Localnameserver
Client
1cicada.cs.princeton.edu
192.12.69.608
cicada.cs.princeton.edu
princeton.edu, 128.196.128.233
cicada.cs.princeton.edu
cicada.cs.princeton.edu,
192.12.69.60
cicada.cs.princeton.edu
cs.princeton.edu, 192.12.69.5
2
3
4
5
6
7
DNS
CSS432: Applications 11
Electronic Mail (SMTP, MIME, IMAP)Email
mail server
outgoingmail queue
User mailbox
useragent
useragent
mail server
outgoingmail queue
mail server
outgoingmail queue
User mailbox
useragent
useragent
useragent
useragent
SMTP/TCP SMTP/TCP
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
CSS432: Applications 12
SMTPEmail
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
CSS432: Applications 13
SMTP Example[mfukuda@uw1-320-20]$ telnet smtp.washington.edu 25Trying 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+UW04.02/8.12.11+UW04.02; Sat, 21Feb 2004 20:00:56 -0800HELO mfukuda250 smtp.washington.edu Hello UW1-320-20.bothell.washington.edu [216.186.75.195], pleased to meet youMAIL FROM:mfukuda@u.washington.edu250 2.1.0 <mfukuda@u.washington.edu>... Sender okRCPT TO:MunehiroFukuda@yahoo.net250 2.1.5 MunehiroFukuda@yahoo.net... Recipient okDATA354 Enter mail, end with “.” on a line by iteselfBlah blah blah……etc. etc. etc..250 2.0.0 i1M40uc3013699 Message accepted fro deliveryQUIT221 2.0.0 smtp.washington.edu closing connectionConnection closed by foreign host.[mfukuda@uw1-320-20]$ _
CSS432: Applications 14
RFC 822 Message Format
Header A series of line<crlf>s
Body ASCII characters only.
Then, what about multimedia information?
HeaderTo:Subject:Date:From:Received:
Body
A blank line
CSS432: Applications 15
MIME MIME: multimedia mail extension, RFC 2045, 2056 Additional lines in msg header declare MIME content type
MIME-Version: 1.0Content-Type: multipart/mixed; boundary=“-------417CA6E2DE4ABCAFBC5”From: mfukuda@u.washington.eduTo: css432a_au04@u.washington.eduSubject: promised materialDate: Mon, 01 Apr 2004 12:34:56 -0800
-------417CA6E2DE4ABCAFBC5Content-Type: text/plain; charset=us-asciiContent-Transfer-Encoding: 7bit
Dear CSS432 students,Here is the jpeg image and draft report I promised.-- Fukuda
-------417CA6E2DE4ABCAFBC5Content-Type: image/jpegContent-Transfer-Encoding: base64
… Unreadable encoding of a jpeg figure
-------417CA6E2DE4ABCAFBC5
Content-Type: application/postscript; name=“draft.ps”Content-Transfer-Encoding: 7bit
… Readable encoding of a postscript document
Type of the data
How the data is encoded
Definitions for content types
Carry more than one data type
3bytes = 3 * 8bits = 24bits = 4 * 6bit-chars, each mapped onto
one of 64 ASCII chars (A~Z,a~z,0~9,+,/)
CSS432: Applications 16
Mail Reader - IMAPEmail
Connection established
Server greeting
Not authenticated
Authenticated
Selected
Logout
Both sides close the connection
TCP to 143
Server: OK Server: PREAUTH Server: BYE
Client: LOGIN or AUTHENTICATEClient LOGOUT
Client LOGOUT
Client LOGOUT
Client SELECT or EXAMINE
Client: CLOSE
Client: FETCH, STORE, DELETE, EXPUNGE
CSS432: Applications 17
File Transfer Protocol
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.
FTP
localfile
system
remotefile
system
FTPserver
FTPclient
FTPuser
interface TCP port 20 for data transfer(not persistent)
TCP port 21 for control (persistent)
CSS432: Applications 18
FTP Commands <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.
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
FTP
CSS432: Applications 19
FTP ExampleFTP
[mfukuda@uw1-320-20]$ telnet ftp.tripod.com 21Trying 209.202.240.80…Connected to ftp.tripod.com (209.202.240.80).Escape character is ‘^]’.220 Welcome to Tripod FTP.USER css432331 Username set to css432. Now enter your password.PASS ********230 User ‘css432’ logged on.LIST425 Can’t open data connection for LIST.PASV227 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 css432 Tripod 0 Sep 15 21:22 cgi-bin// -rw-r--r-- 1 css432 Tripod 26169 Sep 16 18:28 ttcp.c// -rw-r--r-- 1 css432 Tripod 8236 Sep 15 21:22 index.htm// drwxr-xr-x 1 css432 Tripod 0 Sep 16 18:33 project // Connection closed by foreign host.LIST150 Opening ASCII mode data connection for LIST.226 Transfer complete.QUIT221 GoodbyeConnection closed by foreign host.[mfukuda@uw1-320-20]$ _
CSS432: Applications 20
FTP passive mode
FTPserver
FTPclient
TCP port 21 for control (persistent)
Client request: connect( ), USER, PASS, LIST
Server Reply: 220 server ready, 331 send password, 230 login ok, 425 connection timeout
TCP port 20 for data transfer (one time)
FTPserver
FTPclient
TCP port 21 for control (persistent)
Client request: connect( ), USER, PASS, PASV, LIST
Server Reply: 220 server ready, 331 send password, 230 login ok,227 Entering Passive Mode (140,142,12,173,195,54), 226 complete
TCP port 195*256 + 54 = 49974 for data transfer (one time)
data
CSS432: Applications 21
FTP proxy command
FTPServer
2
FTPServer
1
FTPclient
(1) USER, PASS, SYST (2) USER, PASS, SYST(3) TYPE I, PASV
(4) TYPE I, PORT (140,142,12,173,195,54),STOR file(5) RETR file
(3’) 227 Entering Passive Mode(140,142,12,173,195,54)
TCP port 195*256 + 54 = 49974 for data transfer (one time)
data
ftp> open server1ftp> proxy open server2ftp> proxy get file
…(1)…(2)…(3)~(5)
CSS432: Applications 22
World Wide Web - HTTP
Hypertext Transfer Protocol: one-time 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
Web
/public_html
HTTPserver
NetscapeTCP port 80 (one-time connection)
IE
TCP port 80 (one-tim
e connection)HTTP requestHTTP response
CSS432: Applications 23
HTTP CommandsWeb
Client Initiates a TCP connection to a server on port 80. Sends an HTTP request over this TCP connection
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.
1xx: Informational 2xx: success 3xx: Redirection 4xx: Client error 5xx: Server error
CSS432: Applications 24
HTTP Example
[mfukuda@uw1-320-20]$ telnet www.uwb.edu 80Trying 216.186.72.12…Connected to jupiter.uwb.edu (216.186.72.12).Escape character is ‘^]’.GETHTTP/1.1 200 OKDate: Sun, 22 Feb 2004 09:06:17 GMTServer: Apache/1.3.28 (Unix) PHP/4.3.3 mod_perl/1.29 mod_backhand/1.2.2Connection: closeContent-type: text/html
<!doctype html public “-//W3C/DTD HTML 4.0 Transitional//EN”><html><head> … </body></html>
Connection closed by foreign host.[mfukuda@uw1-320-20]$ _
Web
CSS432: Applications 25
Performance Improvement in Web Persistent TCP connections
Advantages Eliminate the connection setup overhead Eliminate repetitions of slow start phase
Disadvantages 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
Reduce the number of HTTP accesses Disadvantages
Need to purge out-of-date version of pages – use expiration date and cache directives to cache or not to cache a given page
Web
CSS432: Applications 26
Reviews RFC Naming service: DNS Email: SMTP, MIME, and IMAP File transfer: FTP WWW: HTTP
Exercises: try the following examples by yourself. Slide p8 (DNS) Slide p12 (SMTP) Slide p18 (FTP) Slide p21 (HTTP)
Recommended