You are on page 1of 26

Sliding Window Protocol

the first protocol which is GBN in terms of three main characteristic features and in the
last part we will be discussing SR as well as comparison of both these protocols
Sender Window Size (WS)
It is N itself. If we say the protocol is GB10, then Ws = 10. N should be always greater
than 1 in order to implement pipelining. For N = 1, it reduces to Stop and Wait
protocol.
Efficiency Of GBN = N/(1+2a) Where a = Tp/Tt
If B is the bandwidth of the channel, then Effective Bandwidth or Throughput =
Efficiency * Bandwidth = (N/(1+2a)) * B.
Receiver Window Size (WR) WR is always 1 in GBN.
Consider the diagram given below. We have sender window size of 4. Assume
that we have lots of sequence numbers just for the sake of explanation. Now the
sender has sent the packets 0, 1, 2 and 3. After acknowledging the packets 0 and
1, receiver is now expecting packet 2 and sender window has also slided to
further transmit the packets 4 and 5. Now suppose the packet 2 is lost in the
network, Receiver will discard all the packets which sender has transmitted
after packet 2 as it is expecting sequence number of 2. On the sender side for
every packet send there is a time out timer which will expire for packet number 2.
Now from the last transmitted packet 5 sender will go back to the packet number
2 in the current window and transmit all the packets till packet number 5. That’s
why it is called Go Back N. Go back means sender has to go back N places from
the last transmitted packet in the unacknowledged window and not from the
point where the packet is lost.
Acknowledgements
There are 2 kinds of acknowledgements namely :
Cumulative ACK – One acknowledgement is used for many packets. Main
advantage is traffic is less. Disadvantage is less reliability as if one ack is loss
that would mean that all the packets sent are lost.
Independent ACK – If every packet is going to get acknowledgement
independently. Reliability is high here but disadvantage is that traffic is also
high since for every packet we are receiving independent ack.
GBN uses Cumulative Acknowledgement. At the receiver side, it starts a acknowledgement
timer whenever receiver receives any packet which is fixed and when it expires, it is going
to send a cumulative Ack for the number of packets received in that interval of timer. If
receiver has received N packets, then the Acknowledgement number will be N+1.
Important point is Acknowledgement timer will not start after the expiry of first timer but
after receiver has received a packet.
Time out timer at the sender side should be greater than Acknowledgement timer.

Consider an example of GB4. Sender window size is 4 therefore we require a minimum of 4


sequence numbers to label each packet in the window. Now suppose receiver has received
all the packets(0, 1, 2 and 3 sent by sender) and hence is now waiting for packet number 0
again(We can not use 4 here as we have only 4 sequence numbers available since N = 4).
Now suppose the cumulative ack for the above 4 packets is lost in the network. On sender
side, there will be timeout for packet 0 and hence all the 4 packets will be transmitted
again. Problem now is receiver is waiting for new set of packets which should have started
from 0 but now it will receive the duplicate copies of the previously accepted packets. In
order to avoid this, we need one extra sequence number. Now the receive could easily
reject all the duplicate packets which were starting from 0 because now it will be waiting
for packet number 4( We have added an extra sequence number now).
In Go-Back-N Protocol, if the sent
frame are find suspected then all In selective Repeat protocol, only
1. the frames are re-transmitted those frames are re-transmitted
from the lost packet to the last which are found suspected.
packet transmitted.

Sender window size of Go-Back-N Sender window size of selective


2. Protocol is N. Repeat protocol is also N.

Receiver window size of Go-Back- Receiver window size of selective


3. Repeat protocol is N.
N Protocol is 1.

Selective Repeat
Go-Back-N Protocol is
4. protocol is more
less complex. complex.

In selective Repeat
In Go-Back-N Protocol, protocol, receiver side
5. neither sender nor at needs sorting to sort the
receiver need sorting. frames.
Go back N is more often used than other protocols.
SR protocol is less used because of its complexity.
Stop and Wait ARQ is less used because of its low efficiency.

Depending on the context and resources availability, Go back N or


Selective Repeat is employed.
Selective Repeat and Stop and Wait ARQ are similar in terms of
retransmissions.

Go back N and Selective Repeat are similar in terms of efficiency


if sender window sizes are same.

SR protocol may be considered as a combination of advantages of


Stop and Wait ARQ and Go back N.

SR protocol is superior to other protocols but because of its


complexity, it is less used.
Note-01:

Protocols at data link layer like HDLC (Low level protocols) use Go back N.
This is because-
Bandwidth is high
CPU is very busy doing routing job
Error rate is low since out of order packets are not possible in wired medium

Note-02:

Protocols at transport layer like TCP (High level protocols) use selective repeat.
Problem-01:

If the bandwidth between the sender and receiver is sufficient, CPU and buffers are
moderate, then which flow control protocol would you suggest to use?

Solution-

The suggested protocol would be Go back N.

Problem-02:

If the bandwidth between the sender and receiver is moderate, CPU and buffers are
sufficient, then which flow control protocol would you suggest to use?

Solution-

The suggested protocol would be Selective Repeat.


Problem-01:
 

In what protocols is it possible for the sender to receive an acknowledgement for a 
packet that falls outside its current window?
1.Stop and Wait
2.Selective Repeat
3.Go back N
4.All of the above
 
Solution-
 

•Delayed Acknowledgements fall outside the current window.
•They may occur in any of the flow control protocols and received by the sender.
 
Thus, correct option is (D).
Problem-02:

On a wireless link, the probability of packet error is 0.2. A stop and wait protocol is used to transfer data across the link. The
channel condition is assumed to be independent from transmission to transmission. What is the average number of
transmission attempts required to transfer 100 packets?
1.100
2.125
3.150
4.200

Solution-

Method-01:

Given-
•Probability of packet error = 0.2
•We have to transfer 100 packets

Now,
•When we transfer 100 packets, number of packets in which error will occur = 0.2 x 100 = 20.
•Then, these 20 packets will have to be retransmitted.
•When we retransmit 20 packets, number of packets in which error will occur = 0.2 x 20 = 4.
•Then, these 4 packets will have to be retransmitted.
•When we retransmit 4 packets, number of packets in which error will occur = 0.2 x 4 = 0.8 ≅ 1.
•Then, this 1 packet will have to be retransmitted.

From here, average number of transmission attempts required = 100 + 20 + 4 + 1 = 125.


Thus, Option (B) is correct.
REMEMBER
If there are n packets to be transmitted and p is the probability of packet error,
then-
Number of transmission attempts required
= n + np + np2 + np3 + …… + ∞
= n / (1-p)
Error Detecting Codes (Implemented either at Data link layer or Transport
Layer of OSI Model)
Whenever a message is transmitted, it may get scrambled by noise or data
may get corrupted. To avoid this, we use error-detecting codes which are
additional data added to a given digital message to help us detect if any error
has occurred during transmission of the message.

Basic approach used for error detection is the use of redundancy bits, where
additional bits are added to facilitate detection of errors.
Some popular techniques for error detection are:
1. Simple Parity check
2. Two-dimensional Parity check
3. Checksum
4. Cyclic redundancy check
1. Simple Parity check
Blocks of data from the source are subjected to a check bit or parity bit generator form,
where a parity of :
1 is added to the block if it contains odd number of 1’s, and
0 is added if it contains even number of 1’s

This scheme makes the total number of 1’s even, that is why it is called even parity
checking.
2. Two-dimensional Parity check
Parity check bits are calculated for each row, which is equivalent to a simple parity check
bit. Parity check bits are also calculated for all columns, then both are sent along with the
data. At the receiving end these are compared with the parity bits calculated on the
received data.
3. Checksum
In checksum error detection scheme, the data is divided into k segments each of m bits.
In the sender’s end the segments are added using 1’s complement arithmetic to get the
sum. The sum is complemented to get the checksum.
The checksum segment is sent along with the data segments.
At the receiver’s end, all received segments are added using 1’s complement arithmetic to
get the sum. The sum is complemented.
If the result is zero, the received data is accepted; otherwise discarded.
4. Cyclic redundancy check (CRC)
•Unlike checksum scheme, which is based on addition, CRC is based on 
binary division. 
•In CRC, a sequence of redundant bits, called cyclic redundancy check bits, 
are appended to the end of data unit so that the resulting data unit becomes 
exactly divisible by a second, predetermined binary number. 
•At the destination, the incoming data unit is divided by the same number. If 
at this step there is no remainder, t
he data unit is assumed to be correct and is therefore accepted. 
•A remainder indicates that the data unit has been damaged in transit and the
refore must be rejected. 
  

You might also like