Distributed Systems Lab

Practical Run Guide

Step-by-step instructions to compile and execute every practical assignment — for both Windows and Linux

8
Practicals
6
Languages
2
Platforms
01 Java RMI – Remote Method Invocation
02 CORBA – Calculator Server & Client
03 MPI – Parallel Array Sum (C)
04 Berkeley Clock Synchronisation (C++)
05 Token-Based Mutual Exclusion (Java)
06a Bully Algorithm – Leader Election
06b Ring Algorithm – Leader Election
07 ASP.NET Web Services (.NET / Mono)
08 Distributed Multiplayer Game (Go + K8s)
01

Java RMI – Remote Method Invocation

Java A client calls a remote add() method on a server over the network using Java RMI.
FileRole
Adder.javaRemote interface – declares add(int, int)
AdderRemote.javaServer-side implementation of the remote interface
MyServer.javaRegisters the stub with the RMI registry on port 5000
MyClient.javaLooks up the stub and calls add(34, 4) remotely

Tools Required

  • JDK 8 or later (includes javac, java, rmiregistry)
  • 3 separate terminal windows

Install JDK

  • Windows: Download from adoptium.net or use winget install Microsoft.OpenJDK.21
  • Linux: sudo apt install default-jdk

Step-by-Step (both Windows & Linux)

1

Compile all four source files from the folder containing them.

Windows & Linux
# Navigate to the assignments folder first
javac Adder.java AdderRemote.java MyServer.java MyClient.java
2

Start the RMI Registry on port 5000 in a dedicated terminal. Keep it running.

Windows & Linux – Terminal 1
rmiregistry 5000
3

Start the RMI Server in a second terminal. Keep it running.

Terminal 2
java MyServer
4

Run the Client in a third terminal. You should see 38 printed (34 + 4).

Terminal 3
java MyClient

Expected Output — Terminal 3 prints 38. If you see a Connection Refused error, make sure rmiregistry was started before MyServer, and both use port 5000.

02

CORBA – Calculator Server & Client

Java (JDK 8) A CORBA Calculator that accepts +5*3-style strings and returns the computed result.

Critical – JDK 8 Only! CORBA (org.omg.*) was deprecated in Java 9 and completely removed in Java 11. You must use JDK 8 for this practical. Download from adoptium.net/releases and select "Java 8".

FileRole
Calc.idlInterface Definition Language – defines the calculate() and shutdown() operations
CalcServer.javaCORBA server — registers with the naming service and serves requests
CalcClient.javaCORBA client — looks up the server and performs calculations

Tools Required

  • JDK 8 exactly (java -version must show 1.8)
  • idlj – IDL-to-Java compiler (bundled in JDK 8)
  • orbd – Object Request Broker Daemon (bundled in JDK 8)
  • 3 terminal windows

Input Format (Client)

  • Enter a 3-character string: +53 → 5+3=8
  • Operators: + (43)  - (45)  * (42)  / (47)
  • Digits must be single characters (0–9)
  • Enter 0 to exit and shutdown server

Step-by-Step

1

Generate Java stubs/skeletons from the IDL file.

Windows & Linux
idlj -fall Calc.idl
# This creates a folder: WssCalculator/
2

Compile all Java files including the generated stubs.

Windows & Linux
javac -classpath . CalcServer.java CalcClient.java WssCalculator/*.java
3

Start the ORB Naming Daemon on port 1050 in Terminal 1. Keep it running.

Terminal 1
orbd -ORBInitialPort 1050 -ORBInitialHost localhost
4

Start the CORBA server in Terminal 2. You should see "The SERVER is READY".

Terminal 2
java CalcServer -ORBInitialPort 1050 -ORBInitialHost localhost
5

Run the client in Terminal 3, then enter calculations.

Terminal 3
java CalcClient -ORBInitialPort 1050 -ORBInitialHost localhost
# Input example: +53  →  Output: 8
# Input example: *27  →  Output: 14
03

MPI – Parallel Array Sum

C Adds 20 numbers in an array distributed across 4 cores using MPI point-to-point messaging.
FileDescription
Array.cRank 0 distributes chunks, each rank computes a local sum, rank 0 collects and prints the final sum (1+2+…+20 = 210)

Tools – Windows

  • MS-MPI Runtimemicrosoft.com/en-us/download/details.aspx?id=100593 (msmpisetup.exe)
  • MS-MPI SDK – same page (msmpisdk.msi)
  • MinGW-w64 – for GCC (gcc.exe must be in PATH)
  • Or use WSL (Windows Subsystem for Linux) and follow Linux steps

Tools – Linux

  • Open MPI – install via package manager
  • GCC – usually pre-installed

Installation

1
Windows – PowerShell (Admin)
# Option A: WSL (Recommended for MPI on Windows)
wsl --install
# Then inside WSL run the Linux commands below

# Option B: Native MS-MPI + MinGW
# 1. Install msmpisetup.exe and msmpisdk.msi from Microsoft
# 2. Install MinGW-w64 from winlibs.com
# 3. Add both to PATH
Ubuntu / Debian
sudo apt update
sudo apt install -y openmpi-bin libopenmpi-dev gcc
Fedora / RHEL
sudo dnf install -y openmpi openmpi-devel gcc
module load mpi/openmpi-x86_64

Compile & Run

2

Compile using the MPI wrapper compiler.

Linux / WSL
mpicc -o array Array.c
Windows (native MS-MPI + MinGW)
gcc Array.c -o array -I "C:\Program Files (x86)\Microsoft SDKs\MPI\Include" ^
    -L "C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64" -lmsmpi
3

Run with exactly 4 processes (N=20, n=4 as per the code).

Linux / WSL
mpirun -np 4 ./array
Windows (native)
mpiexec -n 4 array.exe

Expected Output — Each rank prints its local sum (ranks 0–3 each sum 5 numbers). Rank 0 prints final sum = 210.

04

Berkeley Clock Synchronisation

C++ Master server collects clocks from clients, computes the average, and sends each client its correction offset.

POSIX Sockets – Linux / WSL Only. server.cpp and client.cpp use <sys/socket.h>, <unistd.h>, and other POSIX headers that do not exist on native Windows. Use WSL (recommended) or a Linux machine.

FileRole
server.cppMaster – accepts clients on port 8080, collects their clocks, computes average, sends offsets back
client.cppSlave – connects to port 8080, reports its random local clock, receives and applies correction

Tools Required

  • g++ (GCC C++ compiler)
  • Linux / WSL / macOS
  • 2+ terminal windows

Install on Linux / WSL

  • sudo apt install g++ (Ubuntu)
  • sudo dnf install gcc-c++ (Fedora)
  • macOS: xcode-select --install

Compile

1
Linux / WSL / macOS
g++ -o server server.cpp
g++ -o client client.cpp

Run

2

Start the server first in Terminal 1.

Terminal 1
./server
# Server prints its own random clock and listens on port 8080
3

Open one or more new terminals and run a client in each.

Terminal 2 (and optionally Terminal 3, 4…)
./client
# Client prints its random clock and connects to 127.0.0.1:8080
4

Back in the server terminal, when asked "Do you have enough clients?" type 1 and press Enter. The server will compute the average and send offsets.

Terminal 1 (server prompt)
# You have connected 1 client(s) now.
# Do you have enough clients? (input '1' for yes, '0' for no): 
1

Expected Output — Each client prints "received local clock adjustment offset is add/minus X.XXXXXX" and then its adjusted clock. Server prints "Server new local clock is X" (should equal the average).

05

Token-Based Mutual Exclusion

Java A central server relays data; ClientOne holds the token initially and passes it to ClientTwo in a ring.
FileRolePort
MutualServer.javaCentral server — accepts connections from both clients on port 7000, prints messages it receives7000
ClientOne.javaStarts with the Token; connects to server (7000), listens on 7001 for token from ClientTwo7000, 7001
ClientTwo.javaReceives token from ClientOne (7001) and passes it back in a loop7000, 7001

Tools Required

  • JDK 8 or later
  • 3 terminal windows
  • Ports 7000 and 7001 free

Startup Order (Critical)

  • 1st: Start MutualServer
  • 2nd: Start ClientOne
  • 3rd: Start ClientTwo

Step-by-Step (Windows & Linux)

1

Compile all three Java files.

Windows & Linux
javac MutualServer.java ClientOne.java ClientTwo.java
2

Start the central server in Terminal 1.

Terminal 1
java MutualServer
# Prints: Server Started
3

Start ClientOne in Terminal 2. It immediately asks if you want to send data.

Terminal 2
java ClientOne
# Prints: Do you want to send some data? Enter Yes or No
4

Start ClientTwo in Terminal 3. It waits for the token from ClientOne.

Terminal 3
java ClientTwo
# Prints: Waiting for Token
5

Interact via Terminal 2 (ClientOne): type Yes to send data, then type your message. The data appears in the MutualServer terminal. The token then passes to ClientTwo automatically.

06a

Bully Algorithm – Leader Election

Java Simulates the Bully election algorithm: the highest-numbered active process becomes coordinator.
FileDescription
BullyAlgo.javaSelf-contained simulation — enter number of processes, crash/recover them, and observe new coordinator election via menu

Tools Required

  • JDK 8 or later (single terminal)
  • No network or extra tools needed

Menu Options

  • 1 — Crash a process
  • 2 — Recover a process
  • 3 — Display current coordinator
  • 4 — Exit

Step-by-Step (Windows & Linux)

1
Windows & Linux
javac BullyAlgo.java
java  BullyAlgo
2

Follow the interactive prompts. Sample interaction:

Sample Session
Enter The Number Of Processes: 5

  1. Crash A Process
  2. Recover A Process ...
1
Enter A Process To Crash: 5
The Coordinator Has Crashed!
Enter The Initiator: 3
*** New Coordinator Is 4 ***

Algorithm Logic: When the coordinator (highest-id process) is crashed, the initiator sends election messages to all higher-id processes. The highest remaining active process wins and becomes the new coordinator.

06b

Ring Algorithm – Leader Election

Java Processes arranged in a ring pass messages; the process with the highest ID becomes coordinator.
FileDescription
Ring.javaSimulation — user enters process IDs, one process initiates an election, the maximum ID in the ring becomes coordinator. Also contains helper class Rr.

Tools Required

  • JDK 8 or later (single terminal)
  • No network needed

Menu Options

  • 1 — Initiate election (enter the index of the initiating process)
  • 2 — Quit

Step-by-Step (Windows & Linux)

1
Windows & Linux
javac Ring.java
java  Ring
2

Follow the interactive prompts. Sample interaction:

Sample Session
Enter the number of process: 4
Enter the id of process: 3
Enter the id of process: 7
Enter the id of process: 1
Enter the id of process: 5
Process 7 selected as coordinator

1.election  2.quit
1
Enter the process number who initialised election: 0
Process 7 selected as coordinator

Algorithm Logic: The initiating process sends its ID clockwise around the ring. Each active process appends its ID if it is active. The process with the maximum ID in the collected set becomes the new coordinator.

07

ASP.NET Web Services

C# / .NET An ASMX web service exposing Add() and SayHello(), consumed by both a web page and a Windows console app.
FileRole
FirstService.asmxASP.NET Web Service — provides Add(int a, int b) and SayHello()
WebApp.aspxWeb-based consumer — a browser form that calls both methods and shows results
WinApp.csConsole consumer — calls both methods and prints output to terminal

Windows Tools

  • Windows + IIS (Internet Information Services)
  • .NET Framework 4.x (pre-installed on Windows)
  • wsdl.exe and csc.exe (from .NET SDK)
  • Visual Studio (optional, simplifies hosting)

Linux – Mono

  • mono-complete package
  • XSP (Mono's built-in web server)
  • Note: Classic ASMX is Windows-native; Mono support is partial

Easier Alternative

  • Run inside Visual Studio on Windows — right-click project → "View in Browser"
  • Or use IIS Express (bundled with VS)

Windows – IIS Method

1

Enable IIS: Control Panel → Programs → Turn Windows features on/off → tick Internet Information Services → OK.

2

Create folder C:\MyWebServices, copy FirstService.asmx and WebApp.aspx there.

3

In IIS Manager, add a new site pointing to C:\MyWebServices, port 80. Browse to:

Browser
http://localhost/MyWebServices/FirstService.asmx       # Test service
http://localhost/MyWebServices/WebApp.aspx             # Consumer web page
4

Compile and run the console consumer (WinApp.cs) from Developer Command Prompt:

Developer Command Prompt
# Step 1: Generate proxy class from the running WSDL
wsdl http://localhost/MyWebServices/FirstService.asmx?WSDL

# Step 2: Compile proxy to DLL
csc /t:library FirstService.cs

# Step 3: Copy FirstService.dll to C:\MyWebServices\bin\

# Step 4: Compile the console app
csc /r:FirstService.dll WinApp.cs

# Step 5: Run it
WinApp.exe

Linux – Mono Method (Partial Support)

1
Ubuntu / Debian
sudo apt install -y mono-complete mono-xsp4
# Copy .asmx files to a web directory, then:
xsp4 --root /path/to/MyWebServices --port 8080
# Browse: http://localhost:8080/FirstService.asmx
2

Compile and run the console consumer with Mono:

Linux – Mono
wsdl http://localhost:8080/FirstService.asmx?WSDL
mcs /t:library FirstService.cs
mcs /r:FirstService.dll WinApp.cs
mono WinApp.exe

Expected Output (WinApp.exe)Calling Hello World Service: Hello World and Calling Add(2, 3) Service: 5.

08

Distributed Multiplayer Game

Go C# (Unity) Kubernetes Go game server (UDP+TCP), Go HTTP game manager, Unity3D C# client, and Kubernetes deployment.
FileRolePort
game_server.goGo UDP server (game state broadcast) + TCP server (reliable events)UDP:9000 / TCP:9001
game_manager.goGo HTTP server — REST endpoint to create game pods via kubectlHTTP:8080
GameClient.csUnity3D MonoBehaviour — UDP client that sends MOVE events and receives game stateUDP:9000
deployment.yamlKubernetes Deployment + Ingress for the Game Manager (3 replicas)

Tools – Game Server & Manager (Go)

  • Go runtime 1.18 or later
  • Windows: Download from go.dev/dl
  • Linux: sudo apt install golang-go
  • Verify: go version

Tools – Kubernetes Deployment

  • Docker – to build game server image
  • kubectl – Kubernetes CLI
  • Minikube (local) or any K8s cluster
  • NGINX Ingress Controller in cluster

Part A – Run Game Server Locally

1

Run the game server (UDP:9000 + TCP:9001). Keep Terminal 1 open.

Windows & Linux – Terminal 1
go run game_server.go
# Game server UDP listening on :9000
# Game server TCP listening on :9001
2

Test the UDP endpoint with netcat (Linux/WSL) or PowerShell.

Linux / WSL – Terminal 2
echo "MOVE:LEFT" | nc -u 127.0.0.1 9000
# Expect: STATE:map[127.0.0.1:xxxxx:[1 2]]
Windows – PowerShell
# Use netcat alternative or just run game_manager and check HTTP
Test-NetConnection -ComputerName localhost -Port 9000

Part B – Run Game Manager Locally

3

Run the game manager in Terminal 2 (requires kubectl installed & configured for the create-game endpoint to work).

Windows & Linux – Terminal 2
go run game_manager.go
# Game Manager listening on :8080
4

Test the REST endpoint to create a game:

Linux / macOS / WSL
curl -X POST http://localhost:8080/creategame \
  -H "Content-Type: application/json" \
  -d '{"player1":"alice","player2":"bob"}'
Windows – PowerShell
Invoke-RestMethod -Uri http://localhost:8080/creategame `
  -Method POST -ContentType "application/json" `
  -Body '{"player1":"alice","player2":"bob"}'

Part C – Unity3D Client (GameClient.cs)

5

This is a Unity MonoBehaviour script. To run it:

  • Install Unity Hub from unity.com/download (Windows or Linux)
  • Create a new 3D project in Unity
  • Create an empty GameObject in the scene
  • Drag and drop GameClient.cs onto the GameObject
  • Make sure game_server.go is running on port 9000
  • Press Play in Unity Editor — the client connects and sends MOVE:RIGHT every frame
  • Check the Console window in Unity for Server state: … output

Part D – Kubernetes Deployment

6

Build and push the Docker image, then deploy to Kubernetes.

Windows & Linux
# Step 1: Build Docker image for game manager
docker build -t game-manager:latest .

# Step 2: (If using Minikube) load image into Minikube
minikube image load game-manager:latest

# Step 3: Apply the Kubernetes manifest
kubectl apply -f deployment.yaml

# Step 4: Verify pods are running
kubectl get pods
kubectl get svc
7

Install Minikube (local Kubernetes) if you don't have a cluster:

Windows – PowerShell (Admin)
winget install Kubernetes.minikube
minikube start
Ubuntu / Debian
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
minikube start
📋

Quick Reference – All Tools at a Glance

Everything you need to install before attempting any practical
Practical Language Windows Tools Linux Tools Terminals
01 – RMI Java JDK 8+ (any), winget: Microsoft.OpenJDK.21 sudo apt install default-jdk 3
02 – CORBA Java 8 ONLY JDK 8 exactly from adoptium.net JDK 8 exactly: apt install openjdk-8-jdk 3
03 – MPI C MS-MPI SDK + Runtime + MinGW-w64 (or WSL) sudo apt install openmpi-bin libopenmpi-dev gcc 1
04 – Berkeley C++ WSL required (POSIX sockets) sudo apt install g++ 2+
05 – Token Mutex Java JDK 8+ sudo apt install default-jdk 3
06a – Bully Java JDK 8+ sudo apt install default-jdk 1
06b – Ring Java JDK 8+ sudo apt install default-jdk 1
07 – ASP.NET C# / .NET IIS + .NET Framework 4.x + .NET SDK (wsdl, csc) Mono: sudo apt install mono-complete mono-xsp4 1–2
08 – Game (Go) Go / C# / K8s Go runtime (go.dev/dl), Docker Desktop, kubectl, Minikube, Unity Hub sudo apt install golang-go + Docker + kubectl + Minikube + Unity Hub 2+

One-Time Windows Setup Checklist

  • ☐ Install JDK 21 (for most Java practicals)
  • ☐ Install JDK 8 separately (for CORBA only)
  • ☐ Enable WSL2 (wsl --install) for MPI and Berkeley
  • ☐ Install Go runtime from go.dev/dl
  • ☐ Enable IIS for ASP.NET practical
  • ☐ Install Docker Desktop for Kubernetes
  • ☐ Install Minikube for Kubernetes practical
  • ☐ Install Unity Hub for GameClient.cs

One-Time Linux Setup Checklist

  • sudo apt install default-jdk (Java 21 for most)
  • sudo apt install openjdk-8-jdk (JDK 8 for CORBA)
  • sudo apt install openmpi-bin libopenmpi-dev gcc g++
  • sudo apt install golang-go
  • sudo apt install mono-complete mono-xsp4
  • ☐ Install Docker Engine from docker.com
  • ☐ Install kubectl + Minikube
  • ☐ Install Unity Hub from unity.com/download
💡

Pro Tip – Managing Multiple JDK Versions on Windows
Use JABBA (jabba install 1.8 && jabba use 1.8) or simply keep two JDK folders and swap the JAVA_HOME environment variable before running each practical. For Linux use sudo update-alternatives --config java.

Port Summary: RMI uses 5000 • CORBA uses 1050 • Berkeley uses 8080 • Token Mutex uses 7000 & 7001 • Game Server uses UDP:9000 & TCP:9001 • Game Manager uses HTTP:8080. Ensure none of these ports are occupied by other processes before starting each practical.