41
1 CSE 524: Lecture 15 Application layer (Part 2)

1 CSE 524: Lecture 15 Application layer (Part 2)

Embed Size (px)

Citation preview

Page 1: 1 CSE 524: Lecture 15 Application layer (Part 2)

1

CSE 524: Lecture 15

Application layer (Part 2)

Page 2: 1 CSE 524: Lecture 15 Application layer (Part 2)

2

Administrative

• Homework #5– Due today

• Programming assignment– Due Monday, 12/1

• Reading assignment Chapter 2– Due Monday, 11/24

• Thanksgiving holiday– Lecture on Wednesday 11/26– Potentially optional

• Who will be here?• What would you like to hear more about?

Page 3: 1 CSE 524: Lecture 15 Application layer (Part 2)

3

Application Layer

• So far– Application layer functions

– Specific applications• HTTP

• Today– More applications

• DNS

• FTP

• SMTP/POP

• P2P

Page 4: 1 CSE 524: Lecture 15 Application layer (Part 2)

4

AL: Domain Name System (DNS)

• Internet hosts, routers like to use fixed length addresses (numbers)– IP address (32 bit) - used for addressing datagrams

• Humans like to use names– www.cse.ogi.edu

– keywords

• DNS, keywords, naming protocols– Map from IP addresses to names

– Map from names to IP addresses

Page 5: 1 CSE 524: Lecture 15 Application layer (Part 2)

5

AL: Original Name to Address Mapping

• Flat namespace– /etc/hosts

– SRI kept main copy

– Downloaded regularly

• Problems– Count of hosts was increasing: machine per domain

machine per user• Many more downloads

• Many more updates

Page 6: 1 CSE 524: Lecture 15 Application layer (Part 2)

6

AL: Goals for a new naming system

• Implement a wide area distributed database– Scalability

– Decentralized maintenance

– Robustness, fault-tolerance

– Global scope • Names mean the same thing everywhere

– Don’t need• Atomicity

• Strong consistency

Page 7: 1 CSE 524: Lecture 15 Application layer (Part 2)

7

AL: Goals for a new naming system

Why not centralize DNS?• Single server with all name-to-IP address mappings

– single point of failure

– traffic volume

– distant centralized database (performance)

– maintenance

– doesn’t scale!

Page 8: 1 CSE 524: Lecture 15 Application layer (Part 2)

8

AL: DNS (Domain Name System)

• http://www.rfc-editor.org/rfc/rfc1034.txt

• http://www.rfc-editor.org/rfc/rfc1035.txt

• distributed database implemented in hierarchy of many name servers

• decentralized control and management of data

• application-layer protocol used by hosts and name servers– communicate to resolve names (address/name translation)

– core Internet function implemented as application-layer protocol• complexity at network’s “edge”

• compare to phone network naming

Page 9: 1 CSE 524: Lecture 15 Application layer (Part 2)

9

AL: DNS nutshell solution

• Hierarchical canonical name space – www.cse.ogi.edu

root

edunetorg ukcom ca

gwu ucb ogi bu mit

cse ece

www

Page 10: 1 CSE 524: Lecture 15 Application layer (Part 2)

10

AL: DNS nutshell solution

• Authoritative name servers store parts of the database – Names assigned to authoritative name servers

• For a host, authority stores that host’s IP address, name• Responds to queries for host’s IP address• Perform name/address translation for that host’s name

– Root name server knows authoritative servers for particular subdomains• Hierarchy organizes authoritative name servers• Reserving a domain gives you control of entry in root name server for

particular names

• DNS hierarchical lookup– Each host has a pointer to a local name server for which to query for

unknown names– Each local name server knows root of hierarchy– Root points to sub-levels, sub-levels point to deeper sub-levels, … , deeper

sub-levels point to leaf name server representing authority for unknown name

Page 11: 1 CSE 524: Lecture 15 Application layer (Part 2)

11

AL: DNS nutshell figure

Root name servers:• may not know authoratiative name

server• may know intermediate name

server: who to contact to find authoritative name server

• multiple root name servers for fault-tolerance

Example:• surf.eurecom.fr wants to talk to

gaia.cs.umass.edu– contact local dns server– local dns contacts root– root contacts authoritative (or next

level to authoritative)

requesting hostsurf.eurecom.fr

gaia.cs.umass.edu

root name server

local name serverdns.eurecom.fr

1

23

4 5

6

authoritative name serverdns.cs.umass.edu

intermediate name serverdns.umass.edu

7

8

Page 12: 1 CSE 524: Lecture 15 Application layer (Part 2)

12

AL: DNS: Root name servers

• contacted by local name server that can not resolve any part of the name

• root name server:

– contacts authoritative name server if name mapping not known

– gets mapping

– returns mapping to local name server

b USC-ISI Marina del Rey, CAl ICANN Marina del Rey, CA

e NASA Mt View, CAf Internet Software C. Palo Alto, CA

i NORDUnet Stockholm

k RIPE London

m WIDE Tokyo

a NSI Herndon, VAc PSInet Herndon, VAd U Maryland College Park, MDg DISA Vienna, VAh ARL Aberdeen, MDj NSI (TBD) Herndon, VA

13 root name servers worldwide (all that fit in a 512 octet SOA record)

Page 13: 1 CSE 524: Lecture 15 Application layer (Part 2)

13

AL: DNS server name database

• DB contains tuples called resource records (RRs)– RR contains type, class and application data

• Before types added, only one record type (A)

– Classes = Internet (IN), Chaosnet (CH), etc.– Each class defines types, e.g. for IN:

• A = address• NS = name server• CNAME = canonical name (for aliasing)• HINFO = CPU/OS info• MX = mail exchange• PTR = pointer for reverse mapping of address to name

• nslookup example

Page 14: 1 CSE 524: Lecture 15 Application layer (Part 2)

14

AL: DNS MX record type

• MX records point to mail exchanger for a name– E.g. mail.acm.org is MX for acm.org

• Addition of MX record type proved to be a challenge– How to get mail programs to lookup MX record for mail

delivery rather than A record?

– Needed critical mass of such mailers

Page 15: 1 CSE 524: Lecture 15 Application layer (Part 2)

15

AL: DNS record types

Resource records (RR) and their types

• Type=NS– name is domain (e.g. foo.com)– value is IP address of

authoritative name server for this domain

RR format: (name, value, type,ttl)

• Type=A– name is hostname– value is IP address

• Type=CNAME– name is an alias name for

some “cannonical” (the real) name

– value is cannonical name

• Type=MX– value is hostname of mailserver

associated with name

Page 16: 1 CSE 524: Lecture 15 Application layer (Part 2)

16

AL: DNS server database distribution

• Administrative hierarchy– Organized into regions known as “zones”– “.” as separator– zone = contiguous section of name space

• Zones created by convincing owner node to delegate a subzone– umass.edu zone delegates cs.umass.edu to a different set of authoritative

name servers– Each zone contains multiple redundant servers

• Primary (master) name server updated manually• Secondary (redundant) servers updated by zone transfer of name space• Provides fault-tolerance within zone

• Host name to address section– Top-level domains edu, gov, ca, us, etc.– Sub-domains = subtrees– Human readable name = leaf root path

Page 17: 1 CSE 524: Lecture 15 Application layer (Part 2)

17

AL: DNS client lookups

• Each host has a resolver– Typically a library that applications can link gethostbyname()

– Local name servers hand-configured (e.g. /etc/resolv.conf) or automatically configured (DHCP)

• Can specify a file /etc/hosts

• Can specify a name server by its IP address (i.e. 129.95.50.2)

– Host queries local name server for unknown names

• Name servers– Configured with well-known root servers

• Currently {a-m}.root-servers.net

– Local servers• Typically answer queries about local zone

• Typically do a lookup of distant host names for local hosts

Page 18: 1 CSE 524: Lecture 15 Application layer (Part 2)

18

AL: Lookup Methods

• Recursive queries– Server goes out and searches for more info on behalf of the

client (recursive)– Only returns final answer or “not found”– Puts burden of name resolution on contacted name server– Heavy load?

• Root server implosion

• Iterative– Server responds with as much as it knows (i.e. name of

server to contact next)– “I don’t know this name, but ask this server”– Client iteratively queries additional servers

Page 19: 1 CSE 524: Lecture 15 Application layer (Part 2)

19

AL: All recursive DNS example

host surf.eurecom.fr wants IP address of gaia.cs.umass.edu

1. Contacts its local DNS server, dns.eurecom.fr

2. dns.eurecom.fr contacts root name server, if necessary

3. root name server contacts authoritative name server, dns.umass.edu, if necessary

requesting hostsurf.eurecom.fr

gaia.cs.umass.edu

root name server

authorititive name serverdns.umass.edu

local name serverdns.eurecom.fr

1

23

4

5

6

Page 20: 1 CSE 524: Lecture 15 Application layer (Part 2)

20

AL: DNS: iterated queries

recursive query:• puts burden of name

resolution on contacted name server

• heavy load?• root servers now disable

recursive queries (RFC 2010)

iterated query:• contacted server replies

with name of server to contact

• “I don’t know this name, but ask this server” requesting host

surf.eurecom.fr

gaia.cs.umass.edu

root name server

local name serverdns.eurecom.fr

1

23

4

5 6

authoritative name serverdns.cs.umass.edu

intermediate name serverdns.umass.edu

7

8

iterated query

Page 21: 1 CSE 524: Lecture 15 Application layer (Part 2)

21

AL: Typical Resolution

• Client does recursive request to local name server• Local name server does iterative requests to find name• Local name server has knowledge of root servers• Steps for resolving www.ogi.edu

– Application calls gethostbyname()– Resolver contacts local name server (S1)– S1 queries root server (S2) for (www.ogi.edu)– S2 returns NS record for ogi.edu (S3)– S1 queries S3 for www.ogi.edu– S3 returns A record for www.ogi.edu

• Can return multiple addresses what does this mean?• nslookup, named example

– iterative query with tcpdump

Page 22: 1 CSE 524: Lecture 15 Application layer (Part 2)

22

AL: DNS Caching

• DNS responses are cached – Quick response for repeated translations– Other queries may reuse some parts of lookup

• NS records for domains

• DNS negative queries are also cached– Don’t have to repeat past mistakes– E.g. misspellings

• Cached data periodically times out– Soft state– Lifetime (TTL) of data controlled by owner of data– TTL passed with every record– TTL affects DNS-based load balancing techniques

• update/notify mechanisms under design by IETF– RFC 2136– http://www.ietf.org/html.charters/dnsind-charter.html

Page 23: 1 CSE 524: Lecture 15 Application layer (Part 2)

23

AL: DNS Lookup Example

ClientLocal

DNS server

root & edu DNS server

ogi.edu DNS server

www.cse.ogi.edu

NS ogi.eduwww.cse.ogi.edu

NS cs.ogi.edu

www=IPaddr

cse.ogi.eduDNS

server

Page 24: 1 CSE 524: Lecture 15 Application layer (Part 2)

24

AL: Subsequent Lookup Example

ClientLocal

DNS server

root & edu DNS server

ogi.edu DNS server

cse.ogi.eduDNS

server

ftp.cse.ogi.edu

ftp=IPaddr

ftp.cse.ogi.edu

cse.ogi.edu entry cached

Page 25: 1 CSE 524: Lecture 15 Application layer (Part 2)

25

AL: A word about iterated queries and caching

• Recall– Recursive query to local DNS server

– Iterative query from local DNS server on

• Why not do iterative queries from host?– Win2k client

• Does iterative queries from host

– Caching implications?

Page 26: 1 CSE 524: Lecture 15 Application layer (Part 2)

26

AL: DNS/nslookup example

• Real example using nslookup and named– Shows iterative– Shows root name servers– Shows recursive– Shows negative caching

• nslookup– Set iterative– Lookup bogus name– Get list of root servers– Set recursive– Lookup same bogus name– Get negative response– Set iterative– Lookup bogus name– Get negative response

Page 27: 1 CSE 524: Lecture 15 Application layer (Part 2)

27

AL: DNS protocol, messages

DNS protocol : query and repy messages, both with same message format

msg header• identification: 16 bit # for

query, repy to query uses same #

• flags:

– query or reply

– recursion desired

– recursion available

– reply is authoritative

Page 28: 1 CSE 524: Lecture 15 Application layer (Part 2)

28

AL: DNS protocol, messages

Name, type fields for a query

RRs in reponseto query

records forauthoritative servers

additional “helpful”info that may be used

Page 29: 1 CSE 524: Lecture 15 Application layer (Part 2)

29

AL: DNS issues

• Poor static configuration (root server list)• Lack of exponential backoff• No centralized caching per site

– Each machine runs on caching local server

• UDP used for queries– Need reliability Why not TCP?

• Vulnerability of 13 TLD servers– See past year

Page 30: 1 CSE 524: Lecture 15 Application layer (Part 2)

30

AL: Electronic Mail

Three major components: • user agents

• mail servers

• simple mail transfer protocol: smtp

User Agent

• a.k.a. “mail reader”

• composing, editing, reading mail messages

• e.g., Eudora, Outlook, elm, Netscape Messenger

• outgoing, incoming messages stored on server

user mailbox

outgoing message queue

mailserver

useragent

useragent

useragent

mailserver

useragent

useragent

mailserver

useragent

SMTP

SMTP

SMTP

Page 31: 1 CSE 524: Lecture 15 Application layer (Part 2)

31

AL: Electronic Mail: mail servers

Mail Servers • mailbox contains incoming

messages (yet to be read) for user

• message queue of outgoing (to be sent) mail messages

• smtp protocol between mail servers to send email messages– client: sending mail server– “server”: receiving mail

server

mailserver

useragent

useragent

useragent

mailserver

useragent

useragent

mailserver

useragent

SMTP

SMTP

SMTP

Page 32: 1 CSE 524: Lecture 15 Application layer (Part 2)

32

AL: Electronic Mail: smtp [RFC 821]

• uses tcp to reliably transfer email msg from client to server, port 25

• direct transfer: sending server to receiving server

• relay: intermediate server transfer

• three phases of transfer

– handshaking (greeting)

– transfer of messages

– closure

• command/response interaction

– commands: ASCII text

– response: status code and phrase

Page 33: 1 CSE 524: Lecture 15 Application layer (Part 2)

33

AL: Sample smtp interaction

S: 220 hamburger.edu C: HELO crepes.fr S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: <[email protected]> S: 250 [email protected]... Sender ok C: RCPT TO: <[email protected]> S: 250 [email protected] ... 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

Page 34: 1 CSE 524: Lecture 15 Application layer (Part 2)

34

AL: try smtp interaction for yourself:

• telnet servername 25• see 220 reply from server

• enter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands

above lets you send email without using email client (reader)

Page 35: 1 CSE 524: Lecture 15 Application layer (Part 2)

35

AL: smtp: final words

• smtp uses persistent connections

• smtp requires that message (header & body) be in 7-bit ascii

• certain character strings are not permitted in message (e.g., CRLF.CRLF). Thus message has to be encoded (usually into either base-64 or quoted printable)

• smtp server uses CRLF.CRLF to determine end of message

Comparison with http

• http: pull

• email: push

• both have ASCII command/response interaction, status codes

• http: each object is encapsulated in its own response message

• smtp: multiple objects message sent in a multipart message

Page 36: 1 CSE 524: Lecture 15 Application layer (Part 2)

36

AL: Mail message format

smtp: protocol for exchanging email 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

blankline

Page 37: 1 CSE 524: Lecture 15 Application layer (Part 2)

37

AL: Message format: multimedia extensions

• MIME: multimedia mail extension, RFC 2045, 2056

• additional lines in msg header declare MIME content type

From: [email protected] To: [email protected] Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg

base64 encoded data ..... ......................... ......base64 encoded data

multimedia datatype, subtype,

parameter declaration

method usedto encode data

MIME version

encoded data

Page 38: 1 CSE 524: Lecture 15 Application layer (Part 2)

38

AL: MIME typesContent-Type: type/subtype; parameters

Text• example subtypes: plain,

html

Image• example subtypes: jpeg, gif

Audio• exampe subtypes: basic (8-bit

mu-law encoded), 32kadpcm (32 kbps coding)

Video• example subtypes: mpeg,

quicktime

Application• other data that must be processed

by reader before “viewable”

• example subtypes: msword, octet-stream

Page 39: 1 CSE 524: Lecture 15 Application layer (Part 2)

39

AL: Multipart TypeFrom: [email protected] To: [email protected] Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=98766789 --98766789Content-Transfer-Encoding: quoted-printableContent-Type: text/plain

Dear Bob, Please find a picture of a crepe.--98766789Content-Transfer-Encoding: base64Content-Type: image/jpeg

base64 encoded data ..... ......................... ......base64 encoded data --98766789--

Page 40: 1 CSE 524: Lecture 15 Application layer (Part 2)

40

AL: Mail access protocols

• Mail delivery/transfer protocol– SMTP

• Mail access protocol: retrieval from server– POP: Post Office Protocol [RFC 1939]

• authorization (agent <-->server) and download – IMAP: Internet Mail Access Protocol [RFC 1730]

• more features (more complex)• manipulation of stored msgs on server

– HTTP: Hotmail , Yahoo! Mail, Horde/IMP etc.

useragent

sender’s mail server

useragent

SMTP SMTP POP3 orIMAP

receiver’s mailserver

useragent

POP3 orIMAP

web server

HTTP

web server

SMTP

useragent

HTTP

Page 41: 1 CSE 524: Lecture 15 Application layer (Part 2)

41

AL: POP3 protocol

authorization phase• client commands:

– user: declare username– pass: password

• server responses– +OK– -ERR

transaction phase, client:• list: list message numbers• top: get head of message• retr: retrieve message by

number• dele: delete• quit

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 server signing off

S: +OK POP3 server ready C: user alice S: +OK C: pass hungry S: +OK user successfully logged on