0% found this document useful (0 votes)
8 views

List of Experiments and Last 2 Programs

The document outlines two programming tasks: implementing a Distance Vector Routing protocol in Java and creating a Basic Calculator using Java RMI. It includes code snippets for both tasks, demonstrating the logic for distance calculation and basic arithmetic operations. Additionally, it lists various experiments related to Operating Systems and Computer Networks, highlighting practical exercises for students.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

List of Experiments and Last 2 Programs

The document outlines two programming tasks: implementing a Distance Vector Routing protocol in Java and creating a Basic Calculator using Java RMI. It includes code snippets for both tasks, demonstrating the logic for distance calculation and basic arithmetic operations. Additionally, it lists various experiments related to Operating Systems and Computer Networks, highlighting practical exercises for students.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Use Packet tracer software to build network topology and configure using

Distance vector routing protocol.

import java.util.Arrays;

public class DistanceVectorRouting {

private int[][] distanceMatrix;

private int[] nextHop;

public DistanceVectorRouting(int[][] distanceMatrix) {

this.distanceMatrix = distanceMatrix;

this.nextHop = new int[distanceMatrix.length];

Arrays.fill(this.nextHop, -1);

public void runRoutingProtocol() {

boolean updated;

int numNodes = distanceMatrix.length;

do {

updated = false;

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

for (int j = 0; j < numNodes; j++) {

if (distanceMatrix[i][j] != 0 && distanceMatrix[i][j] != Integer.MAX_VALUE) {

for (int k = 0; k < numNodes; k++) {

if (distanceMatrix[i][j] + distanceMatrix[j][k] < distanceMatrix[i][k]) {

distanceMatrix[i][k] = distanceMatrix[i][j] + distanceMatrix[j][k];

nextHop[i] = j;

updated = true;

}
}

} while (updated);

public void printRoutingTable() {

int numNodes = distanceMatrix.length;

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

System.out.println("Routing table for Node " + i);

System.out.println("Destination\tNext Hop\tDistance");

for (int j = 0; j < numNodes; j++) {

if (i != j && nextHop[j] != -1) {

System.out.println(j + "\t\t" + nextHop[j] + "\t\t" + distanceMatrix[i][j]);

System.out.println();

public static void main(String[] args) {

// Define the distance matrix

int[][] distanceMatrix = {

{0, 1, 3, Integer.MAX_VALUE},

{1, 0, Integer.MAX_VALUE, 2},

{3, Integer.MAX_VALUE, 0, 4},

{Integer.MAX_VALUE, 2, 4, 0}

};

// Create a new instance of DistanceVectorRouting

DistanceVectorRouting routingProtocol = new DistanceVectorRouting(distanceMatrix);

// Run the routing protocol


routingProtocol.runRoutingProtocol();

// Print the routing table

routingProtocol.printRoutingTable();

OUTPUT:Routing table for Node 0

Destination Next Hop Distance

1 1 1

2 1 3

3 1 3

Routing table for Node 1

Destination Next Hop Distance

0 0 1

3 3 2

Routing table for Node 2

Destination Next Hop Distance

0 0 3

3 3 4

Routing table for Node 3

Destination Next Hop Distance

1 1 2

2 2 4
. Using JAVA RMI Write a program to implement Basic Calculator
// Java program for simple calculator
import java.io.*;
import java.lang.*;
import java.lang.Math;
import java.util.Scanner;

// Driver class
public class BasicCalculator {
// main function
public static void main(String[] args)
{
// Stores two numbers
double num1, num2;

// Take input from the user


Scanner sc = new Scanner(System.in);

System.out.println("Enter the numbers:");

// Take the inputs


num1 = sc.nextDouble();
num2 = sc.nextDouble();

System.out.println("Enter the operator (+,-,*,/):");

char op = sc.next().charAt(0);
double o = 0;

switch (op) {
// case to add two numbers
case '+':
o = num1 + num2;
break;

// case to subtract two numbers


case '-':
o = num1 - num2;
break;

// case to multiply two numbers


case '*':
o = num1 * num2;
break;

// case to divide two numbers


case '/':
o = num1 / num2;
break;
default:
System.out.println("You enter wrong input");
}

System.out.println("The final result:");


System.out.println();

// print the final result


System.out.println(num1 + " " + op + " " + num2
+ " = " + o);
}
}
OUTPUT

Enter the numbers:


2
2
Enter the operator (+,-,*,/)
+
The final result:
2.0 + 2.0 = 4.0

List of Experiments:
Operating Systems Programs
1. Practicing of Basic UNIX Commands.
2. Write programs using the following UNIX operating system calls Fork, exec, getpid, exit, wait,
close, stat, opendir and readdir
3. Simulate UNIX commands like cp, ls, grep, etc.
4. Simulate the following CPU scheduling algorithms a) Round Robin b) SJF c) FCFS d) Priority
5. Simulate the following CPU scheduling algorithms a)FCFS b) Priority
6. Simulate dining philosopher’s problem.
7. Simulate producer-consumer problem using threads.
8.. Implement the following memory allocation methods for fixed partition a) First fit b) Worst fit
c) Best fit
9. Simulate the following page replacement algorithms a) FIFO b) LRU c) LFU etc.,
10. Simulate Paging Technique of memory management
11. Simulate Bankers Algorithm for Dead Lock avoidance and prevention

Computer Networks Programs


12. Work with the commands Ping, Tracert, Ipconfig, pathping, telnet, ftp, getmac, ARP,
Hostname, Nbtstat, netdiag, and Nslookup
13. Find all the IP addresses on your network. Unicast, Multicast, and Broadcast on your network.
14. Use Packet tracer software to build network topology and configure using Distance vector
routing protocol.
15. Using JAVA RMI Write a program to implement Basic Calculator

You might also like