root / slirp / tcp_var.h @ efb56cf7
History | View | Annotate | Download (6.5 kB)
1 | f0cbd3ec | bellard | /*
|
---|---|---|---|
2 | f0cbd3ec | bellard | * Copyright (c) 1982, 1986, 1993, 1994
|
3 | f0cbd3ec | bellard | * The Regents of the University of California. All rights reserved.
|
4 | f0cbd3ec | bellard | *
|
5 | f0cbd3ec | bellard | * Redistribution and use in source and binary forms, with or without
|
6 | f0cbd3ec | bellard | * modification, are permitted provided that the following conditions
|
7 | f0cbd3ec | bellard | * are met:
|
8 | f0cbd3ec | bellard | * 1. Redistributions of source code must retain the above copyright
|
9 | f0cbd3ec | bellard | * notice, this list of conditions and the following disclaimer.
|
10 | f0cbd3ec | bellard | * 2. Redistributions in binary form must reproduce the above copyright
|
11 | f0cbd3ec | bellard | * notice, this list of conditions and the following disclaimer in the
|
12 | f0cbd3ec | bellard | * documentation and/or other materials provided with the distribution.
|
13 | 2f5f8996 | aliguori | * 3. Neither the name of the University nor the names of its contributors
|
14 | f0cbd3ec | bellard | * may be used to endorse or promote products derived from this software
|
15 | f0cbd3ec | bellard | * without specific prior written permission.
|
16 | f0cbd3ec | bellard | *
|
17 | f0cbd3ec | bellard | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
18 | f0cbd3ec | bellard | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19 | f0cbd3ec | bellard | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
20 | f0cbd3ec | bellard | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
21 | f0cbd3ec | bellard | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22 | f0cbd3ec | bellard | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
23 | f0cbd3ec | bellard | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
24 | f0cbd3ec | bellard | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | f0cbd3ec | bellard | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
26 | f0cbd3ec | bellard | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
27 | f0cbd3ec | bellard | * SUCH DAMAGE.
|
28 | f0cbd3ec | bellard | *
|
29 | f0cbd3ec | bellard | * @(#)tcp_var.h 8.3 (Berkeley) 4/10/94
|
30 | f0cbd3ec | bellard | * tcp_var.h,v 1.3 1994/08/21 05:27:39 paul Exp
|
31 | f0cbd3ec | bellard | */
|
32 | f0cbd3ec | bellard | |
33 | f0cbd3ec | bellard | #ifndef _TCP_VAR_H_
|
34 | f0cbd3ec | bellard | #define _TCP_VAR_H_
|
35 | f0cbd3ec | bellard | |
36 | f0cbd3ec | bellard | #include "tcpip.h" |
37 | f0cbd3ec | bellard | #include "tcp_timer.h" |
38 | f0cbd3ec | bellard | |
39 | f0cbd3ec | bellard | /*
|
40 | f0cbd3ec | bellard | * Tcp control block, one per tcp; fields:
|
41 | f0cbd3ec | bellard | */
|
42 | f0cbd3ec | bellard | struct tcpcb {
|
43 | 429d0a3d | blueswir1 | struct tcpiphdr *seg_next; /* sequencing queue */ |
44 | 429d0a3d | blueswir1 | struct tcpiphdr *seg_prev;
|
45 | f0cbd3ec | bellard | short t_state; /* state of this connection */ |
46 | f0cbd3ec | bellard | short t_timer[TCPT_NTIMERS]; /* tcp timers */ |
47 | f0cbd3ec | bellard | short t_rxtshift; /* log(2) of rexmt exp. backoff */ |
48 | f0cbd3ec | bellard | short t_rxtcur; /* current retransmit value */ |
49 | f0cbd3ec | bellard | short t_dupacks; /* consecutive dup acks recd */ |
50 | f0cbd3ec | bellard | u_short t_maxseg; /* maximum segment size */
|
51 | f0cbd3ec | bellard | char t_force; /* 1 if forcing out a byte */ |
52 | f0cbd3ec | bellard | u_short t_flags; |
53 | f0cbd3ec | bellard | #define TF_ACKNOW 0x0001 /* ack peer immediately */ |
54 | f0cbd3ec | bellard | #define TF_DELACK 0x0002 /* ack, but try to delay it */ |
55 | f0cbd3ec | bellard | #define TF_NODELAY 0x0004 /* don't delay packets to coalesce */ |
56 | f0cbd3ec | bellard | #define TF_NOOPT 0x0008 /* don't use tcp options */ |
57 | f0cbd3ec | bellard | #define TF_SENTFIN 0x0010 /* have sent FIN */ |
58 | f0cbd3ec | bellard | #define TF_REQ_SCALE 0x0020 /* have/will request window scaling */ |
59 | f0cbd3ec | bellard | #define TF_RCVD_SCALE 0x0040 /* other side has requested scaling */ |
60 | f0cbd3ec | bellard | #define TF_REQ_TSTMP 0x0080 /* have/will request timestamps */ |
61 | f0cbd3ec | bellard | #define TF_RCVD_TSTMP 0x0100 /* a timestamp was received in SYN */ |
62 | f0cbd3ec | bellard | #define TF_SACK_PERMIT 0x0200 /* other side said I could SACK */ |
63 | f0cbd3ec | bellard | |
64 | 0d62c4cf | Jan Kiszka | struct tcpiphdr t_template; /* static skeletal packet for xmit */ |
65 | f0cbd3ec | bellard | |
66 | f0cbd3ec | bellard | struct socket *t_socket; /* back pointer to socket */ |
67 | f0cbd3ec | bellard | /*
|
68 | f0cbd3ec | bellard | * The following fields are used as in the protocol specification.
|
69 | f0cbd3ec | bellard | * See RFC783, Dec. 1981, page 21.
|
70 | f0cbd3ec | bellard | */
|
71 | f0cbd3ec | bellard | /* send sequence variables */
|
72 | f0cbd3ec | bellard | tcp_seq snd_una; /* send unacknowledged */
|
73 | f0cbd3ec | bellard | tcp_seq snd_nxt; /* send next */
|
74 | f0cbd3ec | bellard | tcp_seq snd_up; /* send urgent pointer */
|
75 | f0cbd3ec | bellard | tcp_seq snd_wl1; /* window update seg seq number */
|
76 | f0cbd3ec | bellard | tcp_seq snd_wl2; /* window update seg ack number */
|
77 | f0cbd3ec | bellard | tcp_seq iss; /* initial send sequence number */
|
78 | f0cbd3ec | bellard | u_int32_t snd_wnd; /* send window */
|
79 | f0cbd3ec | bellard | /* receive sequence variables */
|
80 | f0cbd3ec | bellard | u_int32_t rcv_wnd; /* receive window */
|
81 | f0cbd3ec | bellard | tcp_seq rcv_nxt; /* receive next */
|
82 | f0cbd3ec | bellard | tcp_seq rcv_up; /* receive urgent pointer */
|
83 | f0cbd3ec | bellard | tcp_seq irs; /* initial receive sequence number */
|
84 | f0cbd3ec | bellard | /*
|
85 | f0cbd3ec | bellard | * Additional variables for this implementation.
|
86 | f0cbd3ec | bellard | */
|
87 | f0cbd3ec | bellard | /* receive variables */
|
88 | f0cbd3ec | bellard | tcp_seq rcv_adv; /* advertised window */
|
89 | f0cbd3ec | bellard | /* retransmit variables */
|
90 | f0cbd3ec | bellard | tcp_seq snd_max; /* highest sequence number sent;
|
91 | f0cbd3ec | bellard | * used to recognize retransmits
|
92 | f0cbd3ec | bellard | */
|
93 | f0cbd3ec | bellard | /* congestion control (for slow start, source quench, retransmit after loss) */
|
94 | f0cbd3ec | bellard | u_int32_t snd_cwnd; /* congestion-controlled window */
|
95 | f0cbd3ec | bellard | u_int32_t snd_ssthresh; /* snd_cwnd size threshold for
|
96 | f0cbd3ec | bellard | * for slow start exponential to
|
97 | f0cbd3ec | bellard | * linear switch
|
98 | f0cbd3ec | bellard | */
|
99 | f0cbd3ec | bellard | /*
|
100 | f0cbd3ec | bellard | * transmit timing stuff. See below for scale of srtt and rttvar.
|
101 | f0cbd3ec | bellard | * "Variance" is actually smoothed difference.
|
102 | f0cbd3ec | bellard | */
|
103 | f0cbd3ec | bellard | short t_idle; /* inactivity time */ |
104 | f0cbd3ec | bellard | short t_rtt; /* round trip time */ |
105 | f0cbd3ec | bellard | tcp_seq t_rtseq; /* sequence number being timed */
|
106 | f0cbd3ec | bellard | short t_srtt; /* smoothed round-trip time */ |
107 | f0cbd3ec | bellard | short t_rttvar; /* variance in round-trip time */ |
108 | f0cbd3ec | bellard | u_short t_rttmin; /* minimum rtt allowed */
|
109 | f0cbd3ec | bellard | u_int32_t max_sndwnd; /* largest window peer has offered */
|
110 | f0cbd3ec | bellard | |
111 | f0cbd3ec | bellard | /* out-of-band data */
|
112 | f0cbd3ec | bellard | char t_oobflags; /* have some */ |
113 | f0cbd3ec | bellard | char t_iobc; /* input character */ |
114 | f0cbd3ec | bellard | #define TCPOOB_HAVEDATA 0x01 |
115 | f0cbd3ec | bellard | #define TCPOOB_HADDATA 0x02 |
116 | f0cbd3ec | bellard | short t_softerror; /* possible error not yet reported */ |
117 | f0cbd3ec | bellard | |
118 | f0cbd3ec | bellard | /* RFC 1323 variables */
|
119 | f0cbd3ec | bellard | u_char snd_scale; /* window scaling for send window */
|
120 | f0cbd3ec | bellard | u_char rcv_scale; /* window scaling for recv window */
|
121 | f0cbd3ec | bellard | u_char request_r_scale; /* pending window scaling */
|
122 | f0cbd3ec | bellard | u_char requested_s_scale; |
123 | f0cbd3ec | bellard | u_int32_t ts_recent; /* timestamp echo data */
|
124 | f0cbd3ec | bellard | u_int32_t ts_recent_age; /* when last updated */
|
125 | f0cbd3ec | bellard | tcp_seq last_ack_sent; |
126 | f0cbd3ec | bellard | |
127 | f0cbd3ec | bellard | }; |
128 | f0cbd3ec | bellard | |
129 | f0cbd3ec | bellard | #define sototcpcb(so) ((so)->so_tcpcb)
|
130 | f0cbd3ec | bellard | |
131 | f0cbd3ec | bellard | /*
|
132 | f0cbd3ec | bellard | * The smoothed round-trip time and estimated variance
|
133 | f0cbd3ec | bellard | * are stored as fixed point numbers scaled by the values below.
|
134 | f0cbd3ec | bellard | * For convenience, these scales are also used in smoothing the average
|
135 | f0cbd3ec | bellard | * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
|
136 | f0cbd3ec | bellard | * With these scales, srtt has 3 bits to the right of the binary point,
|
137 | f0cbd3ec | bellard | * and thus an "ALPHA" of 0.875. rttvar has 2 bits to the right of the
|
138 | f0cbd3ec | bellard | * binary point, and is smoothed with an ALPHA of 0.75.
|
139 | f0cbd3ec | bellard | */
|
140 | f0cbd3ec | bellard | #define TCP_RTT_SCALE 8 /* multiplier for srtt; 3 bits frac. */ |
141 | f0cbd3ec | bellard | #define TCP_RTT_SHIFT 3 /* shift for srtt; 3 bits frac. */ |
142 | f0cbd3ec | bellard | #define TCP_RTTVAR_SCALE 4 /* multiplier for rttvar; 2 bits */ |
143 | f0cbd3ec | bellard | #define TCP_RTTVAR_SHIFT 2 /* multiplier for rttvar; 2 bits */ |
144 | f0cbd3ec | bellard | |
145 | f0cbd3ec | bellard | /*
|
146 | f0cbd3ec | bellard | * The initial retransmission should happen at rtt + 4 * rttvar.
|
147 | f0cbd3ec | bellard | * Because of the way we do the smoothing, srtt and rttvar
|
148 | f0cbd3ec | bellard | * will each average +1/2 tick of bias. When we compute
|
149 | f0cbd3ec | bellard | * the retransmit timer, we want 1/2 tick of rounding and
|
150 | f0cbd3ec | bellard | * 1 extra tick because of +-1/2 tick uncertainty in the
|
151 | f0cbd3ec | bellard | * firing of the timer. The bias will give us exactly the
|
152 | f0cbd3ec | bellard | * 1.5 tick we need. But, because the bias is
|
153 | f0cbd3ec | bellard | * statistical, we have to test that we don't drop below
|
154 | f0cbd3ec | bellard | * the minimum feasible timer (which is 2 ticks).
|
155 | f0cbd3ec | bellard | * This macro assumes that the value of TCP_RTTVAR_SCALE
|
156 | f0cbd3ec | bellard | * is the same as the multiplier for rttvar.
|
157 | f0cbd3ec | bellard | */
|
158 | f0cbd3ec | bellard | #define TCP_REXMTVAL(tp) \
|
159 | f0cbd3ec | bellard | (((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar) |
160 | f0cbd3ec | bellard | |
161 | f0cbd3ec | bellard | #endif |