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