Vous êtes sur la page 1sur 17

COMPUTER NETWORK LAB-ECE-EC6611 2018

EC6611 COMPUTER NETWORKS LABORATORY L T P C 0 0 3 2 OBJECTIVES: The


student should be made to:
Learn to communicate between two desktop computers.
Learn to implement the different protocols
Be familiar with socket programming.
Be familiar with the various routing algorithms
Be familiar with simulation tools.

LIST OF EXPERIMENTS:
1. Implementation of Error Detection / Error Correction Techniques
2. Implementation of Stop and Wait Protocol and sliding window
3. Implementation and study of Goback-N and selective repeat protocols
4. Implementation of High Level Data Link Control
5. Study of Socket Programming and Client – Server model
6. Write a socket Program for Echo/Ping/Talk commands.
7. To create scenario and study the performance of network with CSMA / CA protocol
and compare with CSMA/CD protocols.
8. Network Topology - Star, Bus, Ring
9. Implementation of distance vector routing algorithm

10. Implementation of Link state routing algorithm


11. Study of Network simulator (NS) and simulation of Congestion Control Algorithms using NS
12. Encryption and decryption.
TOTAL: 45 PERIODS OUTCOMES: At the end of the course, the student should be able to
Communicate between two desktop computers.
Implement the different protocols
Program using sockets.
Implement and compare the various routing algorithms
Use simulation tool.

LIST OF EQUIPMENT FOR A BATCH OF 30 STUDENTS

Salai kishwar jahan –Asst professor (ECE) Page 1


COMPUTER NETWORK LAB-ECE-EC6611 2018
EX.NO:01

DATE:

IMPLEMENTATION OF GO BACK N ARQ AND SELECTIVE REPEAT


PROTOCOL.

AIM:

To simulate go back n arq and selective repeat protocol and record its perfomence for
reliable data transfer.

ALGORITHM:

1) Sender keeps track of out sending frames and updates the variable and
window as acknowledgement archives.
2) Receive sliding window sends back the acknowledgement for the received
frame and notifies the next expected frame.
3) Commence transmission.
4) Deal with damaged or lost frame.
5) Deal with damaged or lost acknowledgement.
6) Deal with delayed acknowledgement.
7) Update sender window size.
8) Stop the program.

Salai kishwar jahan –Asst professor (ECE) Page 2


COMPUTER NETWORK LAB-ECE-EC6611 2018
PROGRAM:

GO BACK SELCTIVE ARQ

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<conio.h>
int n,r;
struct frame
{
char ack;
int data;
}
frm[10];
int sender(void);
void recvfrm(void);
void resend(void);
void resend1(void);
void goback(void);
void selective(void);
int main()
{
int c;
clrscr();
do
{
printf("\nMENU:");
printf("\n\n1.selective repeat ARQ\n 2.go back-n ARQ\n 3.exit");
printf("\n enter the choice");
scanf("%d",&c);
switch(c)
{
case 1:
selective();
break;
case 2:
goback();
break;
case 3:
exit(0);
break;
}

Salai kishwar jahan –Asst professor (ECE) Page 3


COMPUTER NETWORK LAB-ECE-EC6611 2018
}while(c!=4);
return 0;
}
void goback()
{
sender();
recvfrm();
resend1();
printf ("\n all packets sent successfully\n");
}
void selective()
{
sender();
recvfrm();
resend();
printf("\n all packets sent sucessfully \n");
}
int sender()
{
int i;
printf("\n enter the no.of.packets to be sent: \n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\n enter data for packets[%d]:",i);
scanf("%d",&frm[i].data);
frm[i].ack='y';
}
return 0;
}
void recvfrm()
{
int i;
rand();
r=rand()%n;
frm[r].ack='n';
for(i=0;i<n;i++)
{
if(frm[i].ack=='n')
printf("\n the packet num %d is not interested:",r);
}
}
void resend()
{
printf("\n resending packets %d",r);
sleep(2);

Salai kishwar jahan –Asst professor (ECE) Page 4


COMPUTER NETWORK LAB-ECE-EC6611 2018
frm[r].ack='y';
printf(" \n the received packetsis %d",frm[r].data);
}
void resend1()
{
int i;
printf("\n resending from packets%d",r);
for(i=r;i<n;i++)
{
sleep(2);
frm[i].ack='y';
printf("\n received data of parant %d is %d",i,frm[i].data);
}
}

OUTPUT:

Salai kishwar jahan –Asst professor (ECE) Page 5


COMPUTER NETWORK LAB-ECE-EC6611 2018

Salai kishwar jahan –Asst professor (ECE) Page 6


COMPUTER NETWORK LAB-ECE-EC6611 2018
EX:NO: 02

DATE:

IMPLEMENTATION OF ERROR DETECTION AND ERROR CORRECTION

TECHNIQUES CRC COMPUTATIOIN

AIM:

To write a c program to find the cycle redundancy check code for a given input
binary data word.

ALGORITHM:

1) Start the program.


2) The CRC algorithm operates on a block of data as a unit.
3) The CRC algorithm divides this large values by the CRC polynomial
(or) generator polynomial leaving the remainder which is the CRC result.
4) The CRC result can be sent (or)stored along with original data.
5) When the data is received (or) recovered from storage, the CRC algorithm
can be reapplied and the latest result is compared with original result.
6) If an error has occurred, we will probably get a different CRC result.
7) Stop the program.

Salai kishwar jahan –Asst professor (ECE) Page 7


COMPUTER NETWORK LAB-ECE-EC6611 2018
PROGRAM

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char text[100];
char key[100];
char rem[100];
void crc()
{
int i,j;
int keylen,textlen;
char temp[100];
strcpy(temp,text);
keylen=strlen(key);
for(i=0;i<keylen-1;i++)
strcat(temp,"0");
textlen=strlen(temp);
strncpy(rem,temp,keylen);
while(i!=textlen)
{
if(rem[0]=='0')
{
strcpy(rem,&rem[1]);
rem[keylen-1]=temp[++i];
rem[keylen]='10';
continue;
}
for(j=0;j<keylen;j++)
rem[j]=((rem[j]-'0')^(key[j]-'0'))+'0';
}
}
main()
{
int i;
int choice;
while(1)
{
printf("\n1.find crc\n2.check crc\n3.quite\n enter your choice\t:");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("enter the input signal");
scanf("%s",text);
printf("\n enter the key");
scanf("%s",key);
crc();
printf("the transmitted msg is %s\n",strcat(text,rem));
break;
case 2:
printf("\nenter input string");
scanf("%s",text);

Salai kishwar jahan –Asst professor (ECE) Page 8


COMPUTER NETWORK LAB-ECE-EC6611 2018
printf("\n enter the key");
scanf("%s",key);
crc();
for(i=0;i<strlen(key)-1;i++)
if(rem[i]=='1')

if(i==strlen (key)-1)
printf("\n there is no error in the msg");
else
printf("\n there is error in the msg");
break;
case 3:
exit(0);
}
}
}

Salai kishwar jahan –Asst professor (ECE) Page 9


COMPUTER NETWORK LAB-ECE-EC6611 2018

Salai kishwar jahan –Asst professor (ECE) Page 10


COMPUTER NETWORK LAB-ECE-EC6611 2018

EX:NO: 02

DATE:

TO CREATE SCENARIO AND STUDY THE PERFORMANCE OF


NETWORK WITH CSMA / CA PROTOCOL
AND COMPARE WITH CSMA/CD PROTOCOLS.
CSMA / CD protocol

include <protocol.h>
void main()
{
Frame X,Y;
X="data1";
Y="data2";

CSMACD_INIT();
CSMACD_START();

CSMA_SEND(B,A,X);
CSMA_SEND(A,C,Y);

R=COLLISION_OCCUR();
if(R)
{
WAIT(1000);

RETRANSMIT(B,A);
RETRANSMIT(A,C);

}
}
OUTPUT

Salai kishwar jahan –Asst professor (ECE) Page 11


COMPUTER NETWORK LAB-ECE-EC6611 2018

CSMA / CA protocol

include <protocol.h>
void main()
{
Frame X;
X="data1";

CSMACA_INIT();

CSMACA_START();

NODE_LISTEN();

REQUESTTO_SEND(A,B);

CLEARTO_SEND(B,A);

DATATO_SEND(A,B,X);

ACKNOWLEDGE(B,A);

}
OUTPUT

Salai kishwar jahan –Asst professor (ECE) Page 12


COMPUTER NETWORK LAB-ECE-EC6611 2018

Salai kishwar jahan –Asst professor (ECE) Page 13


COMPUTER NETWORK LAB-ECE-EC6611 2018

IMPLEMENTATION OF DISTANCE VECTOR ROUTING


ALGORITHM

Salai kishwar jahan –Asst professor (ECE) Page 14


COMPUTER NETWORK LAB-ECE-EC6611 2018

Salai kishwar jahan –Asst professor (ECE) Page 15


COMPUTER NETWORK LAB-ECE-EC6611 2018

Salai kishwar jahan –Asst professor (ECE) Page 16


COMPUTER NETWORK LAB-ECE-EC6611 2018

Salai kishwar jahan –Asst professor (ECE) Page 17

Vous aimerez peut-être aussi