📄 sipp.cpp
字号:
if(open_calls >= open_calls_allowed) { set_rate(rate); } } // Quit after asked number of calls is reached if(total_calls >= stop_after) { quitting = 1; } } else if (quitting) { /* Quitting and no more openned calls, close all */ if(!open_calls) { // Dump the latest statistics if necessary if(dumpInFile) { CStat::instance()->dumpData(); } /* Screen dumping in a file if asked */ if(screenf) { print_screens(); } screen_exit(EXIT_TEST_RES_UNKNOWN); } } if(compression) { timer_resolution = 50; } /* Schedule all pending calls and process their timers */ if((clock_tick - last_timer_cycle) > timer_resolution) { call_map * calls = get_calls(); call_map::iterator iter; /* Workaround hpux problem with iterators. Deleting the * current object when iterating breaks the iterator and * leads to iterate again on the destroyed (deleted) * object. Thus, we have to wait ont step befere actual * deletion of the object*/ call * last = NULL; for(iter = calls->begin(); iter != calls->end(); iter++) { if(last) { last -> run(); } last = iter -> second; } if(last) { last -> run(); } last_timer_cycle = clock_tick; } /* Receive incomming messages */ pollset_process(ipv6); if(firstPass) { // dumping (to create file on disk) and showing // screen at the beginning even if the report // period is not reach firstPass = false; print_statistics(0); /* Dumping once to create the file on disk */ if(dumpInFile) { CStat::instance()->dumpData(); } } if((clock_tick - last_report_time) >= report_freq) { print_statistics(0); CStat::instance()->computeStat(CStat::E_RESET_PD_COUNTERS); last_report_time = clock_tick; last_report_calls = total_calls; rtd_sum = 0; rtd_nb = 0; call_duration_sum = 0; call_duration_nb = 0; scheduling_loops = 0; } // FIXME - Should we recompute time ? print stat take // a lot of time, so the clock_time is no more // the current time ! if(dumpInFile) { if((clock_tick - last_dump_time) >= report_freq_dumpLog) { CStat::instance()->dumpData(); CStat::instance()->computeStat(CStat::E_RESET_PL_COUNTERS); last_dump_time = clock_tick; } } }}/*************** RTP ECHO THREAD ***********************/void rtp_echo_thread (void * param){ char msg[2048]; size_t nr, ns; sipp_socklen_t len; int rc; sigset_t mask; sigfillset(&mask); /* Mask all allowed signals */ rc = pthread_sigmask(SIG_BLOCK, &mask, NULL); for (;;) { len = sizeof(remote_rtp_addr); nr = recvfrom(media_socket, msg, sizeof(msg), 0, (sockaddr *)(void *) &remote_rtp_addr, &len); if (((long)nr) < 0) { WARNING_P2("%s %i", "Error on RTP echo reception - stopping echo - errno=", errno); return; } ns = sendto(media_socket, msg, nr, 0, (sockaddr *)(void *) &remote_rtp_addr, len); if (ns != nr) { WARNING_P2("%s %i", "Error on RTP echo transmission - stopping echo - errno=", errno); return; } rtp_pckts++; rtp_bytes += ns; }}/* Help screen */void help() { printf ("\n" "Usage:\n" "\n" " sipp remote_host[:remote_port] [options]\n" "\n" " Available options:\n" "\n" " -v : Display version and copyright information.\n" "\n" " -bg : Launch the tool in background mode.\n" "\n" " -p local_port : Set the local port number. Default is a\n" " random free port chosen by the system.\n" "\n" " -i local_ip : Set the local IP address for 'Contact:',\n" " 'Via:', and 'From:' headers. Default is\n" " primary host IP address.\n" "\n" " -inf file_name : Inject values from an external CSV file during calls\n" " into the scenarios.\n" " First line of this file say whether the data is \n" " to be read in sequence (SEQUENTIAL) or random \n" " (RANDOM) order.\n" " Each line corresponds to one call and has one or \n" " more ';' delimited data fields. Those fields can be \n" " referred as [field0], [field1], ... in the xml \n" " scenario file.\n" "\n" " -d duration : Controls the length (in milliseconds) of\n" " calls. More precisely, this controls\n" " the duration of 'pause' instructions in\n" " the scenario, if they do not have a\n" " 'milliseconds' section. Default value is 0.\n" "\n" " -r rate (cps) : Set the call rate (in calls per seconds).\n" " This value can be changed during test by\n" " pressing '+','_','*' or '/'. Default is 10.\n" " pressing '+' key to increase call rate by 1,\n" " pressing '-' key to decrease call rate by 1,\n" " pressing '*' key to increase call rate by 10,\n" " pressing '/' key to decrease call rate by 10.\n" " If the -rp option is used, the call rate is\n" " calculated with the period in ms given \n" " by the user.\n" "\n" " -rp period (ms) : Specify the rate period in milliseconds for the call\n" " rate.\n" " Default is 1 second.\n" " This allows you to have n calls every m milliseconds \n" " (by using -r n -rp m).\n" " Example: -r 7 -rp 2000 ==> 7 calls every 2 seconds.\n" "\n" " -sf filename : Loads an alternate xml scenario file.\n" " To learn more about XML scenario syntax,\n" " use the -sd option to dump embedded \n" " scenarios. They contain all the necessary\n" " help.\n" "\n" " -sn name : Use a default scenario (embedded in\n" " the sipp executable). If this option is omitted,\n" " 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\n" " regexp and variables.\n" " 'branchc' : Branching and conditional\n" " branching in scenarios - client.\n" " 'branchs' : Branching and conditional\n" " branching in scenarios - server.\n"#ifdef __3PCC__ "\n" " Default 3pcc scanerios (see -3pcc option):\n" "\n" " '3pcc-C-A' : Controller A side (must be started\n" " after all other 3pcc scenarios)\n" " '3pcc-C-B' : Controller B side.\n" " '3pcc-A' : A side.\n" " '3pcc-B' : B side.\n"#endif "\n" " -sd name : Dumps a default scenario (embeded in\n" " the sipp executable)\n" "\n"#ifdef _USE_OPENSSL " -t [u1|un|t1|tn|l1|ln] : Set the transport mode:\n"#else " -t [u1|un|t1|tn] : Set the transport mode:\n"#endif "\n" " u1: UDP with one socket (default),\n" " un: UDP with one socket per call,\n" " t1: TCP with one socket,\n" " tn: TCP with one socket per call,\n"#ifdef _USE_OPENSSL " l1: TLS with one socket,\n" " ln: TLS with one socket per call.\n"#endif "\n"); if(!strlen(comp_error)) { printf (" It appears that you installed the\n" " " COMP_PLUGGIN " plugin. 2 additionnal\n" " transport modes are available:\n" "\n" " c1: u1 + compression,\n" " cn: un + compression.\n" "\n"); } printf (" -trace_msg : Displays sent and received SIP messages in\n" " <scenario file name>_<ppid>_messages.log\n" "\n" " -trace_screen : Dump statistic screens in the \n" " <scenario_name>_<ppid>_screens.log file when\n" " quitting SIPp. Useful to get a final status report\n" " in background mode (-bg option).\n" "\n" " -trace_timeout : Displays call ids for calls with timeouts in\n" " <scenario file name>_<ppid>_timeout.log\n" "\n" " -trace_stat : Dumps all statistics in <scenario_name>_<ppid>.csv\n" " file. Use the '-h stat' option for a detailed\n" " description of the statistics file content.\n" "\n" " -stf file_name : Set the file name to use to dump statistics\n" "\n" " -trace_err : Trace all unexpected messages in\n" " <scenario file name>_<ppid>_errors.log.\n" "\n" " -trace_logs : Allow tracing of <log> actions in\n" " <scenario file name>_<ppid>_logs.log.\n" "\n" " -s service_name : Set the username part of the resquest URI.\n" " Default is 'service'.\n" "\n"#ifdef _USE_OPENSSL " -ap password : Set the password for authentication challenges.\n" " Default is 'password'\n" "\n"#endif " -f frequency : Set the statistics report frequency on screen\n" " (in seconds). Default is 1.\n" "\n" " -fd frequency : Set the statistics dump log report frequency\n" " (in seconds). Default is 60.\n" "\n" " -l calls_limit : Set the maximum number of simultaneous\n" " calls. Once this limit is reached, traffic\n" " is decreased until the number of open calls\n" " goes down. Default:\n" "\n" " (3 * call_duration (s) * rate).\n" "\n" " -m calls : Stop the test and exit when 'calls' calls are\n" " processed.\n" "\n" " -mp local_port : Set the local RTP echo port number. Default\n" " is none. RTP/UDP packets received on that\n" " port are echoed to their sender.\n" "\n" " -mi local_rtp_ip : Set the local IP address for RTP echo.\n" "\n"#ifdef __3PCC__ " -3pcc ip:port : Launch the tool in 3pcc mode (\"Third Party\n" " call control\"). The passed ip address\n" " is depending on the 3PCC role.\n" " - When the first twin command is 'sendCmd' then\n" " this is the address of the remote twin socket.\n" " Example: 3PCC-C-A scenario.\n" " - When the first twin command is 'recvCmd' then\n" " this is the address of the local twin socket.\n" " Example: 3PCC-C-B scenario.\n" "\n"#endif " -nr : Disable retransmission in UDP mode.\n" "\n" " -nd : No Default. Disable all default behavior of SIPp\n" " which are the following:\n" " - On UDP retransmission timeout, abort the call by\n" " 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\n" " sending a BYE or a CANCEL\n" "\n" " -rsa host:port : Set the remote sending address to host:port.\n" " for sending the messages.\n" "\n" "Signal handling:\n" "\n" " SIPp can be controlled using posix signals. The following signals\n" " are handled:\n" " USR1: Similar to press 'q' keyboard key. It triggers a soft exit\n" " of SIPp. No more new calls are placed and all ongoing calls\n" " are finished before SIPp exits.\n" " Example: kill -SIGUSR1 732\n" " USR2: Triggers a dump of all statistics screens in\n" " <scenario_name>_<ppid>_screens.log file. Especially useful \n" " in background mode to know what the current status is.\n" " Example: kill -SIGUSR2 732\n" "\n" "Exit code:\n" "\n" " Upon exit (on fatal error or when the number of asked calls (-m\n" " option) is reached, sipp exits with one of the following exit\n" " code:\n" " 0: All calls were successful\n" " 1: At least one call failed\n" " 97: exit on internal command. Calls may have been processed\n" " 99: Normal exit without calls processed\n" " -1: Fatal error\n" "\n" "\n" "Example:\n" "\n" " Run sipp with embedded server (uas) scenario:\n" " ./sipp -sn uas\n" " On the same host, run sipp with embedded client (uac) scenario\n" " ./sipp -sn uac 127.0.0.1\n" "\n");}void help_stats() { printf("\n"" The -trace_stat option dumps all statistics in the\n"" <scenario_name.csv> file. The dump starts with one header\n" " line with all counters. All following lines are 'snapshots' of \n"" statistics counter given the statistics report frequency\n"" (-fd option). This file can be easily imported in any\n"" spreadsheet application, like Excel.\n""\n"" In counter names, (P) means 'Periodic' - since last\n"" statistic row and (C) means 'Cumulated' - since sipp was\n"" started.\n""\n"" Available statistics are:\n""\n"" - StartTime: \n"" Date and time when the test has started.\n""\n"" - LastResetTime:\n"" Date and time when periodic counters where last reseted.\n""\n"" - CurrentTime:\n"" Date and time of the statistic row.\n""\n"" - ElapsedTime:\n"" Elapsed time.\n""\n"" - CallRate:\n"" Call rate (calls per seconds).\n""\n"" - IncomingCall:\n"" Number of incoming calls.\n""\n"" - OutgoingCall:\n"" Number of outgoing calls.\n""\n"" - TotalCallCreated:\n"" Number of calls created.\n""\n"" - CurrentCall:\n"" Number of calls currently ongoing.\n""\n"" - SuccessfulCall:\n"" Number of successful calls.\n""\n"" - FailedCall:\n"" Number of failed calls (all reasons).\n""\n"" - FailedCannotSendMessage:\n"" Number of failed calls because Sipp cannot send the\n"" message (transport issue).\n""\n"" - FailedMaxUDPRetrans:\n"" Number of failed calls because the maximum number of\n"" UDP retransmission attempts has been reached.\n""\n"" - FailedUnexpectedMessage:\n"" Number of failed calls because the SIP message received\n"" is not expected in the scenario.\n""\n"" - FailedCallRejected:\n"" Number of failed calls because of Sipp internal error.\n"" (a scenario sync command is not recognized or a scenario\n"" action failed or a scenario variable assignment failed).\n""\n"" - FailedCmdNotSent:\n"" Number of failed calls because of inter-Sipp\n"" communication error (a scenario sync command failed to\n"" be sent).\n""\n"" - FailedRegexpDoesntMatch:\n"" Number of failed calls because of regexp that doesn't\n"" match (there might be several regexp that don't match\n"" during the call but the counter is increased only by\n"" one).\n""\n"" - FailedRegexpHdrNotFound:\n"" Numbe
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -