Jump to content

Time to live

From Wikipedia, the free encyclopedia
(Redirected fromTime-to-live)

Time to live(TTL) orhop limitis a mechanism which limits the lifespan or lifetime of data in a computer or network. TTL may be implemented as acounterortimestampattached to or embedded in the data. Once the prescribed event count or timespan has elapsed, data is discarded or revalidated. Incomputer networking,TTL prevents a data packet from circulating indefinitely. Incomputingapplications, TTL is commonly used to improve the performance and manage thecachingof data.

Description

[edit]

The originalDARPAInternet Protocol'sRFCdescribes[1]: §1.4 TTL as:

The Time to Live is an indication of an upper bound on the lifetime of an internetdatagram.It is set by the sender of the datagram and reduced at the points along the route where it is processed. If the time to live reaches zero before the internet datagram reaches its destination, the internet datagram is destroyed. The time to live can be thought of as a self destruct time limit.

IP packets

[edit]

Under theInternet Protocol,TTL is an 8-bit field. In theIPv4 header,TTL is the 9thoctetof 20. In theIPv6 header,it is the 8th octet of 40. The maximum TTL value is 255, the maximum value of a single octet. A recommended initial value is 64.[2][3]

The time-to-live value can be thought of as an upper bound on the time that an IPdatagramcan exist in an Internet system. The TTL field is set by the sender of the datagram, and reduced by everyrouteron the route to its destination. If the TTL field reaches zero before the datagram arrives at its destination, then the datagram is discarded and anInternet Control Message Protocol(ICMP) error datagram (11 - Time Exceeded) is sent back to the sender. The purpose of the TTL field is to avoid a situation in which an undeliverable datagram keeps circulating on an Internet system, and such a system eventually becoming swamped by such "immortals".

In theory, underIPv4,time to live is measured in seconds, although every host that passes the datagram must reduce the TTL by at least one unit. In practice, the TTL field is reduced by one on everyhop.To reflect this practice, the field is renamedhop limitinIPv6.

DNS records

[edit]
TTL of a DNS answer resolving google, seen inWireshark

TTLs also occur in theDomain Name System(DNS), where they are set by anauthoritative name serverfor a particular resource record. When a caching (recursive)nameserverqueries the authoritative nameserver for a resource record, it will cache that record for the time (in seconds) specified by the TTL. If astub resolverqueries the caching nameserver for the same record before the TTL has expired, the caching server will simply reply with the already cached resource record rather than retrieve it from the authoritative nameserver again. TTL for NXDOMAIN (non-existent domain) responses is set from the minimum of the MINIMUM field of theSOArecord and the TTL of the SOA itself, and indicates how long a resolver may cache the negative answer.[4][jargon]

Shorter TTLs can cause heavier loads on an authoritative name server, but can be useful when changing the address of critical services likeweb serversorMX records,and therefore are often lowered by the DNS administrator prior to a service being moved, in order to reduce possible disruptions.

The units used are seconds. An older common TTL value for DNS was 86400 seconds, which is 24 hours. A TTL value of 86400 would mean that, if a DNS record was changed on the authoritative nameserver, DNS servers around the world could still be showing the old value from their cache for up to 24 hours after the last update by client.

Newer DNS methods that are part of adisaster recovery(DR) system may have some records deliberately set extremely low on TTL. For example, a 300-second TTL would help key records expire in 5 minutes to help ensure these records are flushed quickly worldwide. This gives administrators the ability to edit and update records in a timely manner. TTL values are "per record" and setting this value on specific records is sometimes honored automatically by all standard DNS systems worldwide. However, a problem persists in that some caching DNS nameservers set their own TTLs regardless of the authoritative records, thus it cannot be guaranteed that all downstream DNS servers have the new records after the TTL has expired.

HTTP

[edit]

Time to live may also be expressed as the date and time on which a record expires. TheExpires:header in HTTP responses,theCache-Control: max-ageheader field in both requests and responses and theexpiresfield in HTTP cookiesexpress time-to-live in this way.

See also

[edit]

References

[edit]
  1. ^J. Postel,ed. (September 1981).INTERNET PROTOCOL - DARPA INTERNET PROGRAM PROTOCOL SPECIFICATION.IETF.doi:10.17487/RFC0791.STD 5.RFC791.IEN 128, 123, 111, 80, 54, 44, 41, 28, 26.Internet Standard 5.ObsoletesRFC760.Updated byRFC1349,2474and6864.
  2. ^"Default TTL Values in TCP/IP".Archived fromthe originalon 2013-02-12.Retrieved2013-02-19.
  3. ^"IP OPTION NUMBERS".2012-11-30.Retrieved2013-02-19.The current recommended default time to live (TTL) for the Internet Protocol (IP) is 64 [RFC791], [RFC1122].
  4. ^<[email protected]>, Mark Andrews (1998)."Negative Caching of DNS Queries (DNS NCACHE)".tools.ietf.org.doi:10.17487/RFC2308.Retrieved2018-11-12.
[edit]