To add to the previous answer:
A "Cumulative ACK" implies that all the bytes sent by the sender (so far) have been received correctly by the receiver. In order words, when the sender receives an ACK with sequence number n
, the receiver is telling the sender that it has received every byte up to and including n-1
and it is expecting byte n
next.
In "selective ACKs", the receiver sends ACKs for every packet that it has received, regardless of whether it was the packet that the receiver was expecting or not (i.e. whether the packet was out-of-order or not).
E.g. Let's assume that sender S sends 3 packets: pkt1
(seq # = 100), pkt2
(seq # = 200), and pkt3
(seq # = 300), but pkt2
gets lost in transmission.
With GBN: When the receiver R gets pkt1
: It sends ACK=200
, telling the sender that it has received all the bytes up to (but not including) 200 and is expecting byte 200 next. Now, pkt2
got lost, but pkt3
was received by the receiver. So, the receiver will send ACK=200 again and drop pkt3
because it is out-of-order. S will then have to re-transmit pkt2
AND pkt3
.
Once pkt2
is retransmitted and successfully received, R will send ACK=300 (i.e. it has received everything up to, but not including, byte 300 and is expecting byte 300, i.e. pkt3
). Once pkt3
is transmitted successfully, it will ACK that too.
With Selective Repeat (SR): Once R receives pkt1
, it will send an ACK for it. Once it receives pkt3
, it will send an ACK specifically for this packet too and will NOT drop the packet even though pkt3
is out-of-order (it will buffer it). Eventually, pkt2
will timeout on the sender's end, so the sender will retransmit pkt2
. If it's successful the receiver will send an ACK for it too.
Notice that, with SR, you didn't have to retransmit pkt3
even though pkt2
was lost. This is beneficial because it prevents the sender from having to retransmit the packets that had already been successfully received by the receiver (it's pointless, right? Why send pkt3
again when it was already delivered?). This helps avoid congestion in the network because you're not constantly retransmitting packets that DON'T need to be retransmitted.
In general, TCP's congestion control can be described as a combination/hybrid of GBN and Selective Repeat. Here's why:
TCP is similar to GBN because both protocols have a limit on the number of
unACK'd packets that the sender can send into the network. However, TCP is different from GBN because GBN requires the re-transmission of every unACK'd
packet when packets are lost, but TCP only retransmits the oldest unACK'd one.
TCP is similar to selective repeat because, when packets are lost due to congestion, the protocols do not require the sender to retransmit EVERY unACK'd packet sent by the sender. The sender just retransmits the oldest unACK'd packet. TCP is different from selective repeat because SR requires individual acknowledgement of each packet that was sent by the receiver; but rather than selectively ACKing every packet, TCP sends an ACK for the next packet that it is expecting (like GBN) and buffers the ones that it has received so far, even if they're out of order (like SR). That's why it can be considered a hybrid.
Hope this helps.