Regarding Keep-Alive doubt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



   Hi Linux Pals,


   We have a tcp keepalive options in the kernel, like when i do "cat /proc/sys/

   net.ipv4.tcp_keepalive_time"   = 7200 (sec)
   net.ipv4.tcp.keepalive_probes" = 9 


   What i understand is that kernel's default time to keep the connection live is 2 hours and kernel sends total
   of 9 packets in interval of 12 minutes and 15 seconds before assuming the connection is dead.

   As far as i belived that we use keep Alive at application level (HTTP).  i.e if client request the connection to be kept alive,
   this is implemented in the server and then accordinging we close the socket.
   But this says that before assuming the connection is dead, kernel probes 9 times in the duration of 2 hours and then if 
   there is no response, kernel closes the socket.

   Now , i  reduce tcp_keepalive_time to 5 minutes and tcp_keepalive_probes to 2
   (using sysctl) and put sleep of 10 minutes in client,  the connected server-client socket (on the server side) 
   shud be closed in 5 minutes, Right !!, as i have set the value(of 5 minutes) and there is no data written or read on
   the connected socket (in the 5 minutes interval, v.i.z.,client is sleeping).

   And the client shud be sent "RST" ----- connection reset by host, on trying to write data 
   on the connected fd (descriptor).

   This does not happen. the kernel does not close the socket and the connection is maintained, It serves the next 
   request on the same  connection.

   I even waited for 2 hours to check what happens if default values are used, v.i.z. the client slept for more than 2 hours
   before sending the second request on same connection.
   Again the request is served by same connection, on same socket.
   
   Then what is the significance of these 2 hours set in kernel ?

   I also got some piece of information from below URL which i am pasting here.

   Reference : http://archive.lug.boulder.co.us/bymonth/1998.12/msg00371.html

   **************************************************************************

   From Nov 98 IETF "Known TCP Implementation Problems" draft:
    http://ftp.ietf.org/internet-drafts/draft-ietf-tcpimpl-prob-05.txt
        Name of Problem:    Insufficient interval between keepalives...
        Keep-alive is a mechanism for checking whether an  idle  connection
        is  still alive.  According to RFC-1122, keep-alive may be included
        in an implementation.  If it  is  included,  the  interval  between
        keep-alive  packets  MUST  be  configurable, and MUST default to no
        less than two hours.

      Name of Problem: Excessively short keepalive connection timeout...
        RFC-1122 also specifies that if a keep-alive mechanism is
        implemented it MUST NOT interpret failure to respond to any
        specific probe as a dead connection.  The RFC does not specify a
        particular mechanism for timing out a connection when no response
        is received for keepalive probes.  However, if the mechanism does
        not allow ample time for recovery from network congestion or delay,
        connections may be timed out unnecessarily.


   Correct implementation: 11 minutes, 75 second intervals, 9 packets]

   **************************************************************************

   If any one could clear this confusion to me , it wud be very helpful.

   Regards,
   Vishal.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux