Distributed ComputingAdvent of Distributed ComputingMain Issue in Designing Communication AbstractionsParadigms for Distributed ComputingInter-Process Communication (UNIX Socket IPC)Remote Procedure CallsImplementing RPCDistributed Objects (CORBA)Distributed Objects (CORBA)Distributed Shared Memory (Not widely used)Group CommunicationImportant ObservationClient-Server ModelPeer-to-PeerThe Socket AbstractionA Simple Client-Server ProgramThe socket() CallThe bind() CallThe listen() callServer InitializationThe connect() CallConnecting to the ServerBusy Server OperationThe accept() CallDistributed ComputingA Programmer’s PerspectiveAdvent of Distributed ComputingEarly programming models were designed for a single computer – there was no notion of communication between multiple machinesWith the advent of computer networks, an important question arose – how should communication be presented to the programmer? what communication abstractions make more sense? Different paradigms presented different communication abstractionsMain Issue in Designing Communication Abstractions Should the programmer write communication explicitly or should communication be hidden from the programmer? I see one machinerunning one programWhat should I run where?Communicationis transparentCommunicationis explicitParadigms for Distributed ComputingUNIX IPC (Inter-Process Communication)RPC (Remote Procedure Calls)Distributed Shared MemoryObject-Oriented ModelInter-Process Communication(UNIX Socket IPC)Simplest approach – programmer does it all.World consists of multiple machines and dataData is sent from one machine to another using send(m achine,port,data)Machine AMachine BMachine CSend()Remote Procedure CallsCommunication is completely hiddenWorld is a single machine running a single sequential programThe compiler distributes different program functions to different machines to improve performanceProgrammer does not have to know that multiple machines are involvedImplementing RPCMaking remote function calls look like local onesmain() { … function() …}Machine AOSfunction() { send message wait for reply return} Machine BOSparent() { wait for call call function() send reply}function() { …}Distributed Objects (CORBA) World is made of objectsProgrammer invokes methods on objects without having to know where the objects areObjects reside on multiple machines. System delivers method calls to objects across network (CORBA)Distributed Objects (CORBA)ORB handles remote object invocationsmain () { … obj.method() …}Object RequestBrokerDistributedObjectsFindobjectDistributed Shared Memory(Not widely used)Program has big virtual address spaceAddress space is distributed among multiple machinesCode segmentData segmentMachine AMachine BMachine CMachine DMachine EProgramGroup CommunicationWorld consists of multicast groupsEach group may span multiple machinesProgrammer knows about groups but does not have to worry about their physical locationsA message sent to a group is received by all membersImportant ObservationAll distributed communication paradigms can be built on top of IPC.Models of distributed computing using IPC:Client-serverPeer-to-peerClient-Server ModelWorld is made of:Servers: machine who provide services to a population of clients (e.g., web servers, pop mail servers, audio servers, etc)Clients: those who connect to servers (e.g., browsers, mail clients, etc)Servers are “well known”Peer-to-PeerAll machines are equal – there is no separation into servers and clientsMachines collectively perform a service to their peersAdvantages:No central point of failurePotentially more scalableDisadvantages:More difficult to programThe Socket AbstractionClientClient plugs into a server portConnection creates a bi-directional pipeServerPortA Simple Client-Server Programbind()Well-known portlisten()accept()read()write()close()eof()?write()read()connect()socket()socket()close()ClientServerThe socket() CallCreates a socket of a particular typeint socket (int family, int type, int protocol)FamilyAF_INET: IPv4 protocolsAF_INET6: IPv6 protocolsAF_LOCAL: UNIX socketAF_ROUTE: Routing socket TypeSOCK_STREAM: Stream (TCP) socketSOCK_DGARM: Datagram (UDP) socketSOCK_RAW: Raw (IP) socketThe bind() CallExecuted on the server to assign a (well-known) port address to the socketint bind (int sockfd , const struct sockaddr *myaddr , socklen_t addrlen)IP AddressPort AddressThe listen() callMoves the socket from the CLOSED to the LISTEN state in the TCP state diagram – socket is now ready to accept connectionsint listen (int sockfd, int bac k log)Server InitializationOS1. socket()Web Server2. bind(80)3. listen()80ListenqueueThe connect() CallEstablishes a connection with a serverint connect (int sockfd , const struct sockaddr *servaddr, socklen_t addrlen)Connecting to the ServerOS1. socket()Web Server2. bind(80)3. listen()80ListenqueueClientconnect()Requestfrom (IP, port)Busy Server OperationOSWeb Server80ListenqueueClient 1 Client 3Client 2Client requests get queued-up in the listen queue First-come first-servedThe accept() CallOSWeb Server80ListenqueueClient 1 Client 3Client 2Client requests get queued-up in the listen queue First-come
View Full Document