107
7/23/2019 Networking -Application Layer http://slidepdf.com/reader/full/networking-application-layer 1/107 Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down  Approach 6 th  edition  Jim Kurose, Keith Ross Addison-Wesley March 2012  A note on the use of these ppt slides: We’re making these slides freely available to all (faculty, students, readers). They’re in o!eroint form so you see the animations" and can add, modify, and delete slides (including this one) and slide content to suit your needs. They obviously represent a lot  of !ork on our part. #n return for use, !e only ask the follo!ing: #f you use these slides (e.g., in a class) that you mention their source (after all, !e’d like people to use our book$) #f you post any slides on a !!! site, that you note that they are adapted from (or perhaps identical to) our slides, and note our copyright of this material. Thanks and en%oy$ &'W*  All material copyright +-/0+/  &.' urose and .W. *oss, All *ights *eserved

Networking -Application Layer

Embed Size (px)

Citation preview

Page 1: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 1/107

Application Layer 2-1

Chapter 2

ApplicationLayer

ComputerNetworking: ATop Down

 Approach

6th

 edition Jim Kurose, KeithRossAddison-WesleyMarch 2012

 A note on the use of these ppt slides:We’re making these slides freely available to all (faculty, students, readers).

They’re in o!eroint form so you see the animations" and can add, modify,

and delete slides (including this one) and slide content to suit your needs.

They obviously represent a lot  of !ork on our part. #n return for use, !e only

ask the follo!ing:

#f you use these slides (e.g., in a class) that you mention their source

(after all, !e’d like people to use our book$) #f you post any slides on a !!! site, that you note that they are adapted

from (or perhaps identical to) our slides, and note our copyright of this

material.

Thanks and en%oy$ &'W*

  All material copyright +-/0+/  &.' urose and .W. *oss, All *ights *eserved

Page 2: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 2/107

Application Layer 2-2

Chapter 2 outline

2!1 principles o"net#or$applications

2!2 We% and &''(2!) *'(

2!+ electronic mail M'(, ((),

.MA(2!/

2!6 (2( applications

2! soc$etpro3rammin3

#ith 4( and 'C(

Page 3: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 3/107

Application Layer 2-)

Chapter 2 applicationlayerour 3oals conceptual,

implementationaspects o" net#or$application

protocols transport-layer

ser5ice models client-ser5er

paradi3m peer-to-peerparadi3m

learn a%outprotocols %yeaminin3 popularapplication-le5elprotocols &''( *'( M'( 7 (() 7 .MA(

creatin3 net#or$applications soc$et A(.

Page 4: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 4/107

Application Layer 2-+

ome net#or$ apps

e-mail #e% tet messa3in3 remote lo3in (2( 8le sharin3 multi-user net#or$

3ames streamin3 stored

5ideo 9:ou'u%e, &ulu,et;i<

5oice o5er .( 9e!3!,$ype<

real-time 5ideocon"erencin3

social net#or$in3 search = =

Page 5: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 5/107

Application Layer 2-/

Creatin3 a net#or$ app

#rite pro3rams that run on 9di>erent< end

systems communicate o5er net#or$ e!3!, #e% ser5er so"t#are

communicates #ith

%ro#ser so"t#are

no need to #rite so"t#are "ornet#or$-core de5ices

net#or$-core de5ices donot run user applications

applications on endsystems allo#s "or rapidapp de5elopment,propa3ation

application

transport

net!ork

data link

physical

application

transport

net!ork

data link

physical

application

transport

net!ork

data link

physical

Page 6: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 6/107

Application Layer 2-6

Application architectures

possi%le structure o" applications client-ser5er peer-to-peer 9(2(<

Page 7: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 7/107Application Layer 2-

Client-ser5er architecture

ser5er al#ays-on host permanent .( address data centers "or scalin3

clients communicate #ith ser5er may %e intermittently

connected

may ha5e dynamic .(addresses

do not communicatedirectly #ith each other

clientserver 

Page 8: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 8/107Application Layer 2-?

(2( architecture

no al#ays-on ser5er ar%itrary end systems

directly communicate peers re@uest ser5ice

"rom other peers,

pro5ide ser5ice in returnto other peers self scalability   ne#

peers %rin3 ne#ser5ice capacity, as#ell as ne# ser5icedemands

peers are intermittentlyconnected and chan3e.( addresses comple mana3ement

peerpeer 

Page 9: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 9/107

Page 10: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 10/107

Application Layer 2-10

oc$ets

process sends7recei5es messa3es to7"rom its soc$et soc$et analo3ous to door

sendin3 process sho5es messa3e out door sendin3 process relies on transport in"rastructure

on other side o" door to deli5er messa3e to

soc$et at recei5in3 process

#nternet

controlled

by 12

controlled byapp developer 

transport

application

physical

lin$

net#or$

process

transport

application

physical

lin$

net#or$

processsocket 

Page 11: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 11/107

Application Layer 2-11

Addressin3 processes

to recei5e messa3es,process must ha5eidentier 

host de5ice hasuni@ue )2-%it .(

address Q: does .( address o"

host on #hich processruns suDce "oridenti"yin3 the

processE

identier  includes %oth.( address and portnum%ers associated#ith process on host!

eample port num%ers

&''( ser5er ?0 mail ser5er 2/

to send &''( messa3eto 3aia!cs!umass!edu#e% ser5er .( address 

12?!11B!2+/!12 port num%er ?0

more shortly=

 A: no, many  processescan %e runnin3 on

same host

Page 12: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 12/107

Application Layer 2-12

App-layer protocol de8nes

types o" messa3esechan3ed,  e!3!, re@uest,

response messa3e synta

#hat 8elds inmessa3es ho#8elds are delineated

messa3e semantics  meanin3 o"

in"ormation in 8elds rules "or #hen and ho#

processes send respond to messa3es

open protocols de8ned in R*Cs allo#s "or

interopera%ility

e!3!, &''(, M'(proprietary protocols e!3!, $ype

Page 13: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 13/107

Application Layer 2-1)

What transport ser5ice does anapp needEdata inte3rity some apps 9e!3!, 8le

trans"er, #e%transactions< re@uire100F relia%le data

trans"er  other apps 9e!3!, audio<

can tolerate some losstimin3 some apps 9e!3!,

.nternet telephony,interacti5e 3ames<re@uire lo# delay to%e Ge>ecti5eH

throu3hput

some apps 9e!3!,multimedia< re@uireminimum amount o"throu3hput to %eGe>ecti5eH

other apps 9GelasticappsH< ma$e use o"#hate5er throu3hputthey 3et

security encryption, data

inte3rity, =

Page 14: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 14/107

Application Layer 2-1+

 'ransport ser5ice re@uirementscommon apps

application

file transfer 

email

Web documentsrealtime audiovideo

stored audiovideo

interactive games

te3t messaging

data loss

no loss

no loss

no losslosstolerant

losstolerant

losstolerant

no loss

throughput

elastic

elastic

elasticaudio: 4kbps+5bps

video:+0kbps45bps

same as above

fe! kbps up

elastic

time sensitive

no

no

noyes, +00’s msec

yes, fe! secs

yes, +00’s msec

yes and no

Page 15: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 15/107

Application Layer 2-1/

.nternet transport protocolsser5ices

TC service: reliable transport  

%et#een sendin3 andrecei5in3 process

!ow control: sender

#onIt o5er#helm recei5er congestion control: 

throttle sender #hennet#or$ o5erloaded

does not provide: timin3,minimum throu3hput

3uarantee, security connection"oriented: 

setup re@uired %et#eenclient and ser5erprocesses

#D service: unreliable data

transfer  %et#eensendin3 and recei5in3process

does not provide: relia%ility, ;o# control,con3estion control,timin3, throu3hput3uarantee, security,

orconnection setup,

 #hy %otherE Why isthere a 4(E

Page 16: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 16/107

Application Layer 2-16

.nternet apps application, transportprotocols

application

email

remote terminal access

Webfile transfer 

streaming multimedia

#nternet telephony

applicationlayer protocol

25T 6*'7 /8/+9

Telnet 6*'7 849

;TT 6*'7 /-+-9'T 6*'7 49

;TT (e.g., <ouTube),

*T 6*'7 +889

2#, *T, proprietary

(e.g., 2kype)

underlyingtransport protocol

T7

T7

T7T7

T7 or =>

T7 or =>

Page 17: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 17/107

ecurin3 'C(

 'C( 4( no encryption cleartet pass#ds

sent into soc$ettra5erse .nternet incleartet

L  pro5ides encrypted

 'C( connection data inte3rity end-point

authentication

L is at app layer Apps use L

li%raries, #hich

Gtal$H to 'C(L soc$et A(. cleartet pass#ds

sent into soc$et

tra5erse .nternetencrypted ee Chapter

Application Layer 2-1

Page 18: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 18/107

Application Layer 2-1?

Chapter 2 outline

2!1 principles o"net#or$applications app architectures app re@uirements

2!2 We% and &''(

2!) *'(

2!+ electronic mail M'(, ((),

.MA(

2!/

2!6 (2( applications

2! soc$etpro3rammin3

#ith 4( and 'C(

Page 19: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 19/107

Application Layer 2-1B

We% and &''(

$irst% a review& web page consists o" ob'ects o%ect can %e &'ML 8le, J( ima3e,

 Ja5a applet, audio 8le,= #e% pa3e consists o" base (T)*"le 

#hich includes several referencedob'ects

each o%ect is addressa%le %y a #+*%e!3!,www.someschool.edu/someDept/pic.gif

host name path name

Page 20: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 20/107

Application Layer 2-20

&''( o5er5ie#

&''( hypertettrans"er protocol

We%Is application layerprotocol

client7ser5er model

client : %ro#ser thatre@uests, recei5es,9usin3 &''(protocol< andGdisplaysH We%o%ects

server: We% ser5ersends 9usin3 &''(protocol< o%ects inresponse tore@uests

7 running

'irefo3 bro!ser 

server

running

 Apache Web

server 

iphone running

2afari bro!ser 

; T  T    r e ? u e s t ; T  T    r e s  p o n s e 

  ;  T  T  

  r e ?  u

 e s  t

  ;  T  T  

  r e s p o n

 s e

Page 21: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 21/107

Application Layer 2-21

&''( o5er5ie# 9continued<

uses TC: client initiates 'C(

connection 9createssoc$et< to ser5er, port?0

ser5er accepts 'C(connection "rom client

&''( messa3es9application-layerprotocol messa3es<

echan3ed %et#een%ro#ser 9&''( client<and We% ser5er 9&''(ser5er<

 'C( connection closed

(TT is ,stateless-  ser5er maintains no

in"ormation a%outpast client re@uests

protocols that maintainGstateH are compleN

past history 9state< must%e maintained

i" ser5er7client crashes,their 5ie#s o" GstateHmay %e inconsistent,must %e reconciled

aside

Page 22: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 22/107

Page 23: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 23/107

Page 24: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 24/107

Application Layer 2-2+

on-persistent &''( 9cont!<

/! &''( client recei5esresponse messa3econtainin3 html 8le, displayshtml! (arsin3 html 8le, 8nds

10 re"erenced pe3 o%ects

6! teps 1-/ repeated "oreach o" 10 pe3 o%ects

+! &''( ser5er closes 'C(connection!

time

i t t &''(

Page 25: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 25/107

Application Layer 2-2/

on-persistent &''( responsetime

R'' 9de8nition< time "or asmall pac$et to tra5el "romclient to ser5er and %ac$

&''( response time one R'' to initiate 'C(

connection one R'' "or &''( re@uest

and 8rst "e# %ytes o" &''(response to return

8le transmission time non-persistent &''(

response time O2R''P 8le transmissiontime

time totransmitfile

initiate T7connection

*TT

re?uestfile

*TT

file

received

time time

Page 26: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 26/107

Page 27: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 27/107

Application Layer 2-2

&''( re@uest messa3e

t#o types o" &''( messa3es re.uest ,response

&''( re@uest messa3e AC.. 9human-reada%le "ormat<

re?uest line(@T, 12T,

;A> commands<

header 

 lines

carriage return,

line feed at start

of line indicates

end of header lines

GET /index.html HTTP/1.1\r\nHost: www-net.cs.umass.edu\r\nser-!"ent: #ire$ox/%.&.1'\r\n !ccept: text/html(application/xhtml)xml\r\n !ccept-*an"ua"e: en-us(en+,'.\r\n

 !ccept-Encodin": "ip(de$late\r\n !ccept-0harset: S2-334-1(ut$-3+,'.5\r\n6eep-!li7e: 11\r\n0onnection: 8eep-ali7e\r\n\r\n

carriage return character 

linefeed character 

Page 28: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 28/107

Application Layer 2-2?

&''( re@uest messa3e 3eneral"ormat

re?uestline

header 

lines

body

method sp sp cr  lf version=*B

cr  lf valueheader field name

cr  lf valueheader field name

CC CC

cr  lf 

entity bodyCC CC

Page 29: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 29/107

Page 30: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 30/107

Application Layer 2-)0

Methodtypes&''(71!0 ' (' &A

as$s ser5er tolea5e re@uestedo%ect out o"response

&''(71!1 ', (', &A (4'

uploads 8le inentity %ody topath speci8ed in4RL 8eld

L'

deletes 8lespeci8ed in the4RL 8eld

Page 31: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 31/107

Application Layer 2-)1

&''( response messa3e

status line(protocol

status code

status phrase)

header 

 lines

data, e.g.,

re?uested

;T5B file

HTTP/1.1 ='' 26\r\nDate: Sun( =& Sep ='1' =':'4:=' G>T\r\nSer7er: !pache/=.'.= ?0ent2S@\r\n*ast->odi$ied: Tue( %' 2ct =''5 15:'':'=

G>T\r\nETa": A15dc&-ac-<$51&33'A\r\n !ccept-Ban"es: <tes\r\n0ontent-*en"th: =&=\r\n6eep-!li7e: timeout1'( max1''\r\n0onnection: 6eep-!li7e\r\n0ontent-Tpe: text/html+ charsetS2-334-

1\r\n\r\ndata data data data data ...

Page 32: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 32/107

Page 33: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 33/107

Application Layer 2-))

 'ryin3 out &''( 9client side< "oryoursel" 

1! 'elnet to your "a5orite We% ser5er

opens T7 connection to port 80

(default ;TT server port) at cis.poly.edu.

anything typed in sent

to port 80 at cis.poly.edu

telnet cis.pol.edu 3'

/. type in a @T ;TT re?uest:

GET /ross/ HTTP/1.1

Host: cis.pol.edu

by typing this in (hit carriage

return t!ice), you send

this minimal (but complete)@T re?uest to ;TT server 

D. look at response message sent by ;TT server$

9or use Wireshar$ to loo$ at captured &''( re@uest7resp

Page 34: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 34/107

Application Layer 2-)+

4ser-ser5er state coo$ies

many We% sites usecoo$ies

four components:

1< coo$ie header line o"

&''( response messa3e

2< coo$ie header line innet &''( re.uest  messa3e

)< coo$ie 8le $ept onuserIs host, mana3ed%y userIs %ro#ser

+< %ac$-end data%aseat We% site

eample usan al#ays access

.nternet "rom (C 5isits speci8c e-

commerce site "or 8rsttime

#hen initial &''(re@uests arri5es atsite, site creates

uni@ue . entry in %ac$enddata%ase "or .

Page 35: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 35/107

Application Layer 2-)/

Coo$ies $eepin3 GstateH 9cont!<

client server 

usual http response msg

usual http response msg

cookie file

one !eek later:

usual http re?uest msgcookie: 1678

cookie

specific

action

access

ebay 8734usual http re?uest msg  AmaEon server 

creates #>

+-F8 for user  create

  entry

usual http responseset-cookie: 1678 

ebay 8734amazon 1678

usual http re?uest msgcookie: 1678 cookie

specific

action

access

ebay 8734

amazon 1678

backend

database

Page 36: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 36/107

Application Layer 2-)6

Coo$ies 9continued<

what cookies canbe used for: authoriQation shoppin3 carts recommendations user session state

9We% e-mail<

cookies and privacy: coo$ies permit sites to

learn a lot a%out you you may supply name

and e-mail to sites

aside

how to keep ,state-: protocol endpoints maintain

state at sender7recei5er o5ermultiple transactions

coo$ies http messa3es carrystate

Page 37: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 37/107

Application Layer 2-)

We% caches 9proy ser5er<

user sets %ro#ser We%accesses 5ia cache

%ro#ser sends all &''(re@uests to cache o%ect in cache

cache returns o%ect else cache re@uests

o%ect "rom ori3inser5er, then returns

o%ect to client

goal: satis"y client re@uest #ithout in5ol5in3 ori3in ser5er

client

pro3y

server 

client

  ;  T  T  

  r e ?  u e s

 t

  ;  T  T    r e s p o

 n s e

; T  T    r e ? u e s t   ;  T  T

   r e ?  u e s t

origin

server 

origin

server 

; T  T    r e s  p o n s e   ;  T  T   r e

 s p o n s e

Page 38: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 38/107

Application Layer 2-)?

More a%out We% cachin3

cache acts as%oth client andser5er ser5er "or ori3inal

re@uestin3 client client to ori3in ser5er

typically cache isinstalled %y .(

9uni5ersity,company,residential .(<

why /eb caching0 reduce response time

"or client re@uest reduce traDc on an

institutionIs accesslin$

.nternet dense #ithcaches ena%les

GpoorH contentpro5iders toe>ecti5ely deli5ercontent 9so too does(2( 8le sharin3<

Page 39: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 39/107

Application Layer 2-)B

Cachin3 eample

origin

serverspublic

 #nternet

institutional

net!ork

+ @bps BAG

+.4 5bps

access link

assumptions: a53 o%ect siQe 100K %its a53 re@uest rate "rom

%ro#sers to ori3inser5ers1/7sec

a53 data rate to %ro#sers1!/0 M%ps

R'' "rom institutional routerto any ori3in ser5er 2 sec

access lin$ rate 1!/+ M%ps

conse.uences: LA utiliQation 1/F access lin$ utiliQation O BBF total delay O .nternet delay

P access delay P LA delay

  O 2 sec P minutes P usecs

 problem! 

Page 40: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 40/107

Application Layer 2-+0

assumptions: a53 o%ect siQe 100K %its a53 re@uest rate "rom %ro#sers

to ori3in ser5ers1/7sec a53 data rate to %ro#sers 1!/0

M%ps

R'' "rom institutional router toany ori3in ser5er 2 sec

access lin$ rate 1!/+ M%ps

conse.uences: LA utiliQation 1/F

access lin$ utiliQation O BBF total delay O .nternet delay P

access delay P LA delay

  O 2 sec P minutes P usecs

Cachin3 eample "atter

access lin$ 

origin

servers

+.4 5bps

access link1/+

M%ps+4 5bps

msecs

Cost: increased access link speed (not cheap$)

B!BF

public

 #nternet

institutional

net!ork

+ @bps BAG

Page 41: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 41/107

institutional

net!ork

+ @bps BAG

Application Layer 2-+1

Cachin3 eample install local

cache 

origin

servers

+.4 5bps

access link

local !ebcache

assumptions: a53 o%ect siQe 100K %its a53 re@uest rate "rom %ro#sers

to ori3in ser5ers1/7sec a53 data rate to %ro#sers 1!/0

M%ps R'' "rom institutional router to

any ori3in ser5er 2 sec access lin$ rate 1!/+ M%ps

conse.uences: LA utiliQation 1/F access lin$ utiliQation O 100F total delay O .nternet delay P

access delay P LA delay

  O 2 sec P minutes P usecs

HH

(ow to compute linkutili1ation% delay0

Cost: !eb cache (cheap$)

public

 #nternet

Page 42: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 42/107

Application Layer 2-+2

Cachin3 eample install local

cache Calculating access link

utili1ation% delay with cache:suppose cache hit rate is 0!+ +0F re@uests satis8ed at cache,

60F re@uests satis8ed at ori3in

origin

servers

+.4 5bps

access link

access lin$ utiliQation 60F o" re@uests use access lin$

data rate to %ro#sers o5er accesslin$ O 0!61!/0 M%ps O !B M%ps utiliQation O 0!B71!/+ O !/?

total delay O 0!6 9delay "rom ori3in ser5ers< P0!+ 9delay

#hen satis8ed at cache< O 0!6 92!01< P 0!+ 9Smsecs< O S 1!2 secs less than #ith 1/+ M%ps lin$ 9and cheaper tooN<

 

public

 #nternet

institutional

net!ork

+ @bps BAG

local !ebcache

Page 43: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 43/107

Application Layer 2-+)

Conditional '

2oal: donIt sendo%ect i" cache has up-to-date cached 5ersion no o%ect transmission

delay lo#er lin$ utiliQation

cache: speci"y date o"cached copy in &''(re@uest$-modi$ied-since: dateI 

server: responsecontains no o%ect i"cached copy is up-to-dateHTTP/1.' %'C ot >odi$ied 

;TT re?uest msgI-modiied-since: !date"

;TT response

#$$%&1'(3(4 )ot *odiied

ob%ect

not

modified

beforeIdateJ

;TT re?uest msgI-modiied-since: !date"

;TT response#$$%&1'( +(( ,

!data"

ob%ect

modified

after

IdateJ

client server 

Page 44: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 44/107

Application Layer 2-++

Chapter 2 outline

2!1 principles o"net#or$applications app architectures

app re@uirements

2!2 We% and &''(

2!) *'( 

2!+ electronic mail M'(, ((),.MA(

2!/

2!6 (2( applications

2! soc$etpro3rammin3#ith 4( and 'C(

Page 45: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 45/107

*'( t t l d t

Page 46: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 46/107

Application Layer 2-+6

*'( separate control, dataconnections

*'( client contacts *'(ser5er at port 21, usin3

 'C( client authoriQed o5er

control connection

client %ro#ses remotedirectory, sends commandso5er control connection

#hen ser5er recei5es 8letrans"er command, server  opens 3nd  'C( dataconnection 9"or 8le< toclient

a"ter trans"errin3 one 8le,ser5er closes dataconnection

'Tclient

'Tserver 

TCP control connection,server port 21

TCP data connection,server port 20 

ser5er opens another 'C( data connection totrans"er another 8le

control connection ,out

of band-  *'( ser5er maintains

GstateH currentdirectory, earlierauthentication

Page 47: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 47/107

Application Layer 2-+

*'( commands, responses

sample commands: sent as AC.. tet

o5er control channel SEB username

P!SS  password 

*ST return list o" 8lein current directory

BETB $ilename retrie5es 93ets< 8le

ST2B $ilename stores 9puts< 8le ontoremote host

sample return codes status code and

phrase 9as in &''(< %%1 sername 26( password re,uired 

1= dataconnection alreadopen+ trans$erstartin"

C= 0anJt opendata connection

C= Error writin"$ile

Page 48: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 48/107

Page 49: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 49/107

Application Layer 2-+B

lectronic mail

Three ma'or components:  user a3ents mail ser5ers simple mail trans"er

protocol M'(

#ser Agent  a!$!a! Gmail readerH composin3, editin3, readin3

mail messa3es e!3!, utloo$, 'hunder%ird,

i(hone mail client out3oin3, incomin3

messa3es stored on ser5er

user mailbo3

outgoing

message ?ueue

mail

server 

mail

server 

mail

server 

25T

25T

25T

user 

agent

user 

agent

user 

agent

user 

agent

user 

agent

user 

agent

Page 50: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 50/107

Application Layer 2-/0

lectronic mail mail ser5ers

mail ser5ers mailbo4  contains

incomin3 messa3es "oruser

message .ueue o"

out3oin3 9to %e sent<mail messa3es

5)T protocol %et#eenmail ser5ers to sendemail messa3es

client sendin3 mailser5er Gser5erH recei5in3

mail ser5er

mail

server 

mail

server 

mail

server 

25T

25T

25T

user 

agent

user 

agent

user 

agent

user 

agent

user 

agent

user 

agent

l i il

Page 51: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 51/107

Application Layer 2-/1

lectronic Mail M'( TR*C

2?21U uses 'C( to relia%ly trans"er email messa3e

"rom client to ser5er, port 2/ direct trans"er sendin3 ser5er to recei5in3

ser5er three phases o" trans"er

handsha$in3 93reetin3< trans"er o" messa3es closure

command7response interaction 9li$e &''(, *'(<

commands AC.. tet response status code and phrase

messa3es must %e in -%it AC. N

cenario Alice sends messa3e

Page 52: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 52/107

Application Layer 2-/2

user 

agent

cenario Alice sends messa3eto Vo%

1< Alice uses 4A tocompose messa3e [email protected]

2< AliceIs 4A sendsmessa3e to her mailser5er messa3e placed

in messa3e @ueue)< client side o" M'(

opens 'C( connection#ith Vo%Is mail ser5er

+< M'( client sendsAliceIs messa3e o5erthe 'C( connection

/< Vo%Is mail ser5erplaces the messa3e inVo%Is mail%o

6< Vo% in5o$es his usera3ent to read messa3e

mail

server 

mail

server 

+

/ D

4

-

 Alice’s mail server  Kob’s mail server 

user agent

Page 53: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 53/107

Application Layer 2-/)

ample M'( interaction

  S: ==' ham<ur"er.edu

0: HE*2 crepes.$r

S: =' Hello crepes.$r( pleased to meet ou

0: >!* #B2>: aliceKcrepes.$rI

S: =' aliceKcrepes.$r... Sender o8

0: B0PT T2: <o<Kham<ur"er.eduI

S: =' <o<Kham<ur"er.edu ... Becipient o80: D!T!

S: %C Enter mail( end with A.A on a line < itsel$

0: Do ou li8e 8etchup9

0: How a<out pic8les9

0: .S: =' >essa"e accepted $or deli7er

0: LT

S: ==1 ham<ur"er.edu closin" connection

Page 54: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 54/107

Application Layer 2-/+

 'ry M'( interaction "or yoursel"

telnet ser7ername = see 220 reply "rom ser5er enter &L, MA.L *RM, RC(' ', A'A, 4.'

commands 

a%o5e lets you send email #ithout usin3 emailclient 9reader<

Page 55: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 55/107

Page 56: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 56/107

Application Layer 2-/6

Mail messa3e "ormat

M'( protocol "orechan3in3 emailms3s

R*C ?22 standard "ortet messa3e "ormat

header lines, e!3!,  'o *rom u%ect

di6erent  fromM'(

MA.L *RM, RC(' ' commandsN

Vody the Gmessa3eH AC.. characters only

header 

body

blank

line

Page 57: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 57/107

Application Layer 2-/

Mail access protocols

M'( deli5ery7stora3e to recei5erIs ser5er mail access protocol retrie5al "rom ser5er

(( (ost Dce (rotocol TR*C 1B)BU authoriQation,do#nload

.MA( .nternet Mail Access (rotocol TR*C 1)0U more"eatures, includin3 manipulation o" stored ms3s on ser5er

&''( 3mail, &otmail, :ahooN Mail, etc!

sender’s mailserver 

25T 25Tmail access

 protocol 

receiver’s mailserver 

(e.g., POP,IP  "

user 

agentuser 

agent

(() t l

Page 58: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 58/107

Application Layer 2-/?

(() protocol

authori1ation phase client commands

user: declare username pass: pass#ord

ser5er responses

)26  -EBB 

transaction phase% client

list: list messa3e num%ers retr: retrie5e messa3e %y

num%er dele: delete Luit

#pdate phase

  0: list

S: 1 C43

S: = 41=

S: .

0: retr 1

S: messa"e 1 contentsI 

  S: .

0: dele 1

0: retr =

S: messa"e 1 contentsI 

  S: .

0: dele =

0: ,uit

S: )26 P2P% ser7er si"nin" o$$

S: )26 P2P% ser7er read

0: user <o<

S: )260: pass hun"r

S: )26  user success$ull lo""ed on

Page 59: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 59/107

Page 60: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 60/107

Application Layer 2-60

Chapter 2 outline

2!1 principles o"net#or$applications app architectures

app re@uirements

2!2 We% and &''(

2!) *'(

2!+ electronic mail M'(, ((),.MA(

2!/

2!6 (2( applications

2! soc$etpro3rammin3#ith 4( and 'C(

Page 61: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 61/107

i

Page 62: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 62/107

Application Layer 2-62

ser5ices, structure

why not centrali1e DN50 sin3le point o" "ailure traDc 5olume distant centraliQed

data%ase

maintenance

DN5 services hostname to .(address translation

host aliasin3 canonical, alias

names mail ser5er aliasin3 load distri%ution

replicated We%ser5ers many .(addressescorrespond to onename

 : doesn#t scale! 

a distri%uted hierarchical

Page 63: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 63/107

Application Layer 2-6)

*oot >G2 2ervers

com >G2 servers org >G2 servers edu >G2 servers

poly.edu

>G2 servers

umass.edu

>G2 serversyahoo.com

>G2 serversamaEon.com

>G2 servers

pbs.org

>G2 servers

a distri%uted, hierarchicaldata%ase

client wants 9 for wwwama1oncom; <st  appro4: client @ueries root ser5er to 8nd com ser5er

client @ueries !com ser5er to 3et amaQon!com ser5er

client @ueries amaQon!com ser5er to 3et .(address "or ###!amaQon!com

L L

t

Page 64: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 64/107

Application Layer 2-6+

root name ser5ers

contacted %y local name ser5er that can notresol5e name root name ser5er

contacts authoritati5e name ser5er i" name mappin3not $no#n

3ets mappin3 returns mappin3 to local name ser5er

  1$ root name%servers& 'orld'ide

a. Merisign, Bos Angeles 7A  (4 other sites)b. =27#2# 5arina del *ey, 7Al. #7AGG Bos Angeles, 7A  (+ other sites)

e. GA2A 5t Mie!, 7Af. #nternet 2oft!are 7.alo Alto, 7A (and 8 other sites)

i. Getnod, 2tockholm (DF other sites)

k. *# Bondon (+F other sites)

m. W#> Tokyo(4 other sites)

c. 7ogent, ;erndon, MA (4 other sites)d. = 5aryland 7ollege ark, 5>h. A*B Aberdeen, 5> %. Merisign, >ulles MA (- other sites )

g. =2 >o> 7olumbus,1; (4 other sites)

'L th it ti

Page 65: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 65/107

Application Layer 2-6/

 'L, authoritati5e ser5ers

top"level domain =T*D> servers: responsi%le "or com, or3, net, edu, aero, o%s,

museums, and all top-le5el country domains,e!3! u$, "r, ca, p

et#or$ olutions maintains ser5ers "or !com 'L

ducause "or !edu 'L

authoritative DN5 servers:  or3aniQationIs o#n ser5er9s<, pro5idin3

authoritati5e hostname to .( mappin3s "oror3aniQationIs named hosts

can %e maintained %y or3aniQation or ser5icepro5ider

Page 66: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 66/107

name

Page 67: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 67/107

Application Layer 2-6

re?uesting hostcis.pol.ed)

gaia.cs.)mass.ed)

root >G2 server 

local >G2 server dns.pol.ed)

+

/ D

4

-

authoritative >G2 server 

dns'cs'umass'edu

F8

TB> >G2 server 

nameresolution

eample host at cis!poly!edu#ants .( address"or3aia!cs!umass!edu

iterated .uery: contacted ser5er

replies #ith nameo" ser5er to contact

G. donIt $no# thisname, %ut as$ thisser5erH

name

Page 68: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 68/107

Application Layer 2-6?

4

-

D

recursive quer:  puts %urden o" name

resolution oncontacted nameser5er

hea5y load at upperle5els o" hierarchyE

re?uesting hostcis.pol.ed)

gaia.cs.)mass.ed)

root >G2 server 

local >G2 server dns.pol.ed)

+

/ F

authoritative >G2 server 

dns'cs'umass'edu

8

nameresolution eample

TB> >G2server 

cachin3 updatin3

Page 69: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 69/107

Application Layer 2-6B

cachin3, updatin3records

once 9any< name ser5er learns mappin3, itcaches mappin3 cache entries timeout 9disappear< a"ter some time

9''L<  'L ser5ers typically cached in local name ser5ers

Y thus root name ser5ers not o"ten 5isited cached entries may %e out"of"date 9%est e>ort

name-to-address translationN< i" name host chan3es .( address, may not %e

$no#n .nternet-#ide until all ''Ls epire

update7noti"y mechanisms proposed .'*standard R*C 21)6

Page 70: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 70/107

Page 71: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 71/107

Page 72: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 72/107

.nsertin3 records into

Page 73: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 73/107

Application Layer 2-)

.nsertin3 records into

eample ne# startup Get#or$ 4topiaH re3ister name net#or$uptopia!com at DN5

registrar  9e!3!, et#or$ olutions< pro5ide names, .( addresses o" authoritati5e

name ser5er 9primary and secondary< re3istrar inserts t#o RRs into !com 'L ser5er?networ8utopia.com( dns1.networ8utopia.com( S@

  ?dns1.networ8utopia.com( =1=.=1=.=1=.1( !@

create authoritati5e ser5er type A record "or

###!net#or$uptopia!com type MZ record"or net#or$utopia!com

A $i

Page 74: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 74/107

Attac$in3

o attac$s Vom%ard root

ser5ers #ith traDc ot success"ul to

date  'raDc *ilterin3 Local ser5ers

cache .(s o" 'Lser5ers, allo#in3 rootser5er %ypass

Vom%ard 'Lser5ers (otentially more

dan3erous

Redirect attac$s Man-in-middle

.ntercept @ueries

poisonin3

end %o3us relies to ser5er, #hichcaches

ploit "or o end @ueries #ith

spoo"ed sourceaddress tar3et .(

Re@uiresampli8cation

Application Layer 2-+

Page 75: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 75/107

Page 76: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 76/107

*ile distri%ution client-ser5er 5s (2(

Page 77: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 77/107

Application Layer 2-

*ile distri%ution client ser5er 5s (2(

Question: ho# much time to distri%ute 8le 9siQe $ < "rom one ser5er

to N peersE peer upload7do#nload capacity is limited resource

)s

)* 

d * 

server 

net!ork (!ith abundant

 band!idth)

+ile, sie - 

u s: server upload

capacity

u i : peer i upload

capacity

d i : peer i do!nload

capacity)2  d 2 

)1 d 1

d i 

)i 

*ile distri%ution time client ser5er

Page 78: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 78/107

Application Layer 2-?

*ile distri%ution time client-ser5er

server transmission: must 

se@uentially send9upload< N 8le copies time to send one copy $?us

time to send copies N$?us

increases linearly in G

time to distrib)te -to * clients )sing

clientserver approac/ cs  ma3*-4)s,,-4d min 5 

client: each client mustdo#nload 8le copy dmin O min client do#nload

rate min client do#nload time

*7dmin 

)s

net!ork

d i 

)i 

Page 79: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 79/107

Client-ser5er 5s (2( eample

Page 80: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 80/107

Application Layer 2-?0

Client-ser5er 5s! (2( eample

client upload rate P ), -4) P + hour, )s 6 10), d min 7 )s

(2( 8le distri%ution

Page 81: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 81/107

Application Layer 2-?1

Vit'orrent

tracker: trac$s peersparticipatin3 in torrent

torrent: 3roup o"peers echan3in3chun$s o" a 8le

 Alice arrives L

file divided into /4-b chunks

peers in torrent sendreceive file chunks

L obtains list

of peers from tracker L and begins e3changing

file chunks !ith peers in torrent

(2( 8le distri%ution Vit'orrent

Page 82: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 82/107

Application Layer 2-?2

peer oinin3 torrent has no chun$s, %ut #ill

accumulate them o5ertime "rom other peers

re3isters #ith trac$er to3et list o" peers, connectsto su%set o" peers9Gnei3h%orsH<

(2( 8le distri%ution Vit'orrent

#hile do#nloadin3, peer uploads chun$s to otherpeers

peer may chan3e peers #ith #hom it echan3eschun$s

churn: peers may come and 3o once peer has entire 8le, it may 9sel8shly< lea5e or

9altruistically< remain in torrent

Vit'orrent re@uestin3, sendin3 8le

Page 83: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 83/107

Application Layer 2-?)

@ 3, 3chun$s

re.uesting chunks: at any 3i5en time,

di>erent peers ha5edi>erent su%sets o" 8lechun$s

periodically, Alice as$seach peer "or list o"chun$s that they ha5e

Alice re@uests missin3chun$s "rom peers,

rarest 8rst

sending chunks: tit"for"tat  Alice sends chun$s to those

"our peers currently sendin3her chun$s at highest rate  other peers are cho$ed %y Alice

9do not recei5e chun$s "rom her<

re-e5aluate top + e5ery10 secs e5ery )0 secs randomly

select another peer, startssendin3 chun$s Goptimistically uncho$eH this

peer

ne#ly chosen peer may oin top+

Page 84: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 84/107

istri%uted &ash 'a%le

Page 85: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 85/107

istri%uted &ash 'a%le9&'< &ash ta%le

&' paradi3m

Circular &' and o5erlay net#or$s

(eer churn

Page 86: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 86/107

&ash 'a%le

Page 87: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 87/107

Original Key Key Value

!ohn "ashington 0.-%('0 #$%&'(&$')*+iana ,ouise !ones )0**$'- )-#&''&$).#

/iaoming ,iu #'-)#*. $0'&(#&*.*%

1akesh 2opal %$-**#% ((#&0.&#.'-

,inda 3ohen '($*.$0 %#)&--&'-*.445 444

,isa 6obaashi .%.*#%( #))&%$&*#..

Q More con5enient to store and searchon numerical representation o" $ey

Q $ey O hash9ori3inal $ey<

&ash 'a%le

istri%uted &ash 'a%le

Page 88: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 88/107

istri%ute 9$ey, 5alue< pairs o5er millions o"

peers pairs are e5enly distri%uted o5er peers

Any peer can @uery data%ase #ith a $ey data%ase returns 5alue "or the $ey

 'o resol5e @uery, small num%er o" messa3esechan3ed amon3 peers

ach peer only $no#s a%out a small num%ero" other peers

Ro%ust to peers comin3 and 3oin3 9churn<

9&'<

Assi3n $ey-5alue pairs to

Page 89: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 89/107

3 y ppeers rule assi3n $ey-5alue pair to the peer

that has the closest  .! con5ention closest is the immediate

successor o" the $ey!

e!3!, . space \0,1,2,),=,6)] suppose ? peers1,12,1),2/,)2,+0,+?,60 ." $ey O /1, then assi3ned to peer 60 ." $ey O 60, then assi3ned to peer 60 ." $ey O 61, then assi3ned to peer 1

Circular &'

Page 90: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 90/107

1

12

1)

2/

)2+0

+?

60

Circular &'

Q

each peer only  a#are o"immediate successor andpredecessor!

Roverlay net!orkS

Resol5in3 a @uery

Page 91: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 91/107

1

12

1)

2/

)2+0

+?

60

What is the 5alueassociated #ith $e

5alue

7=N> messa3es

on a53era3e to resol5e

@uery, #hen there

are N peers

Resol5in3 a @uery

Circular &' #ith shortcuts

Page 92: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 92/107

Circular &' #ith shortcuts

Q each peer $eeps trac$ o" .( addresses o"predecessor, successor, short cuts!Q reduced "rom 6 to ) messa3es!Q possi%le to desi3n shortcuts #ith 7=log N>

nei3h%ors, 7=log N> messa3es in @uery

1

12

1)

2/

)2+0

+?

60

What is the5alue "or

$ey /)

5alue

Page 93: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 93/107

Page 94: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 94/107

Chapter 2 outline

Page 95: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 95/107

Application Layer 2-B/

Chapter 2 outline

2!1 principles o"net#or$applications app architectures

app re@uirements2!2 We% and &''(

2!) *'(

2!+ electronic mail M'(, ((),

.MA(

2!/

2!6 (2( applications2! soc$et

pro3rammin3#ith 4( and 'C(

oc$et pro3rammin3

Page 96: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 96/107

Application Layer 2-B6

p 3 3

goal: learn ho# to %uild client7ser5er applicationsthat communicate usin3 soc$ets

socket: door %et#een application process andend-end-transport protocol

#nternet

controlled

by 12

controlled byapp developer 

transport

application

physicallin$

net#or$

process

transport

application

physicallin$

net#or$

processsocket 

oc$et pro3rammin3

Page 97: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 97/107

Application Layer 2-B

p 3 3

Two socket types for two transport services: #D: unrelia%le data3ram TC: relia%le, %yte stream-oriented

 Application 4ample:1! Client reads a line o" characters 9data<

"rom its $ey%oard and sends the data tothe ser5er!

2!  'he ser5er recei5es the data andcon5erts characters to uppercase!

)!  'he ser5er sends the modi8ed data tothe client!

+! 'he client recei5es the modi8ed data

oc$et pro3rammin3 with#D

Page 98: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 98/107

Application Layer 2-B?

#D4( no GconnectionH %et#een client

ser5er no handsha$in3 %e"ore sendin3 data sender eplicitly attaches .( destination

address and port X to each pac$et

rc5r etracts sender .( address and portX "romrecei5ed pac$et

4( transmitted data may %e lost orrecei5ed out-o"-order

Application 5ie#point 4( pro5ides unreliable trans"er o" 3roups o"

%ytes 9Gdata3ramsH< %et#een client and ser5er

Client7ser5er soc$et interaction4(

Page 99: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 99/107

4(

close

client2ocket

read datagram fromclient2ocket

create socket:client2ocket P

socket(A'#GT,217>@*A5)

7reate datagram !ith server # andportP3" send datagram via

client2ocket

create socket, portP 3:

server2ocket P

socket(A'#GT,217>@*A5)

read datagram from

server2ocket

!rite reply to

server2ocketspecifying

client address,

port number 

 Application /

ser5er 9runnin3 on server7P< client

ample app 4( client

Page 100: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 100/107

Application Layer 2-100

from socket import U

serverGame P Vhostname’

serverort P +/000

client2ocket P socket(socket.A'#GT,

socket.217>@*A5)

message P ra!input(’#nput lo!ercase sentence:’)

client2ocket.sendto(message,(serverGame, serverort))

modified5essage, serverAddress P

client2ocket.recvfrom(/08)

print modified5essage

client2ocket.close()

Pt/on 8PClient 

include ython’s socketlibrary

create => socket for

server 

get user keyboard

input

 Attach server name, port to

message" send into socket

print out received string

and close socket

read reply characters from

socket into string

ample app 4( ser5er

Page 101: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 101/107

Application Layer 2-101

from socket import U

serverort P +/000

server2ocket P socket(A'#GT, 217>@*A5)

server2ocket.bind((, serverort))

print RT/e server is read to receiveS

!hile +:

  message, clientAddress P server2ocket.recvfrom(/08)

  modified5essage P message.upper()

  server2ocket.sendto(modified5essage, clientAddress)

Pt/on 8P9erver 

create => socket

bind socket to local port

number +/000

loop forever 

*ead from => socket intomessage, getting client’saddress (client # and port)

send upper case string

back to this client

oc$et pro3rammin3 with

Page 102: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 102/107

Application Layer 2-102

TCclient must contact ser5er ser5er process must 8rst

%e runnin3 ser5er must ha5e created

soc$et 9door< that#elcomes clientIs contact

client contacts ser5er %y Creatin3 'C( soc$et,

speci"yin3 .( address, portnum%er o" ser5er process

when client createssocket: client 'C(

esta%lishes connection toser5er 'C(

#hen contacted %y client,

server TC creates newsocket  "or ser5er process tocommunicate #ith thatparticular client allo#s ser5er to tal$

#ith multiple clients

source port num%ersused to distin3uishclients 9more in Chap )<

 'C( pro5ides relia%le, in-ord%yte-stream trans"er 9GpipeH%et#een client and ser5er

application 5ie#point

Client7ser5er soc$et interaction'C(

Page 103: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 103/107

Application Layer 2-10)

 'C(

!ait for incoming

connection re?uestconnection2ocket P

server2ocket.accept()

create socket,

portPx, for incoming

re?uest:server2ocket P socket()

create socket,

connect to hostid , portPxclient2ocket P socket()

ser5er 9runnin3 on hostid < client

send re?uest using

client2ocketread re?uest from

connection2ocket

!rite reply toconnection2ocket

T7connection setup

close

connection2ocket

read reply from

client2ocket

close

client2ocket

ample app 'C( client

Page 104: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 104/107

Application Layer 2-10+

from socket import U

serverGame P ’servername’

serverort P +/000

client2ocket P socket(A'#GT, 2172T*A5)

client2ocket.connect((serverGame,serverort))

sentence P ra!input(V#nput lo!ercase sentence:’)

client2ocket.send(sentence)

modified2entence P client2ocket.recv(+0/)

print V'rom 2erver:’, modified2entence

client2ocket.close()

Pt/on TCPClient 

create T7 socket for

server, remote port +/000

Go need to attach server

name, port

ample app 'C( ser5er

Page 105: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 105/107

Application Layer 2-10/

 from socket import U

serverort P +/000

server2ocket P socket(A'#GT,2172T*A5)

server2ocket.bind((V’,serverort))

server2ocket.listen(+)print VThe server is ready to receive’

!hile +:

  connection2ocket, addr P server2ocket.accept()

 

sentence P connection2ocket.recv(+0/)

  capitaliEed2entence P sentence.upper()

  connection2ocket.send(capitaliEed2entence)

  connection2ocket.close()

Pt/on TCP9erver 

create T7 !elcoming

socket

server begins listening for

incoming T7 re?uests

loop forever 

server !aits on accept()

for incoming re?uests, ne!socket created on return

read bytes from socket (but

not address as in =>)

close connection to this

client (but not  !elcoming

socket)

Chapter 2

Page 106: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 106/107

Application Layer 2-106

psummary application architectures

client-ser5er (2(

application ser5icere@uirements relia%ility, %and#idth, delay

.nternet transport ser5icemodel connection-oriented,

relia%le 'C(

unrelia%le, data3rams 4(

our study of network apps now completeB

speci8c protocols

&''(

*'(

M'(, ((, .MA(

(2( Vit'orrent, &'

soc$et pro3rammin3

 'C(, 4( soc$ets

Page 107: Networking -Application Layer

7/23/2019 Networking -Application Layer

http://slidepdf.com/reader/full/networking-application-layer 107/107