DOC PREVIEW
CORNELL CS 414 - Lecture Notes

This preview shows page 1-2-3-24-25-26 out of 26 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Remote Procedure CallsAnnouncementsReview: Use of TCP: SocketsSocket Setup (Con’t)Socket Example (Java)Goals for TodayDistributed ApplicationsUsing Messages: Send/Recv behaviorMessages for Producer-ConsumerMessages for Req/Resp comm.Client/Server ParadigmWhy not use messages?Procedure Call(Remote) Procedure CallRemote Procedure CallRPCRPC StubsRPC Call StructureRPC Return StructureRPC Information FlowRPC BindingRPC MarshallingProblems with RPCCross-Domain Comm./Location TransparencyMicrokernel operating systemsSummaryRemote Procedure Calls2Announcements•Prelim II coming up in one week:–Thursday, April 26th, 7:30—9:00pm, 1½ hour exam–101 Phillips–Closed book, no calculators/PDAs/…–Bring ID•Topics:–Since last Prelim, up to (and including) Monday, April 23rd–Lectures 19-34, chapters 10-18 (7th ed)•Project 5 due after Prelim II, Monday, April 30th –Make sure to look at the lecture schedule to keep up with due dates!3Review: Use of TCP: Sockets•Socket: an abstraction of a network I/O queue–Embodies one side of a communication channel•Same interface regardless of location of other end•Could be local machine (called “UNIX socket”) or remote machine (called “network socket”)–First introduced in 4.2 BSD UNIX: big innovation at time•Now most operating systems provide some notion of socket•Using Sockets for Client-Server (C/C++ interface):–On server: set up “server-socket”•Create socket, Bind to protocol (TCP), local address, port•call listen(): tells server socket to accept incoming requests•Perform multiple accept() calls on socket to accept incoming connection request•Each successful accept() returns a new socket for a new connection; can pass this off to handler thread–On client: •Create socket, Bind to protocol (TCP), remote address, port•Perform connect() on socket to make connection•If connect() successful, have socket connected to server4ServerSocketsocket socketconnectionRequest ConnectionnewsocketServerClientSocket Setup (Con’t)•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”•80 (web), 443 (secure web), 25 (sendmail), etc•Well-known ports from 0—10235Socket Example (Java)server://Makes socket, binds addr/port, calls listen()ServerSocket sock = new ServerSocket(6013);while(true) {Socket client = sock.accept();PrintWriter pout = newPrintWriter(client.getOutputStream(),true);pout.println(“Here is data sent to client!”);…client.close();}client:// Makes socket, binds addr/port, calls connect()Socket sock = new Socket(“169.229.60.38”,6018);BufferedReader bin = new BufferedReader(new InputStreamReader(sock.getInputStream));String line;while ((line = bin.readLine())!=null)System.out.println(line);sock.close();6Goals for Today•Implementing Distributed Applications•Messages–Send/receive–One vs. two-way communication•Remote Procedure Call7Distributed Applications•How do you actually program a distributed application?–Need to synchronize multiple threads, running on different machines •No shared memory, so cannot use test&set–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•For example, mbox is kernel buffer associated with a Socket–Send(message,mbox)•Send message to remote mailbox identified by mbox–Receive(buffer,mbox)•Wait until mbox has message, copy into buffer, and return•If threads sleeping on this mbox, wake up one of themNetworkSendReceive8Using Messages: Send/Recv behavior•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?•Actually two questions here:–When can the sender be sure that receive actually received the message?–When can sender reuse the memory containing message?•Mailbox provides 1-way communication from P1P2–P1bufferP2–Very similar to producer/consumer •Send = V (i.e. signal)•Receive = P (i.e. wait)•However, can’t tell if sender/receiver is local or not!9Messages for Producer-Consumer•Using send/receive for producer-consumer style:Producer:int msg1[1000];while(1) {prepare message; send(msg1,mbox);}Consumer:int buffer[1000];while(1) {receive(buffer,mbox);process message;}•No need for producer/consumer to keep track of space in mailbox: handled by send/receive–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 bufferSendMessageReceiveMessage10Messages for Req/Resp comm.•What about two-way communication?–Request/Response•Read a file stored on a remote machine•Request a web page from a remote web server–Also called: client-server•Client  requester, Server  responder•Server provides “service” (file storage) to the client•Example: File serviceClient: (requesting the file)char response[1000];send(“read rutabaga”, server_mbox);receive(response, client_mbox);Server: (responding with the file)char command[1000], answer[1000];receive(command, server_mbox);decode command;read file into answer;send(answer, client_mbox);RequestFileGetResponseReceiveRequestSendResponse11Client/Server Paradigm•Common model for structuring distributed computations•A server is a program (or collection of programs) that–provides some service, e.g., file service, name service, …–may exist on one or more nodes.•A client is a program that uses the service.–It first binds to the server, •i.e., locates it in the network and establishes a connection.•The client then sends requests to perform actions; –Using messages to indicate the desired service and params. –The server returns a response.12Why not use messages?•Although messages are flexible, they have problems:–Requires that programmer worry about message formats–Messages must be packed and unpacked–Server needs to decode messages to figure out the request–Messages are often asynchronous–They may require special error handling functions•Basically using messages is not a convenient paradigm for most programmers.13Procedure Call•More natural way is to


View Full Document

CORNELL CS 414 - Lecture Notes

Documents in this Course
Security

Security

49 pages

Processes

Processes

24 pages

Deadlocks

Deadlocks

57 pages

Threads

Threads

5 pages

Threads

Threads

29 pages

Deadlocks

Deadlocks

36 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes 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 Notes 2 2 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?