1df8bae1dSRodney W. Grimes /* 2df8bae1dSRodney W. Grimes * Copyright (c) 1982, 1986, 1993 3df8bae1dSRodney W. Grimes * The Regents of the University of California. All rights reserved. 4df8bae1dSRodney W. Grimes * 5df8bae1dSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 6df8bae1dSRodney W. Grimes * modification, are permitted provided that the following conditions 7df8bae1dSRodney W. Grimes * are met: 8df8bae1dSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 9df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 10df8bae1dSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 11df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 12df8bae1dSRodney W. Grimes * documentation and/or other materials provided with the distribution. 13df8bae1dSRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 14df8bae1dSRodney W. Grimes * must display the following acknowledgement: 15df8bae1dSRodney W. Grimes * This product includes software developed by the University of 16df8bae1dSRodney W. Grimes * California, Berkeley and its contributors. 17df8bae1dSRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 18df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 19df8bae1dSRodney W. Grimes * without specific prior written permission. 20df8bae1dSRodney W. Grimes * 21df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31df8bae1dSRodney W. Grimes * SUCH DAMAGE. 32df8bae1dSRodney W. Grimes * 33df8bae1dSRodney W. Grimes * @(#)tcp_timer.h 8.1 (Berkeley) 6/10/93 347b40aa32SPaul Traina * $Id: tcp_timer.h,v 1.9 1996/06/14 17:17:32 wollman Exp $ 35df8bae1dSRodney W. Grimes */ 36df8bae1dSRodney W. Grimes 37707f139eSPaul Richards #ifndef _NETINET_TCP_TIMER_H_ 38707f139eSPaul Richards #define _NETINET_TCP_TIMER_H_ 39707f139eSPaul Richards 40df8bae1dSRodney W. Grimes /* 41df8bae1dSRodney W. Grimes * Definitions of the TCP timers. These timers are counted 42df8bae1dSRodney W. Grimes * down PR_SLOWHZ times a second. 43df8bae1dSRodney W. Grimes */ 44df8bae1dSRodney W. Grimes #define TCPT_NTIMERS 4 45df8bae1dSRodney W. Grimes 46df8bae1dSRodney W. Grimes #define TCPT_REXMT 0 /* retransmit */ 476c5e9bbdSMike Pritchard #define TCPT_PERSIST 1 /* retransmit persistence */ 48df8bae1dSRodney W. Grimes #define TCPT_KEEP 2 /* keep alive */ 49df8bae1dSRodney W. Grimes #define TCPT_2MSL 3 /* 2*msl quiet time timer */ 50df8bae1dSRodney W. Grimes 51df8bae1dSRodney W. Grimes /* 52df8bae1dSRodney W. Grimes * The TCPT_REXMT timer is used to force retransmissions. 53df8bae1dSRodney W. Grimes * The TCP has the TCPT_REXMT timer set whenever segments 54df8bae1dSRodney W. Grimes * have been sent for which ACKs are expected but not yet 55df8bae1dSRodney W. Grimes * received. If an ACK is received which advances tp->snd_una, 56df8bae1dSRodney W. Grimes * then the retransmit timer is cleared (if there are no more 57df8bae1dSRodney W. Grimes * outstanding segments) or reset to the base value (if there 58df8bae1dSRodney W. Grimes * are more ACKs expected). Whenever the retransmit timer goes off, 59df8bae1dSRodney W. Grimes * we retransmit one unacknowledged segment, and do a backoff 60df8bae1dSRodney W. Grimes * on the retransmit timer. 61df8bae1dSRodney W. Grimes * 62df8bae1dSRodney W. Grimes * The TCPT_PERSIST timer is used to keep window size information 63df8bae1dSRodney W. Grimes * flowing even if the window goes shut. If all previous transmissions 64df8bae1dSRodney W. Grimes * have been acknowledged (so that there are no retransmissions in progress), 65df8bae1dSRodney W. Grimes * and the window is too small to bother sending anything, then we start 66df8bae1dSRodney W. Grimes * the TCPT_PERSIST timer. When it expires, if the window is nonzero, 67df8bae1dSRodney W. Grimes * we go to transmit state. Otherwise, at intervals send a single byte 68df8bae1dSRodney W. Grimes * into the peer's window to force him to update our window information. 69df8bae1dSRodney W. Grimes * We do this at most as often as TCPT_PERSMIN time intervals, 70df8bae1dSRodney W. Grimes * but no more frequently than the current estimate of round-trip 71df8bae1dSRodney W. Grimes * packet time. The TCPT_PERSIST timer is cleared whenever we receive 72df8bae1dSRodney W. Grimes * a window update from the peer. 73df8bae1dSRodney W. Grimes * 74df8bae1dSRodney W. Grimes * The TCPT_KEEP timer is used to keep connections alive. If an 75df8bae1dSRodney W. Grimes * connection is idle (no segments received) for TCPTV_KEEP_INIT amount of time, 76df8bae1dSRodney W. Grimes * but not yet established, then we drop the connection. Once the connection 77df8bae1dSRodney W. Grimes * is established, if the connection is idle for TCPTV_KEEP_IDLE time 78df8bae1dSRodney W. Grimes * (and keepalives have been enabled on the socket), we begin to probe 79df8bae1dSRodney W. Grimes * the connection. We force the peer to send us a segment by sending: 80df8bae1dSRodney W. Grimes * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK> 81df8bae1dSRodney W. Grimes * This segment is (deliberately) outside the window, and should elicit 82df8bae1dSRodney W. Grimes * an ack segment in response from the peer. If, despite the TCPT_KEEP 83df8bae1dSRodney W. Grimes * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE 84df8bae1dSRodney W. Grimes * amount of time probing, then we drop the connection. 85df8bae1dSRodney W. Grimes */ 86df8bae1dSRodney W. Grimes 87df8bae1dSRodney W. Grimes /* 88df8bae1dSRodney W. Grimes * Time constants. 89df8bae1dSRodney W. Grimes */ 90df8bae1dSRodney W. Grimes #define TCPTV_MSL ( 30*PR_SLOWHZ) /* max seg lifetime (hah!) */ 91df8bae1dSRodney W. Grimes #define TCPTV_SRTTBASE 0 /* base roundtrip time; 92df8bae1dSRodney W. Grimes if 0, no idea yet */ 9351fb3922SGarrett Wollman #define TCPTV_RTOBASE ( 3*PR_SLOWHZ) /* assumed RTO if no info */ 94df8bae1dSRodney W. Grimes #define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */ 95df8bae1dSRodney W. Grimes 966c5e9bbdSMike Pritchard #define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistence */ 97df8bae1dSRodney W. Grimes #define TCPTV_PERSMAX ( 60*PR_SLOWHZ) /* maximum persist interval */ 98df8bae1dSRodney W. Grimes 99df8bae1dSRodney W. Grimes #define TCPTV_KEEP_INIT ( 75*PR_SLOWHZ) /* initial connect keep alive */ 100df8bae1dSRodney W. Grimes #define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ) /* dflt time before probing */ 101df8bae1dSRodney W. Grimes #define TCPTV_KEEPINTVL ( 75*PR_SLOWHZ) /* default probe interval */ 102df8bae1dSRodney W. Grimes #define TCPTV_KEEPCNT 8 /* max probes before drop */ 103df8bae1dSRodney W. Grimes 104df8bae1dSRodney W. Grimes #define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */ 105df8bae1dSRodney W. Grimes #define TCPTV_REXMTMAX ( 64*PR_SLOWHZ) /* max allowable REXMT value */ 106df8bae1dSRodney W. Grimes 107eb6ad696SGarrett Wollman #define TCPTV_TWTRUNC 8 /* RTO factor to truncate TW */ 108eb6ad696SGarrett Wollman 109df8bae1dSRodney W. Grimes #define TCP_LINGERTIME 120 /* linger at most 2 minutes */ 110df8bae1dSRodney W. Grimes 111df8bae1dSRodney W. Grimes #define TCP_MAXRXTSHIFT 12 /* maximum retransmits */ 112df8bae1dSRodney W. Grimes 113df8bae1dSRodney W. Grimes #ifdef TCPTIMERS 1140312fbe9SPoul-Henning Kamp static char *tcptimers[] = 115df8bae1dSRodney W. Grimes { "REXMT", "PERSIST", "KEEP", "2MSL" }; 116df8bae1dSRodney W. Grimes #endif 117df8bae1dSRodney W. Grimes 118df8bae1dSRodney W. Grimes /* 119df8bae1dSRodney W. Grimes * Force a time value to be in a certain range. 120df8bae1dSRodney W. Grimes */ 121df8bae1dSRodney W. Grimes #define TCPT_RANGESET(tv, value, tvmin, tvmax) { \ 122df8bae1dSRodney W. Grimes (tv) = (value); \ 12326f9a767SRodney W. Grimes if ((u_long)(tv) < (u_long)(tvmin)) \ 124df8bae1dSRodney W. Grimes (tv) = (tvmin); \ 12526f9a767SRodney W. Grimes else if ((u_long)(tv) > (u_long)(tvmax)) \ 126df8bae1dSRodney W. Grimes (tv) = (tvmax); \ 127df8bae1dSRodney W. Grimes } 128df8bae1dSRodney W. Grimes 129df8bae1dSRodney W. Grimes #ifdef KERNEL 1307b40aa32SPaul Traina extern int tcp_keepinit; /* time to establish connection */ 131df8bae1dSRodney W. Grimes extern int tcp_keepidle; /* time before keepalive probes begin */ 132df8bae1dSRodney W. Grimes extern int tcp_keepintvl; /* time between keepalive probes */ 133df8bae1dSRodney W. Grimes extern int tcp_maxidle; /* time to drop after starting probes */ 134df8bae1dSRodney W. Grimes extern int tcp_ttl; /* time to live for TCP segs */ 135df8bae1dSRodney W. Grimes extern int tcp_backoff[]; 136df8bae1dSRodney W. Grimes #endif 137707f139eSPaul Richards 138707f139eSPaul Richards #endif 139