DCCNLAB
DCCNLAB
MODULE-1:
1. Study of different types of network cables and practically implement the cross wired cable and
straight through cable using Clamping tool.
2. Connect the computers in Local Area Network.
3. Study of basic network commands and network configuration commands.
4. Configure a Network Topology using packet tracer software.
MODULE-2:
1. Implementation of Error Detection / Error Correction Techniques.
2. Implementation of Stop and Wait Protocol and sliding window.
3. Implementation and study of Goback-N and selective repeat protocols.
4. Implementation of High Level Data Link Control.
5. Study of Socket Programming and Client – Server model using java.
6. Write a socket Program for Echo/Ping/Talk commands using java.
7. Implementation of distance vector routing algorithm.
8. Implementation of Link state routing algorithm.
9. Study of Network simulator (NS) and simulation of Congestion Control Algorithms using NS.
MODULE-2
PROGRAM:
import java.util.*;
class Hamming {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter the number of bits for the Hamming data: ");
int n = scan.nextInt();
int a[] = new int[n];
for (int i = 0; i < n; i++) {
System.out.println("Enter bit no" + (n - i - 1) + ":");
a[n - i - 1] = scan.nextInt();
}
System.out.println("You entered:");
for (int i = 0; i < n; i++) {
System.out.println(a[n - i - 1]);
}
System.out.println();
int b[] = generateCode(a);
System.out.println("Generated code is: ");
for (int i = 0; i < b.length; i++) {
System.out.print(b[b.length - i - 1]);
}
System.out.println();
System.out.println("Enter position of a bit to alter to check for error detection at the receiver end (0 for no
error): ");
int error = scan.nextInt();
if (error != 0) {
b[error - 1] = (b[error - 1] + 1) % 2;
}
System.out.println("Sent code is: ");
for (int i = 0; i < b.length; i++) {
System.out.println(b[b.length - i - 1]);
}
System.out.println();
receive(b, b.length - a.length);
}
static int[] generateCode(int a[]) {
int b[];
int i = 0, parity_count = 0, j = 0, k = 0;
while (i < a.length) {
if (Math.pow(2, parity_count) == i + parity_count + 1) {
parity_count++;
} else {
i++;
}
}
b = new int[a.length + parity_count];
for (i = 1; i <= b.length; i++) {
if (Math.pow(2, j) == i) {
b[i - 1] = 2;
j++;
} else {
b[k + j] = a[k++];
}
}
for (i = 0; i < parity_count; i++) {
b[((int) Math.pow(2, i)) - 1] = getParity(b, i);
}
return b;
}
PROGRAM:
import java.io.*;
import java.net.*;
Sender() {
}
import java.net.*;
ServerSocket receiver;
ObjectOutputStream out;
ObjectInputStream in;
int i = 0, sequence = 0;
Receiver() {
connection = receiver.accept();
sequence = 0;
out.writeObject("connected.");
do {
try {
in = new ObjectInputStream(connection.getInputStream());
data += packet.substring(1);
sequence = (sequence == 0) ? 1 : 0;
} else {
if (i < 3) {
out.writeObject(String.valueOf(sequence));
i++;
} else {
out.writeObject(String.valueOf((sequence + 1) % 2));
i = 0;
} finally {
try {
in.close();
out.close();
connection.close();
} catch (IOException e) {
} while (true);
} catch (IOException e) {
while (true) {
s.run();
import java.io.*;
import java.net.*;
Socket sender;
ObjectOutputStream out;
ObjectInputStream in;
String pkt;
SlideSender() {
try {
pkt = String.valueOf(SeqNum);
pkt = pkt.concat(String.valueOf(data));
LFS = SeqNum;
data++;
if (data == 'g')
data = 'a';
SeqNum++;
out.writeObject(pkt);
out.flush();
} catch (Exception e) {
in = new ObjectInputStream(sender.getInputStream());
while (LAR <= 15) {
try {
SendFrames();
LAR = Integer.parseInt(Ack);
} catch (Exception e) {
in.close();
out.close();
sender.close();
s.run();
import java.io.*;
import java.net.*;
import java.util.*;
ServerSocket receiver;
ObjectOutputStream out;
ObjectInputStream in;
String ack, pkt, data = " ";
int LFR = 0;
SlideReceiver() {
conc = receiver.accept();
if (conc != null)
in = new ObjectInputStream(conc.getInputStream());
try {
ack = str[0];
data = str[1];
LFR = Integer.parseInt(ack);
out.writeObject(ack);
out.flush();
}
} catch (Exception e) {
in.close();
out.close();
receiver.close();
System.out.println("\nConnection terminated.");
R.run();
OUTPUT:
PROGRAM:
import java.io.*;
rand = rands.nextInt(p);
v[rand] = -1;
for (int i = 0; i < p; i++) {
if (v[i] == -1) {
System.out.println("request to retransmit from packet no" + (i + 1) + " again!!");
n = i;
out.writeInt(n);
out.flush();
}
}
System.out.println();
v[n] = in.readInt();
System.out.println("received frame is: " + v[n]);
System.out.println("quitting");
} catch (Exception e) {
System.out.println(e);
}
}
}
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
PROGRAM:
import java.util.*;
public class Main {
static int[] crc_func(int[] crc) {
int l_d = 4, l_dd = 0;
char divisor[] = {'1', '1', '0', '0'};
char divident[] = new char[8];
int in = 0;
in = 0;
return fs;
}
crc = crc_func(crc);
System.out.println("HDLC:");
for (int i = 0; i < 48 + payload; i++) {
System.out.print(hdleframe[i]);
}
}
}
OUTPUT:
PROGRAM:
import java.net.*;
import java.io.*;
public class Server {
private ServerSocket server = null;
private Socket socket = null;
private DataInputStream in = null;
public Server(int port) {
try {
server = new ServerSocket(port);
System.out.println("Server Started");
System.out.println("Waiting for a client...");
socket = server.accept();
System.out.println("Client accepted");
in = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
OUTPUT:
6. Write a socket Program for Echo/Ping/Talk commands using java.
PROGRAM:
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class pingEmd {
public static void runSystemCommand(String command) {
try {
ProcessBuilder processBuilder = new ProcessBuilder(command.split(" "));
Process p = processBuilder.start();
OUTPUT:
7. Implementation of distance vector routing algorithm.
PROGRAM:
import java.io.*;
public class DVR
{
static int graph[][];
static int via[][];
static int rt[][];
static int v;
static int e;
System.out.print("Please enter the Source Node for the edge whose cost has changed: ");
int s = Integer.parseInt(br.readLine());
s--;
System.out.print("Please enter the Destination Node for the edge whose cost has changed: ");
int d = Integer.parseInt(br.readLine());
d--;
System.out.print("Please enter the new cost: ");
int c = Integer.parseInt(br.readLine());
graph[s][d] = c;
graph[d][s] = c;
PROGRAM:
import java.util.*;
OUTPUT: