Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I do a ping, I can see the TTL value for each packet. For every router that I insert in between my computer and the router that connects to the internet, the TTL value goes down by one. However, inserting a switch or a hub does not have any effect on the TTL value. Why is that?

share|improve this question
add comment

2 Answers

up vote 15 down vote accepted

TTL is part of the IPv4 protocol (on v6 it is called "Hop Limit", as per Steven Monday's comment). Switches and hubs operate on a different layer of the ISO/OSI model (layer 2 as opposed to layer 3 - there do exist so-called layer 3 switches, but I assume you're not asking about them as you include hubs as well).

The TTL field is set by the sender of the datagram, 
and reduced by every host on the route to its destination.

http://en.wikipedia.org/wiki/Time_to_live

A switch or hub isn't a host on the IP protocol sense - they usually don't have IP addresses. If they do (in the case of switches) they are for management purposes and don't really take part in the actual functioning of the device. Switches work with MAC addresses instead, mapping them to ports and "routing" the packet only in the sense of sending it down the right port (hubs do much less work and send them through all ports instead). They don't inspect or alter the IP payload - you could be using other protocols as well.

http://en.wikipedia.org/wiki/ISO_model

share|improve this answer
    
Excellent answer. Just a very minor nitpick: IPv6 does not have a "Time To Live" header. Instead, it has "Hop Limit", which is equivalent to the IPv4 TTL. –  Steven Monday May 5 '11 at 15:08
    
Didn't know that! Thanks, I'll edit my answer. –  Eduardo Ivanec May 5 '11 at 15:10
    
@EduardoIvanec What is the difference between TTL and "Hop Limit" (besides the name of course)? –  Pacerier Jul 2 '12 at 20:42
    
@Pacerier: I don't know of any difference apart from the name. I'm guessing it was changed to make it clear that the original semantic from IPv4 RFCs (using TTL literally as a time field instead of the more common hop count, at least in some cases) is deprecated. –  Eduardo Ivanec Jul 7 '12 at 1:40
1  
@Pacerier: allow me to clarify. With IPv4 a router has to decrement the TTL field by at least 1, but may choose to decrement TTL by more than 1. In IPv6 the "hop limit" should always be decreased by 1 as per RFC 2460. –  Eduardo Ivanec Jul 7 '12 at 1:46
add comment

In a nutshell, Time To Live was implemented to prevent routing(OSI Layer 3) loops. That is to prevent a packet from hoping forever between the same nodes without ever reaching its destination. So only the nodes that make a routing decision for the packet decrease its TTL by one. When TTL reaches zero then the packet is dropped again only by a device making routing decisions.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.