![](/uploads/1/2/6/4/126465206/424194058.jpg)
Computer Networks Programs::
Software Testing Laboratory-15ISL67 VI Sem.ISE Dept.,of ISE,CIT,Gubbi 3 1. Design and develop a program in a language of your choice to solve the. Notes Credits to Prof Kavya T C & Mohana Priya under the guidance of Prof Manjunath K V (CITech, Blr) Last updated: 18/05/18.
7. Crc.c - CRC-CCITT
![Vtu 6th sem software testing lab programs online Vtu 6th sem software testing lab programs online](/uploads/1/2/6/4/126465206/829098804.jpg)
#include<string.h>
#define N strlen(g)
char t[128], cs[128], g[]='10001000000100001';
int a, e, c;
void xor()
{
for(c=1;c<N;c++) cs[c]=((cs[c]g[c])?'0':'1');
}
void crc()
{
for(e=0;e<N;e++) cs[e]=t[e];
do
{
if(cs[0]'1') xor();
for(c=0;c<N-1;c++) cs[c]=cs[c+1];
cs[c]=t[e++];
}
while(e<=a+N-1);
}
void main()
{
printf('nEnter poly : '); scanf('%s',t);
printf('nGenerating Polynomial is : %s',g);
a=strlen(t);
for(e=a;e<a+N-1;e++) t[e]='0';
printf('nModified t[u] is : %s',t);
crc();
printf('nChecksum is : %s',cs);
for(e=a;e<a+N-1;e++) t[e]=cs[e-a];
printf('nFinal Codeword is : %s',t);
printf('nTest Error detection 0(yes) 1(no) ? : ');
scanf('%d',&e);
if(e0)
{
printf('Enter position where error is to inserted : ');
scanf('%d',&e);
t[e]=(t[e]'0')?'1':'0';
printf('Errorneous data : %sn',t);
}
crc();
for (e=0;(e<N-1)&&(cs[e]!='1');e++);
if(e<N-1) printf('Error detected.');
else printf('No Error Detected.');
}
----------------------------------------------------------------------------------------------------------
8. Distvect.c - Distance Vector Algorithm
#include <stdio.h>
const int MAX = 20, INFINITY = 999;
void find (int x,int y ,int path[MAX][MAX])
{
printf('%d =>',x);
if(y!=path[x][y])
find(path[x][y],y,path);
}
int main() {
int i, j, k,x,y;
int d[MAX][MAX],path[MAX][MAX],n;
printf('Enter the num of nodes (1 - 20): n');
scanf('%d', &n);
printf('Enter the distance matrix (999 if no link): n');
for(i = 0; i < n; i++) {
for(j = 0; j < n; j++) {
scanf('%d', &d[i][j]);
if(d[i][j] INFINITY) path[i][j] = -1;
else path[i][j] = j;
}
}
for(k = 0; k < n; k++) {
for(i = 0; i < n; i++) {
for(j = 0; j < n; j++) {
if(d[i][j] > d[i][k] + d[k][j]) {
path[i][j] = k;
d[i][j] = d[i][k] + d[k][j];
}
}
}
}
for(i = 0; i < n; i++) {
printf('nRouting table for node %d n', i);
printf('Dest Next hop Distance n');
for(j = 0; j < n; j++) {
printf('%3d %3d %3dn', j, path[i][j], d[i][j]);
}
}
while(1)
{
printf('enter 0 TO EXIT n');
scanf('%d',&x);
if(!x)
break;
printf('Enter te 2 nodes n');
scanf('%d%d',&x,&y);
find(x,y,path);
printf('%dn',y);
printf('The distance between 2 nodes is %D ',d[x][y]);
}
return 0;
}
const int MAX = 20, INFINITY = 999;
void find (int x,int y ,int path[MAX][MAX])
{
printf('%d =>',x);
if(y!=path[x][y])
find(path[x][y],y,path);
}
int main() {
int i, j, k,x,y;
int d[MAX][MAX],path[MAX][MAX],n;
printf('Enter the num of nodes (1 - 20): n');
scanf('%d', &n);
printf('Enter the distance matrix (999 if no link): n');
for(i = 0; i < n; i++) {
for(j = 0; j < n; j++) {
scanf('%d', &d[i][j]);
if(d[i][j] INFINITY) path[i][j] = -1;
else path[i][j] = j;
}
}
for(k = 0; k < n; k++) {
for(i = 0; i < n; i++) {
for(j = 0; j < n; j++) {
if(d[i][j] > d[i][k] + d[k][j]) {
path[i][j] = k;
d[i][j] = d[i][k] + d[k][j];
}
}
}
}
for(i = 0; i < n; i++) {
printf('nRouting table for node %d n', i);
printf('Dest Next hop Distance n');
for(j = 0; j < n; j++) {
printf('%3d %3d %3dn', j, path[i][j], d[i][j]);
}
}
while(1)
{
printf('enter 0 TO EXIT n');
scanf('%d',&x);
if(!x)
break;
printf('Enter te 2 nodes n');
scanf('%d%d',&x,&y);
find(x,y,path);
printf('%dn',y);
printf('The distance between 2 nodes is %D ',d[x][y]);
}
return 0;
}
----------------------------------------------------------------------------------------------------------
#include<stdio.h>
int z,m,n,e,d,c,flag;
void check()
{
int i;
for(i=3;e%i0 && z%i0;i++)
{
flag = 1;
}
flag = 0;
}
void encrypt()
{
int i;
c = 1;
for(i=0;i< e;i++)
c=c*m%n;
c=c%n;
printf('ntEncrypted keyword : %d',c);
}
void decrypt()
{
int i;
m = 1;
for(i=0;i< d;i++)
m=m*c%n;
m=m%n;
printf('ntDecrypted keyword : %d',m);
}
void main()
{
int p,q,s;
printf('Enter Two Relatively Prime Numberst: ');
scanf('%d%d',&p,&q);
n = p*q;
z=(p-1)*(q-1);
printf('n z value= %d',z);
printf('nnEnter e: ',n);
scanf('%d',&e);
check();
while(flag1);
d = 1;
do
{
s = (d*e)%z;
d++;
}
while(s!=1);
d = d-1;
printf('ntPublic Keyt: {%d,%d}',e,n);
printf('ntPrivate Keyt: {%d,%d}',d,n);
printf('nnEnter The Plain Textt: ');
scanf('%d',&m);
encrypt();
printf('nnEnter the Cipher textt: ');
scanf('%d',&c);
decrypt();
}
int z,m,n,e,d,c,flag;
void check()
{
int i;
for(i=3;e%i0 && z%i0;i++)
{
flag = 1;
}
flag = 0;
}
void encrypt()
{
int i;
c = 1;
for(i=0;i< e;i++)
c=c*m%n;
c=c%n;
printf('ntEncrypted keyword : %d',c);
}
void decrypt()
{
int i;
m = 1;
for(i=0;i< d;i++)
m=m*c%n;
m=m%n;
printf('ntDecrypted keyword : %d',m);
}
void main()
{
int p,q,s;
printf('Enter Two Relatively Prime Numberst: ');
scanf('%d%d',&p,&q);
n = p*q;
z=(p-1)*(q-1);
printf('n z value= %d',z);
printf('nnEnter e: ',n);
scanf('%d',&e);
check();
while(flag1);
d = 1;
do
{
s = (d*e)%z;
d++;
}
while(s!=1);
d = d-1;
printf('ntPublic Keyt: {%d,%d}',e,n);
printf('ntPrivate Keyt: {%d,%d}',d,n);
printf('nnEnter The Plain Textt: ');
scanf('%d',&m);
encrypt();
printf('nnEnter the Cipher textt: ');
scanf('%d',&c);
decrypt();
}
------------------------------------------------------------------------------------------------------------
#include<stdio.h>
#define bucketsize 500
void bktinput(int a,int b)
{
if(a>bucketsize)
printf('nbucket overflown');
else
{
while(a>b)
{
printf('n%d bytes outputted',b);
a=a-b;
}
if(a>0)
printf('n last %d bytes sent',a);
printf('n bucket output successfuln');
}
}
int main()
{
int op,pktsize;
printf('enter out rate:n');
scanf('%d',&op);
printf('enter the packet size n');
scanf('%d',&pktsize);
bktinput(pktsize,op);
}
#define bucketsize 500
void bktinput(int a,int b)
{
if(a>bucketsize)
printf('nbucket overflown');
else
{
while(a>b)
{
printf('n%d bytes outputted',b);
a=a-b;
}
if(a>0)
printf('n last %d bytes sent',a);
printf('n bucket output successfuln');
}
}
int main()
{
int op,pktsize;
printf('enter out rate:n');
scanf('%d',&op);
printf('enter the packet size n');
scanf('%d',&pktsize);
bktinput(pktsize,op);
}
In this page, you can see and download 6TH SEM Computer Science engineering CBCS scheme VTU notes in pdf. You can also get other study materials about CBCS SCHEME 6TH SEM Computer Science engineering such as model and previous years Computer Science Eng. Question papers of 6TH SEM CBCS SCHEME, question bank, etc. System Software and Compiler Design, Operating Systems, Cryptography, Network Security, and Cyber Law, Computer Graphics, and Visualization, Professional Elective 6th SEM.Below You Can Get These Notes Module WiseSUBJECT NAME: CRYPTOGRAPHY, NETWORK SECURITY, AND CYBERLAW Module – I: Module – II: Module – III: Module – IV: Module – V:SUBJECT NAME: COMPUTER GRAPHICS AND VISUALIZATION Module – I: Module – II: Module – III: Module – IV: Module – V:SUBJECT NAME: SYSTEM SOFTWARE AND COMPILER DESIGN.
![](/uploads/1/2/6/4/126465206/424194058.jpg)