1 Lecture05: Application layer r Principles of network applications r DNS r P2P and DHT.

Post on 27-Dec-2015

218 views 0 download

Tags:

Transcript of 1 Lecture05: Application layer r Principles of network applications r DNS r P2P and DHT.

1

Lecture05: Application layer

Principles of network applications

DNS

P2P and DHT

2

Some network apps

e-mail web instant messaging remote login P2P file sharing multi-user network

games streaming stored

video clips

voice over IP real-time video

conferencing VoD (Youtube) Facebook Twitter Cloud ….

3

Application architectures

Client-server Peer-to-peer (P2P) Hybrid of client-server and P2P

4

Client-server architectureserver:

always-on host permanent IP address server farms for

scalingclients:

communicate with server (speak first)

may have dynamic IP addresses

do not communicate directly with each other

client/server

5

Pure P2P architecture

no always-on server arbitrary end systems

directly communicate peers are

intermittently connected and change IP addresses

Highly scalable but difficult to manage

peer-peer

6

Hybrid of client-server and P2PSkype

voice-over-IP P2P application centralized server: finding address of

remote party: client-client connection: direct (not through

server) Instant messaging

chatting between two users is (can be) P2P centralized service: client presence

detection/location• user registers its IP address with central

server when it comes online• user contacts central server to find IP

addresses of buddies

7

What transport service does an app need?

Data loss some apps (e.g., audio)

can tolerate some loss other apps (e.g., file

transfer, telnet) require 100% reliable data transfer

Timing some apps (e.g.,

Internet telephony, interactive games) require low delay to be “effective”

Throughput some apps (e.g.,

multimedia) require minimum amount of throughput to be “effective”

other apps (“elastic apps”) make use of whatever throughput they get

Security Encryption, data

integrity, …

8

Internet apps: application, transport protocols

Application

e-mailremote terminal access

Web file transfer

streaming multimedia

Internet telephony

Applicationlayer protocol

SMTP [RFC 2821]Telnet [RFC 854]HTTP [RFC 2616]FTP [RFC 959]HTTP (eg Youtube), RTP [RFC 1889]SIP, RTP, proprietary(e.g., Skype)

Underlyingtransport protocol

TCPTCPTCPTCPTCP or UDP

typically UDP

9

Lecture05: Application layer

Principles of network applications

DNS

DHT

10

DNS: Domain Name SystemPeople: many

identifiers: SSN, name, passport

#

Internet hosts, routers: IP address (32 bit)

- used for addressing datagrams

“name”, e.g., www.yahoo.com - used by humans

Required: map between name and IP addresses

Domain Name System: distributed database

implemented as a hierarchy of many name servers

application-layer protocol used to resolve names (address/name translation) note: core Internet

function, implemented as application-layer protocol

11

DNS

Why not centralize DNS? single point of failure traffic volume distant centralized

database maintenance

doesn’t scale!

DNS services Hostname to IP

address translation Mail server aliasing Load distribution

Replicated Web servers: set of IP addresses for one canonical name

12

Root DNS Servers

com DNS servers org DNS servers edu DNS servers

poly.eduDNS servers

umass.edu DNS servers

yahoo.comDNS servers

amazon.comDNS servers

pbs.orgDNS servers

Distributed, Hierarchical Database

Client wants IP address for www.amazon.com; 1st approx:

Client queries a root server to find com DNS server Client queries com DNS server to get amazon.com

DNS server Client queries amazon.com DNS server to get IP

address for www.amazon.com

13

DNS: Root name servers

13 root name servers worldwideb USC-ISI Marina del Rey, CA

l ICANN Los Angeles, CA

e NASA Mt View, CAf Internet Software C. Palo Alto, CA (and 36 other locations)

i Autonomica, Stockholm (plus 28 other locations)

k RIPE London (also 16 other locations)

m WIDE Tokyo (also Seoul, Paris, SF)

a Verisign, Dulles, VAc Cogent, Herndon, VA (also LA)d U Maryland College Park, MDg US DoD Vienna, VAh ARL Aberdeen, MDj Verisign, ( 21 locations)

14

Local Name Server

does not strictly belong to hierarchy each ISP (residential ISP, company,

university) has one. also called “default name server”

when host makes DNS query, query is sent to its local DNS server acts as proxy, forwards query into hierarchy

15

requesting hostcis.poly.edu

gaia.cs.umass.edu

root DNS server

local DNS serverdns.poly.edu

1

23

4

5

6

authoritative DNS serverdns.cs.umass.edu

78

TLD DNS server

DNS name resolution example

Host at cis.poly.edu wants IP address for gaia.cs.umass.edu

iterated query: contacted server

replies with name of server to contact

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

16

requesting hostcis.poly.edu

gaia.cs.umass.edu

root DNS server

local DNS serverdns.poly.edu

1

2

45

6

authoritative DNS serverdns.cs.umass.edu

7

8

TLD DNS server

3recursive query: puts burden of

name resolution on contacted name server

DNS name resolution example

17

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

caches mapping cache entries timeout (disappear) after

some time typically cached in local name servers

• Thus root name servers not often visited

18

Lecture05: Application layer

Principles of network applications

DNS

P2P and DHT

19

Pure P2P architecture

no always-on server arbitrary end systems

directly communicate peers are intermittently

connected and change IP addresses

Three topics: File distribution Searching for information Case Study: Skype

peer-peer

20

File Distribution: Server-Client vs P2PQuestion : How much time to distribute file

from one server to N peers?

us

u2d1 d2u1

uN

dN

Server

Network (with abundant bandwidth)

File, size F

us: server upload capacity (bps)

ui: peer i upload capacity (bps)

di: peer i download capacity (bps)

21

0

0.5

1

1.5

2

2.5

3

3.5

0 5 10 15 20 25 30 35

N

Min

imu

m D

istr

ibut

ion

Tim

e P2P

Client-Server

Client-server vs. P2P: example

Client upload rate = u, F/u = 1 hour, us = 10u, dmin ≥ us

22

File distribution: BitTorrent

tracker: tracks peers participating in torrent

torrent: group of peers exchanging chunks of a file

obtain listof peers

trading chunks

peer

P2P file distribution

23

BitTorrent (1)

file divided into 256KB chunks. peer joining torrent:

registers with tracker to get list of peers, connects to subset of peers (“neighbors”)

has no chunks, but will accumulate them over time

while downloading, peer uploads chunks to other peers.

peers may come and go once a peer has entire file, it may (selfishly) leave

or (altruistically) remain

24

BitTorrent (2)

Pulling Chunks at any given time,

different peers have different subsets of file chunks

periodically, a peer (Alice) asks each neighbor for list of chunks that they have.

Alice sends requests for her missing chunks rarest first

Sending Chunks: tit-for-tat Alice sends chunks to

four neighbors currently sending her chunks at the highest rate re-evaluate top 4

every 10 secs every 30 secs: randomly

select another peer, starts sending chunks “optimistically

unchoke”

25

Finding a better trading partner(1) Alice “optimistically unchokes” Bob

(2) Alice becomes one of Bob’s top-four providers; Bob reciprocates(3) Bob becomes one of Alice’s top-four providers

With higher upload rate, can find better trading partners & get file faster!

26

Distributed Hash Table (DHT)

DHT = distributed P2P database Database has (key, value) pairs;

key: ss number; value: human name key: content type; value: IP address

Peers query database with key database returns values that match the key

Peers can also insert (key, value) pairs into database

Finding “needles” requires that the P2P system be structured

27

DHT Identifiers

Assign integer identifier to each peer in range [0,2n-1]. Each identifier can be represented by n bits.

Require each key to be an integer in same range.

To get integer keys, hash original key. e.g., key = h(“Led Zeppelin IV”) This is why database is called a distributed “hash”

table

28

How to assign keys to peers?

Central issue: Assigning (key, value) pairs to peers.

Rule: assign to the peer that has the ID closest to key.

Convention in lecture: closest is the immediate successor of the key (or equal to)

Example: 4 bits; peers: 1,3,4,5,8,10,12,14; key = 13, then successor peer = 14 key = 15, then successor peer = 1

Consistent Hashing For n = 6, # of identifiers is 64. The following DHT ring has 10 nodes

and stores 5 keys. The successor of key 10 is node 14.

30

1

3

4

5

810

12

15

Circular DHT (1)

Each peer only aware of immediate successor and predecessor.

31

Circle DHT (2)

0001

0011

0100

0101

10001010

1100

1111

Who’s resp

for key 1110 ?I am

O(N) messageson avg to resolvequery, when thereare N peers

1110

1110

1110

1110

1110

1110

Define closestas closestsuccessor

32

Circular DHT with Shortcuts

Each peer keeps track of IP addresses of predecessor, successor, and short cuts.

Reduced from 6 to 3 messages. Can design shortcuts such that O(log N) neighbors per

peer, O(log N) messages per query

0001

0011

0100

0101

10001010

1100

1111

Who’s resp for key 1110?

Scalable Key Location – Finger Tables

0

4

26

5

1

3

7

124

130

finger tablestart succ.

keys1

235

330

finger tablestart succ.

keys2

457

000

finger tablestart succ.

keys6

0+20

0+21

0+22

For.

1+20

1+21

1+22

For.

3+20

3+21

3+22

For.

34

Peer Churn

•To handle peer churn, require each peer to know the IP address of its two successors •Each peer periodically pings its two successors to see if they are still alive •Limited solution for single join or single failure

Consistent Hashing – Node Join

0

4

26

5

1

3

7

keys1

keys2

keys

keys

7

5

Consistent Hashing – Node Dep.

0

4

26

5

1

3

7

keys1

keys2

keys

keys6

7

Problem of DHT

No good solution to maintain both scalable and consistent finger table under Churn.

Solution of BitTorrent Maintain trackers (servers) as DHT, which

are more reliable Users queries trackers to get the locations

of the file File sharing are not structured.

37

38

DNS vs. DHT

DNS

provides a host name to IP address mapping

relies on a set of special root servers

names reflect administrative boundaries

is specialized to finding named hosts or services

DHT

can provide same service: Name = key, value = IP

requires no special servers

imposes no naming structure

can also be used to find data objects that are not tied to certain machines

39

End of Lecture05