Packet Dropping – When Hops Equal Default TTL

ipipv4ipv6ntpprotocol-theory

From my understanding, the default TTL represents the maximum number of hops allowed such that the packet may reach the host.

NTP Documentation Archive: ttl – This option is used only with broadcast server and manycast client modes. It specifies the time-to-live ttl to use on broadcast server and multicast server and the maximum ttl for the expanding ring search with manycast client packets

However, it is also mentioned in some answers that the packet is discarded if the TTL is 0 and it will never reach the host. I'm wondering what would happen when the number of hops before the packet was consumed is exactly the same as TTL_DEFAULT (e.g. TTL_DEFAULT is 2 and there are 2 hops before the packet was consumed). Will the packet reach the host, or it will be discarded?

Best Answer

A TTL of 1 restricts a packet to the local network because a hop to another network will decrement the TTL to 0, then the packet is discarded.

Every time a packet is processed, the TTL is supposed to be decremented, and then any packets with a TTL of 0 are discarded, but in practice no hosts do it that way. The original idea of TTL is actually Time to Live (in seconds), not a hop count, and each processing of the packet would decrement by the actual time used to process the packet, but the minimum decrement was 1. The idea was to keep upper-layer protocols from receiving stale or duplicate data. This is explained in RFC 791, Internet Protocol, which is for IPv4:

Time to Live

The time to live is set by the sender to the maximum time the datagram is allowed to be in the internet system. If the datagram is in the internet system longer than the time to live, then the datagram must be destroyed.

This field must be decreased at each point that the internet header is processed to reflect the time spent processing the datagram. Even if no local information is available on the time actually spent, the field must be decremented by 1. The time is measured in units of seconds (i.e. the value 1 means one second). Thus, the maximum time to live is 255 seconds or 4.25 minutes. Since every module that processes a datagram must decrease the TTL by at least one even if it process the datagram in less than a second, the TTL must be thought of only as an upper bound on the time a datagram may exist. The intention is to cause undeliverable datagrams to be discarded, and to bound the maximum datagram lifetime.

Some higher level reliable connection protocols are based on assumptions that old duplicate datagrams will not arrive after a certain time elapses. The TTL is a way for such protocols to have an assurance that their assumption is met.

When IPv6 was created, the authors understood that TTL was not being used the way it was documented. For IPv6, the TTL was changed to Hop Limit to reflect how the TTL was actually being used. See RFC 2460, Internet Protocol, Version 6 (IPv6) Specification:

Hop Limit

8-bit unsigned integer. Decremented by 1 by each node that forwards the packet. The packet is discarded if Hop Limit is decremented to zero.

-and what routers are supposed to do when receiving an IPv6 packet:

if the IPv6 Hop Limit is less than or equal to 1 {
  send an ICMP Time Exceeded -- Hop Limit Exceeded in Transit
  message to the Source Address and discard the packet
}

-and where IPv6 recognizes that the IPv4 implementations of TTL were flawed:

8.2 Maximum Packet Lifetime

Unlike IPv4, IPv6 nodes are not required to enforce maximum packet lifetime. That is the reason the IPv4 "Time to Live" field was renamed "Hop Limit" in IPv6. In practice, very few, if any, IPv4 implementations conform to the requirement that they limit packet lifetime, so this is not a change in practice. Any upper-layer protocol that relies on the internet layer (whether IPv4 or IPv6) to limit packet lifetime ought to be upgraded to provide its own mechanisms for detecting and discarding obsolete packets.


I'm wondering what would happen when the number of hops before the packet was consumed is exactly the same as TTL_DEFAULT (e.g. TTL_DEFAULT is 2 and there are 2 hops before the packet was consumed). Will the packet reach the host, or it will be discarded?

In practice, for an IPv4 packet with a TTL of 1, the packet will reach and be processed by the destination on the same LAN. For a TTL of 2, the packet will reach and be processed by a host one hop from the local LAN (second LAN). And so on.

That means if the destination of a packet with a TTL of 2 is two (router) hops from the local LAN, the second router will decrement the TTL on the packet to 0 and discard the packet before it reaches the destination (third) LAN.