123195Smckusick /* 2*63218Sbostic * Copyright (c) 1982, 1986, 1993 3*63218Sbostic * The Regents of the University of California. All rights reserved. 423195Smckusick * 544490Sbostic * %sccs.include.redist.c% 632789Sbostic * 7*63218Sbostic * @(#)tcp_timer.h 8.1 (Berkeley) 06/10/93 823195Smckusick */ 95125Swnj 105125Swnj /* 115125Swnj * Definitions of the TCP timers. These timers are counted 125125Swnj * down PR_SLOWHZ times a second. 135125Swnj */ 149860Ssam #define TCPT_NTIMERS 4 155125Swnj 165125Swnj #define TCPT_REXMT 0 /* retransmit */ 175165Swnj #define TCPT_PERSIST 1 /* retransmit persistance */ 185165Swnj #define TCPT_KEEP 2 /* keep alive */ 195165Swnj #define TCPT_2MSL 3 /* 2*msl quiet time timer */ 205125Swnj 215165Swnj /* 225165Swnj * The TCPT_REXMT timer is used to force retransmissions. 235165Swnj * The TCP has the TCPT_REXMT timer set whenever segments 245165Swnj * have been sent for which ACKs are expected but not yet 255165Swnj * received. If an ACK is received which advances tp->snd_una, 265165Swnj * then the retransmit timer is cleared (if there are no more 275165Swnj * outstanding segments) or reset to the base value (if there 285165Swnj * are more ACKs expected). Whenever the retransmit timer goes off, 2924820Skarels * we retransmit one unacknowledged segment, and do a backoff 3024820Skarels * on the retransmit timer. 315165Swnj * 325165Swnj * The TCPT_PERSIST timer is used to keep window size information 337041Swnj * flowing even if the window goes shut. If all previous transmissions 347041Swnj * have been acknowledged (so that there are no retransmissions in progress), 3524820Skarels * and the window is too small to bother sending anything, then we start 3624820Skarels * the TCPT_PERSIST timer. When it expires, if the window is nonzero, 3724820Skarels * we go to transmit state. Otherwise, at intervals send a single byte 3824820Skarels * into the peer's window to force him to update our window information. 3924820Skarels * We do this at most as often as TCPT_PERSMIN time intervals, 4024820Skarels * but no more frequently than the current estimate of round-trip 4124820Skarels * packet time. The TCPT_PERSIST timer is cleared whenever we receive 4224820Skarels * a window update from the peer. 435165Swnj * 445165Swnj * The TCPT_KEEP timer is used to keep connections alive. If an 4533747Skarels * connection is idle (no segments received) for TCPTV_KEEP_INIT amount of time, 4633747Skarels * but not yet established, then we drop the connection. Once the connection 4733747Skarels * is established, if the connection is idle for TCPTV_KEEP_IDLE time 4833747Skarels * (and keepalives have been enabled on the socket), we begin to probe 4933747Skarels * the connection. We force the peer to send us a segment by sending: 505165Swnj * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK> 515165Swnj * This segment is (deliberately) outside the window, and should elicit 525165Swnj * an ack segment in response from the peer. If, despite the TCPT_KEEP 535165Swnj * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE 5433747Skarels * amount of time probing, then we drop the connection. 555165Swnj */ 565165Swnj 575125Swnj /* 585165Swnj * Time constants. 595125Swnj */ 6033747Skarels #define TCPTV_MSL ( 30*PR_SLOWHZ) /* max seg lifetime (hah!) */ 6118647Skarels #define TCPTV_SRTTBASE 0 /* base roundtrip time; 6218647Skarels if 0, no idea yet */ 6326990Skarels #define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */ 6425889Skarels 655165Swnj #define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */ 6631726Skarels #define TCPTV_PERSMAX ( 60*PR_SLOWHZ) /* maximum persist interval */ 675125Swnj 6833747Skarels #define TCPTV_KEEP_INIT ( 75*PR_SLOWHZ) /* initial connect keep alive */ 6933747Skarels #define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ) /* dflt time before probing */ 7033747Skarels #define TCPTV_KEEPINTVL ( 75*PR_SLOWHZ) /* default probe interval */ 7133747Skarels #define TCPTV_KEEPCNT 8 /* max probes before drop */ 725125Swnj 735165Swnj #define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */ 7431726Skarels #define TCPTV_REXMTMAX ( 64*PR_SLOWHZ) /* max allowable REXMT value */ 755125Swnj 765392Swnj #define TCP_LINGERTIME 120 /* linger at most 2 minutes */ 775392Swnj 7824820Skarels #define TCP_MAXRXTSHIFT 12 /* maximum retransmits */ 795691Swnj 805125Swnj #ifdef TCPTIMERS 815125Swnj char *tcptimers[] = 829860Ssam { "REXMT", "PERSIST", "KEEP", "2MSL" }; 835125Swnj #endif 845165Swnj 855165Swnj /* 865165Swnj * Force a time value to be in a certain range. 875165Swnj */ 885245Sroot #define TCPT_RANGESET(tv, value, tvmin, tvmax) { \ 895165Swnj (tv) = (value); \ 905165Swnj if ((tv) < (tvmin)) \ 915165Swnj (tv) = (tvmin); \ 9231726Skarels else if ((tv) > (tvmax)) \ 935245Sroot (tv) = (tvmax); \ 945245Sroot } 9531726Skarels 9631726Skarels #ifdef KERNEL 9733747Skarels extern int tcp_keepidle; /* time before keepalive probes begin */ 9833747Skarels extern int tcp_keepintvl; /* time between keepalive probes */ 9933747Skarels extern int tcp_maxidle; /* time to drop after starting probes */ 10033747Skarels extern int tcp_ttl; /* time to live for TCP segs */ 10131726Skarels extern int tcp_backoff[]; 10231726Skarels #endif 103