Router – How network devices affect TTL

pingrouterswitchttl

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?

Best Answer

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