1 /*
2     httperf -- a tool for measuring web server performance
3     Copyright 2000-2007 Hewlett-Packard Company
4 
5     This file is part of httperf, a web server performance measurment
6     tool.
7 
8     This program is free software; you can redistribute it and/or
9     modify it under the terms of the GNU General Public License as
10     published by the Free Software Foundation; either version 2 of the
11     License, or (at your option) any later version.
12 
13     In addition, as a special exception, the copyright holders give
14     permission to link the code of this work with the OpenSSL project's
15     "OpenSSL" library (or with modified versions of it that use the same
16     license as the "OpenSSL" library), and distribute linked combinations
17     including the two.  You must obey the GNU General Public License in
18     all respects for all of the code used other than "OpenSSL".  If you
19     modify this file, you may extend this exception to your version of the
20     file, but you are not obligated to do so.  If you do not wish to do
21     so, delete this exception statement from your version.
22 
23     This program is distributed in the hope that it will be useful,
24     but WITHOUT ANY WARRANTY; without even the implied warranty of
25     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26     General Public License for more details.
27 
28     You should have received a copy of the GNU General Public License
29     along with this program; if not, write to the Free Software
30     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
31     02110-1301, USA
32 */
33 
34 #ifndef httperf_h
35 #define httperf_h
36 
37 #include "config.h"
38 
39 #define NELEMS(a)	((sizeof (a)) / sizeof ((a)[0]))
40 #define TV_TO_SEC(tv)	((tv).tv_sec + 1e-6*(tv).tv_usec)
41 
42 #define NUM_RATES 16
43 
44 typedef enum Dist_Type
45   {
46     DETERMINISTIC,	/* also called fixed-rate */
47     UNIFORM,		/* over interval [min_iat,max_iat) */
48     VARIABLE,           /* allows varying input load */
49     EXPONENTIAL		/* with mean mean_iat */
50   }
51 Dist_Type;
52 
53 typedef struct Load_Generator
54   {
55     const char *name;
56     void (*init) (void);
57     void (*start) (void);
58     void (*stop) (void);
59   }
60 Load_Generator;
61 
62 typedef struct Stat_Collector
63   {
64     const char *name;
65     /* START and STOP are timing sensitive, so they should be as short
66        as possible.  More expensive stuff can be done during INIT and
67        DUMP.  */
68     void (*init) (void);
69     void (*start) (void);
70     void (*stop) (void);
71     void (*dump) (void);
72   }
73 Stat_Collector;
74 
75 typedef struct Rate_Info
76   {
77     Dist_Type dist;		/* interarrival distribution */
78     double rate_param;		/* 0 if mean_iat==0, else 1/mean_iat */
79     Time mean_iat;		/* mean interarrival time */
80     Time min_iat;		/* min interarrival time (for UNIFORM) */
81     Time max_iat;	        /* max interarrival time (for UNIFORM) */
82     int numRates;               /* number of rates we want to use */
83     Time iat[NUM_RATES];
84     Time duration[NUM_RATES];
85   }
86 Rate_Info;
87 
88 #define PRINT_HEADER	(1 << 0)
89 #define PRINT_BODY	(1 << 1)
90 
91 typedef struct Cmdline_Params
92   {
93     int http_version;	/* (default) HTTP protocol version */
94     const char *server;	/* (default) hostname */
95     const char *server_name; /* fully qualified server name */
96     const char *servers;
97     int port;		/* (default) server port */
98     const char *uri;	/* (default) uri */
99     const char *myaddr;
100     Rate_Info rate;
101     Time timeout;	/* watchdog timeout */
102     Time think_timeout;	/* timeout for server think time */
103     Time runtime;	/* how long to run the test */
104     u_long num_conns;	/* # of connections to generate */
105     u_long num_calls;	/* # of calls to generate per connection */
106     u_long burst_len;	/* # of calls to burst back-to-back */
107     u_long max_piped;	/* max # of piped calls per connection */
108     u_long max_conns;	/* max # of connections per session */
109     int hog;		/* client may hog as much resources as possible */
110     u_long send_buffer_size;
111     u_long recv_buffer_size;
112     int failure_status;	/* status code that should be considered failure */
113     int retry_on_failure; /* when a call fails, should we retry? */
114     int close_with_reset; /* close connections with TCP RESET? */
115     int print_request;	/* bit 0: print req headers, bit 1: print req body */
116     int print_reply;	/* bit 0: print repl headers, bit 1: print repl body */
117     int session_cookies; /* handle set-cookies? (at the session level) */
118     int no_host_hdr;	/* don't send Host: header in request */
119 #ifdef HAVE_SSL
120     int use_ssl;	/* connect via SSL */
121     int ssl_reuse;	/* reuse SSL Session ID */
122     int ssl_verify;     /* whether to verify the server certificate */
123     int ssl_protocol;   /* which SSL protocol to use */
124     const char *tls_server_name; /* TLS SNI (server name indication) */
125     const char *ssl_cipher_list; /* client's list of SSL cipher suites */
126     const char *ssl_cert; /* client certificate file name */
127     const char *ssl_key; /* client key file name */
128     const char *ssl_ca_file; /* certificate authority file */
129     const char *ssl_ca_path; /* certificate authority path */
130 #endif
131     int use_timer_cache;
132     const char *additional_header;	/* additional request header(s) */
133     const char *additional_header_file;
134     const char *method;	/* default call method */
135     struct
136       {
137 	u_int id;
138 	u_int num_clients;
139       }
140     client;
141     struct
142       {
143 	char *file;	/* name of the file where entries are */
144 	char do_loop;	/* boolean indicating if we want to loop on entries */
145       }
146     wlog;
147     struct
148       {
149 	u_int num_sessions;	/* # of sessions */
150 	u_int num_calls;	/* # of calls per session */
151 	Time think_time;	/* user think time between calls */
152       }
153     wsess;
154     struct
155       {
156 	u_int num_sessions;	/* # of sessions */
157 	u_int num_reqs;		/* # of user requests per session */
158 	Time think_time;	/* user think time between requests */
159       }
160     wsesspage;
161     struct
162       {
163 	u_int num_sessions;	/* # of user-sessions */
164 	Time think_time;	/* user think time between calls */
165 	char *file;		/* name of the file where session defs are */
166       }
167     wsesslog;
168     struct
169       {
170 	u_int num_files;
171 	double target_miss_rate;
172       }
173     wset;
174   }
175 Cmdline_Params;
176 
177 extern const char *prog_name;
178 extern int verbose;
179 extern int periodic_stats;
180 extern Cmdline_Params param;
181 extern Time test_time_start;
182 extern Time test_time_stop;
183 extern struct rusage test_rusage_start;
184 extern struct rusage test_rusage_stop;
185 
186 #ifdef HAVE_SSL
187 # include <openssl/ssl.h>
188   extern SSL_CTX *ssl_ctx;
189 #endif
190 
191 #ifdef DEBUG
192   extern int debug_level;
193 # define DBG debug_level
194 #else
195 # define DBG 0
196 #endif
197 
198 extern void panic (const char *msg, ...);
199 extern void no_op (void);
200 
201 #endif /* httperf_h */
202