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 #include <ctype.h>
15 #include <errno.h>
16 #include <signal.h>
17 #include <stdio.h>
18 #include <stdlib.h>         /* malloc(3) */
19 #include <string.h>
20 #include <sys/types.h>
21 #include <sys/time.h>       /* struct timeval */
22 #ifdef HAVE_GETRUSAGE
23 #include <sys/resource.h>
24 #endif
25 #include <unistd.h>
26 
27 
28 #define  DEFPORT            5002
29 #define  TRIALS             7
30 #define  NSAMP              8000
31 #define  PERT               3
32 #define  LATENCYREPS        100
33 #define  LONGTIME           1e99
34 #define  CHARSIZE           8
35 #define  RUNTM              0.25
36 #define  STOPTM             1.0
37 #define  MAXINT             2147483647
38 
39 #define     ABS(x)     (((x) < 0)?(-(x)):(x))
40 #define     MIN(x,y)   (((x) < (y))?(x):(y))
41 #define     MAX(x,y)   (((x) > (y))?(x):(y))
42 
43 /* Need to include the protocol structure header file.                       */
44 /* Change this to reflect the protocol                                       */
45 #if defined(TCP)
46 #include "TCP.h"
47 #elif defined(MPI)
48 #include "MPI.h"
49 #elif defined(PVM)
50 #include "PVM.h"
51 #else
52 #error "One of TCP, MPI, or PVM must be defined during compilation"
53 #endif
54 
55 
56 typedef struct argstruct ArgStruct;
57 struct argstruct
58 {
59     /* This is the common information that is needed for all tests           */
60     char     *host;         /* Name of receiving host                        */
61     int      servicefd,     /* File descriptor of the network socket         */
62              commfd;        /* Communication file descriptor                 */
63     short    port;          /* Port used for connection                      */
64     char     *buff;         /* Transmitted buffer                            */
65     char     *buff1;        /* Transmitted buffer                            */
66     int      bufflen,       /* Length of transmitted buffer                  */
67              tr,            /* Transmit flag                                 */
68              nbuff;         /* Number of buffers to transmit                 */
69 
70     /* Now we work with a union of information for protocol dependent stuff  */
71     ProtocolStruct prot;    /* Structure holding necessary info for TCP      */
72 };
73 
74 typedef struct data Data;
75 struct data
76 {
77     double t;
78     double bps;
79     double variance;
80     int    bits;
81     int    repeat;
82 };
83 
84 double When();
85 
86 void PrintUsage(void);
87 
88 int Setup(ArgStruct *p);
89 
90 void Sync(ArgStruct *p);
91 
92 void PrepareToReceive(ArgStruct *p);
93 
94 void SendData(ArgStruct *p);
95 
96 void RecvData(ArgStruct *p);
97 
98 void SendTime(ArgStruct *p, double *t);
99 
100 void RecvTime(ArgStruct *p, double *t);
101 
102 void SendRepeat(ArgStruct *p, int rpt);
103 
104 void RecvRepeat(ArgStruct *p, int *rpt);
105 
106 int Establish(ArgStruct *p);
107 
108 int  CleanUp(ArgStruct *p);
109