Network Lab Manual
Network Lab Manual
PAGE
EXPNO DATE EXPERIMENT NAME SIGNATURE
NO
1 SOCKET CREATION
SIMULATION OF
2
ARP/RARP
3 BIT STUFFING
CYCLIC REDUNDANCY
4
CHECK
SIMULATION OF SLIDING
5
WINDOW PROTOCOL
OPEN SHORTEST PATH
6
FIRST ALGORITHM
SOCKET CREATION
AIM:
ALGORITHM:
Output:
Result:
Thus the c program for implementing socket creation has been executed and verified.
SIMULATION OF ARP/RARP
AIM:
ALGORITHM:
Step 4: Create a file and with that file declare the physical and logical address.
Step 5: Get the choice of operation. If it is ARP show the logical address and if its RARP
display the physical address.
.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct file
{
char phyadd[30];
char logadd[30];
}f[15];
File *fp
int n;
void arp(char *ladd)
{
int i;
for(i=0;i<n;i++)
{
if(strcmp,(ladd,f[i].logadd))
{
printf("\n corresponding logical address is",f[i].phyadd);
break;
}
if(i==n)
printf("the address is not found");
}
}
void rarp(char *padd)
{
int i;
for(i=0;i<n;i++)
{
if(!strcmp,(padd,f[i].phyadd))
{
printf("\n corresponding physical address is",f[i].logadd);
break;
}
}
if(i==n)
printf("the address is not found");
}
int main()
{
int i=0,ch;
char padd[30],ladd[30];
fp=fopen("data.txt","r");
if(fp=null)
{
pritnf(" \n file not found");
exit(0);
}
while(!feof(fp))
{
fscanf(fp,"%s%s",f[i].phyadd,f[i].logadd);
i++;
}
fclose(fp);
n=i;
while(1);
{
printf("\n 1.ARP \n 2.RARP \n 3.EXIT");
printf(" enter your choice");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("enter the physical address");
scanf("%s",ladd);
arp(ladd);
break;
case 2:
printf(" enter the logical address");
scanf("%s",padd);
rarp(padd);
break;
case 3:
exit(1);
break;
}
}
return(0);
}
Output:
1. ARP
2. RARP
3. EXIT
Enter your choice: 1
AIM:
To write a c program to implement bit stuffing for the given bits of information.
ALGORITHM:
Step 2: Declare the variable and obtain the information size and need it.
Step 3: Create an input file and copy the information into it.
Step 4: Create another file with read mode and check for the condition.
#include<stdio.h>
main()
{
int n=0,i,size;
char ch,b[100];
FILE*ed;
FILE*es;
printf("enter the bit information size:");
scanf("%d",&size);
printf("enter the bit information:");
for(i=0;i<size;i++)
{
scanf("%c",&b[i]);
}
ed=fopen("sarinput.txt","wt");
i=0;
for(i=0;i<size;i++)
{
fputc(b[i],ed);
}
fclose(ed);
ed=fopen("sarinput.txt","rt");
if(ed==NULL)
printf("\n error ");
es=fopen("saroutput.txt","wt");
ch=getc(ed);
while(ch!=EOF)
{
fputc(ch,es);
if(ch='1')
n++;
else
n=0;
if(n==5)
{
fputc('0',es);
n=0;
}
ch=getc(ed);
}
printf("\n original data");
fclose(ed);
fclose(es);
ed=fopen("sarinput.txt","rbt");
ed=fopen("saroutput","rbt");
ch=getc(ed);
while(ch!=EOF)
{
printf("%c",ch);
ch=getc(ed);
}
printf("\n data after stuffing");
ch=getc(es);
while(ch!=EOF)
{
printf("%c",ch);
ch=getc(es);
}
fclose(ed);
fclose(es);
}
output:
original data:
111111
data after stuffing:
1111101
Result:
Thus the program for bit stuffing is verified and written successfully.
CYCLIC REDUNDANCY CHECK
AIM:
ALGORITHM:
Step 3: Perform the binary division and the CRC remainder is found.
#include<stdio.h>
#include<string.h>
int main()
{
int i,j=1,k=0,m=0,divlen,len;
char orgdiv[20],dividend[20],divisor[20],zeros[10],crc[10];
printf("enter the dividend:");
scanf("%s",dividend);
printf("enter the divisor:");
scanf("%s",divisor);
divlen=strlen(divisor);
for(i=0;i<divlen-1;i++)
zeros[i]='0';
zeros[i]='\0';
strcpy(orgdiv,dividend);
strcat(dividend,zeros);
len=strlen(dividend);
while(j<=(len-divlen+1))
{
if(dividend[m]=='1')
{
for(i=0;i<divlen;i++)
{
if(dividend[i]==divisor[i])
crc[i]='0';
else
crc[i]='1';
dividend[m]=crc[i];
m++;
}
}
else
{
for(i=0;i<divlen;i++)
{
if(dividend[i]=='0')
crc[i]='0';
else
crc[i]='1';
dividend[m]=crc[i];
m++;
}
}
for(k=0;dividend[k]!='\0';k++)
dividend[k]=dividend[k+1];
m=0;
j++;
}
for(j=0;j<divlen-1;j++)
crc[j]=dividend[j];
crc[j]='\0';
printf("\n the crc is: %s",crc);
strcat(orgdiv,crc);
printf("the append data is p: %s",orgdiv);
}
Output:
AIM:
ALGORITHM:
Step 5: Enter the sequence number to be sent and the current sender window.
Thus the program for sliding window protocol is verified and written successfully.
OPEN SHORTEST PATH FIRST ALGORITHM
AIM:
To write a c++ program for open shortest path between server and destination
Node.
ALGORITHM:
Step 4: Get the Number of nodes and the cost of the edge between various nodes.
Step 6: Find the shortest path between source and destination node.
Output:
Number of nodes : 3
1.shortest path
2.exit
Choice……….. 1
Choice……….. 2