Use Packet tracer software to build network topology and configure using
Distance vector routing protocol.
import [Link];
public class DistanceVectorRouting {
private int[][] distanceMatrix;
private int[] nextHop;
public DistanceVectorRouting(int[][] distanceMatrix) {
[Link] = distanceMatrix;
[Link] = new int[[Link]];
[Link]([Link], -1);
public void runRoutingProtocol() {
boolean updated;
int numNodes = [Link];
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 = [Link];
for (int i = 0; i < numNodes; i++) {
[Link]("Routing table for Node " + i);
[Link]("Destination\tNext Hop\tDistance");
for (int j = 0; j < numNodes; j++) {
if (i != j && nextHop[j] != -1) {
[Link](j + "\t\t" + nextHop[j] + "\t\t" + distanceMatrix[i][j]);
[Link]();
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
[Link]();
// Print the routing table
[Link]();
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 [Link].*;
import [Link].*;
import [Link];
import [Link];
// 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([Link]);
[Link]("Enter the numbers:");
// Take the inputs
num1 = [Link]();
num2 = [Link]();
[Link]("Enter the operator (+,-,*,/):");
char op = [Link]().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:
[Link]("You enter wrong input");
}
[Link]("The final result:");
[Link]();
// print the final result
[Link](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