[net.unix-wizards] Time to live values for IP networks.

martin@sabre.UUCP (Martin Levy) (02/28/85)

I'm looking for infomation about the correct values for the Time to
live (TTL) in the IP world.
We have constructed a network with 4.2 machines as gateways, both Vaxen
and Sun's, soon to replaced with real gateway machines. The problem is
to do with the initial value of the TTL field and the amount you should
decrement it by when passing thru a Gateway. The 4.2 code is ment to run
as a gateway, but these are the defines and code for dealing with TTL.

$ grep TTL /sys/netinet/ip.h:
#define	MAXTTL		255		/* maximum time to live (seconds) */
#define	IPTTLDEC	1		/* subtracted when forwarding */

$ grep TTL /sys/netinet/tcp_timer.h:
#define	TCP_TTL		15		/* time to live for TCP segs */

$ cat /sys/netinet/ip_output.c
...
	if (ip->ip_ttl < IPTTLDEC) {
		type = ICMP_TIMXCEED, code = ICMP_TIMXCEED_INTRANS;
		goto sendicmp;
	}
	ip->ip_ttl -= IPTTLDEC;
...

$ cat /sys/netinet/tcp_output.c:
...
	((struct ip *)ti)->ip_ttl = TCP_TTL;

$ cat /sys/netinet/tcp_subr.c:
...
	((struct ip *)ti)->ip_ttl = TCP_TTL;

$ cat /sys/netinet/udp_usrreq.c:
...
	((struct ip *)ui)->ip_ttl = MAXTTL;

As you can see the ip_ttl field is set to two different values for UDP
or TCP. the decrement values are in ip_input, and it's set to 15.

whats should the correct vaules be, should UDP and TCP packets have the
same start values?

what are the values used in other network protocols.

martin.

lwa@mit-mrclean (Larry Allen) (03/01/85)

In my opinion TTL should always be set to the maximum value.  It's only
real purpose is to prevent packets from looping when the gateways are
confused about routing (eg. when a gateway has gone down and the other
gateways are in the process of changing their routing information).
					-Larry Allen

ron@BRL-TGR (Ron Natalie) (03/01/85)

Every module that processes a packet should decrement time to live by
the number of seconds that it has the packet (minimum of 1 if less than
one second).  What a counts as a module is unclear.  In the gateways
we use, I decrement it once on the way in, and if the packet is not
for the gateway itself, once on the way out.


You just pick a time to live value that you think is reasonable to get
it to the destination.  Note that the old 4.1 TCP code used to decrement
ttl by 5 on input and output.  This seemed a little excessive.

-Ron

lwa@mit-mrclean (Larry Allen) (03/02/85)

Sorry, Ron, but I have to disagree that you 'just pick a time to live value
that you think is reasonable'.  The Internet is growing every day; in my
opinion choosing a value out of the air is just going to lead to hard-to-find
bugs later.  I'd strongly argue for always running with
time-to-live = 255.

I'm not sure, but I think the only time TTL needs to be decremented is
when a packet passes through a gateway.
					-Larry Allen

ron@BRL-TGR (Ron Natalie) (03/03/85)

You obviously consider that a reasonable value.  On systems connected via
a high speed local net, where the Internet doesn't come in to it, a smaller
TTL may be more appropriate.

-Ron