Description
Objective:
To demonstrate Go Back N and Selective Repeat Modes of Sliding Window Protocol in peer to
peer mode.
Problem Description:
a. Write a program to simulate Go Back N and Selective Repeat Modes of Sliding Window
Protocol in peer to peer mode and demonstrate the packets captured traces using Wireshark
Packet Analyzer Tool for peer to peer mode.
a. Client Program acts as a Sender
b. Server Program acts as a Receiver
c. The messages being communicated are of the form <D, i> i.e. data message with
sequence number i; and <A,i> i.e acknowledgement message with sequence number
i
d. Assume that packets are never corrupted (no checksum required) or delayed (no
timer required)
e. The client program will take <D, i> as input from the user and send it to the server
f. The server will automatically respond as per the protocol with acknowledgement
g. Things to check:
h. What if client sends data messages out of sequence, validate the response from the
server based on the protocol being used
b. Demonstrate Go back N and Selective Repeat Modes and also captured packets using
Wireshark Packet Analyzer Tool for peer to peer mode.
2
Theory:
The basic idea of sliding window protocol is that both sender and receiver keep a
“window” of acknowledgment. The sender keeps the value of expected acknowledgment;
while the receiver keeps the value of expected receiving frame. When it receives an
acknowledgment from the receiver, the sender advances the window. When it receives the
expected frame, the receiver advances the window.
In transmit flow control, sliding window is a variable-duration window that allows a
sender to transmit a specified number of data units before an acknowledgement is
received or before a specified event occurs.
Flow Control is a set of procedures that tells the sender how much data it can transmit before it
must wait for an acknowledgment from the receiver. The flow of data should not be allowed to
overwhelm the receiver. Receiver should also be able to inform the transmitter before its limits
(this limit may be amount of memory used to store the incoming data or the processing power at
the receiver end) are reached and the sender must send fewer frames. Hence, Flow control refers
to the set of procedures used to restrict the amount of data the transmitter can send before
waiting for acknowledgment.
There are two methods developed for flow control namely Stop-and-wait and Sliding-window
Sliding window algorithms, used by TCP, permit multiple data packets to be in simultaneously
transit, making more efficient use of network bandwidth.
Sliding Window Protocol:
With the use of multiple frames for a single message, the stop-and-wait protocol does not
perform well. Only one frame at a time can be in transit. Efficiency can be greatly improved by
allowing multiple frames to be in transit at the same time. Efficiency can also be improved by
making use of the full-duplex line. To keep track of the frames, sender station sends sequentially
numbered frames. Since the sequence number to be used occupies a field in the frame, it should
3
be of limited size. If the header of the frame allows k bits, the sequence numbers range from 0 to
2k – 1. Sender maintains a list of sequence numbers that it is allowed to send (sender window).
The size of the sender’s window is at most 2k – 1. The sender is provided with a buffer equal to
the window size. Receiver also maintains a window of size 2k – 1. The receiver acknowledges a
frame by sending an ACK frame that includes the sequence number of the next frame expected.
This also explicitly announces that it is prepared to receive the next N frames, beginning with the
number specified. This scheme can be used to acknowledge multiple frames. It could receive
frames 2, 3, 4 but withhold ACK until frame 4 has arrived. By returning an ACK with sequence
number 5, it acknowledges frames 2, 3, 4 in one go. The receiver needs a buffer of size 1.
Sliding window algorithm is a method of flow control for network data transfers. TCP, the
Internet’s stream transfer protocol, uses a sliding window algorithm.
A sliding window algorithm places a buffer between the application program and the network
data flow. For TCP, the buffer is typically in the operating system kernel, but this is more of an
implementation detail than a hard-and-fast requirement.
Data received from the network is stored in the buffer, from where the application can read at its
own pace. As the application reads data, buffer space is freed up to accept more input from the
network. The window is the amount of data that can be “read ahead” – the size of the buffer, less
the amount of valid data stored in it. Window announcements are used to inform the remote host
of the current window size.
An example of a sliding window in packet transmission is one in which, after the sender
fails to receive an acknowledgement for the first transmitted packet, the sender “slides”
the window, i.e. resets the window, and sends a second packet. This process is repeated
for the specified number of times before the sender interrupts transmission. Sliding
window is sometimes (loosely) called acknowledgement delay period.
4
Go-Back-N Protocol and “Selective Repeat Protocol” are the sliding window protocols. The
sliding window protocol is primarily an error control protocol, i.e. it is a method of error
detection and error correction. The basic difference between go-back-n protocol and selective
repeat protocol is that the “go-back-n protocol” retransmits all the frames that lie after the
frame which is damaged or lost. The “selective repeat protocol” retransmits only that frame
which is damaged or lost.
Go back N ARQ
In the Go-Back-N Protocol, the sequence numbers are modulo 1!”, where m is the size of the
sequence number
Selective Repeat ARQ
Go-Back-N ARQ simplifies the process at the receiver site. The receiver keeps track of only
one variable, and there is no need to buffer out-of-order frames; they are simply discarded.
However, this protocol is very inefficient for a noisy link. In a noisy link a frame has a higher
probability of damage, which means the resending of multiple frames. This resending uses up
the bandwidth and slows down the transmission. For noisy links, there is another mechanism
that does not resend N frames when just one frame is damaged; only the damaged frame is
resent. This mechanism is called Selective Repeat ARQ.
5
Key Differences Between Go-Back-N and Selective Repeat
1. Go-Back-N protocol is design to retransmit all the frames that are arrived after the
damaged or a lost frame. On the other hand, Selective Repeat protocol retransmits only
that frame that is damaged or lost.
2. If the error rate is high i.e. more frames are being damaged and then retransmitting all the
frames that arrived after a damaged frame waste the lots of bandwidth. On the other hand,
selective repeat protocol re-transmits only damaged frame hence, minimum bandwidth is
wasted.
3. All the frames after the damaged frame are discarded and the retransmitted frames arrive
in a sequence from a damaged frame onwards, so, there is less headache of sorting the
frames hence it is less complex. On the other hand, only damaged or suspected frame is
retransmitted so,
extra logic has
to be applied for
sorting hence, it
is more
complicated.
4. Go-Back-N has a window size of N-1 and selective repeat have a window size
<=(N+1)/2.
5. Neither sender nor receiver need the sorting algorithm in Go-Back-N whereas, receiver
must be able to sort the as it has to maintain the sequence.
6. In Go-Back-N receiver discards all the frames after the damaged frame hence, it don’t
need to store any frames. Selective repeat protocol does not discard the frames arrived
after the damaged frame instead it stores those frames till the damaged frame arrives
successfully and is sorted in a proper sequence.
7. In selective repeat NAK frame refers to the damaged frame number and in Go-Back-N,
NAK frame refers to the next frame expected.
8. Generally, the Go-Back-N is more is use due to its less complex nature instead
6
of Selective Repeat protocol.
Conclusion: Hence we have implemented of sliding window protocol (Go back N and
Selective Repeat).