cs 43: computer networkschaganti/cs43/f18/... · – choice of transport protocol (tcp, udp, icmp,...

Post on 16-Apr-2020

4 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

CS 43: Computer Networks

08:NetworkServicesandDistributedSystems

19September

Reading Quiz

Lecture8-Slide2

Last class

•  Inter-processcommunicationusingmessagepassing•  Howsendandrecvbufferswork•  Concurrency

– Multi-threadingvs.multipleprocesses–  select()systemcall

Lecture8-Slide3

Today

•  Distributednetworkapplications•  Pros/Consof:

–  Client-Server–  Peer-to-peerarchitecture

•  Sourcesofcomplexity

Lecture8-Slide4

•  Cooperatingprocessesinacomputernetwork•  Varyingdegreesofintegration

–  Loose:email,webbrowsing– Medium:chat,Skype,remoteexecution,remotefilesystems

–  Tight:processmigration,distributedfilesystems Lecture8-Slide5

What is a distributed application?

Computer

Network

`processes

messages

Computer

Computer

Computer

Computer

Inter-process Communication (IPC)

•  Inordertocooperate,needtocommunicate•  AchievedviaIPC:inter-processcommunication

–  abilityforaprocesstocommunicatewithanother

Lecture8-Slide6

Inter-process Communication (IPC)

•  Inordertocooperate,needtocommunicate•  AchievedviaIPC:inter-processcommunication

–  abilityforaprocesstocommunicatewithanother

•  Onasinglemachine:–  Sharedmemory

Text

Data

Stack

Text

Data

StackP1 P2

Lecture8-Slide7

Inter-process Communication (IPC)

•  Inordertocooperate,needtocommunicate•  AchievedviaIPC:interprocesscommunication

–  abilityforaprocesstocommunicatewithanother

•  Onasinglemachine:–  Sharedmemory

Text

Data

StackP1 P2

Text

Data

Stack

SharedSegment

Lecture8-Slide8

SharedSegment

Inter-process Communication (IPC)

•  Inordertocooperate,needtocommunicate•  AchievedviaIPC:interprocesscommunication

–  abilityforaprocesstocommunicatewithanother

•  Onasinglemachine:–  Sharedmemory

•  Acrossmachines:– Weneedotherabstractions(messagepassing)

Text

Data

Stack

Text

Data

StackP1 P2

Lecture8-Slide9

Sockets

•  Processsends/receivesmessagesto/fromitssocket•  Applicationhasafewoptions,operatingsystemhandlesthedetails

–  Choiceoftransportprotocol(TCP,UDP,ICMP,SCTP,etc.)–  Transportoptions(TCP:maximumsegmentsize,delayedsends)

Internet

controlledbyOS

controlledbyappdeveloper

transport

application

physical

link

network

process

transport

application

physical

link

network

processsocket

Lecture8-Slide10

Sockets

•  Processsends/receivesmessagesto/fromitssocket•  Applicationhasafewoptions,operatingsystemhandlesthedetails

–  Choiceoftransportprotocol(TCP,UDP,ICMP,SCTP,etc.)–  Transportoptions(TCP:maximumsegmentsize,delayedsends)

•  Mustidentifywhichsocketwe’readdressing

Internet

controlledbyOS

controlledbyappdeveloper

transport

application

physical

link

network

process

transport

application

physical

link

network

processsocket

Lecture8-Slide11

App

TCP

IP

Ethernet interface

App

TCP

IP

Ethernet interface

IP IP

Ethernet interface

Ethernet interface

SONET interface

SONET interface

host host

router router

Addressing Sockets

•  IPaddressidentifiesdeviceinterface

Lecture8-Slide12

App

TCP

IP

Ethernet interface

App

TCP

IP

Ethernet interface

IP IP

Ethernet interface

Ethernet interface

SONET interface

SONET interface

host host

router router

Addressing Sockets

•  IPaddressidentifiesdeviceinterface

•  Needanotheridentifier:port–  16-bit,unsignedintegervalue–  Differentiatessockets

Lecture8-Slide13

§  TCPsocketidentifiedby4-tuple:•  sourceIPaddress•  sourceportnumber•  destIPaddress•  destportnumber

§  Receiverusesallfourvaluestodirectsegmenttoappropriatesocket

§  serverhostmaysupportmanysimultaneousTCPsockets:•  eachsocketidentifiedbyitsown4-tuple

§  webservershavedifferentsocketsforeachconnectingclient•  non-persistentHTTPwillhavedifferentsocketforeachrequest

Connection-oriented: example

Lecture8-Slide14

Connection-oriented: example

transport

application

physical

link

network

P3 transport

application

physical

link

P4

transport

application

physical

link

network

P2

source IP,port: A,9157 dest IP, port: B,80

source IP,port: B,80 dest IP,port: A,9157

host: IP address A

host: IP address C

network

P6 P5 P3

source IP,port: C,5775 dest IP,port: B,80

source IP,port: C,9157 dest IP,port: B,80

three segments, all destined to IP address: B, dest port: 80 are demultiplexed to different sockets

server: IP address B

Lecture8-Slide15

Connection-oriented: example

transport

application

physical

link

network

P3 transport

application

physical

link

transport

application

physical

link

network

P2

source IP,port: A,9157 dest IP, port: B,80

source IP,port: B,80 dest IP,port: A,9157

host: IP address A

host: IP address C

server: IP address B

network

P3

source IP,port: C,5775 dest IP,port: B,80

source IP,port: C,9157 dest IP,port: B,80

P4

threaded server

Lecture8-Slide16

Client/Server Model

•  Client–  Short-livedprocessthatmakesrequests–  “User-side”ofapplication–  Initiatesthecommunication(oftenviaconnect())

•  Server–  Exportswell-definedrequests/responseinterface–  Long-livedprocessthatwaitsforrequests–  Uponreceivingrequest,carriesitout(mayspawnprocesses)

Client ServerInternet

Lecture8-Slide17

Server:•  always-onhost•  permanent(IP)address(rendezvouslocation)•  staticportconventions(http:80,email:25,ssh:22)•  datacentersforscaling•  maycommunicatewithotherserverstorespond

Clients:•  maybeintermittentlyconnected•  mayhavedynamic(IP)addresses•  donotcommunicatedirectlywitheachother

Lecture8-Slide18

Client vs. Server

•  noalways-onserver•  arbitraryendsystemsdirectly

communicate•  peersrequestservicefrom

otherpeers,provideserviceinreturntootherpeers–  selfscalability–newpeersbringnewservicecapacity,aswellasnewservicedemands

•  peersareintermittentlyconnectedandchangeIPaddresses–  complexmanagement

peer-peer

Lecture8-Slide19

Peer-to-Peer

Peer-to-Peer

•  Apeertalksdirectlywithanotherpeer–  Symmetricresponsibility(unlikeclient/server)

•  Oftenusedfor:–  Filesharing(Napster,BitTorrent)– Games–  “NoSQL”dataretrieval–  Ingeneral:“distributedsystems”

Peer Peer

Lecture8-Slide20

In a peer-to-peer architecture, are there clients and servers?

A.  Yes

B.  No

Lecture8-Slide21

Peer-to-Peer

•  (+)Peersrequestservicefromotherpeers,provideserviceinreturntootherpeers–  selfscalability–newpeersbringnewservicecapacity,aswellasnewservicedemands

•  (-)Complexmanagement,difficultproblems

Peer Peer

Lecture8-Slide22

Advantages

•  Speed:parallelism,lesscontention•  Reliability:redundancy,faulttolerance•  Scalability:incrementalgrowth,economyofscale•  Geographicdistribution:lowlatency,reliability

Lecture8-Slide23

Network

`processes

messages

Computer

Computer

Computer

Computer

If one machine can process requests at a rate of X per second, how quickly can two machines process requests?

A.  Slowerthanonemachine(<X)B.  Thesamespeed(X)C.  Fasterthanonemachine,butnotdouble(X-2X)D.  Twiceasfast(2X)E.  Morethantwiceasfast(>2X)

Lecture8-Slide24

Disadvantages

•  Fundamentalproblemsofdecentralizedcontrol–  Stateuncertainty:nosharedmemoryorclock– Actionuncertainty:mutuallyconflictingdecisions

•  Distributedalgorithmsarecomplex

Lecture8-Slide25

Network

`processes

messages

Computer

Computer

Computer

Computer

On a single system…

•  Youhaveanumberofcomponents–  CPU– Memory– Disk–  Powersupply

•  Ifanyofthesegowrong,you’re(usually)toast.

Lecture8-Slide26

On multiple systems…

•  Newclassesoffailures(partialfailures).– Alinkmightfail

– One(ofmany)processesmightfail

–  Thenetworkmightbepartitioned

Lecture8-Slide27

On multiple systems…

•  Newclassesoffailures(partialfailures).– Alinkmightfail

– One(ofmany)processesmightfail

–  Thenetworkmightbepartitioned

Introducesmajorcomplexity! Lecture8-Slide28

If a process sends a message, can it tell the difference between a slow link and a delivery failure?

Lecture8-Slide29

If a process sends a message, can it tell the difference between a slow link and a delivery failure?

A.  Yes

B.  No

Lecture8-Slide30

What should we do to handle a partial failure? Under what circumstances, or what types of distributed applications?

A.  Ifoneprocessfailsorbecomesunreachable,switchtoaspare.

B.  Pauseorshutdowntheapplicationuntilallconnectivityandprocessesareavailable.

C.  Allowtheapplicationtokeeprunning,evenifnotallprocessescancommunicate.

D.  Handlethefailureinsomeotherway.

Lecture8-Slide31

Desirable Properties

•  Consistency– Nodesagreeonthedistributedsystem’sstate

•  Availability–  Thesystemisableandwillingtoprocessrequests

•  Partitiontolerance–  Thesystemisrobusttonetwork(dis)connectivity

Lecture8-Slide32

The CAP Theorem •  Consistency

–  Nodesagreeonthedistributedsystem’sstate•  Availability

–  Thesystemisableandwillingtoprocessrequests•  Partitiontolerance

–  Thesystemisrobusttonetwork(dis)connectivity

•  ChooseTwo•  “CAPprohibitsonlyatinypartofthedesignspace:perfect

availabilityandconsistencyinthepresenceofpartitions,whicharerare.”*

*Brewer,Eric."CAPtwelveyearslater:Howthe"rules"havechanged."Computer45.2(2012):23-29. Lecture8-Slide33

Event Ordering

•  It’sveryusefulifallnodescanagreeontheorderofeventsinadistributedsystem

•  Forexample:Twouserstryingtoupdateasharedfileacrosstworeplicas

Lecture8-Slide34

If two events occur (digitally or in the “real world”), can we always tell which happened first?

A.  Yes

B.  No

“Relativityofsimultaneity”•  Example:observingcarcrashes•  Exception:causalrelationship

Lecture8-Slide35

If two events occur (digitally or in the “real world”), can we always tell which happened first?

A.  Yes

B.  No

“Relativityofsimultaneity”•  Example:observingcarcrashes•  Exception:causalrelationship

Lecture8-Slide36

Event Ordering

•  It’sveryusefulifallnodescanagreeontheorderofeventsinadistributedsystem

•  Forexample:Twouserstryingtoupdateasharedfileacrosstworeplicas

•  “Time,Clocks,andtheOrderingofEventsinaDistributedSystem”byLeslieLamport(1978)–  Establishescausalorderings–  Cited>8000times

Lecture8-Slide37

Causal Consistency Example

•  Supposewehavethefollowingscenario:–  SallypoststoFacebook,“Billyismissing!”–  (Billyisatafriend’shouse,seesmessage,callsmom)–  Sallypostsnewmessage,“Falsealarm,he’sfine”–  Sally’sfriendJamesposts,“Whatarelief!”

•  NOTcausallyconsistent:–  Thirduser,Henry,seesonly:

Lecture8-Slide38

Causal Consistency Example

•  Supposewehavethefollowingscenario:–  SallypoststoFacebook,“Billyismissing!”–  (Billyisatafriend’shouse,seesmessage,callsmom)–  Sallypostsnewmessage,“Falsealarm,he’sfine”–  Sally’sfriendJamesposts,“Whatarelief!”

•  NOTcausallyconsistent:–  Thirduser,Henry,seesonly:

Lecture8-Slide39

Causal Consistency Example

•  Supposewehavethefollowingscenario:–  SallypoststoFacebook,“Billyismissing!”–  (Billyisatafriend’shouse,seesmessage,callsmom)–  Sallypostsnewmessage,“Falsealarm,he’sfine”–  Sally’sfriendJamesposts,“Whatarelief!”

•  Causallyconsistentversion:–  Thirduser,Henry,seesonly:

BecauseJameshadseenSally’ssecondpost(whichcausedhisresponse),HenrymustalsoseeitpriortoseeingJames’s.

Lecture8-Slide40

Summary

•  Client-servervs.peer-to-peermodels

•  Distributedsystemsarehardtobuild!–  Partialfailures– Orderingofevents

•  TakeCS87formoredetails!

Lecture8-Slide41

top related