blob: 6c5372e3bcfdd0aecf2852b178237e06884f9cae [file] [log] [blame]
Benny Prijono8df5b022006-03-01 19:31:18 +00001/* $Id$ */
2/*
3 * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
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; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJSIP_PERF_H__
20#define __PJSIP_PERF_H__
21
22#include <pjsua-lib/pjsua.h>
23
24
25PJ_BEGIN_DECL
26
27
28typedef struct batch batch;
29typedef struct session session;
30
31/**
32 * A test batch.
33 */
34struct batch
35{
36 PJ_DECL_LIST_MEMBER(struct batch);
37
Benny Prijono3cb39702006-03-01 22:26:51 +000038 unsigned rate; /**< How many tasks to perform */
39
40 unsigned started; /**< # of tasks started. */
41 unsigned success; /**< # of tasks completed successfully. */
42 unsigned failed; /**< # of failed tasks. */
43
44 pj_time_val start_time; /**< Start time of the tests. */
45 pj_time_val spawned_time; /**< Time when all tasks has been started. */
46 pj_time_val end_time; /**< Time when all tasks has completed. */
Benny Prijono8df5b022006-03-01 19:31:18 +000047};
48
49/**
50 * Test session.
51 */
52struct session
53{
54 pj_pool_t *pool;
55 pj_time_val start_time;
56 pj_bool_t stopping;
57 pjsip_method method;
58 struct batch active_list;
59 struct batch free_list;
60
61 unsigned outstanding;
62 unsigned total_created;
63};
64
65
66/**
67 * Request parameter.
68 */
69struct request_param
70{
71 pj_str_t dst;
72 pj_str_t src;
73 pjsip_cred_info cred;
74};
75
76
77typedef struct request_param request_param;
78
79
80void app_perror(const char *sender, const char *title, pj_status_t status);
81
82/* OPTIONS test */
83pj_status_t options_handler_init(void);
84pj_status_t options_spawn_test(const pj_str_t *target,
85 const pj_str_t *from,
86 const pj_str_t *to,
87 unsigned cred_cnt,
88 const pjsip_cred_info cred[],
89 const pjsip_route_hdr *route_set,
90 void *test_data,
91 void (*completion_cb)(void*,pj_bool_t));
92
93/* CALL test */
94pj_status_t call_handler_init(void);
95pj_status_t call_spawn_test( const pj_str_t *target,
96 const pj_str_t *from,
97 const pj_str_t *to,
98 unsigned cred_cnt,
99 const pjsip_cred_info cred[],
100 const pjsip_route_hdr *route_set,
101 void *test_data,
102 void (*completion_cb)(void*,pj_bool_t));
103
104
105
106/**
107 * Global settings
108 */
109struct pjsip_perf_settings
110{
111 /* Global */
112 pj_caching_pool cp;
113 pj_pool_t *pool;
114 pjsip_endpoint *endpt;
115 pj_mutex_t *mutex;
116
Benny Prijono3cb39702006-03-01 22:26:51 +0000117 /* Misc: */
118 int log_level;
119 int app_log_level;
120 char *log_file;
121
Benny Prijono8df5b022006-03-01 19:31:18 +0000122 /* Network: */
123 int local_port;
124
125 /* Threads. */
126 pj_bool_t quit_flag;
127 int thread_cnt;
128 pj_thread_t *thread[16];
129
130 /* Outgoing request method: */
131 pjsip_method method;
132
133 /* Default target: */
134 pj_str_t target;
135
136 /* Media: */
137 pjmedia_endpt *med_endpt;
138 pjmedia_conf *mconf;
139
140 /* Handling incoming requests: */
141 pj_bool_t stateless;
142
143 /* Rate control. */
144 pj_uint32_t start_rate;
145 pj_uint32_t cur_rate;
146
147 /* Capacity control. */
148 pj_uint32_t max_capacity;
149
150 /* Duration control: */
151 pj_uint32_t duration;
152
153 /* Test control: */
154 session *session;
155 pj_timer_entry timer;
Benny Prijono3cb39702006-03-01 22:26:51 +0000156
157 /* Counters: */
158 pj_uint32_t tx_req;
159 pj_uint32_t tx_res;
160 pj_uint32_t rx_req;
161 pj_uint32_t rx_res;
Benny Prijono8df5b022006-03-01 19:31:18 +0000162};
163
164
165typedef struct pjsip_perf_settings pjsip_perf_settings;
166
167extern pjsip_perf_settings settings;
168
169
170
171PJ_END_DECL
172
173
174#endif /* __PJSIP_PERF_H__ */
175
176
177
178