1*18647Skarels /* tcp_timer.h 6.2 85/04/17 */ 25125Swnj 35125Swnj /* 45125Swnj * Definitions of the TCP timers. These timers are counted 55125Swnj * down PR_SLOWHZ times a second. 65125Swnj */ 79860Ssam #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 */ 51*18647Skarels #define TCPTV_SRTTBASE 0 /* base roundtrip time; 52*18647Skarels if 0, no idea yet */ 537041Swnj #define TCPTV_KEEP ( 45*PR_SLOWHZ) /* keep alive - 45 secs */ 545165Swnj #define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */ 555125Swnj 567041Swnj #define TCPTV_MAXIDLE ( 8*TCPTV_KEEP) /* maximum allowable idle 575165Swnj time before drop conn */ 585125Swnj 595165Swnj #define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */ 605392Swnj #define TCPTV_MAX ( 30*PR_SLOWHZ) /* maximum allowable value */ 615125Swnj 625392Swnj #define TCP_LINGERTIME 120 /* linger at most 2 minutes */ 635392Swnj 645691Swnj #define TCP_MAXRXTSHIFT 10 /* maximum retransmits */ 655691Swnj 665125Swnj #ifdef TCPTIMERS 675125Swnj char *tcptimers[] = 689860Ssam { "REXMT", "PERSIST", "KEEP", "2MSL" }; 695125Swnj #endif 705165Swnj 715165Swnj /* 725165Swnj * Retransmission smoothing constants. 735165Swnj * Smoothed round trip time is updated by 745165Swnj * tp->t_srtt = (tcp_alpha * tp->t_srtt) + ((1 - tcp_alpha) * tp->t_rtt) 755165Swnj * each time a new value of tp->t_rtt is available. The initial 765165Swnj * retransmit timeout is then based on 775165Swnj * tp->t_timer[TCPT_REXMT] = tcp_beta * tp->t_srtt; 785165Swnj * limited, however to be at least TCPTV_REXMTLO and at most TCPTV_REXMTHI. 795165Swnj */ 805165Swnj float tcp_alpha, tcp_beta; 815165Swnj 825165Swnj /* 835165Swnj * Initial values of tcp_alpha and tcp_beta. 845165Swnj * These are conservative: averaging over a long 855165Swnj * period of time, and allowing for large individual deviations from 865165Swnj * tp->t_srtt. 875165Swnj */ 885165Swnj #define TCP_ALPHA 0.9 895165Swnj #define TCP_BETA 2.0 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); \ 985165Swnj if ((tv) > (tvmax)) \ 995245Sroot (tv) = (tvmax); \ 1005245Sroot } 101