fix device register structure's names
[unix-history] / usr / src / sys / netinet / tcp_timer.h
CommitLineData
8b5a83bb 1/* tcp_timer.h 4.6 82/01/17 */
1c4a70b8
BJ
2
3/*
4 * Definitions of the TCP timers. These timers are counted
5 * down PR_SLOWHZ times a second.
6 */
8b5a83bb 7#define TCPT_NTIMERS 5
1c4a70b8
BJ
8
9#define TCPT_REXMT 0 /* retransmit */
405c9168
BJ
10#define TCPT_PERSIST 1 /* retransmit persistance */
11#define TCPT_KEEP 2 /* keep alive */
12#define TCPT_2MSL 3 /* 2*msl quiet time timer */
8b5a83bb
BJ
13#ifdef TCPTRUEOOB
14#define TCPT_OOBREXMT 4 /* out-of-band rexmt */
15#endif
405c9168
BJ
16
17/*
18 * The TCPT_REXMT timer is used to force retransmissions.
19 * The TCP has the TCPT_REXMT timer set whenever segments
20 * have been sent for which ACKs are expected but not yet
21 * received. If an ACK is received which advances tp->snd_una,
22 * then the retransmit timer is cleared (if there are no more
23 * outstanding segments) or reset to the base value (if there
24 * are more ACKs expected). Whenever the retransmit timer goes off,
25 * we retransmit all unacknowledged segments, and do an exponential
26 * backoff on the retransmit timer.
27 *
28 * The TCPT_PERSIST timer is used to keep window size information
29 * flowing even if the window goes shut. If an output is attempted when there
30 * is data ready to transmit, but nothing gets sent because the window
31 * is shut, then we start the TCPT_PERSIST timer, and at intervals
32 * send a single byte into the peers window to force him to update
33 * our window information. We do this at most as often as TCPT_PERSMIN
34 * time intervals, but no more frequently than the current estimate of
35 * round-trip packet time. The TCPT_PERSIST timer is cleared whenever
36 * we receive a window update from the peer.
37 *
38 * The TCPT_KEEP timer is used to keep connections alive. If an
39 * connection is idle (no segments received) for TCPTV_KEEP amount of time,
40 * but not yet established, then we drop the connection. If the connection
41 * is established, then we force the peer to send us a segment by sending:
42 * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK>
43 * This segment is (deliberately) outside the window, and should elicit
44 * an ack segment in response from the peer. If, despite the TCPT_KEEP
45 * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE
46 * amount of time, then we drop the connection.
8b5a83bb
BJ
47 *
48 * The OOBREXMT timer is to force retransmissions of out-of-band indications.
49 * Because out-of-band data is considered critical, it does not exponential
50 * backoff, but runs at a multiple of smoothed round trip time until acked.
405c9168 51 */
1c4a70b8 52
4aed14e3 53#define TCP_TTL 15 /* time to live for TCP segs */
1c4a70b8 54/*
405c9168 55 * Time constants.
1c4a70b8 56 */
4aed14e3 57#define TCPTV_MSL ( 30*PR_SLOWHZ) /* max seg lifetime */
405c9168 58#define TCPTV_SRTTBASE ( 1*PR_SLOWHZ) /* base roundtrip time */
4aed14e3 59#define TCPTV_KEEP ( 60*PR_SLOWHZ) /* keep alive - 1 min */
405c9168 60#define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */
1c4a70b8 61
405c9168
BJ
62#define TCPTV_MAXIDLE ( 4*TCPTV_KEEP) /* maximum allowable idle
63 time before drop conn */
1c4a70b8 64
405c9168 65#define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */
8e65fd66
BJ
66#define TCPTV_MAX ( 30*PR_SLOWHZ) /* maximum allowable value */
67
68#define TCP_LINGERTIME 120 /* linger at most 2 minutes */
1c4a70b8
BJ
69
70#ifdef TCPTIMERS
71char *tcptimers[] =
8b5a83bb 72 { "REXMT", "PERSIST", "KEEP", "2MSL", "OOBREXMT" };
1c4a70b8 73#endif
405c9168
BJ
74
75/*
76 * Retransmission smoothing constants.
77 * Smoothed round trip time is updated by
78 * tp->t_srtt = (tcp_alpha * tp->t_srtt) + ((1 - tcp_alpha) * tp->t_rtt)
79 * each time a new value of tp->t_rtt is available. The initial
80 * retransmit timeout is then based on
81 * tp->t_timer[TCPT_REXMT] = tcp_beta * tp->t_srtt;
82 * limited, however to be at least TCPTV_REXMTLO and at most TCPTV_REXMTHI.
83 */
84float tcp_alpha, tcp_beta;
85
86/*
87 * Initial values of tcp_alpha and tcp_beta.
88 * These are conservative: averaging over a long
89 * period of time, and allowing for large individual deviations from
90 * tp->t_srtt.
91 */
92#define TCP_ALPHA 0.9
93#define TCP_BETA 2.0
94
95/*
96 * Force a time value to be in a certain range.
97 */
4aed14e3 98#define TCPT_RANGESET(tv, value, tvmin, tvmax) { \
405c9168
BJ
99 (tv) = (value); \
100 if ((tv) < (tvmin)) \
101 (tv) = (tvmin); \
102 if ((tv) > (tvmax)) \
4aed14e3
BJ
103 (tv) = (tvmax); \
104}