Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Keepalive
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Term in networking}} {{other uses}} {{Multiple issues| {{Technical|date=February 2024}} {{Context|date=February 2024}} }} A '''keepalive''' ('''KA''') is a message sent by one device to another to check that the [[Data link|link]] between the two is operating, or to prevent the link from being broken. ==Description== Once a TCP connection has been established, that connection is defined to be valid until one side closes it. Once the connection has entered the connected state, it will remain connected indefinitely. But, in reality, the connection will not last indefinitely. Many firewall or NAT systems will close a connection if there has been no activity in some time period. The Keep Alive signal can be used to trick intermediate hosts to not close the connection due to inactivity. It is also possible that one host is no longer listening (e.g. application or system crash). In this case, the connection is closed, but no <code>FIN</code> was ever sent. In this case, a KeepAlive packet can be used to interrogate a connection to check if it is still intact. A keepalive signal is often sent at predefined intervals, and plays an important role on the [[Internet]]. After a signal is sent, if no reply is received, the [[Data link|link]] is assumed to be down and future data will be routed via another path until the link is up again. A keepalive signal can also be used to indicate to Internet infrastructure that the connection should be preserved. Without a keepalive signal, intermediate [[Network address translation|NAT-enabled routers]] can drop the connection after timeout. Since the only purpose is to find links that do not work or to indicate connections that should be preserved, keepalive messages tend to be short and not take much [[Bandwidth (computing)|bandwidth]]. However, their precise format and usage terms depend on the communication protocol. ==TCP keepalive== [[Transmission Control Protocol]] (TCP) keepalives are an optional feature, and if included must default to off.<ref>{{cite journal|url=http://tools.ietf.org/html/rfc1122#page-101|journal=IETF|title=Requirements for Internet Hosts - Communication Layers|date=October 1989|accessdate=November 8, 2013|last1=Braden|first1=Robert T.|editor-first1=R. |editor-last1=Braden |doi=10.17487/RFC1122 |doi-access=free}}</ref> The keepalive packet contains no data. In an [[Ethernet]] network, this results in frames of minimum size (64 bytes<ref name="IEEE 802.3 Clause 3.1.1">{{cite book | publisher = IEEE Standard for Ethernet, 802.3-2015 โ section one | year = 2016 | page = 108 | doi = 10.1109/IEEESTD.2016.7428776 | isbn = 978-1-5044-0078-7 | title = IEEE Standard for Ethernet }}</ref>). There are three parameters<ref>{{Cite web|url=http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/usingkeepalive.html|title=Using TCP keepalive under Linux|website=tldp.org|access-date=2016-07-29}}</ref> related to keepalive: * '''Keepalive time''' is the duration between two keepalive transmissions in idle condition. TCP keepalive period is required to be configurable and by default is set to no less than 2 hours. * '''Keepalive interval''' is the duration between two successive keepalive retransmissions, if acknowledgement to the previous keepalive transmission is not received. * '''Keepalive retry''' is the number of retransmissions to be carried out before declaring that remote end is not available When two hosts are connected over a network via TCP/IP, TCP Keepalive Packets can be used to determine if the connection is still valid, and terminate it if needed. Most hosts that support TCP also support TCP Keepalive. Each host (or peer) periodically sends a TCP packet to its peer which solicits a response. If a certain number of keepalives are sent and no response (ACK) is received, the sending host will terminate the connection from its end. If a connection has been terminated due to a TCP Keepalive time-out and the other host eventually sends a packet for the old connection, the host that terminated the connection will send a packet with the RST flag set to signal the other host that the old connection is no longer active. This will force the other host to terminate its end of the connection so a new connection can be established. Typically, TCP Keepalives are sent every 45 or 60 seconds on an idle TCP connection, and the connection is dropped after 3 sequential ACKs are missed. This varies by host, e.g. by default, Windows PCs send the first TCP Keepalive packet after 7200000ms (2 hours), then send 5 Keepalives at 1000ms intervals, dropping the connection if there is no response to any of the Keepalive packets. Linux hosts send the first TCP Keepalive packet after 2 hours (default since Linux 2.2), then send 9 Keepalive probes (default since Linux 2.2) at 75 seconds (default since Linux 2.4) intervals, dropping the connection if there is no response to any of the Keepalive packets.<ref>{{cite web|url=https://man7.org/linux/man-pages/man7/tcp.7.html|title=tcp(7) - Linux manual page|accessdate=August 14, 2024}}</ref> ==Keepalive on higher layers== Since TCP keepalive is optional, various protocols (e.g. SMB<ref>{{cite journal|url=https://tools.ietf.org/html/rfc1001#page-54|journal=IETF|title=Protocol Standard for a NetBIOS Service on a TCP/UDP Transport: Concepts and Methods|date=March 1987|doi=10.17487/RFC1001 |accessdate=June 18, 2015<!-- |last2=Board |first2=Internet Activities |last3=Force |first3=End-to-End Services Task --> |url-access=subscription}}</ref> and TLS<ref>{{cite journal|url=https://tools.ietf.org/html/rfc6520|journal=IETF|title=Transport Layer Security (TLS) and Datagram Transport Layer Security (DTLS) Heartbeat Extension|date=February 2012|accessdate=June 18, 2015|last1=Williams|first1=Michael|last2=Tรผxen|first2=Michael|last3=Seggelmann|first3=Robin|doi=10.17487/RFC6520 |url-access=subscription}}</ref>) implement their own keep-alive feature on top of TCP. It is also common for protocols which maintain a session over a connectionless protocol, e.g. OpenVPN over UDP,<ref>{{cite web|url=https://community.openvpn.net/openvpn/wiki/Openvpn23ManPage|title=OpenVPN manual page|accessdate=June 18, 2015}}</ref> to implement their own keep-alive. ==Other uses== ===HTTP keepalive=== {{main|HTTP persistent connection}} The [[Hypertext Transfer Protocol]] uses the keyword "Keep-Alive" in the "Connection" header to signal that the connection should be kept open for further messages (this is the default in HTTP 1.1, but in HTTP 1.0 the default was to use a new connection for each request/reply pair).<ref>{{cite web |url=http://www.io.com/~maus/HttpKeepAlive.html |archiveurl=https://web.archive.org/web/20100813132504/http://www.io.com/~maus/HttpKeepAlive.html |archivedate=2010-08-13 |title=HTTP Keep Alive discourse by Jim Driscoll}}</ref> Despite the similar name, this function is entirely unrelated. ==See also== * [[Network switch|Switch]] * [[Watchdog timer]] * [[Hole punching (networking)|Hole punching]] * [[UDP hole punching]] * [[Warrant canary]] * [[Ping test]] ==References== {{reflist}} [[Category:Computer networking]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite book
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite web
(
edit
)
Template:Main
(
edit
)
Template:Multiple issues
(
edit
)
Template:Other uses
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)