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