123195Smckusick /* 229154Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 323195Smckusick * All rights reserved. The Berkeley software License Agreement 423195Smckusick * specifies the terms and conditions for redistribution. 523195Smckusick * 6*31726Skarels * @(#)tcp_timer.h 7.3 (Berkeley) 06/30/87 723195Smckusick */ 85125Swnj 95125Swnj /* 105125Swnj * Definitions of the TCP timers. These timers are counted 115125Swnj * down PR_SLOWHZ times a second. 125125Swnj */ 139860Ssam #define TCPT_NTIMERS 4 145125Swnj 155125Swnj #define TCPT_REXMT 0 /* retransmit */ 165165Swnj #define TCPT_PERSIST 1 /* retransmit persistance */ 175165Swnj #define TCPT_KEEP 2 /* keep alive */ 185165Swnj #define TCPT_2MSL 3 /* 2*msl quiet time timer */ 195125Swnj 205165Swnj /* 215165Swnj * The TCPT_REXMT timer is used to force retransmissions. 225165Swnj * The TCP has the TCPT_REXMT timer set whenever segments 235165Swnj * have been sent for which ACKs are expected but not yet 245165Swnj * received. If an ACK is received which advances tp->snd_una, 255165Swnj * then the retransmit timer is cleared (if there are no more 265165Swnj * outstanding segments) or reset to the base value (if there 275165Swnj * are more ACKs expected). Whenever the retransmit timer goes off, 2824820Skarels * we retransmit one unacknowledged segment, and do a backoff 2924820Skarels * on the retransmit timer. 305165Swnj * 315165Swnj * The TCPT_PERSIST timer is used to keep window size information 327041Swnj * flowing even if the window goes shut. If all previous transmissions 337041Swnj * have been acknowledged (so that there are no retransmissions in progress), 3424820Skarels * and the window is too small to bother sending anything, then we start 3524820Skarels * the TCPT_PERSIST timer. When it expires, if the window is nonzero, 3624820Skarels * we go to transmit state. Otherwise, at intervals send a single byte 3724820Skarels * into the peer's window to force him to update our window information. 3824820Skarels * We do this at most as often as TCPT_PERSMIN time intervals, 3924820Skarels * but no more frequently than the current estimate of round-trip 4024820Skarels * packet time. The TCPT_PERSIST timer is cleared whenever we receive 4124820Skarels * a window update from the peer. 425165Swnj * 435165Swnj * The TCPT_KEEP timer is used to keep connections alive. If an 445165Swnj * connection is idle (no segments received) for TCPTV_KEEP amount of time, 455165Swnj * but not yet established, then we drop the connection. If the connection 465165Swnj * is established, then we force the peer to send us a segment by sending: 475165Swnj * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK> 485165Swnj * This segment is (deliberately) outside the window, and should elicit 495165Swnj * an ack segment in response from the peer. If, despite the TCPT_KEEP 505165Swnj * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE 515165Swnj * amount of time, then we drop the connection. 525165Swnj */ 535165Swnj 5431397Skarels #define TCP_TTL 30 /* default time to live for TCP segs */ 5531397Skarels int tcp_ttl; /* time to live for TCP segs */ 565125Swnj /* 575165Swnj * Time constants. 585125Swnj */ 5924820Skarels #define TCPTV_MSL ( 15*PR_SLOWHZ) /* max seg lifetime */ 6018647Skarels #define TCPTV_SRTTBASE 0 /* base roundtrip time; 6118647Skarels if 0, no idea yet */ 6226990Skarels #define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */ 6325889Skarels 645165Swnj #define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */ 65*31726Skarels #define TCPTV_PERSMAX ( 60*PR_SLOWHZ) /* maximum persist interval */ 665125Swnj 67*31726Skarels #define TCPTV_KEEP ( 75*PR_SLOWHZ) /* keep alive - 75 secs */ 687041Swnj #define TCPTV_MAXIDLE ( 8*TCPTV_KEEP) /* maximum allowable idle 695165Swnj time before drop conn */ 705125Swnj 715165Swnj #define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */ 72*31726Skarels #define TCPTV_REXMTMAX ( 64*PR_SLOWHZ) /* max allowable REXMT value */ 735125Swnj 745392Swnj #define TCP_LINGERTIME 120 /* linger at most 2 minutes */ 755392Swnj 7624820Skarels #define TCP_MAXRXTSHIFT 12 /* maximum retransmits */ 775691Swnj 785125Swnj #ifdef TCPTIMERS 795125Swnj char *tcptimers[] = 809860Ssam { "REXMT", "PERSIST", "KEEP", "2MSL" }; 815125Swnj #endif 825165Swnj 835165Swnj /* 845165Swnj * Force a time value to be in a certain range. 855165Swnj */ 865245Sroot #define TCPT_RANGESET(tv, value, tvmin, tvmax) { \ 875165Swnj (tv) = (value); \ 885165Swnj if ((tv) < (tvmin)) \ 895165Swnj (tv) = (tvmin); \ 90*31726Skarels else if ((tv) > (tvmax)) \ 915245Sroot (tv) = (tvmax); \ 925245Sroot } 93*31726Skarels 94*31726Skarels #ifdef KERNEL 95*31726Skarels extern int tcp_backoff[]; 96*31726Skarels #endif 97