123195Smckusick /* 229154Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 3*32789Sbostic * All rights reserved. 423195Smckusick * 5*32789Sbostic * Redistribution and use in source and binary forms are permitted 6*32789Sbostic * provided that this notice is preserved and that due credit is given 7*32789Sbostic * to the University of California at Berkeley. The name of the University 8*32789Sbostic * may not be used to endorse or promote products derived from this 9*32789Sbostic * software without specific prior written permission. This software 10*32789Sbostic * is provided ``as is'' without express or implied warranty. 11*32789Sbostic * 12*32789Sbostic * @(#)tcp_timer.h 7.4 (Berkeley) 12/07/87 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 505165Swnj * connection is idle (no segments received) for TCPTV_KEEP amount of time, 515165Swnj * but not yet established, then we drop the connection. If the connection 525165Swnj * is established, then we force the peer to send us a segment by sending: 535165Swnj * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK> 545165Swnj * This segment is (deliberately) outside the window, and should elicit 555165Swnj * an ack segment in response from the peer. If, despite the TCPT_KEEP 565165Swnj * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE 575165Swnj * amount of time, then we drop the connection. 585165Swnj */ 595165Swnj 6031397Skarels #define TCP_TTL 30 /* default time to live for TCP segs */ 6131397Skarels int tcp_ttl; /* time to live for TCP segs */ 625125Swnj /* 635165Swnj * Time constants. 645125Swnj */ 6524820Skarels #define TCPTV_MSL ( 15*PR_SLOWHZ) /* max seg lifetime */ 6618647Skarels #define TCPTV_SRTTBASE 0 /* base roundtrip time; 6718647Skarels if 0, no idea yet */ 6826990Skarels #define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */ 6925889Skarels 705165Swnj #define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */ 7131726Skarels #define TCPTV_PERSMAX ( 60*PR_SLOWHZ) /* maximum persist interval */ 725125Swnj 7331726Skarels #define TCPTV_KEEP ( 75*PR_SLOWHZ) /* keep alive - 75 secs */ 747041Swnj #define TCPTV_MAXIDLE ( 8*TCPTV_KEEP) /* maximum allowable idle 755165Swnj time before drop conn */ 765125Swnj 775165Swnj #define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */ 7831726Skarels #define TCPTV_REXMTMAX ( 64*PR_SLOWHZ) /* max allowable REXMT value */ 795125Swnj 805392Swnj #define TCP_LINGERTIME 120 /* linger at most 2 minutes */ 815392Swnj 8224820Skarels #define TCP_MAXRXTSHIFT 12 /* maximum retransmits */ 835691Swnj 845125Swnj #ifdef TCPTIMERS 855125Swnj char *tcptimers[] = 869860Ssam { "REXMT", "PERSIST", "KEEP", "2MSL" }; 875125Swnj #endif 885165Swnj 895165Swnj /* 905165Swnj * Force a time value to be in a certain range. 915165Swnj */ 925245Sroot #define TCPT_RANGESET(tv, value, tvmin, tvmax) { \ 935165Swnj (tv) = (value); \ 945165Swnj if ((tv) < (tvmin)) \ 955165Swnj (tv) = (tvmin); \ 9631726Skarels else if ((tv) > (tvmax)) \ 975245Sroot (tv) = (tvmax); \ 985245Sroot } 9931726Skarels 10031726Skarels #ifdef KERNEL 10131726Skarels extern int tcp_backoff[]; 10231726Skarels #endif 103