Tcp retransmission queue

cnetworkingtcp

I'm trying to understand how tcp retransmission queue works so I can implement it in my application that uses TCAP over SCTP.
What I understood from the TCP queue is that every message is saved in retransmission queue with with a time, when the timer reaches 0 the message will be sent again.

My question is how to check the time on that message, is it like a thread that constantly checks the retransmission queue or is it something else?

Best Answer

Here is how TCP retransmision queue works:

Every packet has a sequence number. After A sends 1 or more packets to B, B responds with an acknowledge packet and the last sequence number that was received correctly. A then begins sending from the next sequence number. There is no need to keep any other packets that B already acknowledged. Here is an example:

  1. A -> B packets 1,2,3,4,5
  2. B -> A Ack 5
  3. A -> B packets 6,7,8,9
  4. Packet 8 was missing (or in error), so B -> A Ack 7. (B also discards packet 9)
  5. A -> B 8,9,10,11

Etc. This guarantees delivery in sequence.

The time to live (TTL) is a counter that is decremented every time the packet is re-transmitted. After the TTL is decremented to "0", the packet is no longer forwarded.

Sequence numbers wrap after 32767. When closing a listening port, in order to make sure there are no stray packets which could arrive at a listening port in error, the OS will usually mark a listening port as [TIMEWAIT] for 2 minutes because the TTL is expected to go to "0" for all inbound packets for that port by then.

Related Topic