Data Communications and Networking Lab File
Data Communications and Networking Lab File
And Networking
LAB FILE
AMITY UNIVERSITY
NOIDA (U.P.)
2008 – 2012
CLASS/SEC: 5IT2 Y
Index
Sno Experiment Date Sign
1. To Establish a Straight Through Configuration For
LAN
2. To Establish a Cross Over Configuration For LAN
EXPERIMENT NO.-1
AIM : Write a C++ program to perform bit stuffing and de-stuffing.
CODE:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a[20],i=0,k=0,count=0; //count is a variable to count the number of 1's.
cout<<"Enter the elements of the array(in 1's and 0's form)";
for(i=0;i<10;i++)
cin>>a[i];
cout<<"\n The array entered is";
for(i=0;i<10;i++)
cout<<a[i];
i=0;
while(i!=9) // Performing Bit-Stuffing.
{
if(a[i]==1)
{
i++;
count++;
if(count==5)
for(k=11;k>i;k--)
a[k]=a[k-1];
a[i]=0;
}
}
else
{
i++;
count=0;
}
}
cout<<"\n"<<"The array after stuffing is: ";
for(i=0;i<=10;i++)
cout<<a[i];
cout<<"\n"<<"The array after destuffing is: ";
i=0;
while (i<10) // Performing Destuffing.
{
if(a[i]==1)
{
i++;
count++;
if(count==5)
{
for(k=i;k<11;k++)
a[k]=a[k+1];
}
}
else
{
i++;
count=0;
}
}
for(i=0;i<10;i++)
cout<<a[i];
getch();
}
OUTPUT:-
Enter the elements of the array(in 1’s and 0’s form)1
1
1
1
1
1
0
0
1
0
The array entered is 1111110010
The array after stuffing is: 11111010010
The array after destuffing is: 1111110010
EXPERIMENT NO.-2
AIM: Write a C++ program to determine if the IP address is in Class A, B, C, D, or E.
CODE:
getch();
}
OUTPUT:
EXPERIMENT NO.-3
AIM: Write a C++ program to determine if the IP address is in Class A, B, or C.
CODE:
OUTPUT:
EXPERIMENT NO.-4
AIM: Write a C++ program to translate dotted decimal IP address into 32 bit address.
CODE:
OUTPUT:
EXPERIMENT NO.-5
AIM: To establish straight configuration for LAN.
EQUIPMENTS REQUIRED:-
1) 2 RJ -45 connectors
4) SLT-Tool
Colour Coding:-
1. Orange white
2. Orange
3. Green white
4. Blue
5. Blue white
6. Green
7. Brown white
8. Brown
PROCEDURE:-
The outer covering of the wire is peeled off and according to requirement the wires are inserted
in RJ-45 connector and punched with the help of punching tool after punching the wire is tested
with SLT( Side locator tool).
RESULT:-
The straight wiring for the LAN has been established and tested using SLT tool.
USE:-
EXPERIMENT NO.-6
AIM: To establish rollover configuration for LAN.
EQUIPMENTS REQUIRED:-
1) 2 RJ -45 connectors
4) SLT-Tool
Colour Coding:-
1. Orange white
2. Orange
3. Green white
4. Blue
5. Blue white
6. Green
7. Brown white
8. Brown
PROCEDURE:-
The outer covering of the wire is peeled off and according to requirement the wires are inserted
in RJ-45 connector and punched with the help of punching tool after punching the wire is tested
with SLT( Side locator tool).
RESULT:-
The rollover wiring for the LAN has been established and tested using SLT tool.
USE:-
This type of wiring is used for configuration of the router.
EXPERIMENT NO.-7
AIM: To establish crossover configuration for LAN.
EQUIPMENTS REQUIRED:-
1) 2 RJ -45 connectors
4) SLT-Tool
Colour Coding:-
1. Orange white
2. Orange
3. Green white
4. Blue
5. Blue white
6. Green
7. Brown white
8. Brown
PROCEDURE:-
The outer covering of the wire is peeled off and according to requirement the wires are inserted
in RJ-45 connector and punched with the help of punching tool after punching the wire is tested
with SLT (Side locator tool).
RESULT:-
The crossover wiring for the LAN has been established and tested using SLT tool.
USES:
CODE:
#include <iostream.h>
#include<conio.h>
void main ( )
{
int a0, a1, a2, a3, b0, b1, b2, b3, r0, r1, r2, s0, s1, s2, q0, q1, q2, q3;
cout<< "Enter the word\n";
cin>>a3>>a2>>a1>>a0;
r0= (a0+a1+a2) %2;
r1= (a1+a2+a3) %2;
r2= (a0+a1+a3) %2;
cout <<"The code at sender is: "<<a3<<a2<<a1<<a0<<r2<<r1<<r0;
cout<<"\n Enter the code at receiver:\n";
cin>>b3>>b2>>b1>>b0>>q2>>q1>>q0;
cout<<"b3="<<b3<<",b2="<<b2<<",b1="<<b1<<",b0="<<b0<<",q2="<<q2<<",q1="<<q1<<",
q0="<<q0;
s0= (b2+b1+b0+q0) %2;
s1= (b3+b2+b1+q1) %2;
s2= (b1+b0+b3+q2) %2;
cout<<"\n"<<"s2="<<s2<<",s1="<<s1<<",s0="<<s0;
if ( s2==0 && s1==0 && s0==0 )
cout << "\n No Error";
else if ( s2==0 && s1==0 && s0==1 )
cout << "\n Error at q0";
CODE:
{
cost[i][j]=IN;
}
}
for(x=1;x<N;x++)
{
for(y=x+1;y<N;y++)
{
printf("Enter the weight of the path between node %d and %d:",x,y);
scanf("%d",&w);
cost[x][y]=cost[y][x]=w;
}
printf("\n");
}
printf("\n Enter the source:");
scanf("%d",&source);
printf("\n Enter the target");
scanf("%d",&target);
co=dijsktra(cost,source,target);
printf("\n shortest path:%d",co);
getch();
}
int dijsktra(int cost[][N],int source,int target)
{
int dist[N],prev[N],selected[N]={0},i,m,min,start,d,j;
char path[N];
for(i=1;i<N;i++)
{
dist[i]=IN;
prev[i]=-1;
}
start=source;
selected[start]=1;
dist[start]=0;
while(selected[target]==0)
{
min=IN;m=0;
for(i=1;i<N;i++)
{
d=dist[start]+cost[start][i];
if(d<dist[i] && selected[i]==0)
{
dist[i]=d;
prev[i]=start;
}
if(min>dist[i] && selected[i]==0)
{
min=dist[i];
m=i;
}
}
start=m;
selected[start]=1;
}
start=target;
j=0;
while(start!=-1)
{
path[j++]=start+65;
start=prev[start];
}
path[j]='\0';
strrev(path);
printf("%s",path);
return dist[target];
}
OUTPUT: