Sunday, January 26, 2014

AnnaUniversity EC66 Computer Networks Lab - C Program to Calculate the Link Utilization for Stop and Wait ARQ Protocol

with 0 Comment
C Program to Calculate the Link Utilization for Stop and Wait ARQ Protocol:

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#define v 2.0e8
void main(void)
{
char instring[80];
double d,r,pr,p,a,u,u1;
long int l;
clrscr();
printf("....................");
printf("\n Program to Compute Utiliation of Stop and Wait Protocol\n");
printf("\n.....................\n");
printf("\n Length of the link in m:");
scanf("%s",instring);
d=atof(instring);
printf("\n Data rate of the link in bits per sec");
scanf("%s",instring);
r=atof(instring);
printf("\n Size of frame in byte:");
scanf("%s",instring);
l=8*atoi(instring);
printf("\n pr[biterror](0.0to1.0):");
scanf("%s",instring);
pr=atof(instring);
p=1-pow((1-pr),(double)l);
a=((double)r*d)/((double)v*l);
u=(1-p)/(1+(2*a));
u1=(1)/(1+(2*a));
printf("\n...................\n");
printf("\n.....Protocol is Stop and Wait....\n");
printf("......a=%f.........\n",a);
printf("......pr[frameloss]=%f....\n",p);
printf(".....Utilisation Factor with Error=%f....\n",100.0*u);
printf(".....Utilisation Factor without Error=%f....\n",100.0*u1);
printf("................\n");
getch();
}

OUTPUT:


0 comments:

Post a Comment

Powered by Blogger.

Blog Archive