• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*****************************************************************************/
2 /* "NetPIPE" -- Network Protocol Independent Performance Evaluator.          */
3 /* Copyright 1997, 1998 Iowa State University Research Foundation, Inc.      */
4 /*                                                                           */
5 /* This program is free software; you can redistribute it and/or modify      */
6 /* it under the terms of the GNU General Public License as published by      */
7 /* the Free Software Foundation.  You should have received a copy of the     */
8 /* GNU General Public License along with this program; if not, write to the  */
9 /* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.   */
10 /*                                                                           */
11 /*     * netpipe.h          ---- General include file                        */
12 /*****************************************************************************/
13 
14 
15 #include <ctype.h>
16 #include <errno.h>
17 #include <signal.h>
18 #include <unistd.h>
19 #include <stdio.h>
20 #include <stdlib.h>         /* malloc(3) */
21 #include <string.h>
22 #include <sys/types.h>
23 #include <sys/time.h>       /* struct timeval */
24 #ifdef HAVE_GETRUSAGE
25 #include <sys/resource.h>
26 #endif
27 
28 
29 #define  DEFPORT            5002
30 #define  TRIALS             7
31 #define  NSAMP              8000
32 #define  PERT               3
33 #define  LATENCYREPS        100
34 #define  LONGTIME           1e99
35 #define  CHARSIZE           8
36 #define  RUNTM              0.25
37 #define  STOPTM             1.0
38 #define  MAXINT             2147483647
39 
40 #define     ABS(x)     (((x) < 0)?(-(x)):(x))
41 #define     MIN(x,y)   (((x) < (y))?(x):(y))
42 #define     MAX(x,y)   (((x) > (y))?(x):(y))
43 
44 /* Need to include the protocol structure header file.                       */
45 /* Change this to reflect the protocol                                       */
46 #if defined(TCP)
47 #include "TCP.h"
48 #elif defined(MPI)
49 #include "MPI.h"
50 #elif defined(PVM)
51 #include "PVM.h"
52 #else
53 #error "One of TCP, MPI, or PVM must be defined during compilation"
54 #endif
55 
56 
57 typedef struct argstruct ArgStruct;
58 struct argstruct
59 {
60     /* This is the common information that is needed for all tests           */
61     char     *host;         /* Name of receiving host                        */
62     char     *server_host;  /* Name of sending host                          */
63     int      servicefd,     /* File descriptor of the network socket         */
64              commfd;        /* Communication file descriptor                 */
65     short    port;          /* Port used for connection                      */
66     char     *buff;         /* Transmitted buffer                            */
67     char     *buff1;        /* Transmitted buffer                            */
68     int      bufflen,       /* Length of transmitted buffer                  */
69              tr,            /* Transmit flag                                 */
70              sr,            /* Server flag                                   */
71              nbuff;         /* Number of buffers to transmit                 */
72 
73     /* Now we work with a union of information for protocol dependent stuff  */
74     ProtocolStruct prot;    /* Structure holding necessary info for TCP      */
75 };
76 
77 typedef struct data Data;
78 struct data
79 {
80     double t;
81     double bps;
82     double variance;
83     int    bits;
84     int    repeat;
85 };
86 
87 double When();
88 
89 int Setup(ArgStruct *p);
90 
91 void Sync(ArgStruct *p);
92 
93 void PrepareToReceive(ArgStruct *p);
94 
95 void SendData(ArgStruct *p);
96 
97 void RecvData(ArgStruct *p);
98 
99 void SendTime(ArgStruct *p, double *t);
100 
101 void RecvTime(ArgStruct *p, double *t);
102 
103 void SendRepeat(ArgStruct *p, int rpt);
104 
105 void RecvRepeat(ArgStruct *p, int *rpt);
106 
107 int Establish(ArgStruct *p);
108 
109 int  CleanUp(ArgStruct *p);
110