Aman - DS

Download as pdf or txt
Download as pdf or txt
You are on page 1of 59

Distributed System (3170719) 200180107014

Preface

Main motto of any laboratory/practical/field work is for enhancing required skills as well as
creating ability amongst students to solve real time problem by developing relevant competencies
in psychomotor domain. By keeping in view, GTU has designed competency focused outcome-
based curriculum for engineering degree programs where sufficient weightage is given to
practical work. It shows importance of enhancement of skills amongst the students and it pays
attention to utilize every second of time allotted for practical amongst students, instructors and
faculty members to achieve relevant outcomes by performing the experiments rather than having
merely study type experiments. It is must for effective implementation of competency focused
outcome-based curriculum that every practical is keenly designed to serve as a tool to develop
and enhance relevant competency required by the various industry among every student. These
psychomotor skills are very difficult to develop through traditional chalk and board content
delivery method in the classroom. Accordingly, this lab manual is designed to focus on the
industry defined relevant outcomes, rather than old practice of conducting practical to prove
concept and theory.

By using this lab manual students can go through the relevant theory and procedure in advance
before the actual performance which creates an interest and students can have basic idea prior to
performance. This in turn enhances pre-determined outcomes amongst students. Each experiment
in this manual begins with competency, industry relevant skills, course outcomes as well as
practical outcomes (objectives). The students will also achieve safety and necessary precautions
to be taken while performing practical.

This manual also provides guidelines to faculty members to facilitate student centric lab activities
through each experiment by arranging and managing necessary resources in order that the
students follow the procedures with required safety and necessary precautions to achieve the
outcomes. It also gives an idea that how students will be assessed by providing rubrics.

A distributed system is a computing environment in which various components are spread across
multiple computers (or other computing devices) on a network. These devices split up the work,
coordinating their efforts to complete the job more efficiently than if a single device had been
responsible for the task. Distributed systems facilitate sharing different resources and capabilities,
to provide users with a single and integrated coherent network.

Utmost care has been taken while preparing this lab manual however always there is chances of
improvement. Therefore, we welcome constructive suggestions for improvement and removal of
errors if any.
Distributed System (3170719) 200180107014

Programme Outcomes (POs)

1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex engineering
problems.
2. Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of
the information to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities
with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to
the professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need
for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader
in diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and receive
clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.
Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
Distributed System (3170719) 200180107014

Practical – Course Outcome matrix

Course Outcomes (COs):


CO1: Understand the architecture and communication system in distributes systems.
CO2: Understand the synchronization and various election algorithms in distributed
systems.
CO3: Analyze various consistency and replication protocol and methods
CO4: Recognize security threats and apply cryptography methods for security in
distributed systems.
CO5: Understand various types of distributed systems.
Sr. CO CO CO CO CO
Objective(s) of Experiment
No. 1 2 3 4 5

1. Implement Chat Server application using Java √


Implement Remote Method Invocation (RMI) to find
2. whether number is odd or even. √

3. Implement Time Server using Remote Method √


Invocation (RMI).
Implement a program to print Hello Message using
4.
Remote Procedure Call (RPC)

Implement simple calculator using Remote Procedure
5 Call (RPC) √
To Simulate the functioning of Lamport’s Logical √
6.
clock.

7. To Simulate the functioning of Lamport’s Vector clock. √

8. Implement the functioning of Bully Algorithm. √

9.
Implement client server application using CORBA √

10. Implement a Simple Web service in Java. √

11. Creation of BPEL and composite application module √


12 Study of open source Key Management Tool √
Distributed System (3170719) 200180107014

Industry Relevant Skills

The following industry relevant competency are expected to be developed in the student by
undertaking the practical work of this laboratory.
1. Will be able to develop web application using Netbeans/Ecllipse IDE
2. Will be able to do Network and distributed programming.

Guidelines for Faculty members


1. Teacher should provide the guideline with demonstration of practical to the students
with all features.
2. Teacher shall explain basic concepts/theory related to the experiment to the students before
starting of each practical
3. Involve all the students in performance of each experiment.
4. Teacher is expected to share the skills and competencies to be developed in the
students and ensure that the respective skills and competencies are developed in the
students after the completion of the experimentation.
5. Teachers should give opportunity to students for hands-on experience after the
demonstration.
6. Teacher may provide additional knowledge and skills to the students even though not
covered in the manual but are expected from the students by concerned industry.
7. Give practical assignment and assess the performance of students based on task
assigned to check whether it is as per the instructions or not.
8. Teacher is expected to refer complete curriculum of the course and follow the
guidelines for implementation.

Instructions for Students


1. Students are expected to carefully listen to all the theory classes delivered by the faculty
members and understand the COs, content of the course, teaching and examination scheme,
skill set to be developed etc.
2. Students shall organize the work in the group and make record of all observations.
3. Students shall develop maintenance skill as expected by industries.
4. Student shall attempt to develop related hand-on skills and build confidence.
5. Student shall develop the habits of evolving more ideas, innovations, skills etc. apart from
those included in scope of manual.
6. Student shall refer technical magazines and data books.
7. Student should develop a habit of submitting the experimentation work as per the schedule
and s/he should be well prepared for the same.

Common Safety Instructions


Students are expected to
1) switch on the PC carefully (not to use wet hands)
2) shutdown the PC properly at the end of your Lab
3) carefully Handle the peripherals (Mouse, Keyboard, Network cable etc)
4) Use Laptop in lab after getting permission from Teacher
Distributed System (3170719) 200180107014

Index
(Progressive Assessment Sheet)

Sr. Objective(s) of Experiment Page Date of Date of Assessme Sign. of Remar


No. No. perform submiss nt Teacher ks
ance ion Marks with date

1. Implement Chat Server application using Java


Implement Remote Method Invocation (RMI)
2. to find whether number is odd or even.

Implement Time Server using Remote Method


3.
Invocation (RMI).
Implement a program to print Hello Message
4.
using Remote Procedure Call (RPC)
Implement simple calculator using Remote
5 Procedure Call (RPC)

To Simulate the functioning of Lamport’s


6.
Logical clock.
To Simulate the functioning of Lamport’s
7.
Vector clock.
8. Implement the functioning of Bully Algorithm.
Implement client server application using
9. CORBA

10. Implement a simple web service in Java


Creation of BPEL and composite application
11.
module

Total
Distributed System (3170719) 200180107014

Experiment No: 1

Implement Chat Server application using Java


Date:

Competency and Practical Skills: Networking & Programing Skill.

Relevant CO: CO1

Objective(s): (a). Learn Socket Programing in Java


(b). Learn the relation between Client and Server Application.

Equipment/Tools Required: Personal Computer, JDK, IDE (Eclipse or NetBeans),

Theory:

A chat server application is a computer program that enables users to communicate with
each other over the internet or a network. Client-Server Model: A chat server application typically
follows a client-server model, where one or more clients connect to a central server. The server
manages the connections and the communication between the clients.

Safety and necessary Precautions:


1. Make sure the server/receiver program runs first
2. Handle all necessary compile time Exception

Procedure:

Implementing a chat server application in Java requires several steps, including setting up a server,
establishing client connections, handling client requests, and sending and receiving messages.
Here's a high-level algorithm for implementing a basic chat server application in Java:

1. Create a server socket that listens for incoming connections on a specific port number.
2. When a client connects, create a new socket to handle the client's requests and establish
input and output streams for sending and receiving messages.
3. Create a thread to handle each client connection so that multiple clients can connect and
communicate simultaneously.
4. Implement the logic for receiving and processing client requests, such as sending messages
to other clients or retrieving a list of currently connected clients.
5. Use synchronization to ensure that multiple threads do not modify shared resources (e.g. a
list of connected clients) at the same time.
6. When a client disconnects, remove it from the list of connected clients and close its socket.

G.E.C Dahod 6
Distributed System (3170719) 200180107014

Program Code:

Sample Program: (Students can frame it in their own way)

//Server
import java.net.*;
import java.io.*;

public class servertcp


{
public static void main(String args[]) throws IOException
{
ServerSocket ss=new ServerSocket(12);
Socket s=ss.accept();
System.out.println("Connection from "+s);
PrintWriter pw1=new PrintWriter(s.getOutputStream(),true);
BufferedReader br3=new BufferedReader(new InputStreamReader(s.getInputStream()));
BufferedReader br4=new BufferedReader(new InputStreamReader(System.in));
System.out.println("i m ready");
String s1, s2;

while(true)
{
do
{
s1=br4.readLine();
pw1.println(s1);
}
while(!s1.equals("over"));

do
{
s2=br3.readLine();
System.out.println(s2);
}

while(!s2.equals("over"));
}
}
} //server ends

// Client
import java.net.*;
import java.io.*;

public class clienttcp


{
public static void main(String args[]) throws IOException
{
Socket cc=new Socket(InetAddress.getLocalHost(),12);
PrintWriter pw=new PrintWriter(cc.getOutputStream(),true);

G.E.C Dahod 7
Distributed System (3170719) 200180107014
BufferedReader br1=new BufferedReader(new
InputStreamReader(cc.getInputStream()));
BufferedReader br2=new BufferedReader(new InputStreamReader(System.in));
String str1, str2;

while(true)
{
do
{
str1=br1.readLine();
System.out.println(str1);
}
while(!str1.equals("over"));
do
{
str2=br2.readLine();
pw.println(str2);
}
while(!str2.equals("over"));
}
}
} //client ends

Output:
Server Side:

Client Side:

Conclusion:
We have successfully implemented client-server chat program.

Exercise:

1. What is the role of socket class in Java for client server programing?
2. What method in Java can be used by a client program to establish a connection to a server
program?
a. Socket.accept()
b. ServerSocket.bind()
c. Socket.connect()
d. ServerSocket.accept()

Suggested References:
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. "TCP/IP Sockets in Java: Practical Guide for Programmers" by Kenneth L. Calvert and Michael J.
Donahoo.
3. Distributed Computing and application by M L Liu, Pearson Education Inc.
G.E.C Dahod 8
Distributed System (3170719) 200180107014

References used by the students:


GeekForGeeks, StackOverflow,j javatpoint

Rubric wise marks obtained:


Rubrics 1 2 3 4 5 Total
Marks

G.E.C Dahod 9
Distributed System (3170719) 200180107014

Experiment No: 2

Implement Remote Method Invocation (RMI) in java to find whether number is odd or
even

Date:

Competency and Practical Skills: Networking & Programing Skill.

Relevant CO: CO1

Objective(s): (a) Learn to develop distributed application using RMI in Java.


(b) Learn how to implement interfaces, stubs, and skeletons for RMI objects.

Equipment/Tools Required: Personal Computer, JDK, IDE (Eclipse or NetBeans), RMI


framework

Theory:
Remote Method Invocation (RMI) is a Java-based technology that enables communication
between different Java Virtual Machines (JVMs) running on different hosts in a network. RMI
provides a mechanism for invoking methods on objects that reside in different JVMs, making it
possible to implement distributed applications in Java.

The basic idea behind RMI is that a Java object running in one JVM can invoke methods on
a Java object running in another JVM. To achieve this, the Java objects that can be accessed
remotely must implement a special interface, called a Remote interface, which extends the
java.rmi.Remote interface. This interface serves as a marker, indicating that the object can be
accessed remotely.

To use RMI, the client needs to know the name or reference of the remote object it wants to
invoke. This can be done by registering the object with a naming service, such as the Java Naming
and Directory Interface (JNDI). Once the client has obtained a reference to the remote object, it can
invoke methods on the object as if it were a local object.

Using RMI you have to implement a program which will find whether the number is odd or even.

Safety and necessary Precautions:


1. Make sure the server/receiver program runs first
2. Handle all necessary compile time Exception

Procedure:

1. Define the Remote Interface: Create a remote interface, let's call it OddEvenInterface,
which declares the method signatures that will be used to determine if a number is even or
odd. This interface should extend Remote.

2. Implement the Remote Interface: Implement the OddEvenInterface interface in a class that
will be used as a remote object. Let's call it OddEvenServer. This class must extend
UnicastRemoteObject and provide an implementation for the remote methods.

3. Create the RMI Registry: Start the RMI registry on the host where the remote object will be
G.E.C Dahod 10
Distributed System (3170719) 200180107014
running. This can be done using the rmiregistry command.

4. Register the Remote Object: Register the remote object with the RMI registry using the
Naming.rebind() method. The name of the object that is used in the Naming.rebind() method
is the name that the client will use to access the remote object.

5. Create the RMI Client: Create a client program that will use the remote object to determine
if a number is even or odd. The client must look up the remote object in the RMI registry
using the Naming.lookup() method.

6. Compile and Run: Compile both the server and client classes and run the server first,
followed by the client. The output should indicate whether the number is even or odd.

Program Code:

Sample Program : (Students can frame it in their own way)

Interface:-

import java.rmi.*;

public interface OddEvenInterface extends Remote {


int isEven(String nulber) throws RemoteException;

Server:-

import java.net.*;
import java.rmi.*;
import java.rmi.registry.*;

public class OddEvenServer extends java.rmi.server.UnicastRemoteObject implements


OddEvenInterface {

String address;
Registry registry;

@Override
public int isEven(String number) throws RemoteException {
int result = 0;
try {
int value = Integer.parseInt(number);
if ((value % 2) == 0)
result = 1;
else
result = 2;
} catch (Exception e) {
}
return result;
}

G.E.C Dahod 11
Distributed System (3170719) 200180107014
public OddEvenServer() throws RemoteException {
try {
address = (InetAddress.getLocalHost()).toString();
} catch (Exception e) {
System.out.println("Can't get Inet Address.");
}
try {
registry = LocateRegistry.createRegistry(3233);
registry.rebind("rmiServer", this);
} catch (RemoteException e) {
System.out.println("Remote Exception" + e);
}
}

public static void main(String args[]) {


try {
OddEvenServer oddEvenServer = new OddEvenServer();
} catch (Exception e) {
System.exit(1);
}
}
}

Client:-

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.rmi.*;
import java.rmi.registry.*;

public class OddEvenClient {

static public void main(String args[]) throws IOException {


OddEvenInterface rmiServer;
Registry registry;
System.out.println("Enter address of Server : ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String serverAddress = br.readLine();
System.out.println("Enter port number of Server : ");
String serverPort = br.readLine();
System.out.println("Enter number : ");
String number = br.readLine();
try {
registry = LocateRegistry.getRegistry(serverAddress, (new
Integer(serverPort)).intValue());
rmiServer = (OddEvenInterface) (registry.lookup("rmiServer"));
int resultOddEven = rmiServer.isEven(number);
if (resultOddEven == 1) {
System.out.println(number + " is even number.");
} else if (resultOddEven == 2){
System.out.println(number + " is odd number.");
} else if (resultOddEven == 0){
G.E.C Dahod 12
Distributed System (3170719) 200180107014
System.out.println("Please enter only numbers.");
}
} catch (RemoteException e) {
} catch (NotBoundException e) {
System.err.println(e);
}
}
}

Conclusion:
I have successfully implemented NumberChecker server for odd and even number using RMI.

Exercise :

Q.1 What does RMI stand for?


a) Remote Method Invocation
b) Remote Method Interface
c) Remote Method Implementation
d) Remote Method Integration

Q.2 Which interface must a remote object implement in order to be accessed remotely?
a) java.rmi.Remote
b) java.rmi.Server
c) java.rmi.Client
d) java.rmi.RemoteObject

Q.3 What is the purpose of a naming service in RMI?


a) To provide a registry for remote objects
b) To serialize Java objects
c) To authenticate clients and servers
d) To encrypt network traffic

Suggested References:
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. "Java RMI" by William Grosso.
3. Distributed Computing and application by M L Liu, Pearson Education Inc.

G.E.C Dahod 13
Distributed System (3170719) 200180107014

References used by the students:


GeekForGeeks, StackOverflow,j javatpoint

Rubric wise marks obtained:


Rubrics 1 2 3 4 5 Total
Marks

G.E.C Dahod 14
Distributed System (3170719) 200180107014

Experiment No: 3

Implement Timer Server using Remote Method Invocation (RMI) in java

Date:

Competency and Practical Skills: Network programing & Programing Skill.

Relevant CO: CO1

Objectives: (a) Learn to develop distributed application using RMI in Java.


(b) Learn how to implement interfaces, stubs, and skeletons for RMI objects.

Equipment/Tools Required: Personal Computer, JDK, IDE (Eclipse or NetBeans), RMI


framework

Theory:
Remote Method Invocation (RMI) is a Java-based technology that enables communication
between different Java Virtual Machines (JVMs) running on different hosts in a network. RMI
provides a mechanism for invoking methods on objects that reside in different JVMs, making it
possible to implement distributed applications in Java.

The basic idea behind RMI is that a Java object running in one JVM can invoke methods on
a Java object running in another JVM. To achieve this, the Java objects that can be accessed
remotely must implement a special interface, called a Remote interface, which extends the
java.rmi.Remote interface. This interface serves as a marker, indicating that the object can be
accessed remotely.

To use RMI, the client needs to know the name or reference of the remote object it wants to
invoke. This can be done by registering the object with a naming service, such as the Java Naming
and Directory Interface (JNDI). Once the client has obtained a reference to the remote object, it can
invoke methods on the object as if it were a local object.

A Timer server is a type of server that provides time synchronization services to clients. It
is often used in distributed systems where it is important for all machines to have a consistent view
of time.

To implement a Timer server in Java, you can use the Java Timer class and the RMI (Remote
Method Invocation) framework.

Safety and necessary Precautions:


1. Make sure the server/receiver program runs first
2. Handle all necessary compile time Exception

Procedure:

1. Define the remote interface: Define a remote interface that extends the java.rmi.Remote
interface and declares the methods that the server will provide. In this case, you need to
define a method that returns the current time.

G.E.C Dahod 15
Distributed System (3170719) 200180107014
2. Implement the remote interface: Implement the remote interface in a server class that
extends the java.rmi.server.UnicastRemoteObject class. This class should provide an
implementation of the getTime() method.

3. Create the server: Create a server class that creates an instance of the TimeServerImpl class
and binds it to the RMI registry.
4. Create the client: Create a client class that looks up the TimeServer object in the RMI
registry and calls its getTime() method.

5. Run the server and client: Start the server class first and then start the client class. The client
should display the current time obtained from the server.

Program Code:

TimerCallback.java
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface TimerCallback extends Remote {


void timerExpired() throws RemoteException;
}

TimerInterface.java
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface TimerInterface extends Remote {


void setTimer(long delay, TimerCallback callback) throws RemoteException;
}

TimerServer.java
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class TimerServer implements TimerInterface {


public TimerServer() throws RemoteException {
super();
}

public void setTimer(long delay, TimerCallback callback) throws RemoteException {


try {
Thread.sleep(delay);
callback.timerExpired();
} catch (InterruptedException e) {
e.printStackTrace();
}
}

public static void main(String[] args) {


try {
TimerServer timerServer = new TimerServer();
G.E.C Dahod 16
Distributed System (3170719) 200180107014
TimerInterface stub = (TimerInterface) UnicastRemoteObject.exportObject(timerServer,
0);

// Create and start the RMI registry on port 1099


Registry registry = LocateRegistry.createRegistry(1099);

// Bind the TimerServer to the registry


registry.rebind("TimerServer", stub);

System.out.println("TimerServer is ready.");
} catch (Exception e) {
System.err.println("TimerServer exception: " + e.toString());
e.printStackTrace();
}
}
}

TimerClient.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.io.Serializable;

public class TimerClient {


public static void main(String[] args) {
try {
Registry registry = LocateRegistry.getRegistry("localhost");
TimerInterface timer = (TimerInterface) registry.lookup("TimerServer");

TimerCallback callback = new TimerCallbackImpl();


// Set a timer for 5 seconds
timer.setTimer(5000, callback);
System.out.println("Timer Expired");
} catch (Exception e) {
System.err.println("TimerClient exception: " + e.toString());
e.printStackTrace();
}
}
}

class TimerCallbackImpl implements TimerCallback, Serializable {


public void timerExpired() {
System.out.println("Timer expired!");
}
}

G.E.C Dahod 17
Distributed System (3170719) 200180107014

Output:

Conclusion:
I have successfully created Timer Program using Remote Procedure Call.

Exercise:
1. What is skeleton in RMI?
the skeleton in RMI acts as a gateway between the client and the server,
handling the deserialization of client requests, routing method calls to the
appropriate remote object, and serializing the results to send back to the
client. It is an essential part of the RMI infrastructure that abstracts many of the
complexities of remote method invocation

2. What is Registry in RMI?


the RMI Registry is a fundamental component that serves as a simple,
centralized repository or directory where remote objects are registered and can
be looked up by their names or references.

3. How does RMI enable remote invocation of methods?


a) By creating a proxy object that implements the remote interface of the remote object
b) By sending a serialized copy of the remote object to the client
c) By opening a socket connection between the client and server
d) By invoking methods on the remote object directly

G.E.C Dahod 18
Distributed System (3170719) 200180107014

Suggested References:
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. Distributed Computing and application by M L Liu, Pearson Education Inc.

References used by the students:


GeekForGeeks, StackOverflow,j javatpoint

Rubric wise marks obtained:


Rubrics 1 2 3 4 5 Total
Marks

G.E.C Dahod 19
Distributed System (3170719) 200180107014

Experiment No: 4

Implement a program which print Hello Message using Remote Procedure Call (RPC)

Date:

Competency and Practical Skills: Network programing & Programing Skill.

Relevant CO: CO1

Objectives: (a) To understand the concept of Remote Procedure Call (RPC) and its
implementation in Java.
(b) To create a simple Java program that demonstrates the use of RPC.

Equipment/Tools Required: Personal Computer, JDK, IDE (Eclipse or NetBeans), RMI


framework.

Theory:
Remote Procedure Call (RPC) is a technique used to enable programs to call procedures on
remote computers as if they were local procedures. It allows a program to invoke a procedure on a
remote computer using the same syntax as for local procedure calls. The RPC program consists of
a client program that sends a request to a server program to execute a procedure, and the server
program executes the procedure and sends a response back to the client.

Safety and necessary Precautions:


3. Make sure the server/receiver program runs first
4. Handle all necessary compile time Exception

Procedure:
Here's a steps for printing a "Hello" message using Remote Procedure Call (RPC) in Java:

1. Set up your development environment:

▪ Install the latest version of Java Development Kit (JDK) and NetBeans IDE (or your
preferred IDE).
▪ Create a new Java project in NetBeans.
2. Define the interface for the remote procedure:

▪Create a new Java interface called HelloService.


▪Define a single method in the interface called sayHello() that returns a String.
▪Annotate the method with the @Remote annotation from the javax.ejb package to
indicate that it is a remote method.
▪ Save the interface.
3. Implement the remote procedure:

▪Create a new Java class called HelloServiceImpl.


▪Implement the sayHello() method by returning the string "Hello, world!".
▪Annotate the class with the @Stateless annotation from the javax.ejb package to
indicate that it is a stateless session bean.
▪ Save the class.
4. Deploy the remote procedure:

G.E.C Dahod 20
Distributed System (3170719) 200180107014

▪ Right-click on the project in NetBeans and select "Clean and Build".


▪ Right-click on the project again and select "Deploy".
5. Create the client application:

▪ Create a new Java class called HelloClient.


▪ Add a main method to the class.
▪ Use the InitialContext class to look up the remote HelloService object.
▪ Call the sayHello() method on the remote object and print the result to the console.
▪ Save the class.
6. Run the client application:

▪ Right-click on the HelloClient class and select "Run File".


▪ Check the console output to see if the "Hello, world!" message was printed.

Program Code:

G.E.C Dahod 21
Distributed System (3170719) 200180107014

Output:

Conclusion:
I have successfully implemented Hello world program using Remote Procedure Call.

G.E.C Dahod 22
Distributed System (3170719) 200180107014

Exercise:
1. What is Remote Procedure Call (RPC)?
A Remote Procedure Call (RPC) is a protocol that allows one program to
request a service or function to be executed on another address space or
even on a different machine, as if it were a local function or procedure call.

2. Which framework is a popular choice for implementing RPC in Java?


RMI

3. What are some important factors to consider when implementing RPC in Java?
a. Choice of RPC Framework:
b. Serialization
c. Network Protocol
d. Error Handling

Suggested References:
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. Distributed Computing and application by M L Liu, Pearson Education Inc.

References used by the students:


GeekForGeeks, StackOverflow,j javatpoint

Rubric wise marks obtained:


Rubrics 1 2 3 4 5 Total
Marks

G.E.C Dahod 23
Distributed System (3170719) 200180107014

Experiment No: 5

Implement simple calculator using Remote Procedure Call (RPC)

Date:

Competency and Practical Skills: Network programing & Programing Skill.

Relevant CO: CO1

Objectives: (a). To implement remote procedure call (RPC) in Java


(b). To perform basic arithmetic operations using RPC
(c). To understand the concept of remote method invocation

Equipment/Tools Required: Personal Computer, JDK, IDE (Eclipse or NetBeans), RMI


framework

Theory:
Remote Procedure Call (RPC) is a technique used to enable programs to call procedures on
remote computers as if they were local procedures. It allows a program to invoke a procedure on a
remote computer using the same syntax as for local procedure calls. The RPC program consists of
a client program that sends a request to a server program to execute a procedure, and the server
program executes the procedure and sends a response back to the client.
In this experiment, we will use RPC to implement a simple calculator program that performs basic
arithmetic operations such as addition, subtraction, multiplication, and division.

Safety and necessary Precautions:


1. Make sure the server/receiver program runs first
2. Handle all necessary compile time Exception

Procedure:

Here's a step-by-step procedure to implement a simple calculator using Remote Procedure Call
(RPC) in Java:
1. Set up your development environment:
▪ Install the latest version of Java Development Kit (JDK) and NetBeans IDE (or your
preferred IDE).
▪ Create a new Java project in NetBeans.

2. Define the interface for the remote procedure:


▪ Create a new Java interface called CalculatorService.
▪ Define methods in the interface for the basic arithmetic operations such as add(),
subtract(), multiply(), and divide().
▪ Annotate the methods with the @Remote annotation from the javax.ejb package to
indicate that they are remote methods.
▪ Save the interface.

3. Implement the remote procedure:


▪ Create a new Java class called CalculatorServiceImpl.
▪ Implement the add(), subtract(), multiply(), and divide() methods by performing the
respective arithmetic operations on the input parameters.
▪ Annotate the class with the @Stateless annotation from the javax.ejb package to
indicate that it is a stateless session bean.
G.E.C Dahod 24
Distributed System (3170719) 200180107014
▪ Save the class.
4. Deploy the remote procedure:
▪ Right-click on the project in NetBeans and select "Clean and Build".
▪ Right-click on the project again and select "Deploy".

5. Create the client application:


▪ Create a new Java class called CalculatorClient
▪ Add a main method to the class.
▪ Use the InitialContext class to look up the remote CalculatorService object.
▪ Call the add(), subtract(), multiply(), and divide() methods on the remote object and
print the results to the console
. • Save the class.

6. Run the client application:


▪ Right-click on the CalculatorClient class and select "Run File". • Check the console
output to see if the arithmetic operations were performed correctly.
.
Program Code:

Calculator.java
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface Calculator extends Remote {


double add(double num1, double num2) throws RemoteException;
double subtract(double num1, double num2) throws RemoteException;
double multiply(double num1, double num2) throws RemoteException;
double divide(double num1, double num2) throws RemoteException;
}

CalculatorServer.java
import java.rmi.*;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

public class CalculatorServer implements Calculator {


public CalculatorServer() throws RemoteException {
super();
}

public double add(double num1, double num2) throws RemoteException {


return num1 + num2;
}

public double subtract(double num1, double num2) throws RemoteException {


return num1 - num2;
}

public double multiply(double num1, double num2) throws RemoteException {


return num1 * num2;
}

public double divide(double num1, double num2) throws RemoteException {


if (num2 == 0) {
G.E.C Dahod 25
Distributed System (3170719) 200180107014
throw new RemoteException("Division by zero is not allowed.");
}
return num1 / num2;
}

public static void main(String[] args) {


try {
CalculatorServer calculator = new CalculatorServer();
Calculator stub = (Calculator) UnicastRemoteObject.exportObject(calculator, 0);

// Create and start the RMI registry on port 1099


Registry registry = LocateRegistry.createRegistry(1099);

// Bind the CalculatorServer to the registry


registry.rebind("Calculator", stub);

System.out.println("CalculatorServer is ready.");
} catch (Exception e) {
System.err.println("CalculatorServer exception: " + e.toString());
e.printStackTrace();
}
}
}

CalculatorClient.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class CalculatorClient {


public static void main(String[] args) {
try {
Registry registry = LocateRegistry.getRegistry("localhost");
Calculator calculator = (Calculator) registry.lookup("Calculator");

double num1 = 10;


double num2 = 5;

double result = calculator.add(num1, num2);


System.out.println(num1 + " + " + num2 + " = " + result);

result = calculator.subtract(num1, num2);


System.out.println(num1 + " - " + num2 + " = " + result);

result = calculator.multiply(num1, num2);


System.out.println(num1 + " * " + num2 + " = " + result);

result = calculator.divide(num1, num2);


System.out.println(num1 + " / " + num2 + " = " + result);
} catch (Exception e) {
System.err.println("CalculatorClient exception: " + e.toString());
e.printStackTrace();
}
}
G.E.C Dahod 26
Distributed System (3170719) 200180107014

Output:

Conclusion:
I have successfully implemented a simple Calculator using Remote Procedure Call.

Exercise:

1. What are the advantages of using RPC?


1. Abstraction of Network Communication
2. Code Reusability
3. Location Transparency
4. Efficiency and Performance

2. How does RPC enable distributed computing?


RPC (Remote Procedure Call) enables distributed computing by providing a
mechanism for programs or processes to communicate and collaborate
across networked systems as if they were making local function calls.

3. What is the role of the client program in an RPC system?


The client program plays a crucial role in an RPC (Remote Procedure Call)
system. Its primary function is to initiate remote method calls on a remote
server or service as if they were local function calls. Here's a breakdown of
the key roles and responsibilities of the client program in an RPC system

Suggested Reference(s):
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. "Java RMI" by William Grosso
3. Distributed Computing and application by M L Liu, Pearson Education Inc.
G.E.C Dahod 27
Distributed System (3170719) 200180107014

References used by the students:


GeekForGeeks, StackOverflow,j javatpoint

Rubric wise marks obtained:


Rubrics 1 2 3 4 5 Total
Marks

G.E.C Dahod 28
Distributed System (3170719) 200180107014

Experiment No: 6

Implementation of Lamport's logical Clock Algorithm for Distributed Systems

Date :

Competency and Practical Skills: Network Programming & Programming Skill

Relevant CO: CO2

Objectives: 1. Understand the Lamport algorithm for logical clocks.


2. Implement the Lamport algorithm using Java programming language.
3. Test the Lamport algorithm to order events in a distributed system.

Equipment/Tools Required: Personal Computer, JDK, IDE (Eclipse or NetBeans)

Theory:

The Lamport algorithm is a logical clock algorithm that allows ordering of events in a
distributed system. The algorithm was proposed by Leslie Lamport in 1978.

The algorithm works by assigning a logical clock value to each event in the system. The
logical clock is a virtual clock that is incremented each time an event occurs in the system. The
logical clock value of an event is the timestamp of the event.

The Lamport algorithm ensures that the events are ordered based on their logical clock
values. If event A has a lower logical clock value than event B, then event A occurred before
event B.

The algorithm is implemented using a message passing mechanism. When a process sends
a message to another process, it includes its current logical clock value in the message. When the
receiving process receives the message, it updates its own logical clock value to the maximum of
its current value and the value received in the message. This ensures that the logical clock values
of events are monotonically increasing.

Safety and necessary Precautions: Handle all necessary compile time Exceptions.

Procedure:

1. Define the Event class: Define an Event class that stores the timestamp and the process id
of an event.

2. Define the Process class: Define a Process class that simulates a process in the distributed
system. The Process class should contain a logical clock value and a queue of events that
have occurred in the process.

3. Implement the Lamport algorithm: Implement the Lamport algorithm in the Process class.
When a process sends a message to another process, it should include its current logical
clock value in the message. When the receiving process receives the message, it should
update its own logical clock value to the maximum of its current value and the value
received in the message. When an event occurs in the process, it should be assigned a
timestamp that is the current logical clock value of the process.

G.E.C Dahod 29
Distributed System (3170719) 200180107014

4. Test the Lamport algorithm: Create a main class that creates a set of processes in the
distributed system. Each process should send messages to other processes and generate
events. The main class should display the events in the order determined by the Lamport
algorithm.

Algorithm works as follows :


• Whenever an event occurs in a process, the process increments its logical clock by 1 and
assigns the new value as the timestamp of the event.

• When a message is sent from one process to another, the sender includes its current logical
clock value as the timestamp of the message.

• When a process receives a message, it sets its logical clock to the maximum of its current
value and the timestamp of the received message plus 1. This ensures that the logical clock
of the receiving process is always greater than the logical clock of the sending process.

• The logical clock values assigned to events by each process can be used to determine the
ordering of events in the system.

Program Code:
import java.util.ArrayList;
import java.util.List;

class LamportClock {
private int value = 0;

public synchronized int getValue() {


return value;
}

public synchronized void tick() {


value++;
}

public synchronized int sendEvent() {


// Increment the clock value and return the current value as a timestamp
value++;
return value;
}

public synchronized void receiveEvent(int sentValue) {


// Increment the clock value to the maximum of the current value and the received timestamp
+1
value = Math.max(value, sentValue) + 1;
}
}

class LamportProcess {
private final int id;
private final LamportClock clock;

G.E.C Dahod 30
Distributed System (3170719) 200180107014

public LamportProcess(int id, LamportClock clock) {


this.id = id;
this.clock = clock;
}

public void localEvent() {


clock.tick();
}

public void sendEvent(LamportProcess receiver) {


int timestamp = clock.sendEvent();
System.out.println("Process " + id + " sends message with timestamp " + timestamp + " to
Process " + receiver.id);
receiver.receiveEvent(timestamp);
}

public void receiveEvent(int sentTimestamp) {


clock.receiveEvent(sentTimestamp);
}

public int getId() {


return id;
}

public LamportClock getClock() {


return clock;
}
}

public class LamportAlgorithm {


public static void main(String[] args) {
LamportClock clock = new LamportClock();
List<LamportProcess> processes = new ArrayList<>();

for (int i = 0; i < 3; i++) {


processes.add(new LamportProcess(i, clock));
}

// Simulate events and message passing


processes.get(0).localEvent();
processes.get(1).sendEvent(processes.get(2));
processes.get(2).localEvent();
processes.get(1).receiveEvent(processes.get(0).getId());

// Print the final clock values for each process


for (LamportProcess process : processes) {
System.out.println("Process " + process.getId() + " clock value: " +
process.getClock().getValue());
}
}
}

G.E.C Dahod 31
Distributed System (3170719) 200180107014

Output:

Conclusion:
I have successfully implemented Lamport’s logical Clock Algorithm for Distributed Systems and
also observed clock cycles successfully.

Exercise:

1. What is the Lamport algorithm?


Lamport timestamps provide a fundamental concept for ensuring a consistent
order of events in distributed systems
A technique for ordering events in a distributed computing system. This algorithm
helps maintain a partial ordering of events in a distributed system, allowing nodes
to agree on the sequence of events without relying on a global clock.

2. How does the Lamport algorithm ensure that events are ordered based on their logical
clock values?
The Lamport algorithm ensures that if event A causally precedes event B, the
Lamport timestamp of event A is less than the timestamp of event B. This means
that events that are causally related are ordered correctly

3. How can the Lamport algorithm be implemented using Java programming language?
Code is given above.

4. How can the Lamport algorithm be tested in a distributed system?


Use property-based testing frameworks, such as QuickCheck or Hypothesis, to
specify properties that the Lamport algorithm must satisfy. The testing framework
can then generate a wide range of inputs and verify that the properties hold for
these inputs.
Use model-checking tools and formal methods to verify the correctness of the
Lamport algorithm. Model-checking tools

Suggested Reference(s):
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. Distributed Computing and application by M L Liu, Pearson Education Inc.
3. "Distributed Systems: Principles and Paradigms" by Andrew S. Tanenbaum and Maarten van
Steen

G.E.C Dahod 32
Distributed System (3170719) 200180107014

References used by the students:


GeekForGeeks, StackOverflow,j javatpoint

Rubric wise marks obtained:


Rubrics 1 2 3 4 5 Total
Marks

G.E.C Dahod 33
Distributed System (3170719) 200180107014

Experiment No: 7

Implementation of Lamport's Vector Clock Algorithm for Distributed Systems

Date:

Competency and Practical Skills: Network Programming & Programming Skill

Relevant CO: CO2

Objectives: (a) Understand the concept of Lamport Vector clock.


(b) Implement Lamport Vector clock in Java.
(c ) Test the implementation of Lamport Vector clock.

Equipment/Tools Required: Personal Computer, JDK, IDE (Eclipse or NetBeans)

Theory:

Lamport Vector clock is a logical clock used in distributed systems. It is an extension of


the Lamport Logical Clock algorithm. In a distributed system, different processes execute
independently and communicate with each other by exchanging messages. In order to keep track
of the order of events in a distributed system, each process maintains a vector clock.

A vector clock is a list of integer values, where each value represents the number of events
that have occurred in each process up until that point in time. Each process increments its own
value in the vector clock whenever an event occurs, and sends the updated vector clock along with
the message to the other processes. When a process receives a message, it updates its own vector
clock by taking the maximum value of each element in its own vector clock and the vector clock
received in the message.

The Lamport Vector clock algorithm ensures that if event A happened before event B,
then the vector clock of A is less than the vector clock of B.

Safety and Necessary Precautions:


- Handle all necessary compile-time exceptions.
- Ensure that the processes are communicating with each other properly.

Procedure:
• Create a Java project in Eclipse or NetBeans.
• Create a Process class that implements Runnable interface. The Process class should have
the following:
o A name for the process.
o A vector clock to keep track of events.
o A method to update the vector clock when an event occurs.
o A run() method that simulates the process.
o A method to send messages to other processes.
• In the main() method, create an array of Process objects.
• Start each process in the array by calling the start() method.
• In the run() method of each Process object, simulate the occurrence of events and update
the vector clock accordingly.
• When a process sends a message to another process, it should update its own vector clock
and send the updated vector clock along with the message.
• When a process receives a message, it should update its own vector clock by taking the

G.E.C Dahod 34
Distributed System (3170719) 200180107014
maximum value of each element in its own vector clock and the vector clock received in
the message.
• Test the implementation of the Lamport Vector clock algorithm by running the program
and observing the vector clocks of each process.

Program Code:
import java.util.*;

class Process implements Runnable {


private String name;
private int processId;
private int[] vectorClock;
private Process[] processes;

public Process(String name, int processId, Process[] processes) {


this.name = name;
this.processId = processId;
this.processes = processes;
this.vectorClock = new int[processes.length];
}

public void updateVectorClock() {


// Increment the vector clock value of this process
vectorClock[processId]++;

// Send the updated vector clock to all other processes


for (int i = 0; i < processes.length; i++) {
if (i != processId) {
processes[i].receiveMessage(vectorClock);
}
}
}

public void receiveMessage(int[] senderVectorClock) {


// Update this process's vector clock element by taking the maximum value
// of its own vector clock and the corresponding element in the sender's vector clock.
for (int i = 0; i < vectorClock.length; i++) {
vectorClock[i] = Math.max(vectorClock[i], senderVectorClock[i]);
}
}

public void run() {


for (int i = 0; i < 3; i++) { // Simulate three events per process
System.out.println(name + " is executing event " + (i + 1));
updateVectorClock();
}

System.out.println(name + "'s vector clock: " + Arrays.toString(vectorClock));


}

public String getName() {


return name;
}

G.E.C Dahod 35
Distributed System (3170719) 200180107014

public int[] getVectorClock() {


return vectorClock;
}
}

public class VectorClock {


public static void main(String[] args) {
int numProcesses = 3;
Process[] processes = new Process[numProcesses];
Thread[] threads = new Thread[numProcesses];

for (int i = 0; i < numProcesses; i++) {


processes[i] = new Process("Process" + i, i, processes);
threads[i] = new Thread(processes[i]);
threads[i].start();
}

// Wait for all threads to finish


for (Thread thread : threads) {
try {
thread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}

// Display the vector clocks of all processes


for (Process process : processes) {
System.out.println(process.getName() + "'s vector clock: " +
Arrays.toString(process.getVectorClock()));
}
}
}

Output:

G.E.C Dahod 36
Distributed System (3170719) 200180107014

Conclusion:

In conclusion, the Lamport Vector clock algorithm is a useful tool for keeping track of the order of
events in distributed systems. By implementing the algorithm in Java, we can ensure that different
processes in a distributed system are able to communicate with each other and maintain a consistent
view of events.

Exercise:
1. What is the purpose of Lamport Vector Clocks in distributed systems?
The primary purpose of Lamport Vector Clocks in distributed systems is to provide
a way to determine a partial ordering of events and understand the causal
relationships between events, even in the absence of global time synchronization.

2. How do Lamport Vector Clocks differ from Lamport Logical Clocks?


The primary distinction between Lamport Logical Clocks and Lamport Vector
Clocks is the data structure used to represent the order of events. While Lamport
Logical Clocks use a single scalar value, vector clocks use a vector of counters to
provide more detailed information about causality relationships between events.
Vector clocks are often preferred when precise causality tracking is essential in
distributed systems, such as for applications involving conflict resolution,
consistency, and coordination

3. Can two events have the same Lamport timestamp in a distributed system?
Yes, in a Lamport timestamp-based system, it is possible for two events to have
the same Lamport timestamp.

4. How do you update a Lamport Vector Clock when a process receives a message from
another process?
Updating a Lamport Vector Clock when a process receives a message from
another process involves incrementing specific elements in the vector to reflect
the reception of the message and the relationship between the two events. Here's
how you can update a Lamport Vector Clock when a process receives a message
from another process:

5. How can you detect causality violations using Lamport Vector Clocks?
Detecting causality violations or inconsistencies in a distributed system using
Lamport Vector Clocks involves analyzing the vector clocks associated with events
and messages. Causality violations typically indicate situations where the observed
event order is not consistent with the causal relationships among events

6. Can Lamport Vector Clocks handle clock drifts between different processes?
No.

Suggested Reference(s):
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. "Distributed Systems: Principles and Paradigms" by Andrew S. Tanenbaum and Maarten
van Steen.
3. Distributed Computing and application by M L Liu, Pearson Education Inc.

G.E.C Dahod 37
Distributed System (3170719) 200180107014

References used by the students:


GeekForGeeks, StackOverflow,j javatpoint

Rubric wise marks obtained:


Rubrics 1 2 3 4 5 Total
Marks

G.E.C Dahod 38
Distributed System (3170719) 200180107014
Experiment No: 8

To implement the functioning of Bully Algorithm

Date:

Competency and Practical Skills: Distributed Systems & Algorithm Design

Relevant CO: CO2

Objectives: (a) Implement the Bully Algorithm for a distributed system.


(b) Understand how the algorithm handles node failures and elections.
(c) Analyze the complexity and efficiency of the algorithm.

Equipment/Tools Required: Personal computer, IDE (Eclipse or NetBeans).

Theory:
The Bully Algorithm is a leader election algorithm that is used in distributed systems. It is a
way to elect a leader node among a group of nodes, with the assumption that the leader node will
be responsible for coordinating and managing the system.

The Bully Algorithm is a fault-tolerant algorithm that is designed to handle node failures.
When a node fails, the other nodes will detect the failure and start a new election process to elect a
new leader. The Bully Algorithm is designed to elect a leader with the highest priority among all
the nodes in the system.

Safety and Necessary Precautions:

Handle all necessary compile time Exception.

Procedure:

1. Create a Java class for the Node object that represents a node in the distributed system. The class
should have fields for the node ID and the priority of the node.

2. Implement a method for sending an election message to all the other nodes in the system.

3. Implement a method for receiving and processing messages from other nodes.

4. Implement a method for electing a new leader.

5. Implement a method for handling node failures.

6. Create a main class for the distributed system that creates and initializes the nodes, and starts the
election process.

7. Test the system by simulating node failures and observing how the algorithm handles them.

Algorithm:
▪ Each process in the network has a unique ID number.
▪ If a process P detects that the coordinator has failed, it sends an ELECTION message to all
processes with higher ID numbers.
▪ If a process Q receives an ELECTION message from P, it sends an OK message to P,
G.E.C Dahod 39
Distributed System (3170719) 200180107014
indicating that it is still alive.
▪ If a process Q does not receive a message from a higher-ID process within a certain time
period, it assumes that the higher-ID process has failed and initiates an election process.
▪ When a process R receives an OK message from all higher-ID processes, it becomes the new
coordinator and sends a COORDINATOR message to all other processes to inform them of the
new leader.

Program Code:
import java.util.*;

class Node {
private int id;
private int priority;
private boolean isCoordinator;
private boolean isOnline;
public List<Node> higherPriorityNodes;

public Node(int id, int priority) {


this.id = id;
this.priority = priority;
this.isCoordinator = false;
this.isOnline = true;
this.higherPriorityNodes = new ArrayList<>();
}

public void sendElectionMessage() {


if (!isOnline) {
return;
}

System.out.println("Node " + id + " initiates an ELECTION.");

for (Node node : higherPriorityNodes) {


if (node.isOnline) {
node.receiveElectionMessage(this);
}
}
}

public void receiveElectionMessage(Node sender) {


System.out.println("Node " + id + " received ELECTION from Node " + sender.id);

if (isOnline) {
System.out.println("Node " + id + " sends OK to Node " + sender.id);
sender.receiveOKMessage(this);
}
}

public void receiveOKMessage(Node sender) {


System.out.println("Node " + id + " received OK from Node " + sender.id);

// Node received OK message, do nothing


}

G.E.C Dahod 40
Distributed System (3170719) 200180107014
public void initiateElection() {
isCoordinator = true;
System.out.println("Node " + id + " becomes the COORDINATOR.");

for (Node node : higherPriorityNodes) {


if (node.isOnline) {
node.receiveCoordinatorMessage(this);
}
}
}

public void receiveCoordinatorMessage(Node sender) {


System.out.println("Node " + id + " received COORDINATOR from Node " + sender.id);
isCoordinator = false;
}

public void handleFailure() {


System.out.println("Node " + id + " has failed.");
isOnline = false;

// Inform higher priority nodes


for (Node node : higherPriorityNodes) {
if (node.isOnline) {
node.receiveNodeFailure(this);
}
}
}

public void receiveNodeFailure(Node failedNode) {


System.out.println("Node " + id + " received failure notification from Node " +
failedNode.id);
}
}

public class BullyAlgorithm {


public static void main(String[] args) {
Node node1 = new Node(1, 5);
Node node2 = new Node(2, 10);
Node node3 = new Node(3, 8);
Node node4 = new Node(4, 12);

// Set higher priority nodes for each node


node1.higherPriorityNodes.add(node2);
node1.higherPriorityNodes.add(node3);
node1.higherPriorityNodes.add(node4);

node2.higherPriorityNodes.add(node3);
node2.higherPriorityNodes.add(node4);

node3.higherPriorityNodes.add(node4);

// Simulate node failures


node4.handleFailure();
G.E.C Dahod 41
Distributed System (3170719) 200180107014

// Start an election
node1.sendElectionMessage();
}
}

Output:

Conclusion:
I have successfully implemented Bully Algorithm and also implemented election for fault
tolerance.

Exercise :

1. What is the purpose of the Bully Algorithm?


The Bully Algorithm is a leader election or coordinator election algorithm used in
distributed systems to select a leader or coordinator among a group of processes
or nodes. The primary purpose of the Bully Algorithm is to establish a single
process as the leader or coordinator to manage certain tasks or responsibilities
within the distributed system.

2. How does the Bully Algorithm handle node failures?


The Bully Algorithm is designed to handle node failures in a distributed system by
initiating a leader election process when it detects that the current leader
(coordinator) has failed or become unreachable.

3. What happens when a node receives an election message from a node with a higher
priority?
When a node in a distributed system receives an election message from another
node with a higher priority, it is an indication that the sender is challenging the
receiver's claim to leadership or coordinator status. In the context of leader
election algorithms like the Bully Algorithm, this situation triggers a response from
the receiving node

G.E.C Dahod 42
Distributed System (3170719) 200180107014

4. What is the role of the OK message in the Bully Algorithm?


The purpose of the "OK" message is to acknowledge that a node has received an
election message and to indicate whether it will concede leadership or challenge
the current leader.

Suggested Reference(s):
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest
Wiley Publication
2. "Distributed Systems: Principles and Paradigms" by Andrew S. Tanenbaum and
Maarten van Steen.
3.
References used by the students:
GeekForGeeks, StackOverflow,j javatpoint

Rubric wise marks obtained:


Rubrics 1 2 3 4 5 Total
Marks

G.E.C Dahod 43
Distributed System (3170719) 200180107014

Experiment 09

Implement client server application using CORBA

Competency and Practical Skills: Network Programming & Programming Skill

Relevant CO: CO5

Objectives:

a) To learn about Common Object Request Broker Architecture (CORBA)


b) To implement a simple client-server application using CORBA
c) To understand the concept of interfaces in CORBA

Equipment/Tools Required: Personal Computer, JDK, IDE (Eclipse or NetBeans),


CORBA framework

Theory:

Common Object Request Broker Architecture (CORBA) is a standard for building


distributed systems. It allows objects written in different programming languages and running on
different platforms to communicate with each other. CORBA uses an Object Request Broker (ORB)
to manage communication between the objects. The ORB acts as an intermediary between the client
and server objects and provides services such as object lookup, object instantiation, and parameter
marshaling.

To use CORBA, you need to define an interface for your objects using the Interface
Definition Language (IDL). The IDL defines the methods and attributes that the objects will
expose to clients. The IDL compiler generates stub and skeleton code for the client and server
objects respectively. The stub and skeleton code provide the necessary marshaling and
unmarshaling of method arguments and results between the client and server.

The steps involved in implementing a simple client-server application using CORBA are:

• Define the IDL interface


• Compile the IDL interface using the IDL compiler
• Implement the server object
• Start the ORB
• Register the server object with the ORB
• Implement the client object
• Compile the client object
• Run the client object

Safety and necessary Precautions:

▪ Make sure that all the software required to run CORBA is installed and properly
configured.
▪ Handle all necessary compile time Exception

Procedure:

▪ Define the IDL interface: Define the interface for your objects using the Interface
Definition Language (IDL). The interface should include the methods and attributes
that the server object will expose to clients.

G.E.C Dahod 44
Distributed System (3170719) 200180107014

▪ Compile the IDL interface using the IDL compiler: Use the IDL compiler to generate
stub and skeleton code for the client and server objects respectively.

▪ Implement the server object: Implement the server object in Java using the skeleton
code generated by the IDL compiler. The server object should implement the
methods defined in the IDL interface.

▪ Start the ORB: Start the ORB by running the orb.run command.

▪ Register the server object with the ORB: Register the server object with the ORB
using the Naming Service.

▪ Implement the client object: Implement the client object in Java using the stub code
generated by the IDL compiler. The client object should invoke the methods defined
in the IDL interface.

▪ Compile the client object: Use the Java compiler to compile the client object.

▪ Run the client object: Run the client object and observe the results.

Program Code:

HelloImpl.java
import HelloApp.HelloPOA;

class HelloImpl extends HelloPOA {


public String sayHello() {
return "Hello, CORBA!";
}
}

HelloServer.java
import HelloApp.Hello;
import HelloApp.HelloHelper;
import org.omg.CORBA.ORB;
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;

public class HelloServer {


public static void main(String[] args) {
try {
// Initialize the ORB
ORB orb = ORB.init(args, null);

// Create the HelloImpl object


HelloImpl helloImpl = new HelloImpl();

// Initialize the ORB and NamingContext


org.omg.CORBA.Object obj = orb.resolve_initial_references("NameService");
NamingContextExt namingContext = NamingContextExtHelper.narrow(obj);

// Create a new object reference of type Hello


org.omg.CORBA.Object helloObj = helloImpl._this(orb);

// Create a NameComponent for the object reference


NameComponent[] name = namingContext.to_name("Hello");

G.E.C Dahod 45
Distributed System (3170719) 200180107014

// Bind the Hello object to the Naming Service


namingContext.rebind(name, helloObj);

System.out.println("HelloServer is running and ready to accept requests.");

// Run the ORB


orb.run();
} catch (Exception e) {
e.printStackTrace();
}
}
}

HelloClient.java
import HelloApp.Hello;
import org.omg.CORBA.ORB;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;

public class HelloClient {


public static void main(String[] args) {
try {
ORB orb = ORB.init(args, null);
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
NamingContextExt namingContext = NamingContextExtHelper.narrow(objRef);
Hello helloImpl = HelloHelper.narrow(namingContext.resolve_str("Hello"));

String message = helloImpl.sayHello();


System.out.println("Message: " + message);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Output:

Conclusion:
I have successfully implemented Hello, World Program using orb in CORBA.

G.E.C Dahod 46
Distributed System (3170719) 200180107014
Exercise :

1. What is CORBA?
CORBA, which stands for Common Object Request Broker Architecture, is a
middleware technology and architecture that enables communication and
interaction between distributed objects in a networked computing environment. It
provides a framework for building distributed systems in which objects written in
different programming languages can interoperate seamlessly.

2. What is the role of the ORB in CORBA?


Its role in CORBA is pivotal, as it acts as an intermediary that facilitates
communication and interaction between distributed objects in a networked
computing environment.

3. What is the IDL?


IDL stands for "Interface Definition Language." It is a specification language used
in distributed computing and software engineering to define the interfaces and
methods that objects or components expose in a language-neutral and platform-
independent manner. IDL serves as a crucial component of various middleware
technologies

4. What is the purpose of the stub and skeleton code generated by the IDL compiler?
It acts as a representative or proxy for a remote object located on the server side.
The primary purpose of the stub is to allow the client to invoke methods on the
remote object as if it were a local object, even though the object resides on a
different machine or in a different address space.

5. How do you register a server object with the ORB?


Registering a server object with the Object Request Broker (ORB) in middleware
technologies like CORBA (Common Object Request Broker Architecture) is a
critical step in making the server object accessible to clients in a distributed
system. The process may vary slightly depending on the CORBA implementation
you are using

Suggested Reference(s):
1. "CORBA: Architecture and Programming with Java" by John Siegel and Thomas
Mowbray

References used by the students:


GeekForGeeks, StackOverflow,j javatpoint

Rubric wise marks obtained:


Rubrics 1 2 3 4 5 Total
Marks

G.E.C Dahod 47
Distributed System (3170719) 200180107014

Experiment 10

Implement a simple Web service in Java

Competency and Practical Skills: Web development, programming skills, and knowledge of
web services.

Relevant CO: CO5

Objectives:

a) Understand the basic concept of web services


b) Learn to create a web service using Java programming language
c) Learn to publish a web service on a web server
d) Learn to consume a web service using a client application

Equipment/Tools Required: Personal computer, Java Development Kit (JDK), Integrated


Development Environment (IDE) such as Eclipse or NetBeans, Apache Tomcat web server

Theory:
A web service is a software system designed to support interoperable machine-to-machine
interaction over a network. It has an interface described in a machine-processable format,
specifically WSDL (Web Service Description Language). Other systems interact with the web
service in a manner prescribed by its description using SOAP messages, typically conveyed using
HTTP with an XML serialization in conjunction with other web-related standards.

A web service comprises three parts:

Service provider: The application that provides the web service.


Service requester: The application that consumes the web service.
Registry: The application that contains the details of the web service provider, which can be
looked up by the service requester.

Apache Axis is one of the popular implementations of web services that is built on top of the Apache
SOAP project. It is an open-source, XML-based web service framework that provides a means to
generate WSDL and create client applications in various programming languages, including Java.

Safety and necessary Precautions:

▪ Make sure to use secure communication protocols such as HTTPS to ensure the
confidentiality of data transmitted over the network.
▪ Make sure to validate user inputs and implement proper error handling mechanisms to
prevent attacks such as SQL injection.

Procedure:

▪ Create a Java project in Eclipse or NetBeans.

▪ Define the web service interface using the JAX-WS (Java API for XML Web Services)
annotations. This interface should declare the methods that will be exposed as web
service operations. Annotate the interface with @WebService and @WebMethod
annotations.

G.E.C Dahod 48
Distributed System (3170719) 200180107014

▪ Implement the web service interface in a Java class. Annotate the class with
@WebService and @WebServiceProvider annotations. Implement the methods
declared in the interface.

▪ Create a web application project in Eclipse or NetBeans. Add the Java class created in
step 3 to the project.

▪ Create a web service deployment descriptor (web.xml) file. This file should specify the
location of the web service implementation class and the URL mapping for the web
service endpoint.

▪ Deploy the web service to a web server such as Apache Tomcat. Publish the web service
by deploying the web application project created in step 4.

▪ Create a client application that will consume the web service. The client application can
be created in any programming language that supports SOAP messages. For this lab,
create a Java client application using the JAX-WS API.

▪ Generate the client artifacts using the wsimport tool provided by the JDK. This tool
generates Java classes that correspond to the WSDL of the web service.

▪ Use the generated Java classes to invoke the web service operations in the client
application.

▪ Run the client application and observe the results of invoking the web service operations.

Program Code:

ExampleResource.java
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@Path("/example")
public class ExampleResource {

@GET
@Produces("text/plain")
public String getExample() {
return "Hello, World!";
}
}

Main.java
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.server.ResourceConfig;

import java.net.URI;

public class Main {

public static void main(String[] args) {


final String baseUri = "http://localhost:8080/";
final ResourceConfig resourceConfig = new
ResourceConfig(ExampleResource.class);

G.E.C Dahod 49
Distributed System (3170719) 200180107014
GrizzlyHttpServerFactory.createHttpServer(URI.create(baseUri), resourceConfig);
}
}

Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>jersey-web-service</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<!-- Jersey dependencies -->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<version>2.35</version> <!-- Replace with the latest version -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.35</version> <!-- Replace with the latest version -->
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.Main</mainClass> <!-- Replace with your main class -->
</configuration>
</plugin>
G.E.C Dahod 50
Distributed System (3170719) 200180107014
</plugins>
</build>
</project>

Output:

Conclusion:

▪ Web services provide a means for different applications to interact with each other
over a network.
▪ Apache Axis is a popular implementation of web services that provides a means to
generate WSDL and create client applications in various programming languages.
▪ Web services can be published on a web server and consumed by client applications in
a secure and efficient manner.

Exercise :

1. What is a web service?


A web service is a standardized way for software applications to
communicate over the internet or other networks. It provides a platform-
agnostic and language-independent means of exchanging data and
performing various operations between different systems, regardless of the
technologies they use.

2. What is WSDL?
WSDL stands for "Web Services Description Language." It is an XML-based
language used to describe the interface and functionality of a web service.
WSDL serves as a standardized way to define how a web service can be
accessed, what operations it supports, the data types it uses, and the
structure of messages that need to be exchanged between clients and the
service.

3. What is Apache Axis?


Apache Axis is an open-source framework for building web services in the
Java programming language. It provides tools and libraries for creating,
deploying, and consuming web services, particularly those based on the
SOAP (Simple Object Access Protocol) standard. Apache Axis is a project
within the Apache Software

Suggested References:
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. "Java Web Services: Up and Running" by Martin Kalin

G.E.C Dahod 51
Distributed System (3170719) 200180107014

References used by the students:


GeekForGeeks, StackOverflow,j javatpoint

Rubric wise marks obtained:


Rubrics 1 2 3 4 5 Total
Marks

G.E.C Dahod 52
Distributed System (3170719) 200180107014

Experiment 11

Creation of BPEL and composite module

Competency: Web Services and SOA

Relevant CO : CO5
Objective: To create a BPEL process and composite application using Oracle JDeveloper.

Tools Required: Oracle JDeveloper, Oracle WebLogic Server

Theory:
A Business Process Execution Language (BPEL) process is an executable process that
describesthe behavior of a business process based on a set of activities, including receiving and
sending messages, invoking services, and manipulating data.

A composite application is an application that consists of multiple services and components


that are orchestrated to achieve a specific business goal. It is usually built using a Service
Oriented Architecture (SOA) approach, where each component provides a specific service that
can be accessed by other components.

In this lab, we will use Oracle JDeveloper to create a BPEL process and a composite
application that integrates multiple services.

Procedure:

Open Oracle JDeveloper and create a new application by selecting File > New > Application
from the menu.

▪ Select the "SOA Application" template and click "OK".

▪ In the "Create SOA Application" wizard, enter the application name and click "Next".

▪ In the "Select Template" page, select "Composite with BPEL" and click "Next".

▪ Enter the composite name and click "Finish".

▪ In the "composite.xml" file, drag and drop a "BPEL Process" component from the
Component Palette onto the design canvas.

▪ Double-click the "BPEL Process" component to open the "BPEL Process Editor".

▪ In the "BPEL Process Editor", add the required activities to define the business
process, such as "Receive", "Invoke", "Assign", and "Reply".

▪ Save the BPEL process by selecting File > Save from the menu.

▪ In the "composite.xml" file, drag and drop the required components from the
Component Palette onto the design canvas to create the composite application.

▪ Use the "Service Component Architecture" (SCA) editor to wire the components
together by creating "references" and "bindings".

▪ Save the composite application by selecting File > Save from the menu.

G.E.C Dahod 53
Distributed System (3170719) 200180107014

▪ Deploy the composite application to the Oracle WebLogic Server by right-clicking the
"composite.xml" file and selecting "Deploy".

▪ Test the composite application by accessing the services provided by the components.

Observations:

During the BPEL process creation, we observed that it is possible to add different activities to
the process to define the business logic.

In the composite application, we observed that the components can be easily wired together
using the SCA editor.

During deployment, we observed that the composite application is deployed as a single unit to
the Oracle WebLogic Server.

Conclusion:
Based on the provided observations and the steps for creating a BPEL process and composite
application in Oracle JDeveloper, we can draw the following conclusions:
1. Ease of BPEL Process Creation: Oracle JDeveloper simplifies the process of creating
BPEL processes. You can quickly define complex business logic by adding various
activities, such as Receive, Invoke, Assign, and Reply, to the BPEL process. This visual
approach makes it easy to design and implement business processes efficiently.
2. Composite Application Development: Creating composite applications for orchestrating
various components is straightforward in Oracle JDeveloper. The Service Component
Architecture (SCA) editor allows you to wire components together seamlessly, enabling
you to build composite applications that integrate and manage different services and
components.
3. Modular Development: Composite applications consist of reusable components, and each
component can be developed and tested independently. This modular approach enhances
the maintainability of the application and promotes code reuse.
4. Deployment as a Single Unit: Deploying composite applications to Oracle WebLogic
Server is a smooth process. The composite application, including all its components and
services, is deployed as a single unit, simplifying deployment and management tasks.
5. Testing and Validation: The built-in tools and features in Oracle JDeveloper, such as the
BPEL Process Tester, make it easy to test and validate the behavior of both individual
BPEL processes and composite applications. This is essential for ensuring that the
application functions correctly.
6. Integration with Oracle WebLogic Server: Oracle JDeveloper seamlessly integrates
with Oracle WebLogic Server, making it a suitable environment for developing and
deploying enterprise-level applications. The integrated deployment process ensures that
the composite application is ready for execution in the server environment.
7. Productivity and Efficiency: Oracle JDeveloper provides a user-friendly interface for
both BPEL process development and composite application creation. This results in
increased productivity and efficiency, allowing developers to focus on defining business
processes rather than dealing with low-level technical details.
In conclusion, Oracle JDeveloper offers a powerful and intuitive development environment for
creating BPEL processes and composite applications. It simplifies the design, development,
testing, and deployment of business processes, making it an ideal choice for enterprises looking to
build sophisticated and integrated applications.

G.E.C Dahod 54
Distributed System (3170719) 200180107014

Suggested Reference(s):
1. "Service-Oriented Architecture: Concepts, Technology, and Design" by Thomas Erl

References used by the students:


GeekForGeeks, StackOverflow,j javatpoint

Rubric wise marks obtained:


Rubrics 1 2 3 4 5 Total
Marks

G.E.C Dahod 55
Distributed System (3170719) 200180107014
Experiment 12

Study of open source Key Management tool

Competency and Practical Skills: Network Security and Cryptography.

Relevant CO: CO4

Objectives: (a) To understand the concept of key management and its importance in cryptography
(b) To study various open source key management tools and their features
(c) To evaluate and compare the performance of these tools

Equipment/Tools Required: Personal Computer, Internet Connection, Open Source Key


Management Tools (e.g., GnuPG, OpenSSL, Keyczar), Performance Evaluation Tools (e.g.,
Apache JMeter)

Theory:

Key management is an essential component of cryptography that involves generating,


storing, distributing, and revoking cryptographic keys. It ensures the secure and efficient
management of keys used in various cryptographic operations, such as encryption, decryption,
authentication, and digital signature. A key management system must provide robust key generation
and distribution mechanisms, secure storage, key backup and recovery options, and support for
various cryptographic algorithms and protocols.
Open source key management tools provide an affordable and customizable solution for managing
cryptographic keys. These tools offer a range of features, such as key pair generation, key exchange,
key storage and retrieval, key revocation, and certificate management. They support various
cryptographic algorithms and protocols, including RSA, DSA, AES, SHA, and SSL/TLS.
In this experiment, we will study and evaluate some popular open source key management tools,
including GnuPG, OpenSSL, and Keyczar. We will analyze their features, strengths, and
weaknesses, and compare their performance using suitable evaluation metrics.

Observations:
Open-source key management tool, HashiCorp Vault:

Overview and Purpose:


• HashiCorp Vault is an open-source tool designed for secrets management, data encryption,
and identity-based access control.
Licensing and Open Source Community:
• Vault is licensed under the Mozilla Public License 2.0 (MPL). It has an active open-source
community and is widely adopted.
Key Storage and Protection:
• Vault provides secure key storage by supporting physical hardware security modules
(HSMs) and software-based encryption.
• Keys are protected using access controls, encryption at rest, and access policies.
Key Lifecycle Management:
• Vault supports key generation, rotation, and destruction. It can manage the lifecycle of
cryptographic keys.
• It automates key rotation and renewal for various cryptographic engines.
Integration and APIs:
• Vault offers a well-documented API for integration with applications and systems.
• It supports industry standards like PKCS#11 and KMIP for compatibility.

G.E.C Dahod 56
Distributed System (3170719) 200180107014
Auditing and Compliance:
• Vault has robust auditing capabilities for tracking key access and usage.
• It can be configured to meet compliance requirements, such as GDPR and HIPAA.
User Management and Access Control:
• Vault supports user and role management with fine-grained access controls.
• It offers various authentication mechanisms, including multi-factor authentication.
Scalability and High Availability:
• Vault is designed to scale horizontally to accommodate growing workloads.
• It provides features for high availability to minimize downtime.
Documentation and Support:
• HashiCorp provides extensive documentation, including installation guides and user
manuals.
• Commercial support is available for organizations seeking assistance.
Security and Vulnerability Assessments:
• HashiCorp maintains a robust security process, actively addressing vulnerabilities when
discovered.
Use Cases and Case Studies:
• Vault is used by various organizations for securing secrets, managing encryption keys, and
protecting sensitive data.
Performance and Speed:
• Vault's performance is optimized for cryptographic operations and key management tasks.
Community and Commercial Alternatives:
• While Vault is open source, HashiCorp also offers a commercial version with additional
features and support.
User Feedback and Reviews:
• You can find user reviews and feedback on HashiCorp Vault's performance, security, and
ease of use.
Testing and Deployment:
• Consider setting up a test environment to evaluate Vault's functionality and suitability
before deploying it in a production environment.
HashiCorp Vault is a widely used open-source key management tool that addresses various
aspects of key management, secrets storage, and access control. It provides strong security
features, robust documentation, and a supportive community, making it suitable for a wide range
of use cases.

G.E.C Dahod 57
Distributed System (3170719) 200180107014

Conclusion:
In conclusion, HashiCorp Vault is a powerful open-source key management tool that excels in
securing secrets, managing cryptographic keys, and enforcing access control. It offers
comprehensive features, robust security, and strong integration capabilities, making it a top choice
for organizations seeking to protect sensitive data and cryptographic assets. Its active open-source
community, scalability, and support for compliance requirements make it a versatile solution for
various use cases.

Exercise:
1. What is a private key in OpenSSL, and how is it generated?
In OpenSSL, a private key is a cryptographic key used in various security protocols,
including SSL/TLS for secure communication over the internet, digital signatures,
and encryption.

2. How do you extract the public key from a private key in OpenSSL?
You can extract the public key from a private key in OpenSSL using the openssl
command-line tool.

3. How can you check the validity of a private key in OpenSSL?


-check is an option that tells OpenSSL to perform a key check on the provided
private key.

4. What is a key pair in OpenSSL, and how is it used in SSL/TLS communication?


In OpenSSL, a key pair refers to a pair of cryptographic keys: a private key and a
public key. These keys are used in various security protocols and applications,
including SSL/TLS (Secure Sockets Layer/Transport Layer Security) communication

Suggested References:
1. OpenSSL - https://www.openssl.org/
2. GnuPG - https://gnupg.org/
3. Bouncy Castle - https://www.bouncycastle.org/
4. Keyczar - https://github.com/google/keyczar
5. Vault - https://www.vaultproject.io/
6. HashiCorp - https://www.hashicorp.com/
7. Apache Ranger - https://ranger.apache.org/

G.E.C Dahod 58
Distributed System (3170719) 200180107014

References used by the students:


GeekForGeeks, StackOverflow,j javatpoint

Rubric wise marks obtained:


Rubrics 1 2 3 4 5 Total
Marks

G.E.C Dahod 59

You might also like