3
A brief file description
5
@section license License
7
Licensed to the Apache Software Foundation (ASF) under one
8
or more contributor license agreements. See the NOTICE file
9
distributed with this work for additional information
10
regarding copyright ownership. The ASF licenses this file
11
to you under the Apache License, Version 2.0 (the
12
"License"); you may not use this file except in compliance
13
with the License. You may obtain a copy of the License at
15
http://www.apache.org/licenses/LICENSE-2.0
17
Unless required by applicable law or agreed to in writing, software
18
distributed under the License is distributed on an "AS IS" BASIS,
19
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
See the License for the specific language governing permissions and
21
limitations under the License.
24
/*************************** -*- Mod: C++ -*- *********************
27
******************************************************************/
32
#include "LoadGenerator.h"
38
#include <sys/socket.h>
39
#include <sys/resource.h>
40
#include <netinet/in.h>
41
#include <netinet/tcp.h>
42
#include <arpa/inet.h>
47
#include <openssl/rsa.h> /* SSLeay stuff */
48
#include <openssl/crypto.h>
49
#include <openssl/x509.h>
50
#include <openssl/pem.h>
51
#include <openssl/ssl.h>
52
#include <openssl/err.h>
53
#include <openssl/rand.h>
54
#define CHK_NULL(x) if ((x)==NULL) exit (1)
55
#define CHK_ERR(err,s) if ((err)==-1) { perror(s); exit(1); }
56
#define CHK_SSL(err) if ((err)==-1) { ERR_print_errors_fp(errFp); exit(2); }
58
#define DIFF_TIME(start_time,end_time) \
59
(long) (((double) (end_time).tv_sec*1000.0 + \
60
(double) (end_time).tv_usec / 1000.0) - \
61
((double) (start_time).tv_sec*1000.0 + \
62
(double) (start_time).tv_usec / 1000.0))
68
GOT_ONE_NEWLINE_IN_HEADERS,
69
GOT_TWO_NEWLINES_IN_HEADERS,
76
StatusStatus status_line_complete;
78
char buffer[MAX_STATUS_LEN];
83
struct timeval transaction_start_time;
84
struct timeval connect_time;
85
struct timeval first_byte_time;
86
struct timeval last_read_time;
87
struct timeval transaction_end_time;
88
struct timeval think_time_start;
96
StatusLineInfo status_line_info;
97
char request_sent[MAX_REQUEST_SIZE];
98
struct sockaddr_in *target_addr;
101
/* for differentiate a completed/non-completed connection */
106
/////////////////////
108
struct sockaddr_in dynamic_target_addr;
110
TSRequestAction action;
111
TSConnectionStatus conn_status;
113
/////////////////////
122
int report_no; /* Each report is labeled with a number */
125
double total_bytes_read; /* total bytes read; only from successful resp */
126
double total_bytes_requested; /* the bytes requested (excluding headers) */
127
double total_bytes_read_including_partial_docs;
128
long finished_requests; /* number of successful requests */
130
long failed_requests; /* number of failed requests */
131
long last_finished; /* number of finished requests at last report */
133
struct timeval start_time; /* start time */
134
struct timeval stop_time; /* stop time */
135
struct timeval reporting_time; /* current time */
136
struct timeval last_reporting_time; /* time of the last report */
138
long elapsed_time; /* Time since start */
139
long time_since_last_report; /* Time since last report */
140
double total_round_trip_time; /* Sum of all latencies */
141
double total_first_byte_latency; /* Sum of all first-byte latencies */
142
double total_connect_time; /* Sum of all connect times */
143
long max_round_trip_time; /* Max of all latencies */
144
long min_round_trip_time; /* Min of all latencies */
145
long max_first_byte_latency; /* Max First Byte Latency */
146
long min_first_byte_latency; /* Min First Byte Latency */
147
long max_connect_time; /* Max of all connect times */
148
long min_connect_time; /* Min of all connect times */
150
long round_trip_time_cutoff;
151
/* It will report how many latencies were above this cutoff (in msec) */
152
long above_round_trip_time_cutoff; /* Req above latency cutoff */
153
long first_byte_latency_cutoff;
154
/* It will report how many first byte latencies were above
155
this cutoff (in msec) */
156
long above_first_byte_latency_cutoff; /* Req above first-byte cutoff */
157
long connect_time_cutoff;
158
/* It will report how many connect times were above
159
this cutoff (in msec) */
160
long above_connect_time_cutoff; /* Req above connect cutoff */
164
histogram round_trip_histogram;
165
histogram first_byte_histogram;
166
histogram connect_histogram;
168
long generated_thinktime; /* Total number of reqs generated */
169
long thinktime_generated[MAX_THTSTIMES]; /* Number of reqs with
171
double total_actual_thinktime;
173
long generated_target_byterate; /* Total number of reqs generated */
174
long target_byterate_generated[MAX_TARGET_BYTERATES];
175
/* Number of reqs with each target_byterate */
176
long num_limited_byterate;
177
// number of transactions that had limited target_byterate
178
double total_limited_byterate_error;
179
// Total error among all the limited byterate trans
180
int reporting_interval;
182
int connections_open;
183
int max_connections_open;
185
double histogram_max;
186
double histogram_resolution;
188
int num_thinktimes; /* Number of thinktimes in the distribution */
189
long *thinktimes; /* actual thinktimes */
190
double *cumulative_thinktime_prob;
191
/* Cumulative probability of selecting different thinktimes
192
cumulative_size_prob[num_thinktimes-1] must be 1.0 */
194
int num_target_byterates; /* Number of thinktimes in the distribution */
195
long *target_byterates; /* actual thinktimes */
196
double *cumulative_target_byterate_prob;
197
/* Cumulative probability of selecting different
199
cumulative_target_byterate_prob[num_thinktimes-1]
203
int debug; /* Debugging Messages */
204
int ssl; /* ssl flad */
206
int client_id; /* Among all the client processes running what
208
LoadGenerator *load_generator;
211
// =0: real test, > 0 : warmup; create only warmup number of
218
struct timeval rr_time;
219
int total_reqs_last_poll;
221
struct pollfd *poll_vector;
222
char read_buf[MAX_READBUF_SIZE];
237
// Generate thinktime (in msecs from give distribution )
238
long generate_think_time();
240
long generate_target_byterate();
241
long compute_bytes_to_read(int user, struct timeval current_time);
242
// User i just finished, update stats
243
void update_completion_stats(int i);
244
int create_new_connection_and_send_request(int user, struct timeval current_time);
245
void initialize_stats();
246
void print_stats(int all);
247
long get_request_rate(struct timeval t);
248
void actual_test(int rr_flag);
252
LoadGenerator * aload_generator,
259
double *acumulative_thinktime_prob,
260
int anum_target_byterates,
261
long *atarget_byterates,
262
double *acumulative_target_byterates_prob,
263
int areporting_interval,
264
double ahistogram_max,
265
double ahistogram_resolution,
266
long around_trip_time_cutoff,
267
long afirst_byte_latency_cutoff,
268
long aconnect_time_cutoff, int aQOS_docsize, TSPlugin * aplug_in, int arequest_rate);
269
void report(char *metric, char *units, char *combiner, double value);
276
extern DoTest *do_test;
278
#endif // #ifndef DoTest_h_