merge in NFS code from Rick Macklem
[unix-history] / usr / src / sys / netinet / tcp_var.h
index 20dcd77..61c672e 100644 (file)
 /*
  * Copyright (c) 1982, 1986 Regents of the University of California.
 /*
  * Copyright (c) 1982, 1986 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
  *
  *
- *     @(#)tcp_var.h   7.3 (Berkeley) %G%
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ *     @(#)tcp_var.h   7.8 (Berkeley) %G%
+ */
+
+/*
+ * TCP configuration:  This is a half-assed attempt to make TCP
+ * self-configure for a few varieties of 4.2 and 4.3-based unixes.
+ * If you don't have a) a 4.3bsd vax or b) a 3.x Sun (x<6), check
+ * this carefully (it's probably not right).  Please send me mail
+ * if you run into configuration problems.
+ *  - Van Jacobson (van@lbl-csam.arpa)
  */
 
  */
 
+#ifndef BSD
+#define BSD 42 /* if we're not 4.3, pretend we're 4.2 */
+#define OLDSTAT        /* set if we have to use old netstat binaries */
+#endif
+
+/* #define OLDSTAT     /* set if we have to use old netstat binaries */
+
+#if sun || BSD < 43
+#define TCP_COMPAT_42  /* set if we have to interop w/4.2 systems */
+#endif
+
+#ifndef SB_MAX
+#ifdef SB_MAXCOUNT
+#define        SB_MAX  SB_MAXCOUNT     /* Sun has to be a little bit different... */
+#else
+#define SB_MAX 32767           /* XXX */
+#endif SB_MAXCOUNT
+#endif SB_MAX
+
+#ifndef IP_MAXPACKET
+#define        IP_MAXPACKET    65535           /* maximum packet size */
+#endif
+
+/*
+ * Bill Nowicki pointed out that the page size (CLBYTES) has
+ * nothing to do with the mbuf cluster size.  So, we followed
+ * Sun's lead and made the new define MCLBYTES stand for the mbuf
+ * cluster size.  The following define makes up backwards compatible
+ * with 4.3 and 4.2.  If CLBYTES is >1024 on your machine, check
+ * this against the mbuf cluster definitions in /usr/include/sys/mbuf.h.
+ */
+#ifndef MCLBYTES
+#define        MCLBYTES CLBYTES        /* XXX */
+#endif
+
+/*
+ * The routine in_localaddr is broken in Sun's 3.4.  We redefine ours
+ * (in tcp_input.c) so we use can it but won't have a name conflict.
+ */
+#ifdef sun
+#define in_localaddr tcp_in_localaddr
+#endif
+
+/* --------------- end of TCP config ---------------- */
+
+/*
+ * TCP configuration:  This is a half-assed attempt to make TCP
+ * self-configure for a few varieties of 4.2 and 4.3-based unixes.
+ * If you don't have a) a 4.3bsd vax or b) a 3.x Sun (x<6), check
+ * this carefully (it's probably not right).  Please send me mail
+ * if you run into configuration problems.
+ *  - Van Jacobson (van@lbl-csam.arpa)
+ */
+
+#ifndef BSD
+#define BSD 42 /* if we're not 4.3, pretend we're 4.2 */
+#define OLDSTAT        /* set if we have to use old netstat binaries */
+#endif
+
+/* #define OLDSTAT     /* set if we have to use old netstat binaries */
+
+#if sun || BSD < 43
+#define TCP_COMPAT_42  /* set if we have to interop w/4.2 systems */
+#endif
+
+#ifndef SB_MAX
+#ifdef SB_MAXCOUNT
+#define        SB_MAX  SB_MAXCOUNT     /* Sun has to be a little bit different... */
+#else
+#define SB_MAX 32767           /* XXX */
+#endif SB_MAXCOUNT
+#endif SB_MAX
+
+/*
+ * Bill Nowicki pointed out that the page size (CLBYTES) has
+ * nothing to do with the mbuf cluster size.  So, we followed
+ * Sun's lead and made the new define MCLBYTES stand for the mbuf
+ * cluster size.  The following define makes up backwards compatible
+ * with 4.3 and 4.2.  If CLBYTES is >1024 on your machine, check
+ * this against the mbuf cluster definitions in /usr/include/sys/mbuf.h.
+ */
+#ifndef MCLBYTES
+#define        MCLBYTES CLBYTES        /* XXX */
+#endif
+
+/*
+ * The routine in_localaddr is broken in Sun's 3.4.  We redefine ours
+ * (in tcp_input.c) so we use can it but won't have a name conflict.
+ */
+#ifdef sun
+#define in_localaddr tcp_in_localaddr
+#endif
+
+/* --------------- end of TCP config ---------------- */
+
 /*
  * Kernel variables for tcp.
  */
 /*
  * Kernel variables for tcp.
  */
@@ -19,7 +134,8 @@ struct tcpcb {
        short   t_state;                /* state of this connection */
        short   t_timer[TCPT_NTIMERS];  /* tcp timers */
        short   t_rxtshift;             /* log(2) of rexmt exp. backoff */
        short   t_state;                /* state of this connection */
        short   t_timer[TCPT_NTIMERS];  /* tcp timers */
        short   t_rxtshift;             /* log(2) of rexmt exp. backoff */
-       struct  mbuf *t_tcpopt;         /* tcp options */
+       short   t_rxtcur;               /* current retransmit value */
+       short   t_dupacks;              /* consecutive dup acks recd */
        u_short t_maxseg;               /* maximum segment size */
        char    t_force;                /* 1 if forcing out a byte */
        u_char  t_flags;
        u_short t_maxseg;               /* maximum segment size */
        char    t_force;                /* 1 if forcing out a byte */
        u_char  t_flags;
@@ -56,19 +172,23 @@ struct tcpcb {
        tcp_seq snd_max;                /* highest sequence number sent
                                         * used to recognize retransmits
                                         */
        tcp_seq snd_max;                /* highest sequence number sent
                                         * used to recognize retransmits
                                         */
-/* congestion control (for source quench) */
+/* congestion control (for slow start, source quench, retransmit after loss) */
        u_short snd_cwnd;               /* congestion-controlled window */
        u_short snd_cwnd;               /* congestion-controlled window */
+       u_short snd_ssthresh;           /* snd_cwnd size threshhold for
+                                        * for slow start exponential to
+                                        * linear switch */
 /*
  * transmit timing stuff.
  * srtt and rttvar are stored as fixed point; for convenience in smoothing,
  * srtt has 3 bits to the right of the binary point, rttvar has 2.
 /*
  * transmit timing stuff.
  * srtt and rttvar are stored as fixed point; for convenience in smoothing,
  * srtt has 3 bits to the right of the binary point, rttvar has 2.
+ * "Variance" is actually smoothed difference.
  */
        short   t_idle;                 /* inactivity time */
        short   t_rtt;                  /* round trip time */
  */
        short   t_idle;                 /* inactivity time */
        short   t_rtt;                  /* round trip time */
-       u_short max_rcvd;               /* most peer has sent into window */
        tcp_seq t_rtseq;                /* sequence number being timed */
        short   t_srtt;                 /* smoothed round-trip time */
        short   t_rttvar;               /* variance in round-trip time */
        tcp_seq t_rtseq;                /* sequence number being timed */
        short   t_srtt;                 /* smoothed round-trip time */
        short   t_rttvar;               /* variance in round-trip time */
+       u_short max_rcvd;               /* most peer has sent into window */
        u_short max_sndwnd;             /* largest window peer has offered */
 /* out-of-band data */
        char    t_oobflags;             /* have some */
        u_short max_sndwnd;             /* largest window peer has offered */
 /* out-of-band data */
        char    t_oobflags;             /* have some */
@@ -86,6 +206,38 @@ struct tcpcb {
  * but that's inconvenient at the moment.
  */
 struct tcpstat {
  * but that's inconvenient at the moment.
  */
 struct tcpstat {
+#ifdef OLDSTAT
+       /*
+        * Declare statistics the same as in 4.3
+        * at the start of tcpstat (same size and
+        * position) for netstat.
+        */
+       int     tcps_rcvbadsum;
+       int     tcps_rcvbadoff;
+       int     tcps_rcvshort;
+       int     tcps_badsegs;
+       int     tcps_unack;
+#define        tcps_badsum     tcps_rcvbadsum
+#define        tcps_badoff     tcps_rcvbadoff
+#define        tcps_hdrops     tcps_rcvshort
+
+#endif OLDSTAT
+#ifdef OLDSTAT
+       /*
+        * Declare statistics the same as in 4.3
+        * at the start of tcpstat (same size and
+        * position) for netstat.
+        */
+       int     tcps_rcvbadsum;
+       int     tcps_rcvbadoff;
+       int     tcps_rcvshort;
+       int     tcps_badsegs;
+       int     tcps_unack;
+#define        tcps_badsum     tcps_rcvbadsum
+#define        tcps_badoff     tcps_rcvbadoff
+#define        tcps_hdrops     tcps_rcvshort
+
+#endif OLDSTAT
        u_long  tcps_connattempt;       /* connections initiated */
        u_long  tcps_accepts;           /* connections accepted */
        u_long  tcps_connects;          /* connections established */
        u_long  tcps_connattempt;       /* connections initiated */
        u_long  tcps_accepts;           /* connections accepted */
        u_long  tcps_connects;          /* connections established */
@@ -116,9 +268,13 @@ struct     tcpstat {
        u_long  tcps_rcvtotal;          /* total packets received */
        u_long  tcps_rcvpack;           /* packets received in sequence */
        u_long  tcps_rcvbyte;           /* bytes received in sequence */
        u_long  tcps_rcvtotal;          /* total packets received */
        u_long  tcps_rcvpack;           /* packets received in sequence */
        u_long  tcps_rcvbyte;           /* bytes received in sequence */
+#ifndef OLDSTAT
+#ifndef OLDSTAT
        u_long  tcps_rcvbadsum;         /* packets received with ccksum errs */
        u_long  tcps_rcvbadoff;         /* packets received with bad offset */
        u_long  tcps_rcvshort;          /* packets received too short */
        u_long  tcps_rcvbadsum;         /* packets received with ccksum errs */
        u_long  tcps_rcvbadoff;         /* packets received with bad offset */
        u_long  tcps_rcvshort;          /* packets received too short */
+#endif
+#endif
        u_long  tcps_rcvduppack;        /* duplicate-only packets received */
        u_long  tcps_rcvdupbyte;        /* duplicate-only bytes received */
        u_long  tcps_rcvpartduppack;    /* packets with some duplicate data */
        u_long  tcps_rcvduppack;        /* duplicate-only packets received */
        u_long  tcps_rcvdupbyte;        /* duplicate-only bytes received */
        u_long  tcps_rcvpartduppack;    /* packets with some duplicate data */