Time to live
lastmod 2019-09-20created 2017-01-134 edits
Time to live (TTL) is a mechanism for indicating the lifetime of data in a computer or network. TTL is included in the data in the form of a counter or timestamp, and the data is discarded once the set lifetime has elapsed. In computer networks, TTL prevents packets from circulating indefinitely. In computer applications, TTL is also used to improve cache performance or privacy levels.
IP packets
In the Internet Protocol, TTL is an 8-bit field. In the IPv4 header, TTL is the 8th of 20 octets; in the IPv6 header, it is the 8th of 40 octets. The maximum TTL value is 255, the maximum value of a single octet. The recommended initial value is 64.
The TTL value can be seen as an upper bound on the time an IP datagram can exist within an internet system. The TTL field is set by the sender of the datagram and decremented by every router on the path to its destination. If the TTL field reaches 0 before the datagram arrives at its destination, the datagram is discarded and an ICMP error datagram 11 - Time Exceeded is sent to the sender. The purpose of the TTL field is to prevent undeliverable datagrams from circulating endlessly and flooding an internet system.
In IPv4, the unit of the TTL value is seconds, and in theory the value can be decremented by 1 or more at every host it passes through on the way to the destination. In practice, however, the TTL value is decremented by only 1 at each hop. In light of this, the field was renamed hop limit in IPv6.