Diagnose Network by TTL Value

Unicorn tutorials

What is the TTL?

Under the Internet Protocol, TTL is an 8-bit field. In the IPv4 header, TTL is the 9th octet of 20. In the IPv6 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.

The time-to-live value can be thought of as an upper bound on the time that an IP datagram can exist in an Internet system. The TTL field is set by the sender of the datagram, and reduced by every router on the route to its destination. If the TTL field reaches zero before the datagram arrives at its destination, then the datagram is discarded and an 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, under IPv4, 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 every hop. To reflect this practice, the field is renamed hop limit in IPv6.

Various causes will lead to packets transmission failure to the destination in a specific time period. For instance, wrong routing table configuration may cause packet endless loop. The solution is to drop the packet after a period of time and then send a message to the sender and let it decide whether to retransmit the packet. When this happens, the packet will be retransmitted at the router which is wrongly configured in the routing table. TTL value will be deducted by 1 upon each retransmission until TTL becomes zero when the packet is dropped by the router, which causes transmission error in the network.

Default TTL value varies depending on the difference of the operating system and transmission protocol. Here I listed the default TTL values in TCP and UDP under common operating systems in table 1:

Operating systemTCPUDP
AIX6030
DEC Patchworks V53030
FreeBSD 2.16464
HP/UX 9.0x3030
HP/UX 10.016464
Irix 5.36060
Irix 6.x6060
UNIX255255
Linux6464
MacOS/MacTCP 2.0.x6060
OS/2 TCP/IP 3.06464
OSF/1 V3.2A6030
Solaris 2.x255255
SunOS 4.1.3/4.1.46060
Ultrix V4.1/V4.2A6030
VMS/Multinet6464
VMS/TCPware6064
VMS/Wollongong 1.1.1.112830
VMS/UCX (latest rel.)128128
MS Windows 95/98/NT 3.513232
Windows NT 4.0/2000/XP/2003 Server128128

Table 1: Default TTL Value under Different Operating Systems

View TTL value of packets and analyze transmission error

When transmission error occurs in the network, we can view the TTL value of packets with Unicorn and determine whether the error is resulted from wrong routing configuration or other possible reasons in combination of the above table. See the figure below:

As we can see from figure 1, TTL is 47. With the list TTL value above, we can determine the packets passed through 255-47=208 routers from the source to the destination machine, and the transmission is normal.

  • Notice:
  1. To determine how many routers a packet passed, you can deduct the TTL value of the packet you captured from the default TTL value of the source device.
  2. If you don’t know the default TTL value of the source device, you can use the default TTL value which is lager than and most close to the TTL value of the packet;
  3. The peak TTL value is 255 as TTL field size is 1 byte.
Conclusion

If TTL value of the packets captured is too small, it indicate there may be a transmission error in the network. By checking the TTL value we can find out whether the network is normal or not.

Share this