Вы находитесь на странице: 1из 148

Department of I.T.

CN & Case Tools Lab Manual

COMPUTER NETWORKS AND CASETOOLS LAB


Objective:
To Under of various layers of OSI model
To inculcate object oriented software design
System/ Software Requirement
Intel based desktop PCs LAN CONNECTED with
minimum of 166 MHZ or faster processor with atleast
64 MB RAM and 100 MB free disk space
Tools Such as Rational Rose
Part - A
1. Implement the data link layer framing methods such as
character, character stuffing and bit stuffing.
2. Implement on a data set of characters the three CRC
polynomials CRC 12, CRC 16
and CRC CCIP.
3. Implement Dijkstra s algorithm to compute the Shortest
path thru a graph.
4. Take an example subnet graph with weights indicating
delay between nodes. Now obtain Routing table art each
node using distance vector routing algorithm
5. Take an example subnet of hosts . Obtain broadcast tree
for it.
6. Take a 64 bit playing text and encrypt the same using
DES algorithm.
7. Write a program to break the above DES coding
8. Using RSA algorithm Encrypt a text data and Decrypt the
same.
Part - B
1. The student should take up the case study of Unified
Library application which is mentioned in the theory, and
Vizag Institute of Engineering and Technology

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Model it in different views i.e Use case view, logical view,


component view, Deployment view, Database design,
forward and Reverse Engineering, and Generation of
documentation of the project.
2. Student has to take up another case study of his/her own
interest and do the same what ever mentioned in first
problem. Some of the ideas regarding case studies are given
in reference books which were mentioned in theory syllabus
can be referred for some idea.
Note : The analysis, design, coding, documentation,
database design of mini project which will be carried out in
4th year should be done in object-oriented approach using
UML and by using appropriate software which supports
UML, otherwise the mini project will not be evaluated.

COMPUTER NETWORKS LAB


1a) PROGRAM SPECIFICATION:
Program to implement bit stuffing.
ALGORITHM:
Step 1: Start
Step 2: Read the bit string to be transmitted in 0s and
1s.
Vizag Institute of Engineering and Technology

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Step 3: For stuffing process, append at begin and end


of the string.
Step 4: Check the string whether it has five
consecutive 1s except the appending string.
Step 5: If yes, insert 0 bit as stuff in the next bit else
transmit the next bit.
Step 6: Continue this process until the completion of
string.
Step 7: Stuffed data is obtained.
Step 8: Now destuffing process, remove the appended
string at start and end
of string.
Step 9: Check the stuffed string again whether it has
five consecutive 1s.
Step 10: If yes then remove the next bit i.e. do not
transmit the next bit else transmit the data.
Step 11: Continue this process until the last bit of
string.
Step 12: Original bit data has been obtained.
Step 13: Stop

Vizag Institute of Engineering and Technology

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

PROGRAM:
#include<stdio.h>
main()
{
int a[50],b[50],i,j,count=0,n,c[]={0,1,1,1,1,1,1,0};
clrscr();
printf("Enter the length of the string:\n");
scanf("%d",&n);
printf("Enter the string:\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
j=0;
/* Stuffing */
for(i=0;i<8;i++)
{
b[j]=c[i];
j++;
Vizag Institute of Engineering and Technology

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

}
for(i=0;i<n;i++)
{
if(a[i]==1)
{
b[j]=a[i];
count++;
if(count==5)
{
b[j]=a[i];
j++;
b[j]=0;
count=0;
}
j++;
}
else
{
b[j]=a[i];
j++;
count=0;
}
}
for(i=0;i<8;i++)
{
b[j]=c[i];
j++;
}
n=j;
printf("The frame after bit stuffing is:\n");
for(i=0;i<n;i++)
printf("%d",b[i]);
Vizag Institute of Engineering and Technology

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

printf("\n");
/*Destuffing*/
count=j=0;
for(i=8;i<n-8;i++)
{
if(b[i]==1)
{
a[j]=b[i];
count++;
if(count==5)
{
i++;
count=0;
}
j++;
}
else
{
a[j]=b[i];
j++;
count=0;
}
}
printf("The destuffed data is:\n");
for(i=0;i<j;i++)
printf("%d",a[i]);
getch();
}

Vizag Institute of Engineering and Technology

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

INPUT1:
Enter the length of the string:
15
Enter the string:
1
1
1
1
1
1
1
0
0
1
1
Vizag Institute of Engineering and Technology

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

1
1
1
1
OUTPUT1:
The frame after bit stuffing is:
011111101111101100111110101111110
The destuffed data is:
111111100111111
INPUT2:
Enter the length of the string:
8
Enter the string:
1
1
1
1
1
1
1
1
OUTPUT 2:
The frame after bit stuffing is:
0111111011111011101111110
The destuffed data is:
11111111

Vizag Institute of Engineering and Technology

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

1b)PROBLEM SPECIFICATION:
Program to implement character stuffing.
ALGORITHM:
Step 1: Start
Step 2: Read the character string to be transmitted in
upper case.
Step 3: For stuffing process, append at begin with
DLE STX as starting flag byte and end with DLE ETX as
ending flag byte of the string.
Step 4: Check the string whether it has DLE, STX,
and ETX.
Step 5: If yes then insert the string DLE before the
character else transmit the next character
Step 6: Continue this process until the completion of
string.
Step 7: Stuffed data is obtained.
Step 8: Now destuffing process, remove the appended
string at start and end of string.
Step 9: Check the stuffed string again whether it has
DLE, STX, and ETX.
Step 10: If yes then remove the string DLE that is
encountered first else transmit the data.
Step 11: Continue this process until the last character
of string.
Step 12: Original data has been obtained.
Step 13: Stop

Vizag Institute of Engineering and Technology

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

PROGRAM:
#include<stdio.h>
#include<conio.h>
main()
{
char a[30],b[30],c[30];
inti,j,n,m;
clrscr();
Vizag Institute of Engineering and Technology

10

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

printf("\tSTUFFING:\n");
printf("\nEnter the string in upper case:\n");
scanf("%s",&a);
n=strlen(a);
b[0]='D';
b[1]='L';
b[2]='E';
b[3]=' ';
b[4]='S';
b[5]='T';
b[6]='X';
b[7]=' ';
j=8;i=0;
while(i<n)
{
if((a[i]=='D'&&a[i+1]=='L'&&a[i+2]=='E')||
(a[i]=='S'&&a[i+1]=='T'&&a[i+2]=='X')||
(a[i]=='E'&&a[i+1]=='T'&&a[i+2]=='X'))
{
b[j]='D';
b[j+1]='L';
b[j+2]='E';
j=j+3;
}
b[j]=a[i];
i++;
j++;
}
b[j]=' ';
b[j+1]='D';
b[j+2]='L';
b[j+3]='E';
Vizag Institute of Engineering and Technology

11

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

b[j+4]=' ';
b[j+5]='E';
b[j+6]='T';
b[j+7]='X';
b[j+8]='\0';
printf("Frames after stuffing:\n");
printf("%s",b);
printf("\n\n\tDESTUFFING:\n");
m=strlen(b);
printf("\nFrames after destuffing:\n");
i=0,j=0;
while(i<8)
i++;
while(i<m-8)
{
if((b[i]=='D'&&b[i+1]=='L'&&b[i+2]=='E')||
(b[i]=='S'&&b[i+1]=='T'&&b[i+2]=='X')||
(b[i]=='E'&&b[i+1]=='T'&&b[i+2]=='X'))
{
i=i+3;
c[j]=b[i];
}
else
c[j]=b[i];
j++;
i++;
}
c[j]='\0';
printf("%s",c);
getch();
}

Vizag Institute of Engineering and Technology

12

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

INPUT1:
STUFFING:
Enter the string in upper case:
ETXWITHSTXCANDLE
OUTPUT1:
Frames after stuffing:
DLE STX DLEETXWITHDLESTXCANDLEDLE
DLE ETX
DESTUFFING:
Frames after destuffing:
ETXWITHSTXCANDLE
INPUT2:
STUFFING:
Enter the string in upper case:
STXETX
OUTPUT2:
Frames after stuffing:
DLE STX DLESTXDLEETX DLE ETX
DESTUFFING:
Frames after destuffing:
STXETX
2) PROGRAM SPECIFICATION:
Program to implement CRC-12.
ALGORITHM:
Step 1: Start
Vizag Institute of Engineering and Technology

13

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Step 2: Let r be the degree of G(x). Append r bits to


the low order end of the frame. So it now contains M+r
bits and corresponds to the polynomial XM(X).
Step 3: Divide the bit string corresponding to G(x) into
the bit string corresponding to xM(X) using Modulo 2
division.
Step 4: Subtract the remainder from the bit string
corresponding to XM(X) using Modulo 2 subtraction. The
result is checksummed frame to be transmitted call its
polynomial T(X).
Step 5: Stop

Vizag Institute of Engineering and Technology

14

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

PROGRAM:
#include<string.h>
#include<stdio.h>
#define crc 12
main()
{
char pola1[39],pola2[30],ch[2]="";
int
ad=0,i=0,j=0,mp[crc+1],pp1[10],pp2[10],gp[crc+1],rm[crc+
1],p1,p2,k;
clrscr();
printf("Enter the message polynomial(in the \"x7+x4+...\"
form):\n ");
gets(pola1);
for(i=0,p1=0;i<strlen(pola1);i++)
if(pola1[i]>='0'&&pola1[i]<='9')
Vizag Institute of Engineering and Technology

15

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

{
ch[0]=pola1[i];
ch[1]=pola1[i+1];
if(pola1[i+1]>='0'&&pola1[i+1]<='9')
i++;
pp1[p1++]=atoi(ch);
}
printf("Enter the generator polynomial(in the \"x7+x4+...\"
form):\n ");
gets(pola2);
for(i=0,p2=0;i<strlen(pola2);i++)
if(pola2[i]>='0'&&pola2[i]<='9')
{
ch[0]=pola2[i];
ch[1]=pola2[i+1];
if(pola2[i+1]>='0'&&pola2[i+1]<='9')
i++;
pp2[p2++]=atoi(ch);
}
if((pp1[0]+pp2[0])<=crc)
{
ad=pp1[0];
j=0;
for(i=ad;i>=0;i--)
{
if(i==pp1[j]&&j<p1)
{
mp[ad-i]=1;
j++;
}
else
mp[ad-i]=0;
Vizag Institute of Engineering and Technology

16

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

}
for(j=ad+1;j<=(ad+pp2[0]);j++)
mp[j]=0;
ad=pp2[0];
k=0;
for(i=ad;i>=0;i--)
{
if(i==pp2[k]&&k<p2)
{
gp[ad-i]=1;
k++;
}
else
gp[ad-i]=0;
}
printf("the message bit string is:\n ");
for(i=0;i<j;i++)
printf("%d",mp[i]);
printf("\nthe generator bit string is:\n ");
for(i=0;i<=ad;i++)
printf("%d",gp[i]);
printf("\n\nThe message to be transmitted is:\n ");
for(i=0;i<=ad;i++)
rm[i]=mp[i];
k=0;
while(1)
{
if(rm[0]==1&&k<=(j-(ad+1)))
{
for(i=0;i<=ad;i++)
{
if(rm[i]==gp[i])
Vizag Institute of Engineering and Technology

17

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

rm[i]=0;
else
rm[i]=1;
}
if(rm[0]==0&&k<(j-(ad+1)))
do
{
for(p1=0;p1<ad;p1++)
rm[p1]=rm[p1+1];
rm[p1]=mp[i+k];
k++;
}while(rm[0]==0&&k<(j-(ad+1)));
}
else
{
k=j-ad;
for(i=1;i<=ad;i++)
mp[k++]=rm[i];
for(i=0;i<j;i++)
printf("%d",mp[i]);
printf("\nthe CHECK SUM is:\n ");
for(i=1;i<=ad;i++)
printf("%d",rm[i]);
break;
}
}
}
else
printf("INVALID GENERATOR POLONOMIAL........");
getch();
}

Vizag Institute of Engineering and Technology

18

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Vizag Institute of Engineering and Technology

19

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Output 1:
Enter the message polynomial(in x7+x4+ form):
X0
Enter the message polynomial(in x7+x4+ form):
X12+x10+x2
The message bit string is:
1
The message bit string before adding checksum is:
1000000000000
The generator bit string is:
1010000000100
The message to be transmitted is:
1010000000100
The CHECK SUM is:
010000000100
Output 2:
Enter the message polynomial(in x7+x4+ form):
X10+X8+X6+X5+X3+X1
Enter the message polynomial(in x7+x4+ form):
Vizag Institute of Engineering and Technology

20

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

X2+X0
The message bit string is:
10101101010
The message bit string before adding checksum is:
1010110101000
The generator bit string is:
101
The message to be transmitted is:
1010110101011
The CHECK SUM is:
11

3) PROBLEM SPECIFICATION:
Program to implement Dijkastra Shortest path routing
algorithm.
ALGORITHM:
Step1: Enter the number of nodes of the subnet
and the node names.
Step2: Enter the cost between each and every
node in the subnet.

Vizag Institute of Engineering and Technology

21

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Step3: Enter the source node and destination node


for the subnet.
Step4:Calculate the shortest distance from source
node to every other nodes.
Step5: Print the shortest distance from source
node to destination.
Step6: Print the path from source to destination.

Vizag Institute of Engineering and Technology

22

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
intar[20][20],n,i,j,k,s,c,spd[10];
charst[20],spn[10];
charspath[10];
clrscr();
printf("Enter the number of nodes:\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter node %d name:\n",i);
scanf("%s",&st[i]);
}
for(i=0;i<n;i++)
Vizag Institute of Engineering and Technology

23

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

{
for(j=i;j<n;j++)
{
if(i==j)
{
ar[i][j]=0;
}
else
{
printf("Enter cost between %c and %c:\n",st[i],st[j]);
scanf("%d",&ar[i][j]);
ar[j][i]=ar[i][j];
}
}
}
printf("\n Enter starting and Ending nodes:");
scanf("%d %d",&s,&c);
for(k=0;k<n;k++)
{
printf(" %c",st[k]);
}
for(i=0;i<n;i++)
{
printf(" ");
printf("\n%c",st[i]);
for(j=0;j<n;j++)
{
printf(" ");
printf("%d",ar[i][j]);
}
}
for(i=0;i<n;i++)
Vizag Institute of Engineering and Technology

24

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

spd[i]=0;
i=0;
while(i!=n)
{
for(j=0;j<n;j++)
{
if(ar[i][j]!=0&&(spd[j]>ar[i][j]+spd[i]||spd[j]==0))
{
spd[j]=spd[i]+ar[i][j];
spn[j]=st[i];
}
}
i++;
}
printf("\nThe shortest distance is %d",spd[c]);
spath[0]=st[c];
for(i=c,j=1;spn[i]!=st[0];)
{
spath[j]=spn[i];
for(k=0;k<n;k++)
if(spn[i]==st[k])
break;
i=k;
j++;
}
printf("\n Shortest path is %c",st[0]);
for(i=j-1;i>=0;i--)
{
printf("%c",spath[i]);
}
getch();
}
Vizag Institute of Engineering and Technology

25

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

OUTPUT:
Enter the number of nodes:
6
Enter node 0 name:
a
Enter node 1 name:
b
Enter node 2 name:
c
Enter node 3 name:
d
Enter node 4 name:
e
Enter node 5 name:
f
Vizag Institute of Engineering and Technology

26

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Enter cost between a and b:


5
Enter cost between a and c:
7
Enter cost between a and d:
1
Enter cost between a and e:
3
Enter cost between a and f:
2
Enter cost between b and c:
8
Enter cost between b and d:
4
Enter cost between b and e:
6
Enter cost between b and f:
9
Enter cost between c and d:
1
Enter cost between c and e:
5
Enter cost between c and f:
8
Enter cost between d and e:
3
Enter cost between d and f:
2
Enter cost between e and f:
1

Vizag Institute of Engineering and Technology

27

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Enter starting and Ending nodes:b f


a b c d e f
a 0 5 7 1 3 2
b 5 0 8 4 6 9
c 7 8 0 1 5 8
d 1 4 1 0 3 2
e 3 6 5 3 0 1
f 2 9 8 2 1 0
The shortest distance is 25700
Shortest path is add

4) PROBLEM SPECIFICATION:
Program to implement distance routing vector.
Vizag Institute of Engineering and Technology

28

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

ALGORITHM:
Step1: Enter the number of nodes n of the subnet and
their node names.
Step2: Enter the link between each and every node in
the subnet.
Step3: Enter the source node in the subnet.
Step4: Enter the estimated delays m of source node
and their estimated values.
Step5: Enter the routing tables for n x m.
Step6: Find the shortest distance from nodes in the
subnet to estimated delays.
Step7: Print the routing table for source node with
their distances and linenames.

PROGRAM:
#include<stdio.h>
Vizag Institute of Engineering and Technology

29

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

#include<conio.h>
main()
{
char l,nname[20],dname[20],temp,s;
inti,j,m,c,n,k,sn,d,link[20][20],dly[10],rval[10]
[10];
clrscr();
printf("\nEnter the no of nodes:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nEnter the node %d name:",i);
scanf("%s",&nname[i]);
}
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
if(i==j)
{
link[i][j]=0;
}
else
{
printf("\nEnter the link between %c and
%c:",nname[i],nname[j]);
scanf("%d",&link[i][j]);
link[j][i]=link[i][j];
}
}
}clrscr();
for(k=0;k<n;k++)
Vizag Institute of Engineering and Technology

30

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

{
printf(" ");
printf("\t%c",nname[k]);
}
for(i=0;i<n;i++)
{
printf("\n");printf("%c",nname[i]);
for(j=0;j<n;j++)
{
printf("\t%d",link[i][j]);
}
}
printf("\nEnter the source node number and
name:");
scanf("%d\t%c",&sn,&s);
c=0;
for(i=0;i<n;i++)
{
if(link[sn][i]==1)
{
dname[c]=nname[i];
printf("\nEnter estimated delay from %c to
%c:",s,nname[i]);
scanf("%d",&d);
dly[c]=d;c++;
}
}
for(i=0;i<n;i++)
{
for(j=0;j<c;j++)
{
printf("\n");
Vizag Institute of Engineering and Technology

31

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

printf("\nEnter the value for %c and


%c:",nname[i],dname[j]);
scanf("\t%d",&rval[i][j]);
}
}
printf("\nThe matrix form of routing table\n");
for(k=0;k<c;k++)
{
printf("\t");
printf("%c",dname[k]);
}
for(i=0;i<n;i++)
{
printf("\n%c",nname[i]);
for(j=0;j<c;j++)
{
printf("\t%d",rval[i][j]);
}
}
printf("\nThe estimated time delay of %c\n",s);
printf("\t\t\t%c line\n",s);
for(i=0;i<n;i++)
{
printf("\n");printf("\t%c",nname[i]);
m=rval[i][0]+dly[0];
for(j=0;j<c;j++)
{
if(nname[i]==dname[j])
{
m=dly[j];l=dname[j];
}
else if(rval[i][j]+dly[j]<=m)
Vizag Institute of Engineering and Technology

32

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

{
m=rval[i][j]+dly[j];
l=dname[j];
}
if(nname[i]==s)
{
l='_'; m=0;
}
}
printf("\t\t");
printf("%d %c",m,l);
printf(" ");
}getch();
}

INPUT:
Enter the number of nodes: 6
Vizag Institute of Engineering and Technology

33

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Enter node 0 name: a


Enter node 1 name: b
Enter node 2 name: c
Enter node 3 name: d
Enter node 4 name: e
Enter node 5 name: f
Enter link between a and b: 1
Enter link between a and c: 0
Enter link between a and d: 0
Enter link between a and e: 1
Enter link between a and f: 0
Enter link between b and c: 1
Enter link between b and d: 0
Enter link between b and e: 0
Enter link between b and f: 1
Enter link between c and d: 1
Enter link between c and e: 1
Enter link between c and f: 0
Enter link between d and e:0
Enter link between d and f: 1
Enter link between e and f: 1
Enter the source node name and number: a 0
Enter the estimated delay from c to b: 6
Enter the estimated delay from c to d: 3
Enter the estimated delay from c to e: 5
Enter the value for a and b:5
Enter the value for a and d:16
Enter the value for a and e:7
Vizag Institute of Engineering and Technology

34

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Enter the value for b and b:0


Enter the value for b and d:12
Enter the value for b and e:6
Enter the value for c and b:8
Enter the value for c and d:6
Enter the value for c and e:3
Enter the value for d and b:12
Enter the value for d and d:0
Enter the value for d and e:9
Enter the value for e and b:6
Enter the value for e and d:9
Enter the value for e and e:0
Enter the value for f and b:2
Enter the value for f and d:10
Enter the value for f and e:4
OUTPUT:
a
b
c
d
e
f
a
0
1
0
0
1
0
b
1
0
1
0
0
1
c
0
1
0
1
1
0
d
0
0
1
0
0
1
e
1
0
1
0
0
1
f
0
1
0
1
1
0
The matrix form of routing table
b
d
e
a
5
16 7
b
0
12 6
c
8
6
3
d
12 0
9
e
6
9
0
f
2
10 4
Vizag Institute of Engineering and Technology

35

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

The time delay of c


b
line
a
11 b
b
6
b
c
0
d
3
d
e
5
e
f
8
b

Vizag Institute of Engineering and Technology

36

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

5) PROBLEM SPECIFICATION:
Program to implement Broadcast routing algorithm.
ALGORITHM:
Step1: Enter the number of nodes n of the subnet and
their node names.
Step2: Enter the link between each and every nodein
the subnet.
Step3: Enter the root node in the subnet and say hop
count as 0 and kept invisited array.
Step4: Compute the links from node and increment
hop count by 1 and kept visited array.
Step5: Repeat step4 until all nodes are visited without
forming any cycles.
Step6: Stop the process when all nodes are visited.

PROGRAM:
#include<stdio.h>
#include<conio.h>
main()
{
inti,j,n,link[20][20],c=0,hop=0
,sn,count=1,flag[30],root;
chars,nname[20];
clrscr();
printf("\nEnter the number of nodes:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nEnter %d node name:",i);
Vizag Institute of Engineering and Technology

37

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

scanf("%s",&nname[i]);
}
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
if(i==j)
link[i][j]=0;
else{
printf("\nEnter link between %c to
%c :",nname[i],nname[j]);
scanf("%d",&link[i][j]);
link[j][i]=link[i][j];
}
}
}
printf("\nEnter the source node name &
number:");
s=getche();
scanf("%d",&sn);
for(i=0;i<n;i++)
{
flag[i]=0;
}
printf("The matrix representation for the graph
is:\n");
printf("\t\t");
for(i=0;i<n;i++)
{
printf("%c\t",nname[i]);
}printf("\n");
for(i=0;i<n;i++)
Vizag Institute of Engineering and Technology

38

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

{
printf("\t%c",nname[i]);
for(j=0;j<n;j++)
{
printf("\t%d ",link[i][j]);
}
printf("\n");
}
printf("\nAt Hop count %d:%c",hop,s);
root=sn;flag[root]=1;
hop++;
while(count!=0)
{
for(i=0;i<n;i++)
{
if(link[root][i]!=0 && flag[root]==1 && flag[i]!
=1)
{
printf("\nAt Hop count %d:%c->
%c",hop,nname[root],nname[i]);
flag[i]=1;c++;
}
}
if(c!=0)
{
hop++;c=0;
}
if(root<n-1)
root++;
else
root=0;
for(i=0;i<n;i++)
Vizag Institute of Engineering and Technology

39

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

{
if(flag[i]==0)
break;
}
if(i==n)
count=0;
} getch();
}

INPUT:
Enter the number of nodes: 5
Enter node 0 name: a
Enter node 1 name: b
Enter node 2 name: c
Enter node 3 name: d
Enter node 4 name: e
Enter link between a and b: 1
Enter link between a and c: 1
Enter link between a and d: 0
Enter link between a and e: 0
Enter link between b and c: 1
Enter link between b and d: 1
Enter link between b and e: 0
Enter link between c and d: 1
Enter link between c and e: 0
Enter link between d and e: 1
Enter the source node name and number: a 0
Vizag Institute of Engineering and Technology

40

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

OUTPUT:
The matrix representation for the graph is:
a
b
c d e
a
0
1
1 0 0
b
1
0
1 1 0
c
1
1
0 1 0
d
0
1
0 0 1
e
0
0
0
1 0
At Hop count 0: a
At Hop count 1: ab
At Hop count 1: ac
At Hop count 2: bd
At Hop count 3: de

6) PROBLEM SPECIFICATION:
Program to implement Data Encryption Standard.
ALGORITHM:
Step 1: START
Vizag Institute of Engineering and Technology

41

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Step 2: Enter the 8 bit plain text and 10 bit key.


Step 3: The given key is divided into two halves one
left and the other right and the halves are applied to the
left shift.
Step 4: The given plain text is also divided into two
halves and right half is applied to Expansion table.
Step 5: The plain text is then xor with the key.
Step 6: Now the value is applied to the substitution
boxes.
Step 7: Now the permutation is applied.
Step 8: The obtained value is xor with the left half of
plain text and this becomes the Right half for the next
DES and the right half becomes left half for next DES.
Step 9: Now the cipher text is taken
and the plain text is generated. By the
process which is exactly opposite to the
process of Encryption
Step10: STOP

PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<math.h>
static char a[10],pp[10],z[10],k[10],ak[10],rp[10],
static char bk[10],k1[10],k2[10],ap[10],bp[10];
static char
k1[10],b[10],rk[10],x[10],ax[10],c[10],s[10],tem[10],p10[10
];
char i,j,s0[4][4],s1[4][4],kk[10],rr[10],bp1[10];
int y1,y2;
Vizag Institute of Engineering and Technology

42

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

xor(char d,char d1)


{
if(d==d1)
return('0');
else
return('1');
}
lr(char x[],int x1)
{
for(i=0;i<5;i++)
z[i]=x[i];
for(i=0;i<4;i++)
x[i]=z[i+1];
x[i]=z[0];
x1--;
if(x1!=0)
lr(x,x1);
}
key()
{
a[0]=bk[0];
a[1]=ak[2];
a[2]=bk[1];
a[3]=ak[3];
a[4]=bk[2];
a[5]=ak[4];
a[6]=bk[4];
a[7]=bk[3];
}

Vizag Institute of Engineering and Technology

43

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

ep()
{
b[0]=bp[3];
b[1]=bp[0];
b[2]=bp[1];
b[3]=bp[2];
b[4]=bp[1];
b[5]=bp[2];
b[6]=bp[3];
b[7]=bp[0];
}
ss(char e,char f)
{
if((e=='0')&&(f=='0'))
return(0);
if((e=='0')&&(f=='1'))
return(1);
if((e=='1')&&(f=='0'))
return(2);
if((e=='1')&&(f=='1'))
return(3);
}
s1s(char m)
{
if(m=='0')
{
kk[0]='0';kk[1]='0';
}
if(m=='1')
{
Vizag Institute of Engineering and Technology

44

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

kk[0]='0';kk[1]='1';
}
if(m=='2')
{
kk[0]='1';kk[1]='0';
}
if(m=='3')
{
kk[0]='1';kk[1]='1';
}
}
p1(char x[])
{
ax[0]=x[1];
ax[1]=x[3];
ax[2]=x[2];
ax[3]=x[0];
}
sos()
{
rk[0]=k[2];
rk[1]=k[4];
rk[2]=k[1];
rk[3]=k[6];
rk[4]=k[3];
rk[5]=k[9];
rk[6]=k[0];
rk[7]=k[8];
rk[8]=k[7];
rk[9]=k[5];
printf("\n rearranged key:");
for(i=0;i<5;i++)
Vizag Institute of Engineering and Technology

45

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

{
ak[i]=rk[i];
printf("%3c",rk[i]);
}
for(i=5,j=0;i<10;i++,j++)
{
bk[j]=rk[i];
printf("%3c",rk[i]);
}
lr(ak,1);
lr(bk,1);
printf("\n key1;");
key();
for(i=0;i<8;i++)
{
k1[i]=a[i];
printf("%3c",a[i]);
}
lr(ak,2);
lr(bk,2);
key();
printf("\n key2:");
for(i=0;i<8;i++)
{
k2[i]=a[i];
printf("%3c",a[i]);
}
}
prg(char p[])
{
rp[0]=p[1];
Vizag Institute of Engineering and Technology

46

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

rp[1]=p[5];
rp[2]=p[2];
rp[3]=p[0];
rp[4]=p[3];
rp[5]=p[7];
rp[6]=p[4];
rp[7]=p[6];
printf("\n rearranged plain text:");
for(i=0;i<8;i++)
printf("%3c",rp[i]);
for(i=0;i<4;i++)
ap[i]=rp[i];
for(i=4,j=0;i<8;i++,j++)
bp[j]=rp[i];
ep();
printf("\n e/p:");
for(i=0;i<8;i++)
{
bp[i]=b[i];
printf("%3c",bp[i]);
}
printf("\n xor;");
for(i=0;i<8;i++)
{
c[i]=xor(bp[i],k1[i]);
printf("%3c",c[i]);
}
[0][0]='1';
s0[0][1]='0';
s0[0][2]='3';
s0[0][3]='2';
s0[1][0]='3';
Vizag Institute of Engineering and Technology

47

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

[1][1]='2';
s0[1][2]='1';
[1][3]='0';
s0[2][0]='0';
s0[2][1]='2';
s0[2][2]='1';
s0[2][3]='3';
s0[3][0]='3';
s0[3][1]='1';
s0[3][2]='3';
s0[3][3]='2';
s1[0][0]='0';
s1[0][1]='1';
s1[0][2]='2';
s1[0][3]='3';
s1[1][0]='2';
s1[1][1]='0';
s1[1][2]='1';
s1[1][3]='3';
s1[2][0]='3';
s1[2][1]='0';
s1[2][2]='1';
s1[2][3]='0';
s1[3][0]='2';
s1[3][1]='1';
s1[3][2]='0';
s1[3][3]='3';
y1=ss(c[0],c[3]);
=ss(c[1],c[2]);
s1s(s0[y1][y2]);
for(i=0;i<2;i++)
s[i]=kk[i];
Vizag Institute of Engineering and Technology

48

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

y1=ss(c[4],c[7]);
y2=ss(c[5],c[6]);
s1s(s1[y1][y2]);
for(i=0,j=2;i<2;i++,j++)
s[j]=kk[i];
p1(s);
printf("\n p4:");
for(i=0;i<4;i++)
{
s[i]=ax[i];
printf("%3c",s[i]);
}
for(j=0;j<4;j++)
{
rp[j]=xor(s[j],ap[j]);
}
for(i=0;i<4;i++)
{
bp[i]=rp[i];
bp1[i]=rp[i];
}
for(i=4,j=0;i<8;i++,j++)
ap[j]=rp[i];
ep();
printf("\n e/p:");
for(i=0;i<8;i++)
{
bp[i]=b[i];
printf("%3c",bp[i]);
}
printf("\n xor:");
Vizag Institute of Engineering and Technology

49

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

for(i=0;i<8;i++)
{
c[i]=xor(bp[i],k2[i]);
printf("%3c",c[i]);
}
y1=ss(c[0],c[3]);
y2=ss(c[1],c[2]);
s1s(s0[y1][y2]);
for(i=0;i<2;i++)
s[i]=kk[i];
y1=ss(c[4],c[7]);
y2=ss(c[5],c[6]);
(s1[y1][y2]);
for(i=0,j=2;i<2;i++,j++)
s[j]=kk[i];
p1(s);
printf("\n p4:");
for(i=0;i<4;i++)
{
s[i]=ax[i];
printf("%3c",s[i]);
}
printf("\n IP inverse;");
for(i=0;i<4;i++)
{
rp[i]=xor(s[i],ap[i]);
printf("%3c",rp[i]);
}
for(j=0,i=4;i<8;j++,i++)
{
rp[i]=bp1[j];
printf("%3c",rp[i]);
Vizag Institute of Engineering and Technology

50

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

}
rr[0]=rp[3];
rr[1]=rp[0];
rr[2]=rp[2];
rr[3]=rp[4];
rr[4]=rp[6];
rr[5]=rp[1];
rr[6]=rp[7];
rr[7]=rp[5];
printf("\n cipher text:");
for(i=0;i<8;i++)
printf("%3c",rr[i]);
for(i=0;i<8;i++)
{
tem[i]=k1[i];
k1[i]=k2[i];
k2[i]=tem[i];
}
}
main()
{
intch,na;
clrscr();
do
{
printf("\nenterur choice:");
printf("1-->encryption 2-->decryption 3->exit:");
scanf("%d",&ch);
switch(ch)
{
Vizag Institute of Engineering and Technology

51

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

case 1: printf("enter 8 bit plain text:");


scanf("%s",&p10);
printf("enter 10 bit key:");
scanf("%s",&k);
na='2';
sos();
prg(p10);
break;
case 2: if(na!='2')
printf("\n decryption is not
possible without encryption");
else
prg(rr);
break;
case 3: exit();
}
}
while(ch<3);
getch();
}

OUTPUT 1:
Enter ur choice:
1encryption 2decryption 3exit:1
Enter 8 bit plain text: 11100010
Enter the 10 bit key: 0011001010
Rearranged key: 1 0 0 1 1 0 0 1 0 0
Key 1:0 1 1 10 1 10 0
Key 2:0 1 0 0 0 0 1 0
Vizag Institute of Engineering and Technology

52

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Rearranged plain text:1 0 1 1 0 0 0 1


e/p : 1 0 0 0 0 0 1 0
xor: 1 1 1 1 0 1 1 0
p4: 0 1 1 1
e/p:0 1 1 0 1 0 0 1
xor: 0 0 1 0 1 0 1 1
p4: 0 1 0 0
IP inverse: 0 1 0 1 1 1 0 0
Cipher text: 1 0 0 1 0 1 0 1
OUTPUT 2:
Enter ur choice:
1encryption 2decryption 3exit:1
Enter 8 bit plain text: 10101010
Enter the 10 bit key: 0101010101
Rearranged key: 0 0 1 0 1 1 0 0 1 1
Key 1:0 0 0 1 1 0 1 1
Key 2:0 1 0 1 1 0 0
Rearranged plain text:0 0 1 1 0 0
e/p : 1 0 0 1 0 1 1 0
xor: 1 0 0 0 1 1 0 1
p4: 0 0 0 0
e/p:1 0 0 1 0 1 1 0
xor: 0 0 1 1 1 0 1 0
p4: 0 0 0 1
IP inverse: 0 0 1 0 0 0 1 1
Cipher text: 0 0 1 0 1 0 1 0

Vizag Institute of Engineering and Technology

53

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

7) PROBLEM SPECIFICATION:
Program to implement Encryption of plain text..
ALGORITHM:
STEP 1: Start
STEP 2: Enter the 8 bit plain text and 10 bit key.
STEP 3: The given key is divided into two halves one
left and the other right and the halves are applied to the left
shift.
STEP 4: The given plain text is also divided into two
halves and right half is applied to Expansion table.
STEP 5: The plaintext is then xored with the key.
STEP 6: Now the value is applied to the substitution
boxes.
STEP 7: Now the permutation is applied.

Vizag Institute of Engineering and Technology

54

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

STEP 8: The obtained value is xored with the left half of


plain text and this becomes the Right half for the next DES
and the right half becomes left half for next DES.
STEP 9: Stop
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<math.h>
static char
a[10],pp[10],z[10],k[10],ak[10];
static char
rp[10],bk[10],k1[10],k2[10],ap[10],bp[10];
static char k1[10],b[10],rk[10],x[10];
static char
ax[10],c[10],s[10],tem[10],p10[10];
char i,j,s0[4][4],s1[4]
[4],kk[10],rr[10],bp1[10];
int y1,y2;
xor(char d,char d1)
{
if(d==d1)
return('0');
else
return('1');
}
lr(char x[],int x1)
{
for(i=0;i<5;i++)
z[i]=x[i];
Vizag Institute of Engineering and Technology

55

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

for(i=0;i<4;i++)
x[i]=z[i+1];
x[i]=z[0];
x1--;
if(x1!=0)
lr(x,x1);
}
key()
{
a[0]=bk[0];
a[1]=ak[2];
a[2]=bk[1];
a[3]=ak[3];
a[4]=bk[2];
a[5]=ak[4];
a[6]=bk[4];
a[7]=bk[3];
}
ep()
{
b[0]=bp[3];
b[1]=bp[0];
b[2]=bp[1];
b[3]=bp[2];
b[4]=bp[1];
b[5]=bp[2];
b[6]=bp[3];
b[7]=bp[0];
}
ss(char e,char f)
{
Vizag Institute of Engineering and Technology

56

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

if((e=='0')&&(f=='0'))
return(0);
if((e=='0')&&(f=='1'))
return(1);
if((e=='1')&&(f=='0'))
return(2);
if((e=='1')&&(f=='1'))
return(3);
}
s1s(char m)
{
if(m=='0')
{
kk[0]='0';kk[1]='0';
}
if(m=='1')
{
kk[0]='0';kk[1]='1';
}
if(m=='2')
{
kk[0]='1';kk[1]='0';
}
if(m=='3')
{
kk[0]='1';kk[1]='1';
}
}
p1(char x[])
{
ax[0]=x[1];
ax[1]=x[3];
Vizag Institute of Engineering and Technology

57

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

ax[2]=x[2];
ax[3]=x[0];
}
sos()
{
rk[0]=k[2];
rk[1]=k[4];
rk[2]=k[1];
rk[3]=k[6];
rk[4]=k[3];
rk[5]=k[9];
k[6]=k[0];
rk[7]=k[8];
rk[8]=k[7];
rk[9]=k[5];
printf("\n rearranged key:");
for(i=0;i<5;i++)
{
ak[i]=rk[i];
printf("%3c",rk[i]);
}
for(i=5,j=0;i<10;i++,j++)
{
bk[j]=rk[i];
printf("%3c",rk[i]);
}
lr(ak,1);
lr(bk,1);
printf("\n key1:");
key();
for(i=0;i<8;i++)
{
Vizag Institute of Engineering and Technology

58

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

k1[i]=a[i];
printf("%3c",a[i]);
}
lr(ak,2);
lr(bk,2);
key();
printf("\n key2:");
for(i=0;i<8;i++)
{
k2[i]=a[i];
printf("%3c",a[i]);
}
}
prg(char p[])
{
rp[0]=p[1];
rp[1]=p[5];
rp[2]=p[2];
rp[3]=p[0];
rp[4]=p[3];
rp[5]=p[7];
rp[6]=p[4];
rp[7]=p[6];
printf("\n rearranged plain text:");
for(i=0;i<8;i++)
printf("%3c",rp[i]);
for(i=0;i<4;i++)
ap[i]=rp[i];
for(i=4,j=0;i<8;i++,j++)
bp[j]=rp[i];
ep();
printf("\n e/p:");
Vizag Institute of Engineering and Technology

59

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

for(i=0;i<8;i++)
{
bp[i]=b[i];
printf("%3c",bp[i]);
}
printf("\n xor;");
for(i=0;i<8;i++)
{
c[i]=xor(bp[i],k1[i]);
printf("%3c",c[i]);
}
s0[0][0]='1';
s0[0][1]='0';
s0[0][2]='3';
s0[0][3]='2';
s0[1][0]='3';
s0[1][1]='2';
s0[1][2]='1';
s0[1][3]='0';
s0[2][0]='0';
s0[2][1]='2';
s0[2][2]='1';
s0[2][3]='3';
s0[3][0]='3';
s0[3][1]='1';
s0[3][2]='3';
s0[3][3]='2';
s1[0][0]='0';
s1[0][1]='1';
s1[0][2]='2';
s1[0][3]='3';
s1[1][0]='2';
Vizag Institute of Engineering and Technology

60

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

s1[1][1]='0';
s1[1][2]='1';
s1[1][3]='3';
s1[2][0]='3';
s1[2][1]='0';
s1[2][2]='1';
s1[2][3]='0';
s1[3][0]='2';
s1[3][1]='1';
s1[3][2]='0';
s1[3][3]='3';
y1=ss(c[0],c[3]);
y2=ss(c[1],c[2]);
s1s(s0[y1][y2]);
for(i=0;i<2;i++)
s[i]=kk[i];
y1=ss(c[4],c[7]);
y2=ss(c[5],c[6]);
s1s(s1[y1][y2]);
for(i=0,j=2;i<2;i++,j++)
s[j]=kk[i];
p1(s);
printf("\n p4:");
for(i=0;i<4;i++)
{
s[i]=ax[i];
printf("%3c",s[i]);
}
for(j=0;j<4;j++)
{
rp[j]=xor(s[j],ap[j]);
}
Vizag Institute of Engineering and Technology

61

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

for(i=0;i<4;i++)
{
bp[i]=rp[i];
bp1[i]=rp[i];
}
for(i=4,j=0;i<8;i++,j++)
ap[j]=rp[i];
ep();
printf("\n e/p:");
for(i=0;i<8;i++)
{
bp[i]=b[i];
printf("%3c",bp[i]);
}
printf("\n xor:");
for(i=0;i<8;i++)
{
c[i]=xor(bp[i],k2[i]);
printf("%3c",c[i]);
}
y1=ss(c[0],c[3]);
y2=ss(c[1],c[2]);
s1s(s0[y1][y2]);
for(i=0;i<2;i++)
s[i]=kk[i];
y1=ss(c[4],c[7]);
y2=ss(c[5],c[6]);
s1s(s1[y1][y2]);
for(i=0,j=2;i<2;i++,j++)
s[j]=kk[i];
p1(s);
printf("\n p4:");
Vizag Institute of Engineering and Technology

62

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

for(i=0;i<4;i++)
{
s[i]=ax[i];
printf("%3c",s[i]);
}
printf("\n IP inverse;");
for(i=0;i<4;i++)
{
rp[i]=xor(s[i],ap[i]);
printf("%3c",rp[i]);
}
for(j=0,i=4;i<8;j++,i++)
{
rp[i]=bp1[j];
printf("%3c",rp[i]);
}
rr[0]=rp[3];
rr[1]=rp[0];
rr[2]=rp[2];
rr[3]=rp[4];
rr[4]=rp[6];
rr[5]=rp[1];
rr[6]=rp[7];
rr[7]=rp[5];
printf("\n cipher text:");
for(i=0;i<8;i++)
printf("%3c",rr[i]);
for(i=0;i<8;i++)
{
tem[i]=k1[i];
k1[i]=k2[i];
k2[i]=tem[i];
Vizag Institute of Engineering and Technology

63

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

}
}
main()
{
intch,na;
clrscr();
do
{
printf("\nenterur choice:");
printf("1-->encryption 2->exit:");
scanf("%d",&ch);
switch(ch)
{
case 1: printf("enter 8 bit
plain text:");
scanf("%s",&p10);
printf("enter 10 bit
key:");
scanf("%s",&k);
sos();
prg(p10);
prg(rr);
break;
case 2: exit();
}
}
while(ch<2);
getch();
}

Vizag Institute of Engineering and Technology

64

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

OUTPUT 1:
Enter ur choice:
1encryption 2exit:1
encryption
Enter 8 bit plain text: 11100010
Enter the 10 bit key: 0011001010
Rearranged key: 1 0 0 1 1 0 0 1 0 0
Key 1:0 1 1 10 1 10 0
Key 2:0 1 0 0 0 0 1 0
Rearranged plain text:1 0 1 1 0 0 0 1
e/p : 1 0 0 0 0 0 1 0
xor: 1 1 1 1 0 1 1 0
p4: 0 1 1 1
e/p:0 1 1 0 1 0 0 1
xor: 0 0 1 0 1 0 1 1
p4: 0 1 0 0
IP inverse: 0 1 0 1 1 1 0 0
Cipher text: 1 0 0 1 0 1 0 1
Rearranged plain text: 0 1 0 1 1 1 0 0
e/p : 0 1 1 0 1 0 0 1
xor: 0 0 1 0 1 0 1 1
p4: 0 1 0 0
e/p:1 0 0 0 0 0 1 0
xor: 1 1 1 1 0 1 1 0
p4: 0 1 1 1
IP inverse:1 0 1 1 0 0 0 1
Cipher text: 1 1 1 0 0 0 1 0
Enter ur choice:
1encryption 2exit:2
OUTPUT 2:
Enter ur choice:
Vizag Institute of Engineering and Technology

65

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

1encryption 2exit:1
Enter 8 bit plain text: 10101010
Enter the 10 bit key: 0101010101
Rearranged key: 0 0 1 0 1 1 0 0 1 1
Key 1:0 0 0 1 1 0 1 1
Key 2:0 1 0 1 1 0 0
Rearranged plain text:0 0 1 1 0 0 1 1
e/p : 1 0 0 1 0 1 1 0
xor: 1 0 0 0 1 1 0 1
p4: 0 0 0 0
e/p:1 0 0 1 0 1 1 0
xor: 0 0 1 1 1 0 1 0
p4: 0 0 0 1
IP inverse: 0 0 1 0 0 0 1 1
Cipher text: 0 0 1 0 1 0 1 0
Rearranged plain text: 0 0 1 0 0 0 1 1
e/p : 1 0 0 1 0 1 1 0
xor: 0 0 1 1 1 0 1 0
p4: 0 0 0 1
e/p:1 0 0 1 0 1 1 0
xor: 1 0 0 0 1 1 0 1
p4: 0 0 0 0
IP inverse: 0 0 1 1 0 0 1 1
Cipher text: 1 0 1 0 1 0 1 0
Enter ur choice:
1encryption 2exit:2

Vizag Institute of Engineering and Technology

66

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

8) PROBLEM SPECIFICATION:
Using RSA algorithm Encrypt a text data and
Decrypt the same.
ALGORITHM:
STEP 1: START
STEP 2: Enter the two prime numbers namely p and
q.
STEP 3: Choose a e value which is less
than0(n),where 0(n)=(p-1)(q-1)
STEP 4: Now the d value will be obtained from the
e value basing on formula

D=e-1mod(0(n))

STEP 5: Now the plain text is to be entered and the


cipher text is obtained by formula C=M^e mod n, where
n=pq.
STEP 6: The decryption also takes place in opposite
way.
STEP 7: STOP.

PROGRAM:
/*RSA algorithm */
#include<stdio.h>
#include<conio.h>
#include<math.h>
Vizag Institute of Engineering and Technology

67

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

static int
a,i,x,e,n,mn,d,a1,a2,a3,b1,b2,b3,p,h,q,s,t1,t2,t3;
read1 ()
{
printf ("\n Enter a prime number :");
scanf("%d",&a);
x=0;
for(i=2;i<a;i++)
if(a%i==0)
x=3;
if((x==3)||(a==0)||(a==1))
{
printf("\n This is not a prime no.Enter prime
no:");
read1();
}
else
return(a);
}
gcd()
{
printf("\n Enter e value:");
scanf("%d",&e);
if((e<=1)||(e>=mn))
{
printf("\n Enter e value such that 1<e<
%d",mn);
gcd();
}
for(i=1;i<e;i++)
{
if(((mn%1)==0)&&((e%i)==0))
Vizag Institute of Engineering and Technology

68

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

x=i;
}
if(x!=1)
{
printf("\n Enter e value such that
gcd(%d,e)=1",mn);
gcd();
}
else
{
a1=1;a2=0;b1=0;b2=1;a3=mn;b3=e;
euc();
}
}
euc()
{
if(b3==0)
{
printf("\n d value does not exist for e value
%d enter another value",e);
gcd();
}
if(b3==1)
{
d=b2;
if(b2<0)
{
printf("\n Enter e value such that d is
positive");
gcd();
}
else
Vizag Institute of Engineering and Technology

69

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

{
printf("\n d value is :%d",d);
printf("\n enter m value;");
scanf("%d",&h);
mod(h);
}
}
s=a3/b3;
t1=a1-(s*b1);
t2=a2-(s*b2);
t3=a3-(s*b3);
a1=b1;a2=b2;a3=b3;
b1=t1;b2=t2;b3=t3;
euc();
}
mod(int m)
{
intl,k=1,ch;
longint w=1,mm=1,c;
l=e;
while(l!=0)
{
if(l<k)
k=l;
mm=l;
for(i=1;i<=k;i++)
mm=mm*m;
w=w*(mm%n);
l=l-k;
if(k<4)
k=k+k;
}
Vizag Institute of Engineering and Technology

70

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

c=w%n;
if(m==c)
printf("\n m value is: %d",c);
else
printf("\n c value is: %d",c);
printf("\n Enter your choice:");
printf("1.Caluculate another one\n2.Verify\n3.Exit");
scanf("%d",&ch);
switch (ch)
{
case 1:main();
case 2:mod(c);
break;
case 3:exit();
}
}
main ()
{
clrscr ();
p=read1 ();
q=read1 ();
n=p*q;
mn= (p-1)*(q-1);
gcd ();
getch ();
}

Vizag Institute of Engineering and Technology

71

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

INPUT 1:
Enter a prime number: 7
Enter a prime number: 3
Enter e value: 5
/*********** OUTPUT1 ************/
D value is 5
Enter m value: 88
C value is 10
Enter your choice 1.caluculate another one.
2. verify
3. Exit 1
INPUT 2:
Enter a prime number: 17
Enter a prime number: 11
Enter e value: 7
/*********OUTPUT2************/
D value is 23
Enter m value: 88
C value is 11
Enter your choice 1.caluculate another one.
2. verify
3. Exit 3

Vizag Institute of Engineering and Technology

72

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

UML (Unified Modeling Language)


UML is a language used for visualizing, specifying,
constructing and documenting the artifacts of software
intensive system.UML makes a clear conceptual
distinction between models, views and diagrams.
A Model is an element that contains information for a
software model.
A View is a visual expression of the information contained
in a model, and
A Diagram is a collection of view elements that represent
the users specific design thoughts.
Building Blocks of UML :
Things
Relationships
Diagrams.
Things in UML :
Structural Things
Classes
Interfaces
Collaborations
Vizag Institute of Engineering and Technology

73

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Use Cases
Active Classes
Components
Nodes Classes
Behavioral Things

Interactions
State Machines
Grouping Things
Packages
Annotational Things
Notes

Diagrams in UML:
Class Diagram
Object Diagram
Usecase Diagram
Sequence Diagram
Collaboration Diagram
Statechart Diagram
Activity Diagram
Component Diagram
Vizag Institute of Engineering and Technology

74

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Deployement Diagram
Class:

A class is the descriptor for a set of objects with

similar structure, behavior, and relationships.

It is

represented by a rectangle.

Interface: An interface is a specified for the externallyvisible operations of a class, component, or other classifier
(including subsystems) without specification of internal
structure. It is represented by a circle.

Relations:
Association
Dependency
Generalization
Realization
In addition to this there are
Directed Association
Aggregation and
Composition

Vizag Institute of Engineering and Technology

75

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Association:
An association is a structural relationship that
specifies the relation between two objects when they are at
the same level (peer level systems).
An Association can specify the relationship, role of
the class and Multiplicity.
An Association used in class diagram, Component
diagram, deployment diagram, usecase diagrams.
The multiplicity can be represented as 1-1..*,*,0
1.
It is represented as follows:

Directed Association:
Links a semantic association between two classes in
the UML diagram.
Directed association is used in class diagram,
Component diagram, deployment diagram, usecase
diagrams.
Vizag Institute of Engineering and Technology

76

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Symbol:
Aggregation:
Links a semantic association between two classes in
the UML diagram.
Aggregation is used in class diagram.
Symbol:

Composition:
Links a semantic association between two classes in
the UML diagram.
Composition is used in class diagram.
Symbol:

Generalization:
Generalization is a specification relationship in which
objects of the specialized element (the child ) are

Vizag Institute of Engineering and Technology

77

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

substitutable for objects of the generalization element (the


parent).It is used in class diagram.
Symbol:

Dependency:
A dependency is a semantic relationship in which if there
is any change occurred in one object that may effect other
object.
Dependency is used in class diagram, Component
diagram, deployment diagram, usecase diagrams.
Symbol:
----------------------------------------Realization:
Realization is a Specified tool that can be represented by
providing a relationship with classifier.
Dependency is used in class diagram, Component
diagram, deployment diagram, usecase diagrams.
Symbol:

Vizag Institute of Engineering and Technology

78

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

--------------------------------------------Class diagrams:
A class diagram is that which represents
classes,

interfaces,

and

collaborations

a set of

and

their

relationships, graphically a class diagram is a collection of


vertices and arcs.
It consists of three compartments.
Name
Attributes
Operations

Uses:
A class diagram is used to model the static design view of
a system.
Object diagrams:
An object diagram shares the same common
properties of all other diagrams.
;Name
Attributes
Vizag Institute of Engineering and Technology

Operations
79

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Uses:
An object diagram is used to model the static design
view of a system.
UseCase Diagrams:
A usecase diagram shares the common properties as all
diagrams. It distinguishes in the contents of use cases,
actors, dependency, and generalization relationships.

Actor
Uses:
A Usecase diagram is used to model the static design view
of a system.
Interaction Diagrams:
An Interaction diagram shares the same common
properties as all other diagrams. It differs in its contents
Vizag Institute of Engineering and Technology

80

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Objects
Links
Messages
It includes two diagrams Sequence and Collaboration

Sequence Diagrams:
A sequence diagram emphasizes the time ordering of
messages. Sequence diagrams have two features that
distinguish them from collaboration diagrams.
(i)Object life time
(ii)The focus of control
Collaboration Diagrams:
A collaboration diagram emphasizes the
organization of the objects that participate in an interaction
Collaboration diagrams have two features that distinguish
them from sequence diagrams.
(i)Path
(ii) The Sequence number
Object: It is an instance of a class.
Symbol:

Object name

Vizag Institute of Engineering and Technology

81

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Stimulus: A Stimulus is a communication between two


Instances that conveys information with the expectation that
action will ensue. A Stimulus will cause an Operation to be
invoked, raise a Signal, or cause an Instance to be created or
destroyed.
Symbol:
It can be annotated by a name. It has a property as Action
kind.
Call:

Send:
Return:
-----------------------------------------Create:
<<create>>
Destroy:
Vizag Institute of Engineering and Technology

82

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

<<destroy>>

Uses:
Interaction diagrams are used to model the dynamic aspects
of a system. It is obtained in two ways:
(i) To model flows of control by time ordering.
(ii) To model flows of control by organization.
State Chart Diagrams:
State: A state is a condition during the life of an object or
an interaction during which it satisfies some condition,
performs some action, or waits for some event. It is
represented

by

rounded

rectangle.

Symbol:
State Name

Sub machine State: A submachine state is a syntactical


convenience that facilitates reuse and modularity. It is a
shorthand that implies a macro-like expansion by another
Sub State Name

state machine and is semantically equivalent to a composite


Vizag Institute of Engineering and Technology

83

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

state.
Symbol:

Initial State:
An initial is a kind of pseudostate that represents the starting
point in a region of a state machine. It has a single outgoing
transition to the default state of the enclosing region, and
has no incoming transitions. There can be one (and only
one) initial state in any given region of a state machine. It is
not

itself

state

but

acts

as

marker.

Symbol:

FinalState: A final state represents the last or "final" state


of the enclosing composite state. There may be more than
one final state at any level signifying that the composite
state can end in different ways or conditions. When a final
state is reached and there are no other enclosing states it
means that the entire state machine has completed its
transitions

and

no

more

transitions

can

Symbol:

Vizag Institute of Engineering and Technology

84

JNTUWORLD

occur.

Department of I.T.

CN & Case Tools Lab Manual

JunctionPoint: Junction Point chains together transitions


into a single run-to-completion path. May have multiple
input and/or output transitions. Each complete path
involving a junction is logically independent and only one
such path fires at one time. May be used to construct
branches and merges.
Symbol:

Transition: A transition is a directed relationship between


a source state vertex and a target state vertex. It may be part
of a compound transition, which takes the state machine
from one state configuration to another, representing the
complete response of the state machine to a particular event
instance.
Symbol:

Vizag Institute of Engineering and Technology

85

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Activity Diagram:
It represents the different activities in the system.
Action State: An action state represents the execution of an
atomic action, typically the invocation of an operation. An
action state is a simple state with an entry action whose only
exit transition is triggered by the implicit event of
completing the execution of the entry action. The state
therefore corresponds to the execution of the entry action
itself and
the outgoing transition is activated as soon as the action has
completed its execution.
Symbol:

Sub Activity State: A sub activity state represents the


execution of a non-atomic sequence of steps that has some
Vizag Institute of Engineering and Technology

86

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

duration; that is, internally it consists of a set of actions and


possibly waiting for events. That is, a sub activity state is a
hierarchical action, where an associated sub activity graph is
executed.
Symbol:
Sub Activity Name

Initial State: An initial is a kind of pseudo state that


represents the starting point in a region of a state machine. It
has a single outgoing transition to the default state of the
enclosing region, and has no incoming transitions. There
can be one (and only one) initial state in any given region of
a state machine. It is not itself a state but acts as a marker.
Symbol:

Final State: A final state represents the last or "final" state


of the enclosing composite state. There may be more than
Vizag Institute of Engineering and Technology

87

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

one final state at any level signifying that the composite


state can end in different ways or conditions. When a final
state is reached and there are no other enclosing states it
means that the entire state machine has completed its
transitions and no more transitions can occur.
Symbol:

Decision:

A state diagram (and by derivation an activity

diagram) expresses a decision when guard conditions are


used to indicate different possible transitions that depend on
Boolean

conditions

of

the

owning

object.

Symbol:

Component Diagrams:

Package:

A package is a grouping of model elements.

Packages themselves may be nested within other packages.


Vizag Institute of Engineering and Technology

88

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

A package may contain subordinate packages as well as


other kinds of model elements. All kinds of UML model
elements

can

be

organized

into

packages.

Symbol:

Interface:

An interface is a specified for the externally-

visible operations of a class, component, or other classifier


(including subsystems) without specification of internal
structure.
Symbol:

Component:

component

represents

modular,

deployable, and replaceable part of a system that


encapsulates implementation and exposes a set of interfaces.
Symbol:

Vizag Institute of Engineering and Technology

89

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Artifact: An Artifact represents a physical piece of


information that is used or produced by a software
development process. Examples of Artifacts include models,
source files, scripts, and binary executable files. An Artifact
may constitute the implementation of a deployable
component.
Symbol:
<<artifact>>

Deployment Diagrams:
Package:

A package is a grouping of model elements.

Packages themselves may be nested within other packages.


A package may contain subordinate packages as well as
other kinds of model elements. All kinds of UML model
elements can be organized into packages.
Symbol:

Node: A node is a run-time physical object that represents a


computational resource, generally having at least a memory
Node Name

Vizag Institute of Engineering and Technology

90

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

and often processing capability as well, and upon which


components may be deployed.
Symbol:

Node Instance: A node instance is an instance of a node. A


collection of component instances may reside on the node
instance.

Node Name

Symbol:

Artifact: An Artifact represents a physical piece of


information that is used or produced by a software
development process. Examples of Artifacts include models,
source files, scripts, and binary executable files. An Artifact
may constitute the implementation of a deployable
component.
<<artifact>>

Symbol:
Vizag Institute of Engineering and Technology

91

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Case Study 1
PROBLEM SPECIFICATION:
Case Study of :: LIBRARY MANAGEMENT SYSTEM.
This Library Management System is used
accomplish the tasks like issue , return, renewal the
book to the library. To computerize the library system, it
should validate the students, staff, etc...By entering the
student_id, and staff_id they used to log into the system.
The library has several volumes of books, journals,
magazines, news papers so, this system should maintain the
library database and also it should maintain the student, staff
database for validating them.
Vizag Institute of Engineering and Technology

92

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

To full fill these requirements we can to design this


system by making use of the UML diagrams for better
understanding the specifications.

USE
CASE
DIAGRAMS
MANAGEMENT SYSTEM:
Vizag Institute of Engineering and Technology

93

OF

LIBRARY

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

System
Add new books

collecting fines
reads magazines, journals, news papers

Update validity
<<extend>>
Access books

Ask for a book


<<include>>

check for authorization


Check for availability of book

<<include>>
Librarian

Student
issue the book

<<include>>
returns the book
<<include>>

renewals the book

ACTORS:
1. STUDENT:
The student is the primary actor who
requires the books from library.
2. LIBRARIAN: The Librarian is also a primary actor who
acts as a mediator between the system and the student. The
actions like issue, return and renewal are performed by
library. He interacts with the system directly.
Vizag Institute of Engineering and Technology

94

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

USE CASES SPECIFICATION OF THE SYSTEM:


The main tasks are performed by the system whenever
student or staff is valid.
I) MAIN FLOW OF EVENTS:
The student must be valid a person and have a
student_id. Similarly staff must be valid a person
and have a staff_id.
II) EXCEPTION FLOW OF EVENTS:
The student accessing the book like magazines,
journals, news papers etc...
III) PRECONDITION:
The client must already have an account in the
college.
IV) POSTCONDITION:
The account database of client is modified after
performing any action.
CLASS DIAGRAMS OF LIBRARY MANAGEMENT
SYSTEM:

Vizag Institute of Engineering and Technology

95

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual


depends on student data

depends on college data


Library
+issue_date
+ret_date
-fine
+std_no_of_books
+stf_no_of_books
+verifies()
+issues()
+renwals()
+returns()
+dispaly fine()

College

Student

+coll_name
-coll_code
+coll_address
+coll_phone
+coll_strn
+coll_data

+st_data()
+staff_data()
+coll_facalities()
+con_exam()
+con_online()
+con_events()
1
+con_sport()
+maintained by librarian
+Operation8()

Staf

+std_name
+std_num
+std_acc
+std_dep

+Stf_name
+stf_num
+stf_dep
+stf_acc

+attends()
+wrt_exam()
+logsin()
+uses_facilities()
+participates()
+request book()

+teaches()
+uses_facilities()
+conducts()
+invigilates()
+logsin()

Librarian
+lib_name
+lib_id

BooksData
+book_name
+author_name
+book_num
+publishers
-ISBN_num

+checks for availability


-collects_fine()
+verifies_login()
1..* +updates()
+maintanence()
-access_lib_data()
+creates_acc()
+deletes_acc()

+updates()
+no_of_books()
+softcopy()
+mastercd()

Class Diagram shows the implementation view of the


system, The first section tells the Name of the class, second
section shows the attributes of the class and the third section
shows the operations of the class. There may be any number
of students but only one library will be present and
providers not more than 3-book. Here Librarian has
composite aggregation with student and staff as librarian is
the one who can access the data n the library auto machine .
Library and librarian has simple association relationship as

Vizag Institute of Engineering and Technology

96

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

both have the same priority and some dependence


relationships between the classes as shown.
SEQUENCE
DIAGRAM
MANAGEMENT SYSTEM:

OF

L : librarian

S : student1

LIBRARY

Li : library

d : database

1 : logsin()

<<create>>

2 : checks for authorization()

3 : creates object()

4 : ask for book()

5 : verifies()
6 : checks for availability()

8 : display fine()

7 : justifies

9 : asks for fine()


10 : pays

11 : updates()

12 : issue the book()


13 : updates()
14 : logsout()

15 : releases()
<<destroy>>

<<destroy>>
16 : switches off()

17 : logsoff out the library()


<<destroy>>

In sequence diagram we considered the process of issue of a


book.In this the objects are the library, student, librarian and
the database. When a student login into the library the
librarian checks for authorization and creates an object for
Vizag Institute of Engineering and Technology

97

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

him. When student asks for the issue of the book the
librarian, he verifies in the library in turn it checks in the
database whether the student has the account
ACTIVITY
DIAGRAM
OF
LIBRARY
MANAGEMENT SYSTEM:

Vizag Institute of Engineering and Technology

98

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

STUDENT

Librarian

Asking for book


Check for book

Available

Not available

Issues

Verification

Student details

Fine verification

Book details

No

valid

In valid

Yes
Collecting fine

Issue the book

Collect book

The activity here considered is the verification of the


student and issuing or the returning of the book with or
without fine.
The student asks for a book.
Vizag Institute of Engineering and Technology

99

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

The library checks for the availability of the book. If the


book
Is available it issues by verification .If the details are valid
and has no fine the book is issued.
The student collects the book.
STATE
CHART DIAGRAMS
MANAGEMENT SYSTEM:
ideal state

OF

LIBRARY

entry state
enters student id
login

verification
authenticates

ask for book

pay fine

collecting book

logout

exit

Vizag Institute of Engineering and Technology

100

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

COMPONENT
DIAGRAM
MANAGEMENT SYSTEM:

OF

LIBRARY

issue.exe
issue of book
<<artifact>>
update.exe

return.exe
return of book

DEPLOYMENT
DIAGRAM
MANAGEMENT SYSTEM:

OF

LIBRARY

Database server

Clients

Librarian

Database Server

Student

Vizag Institute of Engineering and Technology

101

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Case Study 2
Problem statement: : Reservation counter.
Identification of actors:
The actors in the system are the passenger, the
counter clerk and the reservation system consisting of
form processing, reservation, canceling issued ticket,
ticket printing and updating etc.
Use cases:
User
Passenger

Role
1.Enquiry
2.Reservation
and ticketing
3.Cancellation

Vizag Institute of Engineering and Technology

102

JNTUWORLD

Use case
1.
Enquire
ticket
availability
and
other
details.
2.
Reserve

Department of I.T.

CN & Case Tools Lab Manual

Counter clerk

1.Form data
entry
2.Ticket
processing
3.Updation

Reservation
system

Server

seats
and
berths etc.
3.Cancel
tickets
1.Enter
the
details
into
system
2.Trigger
ticket
for
printing
3.Update data
in the system
1.
Process
reservation
data, process
ticketing and
process
cancellation.
2.Update.

Use case diagrams


System
Enquiries for availability

Passenger

CounterClerk

Availability status

Passenger enquiries for the availability of


Seats
Vizag Institute of Engineering and Technology

103

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Fill requisition form

Enter data into system

Passenger

Counter Clerk

Print ticket

Collect fare amount & Issues ticket

Reservation and ticketing


System
Fill Cancellation form

Enter data into system

Passenger

Collect issued ticket


Counter Clerk
Cancels ticket

Return money after deduction

Cancellation of issued ticket


Vizag Institute of Engineering and Technology

104

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Class diagram
Passenger

Clerk

+Name
+Gender
+Age
+Address

+Name
+Gender
+Age

0..*

1..*

+getDetails()
+getFareAmount()
+getTicket()

+fillForm()
+payFareAmount()
+collectTicket()

1
1
Reservation System
+processForm()
+reservation()
+fareComputation()
+processTicket()
+printTicket()

1..*
Payment

CreditPayment

CashPayment

Class diagram for railway reservation


system

Vizag Institute of Engineering and Technology

105

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Interaction diagrams
Sequence diagram

Vizag Institute of Engineering and Technology

106

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

: passenger

: clerk

: reservation system

1 : requestForm()

2 : givesForm()

3 : returnsFilledForm()

4 : entersDetails()

5 : checksAvailability()

6 : fareamount

7 : paysAmount()

8 : triggersTicket()

9 : printTicket()

10 : issueTicket()
11 : updates()

Vizag Institute of Engineering and Technology

107

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Collaboration diagram
4 : entersDetails()

1 : requestForm()
2 : givesForm()

5 : checksAvailability()

3 : returnsFilledForm()
: passenger

: clerk

8 : triggersTicket()

6 : fareamount

: reservation system

9 : printTicket()
11 : updates()

7 : paysAmount()
10 : issueTicket()

Collaboration diagram for reservation


Activity diagrams

[The Data train and tickets]

Data Entered into R&T System


Not Available Puts New Data and Train

R&T Checks Availabillity

Available
Fills Requisition From

R&T Process the Form

Prints Tickets

Tickets Issued and Fare Amount Collected

Vizag Institute of Engineering and Technology

108

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Activity diagram for Enquiry of seats available


Passenger

Clerk

Reservation system

Passenger Comes to the Counter


[Fill formdetails]

[Clerk Enters Details into system]

[Submits formto clerk]

[Formmodified]

Not ok

[Trigger Tickets Printing Process]

[prints the Tickets]

[Verify Availabilities]

Ok

Not

[Issue Tickets]

Ok
Ok

[Collect Amount]

[Informs the fare amount]

Not ok

[Trigger Update Process]


Confirms with the Passenger

Activity diagram for reservation


process
Component diagram

Vizag Institute of Engineering and Technology

109

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

reservation.exe
Reservation form
<<artifact>>
update.exe

cancellation.exe
Cancellation form

Component diagram for reservation


and ticketing

Deployment diagram

Clients

Reservation server

Clerk

Reservation Server

Kiosk

Deployment

diagram

for

reservation system

Vizag Institute of Engineering and Technology

110

JNTUWORLD

Railway

Department of I.T.

CN & Case Tools Lab Manual

Case Study 3
PROBLEM SPECIFICATION: Case Study of ATM
transaction.
An automated teller machine (ATM) or automatic
banking

machine

(ABM)

is

computerized

telecommunications device that provides the clients of a


financial institution with access to financial transactions in a
Vizag Institute of Engineering and Technology

111

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

public space without the need for a cashier, human clerk or


bank teller. On most modern ATMs, the customer is
identified by inserting a plastic ATM card with a magnetic
stripe or a plastic smart card with a chip that contains a
unique card number and some security information such as
an expiration date or CVVC (CVV). Authentication is
provided by the customer entering a personal identification
number (PIN). Using an ATM, customers can access their
bank accounts in order to make cash withdrawals (or credit
card cash advances) and check their account balances as
well as purchase cellphone prepaid credit.
With growing usage of the Internet, people are
utilizing the convenience of online shopping and the ability
to place an order for what they want at all hours of the day
and night, at the office, home, airport, a cafe, or just about
anywhere you can imagine. They want conveniences of
Internet communications to help them improve their
productiveness in the day to day balance between work and
personal life. While ATM's have added some convenience
to our lives. By using ATMs we can make payment
transaction at anytime from anywhere.

Vizag Institute of Engineering and Technology

112

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

USE CASE DIAGRAMS:

Vizag Institute of Engineering and Technology

113

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

System
verification
Bank

managedatabase

invalid PIN
<<extend>>

transcation
Bank client

ATM machine
<<include>>

deposite

withdrawal

balance enquiry

valid client

<<extend>>

invalid client

ACTORS:
1. BANKCLIENT: the bank client is a primary actor
which having an ATM card.
2. ATM MACHINE: The ATM machine is a primary
actor which is used to
Perform the online transaction. It is an
intermediate
between the bank client and bank.
3. BANK: The Bank is a second actor which will
verify the bank client account
and also manages the database.
Vizag Institute of Engineering and Technology

114

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

USE CASES SPECIFICATION OF TRANSACTION:


The use case transaction performs the ATM
transaction whenever cardholder is valid. It contains another
use cases like deposited, withdrawal & balance enquiry.
I) MAIN FLOW OF EVENTS:
The bank client must be valid person and have a
valid PIN number.
II) EXCEPTION FLOW OF EVENTS:
The bank client is an invalid person.
The client had entered the invalid PIN number.
III) PRECONDITION:
The client must already have an account in the
Bank.
IV) POSTCONDITION:
The account database of client is modified after
transaction.
CLASS DIAGRAMS OF ATM TRANSACTION:

Vizag Institute of Engineering and Technology

115

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Bank client

ATM machine

-pin card number


+deposit()
+tranfer()
+withdraw()
+insert_card()
+eject_card()
+entering_pin no.()

+atm_mach no.
1

+providing_receipt()
1..* +display_message()
+status()
+read_card()
+accept_card()
+view_balance()
+notify_successful receipt()

request for

1
asks for

manages

1
Bank

Thirdparity

+account_number
-pin_balance

-pin number

+open _account()
+create_account() 1
+withdraw_funds()
+verification()
+delete_account()

+verify_card()
+system_shut down()
+sys_start up()
+add_cash()
+verify_customer id()
+verify_customer status()
+asking _operation()

Bank database
+card reader_ information
+updating_dbbase()

I) PERSISTENCE CLASSES:
Bank client, ATM machine are the persistence classes.
II) NON-PERSISTENCE CLASSES:
Bank, Third-party, Bank database are non-persistence
classes.

SEQUENCE DIAGRAM OF ATM TRANSACTION:


(Overall ATM transaction)

Vizag Institute of Engineering and Technology

116

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

: Bankclient

: ATM machine

: Bank

1 : Insert ATMcard()

2 : Request PINnum()
3 : Enter PINnum()
4 : verify PINnum()

5 : valid PIN()
6 : Request amount()

7 : Enter amount()
8 : withdraw checking()
9 : withdraw successfully()
10 : Transcation successfully finished()
11 : dispense cash()

12 : print reciept()

13 : terminate()

<<destroy>>

COLLOBARATION
DIAGRAM
TRANSACTION:
(Start-up of ATM transaction)

Vizag Institute of Engineering and Technology

117

OF

JNTUWORLD

ATM

Department of I.T.

CN & Case Tools Lab Manual

ACTIVITY DIAGRAM OF ATM TRANSACTION:


Bankclient

ATM machine

Bank

Insert atmcard

[submite]

enter pin number

read PIN

verify PIN

[invalid]

[verification report]
[valid]
Enter amount

Request amount

dispense cash

update customer account

give recipt

close transcation

Vizag Institute of Engineering and Technology

118

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

STATE
CHART
TRANSACTION:

ideal

DIAGRAMS

OF

ATM

Insert card
Active
cancel

maintain

withdraw/enquiery

validate

maintainance
[continue]
selecting

processing

[not continue]
printreciept
entry/readcard
exit/ejectcard

COMPONENT DIAGRAM OF ATM TRANSACTION:


ATM.exe

ATMdatabase.db

transaction
+pin number
+withdraw()
+enquiery()

.tbl
it contains
databse tables

it contains
ATM.obj files

Vizag Institute of Engineering and Technology

119

it contains
ATM.java files

JNTUWORLD

it contain
ATM.dll files

Department of I.T.

CN & Case Tools Lab Manual

DEPLOYMENT
TRANSACTION:

ATM machine

Ethernet

DIAGRAM

OF

server

RAID farm

RS-232

ATM.exe

Bank

Vizag Institute of Engineering and Technology

120

ATM

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Case Study 4
ONLINE BOOKS SHOP
PROBLEM STATEMENT:
Customer can buy books through online.
Customers login into the website and add or remove to the
cart. Then he will place the order i.e., the cart of the books
then the warehouse checks that the customer is validate user
or not. Customer fills his details and made payment
transactions. The customer got his books through shipment.
Customer may get gifts for their transactions. Wrong
transactions can be verified. The main objective of this case
study ONLINE BOOK SHOP is to make the customers
purchase their books of interest through online without
wasting time by stepping into the bookshops. The customer
Vizag Institute of Engineering and Technology

121

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

can visit this site at any time, search the books and place the
orders which will be delivered by the dealer in short period
of time. This reduces the burden for both the customer and
dealer as the customer need not travel to the cities if the
book of his/her interest is not available in his area, whereas
the dealer also need not strain himself by standing in the
shop all the time. Here the dealer also need not respond to
each and every customer queries. Through this system the
customer submits a query and gets the response from the
database. The dealer can update the stock details of the
books in the database. This project is developed using
ASP.Net and SQL Server.
EXISTING SYSTEM
In the current system if a customer wants to purchase a book
he needs to go to the shop and search for the book then he
can buy that book.

Vizag Institute of Engineering and Technology

122

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Physical Data Flow Diagrams:Context Level Diagram:Search


Order
Customer

Book
Shop

Orders
sDetails
Add Books

Book Details
Ordered Books

Use case diagram:

Vizag Institute of Engineering and Technology

123

JNTUWORLD

Dealer

Department of I.T.

CN & Case Tools Lab Manual

System
Login

authentication

create cart
customer

<<include>>

request

validate customer

verify

order placing
checking

certificate
Validation

bookshop staf

pay
individual

lecturer
payment

sent
accept

Receive

gifts

Shipment
<<extend>>

bank

Scenario for Use case Diagram:-

1.Usecase Name
2. Participating
Instances

ONLINE BOOK SHOP


1. Customer
Actor
2. Dealer
1. Every customer should
have a unique id.
2. Dealer should have a
login-id and password.

3.Entry Conditions

Vizag Institute of Engineering and Technology

124

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

1. Customer
should
register in this system
for future purpose.
2. A Customer can search
for his/her books of
interest.
3. Customer order books.
4. The Customer provides
the shipment details to
which
address
the
ordered books should
be delivered.
5. Dealer can update the
book details.
6. Dealer delivers the
ordered books.

4. Flow of Events

1. The customer can get


the quick response from
the server.

5. Special requirements

Actors: Customer, Book shop staff, bank.


Main flow of events: Create cart, order placing, validations.
Exception flow of events: Gifts to customer, canceling
orders

Vizag Institute of Engineering and Technology

125

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Class Diagrams:
customer
-customer
-billing address
-delivery address
-email
-rating

cart
-total money
+place order()
+cancle order()

0..*

+create customer()
+get customer()
+change status()

1..*

credit card

1
1..*

-card number
-date of expire

0..*

+check authorized charge()

items to buy

frequent shopper

-unit price

-discount rate
-approval date

+add()
-remove()

database
-user name
-book name

+approval()
+disapprove()

+store()
+update()
+delete()
Warehouse
-name
+update()
+delete()

Vizag Institute of Engineering and Technology

126

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Database depends on the warehouse means adding new


customers and books done by Warehouse. Customers add
his books to the cart and make order at a time. A payment is
done through credit cards and receives their books through
shipment.

Sequence and Collaboration diagrams:

Vizag Institute of Engineering and Technology

127

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

website

c : customer

cart

card

staff

1 : login()

2 : authentication()
3 : search for book
4 : showed

5 : add()

6 : viewed
7 : order()
9 : details

8 : setrequest()

10 : update

11 : payment()
12 : authorozation
13 : acknowledgement
14

15 : shipment

Vizag Institute of Engineering and Technology

128

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

Colloboration Diagram:
1 : login()
2 : authentication()
3 : search for books()
7 : details()
8 : Updation()

w : database

4 : add or remove books()


5 : place order()

c : customer

c : cart

6 : viewed()
9 : payment()

10 : acknowledgement()
card : credit card

11 : validate order()
staff : Warehouse

12 : shipment()

Vizag Institute of Engineering and Technology

129

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

ACTIVITY DIAGRAM:
customer

staff

login

cart

verify
database

cardread

authentication

add books

view cart

[c:cart]

payment
staff

upadation

[w:data base]
receive book

Vizag Institute of Engineering and Technology

130

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

STATE CHART DIAGRAM:

Vizag Institute of Engineering and Technology

131

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

ideal

login

add books to cart

place order

check to add
show cart
show order

payment

shipment

COMPONENT DIAGRAM:
Vizag Institute of Engineering and Technology

132

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

users
online shopping

user/ customer

authentication

items
<<artifact>>
login.html

permissions

DEPLOYMENT DIAGRAM:

Vizag Institute of Engineering and Technology

133

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

TESTING
Test cases for customer registration:-

Test Case
1. If password
is
not
matched
with
confirm
password.

Condition
Checked
Password
confirm
password.

Being

Mismatched
password.

Password
should have at
least
6
characters.

2. Password is
empty.

Password
>6.

3. Customer
id contains
spaces.

Customer
id
should be alpha
numeric.

Blank
spaces
are not allowed.

Is Numeric.

Phone number
should
be
numeric.

4. Phone
number

length

Expected Output

Test Cases for Customer Verification:Vizag Institute of Engineering and Technology

134

JNTUWORLD

Department of I.T.

Test Case

CN & Case Tools Lab Manual

Condition
Checked

Being

Expected Output

1. Password

Password length>6.

Invalid
password.

2. Login

Should
empty.

Invalid
name.

not

be

login

Test Cases for searching books:-

Test Case
1. At
least
one of the
fields
should be
filled.

Condition
Checked

Being

bookname=null,
author=null,
publisher=null,
edition=null.

Expected Output
At least one of
the fields must
be filled.

Test Cases for ordering books:-

Test Case
1. Quantity

Condition
Being Expected Output
Checked
quantity<=0
Quantity should
be at least one
to place the

Vizag Institute of Engineering and Technology

135

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

order.
2. Credit card
no.
3. Credit card
no.

should be numeric

Should
be
numeric only.

length!= 14

invalid
card no.

credit

Test Cases for Shipment Details:-

Test Case
1. Address

Condition
Checked
address=null

Vizag Institute of Engineering and Technology

136

Being

Expected Output
address
required
deliver
order.

JNTUWORLD

is
to
the

Department of I.T.

CN & Case Tools Lab Manual

Case Study 5:
PROBLEM SPECIFICATION: Case study of college
administration:
For a student to enter college he must first obtain
an application form. Fill the details and write an entrance
test, after qualifying the student issues a rank card. In the
counseling system of EAMCET the student certificates are
verified and then seat is allotted in required college. The
college is equipped with computer laboratory, electrical and
electronics laboratory, English laboratory, embedded
systems laboratory etc. The library has several volumes of
books, journals, magazines, news papers etc.

Vizag Institute of Engineering and Technology

137

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

uSE
CASE
DIAGRAMS
ADMINISTRATION:

OF

COLLEGE

System

asks the certificates

Submits certificates

verifies the certificates


<<include>>
rank card

<<extend>>
invalid certificates
college administration

Student

Enquires about courses

ofers the courses

selects the course

clerk
gives the fees details

pays the fee

Issues ID card

ACTORS:
1. Student: The student is the primary actor who
requests for seat
2. College administration: The college administrator
is the primary actor who verifies the certificates and
grants the seat

Vizag Institute of Engineering and Technology

138

JNTUWORLD

manager

Department of I.T.

CN & Case Tools Lab Manual

a) Clerk: one who collects the certificates from the


student and submits to the administrator for
verification.
b) Manager: one who manages the college
administration?
USE CASES SPECIFICATION OF EXAMINATION:
The use-case specifies the college admission by
verifying the certificates and allotting the seat
I) MAIN FLOW OF EVENTS:
The student should have the certificates.
The college should have the facilities like library,
laboratory, and transport.
II) EXCEPTION FLOW OF EVENTS:
The certificates may be invalid.
III) PRECONDITION:
The student should have the certificates
IV) POSTCONDITION:
The student completes his course and gets degree.

Vizag Institute of Engineering and Technology

139

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

CLASS
DIAGRAMS
ADMINISTRATION:

Vizag Institute of Engineering and Technology

140

OF

COLLEGE

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

+has

1
college
+college name
+address
+phone
1

department

library

+department t
+dept name
*

+maintain database()

1..*

1..*

1..* +time table()


+add d()
+staff()

1..*

+text books
+book name
+author name
+issues()
+renewal()
+fine()

0..1
1..*
member

assigned to

*
*

course

attends

+status()
+admission()

* 0..1

1..*

student
+sname
+sno
+class

1..*

1..*

+chairperson
faculty

+course name
+tcourse
+add course()

1..*

teaches

+tstaff
+faculty name
+teach()
+salary()

attends

labaratory
+tlabs
+lab name
1..*

+remarks()
1..*

I) PERSISTENCE CLASSES:
College, department, laboratory are the persistence
classes.
II) NON-PERSISTENCE CLASSES:
Library, student, course, faculty, are the nonpersistence classes.

Vizag Institute of Engineering and Technology

141

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

SEQUENCE
DIAGRAM
OF
ADMINISTRATION:
(Admitting a Student into the college):
s : student

a : admission cell

COLLEGE

college database

1 : asks the certificates()


2 : submits the certificates()

3 : verifies the certificates()

4 : enquires about the rank card()


5 : submits the rank card()

6 : verifies the rank card()

7 : checks for the availability of seats()

8 : availble()
9 : enters the details()
10 : issues the id card()
<<destroy>>

Vizag Institute of Engineering and Technology

142

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

COLLOBARATION DIAGRAM
ADMINISTRATION:
(Recruitment of the faculty)

OF

COLLEGE

p : participant

c : college database

2 : submits the certificates()


1 : asks the certificates()
3 : expose some questions()
4 : answering the questions()
6 : sends an appointment letter()

7 : enters the details()

i : interviewer

5 : decides()

Vizag Institute of Engineering and Technology

143

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

ACTIVITY
DIAGRAM
OF
COLLEGE
ADMINISTRATION:
(THE STUDENT ATTENDING AN ONLINE EXAM IN
A COLLEGE)

Vizag Institute of Engineering and Technology

144

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

student

system

enters the IP address

requests

server

accepts

opens the login page

verifies student details

enters the user name and password

invalid

valid
displays question paper

answers the paper


submits
displays marks

Vizag Institute of Engineering and Technology

145

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

STATE CHART DIAGRAMS OF COLLEGE


ADMINISTRATION:
(A STUDENT ISSUING A BOOK IN A LIBRARY)

fine exists

Idle

book not available


Student requirement

book available

Check fine

stores information to database


fine doesn't exist

issue book

Vizag Institute of Engineering and Technology

146

JNTUWORLD

Department of I.T.

COMPONENT

CN & Case Tools Lab Manual

DIAGRAM

student.db

OF

COLLEGE
ADMI
NISTR
ATION
:

college.db

admission

.tlb
contains the
tables of student

.tlb
contains the
tables of college

DEPLOYMENT
DIAGRAM
ADMINISTRATION:

Vizag Institute of Engineering and Technology

147

.exe
contains
execute files

.dll
contains the
library files

OF

COLLEGE

JNTUWORLD

Department of I.T.

CN & Case Tools Lab Manual

student

server

RS-232

RAID

ETHERNET

console

Vizag Institute of Engineering and Technology

148

JNTUWORLD

Вам также может понравиться