1 /* 2 * Copyright (c) 1982, 1986 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 * 12 * @(#)tcp_var.h 7.6.1.1 (Berkeley) 02/07/88 13 */ 14 15 /* 16 * TCP configuration: This is a half-assed attempt to make TCP 17 * self-configure for a few varieties of 4.2 and 4.3-based unixes. 18 * If you don't have a) a 4.3bsd vax or b) a 3.x Sun (x<6), check 19 * this carefully (it's probably not right). Please send me mail 20 * if you run into configuration problems. 21 * - Van Jacobson (van@lbl-csam.arpa) 22 */ 23 24 #ifndef BSD 25 #define BSD 42 /* if we're not 4.3, pretend we're 4.2 */ 26 #endif 27 28 #if sun || BSD < 43 29 #define TCP_COMPAT_42 /* set if we have to interop w/4.2 systems */ 30 #endif 31 32 #ifndef SB_MAX 33 #ifdef SB_MAXCOUNT 34 #define SB_MAX SB_MAXCOUNT /* Sun has to be a little bit different... */ 35 #else 36 #define SB_MAX 32767 /* XXX */ 37 #endif SB_MAXCOUNT 38 #endif SB_MAX 39 40 /* 41 * Bill Nowicki pointed out that the page size (CLBYTES) has 42 * nothing to do with the mbuf cluster size. So, we followed 43 * Sun's lead and made the new define MCLBYTES stand for the mbuf 44 * cluster size. The following define makes up backwards compatible 45 * with 4.3 and 4.2. If CLBYTES is >1024 on your machine, check 46 * this against the mbuf cluster definitions in /usr/include/sys/mbuf.h. 47 */ 48 #ifndef MCLBYTES 49 #define MCLBYTES CLBYTES /* XXX */ 50 #endif 51 52 /* 53 * The routine in_localaddr is broken in Sun's 3.4. We redefine ours 54 * (in tcp_input.c) so we use can it but won't have a name conflict. 55 */ 56 #ifdef sun 57 #define in_localaddr tcp_in_localaddr 58 #endif 59 60 /* --------------- end of TCP config ---------------- */ 61 62 /* 63 * Kernel variables for tcp. 64 */ 65 66 /* 67 * Tcp control block, one per tcp; fields: 68 */ 69 struct tcpcb { 70 struct tcpiphdr *seg_next; /* sequencing queue */ 71 struct tcpiphdr *seg_prev; 72 short t_state; /* state of this connection */ 73 short t_timer[TCPT_NTIMERS]; /* tcp timers */ 74 short t_rxtshift; /* log(2) of rexmt exp. backoff */ 75 short t_rxtcur; /* current retransmit value */ 76 short t_dupacks; /* consecutive dup acks recd */ 77 u_short t_maxseg; /* maximum segment size */ 78 char t_force; /* 1 if forcing out a byte */ 79 u_char t_flags; 80 #define TF_ACKNOW 0x01 /* ack peer immediately */ 81 #define TF_DELACK 0x02 /* ack, but try to delay it */ 82 #define TF_NODELAY 0x04 /* don't delay packets to coalesce */ 83 #define TF_NOOPT 0x08 /* don't use tcp options */ 84 #define TF_SENTFIN 0x10 /* have sent FIN */ 85 struct tcpiphdr *t_template; /* skeletal packet for transmit */ 86 struct inpcb *t_inpcb; /* back pointer to internet pcb */ 87 /* 88 * The following fields are used as in the protocol specification. 89 * See RFC783, Dec. 1981, page 21. 90 */ 91 /* send sequence variables */ 92 tcp_seq snd_una; /* send unacknowledged */ 93 tcp_seq snd_nxt; /* send next */ 94 tcp_seq snd_up; /* send urgent pointer */ 95 tcp_seq snd_wl1; /* window update seg seq number */ 96 tcp_seq snd_wl2; /* window update seg ack number */ 97 tcp_seq iss; /* initial send sequence number */ 98 u_short snd_wnd; /* send window */ 99 /* receive sequence variables */ 100 u_short rcv_wnd; /* receive window */ 101 tcp_seq rcv_nxt; /* receive next */ 102 tcp_seq rcv_up; /* receive urgent pointer */ 103 tcp_seq irs; /* initial receive sequence number */ 104 /* 105 * Additional variables for this implementation. 106 */ 107 /* receive variables */ 108 tcp_seq rcv_adv; /* advertised window */ 109 /* retransmit variables */ 110 tcp_seq snd_max; /* highest sequence number sent 111 * used to recognize retransmits 112 */ 113 /* congestion control (for slow start, source quench, retransmit after loss) */ 114 u_short snd_cwnd; /* congestion-controlled window */ 115 u_short snd_ssthresh; /* snd_cwnd size threshhold for 116 * for slow start exponential to 117 * linear switch */ 118 /* 119 * transmit timing stuff. 120 * srtt and rttvar are stored as fixed point; for convenience in smoothing, 121 * srtt has 3 bits to the right of the binary point, rttvar has 2. 122 * "Variance" is actually smoothed difference. 123 */ 124 short t_idle; /* inactivity time */ 125 short t_rtt; /* round trip time */ 126 tcp_seq t_rtseq; /* sequence number being timed */ 127 short t_srtt; /* smoothed round-trip time */ 128 short t_rttvar; /* variance in round-trip time */ 129 u_short max_rcvd; /* most peer has sent into window */ 130 u_short max_sndwnd; /* largest window peer has offered */ 131 /* out-of-band data */ 132 char t_oobflags; /* have some */ 133 char t_iobc; /* input character */ 134 #define TCPOOB_HAVEDATA 0x01 135 #define TCPOOB_HADDATA 0x02 136 }; 137 138 #define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb) 139 #define sototcpcb(so) (intotcpcb(sotoinpcb(so))) 140 141 /* 142 * TCP statistics. 143 * Many of these should be kept per connection, 144 * but that's inconvenient at the moment. 145 */ 146 struct tcpstat { 147 u_long tcps_connattempt; /* connections initiated */ 148 u_long tcps_accepts; /* connections accepted */ 149 u_long tcps_connects; /* connections established */ 150 u_long tcps_drops; /* connections dropped */ 151 u_long tcps_conndrops; /* embryonic connections dropped */ 152 u_long tcps_closed; /* conn. closed (includes drops) */ 153 u_long tcps_segstimed; /* segs where we tried to get rtt */ 154 u_long tcps_rttupdated; /* times we succeeded */ 155 u_long tcps_delack; /* delayed acks sent */ 156 u_long tcps_timeoutdrop; /* conn. dropped in rxmt timeout */ 157 u_long tcps_rexmttimeo; /* retransmit timeouts */ 158 u_long tcps_persisttimeo; /* persist timeouts */ 159 u_long tcps_keeptimeo; /* keepalive timeouts */ 160 u_long tcps_keepprobe; /* keepalive probes sent */ 161 u_long tcps_keepdrops; /* connections dropped in keepalive */ 162 163 u_long tcps_sndtotal; /* total packets sent */ 164 u_long tcps_sndpack; /* data packets sent */ 165 u_long tcps_sndbyte; /* data bytes sent */ 166 u_long tcps_sndrexmitpack; /* data packets retransmitted */ 167 u_long tcps_sndrexmitbyte; /* data bytes retransmitted */ 168 u_long tcps_sndacks; /* ack-only packets sent */ 169 u_long tcps_sndprobe; /* window probes sent */ 170 u_long tcps_sndurg; /* packets sent with URG only */ 171 u_long tcps_sndwinup; /* window update-only packets sent */ 172 u_long tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */ 173 174 u_long tcps_rcvtotal; /* total packets received */ 175 u_long tcps_rcvpack; /* packets received in sequence */ 176 u_long tcps_rcvbyte; /* bytes received in sequence */ 177 u_long tcps_rcvbadsum; /* packets received with ccksum errs */ 178 u_long tcps_rcvbadoff; /* packets received with bad offset */ 179 u_long tcps_rcvshort; /* packets received too short */ 180 u_long tcps_rcvduppack; /* duplicate-only packets received */ 181 u_long tcps_rcvdupbyte; /* duplicate-only bytes received */ 182 u_long tcps_rcvpartduppack; /* packets with some duplicate data */ 183 u_long tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */ 184 u_long tcps_rcvoopack; /* out-of-order packets received */ 185 u_long tcps_rcvoobyte; /* out-of-order bytes received */ 186 u_long tcps_rcvpackafterwin; /* packets with data after window */ 187 u_long tcps_rcvbyteafterwin; /* bytes rcvd after window */ 188 u_long tcps_rcvafterclose; /* packets rcvd after "close" */ 189 u_long tcps_rcvwinprobe; /* rcvd window probe packets */ 190 u_long tcps_rcvdupack; /* rcvd duplicate acks */ 191 u_long tcps_rcvacktoomuch; /* rcvd acks for unsent data */ 192 u_long tcps_rcvackpack; /* rcvd ack packets */ 193 u_long tcps_rcvackbyte; /* bytes acked by rcvd acks */ 194 u_long tcps_rcvwinupd; /* rcvd window update packets */ 195 }; 196 197 #ifdef KERNEL 198 struct inpcb tcb; /* head of queue of active tcpcb's */ 199 struct tcpstat tcpstat; /* tcp statistics */ 200 struct tcpiphdr *tcp_template(); 201 struct tcpcb *tcp_close(), *tcp_drop(); 202 struct tcpcb *tcp_timers(), *tcp_disconnect(), *tcp_usrclosed(); 203 #endif 204