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 toB
,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 thatB
already acknowledged. Here is an example: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.