0% found this document useful (0 votes)
8 views12 pages

Distributed Networking 1

The document is a lab report from Padmakanya Multiple Campus detailing various cloud computing implementations. It includes labs on Remote Method Invocation (RMI), Remote Procedure Call (RPC), virtualization, network communication testing, client-server architecture in Cisco Packet Tracer, and MapReduce implementation. Each lab provides code examples and explanations of the processes involved.

Uploaded by

Prashant Bhatta
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)
8 views12 pages

Distributed Networking 1

The document is a lab report from Padmakanya Multiple Campus detailing various cloud computing implementations. It includes labs on Remote Method Invocation (RMI), Remote Procedure Call (RPC), virtualization, network communication testing, client-server architecture in Cisco Packet Tracer, and MapReduce implementation. Each lab provides code examples and explanations of the processes involved.

Uploaded by

Prashant Bhatta
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/ 12

Padmakanya Multiple Campus

Bagbazar,Kathmandu
Lab Report of Cloud Computing

Submitted By:​ Submitted To:


Samiksha Khadka​ Mr. Bhim Bahadur Rawat
Table of Content

LAB 1: Implement the RMI


LAB 2: Implement the RPC
LAB 3: Implementation of Virtualization
LAB 4: Test ping command to test the communication
between the guest OS and Host OS.
LAB 5: Implement client and server architecture in Cisco
packet tracer
LAB 6: Implement the map reduce
LAB 1: Implement the RMI: Sum of two number

Create Folder:
mkdir
RMIAddition cd
RMIAddition
mkdir server
mkdir client
mkdir
common

File:
common/AddService.java
package common;
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface AddService extends Remote {


int add(int a, int b) throws RemoteException;
}

server/AddServiceImpl.java
package server;
import common.AddService;
import
java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

public class AddServiceImpl extends UnicastRemoteObject implements AddService {


protected AddServiceImpl() throws RemoteException {
super();
}
public int add(int a, int b) throws RemoteException {
return a + b;
}}

server/Server.java
package server;
import common.AddService;
import
java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class Server {
public static void main(String[] args) {
try {
AddService addService = new AddServiceImpl();
Registry registry = LocateRegistry.createRegistry(1099);
registry.rebind("AddService", addService);
System.out.println("Server is running...");
} catch (Exception e) {
e.printStackTrace();
}}}

client/Client.java
package client;
import common.AddService;
import
java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Scanner;
public class Client {
public static void main(String[] args) {
try {
Registry registry = LocateRegistry.getRegistry("localhost", 1099);
AddService stub = (AddService) registry.lookup("AddService");
Scanner scanner = new Scanner(System.in);
System.out.print("Enter first number: ");
int a = scanner.nextInt();
System.out.print("Enter second number: ");
int b = scanner.nextInt();
int result = stub.add(a, b);
System.out.println("Sum from server: " + result);
} catch (Exception e) {
e.printStackTrace();
}}}
Server side running

Client side running


LAB 2: Implement the RPC: Addition

Create Folder:
mkdir
RPCAddition cd
RPCAddition

Files:
Server.jav
a
Client.java

Server.java
import java.io.*;
import java.net.*;
public class Server {
public static void main(String[] args) {
try (ServerSocket serverSocket = new ServerSocket(5000)) {
System.out.println("Server is running...");
while (true) {
Socket socket = serverSocket.accept();
BufferedReader in = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
String request = in.readLine(); // expects: add 5 7
String[] parts = request.split(" ");
if (parts[0].equals("add") && parts.length == 3) {
int a = Integer.parseInt(parts[1]);
int b = Integer.parseInt(parts[2]);
int result = a + b;
out.println("Result: " + result);
} else {
out.println("Invalid request");
}
socket.close();
}
} catch (IOException e) {
e.printStackTrace();
} } }

Client.java
import java.io.*;
import java.net.*;
import java.util.Scanner;
public class Client {
public static void main(String[] args) {
try (Socket socket = new Socket("localhost", 5000)) {
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
BufferedReader in = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
Scanner scanner = new Scanner(System.in);
System.out.print("Enter first number: ");
int a = scanner.nextInt();
System.out.print("Enter second number: ");
int b = scanner.nextInt();
out.println("add " + a + " " +
b); String response =
in.readLine();
System.out.println(response);
} catch (IOException e)
{ e.printStackTrace();
}
}
}

Server side running

Client side running


LAB 3: Implementation of Virtualization
A guest operating system is the operating system installed on either a virtual machine
(VM) or partitioned disk. Turbo C++3.0 is successfully installed on virtual machine linux
as shown in figure below.

Installation commands:

sudo apt install dosbox

dosbox

mount c ~/turbo-cpp

c:

cd TURBOC3\BIN

TC.EXE

Figure 1: Turbo C++ Installation


Lab 4: Test ping command to test the communication between the guest
OS and Host OS.

To test the ping command between guest OS and Host OS, ip address is pinged which is
demonstrated by the below figure.

Figure 4: Ping command in guest OS

ipconfig /all
Figure 5: ipconfig in Host OS
LAB 5: Implement client and server architecture in Cisco packet tracer

A network where:
A Client PC sends a request to
A Server (e.g., HTTP or DNS server),
Through a Switch or directly connected, depending on setup
Tools
1 Server (from End Devices)
1 or 3 PCs (from End Devices)
1 Switch (optional)
Copper Straight-Through Cables (from Connections)
LAB 6: Implement the map reduce

Folder: mapreduce
File:
Mapper.java
Reducer.java
MapReduceDriver.java

Mapper.java
import java.util.*;
public class Mapper {
// Simulates the Map step: splits lines into words, outputs (word, 1)
public List<Map.Entry<String, Integer>> map(String line) {
List<Map.Entry<String, Integer>> results = new ArrayList<>();
String[] words = line.toLowerCase().split("\\W+");
for (String word : words) {
if (word.length() > 0) {
results.add(new AbstractMap.SimpleEntry<>(word, 1));
}
}
return results;
}
}

Reducer.java
import java.util.*;
public class Reducer {
// Simulates the Reduce step: sums counts for each word
public Map<String, Integer> reduce(List<Map.Entry<String, Integer>> mappedData) {
Map<String, Integer> wordCounts = new HashMap<>();
for (Map.Entry<String, Integer> entry : mappedData) {
wordCounts.put(entry.getKey(), wordCounts.getOrDefault(entry.getKey(), 0)
+
entry.getValue());
}
return wordCounts;
}
}

MapReduceDriver.java
import java.util.*;
public class MapReduceDriver {
public static void main(String[] args) {
String[] input = {
"Hello world",
"Hello from ChatGPT",
"Distributed systems are fun",
"Hello distributed world"
};
Mapper mapper = new Mapper();
Reducer reducer = new Reducer();
List<Map.Entry<String, Integer>> mappedResults = new ArrayList<>();
// Map step
for (String line : input) {
mappedResults.addAll(mapper.map(line));
}
// Reduce step
Map<String, Integer> finalCounts = reducer.reduce(mappedResults);
// Print the result
for (Map.Entry<String, Integer> entry : finalCounts.entrySet()) {
System.out.println(entry.getKey() + " : " + entry.getValue());
}
}

You might also like