1Distributed systems programming Distributed systems programming is needed in many of today’s applications Web servers, web caches, client-server applications, network devices, … From low level to services Sockets (low-level API) TODAY! RPC, RMI (higher-level API discussed earlier) CORBA (also adds services, component model) LATER! EJB, J2EE, (Java version); .net (Microsoft) Jini (Java’s answer to networked services and devices)Sockets Low-level communication interface (API) Network Programming Defined 1981Bolt, Beranek and Newman (BBN) Originally developed for the C language TCP/IP version with Unix called BSD sockets Similar API was developed for System V a.k.a TLI To some extent similar to file IO Sockets What is a socket? It is a peer-to-peer communication “endpoint” abstraction Hides details of network for programming communication situations Interfaces to some common network protocols (e.g. TCP, UDP, XNS, NetBIOS, IP, etc.) Many high level APIs are based on sockets 1985 Sun introduced RPC and NFS (Network File System) over sockets.Socket types Three types: Stream (e.g. interface to TCP), session based reliable service that takes care of connection maintenance, packet reassembly, etc. Mimics UNIX file system semantics Datagram (e.g. interface to UDP, NetBIOS), handles independent packets. Unreliable; 5% of datagrams don’t make it. Needs higher level acknowledgement service. Raw (e.g. interface to IP, ICMP, etc.), Programming interface to lower-level protocolsSocket Ports On TCP/IP networks: Socket = Internet Address(IP) + Port Address IP is a 32 bit number using dotted string notation, e.g., 206.10.47.09. Port is an “entry point”to an application that resides on a host. Commonly used and defined for server applicationsSocket Ports cont. Typically a communication is assigned to a port, a process can request/assign to access a port-number. TCP and UDP protocols (most common TCP/IP transport protocols) use port numbers 1-1023 that are reserved. Standard Internet apps (FTP, TELNET, TFTP, SMTP, SNMP,..) use ports between 1-255. > 1023 can be used for new user-level servers2Sockets To initiate a connection one must fix the roles: client or server A network connection can be connection-oriented or connectionless With a connectionless protocol there is nothing like an “Open” communication; every network IO operation can be with different process/host In a connection based operation a peer-to-peer channel is openedConnection-oriented use Connection is first established between client and server System Calls at server side socket() // creates endpoint, specify protocol (TCP, UDP, XNS, etc.), specify type (i.e. stream, datagram, etc.) Returns a small integer similar to file descriptor. bind() // register and bound network address to socket listen() // signal willing to receive connections accept() // accept a connection read(), write() // transfer dataConnection-oriented protocol Client side socket() // same meaning as in server connect() //establish contact between local-remote site read() write() //transfer dataExample, connection-oriented client-server sequencesocket()bind()listen()accept()read()write()socket()connect()write()read()SERVERCLIENTConnection establishmentData(request)Data (reply)BlocksUntilconnectSystem calls connectionless case sendto() // send datagrams (data packets) recvfrom() // receive datagrams Compared to the connection-oriented read()and write() these calls have arguments for remote protocol-specific addresses.Example 2, connectionless client-server sequence of callssocket()bind()recvfrom()sendto()socket()bind()sendto()recvfrom()SERVERCLIENTData(request)Data (reply)BlocksUntil datareceived from client3Differences connectionless vs. connection-oriented Connection establishing not required Blocks until data is received as opposed until connection is established Note: Client could also use connect() and read() write() in the connectionless case, but not “real connect” as it returns immediately, i.e. does not block as there is no connection established. Use of the sendto() and recvfrom() as opposed to the read() and write() system calls The client registers an address for itself with the bind() to be able to receive messages back (this address is sent with data automatically)More on the differences Connectionless is often useful Lower overhead, no session creation required Discovery type of situations: broadcasting queries to the network and learning who is out there… Quick messages (e.g. heartbeat, “I am alive”) Can send to 500 nodes, would need 500 sessions with the connection-oriented model If one of the messages are not received no problem… Sockets and Java Before RMI and CORBA support has been designed for Java this was the only way to do network programming Java.net package contains Set of classes that let you download and manipulate URL objects A native Java implementation of Berkeley (BSD) socketsJava sockets Semantics the same as we discussed earlier Java.net contains most of the classes needed Java.io contains socket related stream classes A socket may be associated with a “stream” in Java (provided by the Socket class implementation) Streams are fun as they hide devices, its like a data pipe You can use OutputStream, InputStream, and other stream classes derived from these with sockets. Somewhat similar to what you have seen with file access.Summary Sockets Abstraction for network programming. Java provides a nice implementation. Many known high-level protocols use sockets as underlying communication mechanisms. Disadvantages: lots of details to address, many parameters to control. Requires understanding of system issues and network protocols Advantage: Best performance in distributed applications, fine-tuning opportunities. CORBA Programming distributed systems and services Objective of this class is to give you an idea of CORBA capabilities and programming approach4What is CORBA? CORBA = Common Object Request Broker Architecture What is CORBA: A “middleware” or intermediate software layers that allow heterogeneous client and server applications to communicate in a distributed system. CORBA works with distributed systems written in : C,C++,COBOL, Java, or ADA...
View Full Document