Unformatted text preview:

Review Window Based Acknowledgements TCP 100 140 190 340 380 400 Seq 380 Size 20 Seq 340 Size 40 Seq 300 Size 40 Seq 260 Size 40 A 140 260 Seq 140 A 190 210 Seq 230 A 190 140 Seq 260 A 190 100 Seq 300 A 190 60 Seq 190 Retransmit A 340 60 Seq 340 A 380 20 Kubiatowicz CS162 UCB Fall 2008 Review Socket Setup Con t Client 300 Seq 100 Seq 380 11 24 08 A 400 0 Lec 24 2 Goals for Today Server Socket Messages Send receive One vs two way communication new socket connection Seq 230 Size 30 November 24 2008 Prof John Kubiatowicz http inst eecs berkeley edu cs162 socket 260 A 100 300 Network Communication Abstractions Distributed Programming tion nnec o C uest Req 230 Seq 190 Size 40 Seq 100 Size 40 Seq 140 Size 50 CS162 Operating Systems and Systems Programming Lecture 24 Distributed Decision Making socket Two phase commit Byzantine Commit Remote Procedure Call Distributed File Systems Part I Server Things to remember Connection requires 5 values Src Addr Src Port Dst Addr Dst Port Protocol Often Src Port randomly assigned Done by OS during client socket setup Dst Port often well known Note Some slides and or pictures in the following are adapted from slides 2005 Silberschatz Galvin and Gagne Gagne Many slides generated from my lecture notes by Kubiatowicz 80 web 443 secure web 25 sendmail etc Well known ports from 0 1023 11 24 08 Kubiatowicz CS162 UCB Fall 2008 Lec 24 3 11 24 08 Kubiatowicz CS162 UCB Fall 2008 Lec 24 4 Distributed Applications How do you actually program a distributed application Need to synchronize multiple threads running on different machines When should send message mbox return When receiver gets message i e ack received When message is safely buffered on destination Right away if message is buffered on source node No shared memory so cannot use test set Receive Send Network Using Messages Send Receive behavior Actually two questions here One Abstraction send receive messages Already atomic no receiver gets portion of a message and two receivers cannot get same message Interface Mailbox mbox temporary holding area for messages Includes both destination location and queue Send message mbox When can the sender be sure that receiver actually received the message When can sender reuse the memory containing message Mailbox provides 1 way communication from T1 T2 T1 buffer T2 Very similar to producer consumer Send V Receive P However can t tell if sender receiver is local or not Send message to remote mailbox identified by mbox Receive buffer mbox 11 24 08 Wait until mbox has message copy into buffer and return If threads sleeping on this mbox wake up one of them Kubiatowicz CS162 UCB Fall 2008 Lec 24 5 Messaging for Producer Consumer Style 11 24 08 Request Response Read a file stored on a remote machine Request a web page from a remote web server Producer int msg1 1000 Send while 1 Message prepare message send msg1 mbox Consumer int buffer 1000 while 1 Receive receive buffer mbox Message process message Also called client server Client requester Server responder Server provides service file storage to the client Example File service Request File Client requesting the file char response 1000 send read rutabaga server mbox receive response client mbox No need for producer consumer to keep track of space in mailbox handled by send receive Server responding with the file char command 1000 answer 1000 One of the roles of the window in TCP window is size of buffer on far end Restricts sender to forward only what will fit in buffer Kubiatowicz CS162 UCB Fall 2008 Lec 24 6 Messaging for Request Response communication What about two way communication Using send receive for producer consumer style 11 24 08 Kubiatowicz CS162 UCB Fall 2008 Lec 24 7 receive command server mbox decode command read file into answer send answer client mbox 11 24 08 Kubiatowicz CS162 UCB Fall 2008 Get Response Receive Request Send ResponseLec 24 8 General s paradox General s Paradox Two Phase Commit Since we can t solve the General s Paradox i e simultaneous action let s solve a related problem Constraints of problem Distributed transaction Two machines agree to do something or not do it atomically Two generals on separate mountains Can only communicate via messengers Messengers can be captured Two Phase Commit protocol does this Use a persistent stable log on each machine to keep track of whether commit has happened Problem need to coordinate attack If they attack at different times they all die If they attack at same time they win Named after Custer who died at Little Big Horn because he arrived a couple of days too early Can messages over an unreliable network be used to guarantee two entities do something simultaneously Remarkably no even if all messages get through 11 am o k s rk wo 11 s Ye So 1 1 it is No way to be sure last message gets through Kubiatowicz CS162 UCB Fall 2008 Prepare Phase The global coordinator requests that all participants will promise to commit or rollback the transaction Participants record promise in log then acknowledge If anyone votes to abort coordinator writes Abort in its log and tells everyone to abort each records Abort in log Commit Phase After all participants respond that they are prepared then the coordinator writes Commit to its log Then asks all nodes to commit they respond with ack After receive acks coordinator writes Got Commit to log at if you Yeah but wh is ack th t ge Don t 11 24 08 If a machine crashes when it wakes up it first checks its log to recover state of world at time of crash Log can be used to complete this process such that all machines either commit or don t commit Lec 24 9 11 24 08 Two phase commit example Phase 1 Prepare Phase A writes Begin transaction to log A B OK to transfer funds to me Not enough funds B A transaction aborted A writes Abort to log Enough funds B Write new account balance promise to commit to log B A OK I can commit Phase 2 A can decide for both whether they will commit A write new account balance to log Write Commit to log Send message to B that commit occurred wait for ack Write Got Commit to log What if B crashes at beginning Wakes up does nothing A will timeout abort and retry What if A crashes at beginning of phase 2 Wakes up sees that there is a transaction in progress sends Abort to B What if B crashes at beginning of phase 2 B comes back up looks at log when A sends it Commit message it will say oh ok commit 11 24 08 Kubiatowicz CS162 UCB Fall 2008 Lec 24 10 Administrivia Simple Example A WellsFargo Bank B Bank of


View Full Document

Berkeley COMPSCI 162 - Lecture 24 Network Communication Abstractions / Distributed Programming

Documents in this Course
Lecture 1

Lecture 1

12 pages

Nachos

Nachos

41 pages

Security

Security

39 pages

Load more
Loading Unlocking...
Login

Join to view Lecture 24 Network Communication Abstractions / Distributed Programming and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 24 Network Communication Abstractions / Distributed Programming and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?