The sender setup is shown in fig. 2. A sender has two states: Transmit
new packet and wait for feedback packet. Once ready, it sends the message and
waits for an acknowledgement before sending the next packet. When sender sends a
packet (either new or retransmitted packet), it initiates a retransmission
timer. If no acknowledgement (either ACK or NACK) is received for the packet
before the timer expires, the sender will retransmit the packet. This technique
works well for packet loss. However, there is a possibility that packet has
been received correctly at receiver, but the acknowledgement is lost or
delayed, causing retransmission of original message. Thus receiver needs to detect and discard those
packets. To do this, a sequence number is included in each packet. Each packet
and the corresponding ACK have the same unique sequence number. Sender receives
each ACK packet and it can determine from the sequence number whether the transmission is
successful. The sequence number increases
by one whenever a new packet is sent. Both sender and receiver store a sequence
number, initially synchronized to zero. The sequence number field stores the
sender sequence number, which is either the number of packet IDs just sent (or
an acknowledged message) or if acknowledged, the number of next packet IDs to
be sent. Once sender is ready, it writes its sequence number to the packet and
changes its state to waiting for an acknowledgement. When sender
receives an acknowledgement packet, it understands that data packet has been
successfully delivered, and then triggers the queue to throw away the packet and the next
packet to be stored in the buffer. When sender receives a negative
acknowledgement (NACK), it stores that into a queue, and increases the number
of retransmissions by one. If number of retransmissions is greater than
retransmission limit, the packet will be dropped and number of retransmissions will be reset to
zero otherwise the packet will be retransmitted. Retransmission count is used
to avoid endless retransmissions. If the retransmitted packet arrives after the retransmission limit,
even if the packet arrives intact, it is regarded as useless and discarded. The
parameters are shown in Table III