0% found this document useful (0 votes)
3 views39 pages

Computer Networks Lab Programs

The document outlines various laboratory programs focused on computer networks, including practical implementations of network cables, devices, IP addressing, and data link layer framing methods. Each program includes specific aims, procedures, and source code examples for tasks such as character and bit stuffing, cyclic redundancy checks, and Dijkstra's algorithm for shortest paths. The document serves as a comprehensive guide for students to understand and apply networking concepts through hands-on experiments.

Uploaded by

amarvels95
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)
3 views39 pages

Computer Networks Lab Programs

The document outlines various laboratory programs focused on computer networks, including practical implementations of network cables, devices, IP addressing, and data link layer framing methods. Each program includes specific aims, procedures, and source code examples for tasks such as character and bit stuffing, cyclic redundancy checks, and Dijkstra's algorithm for shortest paths. The document serves as a comprehensive guide for students to understand and apply networking concepts through hands-on experiments.

Uploaded by

amarvels95
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/ 39

COMPUTER NETWORKS

LABORATORY
PROGRAM No. 1

Aim: Study of different types of Network cables and Practically implement the cross-
wired cable and straight through cable using clamping tool.

Apparatus (Components): RJ-45 connector, Climping Tool, Twisted pair Cable


Procedure: To do these practical following steps should be done:

1. Start by stripping off about 2 inches of the plastic jacket off the end of the cable. Be very
careful at this point, as to not nick or cut into the wires, which are inside. Doing so could alter
the characteristics of your cable, or even worse render is useless. Check the wires, one more
time for nicks or cuts. If there are any, just whack the whole end off, and start over.

2. Spread the wires apart, but be sure to hold onto the base of the jacket with your other hand.
You do not want the wires to become untwisted down inside the jacket. Category 5 cable
must only have 1/2 of an inch of 'untwisted' wire at the end; otherwise it will be 'out of spec'.
At this point, you obviously have ALOT more than 1/2 of an inch of un-twisted wire.

3. You have 2 end jacks, which must be installed on your cable. If you are using a pre-made
cable, with one of the ends whacked off, you only have one end to install - the crossed over
end. Below are two diagrams, which show how you need to arrange the cables for each type
of cable end. Decide at this point which end you are making and examine the associated
picture below.
Diagram shows you how to prepare Cross wired connection
Diagram shows you how to prepare straight through wired connection
PROGRAM No. 2

Aim: Study of following Network Devices in Detail


 Repeater
 Hub
 Switch
 Bridge
 Router
 Gate Way

Apparatus (Software): No software or hardware needed.

Procedure: Following should be done to understand this practical.

1. Repeater:Functioning at Physical Layer.A repeater is an electronic device that receives a


signal and retransmits it at a higher level and/or higher power, or onto the other side of an
obstruction, so that the signal can cover longer distances. Repeater have two ports ,so cannot
be use to connect for more than two devices

2. Hub: An Ethernet hub, active hub, network hub, repeater hub, hub or concentrator
is a device for connecting multiple twisted pair or fiber optic Ethernet devices together
and making them act as a single network segment. Hubs work at the physical layer (layer
1) of the OSI model. The device is a form of multiport repeater. Repeater hubs also
participate in collision detection, forwarding a jam signal to all ports if it detects a
collision.

3. Switch:A network switch or switching hub is a computer networking device that


connects network segments.The term commonly refers to a network bridge that processes and
routes data at the data link layer (layer 2) of the OSI model. Switches that additionally
process data at the network layer (layer 3 and above) are often referred to as Layer 3 switches
or multilayer switches.

4. Bridge: A network bridge connects multiple network segments at the data link layer
(Layer 2) of the OSI model. In Ethernet networks, the term bridge formally means a device
that behaves according to the IEEE 802.1D standard. A bridge and switch are very much
alike; a switch being a bridge with numerous ports. Switch or Layer 2 switch is often used
interchangeably with bridge.Bridges can analyze incoming data packets to determine if the
bridge is able to send the given packet to another segment of the network.

5. Router: A router is an electronic device that interconnects two or more computer


networks, and selectively interchanges packets of data between them. Each data packet
contains address information that a router can use to determine if the source and destination
are on the same network, or if the data packet must be transferred from one network to
another. Where multiple routers are used in a large collection of interconnected networks, the
routers exchange information about target system addresses, so that each router can build up
a table showing the preferred paths between any two systems on the interconnected networks.

6. Gate Way: In a communications network, a network node equipped for interfacing with
another network that uses different protocols.
 A gateway may contain devices such as protocol translators, impedance matching
devices, rate converters, fault isolators, or signal translators as necessary to provide
system interoperability. It also requires the establishment of mutually acceptable
administrative procedures between both networks.
 A protocol translation/mapping gateway interconnects networks with different
network protocol technologies by performing the required protocol conversions.
PROGRAM No. 3

Aim: Study of network IP

 Classification of IP address
 Sub netting
 Super netting

Apparatus (Software): NA

Procedure: Following is required to be study under this practical.


 Classification of IP address

As show in figure we teach how the ip addresses are classified and when they are used.

Class Address Range Supports


Class A 1.0.0.1 to 126.255.255.254 Supports 16 million hosts on each of 127 networks.
Class B 128.1.0.1 to 191.255.255.254 Supports 65,000 hosts on each of 16,000 networks.
Class C 192.0.1.1 to 223.255.254.254 Supports 254 hosts on each of 2 million networks.
Class D 224.0.0.0 to 239.255.255.255 Reserved for multicast groups.
Class E 240.0.0.0 to 254.255.255.254 Reserved.

 Sub netting
Why we Develop sub netting and How to calculate subnet mask and how to identify
subnet address.

 Super netting
Why we develop super netting and How to calculate supernet mask and how to
identify supernet address.
PROGRAM NO : 4
Aim: Connect the computers in Local Area Network.

Procedure: On the host computer

On the host computer, follow these steps to share the Internet connection:

1. Log on to the host computer as Administrator or as Owner.


2. Click Start, and then click Control Panel.
3. Click Network and Internet Connections.
4. Click Network Connections.
5. Right-click the connection that you use to connect to the Internet. For example, if you
connect to the Internet by using a modem, right-click the connection that you want under
Dial-up / other network available.
6. Click Properties.
7. Click the Advanced tab.

8. Under Internet Connection Sharing, select the Allow other network users to connect
through this computer's Internet connection check box.

9. If you are sharing a dial-up Internet connection, select the Establish a dial-up connection
whenever a computer on my network attempts to access the Internet check box if you
want to permit your computer to automatically connect to the Internet.

10. Click OK. You receive the following message:

When Internet Connection Sharing is enabled, your LAN adapter will be set to use IP
address 192.168.0.1. Your computer may lose connectivity with other computers on your
network. If these other computers have static IP addresses, it is a good idea to set them to
obtain their IP addresses automatically. Are you sure you want to enable Internet
Connection Sharing?

11. Click Yes.


The connection to the Internet is shared to other computers on the local area network (LAN).

The network adapter that is connected to the LAN is configured with a static IP address
of 192.168.0.1 and a subnet mask of 255.255.255.0

On the client computer

To connect to the Internet by using the shared connection, you must confirm the LAN
adapter IP configuration, and then configure the client computer. To confirm the LAN
adapter IP configuration, follow these steps:

1. Log on to the client computer as Administrator or as Owner.


2. Click Start, and then click Control Panel.
3. Click Network and Internet Connections.
4. Click Network Connections.
5. Right-click Local Area Connection and then click Properties.
6. Click the General tab, click Internet Protocol (TCP/IP) in the connection uses the
following items list, and then click Properties.

7. In the Internet Protocol (TCP/IP) Properties dialog box, click Obtain an IP address
automatically (if it is not already selected), and then click OK.

Note: You can also assign a unique static IP address in the range of 192.168.0.2 to
192.168.0.254. For example, you can assign the following static IP address, subnet mask, and
default gateway:

8. IP Address 192.168.31.202
9. Subnet mask 255.255.255.0
10. Default gateway 192.168.31.1

11. In the Local Area Connection Properties dialog box, click OK.

12. Quit Control Panel.


PROGRAM NO : 5(a)

NAME OF THE EXPERIMENT: Character Stuffing.


OBJECTIVE: Implement the data link layer framing methods.
RESOURCE: Turbo C
PROGRAM LOGIC:
The framing method gets around the problem of resynchronization after an error by ha vi
ng each frame star t wit h the ASCII charact er sequence DLE STX and t he sequence
DLE ETX. If the destination ever losses the track of the frame boundaries all it has to do is
look for DLE STX or DLE ETX characters to figure out. The data link layer on the
receiving end re moves the D LE before the data are given to the network layer. This
technique is called character stuffing.
PROCEDURE: Go to debug -> run or press CTRL + F9 to run the program.

SOURCE CODE:
//PROGRAM FOR CHARACTER STUFFING
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
void main()
{
int i=0,j=0,n,pos;char
a[20],b[50],ch; clrscr();
printf("enter
string\n");
scanf("%s",&a);
n=strlen(a);
printf("enter
position\n");
scanf("%d",&pos);
if(pos>n)
{
printf("invalid position, Enter again
:");scanf("%d",&pos);
}
printf("enter the
character\n");ch=getche();
b[0]='d';
b[1]='l';
b[2]='e';
b[3]='s';
b[4]='t';
b[5]='x';
j=6;

while(i<n)
{
if(i==pos-1)
{
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]=ch;
b[j+4]='d';
b[j+5]='l';
b[j+6]='e';
j=j+7;
}
if(a[i]=='d' && a[i+1]=='l' && a[i+2]=='e')
{
b[j]='d';
b[j+1]='l';
b[j+2]='e';
j=j+3;
}
b[j]=a[i];
i++;
j++;
}
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]='e';
b[j+4]='t';
b[j+5]='x';
b[j+6]='\0';
printf("\nframe after stuffing:\n");
printf("%s",b);
getch();
}
OUTPUT:

Viva Questions:
1. What is Character stuffing?
2. What is the use of character stuffing?
3. Are the delimiters for the character stuffing?
4. Expand DLE STX?
5. Expand DLE ETX?

11
PROGRAM No. : 5(b)
NAME OF THE EXPERIMENT: Bit Stuffing.
OBJECTIVE: Implement the data link layer framing method.
RESOURCE: Turbo C
PROGRAM LOGIC:
The new technique allows data frames to contain an arbitrary number if bits
and allows character codes with an arbitrary no of bits per character. Each frame begins and
ends with special bit pattern, 01111110, called a flag byte. Whenever the sender’s
data link layer encounters five consecutive ones in the data, it automatically stuffs a 0 bit
int o the outgoing bit st ream. This bit stuffing is analogous to charact er stuffing, in
whic h a D LE is stuffed int o t he outgoing character stream before DLE in the data.

SOURCE CODE:
// BIT Stuffing
program
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int a[20],b[30],i,j,k,count,n;
clrscr();
printf("Enter frame
length:"); scanf("%d",&n);
printf("Enter input frame (0's & 1's
only):"); for(i=0;i<n;i++)
scanf("%d",&a[i])
; i=0;
count=1;
j=0;
while(i<n)
{
if(a[i]==1)
{
b[j]=a[i];
for(k=i+1;a[k]==1 && k<n &&count<5;k++)
{
j++;
b[j]=a[k];
count++;
if(count==5)
{
12
j++;
b[j]=0;
}
i=k;
}
}
else
{
b[j]=a[i];
}
i++;
j++;
}
printf("After stuffing the frame
is:"); for(i=0;i<j;i++)
printf("%d",b[i]);
getch();
}

13
OUTPUT:

Viva questions:

2. What is Stuffing?
3. What is use of Stuffing?
4. With bit stuffing the boundary between two frames can be unambiguously recognize by?
5. Is a analogous to character stuffing?
6. The senders data link layer encounters ...... no of 1’s consecutively

14
PROGRAM No.: 6
NAME OF THE EXPERIMENT: Cyclic Redundancy Check.
OBJECTIVE: Implement on a data set of characters the three CRC polynomials – CRC 12,
CRC16 and CRC CCIP.
RESOURCE: Turbo C
PROGRAM LOGIC:
CRC method can detect a single burst of length n, since only one bit per column will
be changed, a burst of length n+1 will pass undetected, if the first bit is inverted, the last bit
is inverted and all other bits are correct. If the block is badly garbled by a long burst or by
multiple shorter burst, the probability that any of the n columns will have the correct
parity t hat is 0.5 so the proba bilit y of a bad blo ck being expected when it should not
be 2 power(-n). This scheme sometimes known as Cyclic Redundancy Code

PROCEDURE: Go to debug -> run or press CTRL + F9 to run the program.

SOURCE CODE:
//PROGRAM FOR CYCLIC REDUNDENCY CHECK
#include<stdio.h>
#include<conio.h>
int
gen[4],genl,frl,rem[4];
void main()
{
int i,j,fr[8],dupfr[11],recfr[11],tlen,flag;
clrscr();
frl=8;
genl=4;
printf("enter
frame:");
for(i=0;i<frl;i++)
{
scanf("%d",&fr[i]);
dupfr[i]=fr[i];
}
printf("enter
generator:");
for(i=0;i<genl;i++)
scanf("%d",&gen[i]);
tlen=frl+genl-1;
for(i=frl;i<tlen;i++)
{
dupfr[i]=0;
}
15
remainder(dupfr);
for(i=0;i<frl;i++)
{
recfr[i]=fr[i];
}
for(i=frl,j=1;j<genl;i++,j++)
{
recfr[i]=rem[j];
}
remainder(recfr);
flag=0;
for(i=0;i<4;i++)
{
if(rem[i]!=0)
flag++;
}
if(flag==0)
{
printf("frame received correctly");
}
Else
{
printf("the received frame is wrong");
}
getch();
}
remainder(int fr[])
{
int k,k1,i,j;
for(k=0;k<frl;k++)
{
if(fr[k]==1)
{
k1=k;
for(i=0,j=k;i<genl;i++,j++)
{
rem[i]=fr[j]^gen[i];
}
for(i=0;i<genl;i++)
{
fr[k1]=rem[i];
k1++;
}
}
}
}
16
OUTPUT:

Viva Questions:
1. What is CRC?
2. What is the use of the CRC?
3. Name the CRC standards?
4. Define Checksum?
5. Define generator polynomial?

17
PROGRAM No : 7

NAME OF THE EXPERIMENT: Shortest Path.


OBJECTIVE: Implement Dijkstra‘ s algorithm to compute the Shortest path thru a
given graph.

RESOURCE: Turbo C
Program Logic: Dijkstra's algorithm is very similar to Prim's algorithm for minimum
spanning tree. Like Prim's MST, we generate a SPT (shortest path tree) with given source as
root. We maintain two sets, one set contains vertices included in shortest path tree, and other
set includes vertices not yet included in shortest path tree.
PROCEDURE: Go to debug -> run or press CTRL + F9 to run the program.

SOURCE CODE:
// .PROGRAM FOR FINDING SHORTEST PATH FOR A GIVEN GRAPH//

#include<stdio.h>
#include<conio.h>
void main()
{
int path[5][5],i,j,min,a[5][5],p,st=1,ed=5,stp,edp,t[5],index;clrscr();
printf("enter the cost matrix\n");
for(i=1;i<=5;i++) for(j=1;j<=5;j++)
scanf("%d",&a[i][j]); printf("enter
the paths\n"); scanf("%d",&p);
printf("enter possible paths\n");
for(i=1;i<=p;i++) for(j=1;j<=5;j++)
scanf("%d",&path[i][j]);

18
for(i=1;i<=p;i++)
{
t[i]=0;
stp=st;
for(j=1;j<=5;j++)
{
edp=path[i][j+1];
t[i]=t[i]+a[stp][edp];
if(edp==ed)
break;
else
stp=edp;
}
}min=t[st];
index=st;
for(i=1;i<=p;i++)
{
if(min>t[i])
{
min=t[i];
index=i;
}
}
printf("minimum cost %d",min);
printf("\n minimum cost path ");
for(i=1;i<=5;i++)
{
printf("--> %d",path[index][i]);
if(path[index][i]==ed)
break;
}
getch();
}

19
Output:

Viva questions:

1. Define Dijkstra’s algorithm?


2. What is the use of Dijkstra’s algorithm?
3. What is path?
4. What is minimum cost path?
5. How to find shortest path using Dijkstra’s algorithm?

20
PROGRAM No. : 8

NAME OF THE EXPERIMENT: Distance Vector routing.


OBJECTIVE: Obtain Routing table at each node using distance vector routing algorithm
for agiven subnet.

RESOURCE: Turbo C
PROGRAM LOGIC:
Distance Vector Routing Algorithms calculate a best route to reach a
destination based solely on distance. E.g. RIP. RIP calculates the reach ability
based on hop count. It’s different from link state algorithms which consider some other
factors like bandwidth and other metrics to reach a destination. Distance vector
routing algorithms are not preferable for complex networks and take longer to converge.

PROCEDURE: Go to debug -> run or press CTRL + F9 to run the program.


SOURCE CODE:
#include<stdio.h>
#include<conio.h
> struct node
{
unsigned dist[20];
unsigned
from[20];
}rt[10];
int main()
21
{
int dmat[20][20];
int n,i,j,k,count=0;
clrscr();
printf("\nEnter the number of nodes : ");
scanf("%d",&n);printf("Enter the cost matrix :\n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
scanf("%d",&dmat[i][j]);
dmat[i][i]=0;
rt[i].dist[j]=dmat[i][j];
rt[i].from[j]=j;
}
Do
{
count=0;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
for(k=0;k<n;k++)
if(rt[i].dist[j]>dmat[i][k]+rt[k].dist[j])
{
rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j];
rt[i].from[j]=k;count++;
}
}while(count!=0);
for(i=0;i<n;i++)
{
printf("\nState value for router %d is
\n",i+1); for(j=0;j<n;j++)
{
printf("\nnode %d via %d Distance%d",j+1,rt[i].from[j]+1,rt[i].dist[j]);
}
}
printf(“\n”);
}

22
Output:

Viva Questions:
1. What is routing?
2. What is best algorithm among all routing algorithms?
3. What is static routing?
4. Differences between static and dynamic?
5. What is optimality principle?

23
PROGRAM No : 9

NAME OF THE EXPERIMENT: Broadcast Tree.


OBJECTIVE: Implement broadcast tree for a given subnet of hosts
RESOURCE: Turbo C
PROGRAM LOGIC:
This technique is widely used because it is simple and easy to understand. The idea o f
t his algo r it hm is to build a graph of the subnet wit h each node of the graph
representing a router and each arc of the graph representing a communication line. To
choose a route between a given pair of routers the algor it h m just finds t he broadcast
between them on the graph.

PROCEDURE: Go to debug -> run or press CTRL + F9 to run the program.

SOURCE CODE:
// Write a ‘c’ program for Broadcast tree from subnet of host
#include<stdio.h>
#include<conio.h
> int p,q,u,v,n;
int min=99,mincost=0;
int t[50][2],i,j;
int parent[50],edge[50][50];
main()
{
clrscr();
printf("\n Enter the number of
nodes"); scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("%c\t",65+i);
parent[i]=-1;
}
printf("\n");
for(i=0;i<n;i++)
{
printf("%c",65+i);
for(j=0;j<n;j++)
scanf("%d",&edge[i][j]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
if(edge[i][j]!=99)
if(min>edge[i][j])
{

24
min=edge[i][j];
u=i;
v=j;
}
p=find(u)
;
q=find(v)
;if(p!=q)
{
t[i][0]=u;
t[i][1]=v;
mincost=mincost+edge[u][v]
; sunion(p,q);
}
Else
{
t[i][0]=-1;t[i][1]=-1;
}
min=99;
}
printf("Minimum cost is %d\n Minimum spanning tree is\n"
,mincost);for(i=0;i<n;i++)
if(t[i][0]!=-1 && t[i][1]!=-1)
{
printf("%c %c %d", 65+t[i][0],65+t[i][1],edge[t[i][0]][t[i][1]]);printf("\n");
}
getch();
}
sunion(int l,int m)
{
parent[l]=m;
}
find(int l)
{
if(parent[l]>0)

i=parent[i];

return i;

25
Output:

Viva questions:
1. What is spanning tree?
2. What is broad cast tree?
3. What are the advantages of broadcast tree?
4. What is flooding?
5. What is subnet?

26
PROGRAM No : 10(a)

NAME OF THE EXPERIMENT: Encrypting DES.


OBJECTIVE: Take a 64 bit playing text and encrypt the same using DES algorithm.
RESOURCE: Turbo C
PROGRAM LOGIC:
Data encryption standard was widely adopted by the industry in security products. Pla in
t ext is encr ypt ed in blocks of 64 bit s yielding 64 bit s of cipher t ext . The algorithm
which is parameterized by a 56 bit key has 19 distinct stages. The first stage is a key
independent transposition and the last stage is exactly inverse of the transposition. There
maining stages are functionally identical but are parameterized by different functions of the
key. The algorithm has been designed to allow decryption to be done with the same key as
encryption.
PROCEDURE: Go to debug -> run or press CTRL + F9 to run the program.

SOURCE CODE:
#include<stdio.h
>
#include<conio.h
>
#include<stdlib.h
>
#include<string.h
> void main()
{
int i,ch,lp;char cipher[50],plain[50];
char key[50];
clrscr();
while(1)
{
printf("\n-----MENU ---\n");
printf("\n1:Data Encryption\t\n\n2:Data Decryption\t\n\n3:Exit");
printf("\n\nEnter your choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:printf("\nData Encryption");
printf("\nEnter the plain text:");
fflush(stdin);
gets(plain);
printf("\nEnter the encryption key:");
gets(key);
lp=strlen(key);
for(i=0;plain[i]!='\0';i++)
cipher[i]=plain[i]^lp;
27
cipher[i]='\0';
printf("\nThe encrypted text is:");
puts(cipher);
break;

case 2:
printf("\nData decryption");
for(i=0;cipher[i]!='\0';i++)
plain[i]=cipher[i]^lp;
printf("\nDecrypted text
is:");puts(plain);
break;
case 3: exit(0);
}
}
getch();
}

28
Output:

Viva Questions:

1. Expand DES

2. What is cipher text?

3. What is plain text?

4. Define public key?

5. Define encryption?

29
PROGRAM No: 10(b)
NAME OF THE EXPERIMENT: Decrypting DES.
OBJECTIVE: Write a program to break the above DES coding
RESOURCE: Turbo C
PROGRAM LOGIC:
Data encryption standard was widely adopted by the industry in security products. Plain
t ext is encr ypt ed in block of 64 bit s yielding 64 bit s of cipher t ext . The algorithm
which is parameterized by a 56 bit key has 19 distinct stages. The first stage is a key
independent transposition and the last stage is exactly inverse of the transposition. There
mining stages are functionally identical but are parameterized by different functions of the key.
The algorithm has been designed to allow decryption to be done with the same key as
encryption.

PROCEDURE: Go to debug -> run or press CTRL + F9 to run the program.

SOURCE CODE:
/*Write a program to break the above DES
coding*/ #include<stdio.h>
#include<conio.>
#include<string.>
#include<ctype.>
void main()
{
char pwd[20];
char alpha[26]="abcdefghijklmnopqrstuvwxyz";
int num[20],i,n,key;
clrscr();
printf("\nEnter the password:");
scanf("%s",&pwd);
n=strlen(pwd);
for(i=0;i<n;i++)
num[i]=toascii(tolower(pwd[i]))-'a';
printf("\nEnter the key:");
scanf("%d",&key);
for(i=0;i<n;i++)
num[i]=(num[i]+key)%26;
for(i=0;i<n;i++)
pwd[i]=alpha[num[i]];
printf("\nThe key is:%d",key);
printf("\nEncrypted text is:%s",pwd);
for(i=0;i<n;i++)
{
num[i]=(num[i]-key)%26;
if(num[i]<0)
30
num[i]=26+num[i];
pwd[i]=alpha[num[i]];
}
printf("\nDecrypted text is:%s",pwd);getch();
}

31
Output:

Viva Questions:

1. Define decryption
2. What is private key?
3. What is cipher feedback mode?
4. Define product cipher
5. What is DES chaining?

32
PROGRAM No : 11

NAME OF THE PROGRAM: Frame Sorting


OBJECTIVE: Write a program for Frame Sorting Technique
RESOURCE: Turbo C
PROGRAM LOGIC:
A frame is a digital data transmission unit in computer networking and telecommunication. A
frame typically includes frame synchronization features consisting of a sequence of bits or symbols
that indicate to the receiver the beginning and end of the payload data within the stream of symbols
or bits it receives. If a receiver is connected to the system in the middle of a frame transmission, it
ignores the data until it detects a new frame synchronization sequence.

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct frame{
int fslno;
char finfo[20];
};
struct frame arr[10];
int n;
void sort()
{
int i,j,ex;
struct frame temp;
for(i=0;i<n;i++)
{
ex=0;
for(j=0;j<n-i-1;j++)
if(arr[j].fslno>arr[j+1].fslno)
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
ex++;
}

if(ex==0) break;
}
}
void main()
{
int i;
clrscr();
33
printf("\n Enter the number of frames \n");
scanf("%d",&n);
for(i=0;i<n;i++)
{ arr[i].fslno=random(50);
printf("\n Enter the frame contents for sequence number
%d\n",arr[i].fslno);
scanf("%s",arr[i].finfo);
}
sort();
printf("\n The frames in sequence \n");
for(i=0;i<n;i++)
printf("\n %d\t%s \n",arr[i].fslno,arr[i].finfo);
getch();
}

34
OUTPUT

Enter the number of frames:3


Enter the frame contents for sequence number 23
Wrote
Enter the frame contents for sequence number 45
Program
Enter the frame contents for sequence number 9
Vikas

The frames in sequence


9 Vikas
23 Wrote
45 Program

35
PROGRAM NO: 12
Aim: Configure Network using Link State Vector Routing protocol.
 OSPF

Apparatus (Software): Packet Tracer Software

Procedure:

1. Develop a Topology shown in figure given below.


2. Configure all the workstations
3. Configure all switches
4. Configure all Routers
5. Implement OSPF protocols in Router to configure Network.

36
PROGRAM No: 13

AIM: To implement error detection and error correction techniques.

SOFTWARE REQUIREMENTS:

Turbo C THEORY: The upper layers work on some generalized view of network architecture and
are not aware of actual hardware data processing. Hence, the upper layers expect error-free
transmission between the systems. Most of the applications would not function expectedly if they
receive erroneous data. Applications such as voice and video may not be that affected and with some
errors they may still function well. Data-link layer uses some error control mechanism to ensure that
frames (data bit streams) are transmitted with certain level of accuracy. But to understand how errors is
controlled, it is essential to know what types of errors may occur. CRC is a different approach to detect
if the received frame contains valid data. This technique involves binary division of the data bits being
sent. The divisor is generated using polynomials. The sender performs a division operation on the bits
being sent and calculates the remainder. Before sending the actual bits, the sender adds the remainder
at the end of the actual bits. Actual data bits plus the remainder is called a codeword. The sender
transmits data bits as codewords.

ALGORITHM:
1. Open Turbo c++ software and type the program for error detection
2. Get the input in the form of bits.
3. Append 16 zeros as redundancy bits.
4. Divide the appended data using a divisor polynomial
5. The resulting data should be transmitted to the receiver.
6. At the receiver the received data is entered.
7. The same process is repeated at the receiver.
8. If the remainder is zero there is no error otherwise there is some error in the received bits
9. Run the program

C PROGRAM :

#include <stdio.h>
char m[50],g[50],r[50],q[50],temp[50];
void caltrans(int);
void crc(int);
void calram();
void shiftl();
int main() { int n,i=0;
char ch,flag=0;
printf("Enter the frame bits:");
while((ch=getc(stdin))!='\n')
m[i++]=ch;
n=i;
for(i=0;i<=16;i++)
m{m++}='0';
m[n]= '0';
37
printf("Message after appending 16 zeros:%s",m);
for(i=0;i<=16;i++)
g[i]='0';
g[0]=g[4]=g[11]=g[16]='1';g[17]='\0';
printf("\ngenerator:%s\n",g);
crc(n);
printf("\n\nquotient:%s",q);
caltrans(n);
printf("\ntransmitted frame:%s",m);
printf("\nEnter transmitted frame:");
scanf("\n%s",m);
printf("CRC checking\n");
crc(n);
printf("\n\nlast remainder:%s",r);
for(i=1;i<=16;i++)
if(r[i]!='0') flag=1;
else
continue;
if(flag==1) printf("Error during transmission");
else
printf("\n\nReceived freme is correct"); }
void crc(int n)
{
int i,j;
for(i=0;i<16;i++)
r[i]=m[i];
printf("\nintermediate remainder\n");
for(i=0;i
{
q[i]='1';
calram(); }
else
{
q[i]='0';
shiftl();
}
r[16]=m[17+i];
r[17]='\0';
printf("\nremainder %d:%s",i+1,r);
for(j=0;j<=17;j++) temp[j]=r[j];
}
q[n-16]='\0';
}
void calram()
{ int i,j;
for(i=1;i<=16;i++) r[i-1]=((int)temp[i]-48)^((int) g[i]-48)+48;
}
void shiftl()
{ int i;
for(i=1;i<=16;i++) r[i-1]=r[i];
}
void caltrans(int n)
38
{ int i,k=0;
for(i=n-16;i++)
m[i]=((int)m[i]-48)^((int)r[k++]-48)+48;
m[i]='\0';
}

OUTPUT:

Enter the Frame Bits:


1011
The msg after appending 16 zeros:
10110000000000000000
The Transmitted frame is:10111011000101101011
Enter the transmitted Frame 10111011000101101011
Received msg:10111011000101101011
The Remainder is: 0000000000000000
Received frame is correct.

VIVA QUESTIONS:
1. What are the types of errors?
2. What is Error Detection? What are its methods?
3. What is Redundancy?
4. What is CRC?
5. What is Checksum

39

You might also like