1*5442Swnj /* tcp_timer.h 4.6 82/01/17 */ 25125Swnj 35125Swnj /* 45125Swnj * Definitions of the TCP timers. These timers are counted 55125Swnj * down PR_SLOWHZ times a second. 65125Swnj */ 7*5442Swnj #define TCPT_NTIMERS 5 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 */ 13*5442Swnj #ifdef TCPTRUEOOB 14*5442Swnj #define TCPT_OOBREXMT 4 /* out-of-band rexmt */ 15*5442Swnj #endif 165125Swnj 175165Swnj /* 185165Swnj * The TCPT_REXMT timer is used to force retransmissions. 195165Swnj * The TCP has the TCPT_REXMT timer set whenever segments 205165Swnj * have been sent for which ACKs are expected but not yet 215165Swnj * received. If an ACK is received which advances tp->snd_una, 225165Swnj * then the retransmit timer is cleared (if there are no more 235165Swnj * outstanding segments) or reset to the base value (if there 245165Swnj * are more ACKs expected). Whenever the retransmit timer goes off, 255165Swnj * we retransmit all unacknowledged segments, and do an exponential 265165Swnj * backoff on the retransmit timer. 275165Swnj * 285165Swnj * The TCPT_PERSIST timer is used to keep window size information 295165Swnj * flowing even if the window goes shut. If an output is attempted when there 305165Swnj * is data ready to transmit, but nothing gets sent because the window 315165Swnj * is shut, then we start the TCPT_PERSIST timer, and at intervals 325165Swnj * send a single byte into the peers window to force him to update 335165Swnj * our window information. We do this at most as often as TCPT_PERSMIN 345165Swnj * time intervals, but no more frequently than the current estimate of 355165Swnj * round-trip packet time. The TCPT_PERSIST timer is cleared whenever 365165Swnj * we receive a window update from the peer. 375165Swnj * 385165Swnj * The TCPT_KEEP timer is used to keep connections alive. If an 395165Swnj * connection is idle (no segments received) for TCPTV_KEEP amount of time, 405165Swnj * but not yet established, then we drop the connection. If the connection 415165Swnj * is established, then we force the peer to send us a segment by sending: 425165Swnj * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK> 435165Swnj * This segment is (deliberately) outside the window, and should elicit 445165Swnj * an ack segment in response from the peer. If, despite the TCPT_KEEP 455165Swnj * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE 465165Swnj * amount of time, then we drop the connection. 47*5442Swnj * 48*5442Swnj * The OOBREXMT timer is to force retransmissions of out-of-band indications. 49*5442Swnj * Because out-of-band data is considered critical, it does not exponential 50*5442Swnj * backoff, but runs at a multiple of smoothed round trip time until acked. 515165Swnj */ 525165Swnj 535245Sroot #define TCP_TTL 15 /* time to live for TCP segs */ 545125Swnj /* 555165Swnj * Time constants. 565125Swnj */ 575245Sroot #define TCPTV_MSL ( 30*PR_SLOWHZ) /* max seg lifetime */ 585165Swnj #define TCPTV_SRTTBASE ( 1*PR_SLOWHZ) /* base roundtrip time */ 595245Sroot #define TCPTV_KEEP ( 60*PR_SLOWHZ) /* keep alive - 1 min */ 605165Swnj #define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */ 615125Swnj 625165Swnj #define TCPTV_MAXIDLE ( 4*TCPTV_KEEP) /* maximum allowable idle 635165Swnj time before drop conn */ 645125Swnj 655165Swnj #define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */ 665392Swnj #define TCPTV_MAX ( 30*PR_SLOWHZ) /* maximum allowable value */ 675125Swnj 685392Swnj #define TCP_LINGERTIME 120 /* linger at most 2 minutes */ 695392Swnj 705125Swnj #ifdef TCPTIMERS 715125Swnj char *tcptimers[] = 72*5442Swnj { "REXMT", "PERSIST", "KEEP", "2MSL", "OOBREXMT" }; 735125Swnj #endif 745165Swnj 755165Swnj /* 765165Swnj * Retransmission smoothing constants. 775165Swnj * Smoothed round trip time is updated by 785165Swnj * tp->t_srtt = (tcp_alpha * tp->t_srtt) + ((1 - tcp_alpha) * tp->t_rtt) 795165Swnj * each time a new value of tp->t_rtt is available. The initial 805165Swnj * retransmit timeout is then based on 815165Swnj * tp->t_timer[TCPT_REXMT] = tcp_beta * tp->t_srtt; 825165Swnj * limited, however to be at least TCPTV_REXMTLO and at most TCPTV_REXMTHI. 835165Swnj */ 845165Swnj float tcp_alpha, tcp_beta; 855165Swnj 865165Swnj /* 875165Swnj * Initial values of tcp_alpha and tcp_beta. 885165Swnj * These are conservative: averaging over a long 895165Swnj * period of time, and allowing for large individual deviations from 905165Swnj * tp->t_srtt. 915165Swnj */ 925165Swnj #define TCP_ALPHA 0.9 935165Swnj #define TCP_BETA 2.0 945165Swnj 955165Swnj /* 965165Swnj * Force a time value to be in a certain range. 975165Swnj */ 985245Sroot #define TCPT_RANGESET(tv, value, tvmin, tvmax) { \ 995165Swnj (tv) = (value); \ 1005165Swnj if ((tv) < (tvmin)) \ 1015165Swnj (tv) = (tvmin); \ 1025165Swnj if ((tv) > (tvmax)) \ 1035245Sroot (tv) = (tvmax); \ 1045245Sroot } 105