0% found this document useful (0 votes)
16 views2 pages

Go Back

The provided C program simulates a Go-Back-N ARQ protocol for transmitting frames. It prompts the user to enter the total number of frames and the window size, then sends frames in batches according to the window size. If an acknowledgment for the last sent frame is not received, it resends frames starting from the last acknowledged frame until all frames are acknowledged successfully.

Uploaded by

enjoybaap6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Go Back

The provided C program simulates a Go-Back-N ARQ protocol for transmitting frames. It prompts the user to enter the total number of frames and the window size, then sends frames in batches according to the window size. If an acknowledgment for the last sent frame is not received, it resends frames starting from the last acknowledged frame until all frames are acknowledged successfully.

Uploaded by

enjoybaap6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <stdio.

h>

int main() {
int windowsize, sent = 0, ack, totalFrames, i;

printf("Enter total number of frames to transmit: ");


scanf("%d", &totalFrames);

printf("Enter window size: ");


scanf("%d", &windowsize);

while (sent < totalFrames) {


// Send up to window size frames or until all frames are sent
for (i = 0; i < windowsize && sent < totalFrames; i++) {
printf("Frame %d has been transmitted.\n", sent);
sent++;
}

printf("\nPlease enter the last Acknowledgement received (0 to %d): ", totalFrames - 1);
scanf("%d", &ack);

if (ack >= totalFrames) {


printf("All frames acknowledged.\n");
break;
} else if (ack < sent) {
sent = ack + 1; // Go back to the frame after last acknowledged
printf("Go-Back-N: Resending from frame %d...\n", sent);
}
}

printf("\nAll frames sent and acknowledged successfully.\n");


return 0;
}

Output

Enter total number of frames to transmit: 6


Enter window size: 3
Frame 0 has been transmitted.
Frame 1 has been transmitted.
Frame 2 has been transmitted.

Please enter the last Acknowledgement received (0 to 5): 1


Go-Back-N: Resending from frame 2...
Frame 2 has been transmitted.
Frame 3 has been transmitted.
Frame 4 has been transmitted.

Please enter the last Acknowledgement received (0 to 5): 4


Frame 5 has been transmitted.

Please enter the last Acknowledgement received (0 to 5): 5

All frames sent and acknowledged successfully.

You might also like