|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982, 1986 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution is only permitted until one year after the first shipment ! 6: * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and ! 7: * binary forms are permitted provided that: (1) source distributions retain ! 8: * this entire copyright notice and comment, and (2) distributions including ! 9: * binaries display the following acknowledgement: This product includes ! 10: * software developed by the University of California, Berkeley and its ! 11: * contributors'' in the documentation or other materials provided with the ! 12: * distribution and in all advertising materials mentioning features or use ! 13: * of this software. Neither the name of the University nor the names of ! 14: * its contributors may be used to endorse or promote products derived from ! 15: * this software without specific prior written permission. ! 16: * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 17: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 18: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 19: * ! 20: * @(#)tcp_var.h 7.10 (Berkeley) 6/28/90 ! 21: */ ! 22: ! 23: /* ! 24: * Kernel variables for tcp. ! 25: */ ! 26: ! 27: /* ! 28: * Tcp control block, one per tcp; fields: ! 29: */ ! 30: struct tcpcb { ! 31: struct tcpiphdr *seg_next; /* sequencing queue */ ! 32: struct tcpiphdr *seg_prev; ! 33: short t_state; /* state of this connection */ ! 34: short t_timer[TCPT_NTIMERS]; /* tcp timers */ ! 35: short t_rxtshift; /* log(2) of rexmt exp. backoff */ ! 36: short t_rxtcur; /* current retransmit value */ ! 37: short t_dupacks; /* consecutive dup acks recd */ ! 38: u_short t_maxseg; /* maximum segment size */ ! 39: char t_force; /* 1 if forcing out a byte */ ! 40: u_char t_flags; ! 41: #define TF_ACKNOW 0x01 /* ack peer immediately */ ! 42: #define TF_DELACK 0x02 /* ack, but try to delay it */ ! 43: #define TF_NODELAY 0x04 /* don't delay packets to coalesce */ ! 44: #define TF_NOOPT 0x08 /* don't use tcp options */ ! 45: #define TF_SENTFIN 0x10 /* have sent FIN */ ! 46: struct tcpiphdr *t_template; /* skeletal packet for transmit */ ! 47: struct inpcb *t_inpcb; /* back pointer to internet pcb */ ! 48: /* ! 49: * The following fields are used as in the protocol specification. ! 50: * See RFC783, Dec. 1981, page 21. ! 51: */ ! 52: /* send sequence variables */ ! 53: tcp_seq snd_una; /* send unacknowledged */ ! 54: tcp_seq snd_nxt; /* send next */ ! 55: tcp_seq snd_up; /* send urgent pointer */ ! 56: tcp_seq snd_wl1; /* window update seg seq number */ ! 57: tcp_seq snd_wl2; /* window update seg ack number */ ! 58: tcp_seq iss; /* initial send sequence number */ ! 59: u_short snd_wnd; /* send window */ ! 60: /* receive sequence variables */ ! 61: u_short rcv_wnd; /* receive window */ ! 62: tcp_seq rcv_nxt; /* receive next */ ! 63: tcp_seq rcv_up; /* receive urgent pointer */ ! 64: tcp_seq irs; /* initial receive sequence number */ ! 65: /* ! 66: * Additional variables for this implementation. ! 67: */ ! 68: /* receive variables */ ! 69: tcp_seq rcv_adv; /* advertised window */ ! 70: /* retransmit variables */ ! 71: tcp_seq snd_max; /* highest sequence number sent; ! 72: * used to recognize retransmits ! 73: */ ! 74: /* congestion control (for slow start, source quench, retransmit after loss) */ ! 75: u_short snd_cwnd; /* congestion-controlled window */ ! 76: u_short snd_ssthresh; /* snd_cwnd size threshhold for ! 77: * for slow start exponential to ! 78: * linear switch ! 79: */ ! 80: /* ! 81: * transmit timing stuff. See below for scale of srtt and rttvar. ! 82: * "Variance" is actually smoothed difference. ! 83: */ ! 84: short t_idle; /* inactivity time */ ! 85: short t_rtt; /* round trip time */ ! 86: tcp_seq t_rtseq; /* sequence number being timed */ ! 87: short t_srtt; /* smoothed round-trip time */ ! 88: short t_rttvar; /* variance in round-trip time */ ! 89: u_short t_rttmin; /* minimum rtt allowed */ ! 90: u_short max_sndwnd; /* largest window peer has offered */ ! 91: ! 92: /* out-of-band data */ ! 93: char t_oobflags; /* have some */ ! 94: char t_iobc; /* input character */ ! 95: #define TCPOOB_HAVEDATA 0x01 ! 96: #define TCPOOB_HADDATA 0x02 ! 97: short t_softerror; /* possible error not yet reported */ ! 98: }; ! 99: ! 100: #define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb) ! 101: #define sototcpcb(so) (intotcpcb(sotoinpcb(so))) ! 102: ! 103: /* ! 104: * The smoothed round-trip time and estimated variance ! 105: * are stored as fixed point numbers scaled by the values below. ! 106: * For convenience, these scales are also used in smoothing the average ! 107: * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed). ! 108: * With these scales, srtt has 3 bits to the right of the binary point, ! 109: * and thus an "ALPHA" of 0.875. rttvar has 2 bits to the right of the ! 110: * binary point, and is smoothed with an ALPHA of 0.75. ! 111: */ ! 112: #define TCP_RTT_SCALE 8 /* multiplier for srtt; 3 bits frac. */ ! 113: #define TCP_RTT_SHIFT 3 /* shift for srtt; 3 bits frac. */ ! 114: #define TCP_RTTVAR_SCALE 4 /* multiplier for rttvar; 2 bits */ ! 115: #define TCP_RTTVAR_SHIFT 2 /* multiplier for rttvar; 2 bits */ ! 116: ! 117: /* ! 118: * The initial retransmission should happen at rtt + 4 * rttvar. ! 119: * Because of the way we do the smoothing, srtt and rttvar ! 120: * will each average +1/2 tick of bias. When we compute ! 121: * the retransmit timer, we want 1/2 tick of rounding and ! 122: * 1 extra tick because of +-1/2 tick uncertainty in the ! 123: * firing of the timer. The bias will give us exactly the ! 124: * 1.5 tick we need. But, because the bias is ! 125: * statistical, we have to test that we don't drop below ! 126: * the minimum feasible timer (which is 2 ticks). ! 127: * This macro assumes that the value of TCP_RTTVAR_SCALE ! 128: * is the same as the multiplier for rttvar. ! 129: */ ! 130: #define TCP_REXMTVAL(tp) \ ! 131: (((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar) ! 132: ! 133: /* XXX ! 134: * We want to avoid doing m_pullup on incoming packets but that ! 135: * means avoiding dtom on the tcp reassembly code. That in turn means ! 136: * keeping an mbuf pointer in the reassembly queue (since we might ! 137: * have a cluster). As a quick hack, the source & destination ! 138: * port numbers (which are no longer needed once we've located the ! 139: * tcpcb) are overlayed with an mbuf pointer. ! 140: */ ! 141: #define REASS_MBUF(ti) (*(struct mbuf **)&((ti)->ti_t)) ! 142: ! 143: /* ! 144: * TCP statistics. ! 145: * Many of these should be kept per connection, ! 146: * but that's inconvenient at the moment. ! 147: */ ! 148: struct tcpstat { ! 149: u_long tcps_connattempt; /* connections initiated */ ! 150: u_long tcps_accepts; /* connections accepted */ ! 151: u_long tcps_connects; /* connections established */ ! 152: u_long tcps_drops; /* connections dropped */ ! 153: u_long tcps_conndrops; /* embryonic connections dropped */ ! 154: u_long tcps_closed; /* conn. closed (includes drops) */ ! 155: u_long tcps_segstimed; /* segs where we tried to get rtt */ ! 156: u_long tcps_rttupdated; /* times we succeeded */ ! 157: u_long tcps_delack; /* delayed acks sent */ ! 158: u_long tcps_timeoutdrop; /* conn. dropped in rxmt timeout */ ! 159: u_long tcps_rexmttimeo; /* retransmit timeouts */ ! 160: u_long tcps_persisttimeo; /* persist timeouts */ ! 161: u_long tcps_keeptimeo; /* keepalive timeouts */ ! 162: u_long tcps_keepprobe; /* keepalive probes sent */ ! 163: u_long tcps_keepdrops; /* connections dropped in keepalive */ ! 164: ! 165: u_long tcps_sndtotal; /* total packets sent */ ! 166: u_long tcps_sndpack; /* data packets sent */ ! 167: u_long tcps_sndbyte; /* data bytes sent */ ! 168: u_long tcps_sndrexmitpack; /* data packets retransmitted */ ! 169: u_long tcps_sndrexmitbyte; /* data bytes retransmitted */ ! 170: u_long tcps_sndacks; /* ack-only packets sent */ ! 171: u_long tcps_sndprobe; /* window probes sent */ ! 172: u_long tcps_sndurg; /* packets sent with URG only */ ! 173: u_long tcps_sndwinup; /* window update-only packets sent */ ! 174: u_long tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */ ! 175: ! 176: u_long tcps_rcvtotal; /* total packets received */ ! 177: u_long tcps_rcvpack; /* packets received in sequence */ ! 178: u_long tcps_rcvbyte; /* bytes received in sequence */ ! 179: u_long tcps_rcvbadsum; /* packets received with ccksum errs */ ! 180: u_long tcps_rcvbadoff; /* packets received with bad offset */ ! 181: u_long tcps_rcvshort; /* packets received too short */ ! 182: u_long tcps_rcvduppack; /* duplicate-only packets received */ ! 183: u_long tcps_rcvdupbyte; /* duplicate-only bytes received */ ! 184: u_long tcps_rcvpartduppack; /* packets with some duplicate data */ ! 185: u_long tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */ ! 186: u_long tcps_rcvoopack; /* out-of-order packets received */ ! 187: u_long tcps_rcvoobyte; /* out-of-order bytes received */ ! 188: u_long tcps_rcvpackafterwin; /* packets with data after window */ ! 189: u_long tcps_rcvbyteafterwin; /* bytes rcvd after window */ ! 190: u_long tcps_rcvafterclose; /* packets rcvd after "close" */ ! 191: u_long tcps_rcvwinprobe; /* rcvd window probe packets */ ! 192: u_long tcps_rcvdupack; /* rcvd duplicate acks */ ! 193: u_long tcps_rcvacktoomuch; /* rcvd acks for unsent data */ ! 194: u_long tcps_rcvackpack; /* rcvd ack packets */ ! 195: u_long tcps_rcvackbyte; /* bytes acked by rcvd acks */ ! 196: u_long tcps_rcvwinupd; /* rcvd window update packets */ ! 197: }; ! 198: ! 199: #ifdef KERNEL ! 200: struct inpcb tcb; /* head of queue of active tcpcb's */ ! 201: struct tcpstat tcpstat; /* tcp statistics */ ! 202: struct tcpiphdr *tcp_template(); ! 203: struct tcpcb *tcp_close(), *tcp_drop(); ! 204: struct tcpcb *tcp_timers(), *tcp_disconnect(), *tcp_usrclosed(); ! 205: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.