1 / 24

CSE331: Introduction to Networks and Security

CSE331: Introduction to Networks and Security. Lecture 11 Fall 2002. Announcements. Reminder: Project 1 due on Monday, Oct. 7 th In-class midterm Wednesday, Oct. 9 th. Recap. Transport Level Protocols TCP (Transmission Control Protocol) UDP (User Datagram Protocol)

elarkin
Télécharger la présentation

CSE331: Introduction to Networks and Security

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. CSE331:Introduction to Networksand Security Lecture 11 Fall 2002

  2. Announcements • Reminder: • Project 1 due on Monday, Oct. 7th • In-class midterm Wednesday, Oct. 9th CSE331 Fall 2002

  3. Recap • Transport Level Protocols • TCP (Transmission Control Protocol) • UDP (User Datagram Protocol) • Remote Procedure Call (RPC) • Java’s remote method invocation (RMI) Today CSE331 Fall 2002

  4. Remote Procedure Call (RPC) • Mechanism for structuring distributed programs • Commonly used in OS kernels, for instance • Application-level transparency • To the programmer, RPC looks just like local procedure call CSE331 Fall 2002

  5. Remote Procedure Call (RPC) • Request/Reply Paradigm • Sender (i.e. client) sends request to server • Receiver (i.e. server) sends back response • More than UDP • Reliable • At-most-once message semantics • Less than TCP • Not byte-stream oriented • Establishing full duplex reliable channels is sometimes overkill CSE331 Fall 2002

  6. RPC Mechanism Caller (client) Callee (server) args return val. args return val. Client stub Server stub request reply request reply RPCprotocol RPCprotocol CSE331 Fall 2002

  7. Challenges for RPC • Dealing with network properties • Limited message sizes • Lost messages • Reordered messages • Multiple deliveries • Dealing with architectural differences • big vs. little endian • Data structure layout • Pointer representation • Language semantics • What about network failure? • Garbage collection Language & Compilersupport CSE331 Fall 2002

  8. Networks & RPC • Message Size • Use fragmentation/reassembly • Reliability • Use ACK’s, timeouts, and retransmission • In-order & at-most-once delivery • Use sequence numbers CSE331 Fall 2002

  9. Data Exchange Issues • Different hosts may use different data representations • Sizes of integers, floating points, characters • Big vs. Little endian • Data structure layout in memory • Padding of arrays and structs • Pointers and structured data • Pointer representation might differ • Trees, lists, etc. must be serialized • Objects and functions closures (contain code!) • Typically don’t transmit code CSE331 Fall 2002

  10. Marshalling/Unmarshalling data • Marshalling/Unmarshalling • Process of putting data into a form that can be sent over a network • Strategy 1: Receiver Makes Right • Send data in sender’s native form • Receiver fixes it up if necessary • Strategy 2: Canonical Intermediate Representation • Sender marshals data into common format • Receiver unmarshals data into its own format • (More commonly used) CSE331 Fall 2002

  11. Tagging Data • A tag is additional information that describes the structure of the marshalled data • Type information • Array lengths • Architecture information • Untagged representations are also possible • Sender and receiver know a priori the types of data being transmitted CSE331 Fall 2002

  12. Marshalling Using Tags int16 byte8 array 5 ptr16 struct{ int16,ptr16 } CSE331 Fall 2002

  13. Stubs • A stub is a piece of code that implements marshalling/unmarshalling • Can be interpreted or compiled • Typically generated from the procedure interface by a stub compiler CSE331 Fall 2002

  14. Stub Compiler Source code for P Call Proc. P Code for P args args Stub Compiler Client stub Client stub Marshalled args Marshalled args RPCprotocol RPCprotocol CSE331 Fall 2002

  15. Which Procedure to Run? • Need to identify code to execute • Host x Port x Procedure Identifier • Sometimes provided by well-known numbers • Sometimes given by external mapping CSE331 Fall 2002

  16. SunRPC • Implemented on top of UDP • Designed for LAN use • Does not support at-most-once semantics • A program called Port Mapper • Maps ports to program numbers • Runs on well-known UDP port 111 • Uses the External Data Representation (XDR) • Canonical intermediate form • Handles C types (except function pointers) • No tags CSE331 Fall 2002

  17. Distributed Computing Environment • DEC’s RPC protocol • Implemented on top of UDP • Does support at-most-once semantics • Used with Network Data Representation stub compiler • Receiver makes right strategy • Architecture tags • Description written in Interface Definition Language (IDL) • Essentially supports C’s type system • Underlying mechanism for the Common Object Request Broker Architecture (CORBA) CSE331 Fall 2002

  18. Java RMI (Remote Method Invocation) • Provides RPC Mechanism • See java.rmi.* classes & documentation • http://java.sun.com/products/jdk/rmi/ • Built on top of TCP • Quite heavy weight • Reliable • Incorporates Java’s security model CSE331 Fall 2002

  19. Java RMI Details • Classes implement Remote interface • Use the RMI Naming class to name and advertise remote objects • Naming.rebind maps URLs to Objects • Naming.lookup used by client to find Object references • Java stub compiler is rmic • Objects passed via RMI must implement the Serializable interface • Non-remote arguments (and results) are passed by copying • Remote arguments (and results) are passed by reference CSE331 Fall 2002

  20. Using Java’s Remote interface /* File: Hello.java */ import java.rmi.Remote; import java.rmi.RemoteException; public interface Hello extends Remote { String sayHello() throws RemoteException; } CSE331 Fall 2002

  21. Server Implementation /* File: HelloServer.java */ import java.rmi.*; public class HelloServer extends UnicastRemoteObject implements Hello { public HelloServer() throws RemoteException { super(); } public String sayHello() { return "Hello World!"; } /* continued on next slide */ CSE331 Fall 2002

  22. Server code continued public static void main(String args[]) { // Create and install a security manager if (System.getSecurityManager() == null) { System.setSecurityManager( new RMISecurityManager()); } try { HelloServer obj = new HelloServer(); // Bind this object instance to the // name "HelloServer" Naming.rebind("//host/HelloServer", obj); System.out.println ("HelloServer bound in registry"); } catch (Exception e) {…} } } CSE331 Fall 2002

  23. Client Code /* File: HelloClient.java */ import java.rmi.*; public class HelloClient { String message = "blank"; // "obj" refers to the remote object Hello obj = null; public static void main(String args[]) { try { obj = (Hello)Naming.lookup ("//host/HelloServer"); message = obj.sayHello(); System.out.println(message); } catch (Exception e) {…} }

  24. Compilation & Execution • Compile both files with javac • Produces HelloServer.class and HelloClient.class • Generate stubs by using rmic on HelloServer.class • Produces HelloServer_stub.class and HellowServer_skel.class • Run Java’s rmiregistry program • Start the server on host • Start the client on another CSE331 Fall 2002

More Related