Binding: Connecting From Procedure to Client and Server Remote Procedure Server exports its interface Three main concerns Identifies itself to network name server Parameter passing Tells local runtime its dispatcher address Failure cases Import and export are Client imports the interface Performance explicit calls Remote ain’ t cheap Looks up server through name service in the code Lack of parallelism (on both sides) Contacts server to setup a connection Directory Machine Directory 2. Register service 3. Look up server server Server 5. Do RPC 1. Register Client Machine Endpoint DCE Client Daemon Endpoint 4. Ask for endpoint Table � 37 � 38 RPC Marshaling Passing Pointers Transforms memory representation of Pointers are meaningful only in the address parameters to format suitable for transmission space of the sender… RPC stubs call type-specific procedures to marshal/ Forbid pointers? unmarshal all the parameters to the call breaks transparency On call Stub replaces call-by-reference semantics with Copy/ Client stub marshals parameters into the call packet Restore Server stub unmarshals parameters to call server’ s for simple structures (e.g. an array), pass a copy to the function server On return, roles are reversed for more complex structures (e.g., graphs), server’ s stub sends a request for the missing data to the client’ s stub Server stub marshals return values into return packet every time it encounters a pointer Client stub unmarshals return values, returns to client � 39 � 40
Failures RPC Semantics Exactly once Impossible in practice Request or response are lost Why? Server crashes after receiving request At least once If at first you don’ t succeed… Client crashes after sending request Only for idempotent operations In local procedure calls, if a machine fails, the Server must be stateless applications fails, but with RPC, if a machine fails, only At most once part of application does Zero, don’ t know, or once Cannot tell the difference between a machine failure and a network failure… Server needs to be able to identify requests, so it can resend previously computed replies Easy! Transform partial failures into total failures Zero or once A lso, while you are at it, aim a gun to your foot Transactional semantics � 42 � 41 Asynchronous RPC Asynchronous RPC In traditional RPC, caller blocks until function In asynchronous RPC, caller only blocks until it returns learns the request has been accepted Client Client Wait for result Wait for acceptance Call remote Return Call remote Return procedure from call procedure from call Accept Request Request Reply Request Calls local procedure Calls local procedure Time Time Server Server and returns result and returns result � 43 � 44
Asynchronous RPC RPC: Final Thoughts Common model for communication in distributed In asynchronous RPC, caller only blocks until it applications learns the request has been accepted and is interrupted when reply is received Relies on language support for distributed programming Interrupt client Client Wait for acceptance Stub compiler and IDL server description Commonly used for communication between Call remote Return procedure from call applications running in different address spaces Returns Ack result most RPCs are intra-node! Accept Request Request Calls local procedure Time Server “Distributed objects are different from local objects, and keeping and returns result that difference visible will keep the programmer from forgetting the difference and making mistakes. ” Jim Waldo et al., “A Note on Distributed Computing” (1994) � 45 � 46 Transport Services and Application Protocols Transport Network Link Physical Provide logical communication between processes on different hosts Transport Layer: logical communication between hosts is left to the network layer UDP & TCP Sender packages messages into segments, passes them to the network layer Receiver reassembles segments into messages, passes them to the application layer Apps can use multiple protocols (e.g., on the Internet, UDP or TCP) � 47 � 48
Internet Transport-layer Applications and their Protocols Transport Protocols TCP (Trusty Control Protocol) Application-Layer Application Transport Protocol Protocol Reliable, in-order delivery Email SMTP TCP Congestion control Remote terminal access Telnet TCP Flow control Web HTTP TCP Connection setup File Transfer FTP TCP Remote File Server NFS Typically UDP UDP (Unreliable Datagram Protocol) Streaming Multimedia Proprietary UDP or TCP Unreliable, unordered deliver Internet Telephony Prioprietary UDP or TCP no-frill extension of best-effort IP (network layer protocol) Network Management SNMP Typically UDP Routing Protocol RIP Typically UDP delay guarantees Services not available: Name Translation DNS Typically UDP bandwidth guarantees � 49 The Big Picture Socket (Sender’ s Edition) Sending application One endpoint of a two way communication between specifies IP address (to identify host) and two application processes running on a network destination port Sending process pushes messages out the socket to the uses socket bound to a source port transport protocol Transport protocol delivers message to the socket at the Transport layer receiving process breaks application message into smaller chunks Socket add to each transport-layer header Application Application Identified by Network layer Transport Transport the address of the host machine a port number, unique to the Network Network adds network layer header (with IP address) application Link Link 0-1023 are well known web server = 80; mail = 25; telnet = 23 Physical Physical � 51 � 52
Multiplexing The Big Picture at the Sender (Receiver’ s Edition) Network layer Handles data from multiple sockets removes network layer header (with IP address) Adds transport header (later used for demultiplexing) Transport layer Sources Application Destination P 1 P 2 Destination removes from each segment transport-layer Application 80 53 Application header P 3 P 4 Transport reassembles application message from segment 9157 5775 Network B Transport Transport Link Receiving application Network Network Physical Link Link Src Dst Src Dst receives message on destination port bound to A C Physical B A B C Physical socket 80 9157 80 5775 � 53 � 54 Demultiplexing Socket programming at the Receiver Handles data from multiple sockets Two socket types, depending on transport services Adds transport header (later used for demultiplexing) UDP: unreliable datagram Application Destination P 1 P 2 Source Source TCP: reliable, byte-stream oriented Application 80 53 Application P 3 P 4 Transport Application at end host distinguished by 9157 5775 Network binding socket to a port number B Transport Transport Link Network Network Physical 16 bit unsigned number; 0-1023 are bound to well- Link Link Src Dst Src Dst know applications A C Physical A B C B Physical web server = 80; mail = 25; telnet = 23 9157 80 5775 53 � 55
Socket Programming Client/Server Socket with UDP Interaction: UDP No connection between client and server Create clientsocket Create serversocket; bind to port X no handshaking before sending data Create message Send message to (ServerIP, port x) via Sender: explicitly attaches destination IP address and clientsocket port number to each packet Receiver: extracts sender IP address and port number Read data and clientAddr from from received packet serversocket Modify data Best effort: Data may be lost or received out-of-order Send modified data to clientAddr via serversocket UDP provides applications with unreliable transfer of a group of bytes (“datagram’) between client and server Receive message and serverAddr from clientsocket Close clientsocket Connectionless Demux UDP: Perspective Distinct UDP segments with same dest IP address and port, go to the same socket Speed even if they come from different source IP! no connection establishment (takes time) The application must sort things out! no congestion control: UDP can blast away! Application Destination Source P 1 Source Simplicity 6428 Application Application no connection state at sender/receiver P 4 P 3 Transport 9157 5775 Network Extra work for applications B Transport Transport Link reordering, duplicate suppression, missing packets… Network Network Physical Link Link Src Dst Src Dst but some applications may not care! A C Physical A B C B Physical streaming multimedia: loss tolerant, rate sensitive (want 9157 6428 5775 6428 constant, fast speeds) � 59
Recommend
More recommend