05 FTP Email and DNS 2 Application Layer

  • Slides: 30
Download presentation
05 - FTP, Email, and DNS 2: Application Layer 1

05 - FTP, Email, and DNS 2: Application Layer 1

FTP: the File Transfer Protocol user at host FTP user client interface file transfer

FTP: the File Transfer Protocol user at host FTP user client interface file transfer local file system FTP server remote file system r transfer file to/from remote host r client/server model client: side that initiates transfer (either to/from remote) m server: remote host r ftp: RFC 959 r ftp server: port 21 m 2: Application Layer 2

FTP: separate control, data connections TCP control connection port 21 r FTP client contacts

FTP: separate control, data connections TCP control connection port 21 r FTP client contacts FTP r r server at port 21, specifying TCP as transport protocol Client obtains authorization over control connection Client browses remote directory by sending commands over control connection. When server receives a command for a file transfer, the server opens a TCP data connection to client After transferring one file, server closes connection. FTP client TCP data connection port 20 FTP server r Server opens a second TCP data connection to transfer another file. r Control connection: “out of band” r FTP server maintains “state”: current directory, earlier authentication 2: Application Layer 3

Sample commands r sent as ASCII text over control channel r Authentication m USER:

Sample commands r sent as ASCII text over control channel r Authentication m USER: specify the user name to log in as m PASS: specify the user’s password r Exploring the files m LIST: list the files for the given file specification m CWD: change to the given directory r Downloading and uploading files m TYPE: set type to ASCII (A) or binary image (I) m RETR: retrieve the given file m STOR: upload the given file r Closing the connection m QUIT: close the FTP connection 2: Application Layer 4

Why two connections? r Avoids need to mark the end of the data transfer

Why two connections? r Avoids need to mark the end of the data transfer m Data transfer ends by closing of data connection m Yet, the control connection stays up r Aborting a data transfer m Can abort a transfer without killing the control connection m … which avoids requiring the user to log in again m Done with an ABOR on the control connection r Third-party file transfer between two hosts m Data connection could go to a different host m … by sending a different client IP address to the server m E. g. , user coordinates transfer between two servers m But: this is rarely needed, and presents security issues 2: Application Layer 6

FTP, SFTP r FTP is not secure – nothing is encrypted! r SFTP uses

FTP, SFTP r FTP is not secure – nothing is encrypted! r SFTP uses SSH, and should be used instead of FTP when possible. 2: Application Layer 7

Electronic Mail outgoing message queue user mailbox user agent Three major components: r user

Electronic Mail outgoing message queue user mailbox user agent Three major components: r user agents r mail servers mail server SMTP r simple mail transfer protocol: SMTP User Agent r a. k. a. “mail reader” r composing, editing, reading mail messages r e. g. , Apple Mail, Outlook, elm r outgoing, incoming messages stored on server SMTP mail server user agent SMTP user agent mail server user agent 2: Application Layer 8

Electronic Mail: mail servers user agent Mail Servers r mailbox contains incoming messages for

Electronic Mail: mail servers user agent Mail Servers r mailbox contains incoming messages for user r message queue of outgoing (to be sent) mail messages r SMTP protocol between mail servers to send email messages m client: sending mail server m “server”: receiving mail server SMTP mail server user agent SMTP user agent mail server user agent 2: Application Layer 9

Scenario: Alice sends message to Bob 4) SMTP client sends Alice’s message over the

Scenario: Alice sends message to Bob 4) SMTP client sends Alice’s message over the TCP connection 5) Bob’s mail server places the message in Bob’s mailbox 6) Bob invokes his user agent to read message 1) Alice uses UA to compose message and “to” bob@someschool. edu 2) Alice’s UA sends message to her mail server; message placed in message queue 3) Client side of SMTP opens TCP connection with Bob’s mail server 1 user agent 2 mail server 3 mail server 4 5 6 user agent 2: Application Layer 10

Electronic Mail: SMTP [RFC 2821] r uses TCP to reliably transfer email message from

Electronic Mail: SMTP [RFC 2821] r uses TCP to reliably transfer email message from client to server, port 25 r direct transfer: sending server (client) to receiving server (server) r three phases of transfer m handshaking (greeting) m transfer of messages m closure r command/response interaction m commands: ASCII text m response: status code and phrase r messages must be in 7 -bit ASCII 2: Application Layer 11

Sample SMTP interaction >telnet hamburger. edu 25 S: 220 hamburger. edu C: HELO crepes.

Sample SMTP interaction >telnet hamburger. edu 25 S: 220 hamburger. edu C: HELO crepes. fr S: 250 Hello crepes. fr, pleased to meet you Handshake C: MAIL FROM: <alice@crepes. fr> S: 250 alice@crepes. fr. . . Sender ok C: RCPT TO: <bob@hamburger. edu> S: 250 bob@hamburger. edu. . . Recipient ok C: DATA S: 354 Enter mail, end with ". " on a line by itself C: Do you like ketchup? C: How about pickles? C: . S: 250 Message accepted for delivery C: QUIT S: 221 hamburger. edu closing connection 2: Application Layer 12

SMTP: final words r SMTP uses persistent connections r SMTP requires message (header &

SMTP: final words r SMTP uses persistent connections r SMTP requires message (header & body) to be in 7 bit ASCII r SMTP server uses CRLF to determine end of message Comparison with HTTP: r HTTP: pull r SMTP: push r both have ASCII command/response interaction, status codes r HTTP: each object encapsulated in its own response msg r SMTP: multiple objects sent in multipart msg 2: Application Layer 13

Mail message format SMTP: protocol for exchanging email msgs RFC 822: standard for text

Mail message format SMTP: protocol for exchanging email msgs RFC 822: standard for text message format: r header lines, e. g. , To: m From: m Subject: different from SMTP commands! m header blank line body r body m the “message”, ASCII characters only 2: Application Layer 14

Message format: multimedia extensions r MIME: Multipurpose Internet Mail Extension, RFC 2045, 2056 r

Message format: multimedia extensions r MIME: Multipurpose Internet Mail Extension, RFC 2045, 2056 r additional lines in msg header declare MIME content type MIME version method used to encode data multimedia data type, subtype, parameter declaration encoded data From: alice@crepes. fr To: bob@hamburger. edu Subject: Picture of yummy crepe. MIME-Version: 1. 0 Content-Transfer-Encoding: base 64 Content-Type: image/jpeg base 64 encoded data. . . . . base 64 encoded data 2: Application Layer 15

MIME types Content-Type: type/subtype; parameters Text r example subtypes: plain, html Image r example

MIME types Content-Type: type/subtype; parameters Text r example subtypes: plain, html Image r example subtypes: jpeg, gif Audio r example subtypes: basic Video r example subtypes: mpeg, quicktime Application r other data that must be processed by reader before “viewable” r example subtypes: msword, octet-stream (8 -bit mu-law encoded), 32 kadpcm (32 kbps coding) 2: Application Layer 16

Multipart Type From: alice@crepes. fr To: bob@hamburger. edu Subject: Picture of yummy crepe. MIME-Version:

Multipart Type From: alice@crepes. fr To: bob@hamburger. edu Subject: Picture of yummy crepe. MIME-Version: 1. 0 Content-Type: multipart/mixed; boundary=Start. Of. Next. Part --Start. Of. Next. Part Dear Bob, Please find a picture of a crepe. --Start. Of. Next. Part Content-Transfer-Encoding: base 64 Content-Type: image/jpeg base 64 encoded data. . . . . base 64 encoded data --Start. Of. Next. Part Do you want the recipe? 2: Application Layer 17

Mail access protocols user agent SMTP sender’s mail server access protocol user agent receiver’s

Mail access protocols user agent SMTP sender’s mail server access protocol user agent receiver’s mail server r SMTP: delivery/storage to receiver’s server r Mail access protocol: retrieval from server m POP: Post Office Protocol [RFC 1939] • TCP, port 110 m m • authorization (agent <-->server) and download IMAP: Internet Mail Access Protocol [RFC 1730] • more features (more complex) • manipulation of stored msgs on server HTTP: gmail, Hotmail , Yahoo! Mail, etc. 2: Application Layer 18

POP 3 protocol authorization phase r client commands: m m user: declare username pass:

POP 3 protocol authorization phase r client commands: m m user: declare username pass: password r server responses m m +OK -ERR transaction phase, client: r list: list message numbers r retr: retrieve message by number r dele: delete r Quit Update phase- server deletes files. S: C: S: +OK POP 3 server ready user bob +OK pass hungry +OK user successfully logged C: S: S: S: C: C: S: list 1 498 2 912. retr 1 <message 1 contents>. dele 1 retr 2 <message 1 contents>. dele 2 quit +OK POP 3 server signing off 2: Application Layer 19 on

POP 3 (more) and IMAP More about POP 3 r Previous example uses “download

POP 3 (more) and IMAP More about POP 3 r Previous example uses “download and delete” mode. r Bob cannot re-read email if he changes client r “Download-and-keep”: copies of messages on different clients r POP 3 is stateless across sessions IMAP r Keep all messages in one place: the server r Allows user to organize messages in folders r IMAP keeps user state across sessions: m names of folders and mappings between message IDs and folder name r Can also download only portions of a message e. g. headers 2: Application Layer 20

Web-based E-mail r User agent: browser r Use HTTP to send e-mail to server

Web-based E-mail r User agent: browser r Use HTTP to send e-mail to server and receive e-mail from server. r SMTP between servers. 2: Application Layer 21

DNS: Domain Name System people: many identifiers: m SSN, name, passport # Internet hosts,

DNS: Domain Name System people: many identifiers: m SSN, name, passport # Internet hosts, routers: m m IP address (32 bit) - used for addressing datagrams “name”, e. g. , www. yahoo. com - used by humans Q: map between IP address and name, and vice versa ? www. rose-hulman. edu DNS 137. 112. 18. 43 22

DNS services r hostname to IP address translation r host aliasing m Canonical, alias

DNS services r hostname to IP address translation r host aliasing m Canonical, alias names r mail server aliasing r Core Internet function implemented as application layer protocol r load distribution m replicated Web servers: set of IP addresses for one canonical name Why not centralize DNS? r single point of failure r traffic volume r distant centralized database r maintenance r doesn’t scale! 23

DNS name servers DNS is a distributed database implemented in hierarchy of many name

DNS name servers DNS is a distributed database implemented in hierarchy of many name servers r no server has all name-to- IP address mappings r local name servers: m m each ISP, company has local (default) name server host DNS query first goes to local name server r authoritative name server: m m for a host: stores that host’s IP address, name can perform name/address translation for that host’s name 2: Application Layer 24

Distributed, Hierarchical Database Root DNS Servers com DNS servers yahoo. com amazon. com DNS

Distributed, Hierarchical Database Root DNS Servers com DNS servers yahoo. com amazon. com DNS servers org DNS servers pbs. org DNS servers edu DNS servers poly. edu umass. edu DNS servers client wants IP for www. amazon. com; 1 st approx: r client queries a root server to find com DNS server r client queries com DNS server to get amazon. com DNS server r client queries amazon. com DNS server to get IP address for www. amazon. com 25

DNS: Root name servers r contacted by local name server that can not resolve

DNS: Root name servers r contacted by local name server that can not resolve name r root name server: m m m contacts authoritative name server if name mapping not known gets mapping returns mapping to local name server a NSI Herndon, VA c PSInet Herndon, VA d U Maryland College Park, MD g DISA Vienna, VA h ARL Aberdeen, MD j NSI (TBD) Herndon, VA k RIPE London i NORDUnet Stockholm m WIDE Tokyo e NASA Mt View, CA f Internet Software C. Palo Alto, CA b USC-ISI Marina del Rey, CA l ICANN Marina del Rey, CA Zonefile stored at a root server 13 root name servers worldwide (actually > 80 using anycasting) 2: Application Layer 26

Simple DNS example host surf. eurecom. fr wants IP address of gaia. cs. umass.

Simple DNS example host surf. eurecom. fr wants IP address of gaia. cs. umass. edu root name server 2 5 1. contacts its local DNS server, dns. eurecom. fr 2. dns. eurecom. fr contacts local name server dns. eurecom. fr root name server, if necessary 1 6 3. root name server contacts authoritative name server, dns. umass. edu, if requesting host necessary surf. eurecom. fr 3 4 authoritative name server dns. cs. umass. edu gaia. cs. umass. edu 2: Application Layer 27

DNS example root name server Root name server: r may not know authoritative name

DNS example root name server Root name server: r may not know authoritative name server r may know intermediate name server: who to contact to find authoritative name server 6 2 7 local name server dns. eurecom. fr 1 8 requesting host 3 intermediate name server dns. umass. edu 4 5 authoritative name server dns. cs. umass. edu surf. eurecom. fr gaia. cs. umass. edu 2: Application Layer 28

DNS: iterated queries recursive query: 2 r puts burden of name resolution on contacted

DNS: iterated queries recursive query: 2 r puts burden of name resolution on contacted name server r heavy load? iterated query: r contacted server replies with name of server to contact r “I don’t know this name, but ask this server” root name server iterated query 3 4 7 local name server dns. eurecom. fr 1 8 requesting host intermediate name server dns. umass. edu 5 6 authoritative name server dns. cs. umass. edu surf. eurecom. fr gaia. cs. umass. edu 2: Application Layer 29

DNS: caching and updating records r once (any) name server learns mapping, it caches

DNS: caching and updating records r once (any) name server learns mapping, it caches mapping m cache entries timeout (disappear) after some time r If the TLD servers and intermediate DNS servers perform their functions correctly, the root servers will rarely be contacted. 2: Application Layer 30

DNS records DNS: distributed db stores resource records (RR) RR format: (name, value, type,

DNS records DNS: distributed db stores resource records (RR) RR format: (name, value, type, ttl) r Type=A m name is hostname m value is IP address r Type=CNAME m name is alias name for some “canonical” (the real) name www. ibm. com is really r Type=NS servereast. backup 2. ibm. com m name is domain (e. g. m value is canonical name foo. com) m value is IP address of r Type=MX authoritative name server m value is name of mailserver for this domain associated with name Use “nslookup” and “dig” to see RRs. 2: Application Layer 31