[go: up one dir, main page]

0% found this document useful (0 votes)
50 views53 pages

DS - Chapter 4 - Inter-Process Communication

This document discusses the fundamentals of Inter-Process Communication (IPC) in distributed systems, emphasizing its importance for enabling communication, coordination, and resource sharing among processes running on different machines. It outlines various IPC approaches, including shared memory and message passing, and highlights the necessity of network protocols and layered communication models like the OSI model. Additionally, it addresses key functions and protocols at different layers, such as the application, transport, and network layers, which facilitate reliable data exchange and system scalability.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views53 pages

DS - Chapter 4 - Inter-Process Communication

This document discusses the fundamentals of Inter-Process Communication (IPC) in distributed systems, emphasizing its importance for enabling communication, coordination, and resource sharing among processes running on different machines. It outlines various IPC approaches, including shared memory and message passing, and highlights the necessity of network protocols and layered communication models like the OSI model. Additionally, it addresses key functions and protocols at different layers, such as the application, transport, and network layers, which facilitate reliable data exchange and system scalability.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

HARAMAYA UNIVERSITY

COLLEGE OF COMPUTING AND INFORMATICS


DEPARTMENT OF SOFTWARE ENGINEERING

FUNDAMENTALS OF DISTRIBUTED SYSTEM (SEng 3073)

CHAPTER FOUR
INTER-PROCESS COMMUNICATION

COMPILED BY: GIZACHEW B.


2 CONTENTS

 Introduction
 Importance of Inter-process Communication (IPC)
 Inter-process Communication Approaches
 Shared Memory
 Message Passing
• Remote Procedure Call
• Remote Method Invocation
• Message-Oriented Communication
• Stream-Oriented Communication
• Web Services
3
INTRODUCTION … (1)

 Inter-process communication is at the heart of all distributed systems.

 Distributed systems consist of multiple processes running on different machines that need to coordinate, share

data, and work together to achieve a common goal. IPC is the foundation for enabling such interactions.

 Communication between processes is fundamental to understanding how distributed systems function.

 Without proper mechanisms for exchanging information, it would be impossible to build or analyze distributed systems

effectively.

 Inter-process communication (IPC) is a fundamental concept in distributed systems, enabling processes running on

different machines to exchange information and coordinate their activities.

 At the core, distributed systems rely on networks for communication, and these networks use message-passing

mechanisms
4
INTRODUCTION … (2)

 Expressing communication through message passing is harder than using primitives based on shared memory, as

available for non-distributed platforms.

 Shared memory allows processes on the same machine to directly access and modify shared data structures, making

communication simpler and faster. In contrast, message passing requires explicit serialization, transmission, and

deserialization of data, which introduces complexity and potential inefficiencies.

 Modern distributed systems, such as cloud computing platforms, social media platforms, and IoT networks, involve vast

numbers of processes spread across geographically dispersed locations.

 The Internet, being inherently unreliable due to packet loss, latency, and failures, adds significant challenges to

communication.
5
INTRODUCTION … (3)

 While low-level network communication provides the basic building blocks, it is insufficient for developing complex,

large-scale distributed systems.

 Higher-level abstractions (e.g., middleware, protocols like HTTP/HTTPS, or frameworks like Apache Kafka, gRPC) are

necessary to simplify development, handle reliability issues, and manage complexity.

 These abstractions provide features like fault tolerance, load balancing, and consistency guarantees that are critical for

large-scale systems.
6
NETWORK PROTOCOLS | LAYERED PROTOCOL … (1)

 Due to the absence of shared memory, all communication in distributed systems is based on sending and receiving

messages.

 When process A wants to communicate with process B, it first builds a message in its own address space.

 Then, it executes a system call that causes the operating system to send the message over the network to B.

 Although this basic idea sounds simple enough, in order to prevent chaos, A and B have to agree on the meaning of the

bits being sent.

 Many different agreements are needed.

 How does the receiver know which is the last bit of the message?

 How can it detect if a message has been damaged or lost, and what should it do if it finds out?

 How long are numbers, strings, and other data items, and how are they represented?
7
NETWORK PROTOCOLS | LAYERED PROTOCOL … (2)

 In short, agreements are needed at a variety of levels, varying from the low-level details of bit transmission to the high-

level details of how information is to be expressed.

 To make it easier to deal with the numerous levels and issues involved in communication, the International Standards

Organization (ISO) developed a reference model that clearly identifies the various levels involved, gives them standard

names, and points out which level should do which job.

 This model is called the Open Systems Interconnection Reference Model.

 The OSI model is designed to allow open systems to communicate.

 An open system is one that is prepared to communicate with any other open system by using standard rules that govern

the format, contents, and meaning of the messages sent and received.

 These rules are formalized in what are called protocols


8
NETWORK PROTOCOLS | LAYERED PROTOCOL … (3)

 To allow a group of computers to communicate over a network, they must all agree on the protocols to be used.

 In the OSI model, communication is divided up into seven levels or layers.

 Each layer deals with one specific aspect of the communication.

 In this way, the problem can be divided up into manageable pieces, each of which can be solved independent of the

others.

 Each layer provides an interface to the one above it.

 The interface consists of a set of operations that together define the service the layer is prepared to offer its users
9
NETWORK PROTOCOLS | LAYERED PROTOCOL … (4)

 When process A on machine 1 wants to communicate with

process B on machine 2, it builds a message and passes the

message to the application layer on its machine.

 The application layer software then adds a header to the front of

the message and passes the resulting message to the presentation

layer.

 The presentation layer adds its own header and passes the result

down to the session layer, and so on.

 Some layers add not only a header to the front, but also a trailer

to the end.
10
NETWORK PROTOCOLS | LAYERED PROTOCOL … (5)

 When the message arrives at machine 2, it is passed upward, with each layer stripping off and examining

its own header.

 Finally, the message arrives at the receiver, process B, which may reply to it using the reverse path.

 The information in the layer n header is used for the layer n protocol
11
NETWORK PROTOCOLS | LAYERED PROTOCOL … (6)

APPLICATION LAYER

 The Application Layer is the topmost layer in the OSI (Open Systems Interconnection) model and is

responsible for providing network services directly to end-user applications.

 It facilitates communication between software applications and lower network layers using various

protocols.

Key Functions of the Application Layer:

 Provides network services to user applications.

 Facilitates data exchange between applications over a network.

 Utilizes protocols to define communication standards.


12
NETWORK PROTOCOLS | LAYERED PROTOCOL … (7)

APPLICATION LAYER …

 Common Application Layer Protocols

 HTTP (Hypertext Transfer Protocol) – Used for web browsing and retrieving web pages.

 HTTPS (Hypertext Transfer Protocol Secure) – A secure version of HTTP with encryption.

 FTP (File Transfer Protocol) – Used for transferring files between computers over a network.

 SMTP (Simple Mail Transfer Protocol) – Facilitates sending emails.

 DNS (Domain Name System) – Resolves domain names to IP addresses.


13
NETWORK PROTOCOLS | LAYERED PROTOCOL … (8)

PRESENTATION LAYER

 The Presentation Layer acts as a translator between the Application Layer and the lower network layers.

 It ensures that the data is in a readable format for the receiving application while maintaining security and efficiency.

Key Functions of the Presentation Layer

 Translation

 Converts characters and numbers into binary format that the network can transmit.

 Ensures that different systems with different data representations can communicate.

 Data Compression

 Reduces the size of data to improve transmission speed and efficient bandwidth usage.

 Common compression methods: JPEG (for images), MP3 (for audio), MPEG (for videos).
14
NETWORK PROTOCOLS | LAYERED PROTOCOL … (9)

PRESENTATION LAYER …

 Encryption & Decryption

 Encrypts data before transmission to protect it from unauthorized access.

 Decrypts data on the receiver's end to restore it to its original form.

 SSL (Secure Socket Layer) and TLS (Transport Layer Security) are commonly used encryption protocols.
15
NETWORK PROTOCOLS | LAYERED PROTOCOL … (10)

SESSION LAYER

 The Session Layer is responsible for establishing, managing, and terminating communication sessions between

applications on different devices. It ensures that data exchange is organized and secure.

Key Functions of the Session Layer

 Session Establishment, Maintenance, and Termination

 Creates a connection (session) between sender and receiver.

 Keeps the session active while data is being exchanged.

 Terminates the session when communication is complete.


16
NETWORK PROTOCOLS | LAYERED PROTOCOL … (11)

SESSION LAYER …

 Synchronization

 Uses checkpoints to track communication progress.

 If a session is interrupted, it can resume from the last checkpoint instead of starting over.

 Authentication and Authorization

 Verifies the identity of users before communication begins.

 Grants access permissions to ensure only authorized users or systems can exchange data.

 Session Recovery

 If a connection is lost, the session layer helps recover the session instead of restarting it.
17
NETWORK PROTOCOLS | LAYERED PROTOCOL … (12)

TRANSPORT LAYER

 The Transport Layer is responsible for ensuring end-to-end communication between devices.

 It controls data reliability, flow, and error handling to ensure that information is delivered correctly and efficiently.

Key Functions of the Transport Layer

 SEGMENTATION

 Breaks large data from the Session Layer into smaller segments for easier transmission.

 Each segment contains:

o Source and destination port numbers (to identify the sending and receiving applications).

o Sequence numbers (to reassemble the data in the correct order).


18
NETWORK PROTOCOLS | LAYERED PROTOCOL … (13)

TRANSPORT LAYER …

 FLOW CONTROL

 Manages the rate of data transmission to prevent overwhelming the receiver.

 Example: The Sliding Window Protocol allows a sender to send multiple segments before needing an

acknowledgment.

 ERROR CONTROL

 Ensures data integrity by checking for errors in transmission.

 Uses Automatic Repeat reeuest (ARQ) to retransmit lost or corrupted data.

 Example: TCP uses checksum verification to detect errors.


19
NETWORK PROTOCOLS | LAYERED PROTOCOL … (14)

NETWORK LAYER

 The Network Layer is responsible for the transmission of data between different networks.

 It ensures that data is delivered from the source device to the destination device even if they are on different networks.

 Assigns sender and receiver IP address to each segments to form packet.

Key Functions of the Network Layer


 Routing
 Logical Addressing
 Determines the best path for data to travel from the
 Assigns a unique IP address to each device on a
sender to the receiver.
network.
 Routers use routing algorithms to decide the most
 Helps in identifying the sender and receiver.
efficient route.
 Example: IPv4 and IPv6 addressing.
 Example: OSPF, RIP, BGP protocols.
20
NETWORK PROTOCOLS | LAYERED PROTOCOL … (15)

NETWORK LAYER …

 Path Determination

 Chooses the optimal route for data transmission based on network conditions like congestion, speed, and

reliability.

 Packet Switching & Forwarding

 Encapsulates segments from the Transport Layer into packets.

 Forwards these packets to the next hop toward the destination.


21
NETWORK PROTOCOLS | LAYERED PROTOCOL … (16)

DATA-LINK LAYER

 The Data Link Layer receives data from the Network Layer in the form of data packets.

 These data packets contain essential routing information, like the IP address of the sender and receiver.

 The Data Link Layer is responsible for adding a physical address to the data packets, specifically the MAC (Media

Access Control) address.

 MAC Address: This is a 12-digit alphanumeric address that is unique to each Network Interface Card (NIC).

 It is embedded into the NIC by the manufacturer and ensures the proper identification of devices on a local network.

 The data packet from the Network Layer is encapsulated into a frame at the Data Link Layer.

 Frames are the data units that the Data Link Layer uses for transmission over the network
22
NETWORK PROTOCOLS | LAYERED PROTOCOL … (17)

DATA-LINK LAYER …

 The Data Link Layer manages how data is placed and received from the physical medium, such as cables, fiber optics,

or air (wireless communication).

 Cable: Twisted pair cables (e.g., Ethernet cables) used for wired communication.

 Fiber Optics: High-speed optical fibers used for high-bandwidth, long-distance communication.

 Air: Wireless communication channels (e.g., Wi-Fi, Bluetooth) that use radio waves for transmission
23
NETWORK PROTOCOLS | LAYERED PROTOCOL … (18)

PHYSICAL LAYER

 The Physical Layer is the lowest layer of the OSI model and is responsible for the actual transmission of raw data

bits over a physical medium.

 The primary task of the Physical Layer is to convert the binary data (i.e., 1s and 0s) that it receives from the Data

Link Layer into signals suitable for transmission over a physical medium.

 These signals can take different forms depending on the type of physical medium being used.
24
NETWORK PROTOCOLS | LAYERED PROTOCOL … (19)

PHYSICAL LAYER…

The Physical Layer generates and transmits the appropriate signals for the given medium:

 Cable (Twisted Pair, Coaxial Cable, etc.):

 The binary data is converted into electrical signals. For example, in Ethernet networks, electrical pulses represent the

binary 1s and 0s.

 Fiber Optics:

 The binary data is converted into light signals. A laser or LED is used to transmit light pulses, with each pulse

representing a binary 1 or 0. This method allows for very high-speed and long-distance transmission.

 Air (Wireless Communication):

 The binary data is converted into radio waves or microwaves.

 For instance, in Wi-Fi or Bluetooth, the physical layer uses radio frequency signals to transmit data wirelessly.
25
NETWORK PROTOCOLS | LAYERED PROTOCOL … (20)

https://www.youtube.com/watch?v=Ilk7UXzV_Qc
IMPORTANCE OF INTER-PROCESS COMMUNICATION … (1)
26

The Importance of Inter-process Communication (IPC) in Distributed Systems cannot be overstated. IPC

is the backbone of communication and coordination in distributed systems, enabling processes running on

different machines to work together seamlessly.

ENABLES COMMUNICATION BETWEEN DISTRIBUTED COMPONENTS

 Distributed systems consist of multiple independent components (processes, services, or nodes) that need to

communicate to achieve a common goal.

 Facilitates data exchange between processes running on different machines.

 Allows distributed components to share information and coordinate actions.

 Example: In a web application, the frontend (client) communicates with the backend (server) using HTTP (an IPC mechanism).
IMPORTANCE OF INTER-PROCESS COMMUNICATION … (2)
27

SUPPORTS SCALABILITY FACILITATES FAULT TOLERANCE

 Scalability refers to the system's ability to handle  Fault tolerance is the system's ability to continue functioning

increasing workloads by adding more resources. despite failures.

 Enables horizontal scaling by allowing new nodes  Allows nodes to detect failures and reroute

to join the system and communicate with existing communication to healthy nodes.

nodes.  Enables replication and consensus protocols to maintain

 Ensures that communication remains efficient even system consistency.

as the system grows.  Example: In a distributed file system, if one node fails, other

 Example: In a distributed database, nodes communicate nodes can take over its responsibilities through IPC.

to replicate data and handle queries, ensuring the system

scales with demand.


IMPORTANCE OF INTER-PROCESS COMMUNICATION … (3)
28

ENABLES RESOURCE SHARING SUPPORTS TRANSPARENCY

 Distributed systems often share resources like  Transparency refers to hiding the complexity of the distributed

storage, computation, and network bandwidth. system from users and applications.

 Allows processes to request and access shared  Provides location transparency: Processes can

resources. communicate without knowing each other's physical

location.
 Ensures fair and efficient allocation of
 Ensures access transparency: Processes interact with
resources.
resources uniformly, regardless of their distribution.
 Example: In a cloud computing environment, virtual
 Example: A user accessing a file on a distributed file system
machines (VMs) communicate with hypervisors to
doesn't need to know which node stores the file.
allocate CPU and memory resources.
IMPORTANCE OF INTER-PROCESS COMMUNICATION … (4)
29

ENABLES LOAD BALANCING FACILITATES SYNCHRONIZATION


 Load balancing distributes workloads evenly  Synchronization ensures that processes execute in a
across nodes to optimize resource utilization. coordinated manner.
 Allows nodes to exchange information about  Enables processes to coordinate actions and maintain
their load and redistribute tasks. consistency.
 Ensures no single node becomes a  Supports distributed algorithms like mutual exclusion
bottleneck. and consensus.
 Example: In a web server cluster, a load balancer  Example: In a distributed transaction system, IPC ensures
uses IPC to distribute incoming requests among that all nodes agree on whether to commit or abort a
servers. transaction.
IMPORTANCE OF INTER-PROCESS COMMUNICATION … (5)
30

ENABLES REAL-TIME COMMUNICATION SUPPORTS HETEROGENEITY

 Real-time systems require timely and predictable  Distributed systems often involve diverse hardware,

communication. operating systems, and programming languages.

 Ensures low-latency communication for time-  Provides standardized communication protocols (e.g.,

sensitive applications. TCP/IP, HTTP) that work across different platforms.

 Supports protocols like WebSockets and  Ensures interoperability between heterogeneous

MQTT for real-time data exchange. components.

 Example: In online gaming, IPC ensures that player  Example: A Java-based client can communicate with a

actions are communicated and reflected in real-time. Python-based server using REST APIs.
IMPORTANCE OF INTER-PROCESS COMMUNICATION … (6)
31

ENABLES DECENTRALIZED ARCHITECTURES SUPPORTS MICROSERVICES ARCHITECTURE

 Decentralized systems distribute control and  Microservices break applications into small, independent

decision-making across multiple nodes. services.

 Allows nodes to communicate and coordinate  Enables communication between microservices using

without a central authority. APIs, message queues, or RPC.

 Supports peer-to-peer (P2P) systems and  Ensures loose coupling and independent deployment of

blockchain networks. services.

 Example: In a blockchain, nodes use IPC to  Example: In an e-commerce platform, the payment service

propagate transactions and reach consensus. communicates with the order service using gRPC.
IMPORTANCE OF INTER-PROCESS COMMUNICATION … (7)
32

ENABLES DATA CONSISTENCY ENABLES INNOVATION IN EMERGING TECHNOLOGIES

 Data consistency ensures that all nodes in a  Emerging technologies like IoT, edge computing, and AI rely

distributed system have the same view of data. on distributed systems.

 Supports protocols like two-phase commit  Provides the communication infrastructure for these

(2PC) and distributed locking. technologies.

 Ensures that updates are propagated  Supports protocols like MQTT for IoT and gRPC for

consistently across nodes. AI.

 Example: In a distributed database, IPC ensures  Example: In an IoT system, sensors use IPC to send data to

that all replicas are updated when data changes. edge servers for processing.
33
INTER-PROCESS COMMUNICATION APPROACHES … (1)

 Two basic approaches of communications (Inter-process communication paradigms)

 Shared Memory Approach

 Message Passing Approach


34
INTER-PROCESS COMMUNICATION APPROACHES … (2)

SHARED MEMORY APPROACH

 Communication between processes using shared memory requires processes to share some variable.

 One way of communication using shared memory can be imagined like this:

 Suppose process1 and process2 are executing simultaneously and they share some resources or use some information

from other process, process1 generate information about certain computations or resources being used and keeps it as a

record in shared memory.

 When process2 need to use the shared information, it will check in the record stored in shared memory and take note

of the information generated by process1 and act accordingly.

 Processes can use shared memory for extracting information as a record from other process as well as for delivering any

specific information to other process.


35
INTER-PROCESS COMMUNICATION APPROACHES … (3)

SHARED MEMORY APPROACH | Example: Producer-Consumer problem

There are two processes: Producer and Consumer. Producer produces some item and Consumer consumes that item. The two processes

shares a common space or memory location known as buffer where the item produced by Producer is stored and from where the

Consumer consumes the item if needed. There are two version of this problem: first one is known as unbounded buffer problem in which

Producer can keep on producing items and there is no limit on size of buffer, the second one is known as bounded buffer problem in

which producer can produce up to a certain amount of item and after that it starts waiting for consumer to consume it. We will discuss

the bounded buffer problem. First, the Producer and the Consumer will share some common memory, then producer will start producing

items. If the total produced item is equal to the size of buffer, producer will wait to get it consumed by the Consumer. Similarly, the

consumer first check for the availability of the item and if no item is available, Consumer will wait for producer to produce it. If there are

items available, consumer will consume it.


36
INTER-PROCESS COMMUNICATION APPROACHES … (4)

MESSAGE PASSING APPROACH

 Inter-process communication between processes via message passing.

 In this method, processes communicate with each other without using any kind of shared memory.

 Mostly used in distributed system.

 Inter-process communication techniques that use message passing approach

 Remote Procedure Call (RPC)

 Remote Method Invocation (RMI)

 Message-Oriented Communication

 Stream-Oriented Communication
37
IPC TECHNIQUES | REMOTE PROCEDURE CALL … (1)

 A Remote Procedure Call (RPC) is a communication protocol that allows a program to invoke a procedure (or function) located

on a remote server or system as if it were a local procedure call.

 The key idea behind RPC is a request-response protocol to enable the client (local machine) to call a function or access a service

from a server (remote machine) without needing to explicitly manage the underlying network communication details. A

procedure call is also called function call or subroutine call.

 An RPC is initiated by the client, which sends a request message to a known remote server to execute a specified procedure with

supplied parameters. RPC uses client-server model.

 The RPC model implies a level of location transparency, namely that calling procedures is largely the same whether it is local or

remote, but usually they are not identical, so local calls can be distinguished from remote calls.

 An important difference between remote procedure calls and local calls is that remote calls can fail because of unpredictable

network problems.
38
IPC TECHNIQUES | REMOTE PROCEDURE CALL … (2)
39
IPC TECHNIQUES | REMOTE PROCEDURE CALL … (3)

 The RPC (Remote Procedure Call) implementation

typically involves five key elements: CLIENT

 Client, • The client is the program that initiates the RPC by invoking

 Client Stub, a procedure (function) that resides on the remote server.

 RPC Runtime, • The client sends a request (with necessary parameters) to

 Server Stub, and the remote server and waits for a response.

 Server • The client does not need to worry about how the server is

implemented or how the communication is handled, thanks

to the abstraction provided by the RPC mechanism.


40
IPC TECHNIQUES | REMOTE PROCEDURE CALL … (4)

CLIENT STUB

 The client stub acts as a proxy for the remote procedure.

 It provides the same interface to the client as a local function, making the remote procedure call look like a local call to

the client.

 When the client calls a remote procedure, the client stub:

 Marshals/Pack: It packages the arguments (data) of the remote function call into a format that can be transmitted

over the network.

 Sends: It sends the marshaled message to the server stub over the network (via the RPC runtime).

 After receiving the response from the server, the client stub unmarshals /unpack the data (converts it back into the

original format) and returns it to the client as if it were a local procedure call result.
41
IPC TECHNIQUES | REMOTE PROCEDURE CALL … (5)

RPC Runtime (or RPC Framework)

 The RPC runtime provides the underlying infrastructure to support the transmission of messages between the client

and server. It is responsible for managing the communication process, including:

 Serialization/Deserialization: The RPC runtime marshals (serializes) and unmarshals (deserializes) the function

arguments and results.

 Transport Protocol: It manages the network communication, typically using TCP/IP or other protocols to send

and receive the data.

 Binding: It helps to establish a connection between the client and the server, either statically (at compile time) or

dynamically (at runtime).

 Error Handling: It deals with timeouts, retries, and error management.


42
IPC TECHNIQUES | REMOTE PROCEDURE CALL … (6)

SERVER STUB

 The server stub receives the request from the client, unmarshals/unpack the message, and invokes the actual procedure

on the server.

 When the server stub receives a message from the client:

 Unmarshals/unpack: It extracts the parameters from the received message.

 Invokes the Procedure: It calls the actual function (procedure) on the server with the unmarshalled parameters.

 Returns the Result: After the procedure completes, the server stub marshals/pack the result and sends it back to

the client stub via the RPC runtime.

 The server stub makes the remote function appear as if it's being called directly by the server, without the server needing

to handle the network details directly.


43
IPC TECHNIQUES | REMOTE PROCEDURE CALL … (7)

SERVER

 The server is the program that provides the actual remote procedure or service.

 It contains the implementation of the procedures that the client will call remotely.

 The server:

 Waits for incoming requests from clients (via the server stub).

 Processes the requests (invoking the corresponding procedure with the arguments received).

 Sends back the results or response to the client through the server stub.

 The server provides the functionality that the client needs to access remotely.
44
IPC TECHNIQUES | REMOTE PROCEDURE CALL … (8)
45
IPC TECHNIQUES | REMOTE PROCEDURE CALL … (9)

1. The client procedure calls the client stub in the normal way

2. The client stub builds a message & pack and calls the local OS

3. The client’s OS sends the message to the remote OS

4. The remote OS gives the message to the server stub

5. The server stub unpacks the parameters and calls the server

6. The server does the work and returns the result to the server stub

7. The server stub packs it in a message and calls its local OS

8. The server’s OS sends the message to the client’s OS

9. The client’s OS gives the message to the client stub

10. The client stub unpacks the result and returns to the client
46
IPC TECHNIQUES | REMOTE METHOD INVOCATION … (1)

 RMI enables Java objects running in different JVMs (Java Virtual Machines) to communicate over a network.

 This allows Java applications to be distributed across multiple machines.

 RMI allows Java components in separate JVMs to invoke methods on remote objects as if they were local.

 It provides seamless communication between server and client objects.

 RMI uses stub and skeleton objects to facilitate remote method calls.

 These act as proxies that handle communication between the client and the remote object.
47
IPC TECHNIQUES | REMOTE METHOD INVOCATION … (2)

How RMI Works

 RMI follows a client-server model using stubs and skeletons to handle remote communication

 Step-by-Step Process:

 Client Application calls a method on a remote object.

 The Stub (client-side proxy) forwards the request to the remote JVM.

 The request travels through the RMI runtime system and reaches the Skeleton on the server.

 The Skeleton (server-side proxy) receives the request, unmarshals it, and invokes the actual method.

 The result is marshaled and sent back to the Stub, which returns it to the client.
48
IPC TECHNIQUES | REMOTE METHOD INVOCATION … (3)

 The RMI is an API (Application Program Interface) that provides a mechanism to create distributed application in java.
 The RMI allows an object to invoke methods on an object running in another JVM.
 The RMI provides remote communication between the applications using two objects stub and skeleton.

Machine A Machine B

Client RMI Server

Machine A can invoke methods of Machine B


49
IPC TECHNIQUES | REMOTE METHOD INVOCATION … (4)

STUB SKELETON

 Creates information block  Passes request from STUB object to remote object.
 Identification of remote object  Calls desired method.
 Method name to invoke  Forward the parameters.
 Parameters to pass  Return the value to STUB object.
50
IPC TECHNIQUES | REMOTE METHOD INVOCATION … (5)

 RMI registry is a name space on which all server objects are placed.
 It is a simple server-side bootstrap naming facility that allows remote clients to get a reference to a remote object
 Servers name and register their objects to be accessed remotely with the RMI Registry.
 Clients use the name to find server objects and obtain a remote reference to those objects from the RMI Registry.
RMI Server
Bind Skeleton Object

SKELETON

RMI
Registry
STUB

Lookup for Skeleton Object


RMI Client
51
READING ASSIGNMENT

• Message-Oriented Communication
• Stream-Oriented Communication
• Web Services
52
RMI ASSIGNMENT (10 %)

Develop a Java RMI-based application that allows a client to request arithmetic operations

from a remote server. The client should take user input for two numbers and allow them to

choose an operation (addition, subtraction, multiplication, division, or modulus). The server

will perform the selected computation and return the result to the client. Ensure proper

handling of user input and potential errors (e.g., division by zero).


TEACHING YOU IS GOOD LUCK

You might also like