Cn & Case Tools

143
1a) PROGRAM SPECIFICATION: Program to implement bit stuffing. Description: Bits stuffing is the framing method which includes the flag bytes (01111110) as frame delimiters to given data. On the sending side, any time five consecutive 1s have been transmitted from the body of the message (i.e., excluding when the sender is trying to transmit the distinguished 01111110 sequence),the sender inserts a 0 before transmitting the next bit. On the receiving side, should five consecutive 1s arrive, the receiver makes its decision based on the next bit it sees (i.e., the bit following the five 1s). If the next bit is a 0, it must have been stuffed, and so the receiver removes it. If the next bit is a 1, then one of two things is true: Either this is the end-of-frame marker or an error has been introduced into the bit stream. By looking at the next bit, the receiver can distinguish between these two cases: If it sees a 0 (i.e., the last eight bits it has looked at are 01111110), then it is the end-of frame marker; if it sees a 1 (i.e., the last eight bits it has looked at are 01111111), then there must have been an error and the whole frame is discarded.

Transcript of Cn & Case Tools

Page 1: Cn & Case Tools

1a) PROGRAM SPECIFICATION:

Program to implement bit stuffing.

Description:

Bits stuffing is the framing method which includes the flag bytes (01111110) as

frame delimiters to given data.

On the sending side, any time five consecutive 1s have been transmitted from the

body of the message (i.e., excluding when the sender is trying to transmit the

distinguished 01111110 sequence),the sender inserts a 0 before transmitting the

next bit.

On the receiving side, should five consecutive 1s arrive, the receiver makes its

decision based on the next bit it sees (i.e., the bit following the five 1s).

If the next bit is a 0, it must have been stuffed, and so the receiver removes it.

If the next bit is a 1, then one of two things is true: Either this is the end-of-frame

marker or an error has been introduced into the bit stream.

By looking at the next bit, the receiver can distinguish between these two cases:

If it sees a 0 (i.e., the last eight bits it has looked at are 01111110), then it is

the end-of frame marker; if it sees a 1 (i.e., the last eight bits it has looked at

are 01111111), then there must have been an error and the whole frame is

discarded.

In the latter case, the receiver has to wait for the next 01111110 before it can

start receiving again, and as a consequence, there is the potential that the

receiver will fail to receive two consecutive frames.

Page 2: Cn & Case Tools

Example:-

Page 3: Cn & Case Tools

ALGORITHM:

Step1: Start.

Step2: Read the message frame.

Step3: Insert 01111110 at the starting of the message frame.

Step4: Check for five consecutive one’s if found then insert zero bit (0) otherwise print the frame as it is.

Step5: Repeat step 4 until end of the frame is reached.

Step6: Insert 01111110 at the end of the frame.

Step7: Print the stuffed data.

Step8: Now remove the 01111110 from the starting of the stuffed data.

Step9: Check for five consecutive one’s if found then remove the followed zero.

Step10: Repeat step9 until the 01111110 is encountered.

Step11: Remove 01111110 from the ending of the frame.

Step12: Print the destuffed data.

Step13: Stop.

PROGRAM:

Page 4: Cn & Case Tools

#include<stdio.h>#include<string.h>#include<conio.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++; }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++)

Page 5: Cn & Case Tools

printf("%d",b[i]); 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();}

Page 6: Cn & Case Tools

INPUT1:Enter the length of the string:15Enter the string:111111100111111

OUTPUT1:The frame after bit stuffing is:011111101111101100111110101111110

The destuffed data is:111111100111111

INPUT2:Enter the length of the string:8Enter the string:11111111

OUTPUT 2:The frame after bit stuffing is:0111111011111011101111110The destuffed data is:11111111

Page 7: Cn & Case Tools

1b)PROBLEM SPECIFICATION:Program to implement character stuffing.

Description:

Character stuffing, is the another framing method which uses character bytes as the

frame delimiters.

Characters to indicate the start and end of a frame. For instance, use the two -

character sequence DLE STX (Data-Link Escape, Start of Text) to signal the

beginning of a frame, and the sequence DLE ETX (End of Text) to flag the frame’s

end. For occurrence of either DLE or STX or ETX in the data one DLE character is

stuffed.

The receiver reverses the processes, replacing every occurrence of DLE DLE with a

single DLE

Example:-

ALGORITHM:

Page 8: Cn & Case Tools

Step 1: Start

Step 2: Read the character string to be transmitted in upper case.

Step 3: For stuffing process, append ‘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: In 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

PROGRAM:

Page 9: Cn & Case Tools

#include<stdio.h>#include<string.h>main(){ char a[50],b[50],c[]={'D','L','E','','S','T','X'}, d[]={'D','L','E','','E','T','X'}; int i,n,j=0; clrscr(); printf("\n Enter the string in characters with in 50 characters:"); flushall(); gets(a); n=strlen(a); for(i=0;i<7;i++) { b[j]=c[i]; j++; } for(i=0;i<n;i++) { 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++]='L'; b[j++]='E'; b[j++]=''; } b[j]=a[i]; j++; } for(i=0;i<8;i++) {

b[j]=d[i];j++;

}n=j;for(i=0;i<n-1;i++){ printf("%c",b[i]);}printf("\n The destuffed data is:");i=0;

Page 10: Cn & Case Tools

for(j=7;j<n-8;j++){ if(b[j]=='D'&& b[j+1]=='L' && b[j+2]=='E') { j=j+4; a[i]=b[j]; i++; }else{ a[i]=b[j]; i++;}

} for(j=0;j<i;j++) {

printf("%c",a[j]); } getch(); }

Page 11: Cn & Case Tools

INPUT1:Enter the string in characters (only alphabets)with in 50 characters

ETXWITHSTXCANDLE

OUTPUT1:DLE STX DLEETXWITHDLESTXCANDLEDLE DLE ETX

The destuffed data is:ETXWITHSTXCANDLE

INPUT2:

Enter the string in characters (only alphabets)with in 50 characters

STXETX

OUTPUT2:DLE STX DLESTXDLEETX DLE ETX

The destuffed data is: STXETX

2) PROGRAM SPECIFICATION:

Page 12: Cn & Case Tools

Program to implement CRC

Description:

The most powerful redundancy check is the cyclic redundancy check.

CRC is based on modulo-2 division.

In CRC, instead of adding of bits to achieve a desired a desired parity a sequence of

redundant bits, called the CRC or the CRC remainder, is appeared to the end of data

unit so that the resulting data unit becomes exactly divisible by a second,

predetermined binary number.

At its destination the incoming data unit is divided by the same number.

If at this step there is no remainder, the data unit is assumed to be intact and is

therefore accepted.

A remainder indicates that the data unit has been damaged in transit and therefore

must be rejected.

The redundancy bits used by CRC are derived by dividing the data unit by a

predetermined divisor: The remainder is the CRC.

To be valid, a CRC must have two qualities:

It must exactly one less bit than a divisor, and appending it to the end of the data

string.

It must make the resulting bit sequence exactly divisible by the divisor.

Working of CRC:

CRC generator and checker:

Process of doing CRC:

Page 13: Cn & Case Tools

Modulo-2 Division in CRC generator:

Modulo-2 Division in a CRC checker:

Page 14: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Algorithm :

Step1: Start.

Step2: Enter the binary information of a data F(x)

Step3: Enter the divisor of a binary information P(x)

Step4: Add sequence of redundant bits, to the end of data unit so that the resulting data

unit becomes exactly divisible by a second, predetermined binary number.

Step5: Divide the bit string corresponding to the data P(x) into the bit string corresponding to F(X) using Modulo 2 division

Step6: In this step there is no remainder, the data unit is assumed to be correct and is

therefore accepted.

Step7: stop.

Dadi Institute of Engineering and Technology Anakapalle 14

Page 15: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

PROGRAM:/*program for CRC calculation using binary strings*/

#include<stdio.h>#include"conio.h"void main(){int i,j,m,n,gen[15],rem[20],remr[20],temp[30],k,k1,fr[30];clrscr();printf("enter the size of m:");scanf("%d",&m);printf("enter the size of n:");scanf("%d",&n);printf("enter frame:\t");for(i=0;i<m;i++)scanf("%d",&fr[i]);for(i=m;i<m+n-1;i++)fr[i]=0;for(i=0;i<m+n-1;i++)temp[i]=fr[i];printf("enter generator:\t");for(i=0;i<n;i++)scanf("%d",&gen[i]);for(k=0;k<m;k++){if(fr[k]==1){k1=k;for(i=0,j=k;i<n;i++,j++)rem[i]=fr[j]^gen[i];for(i=0;i<n;i++){fr[k1]=rem[i];k1++;}}}printf("remainder at source is:\t");for(i=0;i<n;i++)printf("%d",rem[i]);for(i=m;i<m+n-1;i++)temp[i]=rem[i-m+1];for(k=0;k<m;k++){if(temp[k]==1){k1=k;for(i=0,j=k;i<n;i++,j++)

Dadi Institute of Engineering and Technology Anakapalle 15

Page 16: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

remr[i]=temp[j]^gen[i];for(i=0;i<n;i++){temp[k1]=remr[i];k1++;}}}printf("\n remainder at receiver side is:\t");for(i=0;i<n;i++)printf("%d",remr[i]);printf("\n frame received successfully");getch();}

OUTPUT:

enter the value of m:8enter the value of n:13enter frame: 1 0 0 0 1 0 0 1enter generator: 1 0 1 0 0 0 0 0 0 1 1 0 1remainder at source side is:0001100101101remainder at receiver side is:0000000000000frame received successfully

Dadi Institute of Engineering and Technology Anakapalle 16

Page 17: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

//Program to implement crc polynomial

#include"stdio.h"#include"conio.h"#include"string.h"#include"stdlib.h"#include"ctype.h"main(){char msg[50],gen[50],e;int a[30],b[30],c[30],t[30],i,j,m,n,l,k,p,count,temp;clrscr();/* reading the degrees of polynomial */printf("enter the higher degree of message polynomial:");scanf("%d",&n);printf("enter the higher degree of generating polynomial:");scanf("%d",&m);l=m+n;if(l<=25){/* entering the message polynomial */printf("enter the message polynomial:");flushall();gets(msg);for(i=0,j=0;i<strlen(msg);i++){if(isdigit(msg[i])){if(isdigit(msg[i+1])){e=msg[i++];temp=atoi(&e);e=msg[i];t[j++]=temp*10+atoi(&e);}else{e=msg[i];t[j++]=atoi(&e);}}}t[j]=-1;for(i=0;i<n;i++)a[i]=0;for(i=0;t[i]!=-1;i++)

Dadi Institute of Engineering and Technology Anakapalle 17

Page 18: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

{k=t[i];a[k]=1;}for(i=n;i>=0;i--)printf("%d",a[i]);/* enter the generator polynomial */printf("\n enter the generator polynomial:");flushall();gets(gen);for(i=0,j=0;i<strlen(gen);i++){if(isdigit(gen[i])){if(isdigit(gen[i+1])){e=gen[i++];temp=atoi(&e);e=gen[i];t[j++]=temp*10+atoi(&e);}else{e=gen[i];t[j++]=atoi(&e);}}}t[j]=-1;for(i=0;i<m;i++)b[i]=0;for(i=0;t[i]!=-1;i++){k=t[i];b[k]=1;}for(i=m;i>=0;i--)printf("%d",b[i]);printf("\n the encrypted message polynomial:");for(i=0;i<m;i++){c[i]=0;}for(j=0;j<=n;j++){c[i++]=a[j];}for(i=l;i>=0;i--)printf("%d",c[i]);

Dadi Institute of Engineering and Technology Anakapalle 18

Page 19: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

/* CRC process */k=l;while(k>=0){count=i=0;for(j=m;j>=0;j--){if(((b[j]==1)&&(c[k-i]==1))||((b[j]==0)&&(c[k-i]==0))){c[k-i]=0;}else{c[k-i]=1;}i++;}for(i=k;i>=0;i--){if(c[i]==0)count++;elsebreak;}k=k-count;if((k-m)<0)break;}i=m;printf("\n the checksum code (CRC) is:");for(j=m-1;j>=0;j--)printf("%d",c[j]);for(j=0;j<=n;j++)c[i++]=a[j];printf("\n the CRC code is:");for(i=l;i>=0;i--)printf("%d",c[i]);}elseprintf("you have entered invalid highest degrees");/* at receiver */k=l;while(k>=0){count=i=0;for(j=m;j>=0;j--){if(((b[j]==1)&&(c[k-i]==1))||((b[j]==0)&&(c[k-i]==0)))c[k-i]=0;

Dadi Institute of Engineering and Technology Anakapalle 19

Page 20: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

elsec[k-i]=1;i++;}for(i=k;i>=0;i--){if(c[i]==0)count++;elsebreak;}k=k-count;if((k-m)<0)break;}i=m;printf("\n the check sum result(CRC) is:");for(j=m-1;j>=0;j--)printf("%d",c[j]);for(j=m-1;j>=0;j--){if(c[j]==0){}else{printf("\n there is an error");exit(0);}}printf("\n there is no error");getch();}

output

Dadi Institute of Engineering and Technology Anakapalle 20

Page 21: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

enter the higher degree of message polynomial:8enter the higher degree of generating polynomial:12enter the message polynomail:x^8+x^7+x^5+x^2+x^0110100101enter the generator polynomial:x^12+x^10+x^3+x^2+x^01010000001101the encrypted message polynomial:110100101000000000000the check sum code (CRC) is:110000011101the CRC code is:110100101110000011101the check sum result (CRC) is:000000000000there is no error

3) PROBLEM SPECIFICATION:

Dadi Institute of Engineering and Technology Anakapalle 21

Page 22: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Program to implement Dijkastra Shortest path routing algorithm.

Description:

Each machine is known as a node.

Each node has a cost and a value.

A pointer to the node that is before it in the path being taken.

A state [permanent or tentative].

Initially each node if given a state of tentative, a pointer to null and, a cost value of

infinity.

The source node is marked as permanent and its cost value as 0 and pointer still to

null.

The source node then calculates the cost values to the nodes that it can reach and

assigns the cost values of these nodes to the values calculated, the pointer of these

nodes now points to the source node.

After this is done the tentative node with the lowest no-infinity cost value

(regardless of what it's pointer points to) is marked permanent and the whole

process is performed again with this newly marked-permanent node.

When the goal is reached, the total cost of the path is the cost value in the cost

value field in the node.

To find the route taken to achieve this shortest path simply work back from the

pointers in the nodes starting with the goal node.

ALGORITHM:

Dadi Institute of Engineering and Technology Anakapalle 22

Page 23: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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.

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.

Program:#include<stdio.h>#include<conio.h>

Dadi Institute of Engineering and Technology Anakapalle 23

Page 24: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

struct str{ int a;

char s;}sp[10];

void main(){ int ar[20][20],n,i,j,k,f=0,s,e;

char st[20];char rev[10];clrscr();printf("enter the no. of nodes:");

scanf("%d",&n);for(i=0;i<n;i++){ printf("enter %d node name:",i);

scanf("%s",&st[i]);}for(i=0;i<n;i++)

for(j=0;j<n;j++){ printf(“enter%d%delements:”,i,j);scanf("%d",&ar[i][j]);}

for(i=0;i<n;i++)sp[i].a=0;

i=0;while(i!=n){ for(j=0;j<n;j++)

{ if(ar[i][j]!=0&&(sp[j].a>ar[i][j]+sp[i].a||sp[j].a==0)){ if(sp[j].a!=0)

f=1;sp[j].a=sp[i].a+ar[i][j];sp[j].s=st[i];if(f==1 && i>j)

break;}

}if(f==1 && i>j)

i=j;else

i++;f=0;

}printf("the Shortest distance is %d",sp[n-1].a);rev[0]=st[n-1];for(i=n-1,j=1;sp[i].s!=st[0];){ rev[j]=sp[i].s;

for(k=0;k<n;k++)if(sp[i].s==st[k])

break;i=k;

Dadi Institute of Engineering and Technology Anakapalle 24

Page 25: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

j++;}printf("\n Shortest path is %c",st[0]);for(i=j-1;i>=0;i--){ printf("--> %c",rev[i]);}getch();

}

Output :enter the no. of nodes:6enter 0 node name:a

Dadi Institute of Engineering and Technology Anakapalle 25

Page 26: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

enter 1 node name:benter 2 node name:center 3 node name:denter 4 node name:eenter 5 node name:fenter the subnet edges weights0 1 0 2 0 01 0 1 0 0 00 1 0 1 1 02 0 1 0 2 00 0 1 2 0 30 0 0 0 3 0the Shortest distance is 6 Shortest path is a--> b--> c--> e--> f

Output2:Enter the no. of nodes:8Enter 0 node name:aEnter 1 node name:bEnter 2node name:cEnter 3 node name:eEnter 4 node name:fEnter 5 node name:gEnter 6 node name:hEnter 7 node name:dEnter 00 elements:0Enter 01 elements:2Enter 02 elements:0Enter 03 elements:0Enter 04 elements:0Enter 05 elements:6Enter 06 elements:0Enter 07 elements:0Enter 10 elements:2Enter 11 elements:0Enter 12 elements:7Enter 13 elements:2Enter 14 elements:0Enter 15 elements:0Enter 16 elements:0Enter 17 elements:0Enter 20 elements:0Enter 21 elements:7Enter 22 elements:0Enter 23 elements:0Enter 24 elements:3Enter 25 elements:0Enter 26 elements:0Enter 27 elements:3

Dadi Institute of Engineering and Technology Anakapalle 26

Page 27: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Enter 30 elements:0Enter 31 elements:2Enter 32 elements:0Enter 33 elements:0Enter 34 elements:2Enter 35 elements:1Enter 36 elements:0Enter 37 elements:0Enter 40 elements:0Enter 41 elements:0Enter 42 elements:3Enter 43 elements:2Enter 44 elements:0Enter 45 elements:0Enter 46 elements:2Enter 47 elements:0Enter 50 elements:6Enter 51 elements:0Enter 52 elements:0Enter 53 elements:1Enter 54 elements:0Enter 55 elements:0Enter 56 elements:4Enter 57 elements:0Enter 60 elements:0Enter 61 elements:0Enter 62 elements:0Enter 63 elements:0Enter 64 elements:2Enter 65 elements:4Enter 66 elements:0Enter 67elements:2Enter 70 elements:0Enter 71elements:0Enter 72 elements3:Enter 73 elements:0Enter 74 elements:0Enter 75 elements:0Enter 76 elements:2Enter 77 elements:0The shortest distance is 10

Shortest path is a->b->e->f->h->d

4:Problem specification:To obtain routing table art each node using Distance vector routing algorithm by taking subnet graph with weights indicating delay between nodes.

Dadi Institute of Engineering and Technology Anakapalle 27

Page 28: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Description:

The Distance Vector Routing Algorithm is also known as Bellman-ford routing

algorithm and Ford-Fulkerson algorithm.

Distance vector routing algorithm is a dynamic algorithm, it operates by having

each router maintain a table giving best known distance to each destination and

which line to use to get there.

These tables are updated by exchanging information with the neighbors. In this

algorithm each router maintains a routing table indexed by, and containing one

entry for each router in subnet.

This entry contains two parts:

The preferred outgoing line to use for that destination

An estimate of the time or distance to the destination.

The metric used might be number of hops, time delay in milliseconds, total

number of packets queued along the path.

The router is assumed to know the distance to each of its neighbors. If the metric

is hops, the distance is just one hop.

If the metric is queue length, the router simply examines each queue.

Dadi Institute of Engineering and Technology Anakapalle 28

Page 29: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Example:

Dadi Institute of Engineering and Technology Anakapalle 29

Page 30: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Algorithm :

Step1: Start.

Step2: Enter the number of nodes in subnet.

Step3: Read the source node.

Step4: Enter the number of neighbor nodes.

Step5: Enter the data into the neighboring vector tables.

Step6: Read the estimated delays to neighbors.

Step7: Calculate the route from source to all other nodes in the subnet and enter

values into vector table of source node.

Step8: Stop.

Program:

Dadi Institute of Engineering and Technology Anakapalle 30

Page 31: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

#include<stdio.h>#include<ctype.h>int graph[12][12];int e[12][12],d[12];int ad[12],temp[20];int no,id,adc,small,chosen,total;char nodes[12]={'a','b','c','d','e','f','g','h','i','j','k','l'};

int main(){int i,j;adc=0;clrscr();printf("enter the no nodes");scanf("%d",&no);printf("enter the value for adjacency matrix\n");

for(i=0;i<no;i++){

for(j=0;j<no;j++){scanf("%d",&graph[i][j]);}

}printf("\nfor which node vector table be built(1-a)(2-b)...");scanf("%d",&id);id--;adc=0;

printf("neighbours for particular node\n");for(i=0;i<no;i++){

if(graph[id][i]==1){ad[adc]=i;adc++;printf("\t%c",nodes[i]);}

}

printf("\nevter vector tables for neighbours\n");for(i=0;i<no;i++){

for(j=0;j<adc;j++){scanf("%d",&e[i][j]);}

}printf("\nenter estimated delays to neighbours\n");

for(i=0;i<adc;i++)

Dadi Institute of Engineering and Technology Anakapalle 31

Page 32: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

{scanf("%d",&d[i]);

}

for(i=0;i<no;i++){

if(id!=i) { small=100; chosen=-1;

for(j=0;j<adc;j++){

int total=e[i][j]+d[j];if(total<small){

small=total;chosen=j;

}}

e[id][i]=small; printf("\n shortest estimate to %c is %d\t%c",nodes[i],

small,nodes[ad[chosen]]); }else{ e[id][i]=0;

printf("\n shortest estimate to %c is %d\t nil",nodes[i],e[id][i]);}

}for(i=0;i<no;i++){

printf("\n"); for(j=0;j<no;j++)

printf(" %d",e[i][j]);printf("\n");

}getch();}

Output 1:enter the no nodes 7enter the value for adjacency matrix0 1 0 1 1 0 01 0 1 0 0 0 00 1 0 1 0 0 11 0 1 0 1 0 11 0 0 1 0 1 00 0 0 0 1 0 1

Dadi Institute of Engineering and Technology Anakapalle 32

Page 33: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

0 0 1 1 0 1 0for which node vector table be built(1-a)(2-b)...3neighbours for particular nodeb d gevter vector tables for neighbours12 19 110 34 2319 23 1831 0 1522 37 1916 17 928 15 0enter estimated delays to neighbours869 shortest estimate to a is 20 b shortest estimate to b is 8 b shortest estimate to c is 0 nil shortest estimate to d is 6 d shortest estimate to e is 28 g shortest estimate to f is 18 g shortest estimate to g is 9 g 12 19 11 0 0 0 0 0 34 23 0 0 0 0 20 8 0 6 28 18 9 31 0 15 0 0 0 0 22 37 19 0 0 0 0 16 17 9 0 0 0 0 28 15 0 0 0 0 0

Dadi Institute of Engineering and Technology Anakapalle 33

Page 34: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Output2:Enter the no. of nodes:12Enter the value for adjency matrix0 1 0 0 1 0 0 0 0 1 0 01 0 1 0 0 0 1 0 0 0 0 00 1 0 1 1 0 0 0 0 0 0 00 0 1 0 0 0 0 1 0 0 0 01 0 1 0 0 1 0 0 1 0 0 00 0 0 0 1 0 1 0 0 0 0 00 1 0 0 0 1 0 1 0 0 0 00 0 0 1 0 0 1 0 0 1 0 10 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 1 0 1 00 0 0 0 0 0 0 0 0 1 0 10 0 0 0 0 0 0 1 0 0 1 0For which node vector table to be built (1-a)(2-b)—10Neighbours for particular nodeA h I kEnter vector tables for neighbours0 20 24 2112 31 36 2825 19 18 3640 8 27 2414 30 7 2223 19 20 4018 6 31 3117 0 20 1921 14 0 22 9 7 11 1024 22 22 0 29 9 33 9Enter estimated delays to neighbours8 12 10 6Shortest estimate to a is 8 aShortest estimate to b is 20 aShortest estimate to c is 28 iShortest estimate to d is 20 h Shortest estimate to e is 17 iShortest estimate to f is 30 iShortest estimate to g is 18 hShortest estimate to h is 12 hShortest estimate to i is 10 iShortest estimate to j is 0 nilShortest estimate to k is 6 kShortest estimate to l is 15 k

0 20 24 21 0 0 0 0 0 0 0 0 12 31 36 28 0 0 0 0 0 0 0 025 19 18 36 0 0 0 0 0 0 0 0

Dadi Institute of Engineering and Technology Anakapalle 34

Page 35: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

40 8 27 24 0 0 0 0 0 0 0 014 30 7 22 0 0 0 0 0 0 0 023 19 20 40 0 0 0 0 0 0 0 018 6 31 31 0 0 0 0 0 0 0 017 0 20 19 0 0 0 0 0 0 0 021 14 0 22 0 0 0 0 0 0 0 08 20 28 20 17 30 18 12 10 0 6 1524 22 22 0 0 0 0 0 0 0 0 029 9 33 9 0 0 0 0 0 0 0 0 0

Dadi Institute of Engineering and Technology Anakapalle 35

Page 36: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

5) PROBLEM SPECIFICATION:Program to implement Broadcast routing algorithm.

Description:

Sending a packet to all destinations simultaneously is called broadcasting.

There are various methods for implementing broadcasting algorithm

1) Subnet

2) Flooding

3) Multicasting Routing

4) Spanning Tree

5) Reverse Path Forwarding

Subnet:

One broadcasting method is that requires no special features form the

subnet is for the source to simply send a distinct packet to each destination.

These methods need more bandwidth and in this method the source require

a complete list of all destinations.

Flooding:

It is a point to point communication, the problem with this method is it

generates too many packets and consumes too much bandwidth.

Multicasting routing:

In this method each packet contains either a list of destinations or bit map

indicating the desired destinations.

When a packet arrives at the router it checks all destinations to determine

the set of output lines that will be needed.

The router generates a new copy of the packet for each output line to be

used and includes in each packet only those destinations that are to use the

line.

Dadi Institute of Engineering and Technology Anakapalle 36

Page 37: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

In effect the destination set is partitioned among the output lines.

Span tree:

Spanning tree is a subnet of the subnet that includes all the routers but

contains no loops.

If each router knows which of its line belong to the spanning tree, it can

copy an incoming broadcast packet onto all the spanning tree lines except

the one it arrived on.

Reverse path forwarding:

When a broadcast packet arrives at a router, the router checks to see if the

packet arrived on the line that is normally used for sending packets to the

source of the broadcast.

Example:

Dadi Institute of Engineering and Technology Anakapalle 37

Page 38: Cn & Case Tools

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 root node in the subnet and say hop count as 0 and kept in visited 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.

Dadi Institute of Engineering and Technology Anakapalle 38

Page 39: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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);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++) {printf("\t%c",nname[i]);for(j=0;j<n;j++) {printf("\t%d ",link[i][j]); }printf("\n");

Dadi Institute of Engineering and Technology Anakapalle 39

Page 40: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

}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++;elseroot=0;for(i=0;i<n;i++) {if(flag[i]==0)break; }if(i==n)count=0; } getch();}

Dadi Institute of Engineering and Technology Anakapalle 40

Page 41: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

INPUT1:

Enter the number of nodes: 5Enter node 0 name: aEnter node 1 name: bEnter node 2 name: cEnter node 3 name: dEnter node 4 name: eEnter link between a and b: 1Enter link between a and c: 1Enter link between a and d: 0Enter link between a and e: 0Enter link between b and c: 1Enter link between b and d: 1Enter link between b and e: 0Enter link between c and d: 1Enter link between c and e: 0Enter link between d and e: 1Enter the source node name and number: a 0

OUTPUT1:The matrix representation for the graph is:

a b c d ea 0 1 1 0 0b 1 0 1 1 0c 1 1 0 1 0d 0 1 0 0 1e 0 0 0 1 0

At Hop count 0: aAt Hop count 1: abAt Hop count 1: acAt Hop count 2: bdAt Hop count 3: de

Dadi Institute of Engineering and Technology Anakapalle 41

Page 42: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Input2:enter the number of nodes:3enter node 0 name:aenter node 1 name:benter node 2 name:center link between a and b:1enter link between a and c:0enter link between band c:1enter source node name and number:b 0the matrix representation for the graph is

a b ca 0 1 0b 1 0 1c 0 1 0at hop count 0:bat hop count 1:b->aat hop count:b->c

Dadi Institute of Engineering and Technology Anakapalle 42

Page 43: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

6) PROBLEM SPECIFICATION:Program to implement Data Encryption Standard.

Description:

The presentation layer deals with syntax and grammatical rules for presenting data to the

application layer (not the user). This includes encoding, decoding and otherwise

converting data. It is responsible for the following.

Character sets

Compression and decompression of data

Encrypts and decrypts data

Bit order translation

Byte order translation

File structure

Encrypts and decrypts data — moving data over a network safe from prying

eyes is the job of encryption. There are many methods available for this including

DES, RSA and SSL and public/private key schemes.

Symmetric (Private Key) Cryptography

DES (Data Encryption Standard) 56-bit key

IDEA (International Data Encryption Algorithm) 128-bit key

AES (Advanced Encryption Standard)

RC4, RC5, Skipjack.

DES: Data Encryption Standard

DES is the most popular symmetric key encryption method.

It is based on research by IBM.

Standardized by the USA government in 1977.

Complex series of bit substitutions, permutation and re-combinations

Basic DES: 56-bit keys

Crackable in hours using specialized hardware

Triple DES: effective 112-bit key

Dadi Institute of Engineering and Technology Anakapalle 43

Page 44: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Three stages of encryption with two keys

o Uncrackable by known technique

Advantages: fast, cipher text secures.

Disadvantages: must distribute key in advance, key must not be divulged.

ALGORITHM:

Dadi Institute of Engineering and Technology Anakapalle 44

Page 45: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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 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:

Dadi Institute of Engineering and Technology Anakapalle 45

Page 46: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

#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;xor(char d,char d1){

if(d==d1)return('0');elsereturn('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];

}

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];

Dadi Institute of Engineering and Technology Anakapalle 46

Page 47: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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'){

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];

Dadi Institute of Engineering and Technology Anakapalle 47

Page 48: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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++){

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];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]);

Dadi Institute of Engineering and Technology Anakapalle 48

Page 49: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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';[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';

Dadi Institute of Engineering and Technology Anakapalle 49

Page 50: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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];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:");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]);

Dadi Institute of Engineering and Technology Anakapalle 50

Page 51: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

(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]);

}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);

Dadi Institute of Engineering and Technology Anakapalle 51

Page 52: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

switch(ch){

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();

}

Dadi Institute of Engineering and Technology Anakapalle 52

Page 53: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

OUTPUT 1:

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

OUTPUT 2:

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

Dadi Institute of Engineering and Technology Anakapalle 53

Page 54: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

8) PROBLEM SPECIFICATION:Using RSA algorithm Encrypt a text data and Decrypt the same.

Description:

By Rivest, Shamir & Adleman of MIT in 1977.

best known & widely used public-key scheme.

based on exponentiation in a finite (Galois) field over integers modulo a prime no.

exponentiation takes O((log n)3) operations (easy)

Uses large integers (eg. 1024 bits)

Security due to cost of factoring large numbers nb.

factorization takes O(e log n log log n) operations (hard)

RSA Key Setup:

Each user generates a public/private key pair by:

selecting two large primes at random - p, q

computing their system modulus N=p.q

Note ø(N)=(p-1)(q-1)

selecting at random the encryption key e

where 1<e<ø(N), gcd(e,ø(N))=1

Solve following equation to find decryption key d

ed=1 mod ø(N) and 0≤d≤N

Publish their public encryption key: KU={e,N}

Keep secret private decryption key: KR={d,p,q}

RSA Use:

to encrypt a message M the sender:

obtains public key of recipient KU={e,N}

computes: C=Me( mod N), where 0≤M<N

to decrypt the ciphertext C the owner:

uses their private key KR={d,p,q}

computes: M=Cd (mod N)

Note that the message M must be smaller than the modulus N (block if needed)

RSA Security:

Dadi Institute of Engineering and Technology Anakapalle 54

Page 55: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

three approaches to attacking RSA:

brute force key search (infeasible given size of numbers)

mathematical attacks (based on difficulty of computing ø(N), by factoring

modulus N)

timing attacks (on running of decryption)

Example of RSA Algorithm:

Dadi Institute of Engineering and Technology Anakapalle 55

Page 56: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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:-

Dadi Institute of Engineering and Technology Anakapalle 56

Page 57: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

/*RSA algorithm */

#include<stdio.h>#include<conio.h>int i,c,p,q,e,d,s,ch,phi,M,n;encrypt();decrypt();void main(){clrscr();printf("enter two relative primes:");scanf("%d%d",&p,&q);printf("enter the value of e:");scanf("%d",&e);n=p*q;phi=(p-1)*(q-1);d=1;do{s=(d*e)%phi;d++;}while(s!=1);d=d-1;printf("\npublic key:%d\t%d",e,n);printf("\nprivate key:%d\t%d",d,n);printf("\nenter the plain text:");scanf("%d",&M);do{printf("\nenter your choice: 1.encrypt 2.decrypt :");scanf("%d",&ch);switch(ch){case 1:encrypt(); break;case 2:decrypt(); break;default:printf("invalid choice,..");

exit(0);}}while(ch!=3);getch();}

Dadi Institute of Engineering and Technology Anakapalle 57

Page 58: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

encrypt(){int i;c=1;for(i=0;i<e;i++)c=c*M%n;c=c%n;printf("\ncipher text:%d",c);}decrypt(){M=1;for(i=0;i<d;i++)M=M*c%n;M=M%n;printf("\nplain text:%d",M);}

Output:-

Dadi Institute of Engineering and Technology Anakapalle 58

Page 59: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

enter two relative primes:17 11enter the value of e:7

public key:7 187private key:23 187enter the plain text:88

enter your choice: 1.encrypt 2.decrypt:1

ciphet text:11enter your choice: 1.encrypt 2.decrypt:2

plain text:88

enter your choice: 1.encrypt 2.decrypt:6invalid choice...

UML (Unified Modeling Language)

Dadi Institute of Engineering and Technology Anakapalle 59

Page 60: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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 user’s specific design

thoughts.

Building Blocks of UML :

Things

Relationships

Diagrams.

Things in UML :

Structural Things

Classes

Interfaces

Collaborations

Use Cases

Active Classes

Components

Nodes Classes

Behavioral Things

Interactions

State Machines

Grouping Things

Packages

Annotational Things

Notes

Diagrams in UML:

Dadi Institute of Engineering and Technology Anakapalle 60

Page 61: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Class Diagram

Object Diagram

Usecase Diagram

Sequence Diagram

Collaboration Diagram

Statechart Diagram

Activity Diagram

Component Diagram

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 externally-visible 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

Association:

Dadi Institute of Engineering and Technology Anakapalle 61

Page 62: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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.

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:

Dadi Institute of Engineering and Technology Anakapalle 62

Page 63: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Generalization is a specification relationship in which objects of the specialized element

(the child ) are 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:

----------------------------------------------

Class diagrams:

A class diagram is that which represents a set of classes, interfaces, and

collaborations and their relationships, graphically a class diagram is a collection of

vertices and arcs.

It consists of three compartments.

Uses:

Dadi Institute of Engineering and Technology Anakapalle 63

Name

Attributes

Operations

Page 64: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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.

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

Objects

Links

Messages

It includes two diagrams – Sequence and Collaboration

Sequence Diagrams:

Dadi Institute of Engineering and Technology Anakapalle 64

;Name Attributes

Operations

Page 65: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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:

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:

Dadi Institute of Engineering and Technology Anakapalle 65

Object name

Page 66: Cn & Case Tools

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 a rounded rectangle.

Symbol:

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 state

machine and is semantically equivalent to a composite 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 a state but acts as a marker.

Symbol:

Dadi Institute of Engineering and Technology Anakapalle 66

State Name

Sub State Name

Page 67: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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 occur. Symbol:

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:

Dadi Institute of Engineering and Technology Anakapalle 67

Page 68: Cn & Case Tools

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 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:

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:

Dadi Institute of Engineering and Technology Anakapalle 68

Sub Activity Name

Page 69: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Final State: 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 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. 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:

Dadi Institute of Engineering and Technology Anakapalle 69

Page 70: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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: A component represents a modular, deployable, and replaceable part of a

system that encapsulates implementation and exposes a set of interfaces.

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.

Symbol:

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:

Dadi Institute of Engineering and Technology Anakapalle 70

<<artifact>>

Page 71: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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

generally having at least a memory 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.

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.

Symbol:

Dadi Institute of Engineering and Technology Anakapalle 71

Node Name

Node Name

<<artifact>>

Page 72: Cn & Case Tools

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.

To full fill these requirements we can to design this system by making use of the

UML diagrams for better understanding the specifications.

Dadi Institute of Engineering and Technology Anakapalle 72

Page 73: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

USE CASE DIAGRAMS OF LIBRARY MANAGEMENT SYSTEM:

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.

USE CASES SPECIFICATION OF THE SYSTEM:

Dadi Institute of Engineering and Technology Anakapalle 73

System

Ask for a book

Check for availability of book

issue the bookLibrarian

Add new books

collecting fines

Update validity

Student

Access books

reads magazines, journals, news papers

<<extend>>

renewals the book

returns the book

check for authorization

<<include>>

<<include>>

<<include>>

<<include>>

Page 74: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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:

Dadi Institute of Engineering and Technology Anakapalle 74

Library

+issue_date+ret_date-fine+std_no_of_books+stf_no_of_books

+verifies()+issues()+renwals()+returns()+dispaly fine()

College

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

+st_data()+staff_data()+coll_facalities()+con_exam()+con_online()+con_events()+con_sport()+Operation8()

Student

+std_name+std_num+std_acc+std_dep

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

Staff

+Stf_name+stf_num+stf_dep+stf_acc

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

BooksData

+book_name+author_name+book_num+publishers-ISBN_num

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

depends on college data

depends on student data

Librarian+lib_name+lib_id

-collects_fine()+verifies_login()+updates()+maintanence()-access_lib_data()+creates_acc()+deletes_acc()

+checks for availability

+maintained by librarian

1..*

1

Page 75: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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 both have the same priority and some dependence relationships between the classes as shown.

SEQUENCE DIAGRAM OF LIBRARY MANAGEMENT SYSTEM:

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 him. When student asks for the

Dadi Institute of Engineering and Technology Anakapalle 75

S : student1 L : librariand : databaseLi : library

1 : logsin()

2 : checks for authorization()

3 : creates object()

<<create>>

4 : ask for book() 5 : verifies()

6 : checks for availability()

7 : justifies8 : display fine()

9 : asks for fine()

10 : pays11 : updates()

12 : issue the book()13 : updates()

14 : logsout()

15 : releases()

<<destroy>> 16 : switches off()<<destroy>>

17 : logsoff out the library()

<<destroy>>

Page 76: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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:

STUDENT Librarian

Asking for bookCheck for book

Available Not available

Issues

Verification

Student details Book details

valid In valid

Fine verification

Collecting fine

Yes

Issue the book

Collect book

No

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.

Dadi Institute of Engineering and Technology Anakapalle 76

Page 77: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

The library checks for the availability of the book. If the bookIs 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 OF LIBRARY MANAGEMENT SYSTEM:

verification

pay fine

collecting book

logout

exit

ideal stateentry state

loginlogin

ask for book

authenticates

enters student id

Dadi Institute of Engineering and Technology Anakapalle 77

Page 78: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

COMPONENT DIAGRAM OF LIBRARY MANAGEMENT SYSTEM:

issue.exe

issue of book

update.exe<<artifact>>

return.exe

return of book

DEPLOYMENT DIAGRAM OF LIBRARY MANAGEMENT SYSTEM:

Clients

Librarian

Student

Database server

Database Server

Case Study 2

Dadi Institute of Engineering and Technology Anakapalle 78

Page 79: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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 Role Use casePassenger 1.Enquiry

2.Reservation and ticketing3.Cancellation

1. Enquire ticket availability and other details.

2. Reserve seats and berths etc.3.Cancel tickets

Counter clerk 1.Form data entry2.Ticket processing3.Updation

1.Enter the details into system2.Trigger ticket for printing3.Update data in the system

Reservation system Server 1. Process reservation data, process ticketing and process cancellation.2.Update.

Use case diagrams

System

Passenger CounterClerk

Enquiries for availability

Availability status

Passenger enquiries for the availability of Seats

Dadi Institute of Engineering and Technology Anakapalle 79

Page 80: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Reservation and ticketing

System

Passenger

Counter Clerk

Fill Cancellation form

Enter data into system

Collect issued ticket

Cancels ticket

Return money after deduction

Cancellation of issued ticket

Dadi Institute of Engineering and Technology Anakapalle 80

PassengerCounter Clerk

Fill requisition form

Enter data into system

Print ticket

Collect fare amount & Issues ticket

Page 81: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Class diagram

Passenger

+Name+Gender+Age+Address

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

Reservation System

+processForm()+reservation()+fareComputation()+processTicket()+printTicket()

Clerk

+Name+Gender+Age

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

1

1

1..*0..*

Payment

CreditPayment CashPayment

1..*

1

Class diagram for railway reservation system

Dadi Institute of Engineering and Technology Anakapalle 81

Page 82: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Interaction diagramsSequence diagram

: 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()

Dadi Institute of Engineering and Technology Anakapalle 82

Page 83: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Collaboration diagram

: 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()

Collaboration diagram for reservationActivity diagrams

[The Data train and tickets]

Data Entered into R&T System

R&T Checks Availabillity

Available

Fills Requisition From

R&T Process the Form

Prints Tickets

Tickets Issued and Fare Amount Collected

Not Available Puts New Data and Train

Dadi Institute of Engineering and Technology Anakapalle 83

Page 84: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Activity diagram for Enquiry of seats available

Passenger Clerk Reservation system

[Fill form details]

Passenger Comes to the Counter

[Clerk Enters Details into system]

[Submits form to clerk][Verify Availabilities]

Ok[Form modified]Not ok

[Informs the fare amount]

Ok

Not ok

Not

[Trigger Tickets Printing Process]

[prints the Tickets]

[Issue Tickets]

[Collect Amount]

[Trigger Update Process]

Confirms with the Passenger

Ok

Activity diagram for reservation process

Component diagram

reservation.exe

Reservation form

update.exe<<artifact>>

cancellation.exe

Cancellation form

Component diagram for reservation and ticketing

Dadi Institute of Engineering and Technology Anakapalle 84

Page 85: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Deployment diagram

Clients

Clerk

Kiosk

Reservation server

Reservation Server

Deployment diagram for Railway reservation system

Dadi Institute of Engineering and Technology Anakapalle 85

Page 86: Cn & Case Tools

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 a

computerized telecommunications device that provides the clients of a financial institution

with access to financial transactions in a 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 ATM’s we can make payment

transaction at anytime from anywhere.

Dadi Institute of Engineering and Technology Anakapalle 86

Page 87: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

USE CASE DIAGRAMS:

System

Bank client ATM machine

deposite withdrawal

transcation

balance enquiry valid client

<<include>>

invalid client

<<extend>>

Bank

verification

managedatabaseinvalid PIN

<<extend>>

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.

USE CASES SPECIFICATION OF TRANSACTION:

Dadi Institute of Engineering and Technology Anakapalle 87

Page 88: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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:

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:

Dadi Institute of Engineering and Technology Anakapalle 88

Bank client

-pin card number

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

ATM machine

+atm_mach no.

+providing_receipt()+display_message()+status()+read_card()+accept_card()+view_balance()

+notify_successful receipt()

Bank database

+card reader_ information

+updating_dbbase()

Thirdparity

-pin number

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

1 1..*request for

manages

Bank

+account_number-pin_balance

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

1

1

asks for

11

Page 89: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

(Overall ATM transaction)

: 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 OF ATM TRANSACTION:(Start-up of ATM transaction)

Dadi Institute of Engineering and Technology Anakapalle 89

Page 90: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

ACTIVITY DIAGRAM OF ATM TRANSACTION:

Bankclient ATM machine Bank

Insert atmcard

enter pin number read PIN[submite] verify PIN

[verification report]

Request amount

[valid]

Enter amount

dispense cash update customer account

close transcation

[invalid]

give recipt

STATE CHART DIAGRAMS OF ATM TRANSACTION:

Dadi Institute of Engineering and Technology Anakapalle 90

Page 91: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

ideal

Active

validate

selecting processing

printreciept

validate

selecting processing

printreciept

Insert card

[continue]

withdraw/enquiery

[not continue]

exit/ejectcard

maintainance

maintain

entry/readcard

cancel

COMPONENT DIAGRAM OF ATM TRANSACTION:

ATM.exe

it containsATM.java files

it containsATM.obj files

transaction

+pin number

+withdraw()+enquiery()

ATMdatabase.db

.tblit containsdatabse tables

it contain ATM.dll files

DEPLOYMENT DIAGRAM OF ATM TRANSACTION:

Dadi Institute of Engineering and Technology Anakapalle 91

Page 92: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

ATM machine server

ATM.exe Bank

Ethernet

RS-232

RAID farm

Case Study 4

ONLINE BOOKS SHOP

Dadi Institute of Engineering and Technology Anakapalle 92

Page 93: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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 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.

Physical Data Flow Diagrams:-

Dadi Institute of Engineering and Technology Anakapalle 93

Page 94: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Context Level Diagram:-

Use case diagram:

System

Login

create cart

order placing

Validation

payment

Shipment

customer

individual lecturer

authentication

request

checking

pay

Receive

bookshop staff

sent

accept

certificate

verify

validate customer<<include>>

bank

gifts

<<extend>>

Scenario for Use case Diagram:-

Dadi Institute of Engineering and Technology Anakapalle 94

Book Shop

Customer Dealer

Search

Order

Ordered Books

Book Details

Orders sDetails

Add Books

Page 95: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

1.Usecase Name ONLINE BOOK SHOP

2. Participating Actor Instances1. Customer2. Dealer

3.Entry Conditions

1. Every customer should have a unique id.

2. Dealer should have a login-id and password.

4. Flow of Events

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.

5. Special requirements1. The customer can get the quick

response from the server.

Actors: Customer, Book shop staff, bank.Main flow of events: Create cart, order placing, validations.Exception flow of events: Gifts to customer, canceling orders

Class Diagrams:

Dadi Institute of Engineering and Technology Anakapalle 95

Page 96: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

cart

-total money

+place order()+cancle order()

credit card

-card number-date of expire

+check authorized charge()

customer

-customer-billing address-delivery address-email-rating

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

items to buy

-unit price

+add()-remove()

database

-user name-book name

+store()+update()+delete()

frequent shopper

-discount rate-approval date

+approval()+disapprove()

Warehouse

-name

+update()+delete()

10..*

1

1..*

1..*

1

1

0..*

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:

Dadi Institute of Engineering and Technology Anakapalle 96

Page 97: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

c : customer website card cart staff

1 : login()

2 : authentication()

3 : search for book

4 : showed 5 : add()

6 : viewed

7 : order()

8 : setrequest()9 : details

10 : update

11 : payment()

12 : authorozation

13 : acknowledgement

14

15 : shipment

Colloboration Diagram:

Dadi Institute of Engineering and Technology Anakapalle 97

Page 98: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

c : customer

w : database

card : credit card

c : cart

staff : Warehouse

1 : login()

5 : place order()

2 : authentication()

6 : viewed()

10 : acknowledgement()

12 : shipment()

11 : validate order()

8 : Updation()

3 : search for books()

4 : add or remove books()

9 : payment()

7 : details()

ACTIVITY DIAGRAM:

Dadi Institute of Engineering and Technology Anakapalle 98

Page 99: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

customer

database

cart

cardread

staff

login

verify

authentication

add books

view cart

[c:cart]

payment

staff

upadation

[w:data base]

receive book

STATE CHART DIAGRAM:

Dadi Institute of Engineering and Technology Anakapalle 99

Page 100: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

ideal

show order

add books to cart place order

login

show cart

check to add

payment

shipment

COMPONENT DIAGRAM:

Dadi Institute of Engineering and Technology Anakapalle 100

Page 101: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

online shopping

login.html<<artifact>>

user/ customer

items

users

permissions

authentication

DEPLOYMENT DIAGRAM:

s

TESTING

Dadi Institute of Engineering and Technology Anakapalle 101

Page 102: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Test cases for customer registration:-

Test Case Condition Being Checked Expected Output1. If password is

not matched with confirm password.

Password = confirm password.

Mismatched password.

2. Password is empty.

Password length >6.Password should have at least 6 characters.

3. Customer id contains spaces.

Customer id should be alpha numeric.

Blank spaces are not allowed.

4. Phone number Is Numeric.Phone number should be numeric.

Test Cases for Customer Verification:-

Test Case Condition Being Checked Expected Output1. Password Password length>6. Invalid password.

2. Login Should not be empty. Invalid login name.

Test Cases for searching books:-

Test Case Condition Being Checked Expected Output1. At least one of

the fields should be filled.

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

At least one of the fields must be filled.

Test Cases for ordering books:-

Dadi Institute of Engineering and Technology Anakapalle 102

Page 103: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Test Case Condition Being Checked Expected Output

1. Quantity quantity<=0Quantity should be at least one to place the order.

2. Credit card no.should be numeric Should be numeric only.

3. Credit card no. length!= 14 invalid credit card no.

Test Cases for Shipment Details:-

Test Case Condition Being Checked Expected Output

1. Address address=nulladdress is required to deliver the order.

Case Study 5:

PROBLEM SPECIFICATION: Case study of college administration:

Dadi Institute of Engineering and Technology Anakapalle 103

Page 104: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

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.

uSE CASE DIAGRAMS OF COLLEGE ADMINISTRATION:

System

Student

college administration

asks the certificates

Submits certificates

verifies the certificates

invalid certificates

<<extend>>

Enquires about courses

offers the courses

selects the course

gives the fees details

pays the fee

Issues ID card

rank card

<<include>>

managerclerk

ACTORS:1. Student: The student is the primary actor who requests for seat2. College administration: The college administrator is the primary actor who

verifies the certificates and grants the seat

Dadi Institute of Engineering and Technology Anakapalle 104

Page 105: Cn & Case Tools

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 seatI) 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.

CLASS DIAGRAMS OF COLLEGE ADMINISTRATION:

Dadi Institute of Engineering and Technology Anakapalle 105

Page 106: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

college

+college name+address+phone

+maintain database()

department

+department t+dept name

+time table()+add d()+staff()

library

+text books+book name+author name

+issues()+renewal()+fine()

student

+sname+sno+class

+status()+admission()

course

+course name+tcourse

+add course()

faculty

+tstaff+faculty name

+teach()+salary()

labaratory

+tlabs+lab name

+remarks()

* 1..* 1..* 1..*

+has1 1..*

member

1..*

*

1..*

1..*

assigned to

1..*

*+chairperson

0..1

0..1

attends

**teaches

* 1..*

*

1..*

1

1..*

attends*

*

I) PERSISTENCE CLASSES:College, department, laboratory are the persistence classes.

II) NON-PERSISTENCE CLASSES:Library, student, course, faculty, are the non-persistence classes.

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

Dadi Institute of Engineering and Technology Anakapalle 106

Page 107: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

s : student a : admission cell 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>>

COLLOBARATION DIAGRAM OF COLLEGE ADMINISTRATION:(Recruitment of the faculty)

Dadi Institute of Engineering and Technology Anakapalle 107

Page 108: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

p : participant

i : interviewer

c : college database

1 : asks the certificates()

2 : submits the certificates()

3 : expose some questions()4 : answering the questions()

5 : decides()

6 : sends an appointment letter()7 : enters the details()

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

Dadi Institute of Engineering and Technology Anakapalle 108

Page 109: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

student system server

enters the IP address

opens the login page

accepts

enters the user name and password

requests

verifies student details

invalid

displays question paper

valid

answers the paper

displays marks

submits

STATE CHART DIAGRAMS OF COLLEGE ADMINISTRATION:(A STUDENT ISSUING A BOOK IN A LIBRARY)

Dadi Institute of Engineering and Technology Anakapalle 109

Page 110: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

Idle

Student requirement Check finebook available

fine exists

book not available

issue book

stores information to database

fine doesn't exist

COMPONENT DIAGRAM OF COLLEGE ADMINISTRATION:

Dadi Institute of Engineering and Technology Anakapalle 110

Page 111: Cn & Case Tools

Department of I.T. CN & Case Tools Lab Manual

student.db college.db

.tlbcontains the tables of student

.tlbcontains the tables of college

.execontains execute files

.dllcontains the library files

admission

DEPLOYMENT DIAGRAM OF COLLEGE ADMINISTRATION:

student server

console

RS-232

ETHERNET

RAID

Dadi Institute of Engineering and Technology Anakapalle 111