1*9860Ssam /* tcp_timer.h 4.9 82/12/20 */ 25125Swnj 35125Swnj /* 45125Swnj * Definitions of the TCP timers. These timers are counted 55125Swnj * down PR_SLOWHZ times a second. 65125Swnj */ 7*9860Ssam #define TCPT_NTIMERS 4 85125Swnj 95125Swnj #define TCPT_REXMT 0 /* retransmit */ 105165Swnj #define TCPT_PERSIST 1 /* retransmit persistance */ 115165Swnj #define TCPT_KEEP 2 /* keep alive */ 125165Swnj #define TCPT_2MSL 3 /* 2*msl quiet time timer */ 135125Swnj 145165Swnj /* 155165Swnj * The TCPT_REXMT timer is used to force retransmissions. 165165Swnj * The TCP has the TCPT_REXMT timer set whenever segments 175165Swnj * have been sent for which ACKs are expected but not yet 185165Swnj * received. If an ACK is received which advances tp->snd_una, 195165Swnj * then the retransmit timer is cleared (if there are no more 205165Swnj * outstanding segments) or reset to the base value (if there 215165Swnj * are more ACKs expected). Whenever the retransmit timer goes off, 225165Swnj * we retransmit all unacknowledged segments, and do an exponential 235165Swnj * backoff on the retransmit timer. 245165Swnj * 255165Swnj * The TCPT_PERSIST timer is used to keep window size information 267041Swnj * flowing even if the window goes shut. If all previous transmissions 277041Swnj * have been acknowledged (so that there are no retransmissions in progress), 287041Swnj * and the window is shut, then we start the TCPT_PERSIST timer, and at 297041Swnj * intervals send a single byte into the peers window to force him to update 305165Swnj * our window information. We do this at most as often as TCPT_PERSMIN 315165Swnj * time intervals, but no more frequently than the current estimate of 325165Swnj * round-trip packet time. The TCPT_PERSIST timer is cleared whenever 335165Swnj * we receive a window update from the peer. 345165Swnj * 355165Swnj * The TCPT_KEEP timer is used to keep connections alive. If an 365165Swnj * connection is idle (no segments received) for TCPTV_KEEP amount of time, 375165Swnj * but not yet established, then we drop the connection. If the connection 385165Swnj * is established, then we force the peer to send us a segment by sending: 395165Swnj * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK> 405165Swnj * This segment is (deliberately) outside the window, and should elicit 415165Swnj * an ack segment in response from the peer. If, despite the TCPT_KEEP 425165Swnj * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE 435165Swnj * amount of time, then we drop the connection. 445165Swnj */ 455165Swnj 465245Sroot #define TCP_TTL 15 /* time to live for TCP segs */ 475125Swnj /* 485165Swnj * Time constants. 495125Swnj */ 505245Sroot #define TCPTV_MSL ( 30*PR_SLOWHZ) /* max seg lifetime */ 515165Swnj #define TCPTV_SRTTBASE ( 1*PR_SLOWHZ) /* base roundtrip time */ 527041Swnj #define TCPTV_KEEP ( 45*PR_SLOWHZ) /* keep alive - 45 secs */ 535165Swnj #define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */ 545125Swnj 557041Swnj #define TCPTV_MAXIDLE ( 8*TCPTV_KEEP) /* maximum allowable idle 565165Swnj time before drop conn */ 575125Swnj 585165Swnj #define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */ 595392Swnj #define TCPTV_MAX ( 30*PR_SLOWHZ) /* maximum allowable value */ 605125Swnj 615392Swnj #define TCP_LINGERTIME 120 /* linger at most 2 minutes */ 625392Swnj 635691Swnj #define TCP_MAXRXTSHIFT 10 /* maximum retransmits */ 645691Swnj 655125Swnj #ifdef TCPTIMERS 665125Swnj char *tcptimers[] = 67*9860Ssam { "REXMT", "PERSIST", "KEEP", "2MSL" }; 685125Swnj #endif 695165Swnj 705165Swnj /* 715165Swnj * Retransmission smoothing constants. 725165Swnj * Smoothed round trip time is updated by 735165Swnj * tp->t_srtt = (tcp_alpha * tp->t_srtt) + ((1 - tcp_alpha) * tp->t_rtt) 745165Swnj * each time a new value of tp->t_rtt is available. The initial 755165Swnj * retransmit timeout is then based on 765165Swnj * tp->t_timer[TCPT_REXMT] = tcp_beta * tp->t_srtt; 775165Swnj * limited, however to be at least TCPTV_REXMTLO and at most TCPTV_REXMTHI. 785165Swnj */ 795165Swnj float tcp_alpha, tcp_beta; 805165Swnj 815165Swnj /* 825165Swnj * Initial values of tcp_alpha and tcp_beta. 835165Swnj * These are conservative: averaging over a long 845165Swnj * period of time, and allowing for large individual deviations from 855165Swnj * tp->t_srtt. 865165Swnj */ 875165Swnj #define TCP_ALPHA 0.9 885165Swnj #define TCP_BETA 2.0 895165Swnj 905165Swnj /* 915165Swnj * Force a time value to be in a certain range. 925165Swnj */ 935245Sroot #define TCPT_RANGESET(tv, value, tvmin, tvmax) { \ 945165Swnj (tv) = (value); \ 955165Swnj if ((tv) < (tvmin)) \ 965165Swnj (tv) = (tvmin); \ 975165Swnj if ((tv) > (tvmax)) \ 985245Sroot (tv) = (tvmax); \ 995245Sroot } 100