home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / include / netiso / tp_stat.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-30  |  9.6 KB  |  302 lines

  1. /*
  2.  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  3.  *
  4.  * @APPLE_LICENSE_HEADER_START@
  5.  * 
  6.  * The contents of this file constitute Original Code as defined in and
  7.  * are subject to the Apple Public Source License Version 1.1 (the
  8.  * "License").  You may not use this file except in compliance with the
  9.  * License.  Please obtain a copy of the License at
  10.  * http://www.apple.com/publicsource and read it before using this file.
  11.  * 
  12.  * This Original Code and all software distributed under the License are
  13.  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  14.  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  15.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  16.  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
  17.  * License for the specific language governing rights and limitations
  18.  * under the License.
  19.  * 
  20.  * @APPLE_LICENSE_HEADER_END@
  21.  */
  22. /*-
  23.  * Copyright (c) 1991, 1993
  24.  *    The Regents of the University of California.  All rights reserved.
  25.  *
  26.  * Redistribution and use in source and binary forms, with or without
  27.  * modification, are permitted provided that the following conditions
  28.  * are met:
  29.  * 1. Redistributions of source code must retain the above copyright
  30.  *    notice, this list of conditions and the following disclaimer.
  31.  * 2. Redistributions in binary form must reproduce the above copyright
  32.  *    notice, this list of conditions and the following disclaimer in the
  33.  *    documentation and/or other materials provided with the distribution.
  34.  * 3. All advertising materials mentioning features or use of this software
  35.  *    must display the following acknowledgement:
  36.  *    This product includes software developed by the University of
  37.  *    California, Berkeley and its contributors.
  38.  * 4. Neither the name of the University nor the names of its contributors
  39.  *    may be used to endorse or promote products derived from this software
  40.  *    without specific prior written permission.
  41.  *
  42.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  43.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  44.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  45.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  46.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  47.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  48.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  49.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  50.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  51.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  52.  * SUCH DAMAGE.
  53.  *
  54.  *    @(#)tp_stat.h    8.1 (Berkeley) 6/10/93
  55.  */
  56.  
  57. /***********************************************************
  58.         Copyright IBM Corporation 1987
  59.  
  60.                       All Rights Reserved
  61.  
  62. Permission to use, copy, modify, and distribute this software and its 
  63. documentation for any purpose and without fee is hereby granted, 
  64. provided that the above copyright notice appear in all copies and that
  65. both that copyright notice and this permission notice appear in 
  66. supporting documentation, and that the name of IBM not be
  67. used in advertising or publicity pertaining to distribution of the
  68. software without specific, written prior permission.  
  69.  
  70. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  71. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  72. IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  73. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  74. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  75. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  76. SOFTWARE.
  77.  
  78. ******************************************************************/
  79.  
  80. /*
  81.  * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
  82.  */
  83. /* 
  84.  * ARGO TP
  85.  *
  86.  * Here are the data structures in which the global
  87.  * statistics(counters) are gathered.
  88.  */
  89.  
  90. #ifndef __TP_STAT__
  91. #define __TP_STAT__
  92.  
  93. struct tp_stat {
  94.     u_long ts_param_ignored;
  95.     u_long ts_unused3;
  96.     u_long ts_bad_csum;
  97.  
  98.     u_long ts_inv_length;
  99.     u_long ts_inv_pcode;
  100.     u_long ts_inv_dutype;
  101.     u_long ts_negotfailed;
  102.     u_long ts_inv_dref;
  103.     u_long ts_inv_pval;
  104.     u_long ts_inv_sufx;
  105.     u_long ts_inv_aclass;
  106.  
  107.     u_long ts_xtd_fmt;
  108.     u_long ts_use_txpd;
  109.     u_long ts_csum_off;
  110.     u_long    ts_send_drop;
  111.     u_long    ts_recv_drop;
  112.  
  113.     u_long ts_xpd_intheway;/* xpd mark caused data flow to stop */
  114.     u_long ts_xpdmark_del;    /* xpd markers thrown away */
  115.     u_long ts_dt_ooo;        /* dt tpdus received out of order */
  116.     u_long ts_dt_niw;        /* dt tpdus received & not in window */
  117.     u_long ts_xpd_niw;        /* xpd tpdus received & not in window */
  118.     u_long ts_xpd_dup;        
  119.     u_long ts_dt_dup;        /* dt tpdus received & are duplicates */
  120.  
  121.     u_long ts_zfcdt;        /* # times f credit went down to 0 */
  122.     u_long ts_lcdt_reduced; /* 
  123.         # times local cdt reduced on an acknowledgement.
  124.         */
  125.  
  126.     u_long    ts_pkt_rcvd; /* from ip */
  127.     u_long    ts_tpdu_rcvd; /* accepted as a TPDU in tp_input */
  128.     u_long    ts_tpdu_sent;
  129.     u_long    ts_unused2;
  130.  
  131.     u_long    ts_retrans_cr;
  132.     u_long    ts_retrans_cc;
  133.     u_long    ts_retrans_dr;
  134.     u_long    ts_retrans_dt;
  135.     u_long    ts_retrans_xpd;
  136.     u_long    ts_conn_gaveup;
  137.  
  138.     u_long ts_ER_sent;
  139.     u_long    ts_DT_sent;
  140.     u_long    ts_XPD_sent;
  141.     u_long    ts_AK_sent;
  142.     u_long    ts_XAK_sent;
  143.     u_long    ts_DR_sent;
  144.     u_long    ts_DC_sent;
  145.     u_long    ts_CR_sent;
  146.     u_long    ts_CC_sent;
  147.  
  148.     u_long ts_ER_rcvd;
  149.     u_long    ts_DT_rcvd;
  150.     u_long    ts_XPD_rcvd;
  151.     u_long    ts_AK_rcvd;
  152.     u_long    ts_XAK_rcvd;
  153.     u_long    ts_DR_rcvd;
  154.     u_long    ts_DC_rcvd;
  155.     u_long    ts_CR_rcvd;
  156.     u_long    ts_CC_rcvd;
  157.  
  158.     u_long    ts_Eticks;
  159.     u_long    ts_Eexpired;
  160.     u_long    ts_Eset;
  161.     u_long    ts_Ecan_act;
  162.     u_long    ts_Cticks;
  163.     u_long    ts_Cexpired;
  164.     u_long    ts_Cset;
  165.     u_long    ts_Ccan_act;
  166.     u_long    ts_Ccan_inact;
  167.     u_long    ts_Fdelack;
  168.     u_long    ts_Fpruned;
  169.  
  170.     u_long    ts_concat_rcvd;
  171.  
  172.     u_long    ts_zdebug; /* zero dref to test timeout on conn estab tp_input.c */
  173.     u_long ts_ydebug; /* throw away pseudo-random pkts tp_input.c */
  174.     u_long ts_unused5;
  175.     u_long ts_unused; /* kludged concat to test separation tp_emit.c */
  176.     u_long ts_vdebug; /* kludge to test input size checking tp_emit.c */
  177.     u_long ts_unused4;
  178.     u_long ts_ldebug; /* faked a renegging of credit */
  179.  
  180.     u_long ts_mb_small;
  181.     u_long ts_mb_cluster;
  182.     u_long ts_mb_len_distr[17];
  183.  
  184.     u_long ts_eot_input;
  185.     u_long ts_eot_user;
  186.     u_long    ts_EOT_sent;
  187.     u_long ts_tp0_conn;
  188.     u_long ts_tp4_conn;
  189.     u_long ts_quench;
  190.     u_long ts_rcvdecbit;
  191.  
  192. #define NRTT_CATEGORIES 4
  193.     /*  The 4 categories are:
  194.      * 0 --> tp_flags: ~TPF_PEER_ON_SAMENET |  TPF_NL_PDN
  195.      * 1 --> tp_flags: ~TPF_PEER_ON_SAMENET | ~TPF_NL_PDN
  196.      * 2 --> tp_flags:  TPF_PEER_ON_SAMENET | ~TPF_NL_PDN
  197.      * 3 --> tp_flags:  TPF_PEER_ON_SAMENET |  TPF_NL_PDN
  198.      */
  199.     int ts_rtt[NRTT_CATEGORIES];
  200.     int ts_rtv[NRTT_CATEGORIES];
  201.  
  202.     u_long ts_ackreason[_ACK_NUM_REASONS_];
  203.         /*  ACK_DONT 0 / ACK_STRAT_EACH 0x1 / ACK_STRAT_FULLWIN 0x4
  204.            *    ACK_DUP 0x8 / ACK_EOT 0x10  / ACK_REORDER 0x20
  205.            *    ACK_USRRCV **
  206.            *    ACK_FCC **
  207.          */
  208. } tp_stat ;
  209. #define     TP_PM_MAX            0xa /* 10 decimal */
  210.  
  211. #define IncStat(x) tp_stat./**/x/**/++
  212.  
  213. #ifdef TP_PERF_MEAS
  214.  
  215. #define PStat(Tpcb, X) (Tpcb)->tp_p_meas->/**/X/**/
  216. #define IncPStat(Tpcb, X) if((Tpcb)->tp_perf_on) (Tpcb)->tp_p_meas->/**/X/**/++
  217.  
  218. /* BEWARE OF MACROS like this ^^^ must be sure it's surrounded by {} if
  219.  * it's used in an if-else statement. 
  220.  */
  221.  
  222.  
  223. /* for perf measurement stuff: maximum window size it can handle */
  224.  
  225. struct tp_pmeas {
  226.         /* the first few are distributions as a fn of window size 
  227.          * only keep enough space for normal format plus 1 slot for
  228.          * extended format, in case any windows larger than 15 are used
  229.          */
  230.  
  231.         /* 
  232.          * tps_npdusent: for each call to tp_sbsend, we inc the 
  233.          * element representing the number of pdus sent in this call
  234.          */
  235.         int        tps_win_lim_by_cdt[TP_PM_MAX+1]; 
  236.         int        tps_win_lim_by_data[TP_PM_MAX+1]; 
  237.         /* 
  238.          * tps_sendtime: Each call to tp_sbsend() is timed.  For
  239.          * Each window size, we keep the running average of the time
  240.          * taken by tp_sbsend() for each window size.
  241.          */
  242.         int    tps_sendtime[TP_PM_MAX+1]; 
  243.         /*
  244.          * n_TMsendack: # times ack sent because timer went off
  245.          * n_ack_cuz_eot: # times ack sent due to EOTSDU on incoming packet
  246.          * n_ack_cuz_dup: # times ack sent for receiving a duplicate pkt.
  247.          * n_ack_cuz_fullwin: # times ack sent for receiving the full window.
  248.          * n_ack_cuz_doack: # times ack sent for having just reordered data.
  249.          */
  250.         int        tps_n_TMsendack;
  251.         int        tps_n_ack_cuz_eot;
  252.         int        tps_n_ack_cuz_fullwin;
  253.         int        tps_n_ack_cuz_reorder;
  254.         int        tps_n_ack_cuz_dup;
  255.         int        tps_n_ack_cuz_strat;
  256.         /*
  257.          * when we send an ack: how much less than the "expected" window
  258.          * did we actually ack.  For example: if we last sent a credit
  259.          * of 10, and we're acking now for whatever reason, and have
  260.          * only received 6 since our last credit advertisement, we'll
  261.          * keep the difference, 4, in this variable.
  262.          */
  263.         int        tps_ack_early[TP_PM_MAX+1]; 
  264.         /*
  265.          * when we ack, for the # pkts we actually acked w/ this ack,
  266.          * how much cdt are we advertising?
  267.          * [ size of window acknowledged ] [ cdt we're giving ]
  268.          */
  269.         int        tps_cdt_acked[TP_PM_MAX+1][TP_PM_MAX+1]; 
  270.  
  271.         int     tps_AK_sent;
  272.         int     tps_XAK_sent;
  273.         int     tps_DT_sent;
  274.         int     tps_XPD_sent;
  275.         int     tps_AK_rcvd;
  276.         int     tps_XAK_rcvd;
  277.         int     tps_DT_rcvd;
  278.         int     tps_XPD_rcvd;
  279.  
  280.         int        Nb_from_sess;
  281.         int        Nb_to_sess;
  282.         int        Nb_to_ll;
  283.         int        Nb_from_ll;
  284. };
  285.  
  286. #define  IFPERF(tpcb)  if (tpcb->tp_perf_on && tpcb->tp_p_meas) {
  287. #define  ENDPERF }
  288.  
  289. #else
  290.  
  291. int PStat_Junk;
  292. #define PStat(tpcb, x)  PStat_Junk
  293. #define IncPStat(tpcb, x)  /* no-op */
  294. #define tpmeas(a,b,c,d,e,f) 0
  295.  
  296. #define IFPERF(x)    if (0) {
  297. #define ENDPERF }
  298.  
  299. #endif /* TP_PERF_MEAS */
  300.  
  301. #endif /* __TP_STAT__ */
  302.