comparison extensions/loadtest_cc/loadtest_cc.c @ 1366:9294ed1c7ac8

loadtest_cc: finish Provide all necessary AVPs. Provide statistics on exit.
author Thomas Klausner <tk@giga.or.at>
date Sun, 09 Jun 2019 15:44:30 +0200
parents a37692441c4d
children d1c40627673c
comparison
equal deleted inserted replaced
1365:0d951a67648b 1366:9294ed1c7ac8
39 #include <signal.h> 39 #include <signal.h>
40 40
41 #define MODULE_NAME "loadtest_cc" 41 #define MODULE_NAME "loadtest_cc"
42 42
43 static pthread_t gen_thr = (pthread_t)NULL; 43 static pthread_t gen_thr = (pthread_t)NULL;
44 struct disp_hdl *ccr_handler_hdl; 44 struct disp_hdl *ccr_local_hdl;
45 struct fd_rt_fwd_hdl *ccr_fwd_hdl;
45 volatile int do_generate = 0; 46 volatile int do_generate = 0;
46 47
47 const char *target = NULL; 48 const char *target = NULL;
48 49
49 struct dict_object * aai_avp_do; /* cache the Auth-Application-Id dictionary object */ 50 struct dict_object * aai_avp_do; /* cache the Auth-Application-Id dictionary object */
51 struct dict_object * crn_avp_do; /* cache the CC-Request-Number dictionary object */
52 struct dict_object * crt_avp_do; /* cache the CC-Request-Type dictionary object */
50 struct dict_object * dh_avp_do; /* cache the Destination-Host dictionary object */ 53 struct dict_object * dh_avp_do; /* cache the Destination-Host dictionary object */
51 struct dict_object * dr_avp_do; /* cache the Destination-Realm dictionary object */ 54 struct dict_object * dr_avp_do; /* cache the Destination-Realm dictionary object */
52 struct dict_object * rc_avp_do; /* cache the Result-Code dictionary object */ 55 struct dict_object * rc_avp_do; /* cache the Result-Code dictionary object */
56 struct dict_object * sci_avp_do; /* cache the Service-Context-Id dictionary object */
53 struct dict_object * si_avp_do; /* cache the Session-Id dictionary object */ 57 struct dict_object * si_avp_do; /* cache the Session-Id dictionary object */
54 struct dict_object * pi_avp_do; /* cache the Proxy-Info dictionary object */ 58 struct dict_object * pi_avp_do; /* cache the Proxy-Info dictionary object */
55 struct dict_object * ph_avp_do; /* cache the Proxy-Host dictionary object */ 59 struct dict_object * ph_avp_do; /* cache the Proxy-Host dictionary object */
56 struct dict_object * ps_avp_do; /* cache the Proxy-State dictionary object */ 60 struct dict_object * ps_avp_do; /* cache the Proxy-State dictionary object */
57 61
58 62 struct statistics {
59 static int ccr_handler(struct msg ** msg, struct avp * avp, struct session * sess, void * data, enum disp_action * act) 63 uint64_t sent;
60 { 64 uint64_t success;
65 uint64_t error;
66 time_t first;
67 time_t last;
68 } statistics;
69
70 static int handle_message(struct msg **msg) {
61 struct msg_hdr *hdr = NULL; 71 struct msg_hdr *hdr = NULL;
62 72 struct avp_hdr *ahdr = NULL;
63 TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act); 73 struct avp *rc;
64 74
65 if (msg == NULL) 75 if (msg == NULL) {
66 return EINVAL; 76 fd_log_error("[%s] NULL CCA message", MODULE_NAME);
77 return -1;
78 }
67 79
68 CHECK_FCT(fd_msg_hdr(*msg, &hdr)); 80 CHECK_FCT(fd_msg_hdr(*msg, &hdr));
69 if (hdr->msg_flags & CMD_FLAG_REQUEST) { 81 /* handle CCAs only */
70 fd_log_error("received Credit-Control-Request, dropping it"); 82 if ((hdr->msg_code != 272) || (hdr->msg_flags & CMD_FLAG_REQUEST)) {
83 fd_log_error("[%s] invalid message type (type %d, flags 0x%x)", MODULE_NAME, hdr->msg_code, hdr->msg_flags);
84 return -1;
85 }
86
87 /* Answer received, check it */
88 if (fd_msg_search_avp(*msg, rc_avp_do, &rc) < 0 || rc == NULL) {
89 fd_log_error("[%s] Result-Code not found in CCA", MODULE_NAME);
90 return -1;
91 }
92
93 if (fd_msg_avp_hdr(rc, &ahdr) < 0) {
94 fd_log_error("[%s] error parsing Result-Code in CCA", MODULE_NAME);
95 return -1;
96 }
97 fd_log_debug("Credit-Control-Answer with Result-Code %d received", ahdr->avp_value->i32);
98 switch (ahdr->avp_value->i32/1000) {
99 case 2:
100 statistics.success++;
101 break;
102 default:
103 statistics.error++;
104 break;
105 }
106
107 return 0;
108 }
109
110 static int ccr_local_handler(struct msg ** msg, struct avp * avp, struct session * sess, void * data, enum disp_action * act)
111 {
112 fd_log_debug("[%s] CCR local handler called", MODULE_NAME);
113
114 if (handle_message(msg) < 0) {
115 fd_log_error("dropping message");
71 CHECK_FCT(fd_msg_free(*msg)); 116 CHECK_FCT(fd_msg_free(*msg));
72 *msg = NULL; 117 *msg = NULL;
73 return 0; 118 return 0;
74 } 119 }
75 120
76 /* Answer received, check it */
77 fd_log_notice("Credit-Control-Answer received, this code should do something about it but doesn't yet");
78 /* TODO */
79 CHECK_FCT(fd_msg_free(*msg)); 121 CHECK_FCT(fd_msg_free(*msg));
80 *msg = NULL; 122 *msg = NULL;
123 return 0;
124 }
125
126 static int ccr_fwd_handler(void *cb_data, struct msg **msg)
127 {
128 fd_log_debug("[%s] CCR FWD handler called", MODULE_NAME);
129
130 if (handle_message(msg) < 0) {
131 return 0;
132 }
133
81 return 0; 134 return 0;
82 } 135 }
83 136
84 /* create message to send */ 137 /* create message to send */
85 struct msg *create_message(const char *destination) 138 struct msg *create_message(const char *destination)
89 struct avp *avp, *avp1; 142 struct avp *avp, *avp1;
90 union avp_value val; 143 union avp_value val;
91 struct msg_hdr *msg_hdr; 144 struct msg_hdr *msg_hdr;
92 const char *realm; 145 const char *realm;
93 const char *session_id = "fixed-session-id-for-now"; 146 const char *session_id = "fixed-session-id-for-now";
147 const char *service_context_id = "version2.clci.ipc@vodafone.com";
94 const char *proxy_host = "Dummy-Proxy-Host-to-Increase-Package-Size"; 148 const char *proxy_host = "Dummy-Proxy-Host-to-Increase-Package-Size";
95 const char *proxy_state = "This is just date to increase the package size\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXX";
96 150
97 if (fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Request", &command, ENOENT) != 0) { 151 if (fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Request", &command, ENOENT) != 0) {
98 fd_log_error("can't find template for 'Credit-Control-Request'"); 152 fd_log_error("can't find template for 'Credit-Control-Request'");
115 if (fd_msg_add_origin(msg, 0) != 0) { 169 if (fd_msg_add_origin(msg, 0) != 0) {
116 fd_log_error("can't set Origin for 'Credit-Control-Request' message"); 170 fd_log_error("can't set Origin for 'Credit-Control-Request' message");
117 fd_msg_free(msg); 171 fd_msg_free(msg);
118 return NULL; 172 return NULL;
119 } 173 }
174
120 /* Destination-Host */ 175 /* Destination-Host */
121 fd_msg_avp_new(dh_avp_do, 0, &avp); 176 fd_msg_avp_new(dh_avp_do, 0, &avp);
122 memset(&val, 0, sizeof(val)); 177 memset(&val, 0, sizeof(val));
123 val.os.data = (uint8_t *)target; 178 val.os.data = (uint8_t *)target;
124 val.os.len = strlen(target); 179 val.os.len = strlen(target);
145 fd_msg_free(msg); 200 fd_msg_free(msg);
146 fd_log_error("can't set value for 'Destination-Realm' for 'Credit-Control-Request' message"); 201 fd_log_error("can't set value for 'Destination-Realm' for 'Credit-Control-Request' message");
147 return NULL; 202 return NULL;
148 } 203 }
149 fd_msg_avp_add(msg, MSG_BRW_LAST_CHILD, avp); 204 fd_msg_avp_add(msg, MSG_BRW_LAST_CHILD, avp);
205
150 /* Session-Id */ 206 /* Session-Id */
151 fd_msg_avp_new(si_avp_do, 0, &avp); 207 fd_msg_avp_new(si_avp_do, 0, &avp);
152 memset(&val, 0, sizeof(val)); 208 memset(&val, 0, sizeof(val));
153 val.os.data = (uint8_t *)session_id; 209 val.os.data = (uint8_t *)session_id;
154 val.os.len = strlen(session_id); 210 val.os.len = strlen(session_id);
156 fd_msg_free(msg); 212 fd_msg_free(msg);
157 fd_log_error("can't set value for 'Session-Id' for 'Credit-Control-Request' message"); 213 fd_log_error("can't set value for 'Session-Id' for 'Credit-Control-Request' message");
158 return NULL; 214 return NULL;
159 } 215 }
160 fd_msg_avp_add(msg, MSG_BRW_FIRST_CHILD, avp); 216 fd_msg_avp_add(msg, MSG_BRW_FIRST_CHILD, avp);
217
161 /* Auth-Application-Id */ 218 /* Auth-Application-Id */
162 fd_msg_avp_new(aai_avp_do, 0, &avp); 219 fd_msg_avp_new(aai_avp_do, 0, &avp);
163 memset(&val, 0, sizeof(val)); 220 memset(&val, 0, sizeof(val));
164 val.i32 = 4; 221 val.i32 = 4;
165 if (fd_msg_avp_setvalue(avp, &val) != 0) { 222 if (fd_msg_avp_setvalue(avp, &val) != 0) {
166 fd_msg_free(msg); 223 fd_msg_free(msg);
167 fd_log_error("can't set value for 'Auth-Application-Id' for 'Credit-Control-Request' message"); 224 fd_log_error("can't set value for 'Auth-Application-Id' for 'Credit-Control-Request' message");
225 return NULL;
226 }
227 fd_msg_avp_add(msg, MSG_BRW_LAST_CHILD, avp);
228
229 /* Service-Context-Id */
230 fd_msg_avp_new(sci_avp_do, 0, &avp);
231 memset(&val, 0, sizeof(val));
232 val.os.data = (uint8_t *)service_context_id;
233 val.os.len = strlen(service_context_id);
234 if (fd_msg_avp_setvalue(avp, &val) != 0) {
235 fd_msg_free(msg);
236 fd_log_error("can't set value for 'Service-Context-Id' for 'Credit-Control-Request' message");
237 return NULL;
238 }
239 fd_msg_avp_add(msg, MSG_BRW_LAST_CHILD, avp);
240
241 /* CC-Request-Type */
242 fd_msg_avp_new(crt_avp_do, 0, &avp);
243 memset(&val, 0, sizeof(val));
244 val.i32 = 1; /* Initial */
245 if (fd_msg_avp_setvalue(avp, &val) != 0) {
246 fd_msg_free(msg);
247 fd_log_error("can't set value for 'CC-Request-Type' for 'Credit-Control-Request' message");
248 return NULL;
249 }
250 fd_msg_avp_add(msg, MSG_BRW_LAST_CHILD, avp);
251
252 /* CC-Request-Number */
253 fd_msg_avp_new(crn_avp_do, 0, &avp);
254 memset(&val, 0, sizeof(val));
255 val.i32 = 1;
256 if (fd_msg_avp_setvalue(avp, &val) != 0) {
257 fd_msg_free(msg);
258 fd_log_error("can't set value for 'CC-Request-Number' for 'Credit-Control-Request' message");
168 return NULL; 259 return NULL;
169 } 260 }
170 fd_msg_avp_add(msg, MSG_BRW_LAST_CHILD, avp); 261 fd_msg_avp_add(msg, MSG_BRW_LAST_CHILD, avp);
171 262
172 /* Proxy-Info */ 263 /* Proxy-Info */
204 struct msg *msg; 295 struct msg *msg;
205 fd_log_threadname ( "Loadtest/Generator" ); 296 fd_log_threadname ( "Loadtest/Generator" );
206 297
207 do { 298 do {
208 if (do_generate) { 299 if (do_generate) {
300 if (statistics.first == 0) {
301 statistics.first = time(NULL);
302 }
303 msg = create_message(target);
209 fd_msg_send(&msg, NULL, NULL); 304 fd_msg_send(&msg, NULL, NULL);
210 fd_log_notice("sent message"); 305 fd_log_debug("[%s] sent message", MODULE_NAME);
211 sleep(1); 306 statistics.last = time(NULL);
307 statistics.sent++;
212 } else { 308 } else {
213 sleep(1); 309 sleep(1);
214 } 310 }
215 } while (1); 311 } while (1);
216 } 312 }
240 336
241 /* Advertise the support for the Diameter Credit Control application in the peer */ 337 /* Advertise the support for the Diameter Credit Control application in the peer */
242 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Credit Control Application", &data.app, ENOENT) ); 338 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Credit Control Application", &data.app, ENOENT) );
243 CHECK_FCT( fd_disp_app_support ( data.app, NULL, 1, 0 ) ); 339 CHECK_FCT( fd_disp_app_support ( data.app, NULL, 1, 0 ) );
244 340
245 /* register handler for CCR */ 341 /* the handling of requests is different if it might be locally handled or not */
246 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Request", &data.command, ENOENT) ); 342 /* for possibly locally handled requests, fd_rt_fwd_register is not called, so we need to add handlers for both cases */
247 CHECK_FCT( fd_disp_register( ccr_handler, DISP_HOW_CC, &data, NULL, &ccr_handler_hdl ) ); 343 /* register forward handler for CCR -- needs to look at all requests */
344 CHECK_FCT(fd_rt_fwd_register(ccr_fwd_handler, NULL, RT_FWD_REQ, &ccr_fwd_hdl));
345 /* register local handler for CCR - if not Destination-Host is set, or the local host is used */
346 memset(&data, 0, sizeof(data));
347 CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Answer", &data.command, ENOENT));
348 CHECK_FCT(fd_disp_register(ccr_local_handler, DISP_HOW_CC, &data, NULL, &ccr_local_hdl));
248 349
249 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &aai_avp_do, ENOENT), 350 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &aai_avp_do, ENOENT),
250 { LOG_E("Unable to find 'Auth-Application-Id' AVP in the loaded dictionaries."); }); 351 { LOG_E("Unable to find 'Auth-Application-Id' AVP in the loaded dictionaries."); });
352 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "CC-Request-Number", &crn_avp_do, ENOENT),
353 { LOG_E("Unable to find 'CC-Request-Number' AVP in the loaded dictionaries."); });
354 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "CC-Request-Type", &crt_avp_do, ENOENT),
355
356 { LOG_E("Unable to find 'CC-Request-Type' AVP in the loaded dictionaries."); });
251 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Host", &dh_avp_do, ENOENT), 357 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Host", &dh_avp_do, ENOENT),
252 { LOG_E("Unable to find 'Destination-Host' AVP in the loaded dictionaries."); }); 358 { LOG_E("Unable to find 'Destination-Host' AVP in the loaded dictionaries."); });
253 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Realm", &dr_avp_do, ENOENT), 359 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Realm", &dr_avp_do, ENOENT),
254 { LOG_E("Unable to find 'Destination-Realm' AVP in the loaded dictionaries."); }); 360 { LOG_E("Unable to find 'Destination-Realm' AVP in the loaded dictionaries."); });
255 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Result-Code", &rc_avp_do, ENOENT), 361 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Result-Code", &rc_avp_do, ENOENT),
256 { LOG_E("Unable to find 'Result-Code' AVP in the loaded dictionaries."); }); 362 { LOG_E("Unable to find 'Result-Code' AVP in the loaded dictionaries."); });
257 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &si_avp_do, ENOENT), 363 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &si_avp_do, ENOENT),
258 { LOG_E("Unable to find 'Session-Id' AVP in the loaded dictionaries."); }); 364 { LOG_E("Unable to find 'Session-Id' AVP in the loaded dictionaries."); });
365 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Service-Context-Id", &sci_avp_do, ENOENT),
366 { LOG_E("Unable to find 'Service-Context-Id' AVP in the loaded dictionaries."); });
259 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-Info", &pi_avp_do, ENOENT), 367 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-Info", &pi_avp_do, ENOENT),
260 { LOG_E("Unable to find 'Proxy-Info' AVP in the loaded dictionaries."); }); 368 { LOG_E("Unable to find 'Proxy-Info' AVP in the loaded dictionaries."); });
261 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-Host", &ph_avp_do, ENOENT), 369 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-Host", &ph_avp_do, ENOENT),
262 { LOG_E("Unable to find 'Proxy-Host' AVP in the loaded dictionaries."); }); 370 { LOG_E("Unable to find 'Proxy-Host' AVP in the loaded dictionaries."); });
263 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-State", &ps_avp_do, ENOENT), 371 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-State", &ps_avp_do, ENOENT),
273 } 381 }
274 382
275 /* And terminate it */ 383 /* And terminate it */
276 void fd_ext_fini(void) 384 void fd_ext_fini(void)
277 { 385 {
386 uint64_t missing;
278 /* stop sending */ 387 /* stop sending */
279 do_generate = 0; 388 do_generate = 0;
280 389
281 /* Stop the expiry thread */ 390 /* Stop the expiry thread */
282 CHECK_FCT_DO( fd_thr_term(&gen_thr), ); 391 CHECK_FCT_DO( fd_thr_term(&gen_thr), );
283 392
284 /* Unregister the callbacks */ 393 /* Unregister the callbacks */
285 if (ccr_handler_hdl) { 394 if (ccr_local_hdl) {
286 CHECK_FCT_DO( fd_disp_unregister(&ccr_handler_hdl, NULL), ); 395 CHECK_FCT_DO( fd_disp_unregister(&ccr_local_hdl, NULL), );
287 ccr_handler_hdl = NULL; 396 ccr_local_hdl = NULL;
288 } 397 }
398
399 missing = statistics.sent - statistics.error - statistics.success;
400
401 fd_log_error("%lld messages sent in %llds (%.2f messages/second), %lld success (%.2f%%), %lld errors (%.2f%%), %lld missing (%.2f%%)",
402 (long long)statistics.sent, (long long)(statistics.last-statistics.first), (float)statistics.sent / (statistics.last-statistics.first),
403 (long long)statistics.success,
404 100*(float)statistics.success/statistics.sent, (long long)statistics.error, 100*(float)statistics.error/statistics.sent,
405 missing, 100*(float)missing/statistics.sent);
289 406
290 return; 407 return;
291 } 408 }
292 409
293 410
"Welcome to our mercurial repository"