You are on page 1of 4

DELHI TECHNOLOGICAL UNIVERSITY

COMPUTER NETWORKS LAB

Submitted To: Submitted By:


Ms. Nipun Bansal Palak Yadav
2K18/SE/092
EXPERIMENT 4

AIM: Write program to implement Go Back N Protocol.

THEORY: Go-Back-N protocol, also called Go-Back-N Automatic Repeat reQuest, is a data link
layer protocol that uses a sliding window method for reliable and sequential delivery of data
frames. It is a case of sliding window protocol having to send window size of N and receiving
window size of 1. Go – Back – N ARQ provides for sending multiple frames before receiving the
acknowledgment for the first frame. The frames are sequentially numbered and a finite number
of frames. The maximum number of frames that can be sent depends upon the size of the
sending window. If the acknowledgment of a frame is not received within an agreed upon time
period, all frames starting from that frame are retransmitted.

CODE:

#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
int nf,N;
int no_tr=0;
srand(time(NULL));
cout<<"Enter the number of frames : ";
cin>>nf;
cout<<"Enter the Window Size : ";
cin>>N;
int i=1;
while(i<=nf)
{
int x=0;
for(int j=i;j<i+N && j<=nf;j++)
{
cout<<"Sent Frame "<<j<<endl;
no_tr++;
}
for(int j=i;j<i+N && j<=nf;j++)
{
int flag = rand()%2;
if(!flag)
{
cout<<"Acknowledgment for Frame "<<j<<endl;
x++;
}
else
{
cout<<"Frame "<<j<<" Not Received"<<endl;
cout<<"Retransmitting Window"<<endl;
break;
}
}
cout<<endl;
i+=x;
}
cout<<"Total number of transmissions : "<<no_tr<<endl;
return 0;
}

OUTPUT:
FINDING & LEARNING:
1. Go Back N is an implementation of sliding window protocol
2. Go-Back-N ARQ is a particular instance of the automatic repeat request (ARQ) protocol, in
which the sending process continues to send the number of frames determined by a window
size even without receiving an acknowledgment (ACK) packet from the beneficiary.
3. It is an uncommon instance of the general sliding window protocol with the transmit window
size of N and get window size of 1. It can transmit N frames to the destination before
requiring an ACK.
4. The receiver process monitors the sequence number of the next edge it hopes to get and
sends that number with each ACK it sends.
5. The receiver will dispose of any casing that does not have the definite sequence number it
expects and will resend an ACK for the last right in-request outline.
6. Once the sender has sent the majority of the frames in its window, it will identify that the
majority of the frames since the main lost edge are outstanding, and will go back to the
sequence number of the last ACK it got from the receiver process and fill its window starting
with that frame and continue the process over again.
7. be spent waiting, more packets are being sent. Nonetheless, this strategy likewise brings
about sending frames on numerous occasions – if any edge was lost or harmed, or the ACK
acknowledging them was lost or harmed, then that frame and every single following frame in
the window will be re-sent. To maintain a strategic distance from this, Selective Repeat ARQ
can be utilized.

You might also like