xref: /onnv-gate/usr/src/uts/common/netinet/tcp_timer.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * Copyright (c) 1982, 1986 Regents of the University of California.
3*0Sstevel@tonic-gate  * All rights reserved.
4*0Sstevel@tonic-gate  *
5*0Sstevel@tonic-gate  * Redistribution and use in source and binary forms are permitted
6*0Sstevel@tonic-gate  * provided that the above copyright notice and this paragraph are
7*0Sstevel@tonic-gate  * duplicated in all such forms and that any documentation,
8*0Sstevel@tonic-gate  * advertising materials, and other materials related to such
9*0Sstevel@tonic-gate  * distribution and use acknowledge that the software was developed
10*0Sstevel@tonic-gate  * by the University of California, Berkeley.  The name of the
11*0Sstevel@tonic-gate  * University may not be used to endorse or promote products derived
12*0Sstevel@tonic-gate  * from this software without specific prior written permission.
13*0Sstevel@tonic-gate  */
14*0Sstevel@tonic-gate 
15*0Sstevel@tonic-gate /*
16*0Sstevel@tonic-gate  * Definitions of the TCP timers.  These timers are counted
17*0Sstevel@tonic-gate  * down PR_SLOWHZ times a second.
18*0Sstevel@tonic-gate  */
19*0Sstevel@tonic-gate 
20*0Sstevel@tonic-gate #ifndef	_NETINET_TCP_TIMER_H
21*0Sstevel@tonic-gate #define	_NETINET_TCP_TIMER_H
22*0Sstevel@tonic-gate 
23*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
24*0Sstevel@tonic-gate /* tcp_timer.h 1.13 89/06/16 SMI; from UCB 7.6 6/29/88 */
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate #ifdef	__cplusplus
27*0Sstevel@tonic-gate extern "C" {
28*0Sstevel@tonic-gate #endif
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #define	TCPT_NTIMERS	4
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #define	TCPT_REXMT	0		/* retransmit */
33*0Sstevel@tonic-gate #define	TCPT_PERSIST	1		/* retransmit persistance */
34*0Sstevel@tonic-gate #define	TCPT_KEEP	2		/* keep alive */
35*0Sstevel@tonic-gate #define	TCPT_2MSL	3		/* 2*msl quiet time timer */
36*0Sstevel@tonic-gate 
37*0Sstevel@tonic-gate /*
38*0Sstevel@tonic-gate  * The TCPT_REXMT timer is used to force retransmissions.
39*0Sstevel@tonic-gate  * The TCP has the TCPT_REXMT timer set whenever segments
40*0Sstevel@tonic-gate  * have been sent for which ACKs are expected but not yet
41*0Sstevel@tonic-gate  * received.  If an ACK is received which advances tp->snd_una,
42*0Sstevel@tonic-gate  * then the retransmit timer is cleared (if there are no more
43*0Sstevel@tonic-gate  * outstanding segments) or reset to the base value (if there
44*0Sstevel@tonic-gate  * are more ACKs expected).  Whenever the retransmit timer goes off,
45*0Sstevel@tonic-gate  * we retransmit one unacknowledged segment, and do a backoff
46*0Sstevel@tonic-gate  * on the retransmit timer.
47*0Sstevel@tonic-gate  *
48*0Sstevel@tonic-gate  * The TCPT_PERSIST timer is used to keep window size information
49*0Sstevel@tonic-gate  * flowing even if the window goes shut.  If all previous transmissions
50*0Sstevel@tonic-gate  * have been acknowledged (so that there are no retransmissions in progress),
51*0Sstevel@tonic-gate  * and the window is too small to bother sending anything, then we start
52*0Sstevel@tonic-gate  * the TCPT_PERSIST timer.  When it expires, if the window is nonzero,
53*0Sstevel@tonic-gate  * we go to transmit state.  Otherwise, at intervals send a single byte
54*0Sstevel@tonic-gate  * into the peer's window to force him to update our window information.
55*0Sstevel@tonic-gate  * We do this at most as often as TCPT_PERSMIN time intervals,
56*0Sstevel@tonic-gate  * but no more frequently than the current estimate of round-trip
57*0Sstevel@tonic-gate  * packet time.  The TCPT_PERSIST timer is cleared whenever we receive
58*0Sstevel@tonic-gate  * a window update from the peer.
59*0Sstevel@tonic-gate  *
60*0Sstevel@tonic-gate  * The TCPT_KEEP timer is used to keep connections alive.  If a
61*0Sstevel@tonic-gate  * connection is idle (no segments received) for TCPTV_KEEP_INIT amount of time,
62*0Sstevel@tonic-gate  * but not yet established, then we drop the connection.  Once the connection
63*0Sstevel@tonic-gate  * is established, if the connection is idle for TCPTV_KEEP_IDLE time
64*0Sstevel@tonic-gate  * (and keepalives have been enabled on the socket), we begin to probe
65*0Sstevel@tonic-gate  * the connection.  We force the peer to send us a segment by sending:
66*0Sstevel@tonic-gate  *	<SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK>
67*0Sstevel@tonic-gate  * This segment is (deliberately) outside the window, and should elicit
68*0Sstevel@tonic-gate  * an ack segment in response from the peer.  If, despite the TCPT_KEEP
69*0Sstevel@tonic-gate  * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE
70*0Sstevel@tonic-gate  * amount of time probing, then we drop the connection.
71*0Sstevel@tonic-gate  */
72*0Sstevel@tonic-gate 
73*0Sstevel@tonic-gate #define	TCP_TTL		60		/* default time to live for TCP segs */
74*0Sstevel@tonic-gate /*
75*0Sstevel@tonic-gate  * Time constants.
76*0Sstevel@tonic-gate  */
77*0Sstevel@tonic-gate #define	TCPTV_MSL	(30*PR_SLOWHZ)		/* max seg lifetime (hah!) */
78*0Sstevel@tonic-gate #define	TCPTV_SRTTBASE	0			/* base roundtrip time; */
79*0Sstevel@tonic-gate 						/* if 0, no idea yet */
80*0Sstevel@tonic-gate #define	TCPTV_SRTTDFLT	(3*PR_SLOWHZ)		/* assumed RTT if no info */
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate #define	TCPTV_PERSMIN	(5*PR_SLOWHZ)		/* retransmit persistance */
83*0Sstevel@tonic-gate #define	TCPTV_PERSMAX	(60*PR_SLOWHZ)		/* maximum persist interval */
84*0Sstevel@tonic-gate 
85*0Sstevel@tonic-gate #define	TCPTV_KEEP_INIT	(75*PR_SLOWHZ)		/* initial connect keep alive */
86*0Sstevel@tonic-gate #define	TCPTV_KEEP_IDLE	(120*60*PR_SLOWHZ)	/* dflt time before probing */
87*0Sstevel@tonic-gate #define	TCPTV_KEEPINTVL	(75*PR_SLOWHZ)		/* default probe interval */
88*0Sstevel@tonic-gate #define	TCPTV_KEEPCNT	8			/* max probes before drop */
89*0Sstevel@tonic-gate 
90*0Sstevel@tonic-gate #define	TCPTV_MIN	(1*PR_SLOWHZ)		/* minimum allowable value */
91*0Sstevel@tonic-gate #define	TCPTV_REXMTMAX	(64*PR_SLOWHZ)		/* max allowable REXMT value */
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate #define	TCP_LINGERTIME	120			/* linger at most 2 minutes */
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate #define	TCP_MAXRXTSHIFT	12			/* maximum retransmits */
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate #ifdef	TCPTIMERS
98*0Sstevel@tonic-gate char *tcptimers[] =
99*0Sstevel@tonic-gate 	{ "REXMT", "PERSIST", "KEEP", "2MSL" };
100*0Sstevel@tonic-gate #endif
101*0Sstevel@tonic-gate 
102*0Sstevel@tonic-gate /*
103*0Sstevel@tonic-gate  * Force a time value to be in a certain range.
104*0Sstevel@tonic-gate  */
105*0Sstevel@tonic-gate #define	TCPT_RANGESET(tv, value, tvmin, tvmax) { \
106*0Sstevel@tonic-gate 	(tv) = (value); \
107*0Sstevel@tonic-gate 	if ((tv) < (tvmin)) \
108*0Sstevel@tonic-gate 		(tv) = (tvmin); \
109*0Sstevel@tonic-gate 	else if ((tv) > (tvmax)) \
110*0Sstevel@tonic-gate 		(tv) = (tvmax); \
111*0Sstevel@tonic-gate }
112*0Sstevel@tonic-gate 
113*0Sstevel@tonic-gate #ifdef	__cplusplus
114*0Sstevel@tonic-gate }
115*0Sstevel@tonic-gate #endif
116*0Sstevel@tonic-gate 
117*0Sstevel@tonic-gate #endif	/* _NETINET_TCP_TIMER_H */
118