//======================================================== file = dlc.c ======//==============================================================================W. Stalllings, Data and Computer Communcations, 6th edition, ==//=————————————————————————-====================//=————————————————————————-==//=————————————————————————-==//=————————————————————————-=====//=————————————————————————-====//===========================================================================//—– Include files ——————————————————-// Needed for printf() and scanf()// Needed for atoi() and atof()// Needed for pow()//—– Defines ————————————————————-// Copper propagation in meters per second//===== Main program ========================================================void main(void){// Temporary input string// Link distance in meters// Link data rate in bits per second// Frame length in bits// Probability of a bit error// Protocol type (1 = SAW, 2 = SW)// ARQ type for SW (1 = SR, 2 = GBN)// Window size for SW// Probability of a frame error// Stallings “a” parameter// Link utilization as a ratio // Output banner printf(“——————————————– dlc.c —– n”);- n”); printf(“——————————————————– n”); // Prompt for distance of link in meters printf(“Length of link in meters =======================> “); scanf(“%s”, instring); d = atof(instring); // Prompt for data rate of link in bits per second printf(“Data rate of link in bits per second ===========> “); scanf(“%s”, instring); R = atof(instring); // Prompt for size of frames in bytes (converted to bits for L) printf(“Size of frames in bytes ========================> “); scanf(“%s”, instring); L = 8 * atoi(instring); // Prompt for error rate (BER) printf(“Pr[bit error] (0.0 to 1.0) =====================> “); scanf(“%s”, instring); pr_bit = atof(instring); // Prompt for protocol (SAW or SW) printf(“Protocol type (1 = SAW, 2 = SW) ================> “); scanf(“%s”, instring); protocol_type = atoi(instring); // If SW then prompt for other parameters if (protocol_type == 2) {// Prompt for window sizeprintf(“Window size ====================================> “);scanf(“%s”, instring);N = atoi(instring);// Prompt for error control (GBN or SR)printf(“ARQ type (1 = SR, 2 = GBN) =====================> “);scanf(“%s”, instring);ARQ_type = atoi(instring); } // Compute P (probability of frame error) P = 1 – pow((1 – pr_bit), (double) L); // Compute “a” value a = ((double) R * d) / ((double) V * L); // Compute U for SAW if (protocol_type == 1)U = (1 – P) / (1 + (2 * a)); // Compute U for SW and SR if ((protocol_type == 2) && (ARQ_type == 1))if (N >= ((2 * a) + 1))U = (1 – P);elseU = (N * (1 – P)) / ((2 * a) + 1); // Compute U for SW and GBN if ((protocol_type == 2) && (ARQ_type == 2))if (N >= ((2 * a) + 1))U = (1 – P) / (1 + (2 * a * P));elseU = (N * (1 – P)) / (((2 * a) + 1) * (1 – P + N * P)); // Output results printf(“——————————————————– n”); printf(“- Protocol is “); if (protocol_type == 1)printf(“Stop-and-Wait n”); else {printf(“Sliding Window with “);if (ARQ_type == 1)printf(“Selective Reject ARQ n”);elseprintf(“Go-Back-N ARQ n”); } printf(“- n”);= %f n”, a);Pr[frame loss] = %f n”, P);= %f %% n”, 100.0 * U); printf(“——————————————————– n”);}
ScholarMatic | 24/7 Homework Help
ScholarMatic Will Help You Write Your Essays and Term Papers
Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.
//======================================================== file = dlc.
HOME TO CERTIFIED WRITERS

Why Place An Order With Us?
- Certified Editors
- 24/7 Customer Support
- Profesional Research
- Easy to Use System Interface
- Student Friendly Pricing
Have a similar question?
ScholarMatic: Get Started
Assignment Writing Service
Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!




