123195Smckusick /* 229154Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 332789Sbostic * All rights reserved. 423195Smckusick * 532789Sbostic * Redistribution and use in source and binary forms are permitted 632789Sbostic * provided that this notice is preserved and that due credit is given 732789Sbostic * to the University of California at Berkeley. The name of the University 832789Sbostic * may not be used to endorse or promote products derived from this 932789Sbostic * software without specific prior written permission. This software 1032789Sbostic * is provided ``as is'' without express or implied warranty. 1132789Sbostic * 12*33747Skarels * @(#)tcp_timer.h 7.5 (Berkeley) 03/16/88 1323195Smckusick */ 145125Swnj 155125Swnj /* 165125Swnj * Definitions of the TCP timers. These timers are counted 175125Swnj * down PR_SLOWHZ times a second. 185125Swnj */ 199860Ssam #define TCPT_NTIMERS 4 205125Swnj 215125Swnj #define TCPT_REXMT 0 /* retransmit */ 225165Swnj #define TCPT_PERSIST 1 /* retransmit persistance */ 235165Swnj #define TCPT_KEEP 2 /* keep alive */ 245165Swnj #define TCPT_2MSL 3 /* 2*msl quiet time timer */ 255125Swnj 265165Swnj /* 275165Swnj * The TCPT_REXMT timer is used to force retransmissions. 285165Swnj * The TCP has the TCPT_REXMT timer set whenever segments 295165Swnj * have been sent for which ACKs are expected but not yet 305165Swnj * received. If an ACK is received which advances tp->snd_una, 315165Swnj * then the retransmit timer is cleared (if there are no more 325165Swnj * outstanding segments) or reset to the base value (if there 335165Swnj * are more ACKs expected). Whenever the retransmit timer goes off, 3424820Skarels * we retransmit one unacknowledged segment, and do a backoff 3524820Skarels * on the retransmit timer. 365165Swnj * 375165Swnj * The TCPT_PERSIST timer is used to keep window size information 387041Swnj * flowing even if the window goes shut. If all previous transmissions 397041Swnj * have been acknowledged (so that there are no retransmissions in progress), 4024820Skarels * and the window is too small to bother sending anything, then we start 4124820Skarels * the TCPT_PERSIST timer. When it expires, if the window is nonzero, 4224820Skarels * we go to transmit state. Otherwise, at intervals send a single byte 4324820Skarels * into the peer's window to force him to update our window information. 4424820Skarels * We do this at most as often as TCPT_PERSMIN time intervals, 4524820Skarels * but no more frequently than the current estimate of round-trip 4624820Skarels * packet time. The TCPT_PERSIST timer is cleared whenever we receive 4724820Skarels * a window update from the peer. 485165Swnj * 495165Swnj * The TCPT_KEEP timer is used to keep connections alive. If an 50*33747Skarels * connection is idle (no segments received) for TCPTV_KEEP_INIT amount of time, 51*33747Skarels * but not yet established, then we drop the connection. Once the connection 52*33747Skarels * is established, if the connection is idle for TCPTV_KEEP_IDLE time 53*33747Skarels * (and keepalives have been enabled on the socket), we begin to probe 54*33747Skarels * the connection. We force the peer to send us a segment by sending: 555165Swnj * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK> 565165Swnj * This segment is (deliberately) outside the window, and should elicit 575165Swnj * an ack segment in response from the peer. If, despite the TCPT_KEEP 585165Swnj * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE 59*33747Skarels * amount of time probing, then we drop the connection. 605165Swnj */ 615165Swnj 6231397Skarels #define TCP_TTL 30 /* default time to live for TCP segs */ 635125Swnj /* 645165Swnj * Time constants. 655125Swnj */ 66*33747Skarels #define TCPTV_MSL ( 30*PR_SLOWHZ) /* max seg lifetime (hah!) */ 6718647Skarels #define TCPTV_SRTTBASE 0 /* base roundtrip time; 6818647Skarels if 0, no idea yet */ 6926990Skarels #define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */ 7025889Skarels 715165Swnj #define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */ 7231726Skarels #define TCPTV_PERSMAX ( 60*PR_SLOWHZ) /* maximum persist interval */ 735125Swnj 74*33747Skarels #define TCPTV_KEEP_INIT ( 75*PR_SLOWHZ) /* initial connect keep alive */ 75*33747Skarels #define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ) /* dflt time before probing */ 76*33747Skarels #define TCPTV_KEEPINTVL ( 75*PR_SLOWHZ) /* default probe interval */ 77*33747Skarels #define TCPTV_KEEPCNT 8 /* max probes before drop */ 785125Swnj 795165Swnj #define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */ 8031726Skarels #define TCPTV_REXMTMAX ( 64*PR_SLOWHZ) /* max allowable REXMT value */ 815125Swnj 825392Swnj #define TCP_LINGERTIME 120 /* linger at most 2 minutes */ 835392Swnj 8424820Skarels #define TCP_MAXRXTSHIFT 12 /* maximum retransmits */ 855691Swnj 865125Swnj #ifdef TCPTIMERS 875125Swnj char *tcptimers[] = 889860Ssam { "REXMT", "PERSIST", "KEEP", "2MSL" }; 895125Swnj #endif 905165Swnj 915165Swnj /* 925165Swnj * Force a time value to be in a certain range. 935165Swnj */ 945245Sroot #define TCPT_RANGESET(tv, value, tvmin, tvmax) { \ 955165Swnj (tv) = (value); \ 965165Swnj if ((tv) < (tvmin)) \ 975165Swnj (tv) = (tvmin); \ 9831726Skarels else if ((tv) > (tvmax)) \ 995245Sroot (tv) = (tvmax); \ 1005245Sroot } 10131726Skarels 10231726Skarels #ifdef KERNEL 103*33747Skarels extern int tcp_keepidle; /* time before keepalive probes begin */ 104*33747Skarels extern int tcp_keepintvl; /* time between keepalive probes */ 105*33747Skarels extern int tcp_maxidle; /* time to drop after starting probes */ 106*33747Skarels extern int tcp_ttl; /* time to live for TCP segs */ 10731726Skarels extern int tcp_backoff[]; 10831726Skarels #endif 109