FTP: the file transfer protocol at host FTP interface FTP client local file system file transfer FTP remote file system transfer file to/from remote host client/ model client: side that initiates transfer (either to/from remote) : remote host ftp: RFC 959 ftp : port 21 2: Application Layer 1 FTP: separate control, data connections FTP client contacts FTP 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 receives a command for a file transfer, the opens a TCP data connection to client After transferring one file, closes connection. FTP client TCP control connection port 21 TCP data connection port 20 FTP Control connection: out of band FTP maintains state : current directory, earlier authentication 2: Application Layer 2
FTP commands, responses Sample commands: sent as ASCII text over control channel USER name PASS password LIST return list of file in current directory RETR filename retrieves (gets) file STOR filename stores (puts) file onto remote host Sample return codes status code and phrase (as in HTTP) 331 Username OK, password required 125 data connection already open; transfer starting 425 Can t open data connection 452 Error writing file 2: Application Layer 3 Electronic Mail Four major components: s s simple transfer protocol: SMTP access protocols: POP3, IMAP User Agent a.k.a. reader composing, editing, reading messages e.g., Eudora, Outlook, elm, Netscape Messenger outgoing, incoming messages stored on SMTP SMTP SMTP SMTP/POP3 SMTP/POP3 outgoing message queue box SMTP/IMAP 2: Application Layer 4
Electronic Mail: s Mail Servers box contains incoming messages for message queue of outgoing (to be sent) messages SMTP protocol between s to send e messages client: sending : receiving SMTP SMTP SMTP 2: Application Layer 5 Electronic Mail: SMTP [RFC 2821] uses TCP to reliably transfer e message from client to, port 25 direct transfer: sending to receiving three phases of transfer handshaking (greeting) transfer of messages closure command/response interaction commands: ASCII text response: status code and phrase messages must be in 7-bit ASCII 2: Application Layer 6
Scenario: Alice sends message to Bob 1) Alice uses UA to compose message and to bob@someschool.edu 2) Alice s UA sends message to her ; message placed in message queue using SMTP 3) Client side of SMTP opens TCP connection with Bob s 4) SMTP client sends Alice s message over the TCP connection 5) Bob s places the message in Bob s box 6) Bob invokes his to read message using POP3, IMAP 1 2 3 4 5 6 2: Application Layer 7 Sample SMTP interaction S: 220 hamburger.edu C: HELO crepes.fr S: 250 Hello crepes.fr, pleased to meet you 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, 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 8
Try SMTP interaction for yourself: telnet name 25 see 220 reply from enter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands above lets you send e without using e client (reader) 2: Application Layer 9 SMTP: final words SMTP uses persistent connections SMTP requires message (header & body) to be in 7- bit ASCII SMTP uses CRLF.CRLF to determine end of message Comparison with HTTP: HTTP: pull SMTP: push both have ASCII command/response interaction, status codes HTTP: each object encapsulated in its own response msg SMTP: multiple objects sent in multipart msg 2: Application Layer 10
Mail message format SMTP: protocol for exchanging e msgs RFC 822: standard for text message format: header lines, e.g., To: From: Subject: different from SMTP commands! body the message, ASCII characters only header body blank line 2: Application Layer 11 Message format: multimedia extensions MIME: multimedia extension, RFC 2045, 2056 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: base64 Content-Type: image/jpeg base64 encoded data.........base64 encoded data 2: Application Layer 12
MIME types Content-Type: type/subtype; parameters Text example subtypes: plain, html Video example subtypes: mpeg, quicktime Image example subtypes: jpeg, gif Audio exampe subtypes: basic (8-bit mu-law encoded), 32kadpcm (32 kbps coding) Application other data that must be processed by reader before viewable example subtypes: msword, octet-stream 2: Application Layer 13 Multipart Type From: alice@crepes.fr To: bob@hamburger.edu Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=startofnextpart --StartOfNextPart Dear Bob, Please find a picture of a crepe. --StartOfNextPart Content-Transfer-Encoding: base64 Content-Type: image/jpeg base64 encoded data.........base64 encoded data --StartOfNextPart Do you want the reciple? 2: Application Layer 14
Mail access protocols SMTP SMTP access protocol sender s receiver s SMTP: delivery/storage to receiver s Mail access protocol: retrieval from POP: Post Office Protocol [RFC 1939] authorization ( <-->) and download IMAP: Internet Mail Access Protocol [RFC 1730] more features (more complex) manipulation of stored msgs on HTTP: Hot, Yahoo! Mail, etc. 2: Application Layer 15 POP3 protocol authorization phase client commands: : declare name pass: password responses +OK -ERR transaction phase, client: list: list message numbers retr: retrieve message by number dele: delete quit S: +OK POP3 ready C: bob S: +OK C: pass hungry S: +OK successfully logged on C: list S: 1 498 S: 2 912 S:. C: retr 1 S: <message 1 contents> S:. C: dele 1 C: retr 2 S: <message 1 contents> S:. C: dele 2 C: quit S: +OK POP3 signing off 2: Application Layer 16
POP3 (more) and IMAP More about POP3 Previous example uses download and delete mode. Bob cannot re-read e- if he changes client (or location) Download-and-keep : copies of messages on different clients POP3 is stateless across sessions IMAP Keep all messages in one place: the Allows to organize messages in folders IMAP keeps state across sessions: names of folders and mappings between message IDs and folder name 2: Application Layer 17 DNS: Domain Name System People: many identifiers: SSN, name, passport # Internet hosts, routers: IP address (32 bit) - used for addressing datagrams name, e.g., gaia.cs.umass.edu - used by humans Q: map between IP addresses and name? Domain Name System: distributed database implemented in hierarchy of many name s application-layer protocol host, routers, name s to communicate to resolve names (address/name translation) note: core Internet function, implemented as application-layer protocol complexity at network s edge 2: Application Layer 18
DNS name s Why not centralize DNS? single point of failure traffic volume distant centralized database maintenance doesn t scale! no has all nameto-ip address mappings local name s: each ISP, company has local (default) name host DNS query first goes to local name authoritative name : for a host: stores that host s IP address, name can perform name/address translation for that host s name 2: Application Layer 19 DNS: Root name s contacted by local name that can not resolve name root name : contacts authoritative name if name mapping not known gets mapping returns mapping to local name 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 13 root name s worldwide 2: Application Layer 20
Simple DNS example root name host surf.eurecom.fr wants IP address of gaia.cs.umass.edu 1. contacts its local DNS, dns.eurecom.fr 2. dns.eurecom.fr contacts root name, if necessary 3. root name contacts authoritative name, dns.umass.edu, if necessary local name dns.eurecom.fr 1 2 6 requesting host surf.eurecom.fr 5 3 4 authorititive name dns.umass.edu gaia.cs.umass.edu 2: Application Layer 21 DNS example root name Root name : may not know authoritative name may know intermediate name : who to contact to find authoritative name local name dns.eurecom.fr 1 2 8 requesting host surf.eurecom.fr 7 3 6 intermediate name dns.umass.edu 4 5 authoritative name dns.cs.umass.edu gaia.cs.umass.edu 2: Application Layer 22
DNS: iterated queries root name recursive query: puts burden of name resolution on contacted name heavy load? iterated query: contacted replies with name of to contact I don t know this name, but ask this local name dns.eurecom.fr 1 2 8 requesting host surf.eurecom.fr 3 4 7 iterated query intermediate name dns.umass.edu 5 6 authoritative name dns.cs.umass.edu gaia.cs.umass.edu 2: Application Layer 23 DNS: caching and updating records once (any) name learns mapping, it caches mapping cache entries timeout (disappear) after some time update/notify mechanisms under design by IETF RFC 2136 http://www.ietf.org/html.charters/dnsind-charter.html 2: Application Layer 24
DNS records DNS: distributed db storing resource records (RR) RR format: (name, value, type,ttl) Type=A name is hostname value is IP address Type=NS name is domain (e.g. foo.com) value is IP address of authoritative name for this domain Type=CNAME name is alias name for some cannonical (the real) name www.ibm.com is really east.backup2.ibm.com value is cannonical name Type=MX value is name of associated with name 2: Application Layer 25 DNS protocol, messages DNS protocol : query and reply messages, both with same message format msg header identification: 16 bit # for query, reply to query uses same # flags: query or reply recursion desired recursion available reply is authoritative 2: Application Layer 26
DNS protocol, messages Name, type fields for a query RRs in reponse to query records for authoritative s additional helpful info that may be used 2: Application Layer 27 Web caches (proxy ) Goal: satisfy client request without involving origin 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, then returns object to client client client HTTP request HTTP response HTTP request HTTP response Proxy HTTP request HTTP response origin origin 2: Application Layer 28
Why Web Caching? Assume: cache is close to client (e.g., in same network) lower response time: cache closer to client decrease traffic to distant s link out of institutional/local ISP network often bottleneck institutional network public Internet 1.5 Mbps access link 10 Mbps LAN origin s institutional cache 2: Application Layer 29 More about Web caching Cache acts as both client and Cache can do up-to-date check using If-modifiedsince HTTP header Issue: should cache take risk and deliver cached object without checking? Heuristics are used Typically cache is installed by ISP (university, company, residential ISP) Where should caches be placed? institutional network public Internet 1.5 Mbps access link 10 Mbps LAN origin s institutional cache 2: Application Layer 30