home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilss / sockets / include / netinet / h / tcp_var < prev    next >
Encoding:
Text File  |  1995-01-11  |  9.9 KB  |  233 lines

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