1 / 110

Communication

Communication. Chapter 2 Layered Protocol Remote Procedure Call(RPC). Communication. Communication Process Protocol Form of layers Four widely used models RPC RMI MOM Stream. Layered Protocols (1). Layers, interfaces, and protocols in the OSI model. 2-1. Layered Protocols (2).

agrata
Télécharger la présentation

Communication

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Communication Chapter 2 Layered Protocol Remote Procedure Call(RPC)

  2. Communication • Communication Process • Protocol • Form of layers • Four widely used models • RPC • RMI • MOM • Stream

  3. Layered Protocols (1) • Layers, interfaces, and protocols in the OSI model. 2-1

  4. Layered Protocols (2) • A typical message as it appears on the network. 2-2

  5. Layered Protocol • Lower-Level Protocols • Physical Layer • Data Link Layer • Network Layer • Transport Protocol • High Level Protocol • Session and Presentation Protocols • Application Protocols • Middleware Protocols=>Application Layer

  6. Physical Layer • Transmitting 0s and 1s. • Standardizing the electrical, mechanical, and signaling interface.

  7. Data Link Layer Consider that, A wants to send 0 and 1 to B • Discussion between a receiver and a sender in the data link layer. 2-3

  8. Network Layer • WAN consists of large number of machine • Message have to make a number of hops besides choosing an outgoing line to use. • Primary task of network layer is to decide the best path – routing • IP • ATM • Virtual channel and virtual path

  9. Transport Protocols • To ensure the reliable transport connection- without data loss • Transport layer- breaks the information from appn layer into pieces, assign a sequence number, then send them all • Connection less and connection oriented • Transmission Control Protocol – de facto standard for network communication

  10. Client-Server TCP • Normal operation of TCP. • Transactional TCP. 2-4

  11. Higher Level Protocol • Session and Presentation Protocols • Application Protocols • Middleware Protocols

  12. Session and Presentation Protocols • Session - Provides the dialogs control • Keeps track of which party is currently talking • Provide synchronous facility • Insert checkpoint to long transfer • Presentation – concern on the meaning of the bits send • Record containing fields • Names, addresses, amount of money etc.

  13. Application Protocols • Collection of standard network application • Electronic mail • File transfer • Terminal emulation application

  14. Middleware Protocols • The application that logically live in appn layer • Contains many general purpose protocols that warrant their own layers, independent of others, more specific application • Security • RPC,RMI, Message Queuing Service and Streaming

  15. Middleware Protocols An adapted reference model for networked communication.

  16. Conventional Procedure Call count = read(fd, buf, nbytes) // a call in C in a //single machine When a procedure is called, it usually makes use of the stack, pushing parameters onto the stack and reserving space for local variables: • Parameter passing in a local procedure call: the stack before the call to read • The stack while the called procedure is active

  17. Client and Server Stubs • Principle of RPC between a client and server program.

  18. Steps of a Remote Procedure Call • Client procedure calls client stub in normal way, The stub packages up the parameters into a network message. This is called marshalling. • Client stub builds message, calls local OS • Client's OS sends message to remote OS, This may be connection-oriented or connectionless. • Remote OS gives message to server stub • Server stub unpacks parameters, calls server • Server does work, returns result to the stub • Server stub packs it in message, calls local OS • Server's OS sends message to client's OS • Client's OS gives message to client stub • Stub unpacks result, returns to client

  19. Passing Value Parameters (1) • Steps involved in doing remote computation through RPC • Parameter marshaling: packing parameters into a message 2-8

  20. Without RPC Consider how you would implement a procedure to find the time on a remote machine as a string, using the IP socket calls: int remote_time(char *machine, char *time_buf) { struct sockaddr_in serv_addr; int sockfd; int nread; if (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return 1; serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = inet_addr(machine); serv_addr.sin_port = htons(13); if (connect(sockfd, &serv_addr, sizeof(serv_addr)) < 0) return 2; nread = read(sockfd, time_buf, sizeof(time_buf)); time_buf[nread] = '\0'; close(sockfd); return 0; } This very obviously uses the network.

  21. With RPC • What RPC should look like? • The network needs to be made invisible, so that everything looks just like ordinary procedure calls. The calling process would execute remote_time(machine, time_buf); All networking should be done by the RPC implementation, such as connecting to the remote machine. On the remote machine this simple function gets executed: • int remote_time(char *time_buf) { • struct tm *time; time_t t; time(&t); • time = localtime(&t); • strcpy(time_buf, asctime(time)); • return 0; }

  22. Stubs When the calling process calls a procedure, the action performed by that procedure will not be the actual code as written, but code that begins network communication. It has to connect to the remote machine, send all the parameters down to it, wait for replies, do the right thing to the stack and return. This is the client side stub. The server side stub has to wait for messages asking for a procedure to run. It has to read the parameters, and present them in a suitable form to execute the procedure locally. After execution,it has to send the results back to the calling process.

  23. stub A stub is a small program routine that substitutes for a longer program, possibly to be loaded later or that is located remotely. For example, a program that uses Remote Procedure Calls (RPC) is compiled with stubs that substitute for the program that provides a requested procedure. The stub accepts the request and then forwards it (through another program) to the remote procedure. When that procedure has completed its service, it returns the results or other status to the stub which passes it back to the program that made the request.

  24. Client Stub: ! Function that mimics the remote procedure in client’s address space (on client-node) Server Stub: ! Function that mimics a local caller (on behalf of the client) in the server’s address space(on server-side)

  25. Example import java.net.*; import java.io.*; public class Server { public static void main(String[] args) throws IOException { Socket client = null; PrintWriter pout = null; ServerSocket sock = null; try{ sock = new ServerSocket(5155); // now listen for connections while (true) { client = sock.accept(); // we have a connection pout = new PrintWriter(client.getOutputStream(), true); // write the Date to the socket pout.println(new java.util.Date().toString()); pout.close(); client.close(); } } catch (IOException ioe) { System.err.println(ioe); } finally { if (client != null) client.close(); if (sock != null) sock.close(); } } }

  26. import java.net.*; import java.io.*; public class Client { public static void main(String[] args) throws IOException { InputStream in = null; BufferedReader bin = null; Socket sock = null; try{ //make connection to the socket sock = new Socket("127.0.0.1",5155); in = sock.getInputStream(); bin = new BufferedReader(new InputStreamReader(in)); String line; while ((line = bin.readLine()) != null) System.out.println(line); } catch (IOException ioe) { System.err.println(ioe); } finally { if (sock != null) sock.close(); } } }

  27. Passing Value Parameters (2) The little numbers in boxes indicate the address of each byte. • Original message on the Pentium (5, JILL) • The message after receipt on the SPARC (5224, JILL) • The message after being inverted (5, LLIJ)

  28. Passing Reference Parameters • count = read(fd, buf, nbytes) • If the address of the buffer of second parameter is 1000 on the client • Cannot just pass the reference number to the server • Address 1000 on the server might be on the middle of program text. server client • Call-by-reference is not possible in parameter passing. Program text

  29. Passing Reference Parameters • Solution • client stub knows that the buf is in an array of characters. • also knows how big the array is. • so copy the array to the message and sent it to the server • The server stub then call the server with the pointer to this array- process and send back to the client. • copy-restore. • A copy of the referenced data structure is sent to the server, and upon return to the client stub the client’s copy of the structure is replaced with the structure modified by the server.

  30. Passing Reference Parameters(1) • Hiding the remote procedure call require the caller and the callee agree on the format of the message. • Use the same format • Define in RPC • interface-IDL • Consist of collection of procedures that can be called by a client and implemented in the server

  31. Parameter Specification and Stub Generation(2) The caller and the callee must agree on the format of the message they exchange, and they must follow the same steps when it comes to passing complex data structures (use same protocol). • A procedure • The corresponding message

  32. Extended RPC Models:Doors • The principle of using doors as IPC mechanism. • A Door is a generic name for a procedure in the address space of a server process that can be called by processes co-located with the server. • Doors require local OS support. • Client pass the integer value; server retun the squere value -See Unix Network Programming: Steven page 357

  33. Extended RPC Models :Asynchronous RPC (1) • The interconnection between client and server in a traditional RPC • The interaction using asynchronous RPC 2-12

  34. Extended RPC Models:Asynchronous RPC (2) • A client and server interacting through two asynchronous RPCs 2-13

  35. Example: DCE RPC • Distributed Computing Environment • Open Software Foundation • Middleware between existing network operating system and distributed application. • Initially design for unix – Win NT

  36. Services • Distributed file service • Directory service • Keep track of resources in the system • Security service • Distributed time service • Clocks on the different machines globally synchronize

  37. DCE stands for "Distributed Computing Environment / Remote Procedure Calls".

  38. Writing a Client and a Server • The steps in writing a client and a server in DCE RPC. 2-14

  39. Binding a Client to a Server Set up the communication between client and server software In order client to communicate with server – server must be registered and to accept the incoming call Client must know the server endpoint (port)to which it can send message. Port can be used by the server to distinguish between different process. Maintains by DCE daemon. • Client-to-server binding in DCE 2-15 Client want to bind to a video server. Pass the name to directory server Directory server then return the network address of video server. Client goes to the DCE daemon – end point of the video server. RPC take place

  40. RPC SUMMARY • RPC is well-suited for client-server interaction where the flow of control alternates. • User does not open connection, read, write, then close connection – client may not even know they are using the network. • RPC may use TCP or UDP as the transport protocol • Parameter/results marshaling issues • Extended RPC models • Example: SunRPC

  41. Distributed object eg. CORBA & DCOM • State- encapsulate data-distributed across multiple machine. • Method –operation on those data • Method are made available through interface • Proxy at the client acting as stub in RPC • The actual object reside in server machine • Incoming invocation request a first pass to a server stub – skeleton • Remote object – object on the other machine. The Common Object Requesting Broker Architecture (CORBA) is a standard defined by the Object Management Group (OMG) that enables software components written in multiple computer languages and running on multiple computers to work together.

More Related