10
! "# $% &% % ’ !"# $%% &’ ( )*+ + ,!"#-+ ,!"#-+ ,!"#-+ .%+ &/ &%0 1 $0 2’3/’+ &/4/)’+ .+ *.+ 5&6.73%7’ ( &..7%7’ ( *.+ *88+ 88+ 9 ( 5&..7$7 11 6.:’ ( 88+ *.+ *88+ 88+ 9 &..:’ ( *.7%7+ *88+ 9 .%+ 9 9 *.73%7+ &/3 /’+ &/34/)’+ .+ *.+

CCN Lab Manual TE VTU

Embed Size (px)

DESCRIPTION

ccn lab manual for 7th semester TE VTU

Citation preview

Page 1: CCN Lab Manual TE VTU

�������������� ������� �������

��������������������� ��������� �����������!����"�� # �������$����%���&��%����� ��%��'�

������������������������������������������������������ �������������������������������� ��������� ������������� ���������������

���������������������������������������������� ��������������� ��������������������� !"#�$%%��

������&'�(�� �������)�*+�� ���������+�� ������,��� !"#-+�� ������� ��,��� !"#-+�

� ��������� ��,��� !"#-+�� �� ����� ��.%+�� �� �����&/������������ ������������������&%0��1�$0�����2'�3�/'+�� �����&/4�/)�'+�

� �� �.�+�� *.�� ��+�� �� 5���&��6.73%7'�� (�

� � �&��..7%7'�� � (�� � � �*.��+�� � � *88+�� � � �88+�

� � 9�� � ������ � (�� � � 5���&��..7$7�11��� ��6.:'�� � � (�� � � � �� ��88+�

� � � � �*.��+�� � � � *88+�� � � � �88+�� � � 9�� � � �� � � �&�� ��..:'�

� � � (�� � � � �*.7%7+�� � � � *88+�� � � 9�� � � �� ��.%+�� � 9�

� 9�� �*.73%7+�� �����&/3������� ����������������������/'+�� �����&/3�4�/)�� ��'+�� �� �.�� ��+�

� *.���� ��+�� �����

Page 2: CCN Lab Manual TE VTU

�������������� ������� �������

��������������������� ��������� �����������!����"�� # �������$����%���&��%����� ��%��(�

� 5���&��6.73%7'�� (�� � �&��..7%7'�

� � (�� � � �*.��+�� � � *88+�� � � �88+�� � 9�� � �����

� � (�� � � 5���&��..7$7�11��� ��6.:'�� � � (�� � � � �� ��88+�� � � � �*.��+�� � � � *88+�

� � � � �88+�� � � 9�� � � �&�� ��..:'�� � � (�� � � � �88+�� � � 9�

� � � �� ��.%+�� � 9�� 9�� �*.73%7+�� �����&/3��������� ����������������������/'+�� �����&/3�4�3�/)���� ��'+�

� ��� ���%+�9��

������������ ������������������&%0��1�$0�����2'��$�%�$�%�$�$�$�$�$�$�

������ �����������������������$�%�$�%�$�$�$�$�$�%�$�

�������� �����������������������

$�%�$�%�$�$�$�$�$�$�

Page 3: CCN Lab Manual TE VTU

�������������� ������� �������

��������������������� ��������� �����������!����"�� # �������$����%���&��%����� ��%��)�

�������������������������������������������������������������� ����������������������������������������� ���������� �������������&���5��;��������;���2������<�2'�

����������������������������������������������� ��������������� ��������������������� !"#�$%%�

������&'�(�� ������,��� !"#-)�� ��,��� !"#-)���� ��,��� !"#-+�� �������)�*+�� ���+�� �

� �����&/��������������������������������� ����3�/'+�� �����&/4�/)�'+�� �.�+�� *.�� ��+�� 5���&��6.73%7'�� (�

� � �&��..7�7'�� � (�� � � �*.��+�� � � �88+�� � � *88+�� � � �&��..7�7'�

� � � (�� � � � �*.��+�� � � � �88+�� � � � *88+�� � � � �&��..7�7'�

� � � � (�� � � � � �*.��+�� � � � � �88+�� � � � � *88+�� � � � � �&*88'.7�7+�� � � � � �&*88'.7�7+�

� � � � � �&*88'.7�7+�� � � � 9�� � � 9�� � 9�� � ������ � (�

� � � �*.��+�� � � *88+�� � � �88+�� � 9�� 9�� �

� �*.73%7+�� �����&/3������� ������������/'+�� �����&/3�4�/)�� ��'+�� ��� �.�� ��+�

� *.���� ��+�� �����

Page 4: CCN Lab Manual TE VTU

�������������� ������� �������

��������������������� ��������� �����������!����"�� # �������$����%���&��%����� ��%��*�

� 5���&��6.73%7'�� (�� � �&��..7�7'�

� � (�� � � �*.��+�� � � �88+�� � � *88+�� � � �&��..7�7'�� � � (�

� � � � �*.��+�� � � � �88+�� � � � *88+�� � � � �&��..7�7'�� � � � (�� � � � � �*.��+�

� � � � � �88+�� � � � � *88+�� �� � � � � ���&.$+�.=+88'�� � � � � �88+���

� � � � 9�� � � 9�� � 9�� � ������ � (�� � � �*.��+�

� � � *88+�� � � �88+�� � 9�� 9�� �*.73%7+�

� �����&/3��������� ������������/'+�� �����&/3�4�3�/)���� ��'+�� ��� ���%+�9��

Page 5: CCN Lab Manual TE VTU

�������������� ������� �������

��������������������� ��������� �����������!����"�� # �������$����%���&��%����� ��%��+�

��������������������������������������������������#���2�������������2�������������������������������������������������������

#include <stdio.h>

#include <string.h>

void encrypt(char str[],int key)

{

unsigned int i;

for(i=0;i<strlen(str);++i)

{

str[i] = str[i] - key;

}

}

void decrypt(char str[],int key)

{

unsigned int i;

for(i=0;i<strlen(str);++i)

{

str[i] = str[i] + key;

}

}

int main()

{

char str[] = "smurffANDkdo";

printf("Passwrod = %s\n",str);

encrypt(str,0xFACA);

printf("Encrypted value = %s\n",str);

decrypt(str,0xFACA);

printf("Decrypted value = %s\n",str);

return 0;

}

Page 6: CCN Lab Manual TE VTU

�������������� ������� �������

��������������������� ��������� �����������!����"�� # �������$����%���&��%����� ��%��,�

������������������������������������������������������������������������������������������������������������������

#include<stdio.h>

#include<conio.h>

void main()

{

int path[5][5],i,j,min,a[5][5],p,st=1,ed=5,stp,edp,t[5],index;

clrscr();

printf("enter the cost matrix\n");

for(i=1;i<=5;i++)

for(j=1;j<=5;j++)

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

printf("enter number of paths\n");

scanf("%d",&p);

printf("enter possible paths\n");

for(i=1;i<=p;i++)

for(j=1;j<=5;j++)

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

for(i=1;i<=p;i++)

{

t[i]=0;

stp=st;

for(j=1;j<=5;j++)

{

edp=path[i][j+1];

t[i]=t[i]+a[stp][edp];

if(edp==ed)

break;

else

stp=edp;

}

}

min=t[st];

index=st;

for(i=1;i<=p;i++)

{

if(min>t[i])

{

min=t[i];

index=i;

}

}

printf("minimum cost %d",min);

Page 7: CCN Lab Manual TE VTU

�������������� ������� �������

��������������������� ��������� �����������!����"�� # �������$����%���&��%����� ��%����

printf("\n minimum cost path ");

for(i=1;i<=5;i++)

{

printf("--> %d",path[index][i]);

if(path[index][i]==ed)

break;

}

getch();

}

/*OUTPUT:

enter the cost matrix :

0 1 4 2 0

0 0 0 2 3

0 0 0 3 0

0 0 0 0 5

0 0 0 0 0

enter number of paths : 4

enter possible paths :

1 2 4 5 0

1 2 5 0 0

1 4 5 0 0

1 3 4 5 0

minimum cost : 4

minimum cost path :

1–>2–>5*/

Page 8: CCN Lab Manual TE VTU

�������������� ������� �������

��������������������� ��������� �����������!����"�� # �������$����%���&��%����� ��%��-�

���������������������������������������������������������� �����������������������������������������������������������������

#include<iostream.h>

#define MAX 10

class prims

{

private : int cost[MAX][MAX], tree[MAX][MAX];

int n;

public : void readmatrix();

int spanningtree(int);

void display(int);

};

void prims :: readmatrix()

{

int i, j;

cout << "\nEnter the number of vertices in the Graph : ";

cin >> n;

cout << "\nEnter the Cost matrix of the Graph\n\n";

for (i = 1; i <= n; i++)

for (j = 1; j <= n; j++)

cin >> cost[i][j];

}

int prims :: spanningtree(int src)

{

int visited[MAX], d[MAX], parent[MAX];

int i, j, k, min, u, v, stcost;

for (i = 1; i <= n; i++)

{

d[i] = cost[src][i];

visited[i] = 0;

parent[i] = src;

}

visited[src] = 1;

stcost = 0;

k = 1;

for (i = 1; i < n; i++)

{

min = 999;

for (j = 1; j <= n; j++)

{

if (!visited[j] && d[j] < min)

{

min = d[j];

u = j;

}

}

visited[u] = 1;

stcost = stcost + d[u];

tree[k][1] = parent[u];

tree[k++][2] = u;

Page 9: CCN Lab Manual TE VTU

�������������� ������� �������

��������������������� ��������� �����������!����"�� # �������$����%���&��%����� ��%��.�

for (v = 1; v <= n; v++)

if (!visited[v] && (cost[u][v] < d[v]))

{

d[v] = cost[u][v];

parent[v] = u;

}

}

return (stcost);

}

void prims :: display(int cost)

{

int i;

cout << "\nThe Edges of the Mininum Spanning Tree are\n\n";

for (i = 1; i < n; i++)

cout << tree[i][1] << " " << tree[i][2] << endl;

cout << "\nThe Total cost of the Minimum Spanning Tree is : " << cost;

}

int main()

{

int source, treecost;

prims pri;

pri.readmatrix();

cout << "\nEnter the Source : ";

cin >> source;

treecost = pri.spanningtree(source);

pri.display(treecost);

return 0;

}

Page 10: CCN Lab Manual TE VTU

�������������� ������� �������

��������������������� ��������� �����������!����"�� # �������$����%���&��%����� ��%��'/�

��������������������������������������������������>?>@>>!AA������������������������������������������

#include <stdio.h>

int crc_1021(int data)

{

int crc;

int x;

x = ((crc >> 8) ^ data) & 0xff;

x ^= x>>4;

crc = (crc << 8) ^ (x << 12) ^ (x <<5) ^ x;

crc &= 0xffff;

return(crc);

}

int main()

{

int crc;

printf("The CRC16-X25_ccitt of %d is %d. \n", crc, crc_1021(crc));

return 0;

}