IP - When is the TTL decremented in a router

Time to live is a field found within the header of IPv4 and IPv6 routers used to ensure that IP packets do not continuously roam the network forever if there is some misconfiguration or network fault.

According to the RFC for IPv4, the "This field must be decreased at each point that the internet header is processed to reflect the time spent processing the datagram." So TTL is decremented whenever the header is processed.

Transient traffic

For traffic that is not destined to the router itself (transient traffic), when an IP packet traverses a router, processing takes place after ingress and before egress, that is, when routing decisions are being made. The order of operations of when the TTL is decremented is as follows:

  1. When a Router Receives the Packet, it will check the packet header, including the TTL field. If it is not zero, it will continue to process the packet. If it is zero, it will drop the packet.
  2. When It Processes the Packet, the router decrements the TTL field by one. This decrement happens before the router makes a decision about where to forward the packet next.
  3. Just Before Egress, the decremented TTL value is used for routing decisions. If the TTL reaches zero after decrementing, the packet is discarded to prevent it from looping indefinitely in the network.

Thus, the TTL is decremented when the router processes the packet, which is after it is received and before it is forwarded (egress).

Traffic destined for the router

If a packet with a Time to Live (TTL) value of 1 arrives at a router, and the destination address of the packet corresponds to another interface of the same router, the behavior depends on the specific scenario and router configuration:

  1. Packet Destined for the Router Itself: If the destination address of the packet is the IP address of the router itself (one of its own interfaces), the packet is meant to be processed by the router. In this case, the TTL decrement occurs as the packet is processed, but since the packet has reached its destination (the router itself), it doesn't need to be forwarded. Therefore, the TTL decrement doesn't lead to the packet being discarded, and the router processes it normally.
  2. Routing with TTL Decrement: In a more general routing scenario, when a router receives a packet, it decrements the TTL by 1 before making a routing decision. If the decremented TTL reaches 0, the router discards the packet and typically sends an ICMP Time Exceeded message back to the sender. However, in the specific case where the packet's destination is another interface of the same router, it's a matter of how the router's software handles this situation. In many cases, routers are designed to treat packets destined for themselves differently from those being forwarded. - If the router's software is configured or designed to decrement the TTL for packets destined to its own interfaces, then a packet with a TTL of 1 would be discarded after the TTL decrement. - If the router treats packets destined for itself differently and does not decrement the TTL, the packet would be processed normally.
  3. Directly Connected Networks: If the packet's destination is on a network directly connected to the router but not the router's interface itself (like a device on a LAN connected to the router), the router will decrement the TTL. If the TTL reaches 0, the packet will be discarded.

https://forum.networklessons.com/t/traceroute/1433/67?u=lagapidis

https://datatracker.ietf.org/doc/html/rfc791#page-30

https://networklessons.com/cisco/ccna-200-301//traceroute

Links to this page: