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 634855Sbostic * provided that the above copyright notice and this paragraph are 734855Sbostic * duplicated in all such forms and that any documentation, 834855Sbostic * advertising materials, and other materials related to such 934855Sbostic * distribution and use acknowledge that the software was developed 1034855Sbostic * by the University of California, Berkeley. The name of the 1134855Sbostic * University may not be used to endorse or promote products derived 1234855Sbostic * from this software without specific prior written permission. 1334855Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 1434855Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 1534855Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1632789Sbostic * 17*40686Skarels * @(#)tcp_timer.h 7.7 (Berkeley) 04/03/90 1823195Smckusick */ 195125Swnj 205125Swnj /* 215125Swnj * Definitions of the TCP timers. These timers are counted 225125Swnj * down PR_SLOWHZ times a second. 235125Swnj */ 249860Ssam #define TCPT_NTIMERS 4 255125Swnj 265125Swnj #define TCPT_REXMT 0 /* retransmit */ 275165Swnj #define TCPT_PERSIST 1 /* retransmit persistance */ 285165Swnj #define TCPT_KEEP 2 /* keep alive */ 295165Swnj #define TCPT_2MSL 3 /* 2*msl quiet time timer */ 305125Swnj 315165Swnj /* 325165Swnj * The TCPT_REXMT timer is used to force retransmissions. 335165Swnj * The TCP has the TCPT_REXMT timer set whenever segments 345165Swnj * have been sent for which ACKs are expected but not yet 355165Swnj * received. If an ACK is received which advances tp->snd_una, 365165Swnj * then the retransmit timer is cleared (if there are no more 375165Swnj * outstanding segments) or reset to the base value (if there 385165Swnj * are more ACKs expected). Whenever the retransmit timer goes off, 3924820Skarels * we retransmit one unacknowledged segment, and do a backoff 4024820Skarels * on the retransmit timer. 415165Swnj * 425165Swnj * The TCPT_PERSIST timer is used to keep window size information 437041Swnj * flowing even if the window goes shut. If all previous transmissions 447041Swnj * have been acknowledged (so that there are no retransmissions in progress), 4524820Skarels * and the window is too small to bother sending anything, then we start 4624820Skarels * the TCPT_PERSIST timer. When it expires, if the window is nonzero, 4724820Skarels * we go to transmit state. Otherwise, at intervals send a single byte 4824820Skarels * into the peer's window to force him to update our window information. 4924820Skarels * We do this at most as often as TCPT_PERSMIN time intervals, 5024820Skarels * but no more frequently than the current estimate of round-trip 5124820Skarels * packet time. The TCPT_PERSIST timer is cleared whenever we receive 5224820Skarels * a window update from the peer. 535165Swnj * 545165Swnj * The TCPT_KEEP timer is used to keep connections alive. If an 5533747Skarels * connection is idle (no segments received) for TCPTV_KEEP_INIT amount of time, 5633747Skarels * but not yet established, then we drop the connection. Once the connection 5733747Skarels * is established, if the connection is idle for TCPTV_KEEP_IDLE time 5833747Skarels * (and keepalives have been enabled on the socket), we begin to probe 5933747Skarels * the connection. We force the peer to send us a segment by sending: 605165Swnj * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK> 615165Swnj * This segment is (deliberately) outside the window, and should elicit 625165Swnj * an ack segment in response from the peer. If, despite the TCPT_KEEP 635165Swnj * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE 6433747Skarels * amount of time probing, then we drop the connection. 655165Swnj */ 665165Swnj 67*40686Skarels #define TCP_TTL 60 /* default time to live for TCP segs */ 685125Swnj /* 695165Swnj * Time constants. 705125Swnj */ 7133747Skarels #define TCPTV_MSL ( 30*PR_SLOWHZ) /* max seg lifetime (hah!) */ 7218647Skarels #define TCPTV_SRTTBASE 0 /* base roundtrip time; 7318647Skarels if 0, no idea yet */ 7426990Skarels #define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */ 7525889Skarels 765165Swnj #define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */ 7731726Skarels #define TCPTV_PERSMAX ( 60*PR_SLOWHZ) /* maximum persist interval */ 785125Swnj 7933747Skarels #define TCPTV_KEEP_INIT ( 75*PR_SLOWHZ) /* initial connect keep alive */ 8033747Skarels #define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ) /* dflt time before probing */ 8133747Skarels #define TCPTV_KEEPINTVL ( 75*PR_SLOWHZ) /* default probe interval */ 8233747Skarels #define TCPTV_KEEPCNT 8 /* max probes before drop */ 835125Swnj 845165Swnj #define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */ 8531726Skarels #define TCPTV_REXMTMAX ( 64*PR_SLOWHZ) /* max allowable REXMT value */ 865125Swnj 875392Swnj #define TCP_LINGERTIME 120 /* linger at most 2 minutes */ 885392Swnj 8924820Skarels #define TCP_MAXRXTSHIFT 12 /* maximum retransmits */ 905691Swnj 915125Swnj #ifdef TCPTIMERS 925125Swnj char *tcptimers[] = 939860Ssam { "REXMT", "PERSIST", "KEEP", "2MSL" }; 945125Swnj #endif 955165Swnj 965165Swnj /* 975165Swnj * Force a time value to be in a certain range. 985165Swnj */ 995245Sroot #define TCPT_RANGESET(tv, value, tvmin, tvmax) { \ 1005165Swnj (tv) = (value); \ 1015165Swnj if ((tv) < (tvmin)) \ 1025165Swnj (tv) = (tvmin); \ 10331726Skarels else if ((tv) > (tvmax)) \ 1045245Sroot (tv) = (tvmax); \ 1055245Sroot } 10631726Skarels 10731726Skarels #ifdef KERNEL 10833747Skarels extern int tcp_keepidle; /* time before keepalive probes begin */ 10933747Skarels extern int tcp_keepintvl; /* time between keepalive probes */ 11033747Skarels extern int tcp_maxidle; /* time to drop after starting probes */ 11133747Skarels extern int tcp_ttl; /* time to live for TCP segs */ 11231726Skarels extern int tcp_backoff[]; 11331726Skarels #endif 114