This repository was archived by the owner on Feb 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsipp.cpp
More file actions
6321 lines (5534 loc) · 188 KB
/
sipp.cpp
File metadata and controls
6321 lines (5534 loc) · 188 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Some of the content of this file has been edited by Metaswitch, in the time
* period from December 2012 to the present time.
*/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author : Richard GAYRAUD - 04 Nov 2003
* Marc LAMBERTON
* Olivier JACQUES
* Herve PELLAN
* David MANSUTTI
* Francois-Xavier Kowalski
* Gerard Lyonnaz
* Francois Draperi (for dynamic_id)
* From Hewlett Packard Company.
* F. Tarek Rogers
* Peter Higginson
* Vincent Luba
* Shriram Natarajan
* Guillaume Teissier from FTR&D
* Clement Chen
* Wolfgang Beck
* Charles P Wright from IBM Research
* Martin Van Leeuwen
* Andy Aicken
* Michael Hirschbichler
*/
#define GLOBALS_FULL_DEFINITION
#include <dlfcn.h>
#include <sys/epoll.h>
#include "sipp.hpp"
#include "assert.h"
void sipp_usleep(unsigned long usec);
void rotate_messagef();
void rotate_calldebugf();
void rotate_shortmessagef();
void rotate_logfile();
#ifdef _USE_OPENSSL
SSL_CTX *sip_trp_ssl_ctx = NULL; /* For SSL cserver context */
SSL_CTX *sip_trp_ssl_ctx_client = NULL; /* For SSL cserver context */
SSL_CTX *twinSipp_sip_trp_ssl_ctx_client = NULL; /* For SSL cserver context */
enum ssl_init_status {
SSL_INIT_NORMAL, /* 0 Normal completion */
SSL_INIT_ERROR /* 1 Unspecified error */
};
#define CALL_BACK_USER_DATA "ksgr"
int passwd_call_back_routine(char *buf , int size , int flag, void *passwd)
{
strncpy(buf, (char *)(passwd), size);
buf[size - 1] = '\0';
return(strlen(buf));
}
#endif
bool do_hide = true;
bool show_index = false;
static struct sipp_socket *sipp_allocate_socket(bool use_ipv6, int transport, int fd, int accepting);
struct sipp_socket *ctrl_socket = NULL;
struct sipp_socket *stdin_socket = NULL;
int command_mode = 0;
char *command_buffer = NULL;
/* These could be local to main, but for the option processing table. */
static int argiFileName;
/***************** Option Handling Table *****************/
struct sipp_option {
const char *option;
const char *help;
int type;
void *data;
/* Pass 0: Help and other options that should exit immediately. */
/* Pass 1: All other options. */
/* Pass 2: Scenario parsing. */
int pass;
};
#define SIPP_OPTION_HELP 1
#define SIPP_OPTION_INT 2
#define SIPP_OPTION_SETFLAG 3
#define SIPP_OPTION_UNSETFLAG 4
#define SIPP_OPTION_STRING 5
#define SIPP_OPTION_ARGI 6
#define SIPP_OPTION_TIME_SEC 7
#define SIPP_OPTION_FLOAT 8
#define SIPP_OPTION_BOOL 10
#define SIPP_OPTION_VERSION 11
#define SIPP_OPTION_TRANSPORT 12
#define SIPP_OPTION_NEED_SSL 13
#define SIPP_OPTION_IP 14
#define SIPP_OPTION_MAX_SOCKET 15
#define SIPP_OPTION_CSEQ 16
#define SIPP_OPTION_SCENARIO 17
#define SIPP_OPTION_RSA 18
#define SIPP_OPTION_LIMIT 19
#define SIPP_OPTION_USERS 20
#define SIPP_OPTION_KEY 21
#define SIPP_OPTION_3PCC 22
#define SIPP_OPTION_TDMMAP 23
#define SIPP_OPTION_TIME_MS 24
#define SIPP_OPTION_SLAVE_CFG 25
#define SIPP_OPTION_3PCC_EXTENDED 26
#define SIPP_OPTION_INPUT_FILE 27
#define SIPP_OPTION_TIME_MS_LONG 28
#define SIPP_OPTION_LONG 29
#define SIPP_OPTION_LONG_LONG 30
#define SIPP_OPTION_DEFAULTS 31
#define SIPP_OPTION_OOC_SCENARIO 32
#define SIPP_OPTION_INDEX_FILE 33
#define SIPP_OPTION_VAR 34
#define SIPP_OPTION_RTCHECK 35
#define SIPP_OPTION_LFNAME 36
#define SIPP_OPTION_LFOVERWRITE 37
#define SIPP_OPTION_PLUGIN 38
#define SIPP_OPTION_NEED_SCTP 39
/* Put Each option, its help text, and type in this table. */
struct sipp_option options_table[] = {
{"v", "Display version and copyright information.", SIPP_OPTION_VERSION, NULL, 0},
{"h", NULL, SIPP_OPTION_HELP, NULL, 0},
{"help", NULL, SIPP_OPTION_HELP, NULL, 0},
{"aa", "Enable automatic 200 OK answer for INFO, UPDATE and NOTIFY messages.", SIPP_OPTION_SETFLAG, &auto_answer, 1},
{"auth_uri", "Force the value of the URI for authentication.\n"
"By default, the URI is composed of remote_ip:remote_port.", SIPP_OPTION_STRING, &auth_uri, 1},
{"au", "Set authorization username for authentication challenges. Default is taken from -s argument", SIPP_OPTION_STRING, &auth_username, 1},
{"ap", "Set the password for authentication challenges. Default is 'password'", SIPP_OPTION_STRING, &auth_password, 1},
{"base_cseq", "Start value of [cseq] for each call.", SIPP_OPTION_CSEQ, NULL, 1},
{"bg", "Launch SIPp in background mode.", SIPP_OPTION_SETFLAG, &backgroundMode, 1},
{"bind_local", "Bind socket to local IP address, i.e. the local IP address is used as the source IP address. If SIPp runs in server mode it will only listen on the local IP address instead of all IP addresses.", SIPP_OPTION_SETFLAG, &bind_local, 1},
{"buff_size", "Set the send and receive buffer size.", SIPP_OPTION_INT, &buff_size, 1},
{"calldebug_file", "Set the name of the call debug file.", SIPP_OPTION_LFNAME, &calldebug_lfi, 1},
{"calldebug_overwrite", "Overwrite the call debug file (default true).", SIPP_OPTION_LFOVERWRITE, &calldebug_lfi, 1},
{"cid_str", "Call ID string (default %u-%p@%s). %u=call_number, %s=ip_address, %p=process_number, %%=% (in any order).", SIPP_OPTION_STRING, &call_id_string, 1},
{"ci", "Set the local control IP address", SIPP_OPTION_IP, control_ip, 1},
{"cp", "Set the local control port number. Default is 8888.", SIPP_OPTION_INT, &control_port, 1},
{"d", "Controls the length of calls. More precisely, this controls the duration of 'pause' instructions in the scenario, if they do not have a 'milliseconds' section. Default value is 0 and default unit is milliseconds.", SIPP_OPTION_TIME_MS, &duration, 1},
{"deadcall_wait", "How long the Call-ID and final status of calls should be kept to improve message and error logs (default unit is ms).", SIPP_OPTION_TIME_MS, &deadcall_wait, 1},
{"default_behaviors", "Set the default behaviors that SIPp will use. Possbile values are:\n"
"- all\tUse all default behaviors\n"
"- none\tUse no default behaviors\n"
"- bye\tSend byes for aborted calls\n"
"- abortunexp\tAbort calls on unexpected messages\n"
"- pingreply\tReply to ping requests\n"
"If a behavior is prefaced with a -, then it is turned off. Example: all,-bye\n",
SIPP_OPTION_DEFAULTS, &default_behaviors, 1},
{"error_file", "Set the name of the error log file.", SIPP_OPTION_LFNAME, &error_lfi, 1},
{"error_overwrite", "Overwrite the error log file (default true).", SIPP_OPTION_LFOVERWRITE, &error_lfi, 1},
{"f", "Set the statistics report frequency on screen. Default is 1 and default unit is seconds.", SIPP_OPTION_TIME_SEC, &report_freq, 1},
{"fd", "Set the statistics dump log report frequency. Default is 60 and default unit is seconds.", SIPP_OPTION_TIME_SEC, &report_freq_dumpLog, 1},
{"i", "Set the local IP address for 'Contact:','Via:', and 'From:' headers. Default is primary host IP address.\n", SIPP_OPTION_IP, local_ip, 1},
{"inf", "Inject values from an external CSV file during calls into the scenarios.\n"
"First line of this file say whether the data is to be read in sequence (SEQUENTIAL), random (RANDOM), or user (USER) order.\n"
"Each line corresponds to one call and has one or more ';' delimited data fields. Those fields can be referred as [field0], [field1], ... in the xml scenario file. Several CSV files can be used simultaneously (syntax: -inf f1.csv -inf f2.csv ...)", SIPP_OPTION_INPUT_FILE, NULL, 1},
{"infindex", "file field\nCreate an index of file using field. For example -inf users.csv -infindex users.csv 0 creates an index on the first key.", SIPP_OPTION_INDEX_FILE, NULL, 1 },
{"ip_field", "Set which field from the injection file contains the IP address from which the client will send its messages.\n"
"If this option is omitted and the '-t ui' option is present, then field 0 is assumed.\n"
"Use this option together with '-t ui'", SIPP_OPTION_INT, &peripfield, 1},
{"l", "Set the maximum number of simultaneous calls. Once this limit is reached, traffic is decreased until the number of open calls goes down. Default:\n"
" (3 * call_duration (s) * rate).", SIPP_OPTION_LIMIT, NULL, 1},
{"log_file", "Set the name of the log actions log file.", SIPP_OPTION_LFNAME, &log_lfi, 1},
{"log_overwrite", "Overwrite the log actions log file (default true).", SIPP_OPTION_LFOVERWRITE, &log_lfi, 1},
{"lost", "Set the number of packets to lose by default (scenario specifications override this value).", SIPP_OPTION_FLOAT, &global_lost, 1},
{"rtcheck", "Select the retransmisison detection method: full (default) or loose.", SIPP_OPTION_RTCHECK, &rtcheck, 1},
{"m", "Stop the test and exit when 'calls' calls are processed", SIPP_OPTION_LONG, &stop_after, 1},
{"mi", "Set the local media IP address (default: local primary host IP address)", SIPP_OPTION_IP, media_ip, 1},
{"master","3pcc extended mode: indicates the master number", SIPP_OPTION_3PCC_EXTENDED, &master_name, 1},
{"max_recv_loops", "Set the maximum number of messages received read per cycle. Increase this value for high traffic level. The default value is 1000.", SIPP_OPTION_INT, &max_recv_loops, 1},
{"max_sched_loops", "Set the maximum number of calsl run per event loop. Increase this value for high traffic level. The default value is 1000.", SIPP_OPTION_INT, &max_sched_loops, 1},
{"max_reconnect", "Set the the maximum number of reconnection.", SIPP_OPTION_INT, &reset_number, 1},
{"max_retrans", "Maximum number of UDP retransmissions before call ends on timeout. Default is 5 for INVITE transactions and 7 for others.", SIPP_OPTION_INT, &max_udp_retrans, 1},
{"max_invite_retrans", "Maximum number of UDP retransmissions for invite transactions before call ends on timeout.", SIPP_OPTION_INT, &max_invite_retrans, 1},
{"max_non_invite_retrans", "Maximum number of UDP retransmissions for non-invite transactions before call ends on timeout.", SIPP_OPTION_INT, &max_non_invite_retrans, 1},
{"max_log_size", "What is the limit for error and message log file sizes.", SIPP_OPTION_LONG_LONG, &max_log_size, 1},
{"max_socket", "Set the max number of sockets to open simultaneously. This option is significant if you use one socket per call. Once this limit is reached, traffic is distributed over the sockets already opened. Default value is 50000", SIPP_OPTION_MAX_SOCKET, NULL, 1},
{"mb", "Set the RTP echo buffer size (default: 2048).", SIPP_OPTION_INT, &media_bufsize, 1},
{"message_file", "Set the name of the message log file.", SIPP_OPTION_LFNAME, &message_lfi, 1},
{"message_overwrite", "Overwrite the message log file (default true).", SIPP_OPTION_LFOVERWRITE, &message_lfi, 1},
{"mp", "Set the local RTP echo port number. Default is 6000.", SIPP_OPTION_INT, &user_media_port, 1},
{"nd", "No Default. Disable all default behavior of SIPp which are the following:\n"
"- On UDP retransmission timeout, abort the call by sending a BYE or a CANCEL\n"
"- On receive timeout with no ontimeout attribute, abort the call by sending a BYE or a CANCEL\n"
"- On unexpected BYE send a 200 OK and close the call\n"
"- On unexpected CANCEL send a 200 OK and close the call\n"
"- On unexpected PING send a 200 OK and continue the call\n"
"- On any other unexpected message, abort the call by sending a BYE or a CANCEL\n",
SIPP_OPTION_UNSETFLAG, &default_behaviors, 1},
{"nr", "Disable retransmission in UDP mode.", SIPP_OPTION_UNSETFLAG, &retrans_enabled, 1},
{"nostdin", "Disable stdin.\n", SIPP_OPTION_SETFLAG, &nostdin, 1},
{"p", "Set the local port number. Default is a random free port chosen by the system.", SIPP_OPTION_INT, &user_port, 1},
{"pause_msg_ign", "Ignore the messages received during a pause defined in the scenario ", SIPP_OPTION_SETFLAG, &pause_msg_ign, 1},
{"periodic_rtd", "Reset response time partition counters each logging interval.", SIPP_OPTION_SETFLAG, &periodic_rtd, 1},
{"plugin", "Load a plugin.", SIPP_OPTION_PLUGIN, NULL, 1},
{"r", "Set the call rate (in calls per seconds). This value can be"
"changed during test by pressing '+','_','*' or '/'. Default is 10.\n"
"pressing '+' key to increase call rate by 1 * rate_scale,\n"
"pressing '-' key to decrease call rate by 1 * rate_scale,\n"
"pressing '*' key to increase call rate by 10 * rate_scale,\n"
"pressing '/' key to decrease call rate by 10 * rate_scale.\n"
"If the -rp option is used, the call rate is calculated with the period in ms given by the user.", SIPP_OPTION_FLOAT, &rate, 1},
{"rp", "Specify the rate period for the call rate. Default is 1 second and default unit is milliseconds. This allows you to have n calls every m milliseconds (by using -r n -rp m).\n"
"Example: -r 7 -rp 2000 ==> 7 calls every 2 seconds.\n -r 10 -rp 5s => 10 calls every 5 seconds.", SIPP_OPTION_TIME_MS, &rate_period_ms, 1},
{"rate_scale", "Control the units for the '+', '-', '*', and '/' keys.", SIPP_OPTION_FLOAT, &rate_scale, 1},
{"rate_increase", "Specify the rate increase every -fd units (default is seconds). This allows you to increase the load for each independent logging period.\n"
"Example: -rate_increase 10 -fd 10s\n"
" ==> increase calls by 10 every 10 seconds.", SIPP_OPTION_INT, &rate_increase, 1},
{"rate_max", "If -rate_increase is set, then quit after the rate reaches this value.\n"
"Example: -rate_increase 10 -rate_max 100\n"
" ==> increase calls by 10 until 100 cps is hit.", SIPP_OPTION_INT, &rate_max, 1},
{"no_rate_quit", "If -rate_increase is set, do not quit after the rate reaches -rate_max.", SIPP_OPTION_UNSETFLAG, &rate_quit, 1},
{"recv_timeout", "Global receive timeout. Default unit is milliseconds. If the expected message is not received, the call times out and is aborted.", SIPP_OPTION_TIME_MS_LONG, &defl_recv_timeout, 1},
{"send_timeout", "Global send timeout. Default unit is milliseconds. If a message is not sent (due to congestion), the call times out and is aborted.", SIPP_OPTION_TIME_MS_LONG, &defl_send_timeout, 1},
{"sleep", "How long to sleep for at startup. Default unit is seconds.", SIPP_OPTION_TIME_SEC, &sleeptime, 1},
{"reconnect_close", "Should calls be closed on reconnect?", SIPP_OPTION_BOOL, &reset_close, 1},
{"reconnect_sleep", "How long (in milliseconds) to sleep between the close and reconnect?", SIPP_OPTION_TIME_MS, &reset_sleep, 1},
{"ringbuffer_files", "How many error/message files should be kept after rotation?", SIPP_OPTION_INT, &ringbuffer_files, 1},
{"ringbuffer_size", "How large should error/message files be before they get rotated?", SIPP_OPTION_LONG_LONG, &ringbuffer_size, 1},
{"rsa", "Set the remote sending address to host:port for sending the messages.", SIPP_OPTION_RSA, NULL, 1},
{"rtp_echo", "Enable RTP echo. RTP/UDP packets received on port defined by -mp are echoed to their sender.\n"
"RTP/UDP packets coming on this port + 2 are also echoed to their sender (used for sound and video echo).",
SIPP_OPTION_SETFLAG, &rtp_echo_enabled, 1},
{"rtt_freq", "freq is mandatory. Dump response times every freq calls in the log file defined by -trace_rtt. Default value is 200.",
SIPP_OPTION_LONG, &report_freq_dumpRtt, 1},
{"s", "Set the username part of the resquest URI. Default is 'service'.", SIPP_OPTION_STRING, &service, 1},
{"sd", "Dumps a default scenario (embeded in the sipp executable)", SIPP_OPTION_SCENARIO, NULL, 0},
{"sf", "Loads an alternate xml scenario file. To learn more about XML scenario syntax, use the -sd option to dump embedded scenarios. They contain all the necessary help.", SIPP_OPTION_SCENARIO, NULL, 2},
{"shortmessage_file", "Set the name of the short message log file.", SIPP_OPTION_LFNAME, &shortmessage_lfi, 1},
{"shortmessage_overwrite", "Overwrite the short message log file (default true).", SIPP_OPTION_LFOVERWRITE, &shortmessage_lfi, 1},
{"oocsf", "Load out-of-call scenario.", SIPP_OPTION_OOC_SCENARIO, NULL, 2},
{"oocsn", "Load out-of-call scenario.", SIPP_OPTION_OOC_SCENARIO, NULL, 2},
{"skip_rlimit", "Do not perform rlimit tuning of file descriptor limits. Default: false.", SIPP_OPTION_SETFLAG, &skip_rlimit, 1},
{"slave", "3pcc extended mode: indicates the slave number", SIPP_OPTION_3PCC_EXTENDED, &slave_number, 1},
{"slave_cfg", "3pcc extended mode: indicates the file where the master and slave addresses are stored", SIPP_OPTION_SLAVE_CFG, NULL, 1},
{"sn", "Use a default scenario (embedded in the sipp executable). If this option is omitted, the Standard SipStone UAC scenario is loaded.\n"
"Available values in this version:\n\n"
"- 'uac' : Standard SipStone UAC (default).\n"
"- 'uas' : Simple UAS responder.\n"
"- 'regexp' : Standard SipStone UAC - with regexp and variables.\n"
"- 'branchc' : Branching and conditional branching in scenarios - client.\n"
"- 'branchs' : Branching and conditional branching in scenarios - server.\n\n"
"Default 3pcc scenarios (see -3pcc option):\n\n"
"- '3pcc-C-A' : Controller A side (must be started after all other 3pcc scenarios)\n"
"- '3pcc-C-B' : Controller B side.\n"
"- '3pcc-A' : A side.\n"
"- '3pcc-B' : B side.\n", SIPP_OPTION_SCENARIO, NULL, 2},
{"stat_delimiter", "Set the delimiter for the statistics file", SIPP_OPTION_STRING, &stat_delimiter, 1},
{"stf", "Set the file name to use to dump statistics", SIPP_OPTION_ARGI, &argiFileName, 1},
{"t", "Set the transport mode:\n"
"- u1: UDP with one socket (default),\n"
"- un: UDP with one socket per call,\n"
"- ui: UDP with one socket per IP address The IP addresses must be defined in the injection file.\n"
"- t1: TCP with one socket,\n"
"- tn: TCP with one socket per call,\n"
"- l1: TLS with one socket,\n"
"- ln: TLS with one socket per call,\n"
"- s1: SCTP with one socket (default),\n"
"- sn: SCTP with one socket per call,\n"
"- c1: u1 + compression (only if compression plugin loaded),\n"
"- cn: un + compression (only if compression plugin loaded). This plugin is not provided with sipp.\n"
, SIPP_OPTION_TRANSPORT, NULL, 1},
{"timeout", "Global timeout. Default unit is seconds. If this option is set, SIPp quits after nb units (-timeout 20s quits after 20 seconds).", SIPP_OPTION_TIME_SEC, &global_timeout, 1},
{"timeout_error", "SIPp fails if the global timeout is reached is set (-timeout option required).", SIPP_OPTION_SETFLAG, &timeout_error, 1},
{"timer_resol", "Set the timer resolution. Default unit is milliseconds. This option has an impact on timers precision."
"Small values allow more precise scheduling but impacts CPU usage."
"If the compression is on, the value is set to 50ms. The default value is 10ms.", SIPP_OPTION_TIME_MS, &timer_resolution, 1},
{"T2", "Global T2-timer in milli seconds", SIPP_OPTION_TIME_MS, &global_t2, 1},
{"sendbuffer_warn", "Produce warnings instead of errors on SendBuffer failures.", SIPP_OPTION_BOOL, &sendbuffer_warn, 1},
{"trace_msg", "Displays sent and received SIP messages in <scenario file name>_<pid>_messages.log", SIPP_OPTION_SETFLAG, &useMessagef, 1},
{"trace_shortmsg", "Displays sent and received SIP messages as CSV in <scenario file name>_<pid>_shortmessages.log", SIPP_OPTION_SETFLAG, &useShortMessagef, 1},
{"trace_screen", "Dump statistic screens in the <scenario_name>_<pid>_screens.log file when quitting SIPp. Useful to get a final status report in background mode (-bg option).", SIPP_OPTION_SETFLAG, &useScreenf, 1},
{"trace_err", "Trace all unexpected messages in <scenario file name>_<pid>_errors.log.", SIPP_OPTION_SETFLAG, &print_all_responses, 1},
// {"trace_timeout", "Displays call ids for calls with timeouts in <scenario file name>_<pid>_timeout.log", SIPP_OPTION_SETFLAG, &useTimeoutf, 1},
{"trace_calldebug", "Dumps debugging information about aborted calls to <scenario_name>_<pid>_calldebug.log file.", SIPP_OPTION_SETFLAG, &useCallDebugf, 1},
{"trace_stat", "Dumps all statistics in <scenario_name>_<pid>.csv file. Use the '-h stat' option for a detailed description of the statistics file content.", SIPP_OPTION_SETFLAG, &dumpInFile, 1},
{"trace_counts", "Dumps individual message counts in a CSV file.", SIPP_OPTION_SETFLAG, &useCountf, 1},
{"trace_rtt", "Allow tracing of all response times in <scenario file name>_<pid>_rtt.csv.", SIPP_OPTION_SETFLAG, &dumpInRtt, 1},
{"trace_logs", "Allow tracing of <log> actions in <scenario file name>_<pid>_logs.log.", SIPP_OPTION_SETFLAG, &useLogf, 1},
{"users", "Instead of starting calls at a fixed rate, begin 'users' calls at startup, and keep the number of calls constant.", SIPP_OPTION_USERS, NULL, 1},
{"watchdog_interval", "Set gap between watchdog timer firings. Default is 400.", SIPP_OPTION_TIME_MS, &watchdog_interval, 1},
{"watchdog_reset", "If the watchdog timer has not fired in more than this time period, then reset the max triggers counters. Default is 10 minutes.", SIPP_OPTION_TIME_MS, &watchdog_reset, 1},
{"watchdog_minor_threshold", "If it has been longer than this period between watchdog executions count a minor trip. Default is 500.", SIPP_OPTION_TIME_MS, &watchdog_minor_threshold, 1},
{"watchdog_major_threshold", "If it has been longer than this period between watchdog executions count a major trip. Default is 3000.", SIPP_OPTION_TIME_MS, &watchdog_major_threshold, 1},
{"watchdog_major_maxtriggers", "How many times the major watchdog timer can be tripped before the test is terminated. Default is 10.", SIPP_OPTION_INT, &watchdog_major_maxtriggers, 1},
{"watchdog_minor_maxtriggers", "How many times the minor watchdog timer can be tripped before the test is terminated. Default is 120.", SIPP_OPTION_INT, &watchdog_minor_maxtriggers, 1},
#ifdef _USE_OPENSSL
{"tls_cert", "Set the name for TLS Certificate file. Default is 'cacert.pem", SIPP_OPTION_STRING, &tls_cert_name, 1},
{"tls_key", "Set the name for TLS Private Key file. Default is 'cakey.pem'", SIPP_OPTION_STRING, &tls_key_name, 1},
{"tls_crl", "Set the name for Certificate Revocation List file. If not specified, X509 CRL is not activated.", SIPP_OPTION_STRING, &tls_crl_name, 1},
#else
{"tls_cert", NULL, SIPP_OPTION_NEED_SSL, NULL, 1},
{"tls_key", NULL, SIPP_OPTION_NEED_SSL, NULL, 1},
{"tls_crl", NULL, SIPP_OPTION_NEED_SSL, NULL, 1},
#endif
{"3pcc", "Launch the tool in 3pcc mode (\"Third Party call control\"). The passed ip address is depending on the 3PCC role.\n"
"- When the first twin command is 'sendCmd' then this is the address of the remote twin socket. SIPp will try to connect to this address:port to send the twin command (This instance must be started after all other 3PCC scenarii).\n"
" Example: 3PCC-C-A scenario.\n"
"- When the first twin command is 'recvCmd' then this is the address of the local twin socket. SIPp will open this address:port to listen for twin command.\n"
" Example: 3PCC-C-B scenario.", SIPP_OPTION_3PCC, NULL, 1},
{"tdmmap", "Generate and handle a table of TDM circuits.\n"
"A circuit must be available for the call to be placed.\n"
"Format: -tdmmap {0-3}{99}{5-8}{1-31}", SIPP_OPTION_TDMMAP, NULL, 1},
{"key", "keyword value\nSet the generic parameter named \"keyword\" to \"value\".", SIPP_OPTION_KEY, NULL, 1},
{"set", "variable value\nSet the global variable parameter named \"variable\" to \"value\".", SIPP_OPTION_VAR, NULL, 3},
#ifdef USE_SCTP
{"multihome", "Set multihome address for SCTP", SIPP_OPTION_IP, multihome_ip, 1},
{"heartbeat", "Set heartbeat interval in ms for SCTP", SIPP_OPTION_INT, &heartbeat, 1},
{"assocmaxret", "Set association max retransmit counter for SCTP", SIPP_OPTION_INT, &assocmaxret, 1},
{"pathmaxret", "Set path max retransmit counter for SCTP", SIPP_OPTION_INT, &pathmaxret, 1},
{"pmtu", "Set path MTU for SCTP", SIPP_OPTION_INT, &pmtu, 1},
{"gracefulclose", "If true, SCTP association will be closed with SHUTDOWN (default).\n If false, SCTP association will be closed by ABORT.\n", SIPP_OPTION_BOOL, &gracefulclose, 1},
#else
{"multihome", NULL, SIPP_OPTION_NEED_SCTP, NULL, 1},
{"heartbeat", NULL, SIPP_OPTION_NEED_SCTP, NULL, 1},
{"assocmaxret", NULL, SIPP_OPTION_NEED_SCTP, NULL, 1},
{"pathmaxret", NULL, SIPP_OPTION_NEED_SCTP, NULL, 1},
{"pmtu", NULL, SIPP_OPTION_NEED_SCTP, NULL, 1},
{"gracefulclose", NULL, SIPP_OPTION_NEED_SCTP, NULL, 1},
#endif
{"dynamicStart", "variable value\nSet the start offset of dynamic_id varaiable", SIPP_OPTION_INT, &startDynamicId, 1},
{"dynamicMax", "variable value\nSet the maximum of dynamic_id variable ", SIPP_OPTION_INT, &maxDynamicId, 1},
{"dynamicStep", "variable value\nSet the increment of dynamic_id variable", SIPP_OPTION_INT, &stepDynamicId, 1}
};
struct sipp_option *find_option(const char *option) {
int i;
int max = sizeof(options_table)/sizeof(options_table[0]);
/* Allow options to start with '-' or '--' */
if (option[0] != '-') {
return NULL;
}
option++;
if (option[0] == '-') {
option++;
}
for (i = 0; i < max; i++) {
if (!strcmp(options_table[i].option, option)) {
return &(options_table[i]);
}
}
return NULL;
};
/***************** System Portability Features *****************/
unsigned long long getmicroseconds()
{
struct timeval LS_system_time;
unsigned long long VI_micro;
static unsigned long long VI_micro_base = 0;
gettimeofday(&LS_system_time, NULL);
VI_micro = (((unsigned long long) LS_system_time.tv_sec) * 1000000LL) + LS_system_time.tv_usec;
if (!VI_micro_base) VI_micro_base = VI_micro - 1;
VI_micro = VI_micro - VI_micro_base;
clock_tick = VI_micro / 1000LL;
return VI_micro;
}
unsigned long getmilliseconds()
{
return getmicroseconds() / 1000LL;
}
#ifdef _USE_OPENSSL
/****** SSL error handling *************/
const char *sip_tls_error_string(SSL *ssl, int size) {
int err;
err=SSL_get_error(ssl, size);
switch(err) {
case SSL_ERROR_NONE:
return "No error";
case SSL_ERROR_WANT_WRITE:
return "SSL_read returned SSL_ERROR_WANT_WRITE";
case SSL_ERROR_WANT_READ:
return "SSL_read returned SSL_ERROR_WANT_READ";
case SSL_ERROR_WANT_X509_LOOKUP:
return "SSL_read returned SSL_ERROR_WANT_X509_LOOKUP";
break;
case SSL_ERROR_SYSCALL:
if(size<0) { /* not EOF */
return strerror(errno);
} else { /* EOF */
return "SSL socket closed on SSL_read";
}
}
return "Unknown SSL Error.";
}
/****** Certificate Verification Callback FACILITY *************/
int sip_tls_verify_callback(int ok , X509_STORE_CTX *store)
{
char data[512];
if (!ok) {
X509 *cert = X509_STORE_CTX_get_current_cert(store);
X509_NAME_oneline(X509_get_issuer_name(cert),
data,512);
WARNING("TLS verification error for issuer: '%s'", data);
X509_NAME_oneline(X509_get_subject_name(cert),
data,512);
WARNING("TLS verification error for subject: '%s'", data);
}
return ok;
}
/*********** Load the CRL's into SSL_CTX **********************/
int sip_tls_load_crls( SSL_CTX *ctx , char *crlfile)
{
X509_STORE *store;
X509_LOOKUP *lookup;
/* Get the X509_STORE from SSL context */
if (!(store = SSL_CTX_get_cert_store(ctx))) {
return (-1);
}
/* Add lookup file to X509_STORE */
if (!(lookup = X509_STORE_add_lookup(store,X509_LOOKUP_file()))) {
return (-1);
}
/* Add the CRLS to the lookpup object */
if (X509_load_crl_file(lookup,crlfile,X509_FILETYPE_PEM) != 1) {
return (-1);
}
/* Set the flags of the store so that CRLS's are consulted */
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
X509_STORE_set_flags( store,X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL);
#else
#warning This version of OpenSSL (<0.9.7) cannot handle CRL files in capath
ERROR("This version of OpenSSL (<0.9.7) cannot handle CRL files in capath");
#endif
return (1);
}
/************* Prepare the SSL context ************************/
static ssl_init_status FI_init_ssl_context (void)
{
sip_trp_ssl_ctx = SSL_CTX_new( TLSv1_method() );
if ( sip_trp_ssl_ctx == NULL ) {
ERROR("FI_init_ssl_context: SSL_CTX_new with TLSv1_method failed");
return SSL_INIT_ERROR;
}
sip_trp_ssl_ctx_client = SSL_CTX_new( TLSv1_method() );
if ( sip_trp_ssl_ctx_client == NULL)
{
ERROR("FI_init_ssl_context: SSL_CTX_new with TLSv1_method failed");
return SSL_INIT_ERROR;
}
/* Load the trusted CA's */
SSL_CTX_load_verify_locations(sip_trp_ssl_ctx, tls_cert_name, NULL);
SSL_CTX_load_verify_locations(sip_trp_ssl_ctx_client, tls_cert_name, NULL);
/* CRL load from application specified only if specified on the command line */
if (strlen(tls_crl_name) != 0) {
if(sip_tls_load_crls(sip_trp_ssl_ctx,tls_crl_name) == -1) {
ERROR("FI_init_ssl_context: Unable to load CRL file (%s)", tls_crl_name);
return SSL_INIT_ERROR;
}
if(sip_tls_load_crls(sip_trp_ssl_ctx_client,tls_crl_name) == -1) {
ERROR("FI_init_ssl_context: Unable to load CRL (client) file (%s)", tls_crl_name);
return SSL_INIT_ERROR;
}
/* The following call forces to process the certificates with the */
/* initialised SSL_CTX */
SSL_CTX_set_verify(sip_trp_ssl_ctx,
SSL_VERIFY_PEER |
SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
sip_tls_verify_callback);
SSL_CTX_set_verify(sip_trp_ssl_ctx_client,
SSL_VERIFY_PEER |
SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
sip_tls_verify_callback);
}
/* Selection Cipher suits - load the application specified ciphers */
SSL_CTX_set_default_passwd_cb_userdata(sip_trp_ssl_ctx,
(void *)CALL_BACK_USER_DATA );
SSL_CTX_set_default_passwd_cb_userdata(sip_trp_ssl_ctx_client,
(void *)CALL_BACK_USER_DATA );
SSL_CTX_set_default_passwd_cb( sip_trp_ssl_ctx,
passwd_call_back_routine );
SSL_CTX_set_default_passwd_cb( sip_trp_ssl_ctx_client,
passwd_call_back_routine );
if ( SSL_CTX_use_certificate_file(sip_trp_ssl_ctx,
tls_cert_name,
SSL_FILETYPE_PEM ) != 1 ) {
ERROR("FI_init_ssl_context: SSL_CTX_use_certificate_file failed");
return SSL_INIT_ERROR;
}
if ( SSL_CTX_use_certificate_file(sip_trp_ssl_ctx_client,
tls_cert_name,
SSL_FILETYPE_PEM ) != 1 ) {
ERROR("FI_init_ssl_context: SSL_CTX_use_certificate_file (client) failed");
return SSL_INIT_ERROR;
}
if ( SSL_CTX_use_PrivateKey_file(sip_trp_ssl_ctx,
tls_key_name,
SSL_FILETYPE_PEM ) != 1 ) {
ERROR("FI_init_ssl_context: SSL_CTX_use_PrivateKey_file failed");
return SSL_INIT_ERROR;
}
if ( SSL_CTX_use_PrivateKey_file(sip_trp_ssl_ctx_client,
tls_key_name,
SSL_FILETYPE_PEM ) != 1 ) {
ERROR("FI_init_ssl_context: SSL_CTX_use_PrivateKey_file (client) failed");
return SSL_INIT_ERROR;
}
return SSL_INIT_NORMAL;
}
int send_nowait_tls(SSL *ssl, const void *msg, int len, int flags)
{
int initial_fd_flags;
int rc;
int fd;
int fd_flags;
if ( (fd = SSL_get_fd(ssl)) == -1 ) {
return (-1);
}
fd_flags = fcntl(fd, F_GETFL , NULL);
initial_fd_flags = fd_flags;
fd_flags |= O_NONBLOCK;
fcntl(fd, F_SETFL , fd_flags);
rc = SSL_write(ssl,msg,len);
if ( rc <= 0 ) {
return(rc);
}
fcntl(fd, F_SETFL , initial_fd_flags);
return rc;
}
#endif
int send_nowait(int s, const void *msg, int len, int flags)
{
#if defined(MSG_DONTWAIT) && !defined(__SUNOS)
return send(s, msg, len, flags | MSG_DONTWAIT);
#else
int fd_flags = fcntl(s, F_GETFL , NULL);
int initial_fd_flags;
int rc;
initial_fd_flags = fd_flags;
// fd_flags &= ~O_ACCMODE; // Remove the access mode from the value
fd_flags |= O_NONBLOCK;
fcntl(s, F_SETFL , fd_flags);
rc = send(s, msg, len, flags);
fcntl(s, F_SETFL , initial_fd_flags);
return rc;
#endif
}
#ifdef USE_SCTP
int send_sctp_nowait(int s, const void *msg, int len, int flags)
{
struct sctp_sndrcvinfo sinfo;
memset(&sinfo, 0, sizeof(sinfo));
sinfo.sinfo_flags = SCTP_UNORDERED; // according to RFC4168 5.1
sinfo.sinfo_stream = 0;
#if defined(MSG_DONTWAIT) && !defined(__SUNOS)
return sctp_send(s, msg, len, &sinfo, flags | MSG_DONTWAIT);
#else
int fd_flags = fcntl(s, F_GETFL, NULL);
int initial_fd_flags;
int rc;
initial_fd_flags = fd_flags;
fd_flags |= O_NONBLOCK;
fcntl(s, F_SETFL , fd_flags);
rc = sctp_send(s, msg, len, &sinfo, flags);
fcntl(s, F_SETFL, initial_fd_flags);
return rc;
#endif
}
#endif
char * get_inet_address(struct sockaddr_storage * addr)
{
static char * ip_addr = NULL;
if (!ip_addr) {
ip_addr = (char *)malloc(1024*sizeof(char));
}
if (getnameinfo(_RCAST(struct sockaddr *, addr),
SOCK_ADDR_SIZE(addr),
ip_addr,
1024,
NULL,
0,
NI_NUMERICHOST) != 0) {
strcpy(ip_addr, "addr not supported");
}
return ip_addr;
}
void get_host_and_port(const char * addr, char * host, int * port)
{
/* Separate the port number (if any) from the host name.
* Thing is, the separator is a colon (':'). The colon may also exist
* in the host portion if the host is specified as an IPv6 address (see
* RFC 2732). If that's the case, then we need to skip past the IPv6
* address, which should be contained within square brackets ('[',']').
*/
const char *has_brackets;
int len;
has_brackets = strchr(addr, '[');
if (has_brackets != NULL) {
has_brackets = strchr(has_brackets, ']');
}
if (has_brackets == NULL) {
/* addr is not a []-enclosed IPv6 address, but might still be IPv6 (without
* a port), or IPv4 or a hostname (with or without a port) */
char *first_colon_location;
char *second_colon_location;
len = strlen(addr) + 1;
memmove(host, addr, len);
first_colon_location = strchr(host, ':');
if (first_colon_location == NULL) {
/* No colon - just set the port to 0 */
*port = 0;
} else {
second_colon_location = strchr(first_colon_location + 1, ':');
if (second_colon_location != NULL) {
/* Found a second colon in addr - so this is an IPv6 address
* without a port. Set the port to 0 */
*port = 0;
} else {
/* IPv4 address or hostname with a colon in it - convert the colon to
* a NUL terminator, and set the value after it as the port */
*first_colon_location = '\0';
*port = atol(first_colon_location + 1);
}
}
} else { /* If '['..']' found, */
const char *initial_bracket; /* extract the remote_host */
char *second_bracket;
char *colon_before_port;
initial_bracket = strchr( addr, '[' );
initial_bracket++; /* Step forward one character */
len = strlen(initial_bracket) + 1;
memmove(host, initial_bracket, len);
second_bracket = strchr( host, ']' );
*second_bracket = '\0';
/* Check for a port specified after the ] */
colon_before_port = strchr(second_bracket + 1, ':');
if (colon_before_port != NULL) {
*port = atol(colon_before_port + 1);
} else {
*port = 0;
}
}
}
static unsigned char tolower_table[256];
void init_tolower_table() {
for (int i = 0; i < 256; i++) {
tolower_table[i] = tolower(i);
}
}
/* This is simpler than doing a regular tolower, because there are no branches.
* We also inline it, so that we don't have function call overheads.
*
* An alternative to a table would be to do (c | 0x20), but that only works if
* we are sure that we are searching for characters (or don't care if they are
* not characters. */
unsigned char inline mytolower(unsigned char c) {
return tolower_table[c];
}
char * strcasestr2(char *s, char *find) {
char c, sc;
size_t len;
if ((c = *find++) != 0) {
c = mytolower((unsigned char)c);
len = strlen(find);
do {
do {
if ((sc = *s++) == 0)
return (NULL);
} while ((char)mytolower((unsigned char)sc) != c);
} while (strncasecmp(s, find, len) != 0);
s--;
}
return ((char *)s);
}
char * strncasestr(char *s, char *find, size_t n) {
char *end = s + n;
char c, sc;
size_t len;
if ((c = *find++) != 0) {
c = mytolower((unsigned char)c);
len = strlen(find);
end -= (len - 1);
do {
do {
if ((sc = *s++) == 0)
return (NULL);
if (s >= end)
return (NULL);
} while ((char)mytolower((unsigned char)sc) != c);
} while (strncasecmp(s, find, len) != 0);
s--;
}
return ((char *)s);
}
int get_decimal_from_hex(char hex) {
if (isdigit(hex))
return hex - '0';
else
return tolower(hex) - 'a' + 10;
}
/******************** Recv Poll Processing *********************/
int epollfd;
int pollnfds;
struct epoll_event epollfiles[SIPP_MAXFDS];
struct epoll_event* epollevents;
struct sipp_socket *sockets[SIPP_MAXFDS];
map<string, struct sipp_socket *> map_perip_fd;
/***************** Check of the message received ***************/
bool sipMsgCheck (const char *P_msg, int P_msgSize, struct sipp_socket *socket) {
const char C_sipHeader[] = "SIP/2.0" ;
if (socket == twinSippSocket || socket == localTwinSippSocket ||
is_a_peer_socket(socket) || is_a_local_socket(socket))
return true;
if (strstr(P_msg, C_sipHeader) != NULL) {
return true ;
}
return false ;
}
/************** Statistics display & User control *************/
void print_stats_in_file(FILE * f, int last)
{
static char temp_str[256];
int divisor;
#define SIPP_ENDL "\r\n"
/* We are not initialized yet. */
if (!display_scenario) {
return;
}
/* Optional timestamp line for files only */
if(f != stdout) {
time_t tim;
time(&tim);
fprintf(f, " Timestamp: %s" SIPP_ENDL, ctime(&tim));
}
/* Header line with global parameters */
if (users >= 0) {
sprintf(temp_str, "%d (%d ms)", users, duration);
} else {
sprintf(temp_str, "%3.1f(%d ms)/%5.3fs", rate, duration, (double)rate_period_ms / 1000.0);
}
unsigned long long total_calls = display_scenario->stats->GetStat(CStat::CPT_C_IncomingCallCreated) + display_scenario->stats->GetStat(CStat::CPT_C_OutgoingCallCreated);
if( creationMode == MODE_SERVER) {
fprintf
(f,
" Port Total-time Total-calls Transport"
SIPP_ENDL
" %-5d %6lu.%02lu s %8llu %s"
SIPP_ENDL SIPP_ENDL,
local_port,
clock_tick / 1000, (clock_tick % 1000) / 10,
total_calls,
TRANSPORT_TO_STRING(transport));
} else {
assert(creationMode == MODE_CLIENT);
if (users >= 0) {
fprintf(f, " Users (length)");
} else {
fprintf(f, " Call-rate(length)");
}
fprintf(f, " Port Total-time Total-calls Remote-host" SIPP_ENDL
"%19s %-5d %6lu.%02lu s %8llu %s:%d(%s)" SIPP_ENDL SIPP_ENDL,
temp_str,
local_port,
clock_tick / 1000, (clock_tick % 1000) / 10,
total_calls,
remote_ip,
remote_port,
TRANSPORT_TO_STRING(transport));
}
/* 1st line */
if(total_calls < stop_after) {
sprintf(temp_str, "%llu new calls during %lu.%03lu s period ",
display_scenario->stats->GetStat(CStat::CPT_PD_IncomingCallCreated) +
display_scenario->stats->GetStat(CStat::CPT_PD_OutgoingCallCreated),
(clock_tick-last_report_time) / 1000,
((clock_tick-last_report_time) % 1000));
} else {
sprintf(temp_str, "Call limit reached (-m %lu), %lu.%03lu s period ",
stop_after,
(clock_tick-last_report_time) / 1000,
((clock_tick-last_report_time) % 1000));
}
divisor = scheduling_loops; if(!divisor) { divisor = 1; }
fprintf(f," %-38s %lu ms scheduler resolution"
SIPP_ENDL,
temp_str,
(clock_tick-last_report_time) / divisor);
/* 2nd line */
if( creationMode == MODE_SERVER) {
sprintf(temp_str, "%llu calls", display_scenario->stats->GetStat(CStat::CPT_C_CurrentCall));
} else {
sprintf(temp_str, "%llu calls (limit %d)", display_scenario->stats->GetStat(CStat::CPT_C_CurrentCall), open_calls_allowed);
}
fprintf(f," %-38s Peak was %llu calls, after %llu s" SIPP_ENDL,
temp_str,
display_scenario->stats->GetStat(CStat::CPT_C_CurrentCallPeak),
display_scenario->stats->GetStat(CStat::CPT_C_CurrentCallPeakTime));
fprintf(f," %d Running, %d Paused, %d Woken up" SIPP_ENDL,
last_running_calls, last_paused_calls, last_woken_calls);
last_woken_calls = 0;
/* 3rd line dead call msgs, and optional out-of-call msg */
sprintf(temp_str,"%llu dead call msg (discarded)",
display_scenario->stats->GetStat(CStat::CPT_G_C_DeadCallMsgs));
fprintf(f," %-37s", temp_str);
if( creationMode == MODE_CLIENT) {
sprintf(temp_str,"%llu out-of-call msg (discarded)",
display_scenario->stats->GetStat(CStat::CPT_G_C_OutOfCallMsgs));
fprintf(f," %-37s", temp_str);
}
fprintf(f,SIPP_ENDL);
if(compression) {
fprintf(f," Comp resync: %d sent, %d recv" ,
resynch_send, resynch_recv);
fprintf(f,SIPP_ENDL);
}
/* 4th line , sockets and optional errors */
sprintf(temp_str,"%d open sockets",
pollnfds);
fprintf(f," %-38s", temp_str);
if(nb_net_recv_errors || nb_net_send_errors || nb_net_cong) {
fprintf(f," %lu/%lu/%lu %s errors (send/recv/cong)" SIPP_ENDL,
nb_net_send_errors,
nb_net_recv_errors,
nb_net_cong,
TRANSPORT_TO_STRING(transport));
} else {
fprintf(f,SIPP_ENDL);
}
#ifdef PCAPPLAY
/* if has media abilities */
if (hasMedia != 0) {
sprintf(temp_str, "%lu Total RTP pckts sent ",
rtp_pckts_pcap);
if (clock_tick-last_report_time) {
fprintf(f," %-38s %lu.%03lu last period RTP rate (kB/s)" SIPP_ENDL,
temp_str,
(rtp_bytes_pcap)/(clock_tick-last_report_time),
(rtp_bytes_pcap)%(clock_tick-last_report_time));
}
rtp_bytes_pcap = 0;
rtp2_bytes_pcap = 0;
}
#endif
/* 5th line, RTP echo statistics */
if (rtp_echo_enabled && (media_socket > 0)) {
sprintf(temp_str, "%lu Total echo RTP pckts 1st stream",
rtp_pckts);
// AComment: Fix for random coredump when using RTP echo
if (clock_tick-last_report_time) {
fprintf(f," %-38s %lu.%03lu last period RTP rate (kB/s)" SIPP_ENDL,
temp_str,
(rtp_bytes)/(clock_tick-last_report_time),
(rtp_bytes)%(clock_tick-last_report_time));
}
/* second stream statitics: */
sprintf(temp_str, "%lu Total echo RTP pckts 2nd stream",
rtp2_pckts);
// AComment: Fix for random coredump when using RTP echo
if (clock_tick-last_report_time) {
fprintf(f," %-38s %lu.%03lu last period RTP rate (kB/s)" SIPP_ENDL,
temp_str,
(rtp2_bytes)/(clock_tick-last_report_time),
(rtp2_bytes)%(clock_tick-last_report_time));
}
rtp_bytes = 0;
rtp2_bytes = 0;
}
/* Scenario counters */
fprintf(f,SIPP_ENDL);
if(!lose_packets) {
fprintf(f," "
"Messages Retrans Timeout Unexpected-Msg"
SIPP_ENDL);
} else {
fprintf(f," "