Different Timers in TCP

We know that Transport layer is one of the most important layer in both OSI Reference model and TCP/IP Model, which allows end-to-end communication between source and destination.

TCP(Transmission Control Protocol) is a reliable byte oriented transport port-to-port protocol. TCP service is obtained by having sockets at the sender and receiver. TCP has certain kinds of Timer Management for smooth data transmission starting from connection establishment to closing a connection.

TCP Timer Management:

TCP Uses four timers

  1. Keep Alive Timer(KAT)

  2. Persistent Timer(PT)

  3. Timed Wait Timer(TWT)

  4. Retransmission Timer(RT)

1. Keep Alive Timer(KAT)

KAT is used in some implementation to prevent a long idle connection between two TCPs. Suppose that a client opens a TCP connection to a server, transfers some data, and become silent. Perhaps, the client has crashed. In this case, the connection remains open forever.

To remedy this situation, most implementations equip a server with a KAT. Each time the server hears from a client, it resets this timer. The time out is usually 2Hrs. If the server does not hear from the client after 2 hr, it sends a probe segment. If there is no response after 10 probes, each of which is 75sec apart, it assumes that the client is down and terminates the connection.

2. Persistent Timer(PT)

To deal with the zero window-size advertisement, TCP needs another timer. Suppose the receiving TCP announces a window size of zero. The sending TCP then stops transmitting segments until the receiving TCP sends an acknowledgement announcing a non-zero window size. This acknowledgement can be lost. As we know that, Acknowledgements are not not acknowledged in TCP. Now Receiving TCP thinks that it has done it's job and waits for the sending TCP to send more segments. Sending TCP has not received an acknowledgement and waits for the receiver TCP to send an acknowledgement(which was lost) advertising the size of the window. Both TCPs now in deadlock.

To correct this deadlock, TCP uses a PT for each connection. When the sending TCP receives an acknowledgement with a window size of zero, it starts a PT. When the PT goes off, the sending TCP sends a special segment called a probe. This segment contains only one byte of data. It has a sequence number, but it's sequence number is never acknowledged(It's even ignored in calculating the sequence number for the rest of the data). The probe alters the receiving TCP that the acknowledgement was lost and should be resent.

The value of the PT is set to the value of the Retransmission Time. However, if a response is not received from the receiver, another probe alters segment is sent and the value of the PT is doubled and Reset. The sender continues sending the probe and doubling and resetting the value of the PT until the value reaches a threshold(usually 60sec). After that, the sender sends one probe segment every 60sec until the window is received.

3. Time - Waited Timer(TWT)

The TWT is used during connection termination. When TCP closes a connection, it does not consider the connection really closed. The connection is held in waiting state(limbo) for a Time-waited period. This allows duplicate FIN segments, if any, to arrive at the destination to be discarded. The Value of this timer is usually 2 times the expected lifetime of a segment.

4. Retransmission Timer(RT)

To control a lost or discarded segment, TCP employs a RT that handles the retransmission time, the waiting time for an acknowledgement of a segment. It creates a retransmission timer for that particular segment.

Two situations may occur:

a) If an ACK is received for this particular segment before the timer goes off, the timer is destroyed.

b) If the timer goes off before the ACK arrives, the segment is retransmitted and the timer is reset.

Even for one single connection,the retransmission time should not be fixed. A connection may be able to send segment and receive ACKs faster during non-traffic periods than during congested periods. TCP uses a dynamic retransmission time, a transmission time that is different for each connection and which may change during the same connection.

Thank you for reading till the end. Hope it helps.

Keep Learning....