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

41
CS 43: Computer Networks 08:Network Services and Distributed Systems 19 September

Upload: others

Post on 16-Apr-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

CS 43: Computer Networks

08:NetworkServicesandDistributedSystems

19September

Page 2: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Reading Quiz

Lecture8-Slide2

Page 3: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Last class

•  Inter-processcommunicationusingmessagepassing•  Howsendandrecvbufferswork•  Concurrency

– Multi-threadingvs.multipleprocesses–  select()systemcall

Lecture8-Slide3

Page 4: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Today

•  Distributednetworkapplications•  Pros/Consof:

–  Client-Server–  Peer-to-peerarchitecture

•  Sourcesofcomplexity

Lecture8-Slide4

Page 5: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

•  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

Page 6: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Inter-process Communication (IPC)

•  Inordertocooperate,needtocommunicate•  AchievedviaIPC:inter-processcommunication

–  abilityforaprocesstocommunicatewithanother

Lecture8-Slide6

Page 7: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Inter-process Communication (IPC)

•  Inordertocooperate,needtocommunicate•  AchievedviaIPC:inter-processcommunication

–  abilityforaprocesstocommunicatewithanother

•  Onasinglemachine:–  Sharedmemory

Text

Data

Stack

Text

Data

StackP1 P2

Lecture8-Slide7

Page 8: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Inter-process Communication (IPC)

•  Inordertocooperate,needtocommunicate•  AchievedviaIPC:interprocesscommunication

–  abilityforaprocesstocommunicatewithanother

•  Onasinglemachine:–  Sharedmemory

Text

Data

StackP1 P2

Text

Data

Stack

SharedSegment

Lecture8-Slide8

Page 9: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

SharedSegment

Inter-process Communication (IPC)

•  Inordertocooperate,needtocommunicate•  AchievedviaIPC:interprocesscommunication

–  abilityforaprocesstocommunicatewithanother

•  Onasinglemachine:–  Sharedmemory

•  Acrossmachines:– Weneedotherabstractions(messagepassing)

Text

Data

Stack

Text

Data

StackP1 P2

Lecture8-Slide9

Page 10: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 11: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 12: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 13: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 14: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

§  Receiverusesallfourvaluestodirectsegmenttoappropriatesocket

§  serverhostmaysupportmanysimultaneousTCPsockets:•  eachsocketidentifiedbyitsown4-tuple

§  webservershavedifferentsocketsforeachconnectingclient•  non-persistentHTTPwillhavedifferentsocketforeachrequest

Connection-oriented: example

Lecture8-Slide14

Page 15: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 16: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 17: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Client/Server Model

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

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

Client ServerInternet

Lecture8-Slide17

Page 18: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 19: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

•  noalways-onserver•  arbitraryendsystemsdirectly

communicate•  peersrequestservicefrom

otherpeers,provideserviceinreturntootherpeers–  selfscalability–newpeersbringnewservicecapacity,aswellasnewservicedemands

•  peersareintermittentlyconnectedandchangeIPaddresses–  complexmanagement

peer-peer

Lecture8-Slide19

Peer-to-Peer

Page 20: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Peer-to-Peer

•  Apeertalksdirectlywithanotherpeer–  Symmetricresponsibility(unlikeclient/server)

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

Peer Peer

Lecture8-Slide20

Page 21: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

A.  Yes

B.  No

Lecture8-Slide21

Page 22: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Peer-to-Peer

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

•  (-)Complexmanagement,difficultproblems

Peer Peer

Lecture8-Slide22

Page 23: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Advantages

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

Lecture8-Slide23

Network

`processes

messages

Computer

Computer

Computer

Computer

Page 24: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 25: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Disadvantages

•  Fundamentalproblemsofdecentralizedcontrol–  Stateuncertainty:nosharedmemoryorclock– Actionuncertainty:mutuallyconflictingdecisions

•  Distributedalgorithmsarecomplex

Lecture8-Slide25

Network

`processes

messages

Computer

Computer

Computer

Computer

Page 26: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

On a single system…

•  Youhaveanumberofcomponents–  CPU– Memory– Disk–  Powersupply

•  Ifanyofthesegowrong,you’re(usually)toast.

Lecture8-Slide26

Page 27: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

On multiple systems…

•  Newclassesoffailures(partialfailures).– Alinkmightfail

– One(ofmany)processesmightfail

–  Thenetworkmightbepartitioned

Lecture8-Slide27

Page 28: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

On multiple systems…

•  Newclassesoffailures(partialfailures).– Alinkmightfail

– One(ofmany)processesmightfail

–  Thenetworkmightbepartitioned

Introducesmajorcomplexity! Lecture8-Slide28

Page 29: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Lecture8-Slide29

Page 30: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 31: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 32: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Desirable Properties

•  Consistency– Nodesagreeonthedistributedsystem’sstate

•  Availability–  Thesystemisableandwillingtoprocessrequests

•  Partitiontolerance–  Thesystemisrobusttonetwork(dis)connectivity

Lecture8-Slide32

Page 33: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 34: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Event Ordering

•  It’sveryusefulifallnodescanagreeontheorderofeventsinadistributedsystem

•  Forexample:Twouserstryingtoupdateasharedfileacrosstworeplicas

Lecture8-Slide34

Page 35: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 36: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 37: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Event Ordering

•  It’sveryusefulifallnodescanagreeontheorderofeventsinadistributedsystem

•  Forexample:Twouserstryingtoupdateasharedfileacrosstworeplicas

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

Lecture8-Slide37

Page 38: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Causal Consistency Example

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

•  NOTcausallyconsistent:–  Thirduser,Henry,seesonly:

Lecture8-Slide38

Page 39: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Causal Consistency Example

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

•  NOTcausallyconsistent:–  Thirduser,Henry,seesonly:

Lecture8-Slide39

Page 40: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

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

Page 41: CS 43: Computer Networkschaganti/cs43/f18/... · – Choice of transport protocol (TCP, UDP, ICMP, SCTP, etc.) – Transport options (TCP: maximum segment size, delayed sends) Internet

Summary

•  Client-servervs.peer-to-peermodels

•  Distributedsystemsarehardtobuild!–  Partialfailures– Orderingofevents

•  TakeCS87formoredetails!

Lecture8-Slide41