21
1 CPSC 360 Network Programming Applications & Application-Layer Protocols: The Domain Name System and Peer- to-Peer Systems Michele Weigle Department of Computer Science Clemson University [email protected] http://www.cs.clemson.edu/~mweigle/courses/cpsc360 2 Application-Layer Protocols Outline The architecture of distributed systems » Client/Server computing » P2P and Hybrid computing The programming model used in constructing distributed systems » Socket programming Example client/server systems and their application-layer protocols » The World-Wide Web (HTTP) » Reliable file transfer (FTP) » E-mail (SMTP & POP) » Internet Domain Name System (DNS) Example P2P/Hybrid systems local ISP company network regional ISP application transport network link physical application

Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

1

CPSC 360Network Programming

Applications &Application-Layer Protocols:

The Domain Name System and Peer-to-Peer Systems

Michele WeigleDepartment of Computer Science

Clemson [email protected]

http://www.cs.clemson.edu/~mweigle/courses/cpsc360

2

Application-Layer ProtocolsOutline

The architecture of distributed systems» Client/Server computing» P2P and Hybrid computing

The programming model used in constructingdistributed systems» Socket programming

Example client/server systems andtheir application-layer protocols» The World-Wide Web (HTTP)» Reliable file transfer (FTP)» E-mail (SMTP & POP)» Internet Domain Name System (DNS)

Example P2P/Hybrid systems

local ISP

companynetwork

regional ISP

applicationtransportnetwork

linkphysical

application

Page 2: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

3

Application-Layer ProtocolsThe Domain Name System (DNS) Computers (hosts, routers) connected to the Internet have two

forms of names:» IP address — a 32 bit identifier used for addressing hosts and routing data

to them» Hostname — an ASCII string used by applications

The DNS is an Internet-wide service that provides mappingsbetween IP addresses and hostnames» The DNS is a distributed database implemented in a hierarchy of name

servers» The DNS is also an application-layer protocol

Hosts and routers use name servers to resolve names(address/name translation)» Name resolution is an essential Internet function implemented as

application-layer protocol

4

The Domain Name SystemServices

Host Aliasing» canonical hostname: relay1.west-coast.enterprise.com» aliases: enterprise.com, www.enterprise.com

Mail Server Aliasing» email address: [email protected]» mail server: relay1.west-coast.hotmail.com

Load Distribution» set of IP addresses associated with 1 canonical hostname

(e.g., cnn.com)» server response with whole set, but rotates ordering

Page 3: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

5

The Domain Name SystemNames are valuable!

A New York Times article from August 22, 2000

6

The Domain Name SystemGrowth of DNS registrations

Source: Internet Software Consortium (http://www.isc.org/)

Page 4: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

7

The Domain Name SystemName Hierarchy in DNS

hostname = “dot” separated concatenation of domainnames along path toward the root» clemson.edu» cs.clemson.edu

» shadow1.cs.clemson.edu

com edu net org gov

npr

yahoo amazon clemson cornell sprint bellsouth

cs ece cssrv

ads

8

Name Hierarchy in the DNSTop level domains

Generic domains:» .com, .org, .net, .edu, .gov, .mil, .int» .biz, .info, .name, .pro

Special sponsored names» .aero, .coop, .museum

Country code domains» .uk, .de, .jp, .us, etc.

com edu net org gov …

Page 5: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

9

DNSOverview

Applications need IP address to open connection Use DNS to find the IP address given a hostname Steps:

1. Application invokes DNS (gethostbyname())2. DNS application in host sends query into network

(UDP port 53)3. DNS application in host receives reply with IP

address (after some delay)4. IP address passed up to the application

DNS is a black box as far as theapplication is concerned.

10

The Domain Name SystemDesigning a distributed service

Why not centralize the DNS» A server process on a big, well connected supercomputer?

Centralized systems do not scale!» Poor reliability: centralized = single point of failure» Poor performance: centralized = “remote access” for most

users» Difficult to manage: centralized = all traffic goes to one

location, a large staff has to be present to handle registrations

A centralized system is not politically feasible in aninternational network

Page 6: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

11

Designing a Distributed ServiceDNS Name Servers

No server has every hostname-to-IP address mapping

Authoritative name server:» Every host is registered with at least

one authoritative server that storesthat host’s IP address and name

» The authoritative name server canperform name/address translation forthat host’s name/address

Local authoritative name servers:» Each ISP, university, company, has a

local (default) name serverauthoritative for its own hosts

» Resolvers always query a name serverlocal to it to resolve any host name

Local hostshadow1.cs.clemson.edu

Local authoritative servertornado.cs.clemson.edu

What if the name isnot a local host (e.g.,www.yahoo.com)?

Name resolution:Query and Reply

12

DNS Name ServersRoot name servers

A root name server is contacted when a local name server that can’tresolve a name» The root server either resolves the name or provides pointers to authoritative

servers at lower level of name hierarchy There are 13 root name servers worldwide

Page 7: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

13

12 independent sites

DNS Name ServersGeneric TLD servers (Verisign Corp.)

.com, org, .net server locations (separated from rootservers)

14

DNS Name ServersUsing a server hierarchy for resolving names

Host shadow1.cs.clemson.edu wants toknow the IP address of www.yahoo.com» shadow1 contacts its local DNS server

tornado.cs.clemson.edu To resolve a non-local name, the local name

server queries the root server The root server responds with the TLD for

.com The local DNS server contacts the TLD

server The local DNS server contacts the

authoritative server dns.yahoo.com Results feed back to shadow1 shadow1 can now use the IP address of

www.yahoo.com to make a connectionRequesting host

shadow1.cs.clemson.edu

Root DNS servera.root-servers.net

Local DNS servertornado.cs.clemson.edu

Authoritative DNS serverdns.yahoo.com

TLD DNS server

1 8

2

3

45 6

7 Target hostwww.yahoo.com

Page 8: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

15

DNS Name ServersRecursive vs. Iterative Queries

Requesting hostestore.yahoo.com

Root DNS servera.root-servers.net

Local DNS serverdns.yahoo.com

TLD DNS server

The DNS supports twoparadigms of queries:» Recursive queries» Iterative queries

Recursive queries place theburden of name resolution(recursively) on the contactedserver

In an iterated query thecontacted server simply replieswith the name of the server tocontact» “I don’t know; trying asking X”

1 8

27

36

AuthortativeDNS server

dns.cs.clemson.edu

45

16

DNS Name ServersRecursive vs. Iterative Queries

Requesting hostshadow1.cs.clemson.edu

Root DNS servera.root-servers.net

Local DNS servertornado.cs.clemson.edu

Authoritative DNS serverdns.yahoo.com

TLD DNS server

1 8

2

3

45 6

7 Target hostwww.yahoo.com

Any query can berecursive or iterative

Iterative and recursivequeries can be combined

Typically, the query fromthe requesting host to thelocal DNS server isrecursive and theremaining queries areiterative

Page 9: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

17

DNS Name ServersCaching and updating DNS entries

Every server caches all themappings it learns» Cache entries are “soft state”» They timeout (are deleted)

after some time period

DNS cache update/notifymechanisms under design bythe IETF» See RFC 2136

Requesting hostshadow1.cs.clemson.edu

Root DNS servera.root-servers.net

Local DNS servertornado.cs.clemson.edu

Authoritative DNS serverdns.yahoo.com

TLD DNS server

1 8

2

3

45 6

7 Target hostwww.yahoo.com

18

DNS Name ServersDNS resource records

The DNS is a distributed database storing resourcerecords (RRs)

Type = NS» name is a domain» value is name of

authoritative nameserver for this domain

RR format: <name, value, type, time_to_live>

Type = A» name is a hostname» value is hostname’s

IP address

Type = CNAME» name is an alias name for

some “canonical” (the real)name

» value is canonical name

Type = MX» value is name of mail

server host associated withname

Page 10: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

19

DNS Name ServersDNS resource records / Examples

A record» (relay1.west-coast.yahoo.com,145.137.93.126, A)

NS record» (yahoo.com, dns.yahoo.com, NS)

CNAME record» (yahoo.com, relay1.west-coast.yahoo.com,CNAME)

MX record» (yahoo.com, mail.yahoo.com, MX)

20

Identification FlagsNumber ofquestions

Number ofauthority RRs

Number ofanswer RRsNumber of

additional RRsQuestions

(variable number)Answers

(variable number of records)Authority

(variable number of records)Additional Information

(variable number of records)

DNS ProtocolDNS query and reply messages

DNS query and reply messages both have thesame message format

Messages have a fixedlength message header» Identification — 16 bit

query/reply identifier usedto match relies to queries

» Flags: Query/Reply bit “Reply is authoritative” bit “Recursion desired” bit ....

variable

12 bytes

Page 11: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

21

Identification FlagsNumber ofquestions

Number ofauthority RRs

Number ofanswer RRsNumber of

additional RRsQuestions

(variable number)Answers

(variable number of records)Authority

(variable number of records)Additional Information

(variable number of records)

DNS ProtocolDNS query and reply messages

Messages have a variable-length “question &answer” body

Questions:» The name and type fields

(type A or MX) for aquery — hotmail.com MX

Answers:» One RR for each IP

address answering query

Authority:» Resource records of other

authoritative servers

variable

12 bytes

22

DNS Resource Recordsnslookup query/reply message example

shadow1% nslookupDefault Server: tornado.cs.clemson.eduAddress: 130.127.48.3

> set debug> www.yahoo.comServer: tornado.cs.unc.eduAddress: 130.127.48.3

;; res_nmkquery(QUERY, www.yahoo.com, IN, A)------------Got answer: HEADER: opcode = QUERY, id = 16795, rcode = NOERROR header flags: response, want recursion, recursion avail. questions = 1, answers = 9, authority records = 11, additional = 3

QUESTIONS: www.yahoo.com, type = A, class = IN

Page 12: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

23

DNS Resource Recordsnslookup query/reply message example ANSWERS: -> www.yahoo.com canonical name = www.yahoo.akadns.net ttl = 300 (5M) -> www.yahoo.akadns.net internet address = 216.109.118.72 ttl = 60 (1M) -> www.yahoo.akadns.net internet address = 216.109.117.106 ttl = 60 (1M) -> www.yahoo.akadns.net internet address = 216.109.117.107 ttl = 60 (1M) -> www.yahoo.akadns.net internet address = 216.109.117.109 ttl = 60 (1M) -> www.yahoo.akadns.net internet address = 216.109.118.64 ttl = 60 (1M) -> www.yahoo.akadns.net internet address = 216.109.118.65 ttl = 60 (1M) -> www.yahoo.akadns.net internet address = 216.109.118.67 ttl = 60 (1M)

AUTHORITY RECORDS: -> akadns.net nameserver = z0c.akadns.org ttl = 113598 (113598) -> akadns.net nameserver = zf.akadns.org ttl = 113598 (113598) -> akadns.net nameserver = zh.akadns.org ttl = 113598 (113598) -> akadns.net nameserver = eur3.akam.net ttl = 113598 (113598) -> akadns.net nameserver = use2.akam.net ttl = 113598 (113598) -> akadns.net nameserver = use4.akam.net ttl = 113598 (113598) -> akadns.net nameserver = usw5.akam.net ttl = 113598 (113598)…

24

DNS Resource Recordsnslookup query/reply message example ADDITIONAL RECORDS: -> za.akadns.org internet address = 208.185.132.176 ttl = 19200 (19200) -> use4.akam.net internet address = 80.67.67.182 ttl = 126017 (126017) -> usw5.akam.net internet address = 63.241.73.214 ttl = 126017 (126017)

Non-authoritative answer:Name: www.yahoo.akadns.netAddresses: 216.109.118.72, 216.109.117.106, 216.109.117.107, 216.109.117.109, 216.109.118.64, 216.109.118.65, 216.109.118.67, 216.109.118.71Aliases: www.yahoo.com

Page 13: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

25

root

comedu

net

cnn

DNS ExampleDNS processing for an iterated query

Resolve the hostname inhttp://www.cnn.com

LocalServer

REPLY: com (NS)

QUERY: www.cnn.com

REPLY: cnn.com (NS)

REPLY: 207.25.71.28(A)

QUERY: www.cnn.co

m

REPLY: 207.25.71.28

com. NS A.GTLD-SERVERS.NET 192.5.6.30cnn.com NS DNS.CNN.COM 128.2.232.1www.cnn.com A 207.25.71.28

QUERY: www.cnn.com

QUERY: www.cnn.com

26

root

comedu

net

cnn

DNS ExampleDNS processing for an iterated query

Resolve the hostname www2.cnn.comwith a warm cache

LocalServer

REPLY: 66.40.26.232(A)

REPLY: 66.40.26.232

com. NS A.GTLD-SERVERS.NET 192.5.6.30cnn.com NS DNS.CNN.COM 128.2.232.1www.cnn.com A 207.25.71.28

QUERY: www2.cnn.com

QUERY: www2.cnn.com

www2.cnn.com A 66.40.26.232

Page 14: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

27

The Domain Name SystemSummary

F gets 270,000,000+hits per day» Other servers have

comparable load

The Verisign TLDservers answer5,000,000,000queries per day

Clearly the DNSwould collapse without:» Hierarchy» Distributed processing» Caching

If DNS fails, Internet servicesstop working!

28

The Domain Name SystemFor More Info

DNS Specification» RFC 1034, RFC 1035» [Mockapetris 1988]

DNS Caching» RFC 2136

DNS Attacks» CAIDA, Nameserver DoS Attack October 2 analysiswww.caida.org/projects/dns-analysis/oct02dos.xml

Page 15: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

29

Application-Layer ProtocolsPeer-to-Peer (P2P) Architecture

No always-on server Arbitrary end systems

directly communicate Peers are intermittently

connected and changeIP addresses

local ISP

companynetwork

regional ISP

30

Application-Layer ProtocolsP2P File Sharing

P2P file sharing accounts for more traffic than anyother application on the Internet

Types of files shared» MP3s 3-8 MB» videos 10MB - 1GB» software

Legality» [vonLohmann 2003]

Page 16: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

31

Application-Layer ProtocolsP2P File Sharing / Example

Alice runs P2P client application onher notebook computer

Intermittently connects to Internet;gets new IP address

Asks for “Hey Jude” Application displays other peers that

have copy of Hey Jude. Alice chooses one of the peers, Bob. File is copied from Bob’s PC to

Alice’s notebook: HTTP While Alice downloads, other users

uploading from Alice. Alice’s peer is both a Web client

and a transient Web server.

All peers are servers =highly scalable!

32

P2P File SharingContent Location Problem

local ISP

companynetwork

regional ISP

Centralized Directory

Query Flooding

HeterogeneousApproach

How do peers knowwhich other peers have

content that they’reinterested in?

Page 17: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

33

Bob

P2P File SharingCentralized Directory (Napster)

1) When peer connects, itinforms central server:» IP address» content

2) Alice queries for “Hey Jude”3) Alice requests file from Bob

centralizeddirectory server

peers

Alice

1

1

1

12

3

inform and update1

2 query3 file transfer

34

P2P File SharingProblems with Centralized Directory

Single point of failure Performance bottleneck Copyright infringement

File transfer is decentralized, butlocating content is highlycentralized

Page 18: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

35

P2P File SharingQuery Flooding (Gnutella)

Fully distributed» no central server

Public domain protocol Many Gnutella clients

implementing protocol Peers form an overlay network

» edge between peer X and Y if there’sa TCP connection

» group of active peers and edges isoverlay network

» edge is not a physical link» given peer will typically be

connected with < 10 overlayneighbors

Protocol specification:[Gnutella 2004]

36

Query Flooding Messages

QueryQueryHit

Query

QueryQuery

Query

QueryHit

QueryHit

File transfer: HTTP

Scalability:limited scopeflooding

Query messagesent over existingTCP connections

Peers forwardQuery message

QueryHit messagesent over reversepath

Bob

Alice

Page 19: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

37

P2P File SharingKaZaA

Borrows ideas from Napster and Gnutella» no dedicated server» peers are either normal peers or group leaders» each group leader is a mini-Napster-like hub» group leaders create a network that resembles a Gnutella network

Contributes more traffic to the Internet than any otherapplication» [Gummadi 2003, Saroiu 2002]

Proprietary specification» harder to know exactly how it works» [Liang 2004] - KaZaA traffic measurement

Encrypts control traffic

38

P2P File SharingExploiting Heterogeneity (KaZaA)

Each peer is either a groupleader or assigned to agroup leader.» TCP connection between

peer and its group leader.» TCP connections between

some pairs of group leaders. Group leader tracks the

content in all its children.

ordinary peer

group-leader peer

neighoring relationships

in overlay network

Page 20: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

39

KaZaAQuerying

Each file has a hash and a descriptor Client sends keyword query to its

group leader Group leader responds with

matches:» For each match: hash, IP address

If group leader forwards query toother group leaders, they respondwith matches

Client then selects files fordownloading» HTTP requests using hash as

identifier sent to peers holdingdesired file

ordinary peer

group-leader peer

neighoring relationships

in overlay network

40

KazaaTricks

Limitations on simultaneous uploads» request queuing

Incentive priorities» priority in queue given to users who upload more than

download Parallel downloading

» use byte-range field in HTTP request header

Page 21: Applications & Application-Layer Protocols: The Domain ...mweigle/clemson/courses/cpsc360-s06/lectures/2-9-DNS-P2P.pdf3 Application-Layer Protocols The Domain Name System (DNS) Computers

41

Peer-to-Peer SystemsFor More Info

Content Location» [Stoica 2001]» [Rowstron 2001]» [Ratnasamy 2001]» [Zhao 2004]» [Maymounkov 2002]» [Garces-Erce 2003]

Gnutella» [Gnutella 2004] -

protocol specification

KaZaA» [KaZaA 2004]» [Gummadi 2003]» [Saroiu 2002]» [Liang 2004]