⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sipp.cpp

📁 学习sip协议的好工具
💻 CPP
📖 第 1 页 / 共 5 页
字号:
     "   -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"     "   -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"     "   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""    Number of failed calls because of regexp with hdr    \n""    option but no matching header found.\n""\n""  - OutOfCallMsgs:\n""    Number of SIP messages received that cannot be associated\n""    to an existing call.\n""\n""  - AutoAnswered:\n""    Number of unexpected specific messages received for new Call-ID.\n""    The message has been automatically answered by a 200 OK\n""    Currently, implemented for 'PING' message only.\n""\n");}/************* exit handler *****************/void print_last_stats(){  interrupt = 1;  // print last current screen  print_statistics(1);  // and print statistics screen  currentScreenToDisplay = DISPLAY_STAT_SCREEN;  print_statistics(1);}void releaseGlobalAllocations(){  message * L_ptMsg = NULL;  CStat::instance()->close();  for(int i=0; i<SCEN_VARIABLE_SIZE; i++)    {      if (scenVariableTable[i] != NULL)        delete(scenVariableTable[i]);      scenVariableTable[i] = NULL;    }  for(int i=0; i<scenario_len; i++)  {    L_ptMsg = scenario[i];    if (L_ptMsg != NULL)    {      delete(L_ptMsg);      scenario[i] = NULL;    }  }}char* remove_pattern(char* P_buffer, char* P_extensionPattern) {  char *L_ptr = P_buffer;  if (P_extensionPattern == NULL) {    return P_buffer ;  }  if (P_buffer == NULL) {    return P_buffer ;  }  L_ptr = strstr(P_buffer, P_extensionPattern) ;  if (L_ptr != NULL) {    *L_ptr = '\0' ;  }  return P_buffer ;  }/* Main */int main(int argc, char *argv[]){  int                  argi = 0;  int                  index = 0;  struct sockaddr_in   local_sockaddr;  struct sockaddr_in   localTwin_sockaddr;  struct sockaddr_in   media_sockaddr;  int                  user_port = 0;  pthread_t            pthread_id, pthread2_id;  int                  argiFileName = 0;  int                  argiInputFile = 0;  /* At least one argument is needed */  if(argc < 2) {    help();    exit(EXIT_OTHER);  }  /* Ignore the SIGPIPE signal */  {    struct sigaction action_pipe;    memset(&action_pipe, 0, sizeof(action_pipe));    action_pipe.sa_handler=SIG_IGN;    sigaction(SIGPIPE, &action_pipe, NULL);	     /* sig usr1 management */    struct sigaction action_usr1;    memset(&action_usr1, 0, sizeof(action_usr1));    action_usr1.sa_handler = sipp_sigusr1;    sigaction(SIGUSR1, &action_usr1, NULL);    /* sig usr2 management */    struct sigaction action_usr2;    memset(&action_usr2, 0, sizeof(action_usr2));    action_usr2.sa_handler = sipp_sigusr2;    sigaction(SIGUSR2, &action_usr2, NULL);  }    screen_set_exename((char *)"sipp");    pid = getpid();  memset(local_ip, 0, 20);  memset(media_ip,0, 20);  /* Load compression pluggin if available */  comp_load();    /* Command line parsing */    for(argi = 1; argi < argc; argi++) {	     int processed = 0;	     if((!strcmp(argv[argi], "-h"    )) ||       (!strcmp(argv[argi], "--h"   )) ||        (!strcmp(argv[argi], "--help")) ||        (!strcmp(argv[argi], "-help" ))    ) {      if(((argi+1) < argc) && (!strcmp(argv[argi+1], "stat"))) {        help_stats();      } else {        help();      }      exit(EXIT_OTHER);    }	     if(!strcmp(argv[argi], "-p")) {      if((++argi) < argc) {        user_port = atol(argv[argi]);        processed = 1;      } else {        ERROR_P1("Missing argument for param '%s'.\nUse 'sipp -h' for details",                 argv[argi-1]);      }    }	     if(!strcmp(argv[argi], "-mp")) {      if((++argi) < argc) {        media_port = atol(argv[argi]);	processed = 1;      } else {        ERROR_P1("Missing argument for param '%s'.\nUse 'sipp -h' for details",                 argv[argi-1]);      }    }    if(!strcmp(argv[argi], "-mi")) {      if((++argi) < argc) {        processed = 1;        strcpy(media_ip, argv[argi]);      } else {        ERROR_P1("Missing argument for param '%s'.\n"                 "Use 'sipp -h' for details",  argv[argi-1]);      }    }    if(!strcmp(argv[argi], "-t")) {      if((++argi) < argc) {        processed = 1;        if(!strcmp(argv[argi], "u1")) {          transport = T_UDP;          multisocket = 0;        } else if(!strcmp(argv[argi], "un")) {          transport = T_UDP;          multisocket = 1;        } else if(!strcmp(argv[argi], "t1")) {          transport = T_TCP;          multisocket = 0;        } else if(!strcmp(argv[argi], "tn")) {          transport = T_TCP;          multisocket = 1;        } else if(!strcmp(argv[argi], "c1")) {          if(strlen(comp_error)) {            ERROR_P1("No " COMP_PLUGGIN " pluggin available:\n%s", comp_error);          }          transport = T_UDP;          multisocket = 0;          compression = 1;        } else if(!strcmp(argv[argi], "cn")) {          if(strlen(comp_error)) {            ERROR_P1("No " COMP_PLUGGIN " pluggin available:\n%s", comp_error);          }          transport = T_UDP;          multisocket = 1;          compression = 1;        } else {          ERROR_P1("Invalid argument for -t param : '%s'.\n"                   "Use 'sipp -h' for details",  argv[argi]);        }                } else {        ERROR_P1("Missing argument for param '%s'.\n"                 "Use 'sipp -h' for details",  argv[argi-1]);      }    }    if(!strcmp(argv[argi], "-nr")) {      processed = 1;      retrans_enabled = 0;    }    if(!strcmp(argv[argi], "-trace_msg")) {      useMessagef = 1 ;      processed = 1;    }    if(!strcmp(argv[argi], "-trace_screen")) {      useScreenf = 1 ;      processed = 1;    }    if(!strcmp(argv[argi], "-trace_timeout")) {      useTimeoutf = 1 ;      processed = 1;    }    if(!strcmp(argv[argi], "-trace_err")) {      processed = 1;      print_all_responses = 1;    }    if(!strcmp(argv[argi], "-trace_stat")) {      processed  = 1;      dumpInFile = 1;    }    if(!strcmp(argv[argi], "-stf")) {      if((++argi) < argc) {        processed = 1;        argiFileName = argi;      } else {        ERROR_P1("Missing argument for param '%s'.\n"                 "Use 'sipp -h' for details",  argv[argi-1]);      }    }    if(!strcmp(argv[argi], "-inf")) {      if((++argi) < argc) {        processed = 1;        argiInputFile = argi;      } else {        ERROR_P1("Missing argument for param '%s'.\n"                 "Use 'sipp -h' for details",  argv[argi-1]);      }    }    if(!strcmp(argv[argi], "-d")) {      if((++argi) < argc) {        processed = 1;        duration = atol(argv[argi]);      } else {        ERROR_P1("Missing argument for param '%s'.\n"                 "Use 'sipp -h' for details",  argv[argi-1]);      }    }    if(!strcmp(argv[argi], "-i")) {      if((++argi) < argc) {        processed = 1;        strcpy(local_ip, argv[argi]);      } else {        ERROR_P1("Missing argument for param '%s'.\n"                 "Use 'sipp -h' for details",  argv[argi-1]);      }    }        if(!strcmp(argv[argi], "-m")) {      if((++argi) < argc) {        processed = 1;        stop_after  = atol(argv[argi]);      } else {        ERROR_P1("Missing argument for param '%s'.\n"                 "Use 'sipp -h' for details",  argv[argi-1]);      }    }    if(!strcmp(argv[argi], "-f")) {      if((++argi) < argc) {        processed = 1;        report_freq  = atol(argv[argi]) * 1000;      } else {        ERROR_P1("Missing argument for param '%s'.\n"                 "Use 'sipp -h' for details",  argv[argi-1]);      }    }    if(!strcmp(argv[argi], "-fd")) {      if((++argi) < argc) {        processed = 1;        report_freq_dumpLog = atol(argv[argi]) * 1000;      } else {        ERROR_P1("Missing argument for param '%s'.\n"                 "Use 'sipp -h' for details",  argv[argi-1]);      }    }    if(!strcmp(argv[argi], "-l")) {      if((++argi) < argc) {        processed = 1;        open_calls_allowed = atol(argv[argi]);        open_calls_user_setting = 1;      } else {        ERROR_P1("Missing argument for param '%s'.\n"                 "Use 'sipp -h' for details",  argv[argi-1]);      }    }    if(!strcmp(argv[argi], "-bg")) {      processed = 1;      backgroundMode = true;    }    if(!strcmp(argv[argi], "-v")) {      printf("\n Sipp v1.0final, built %s, %s.\n\n", __DATE__, __TIME__);       printf        (" This program is free software; you can redistribute it and/or\n"         " modif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -