Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does TCP endpoint that has sent a FIN, still send keepalive?

Tags:

networking

tcp

Sending a FIN is an indication that the end won't send any data. But can it send TCP keepalive?

If it can then it contradicts the statement of "sending stuff after FIN" even though it is keepalive but not data.

If it doesn't send keepalive, it won't detect if the other end is gone.

For ex:

Client send FIN and got ACK back. Server then sent a reset which was lost. Only way the client can detect that server has gone away is by sending keepalive which will be responded with reset and then the client closes.

Does this happen?

like image 954
Nikhil Avatar asked Aug 07 '13 17:08

Nikhil


People also ask

Does a TCP socket connection have a keep alive?

The SO_KEEPALIVE socket option is valid only for protocols that support the notion of keep-alive (connection-oriented protocols). For TCP, the default keep-alive timeout is 2 hours and the keep-alive interval is 1 second. The default number of keep-alive probes varies based on the version of Windows.

Who sends TCP keepalive?

Client-side keepalive: Clients sends TCP keepalive to prevent the server from closing the TCP connection to the client. Both-side keepalive: Both server and clients send TCP keepalive as described in 1 and 2.

How does TCP keep alive work?

The keepalive concept is very simple: when you set up a TCP connection, you associate a set of timers. Some of these timers deal with the keepalive procedure. When the keepalive timer reaches zero, you send your peer a keepalive probe packet with no data in it and the ACK flag turned on.

How long TCP keep alive?

A TCP Keep-Alive, originally defined in Request for Comments (RFC) 1122, is an empty TCP segment intended to cause the peer to send an ACK. The default is 1800 seconds. Note: For more information about TCP keep alive, refer to the Internet Engineering Task Force (RFC 1122).


1 Answers

According to RFC-1122:

Keep-alive packets MUST only be sent when no data or acknowledgement packets have been received for the connection within an interval.

Sending FIN is only an indication that no more data will be sent, not that no more data can be received. If the application after sending FIN is still expecting data, the RFC indicates it can send a keep-alive packet to make sure the other end is still there.

like image 109
jxh Avatar answered Oct 03 '22 14:10

jxh