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

📄 sipp.cpp

📁 sipp is sip protocal testing tool.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
       local_port,       clock_tick / 1000, (clock_tick % 1000) / 10,       total_calls,       TRANSPORT_TO_STRING(transport));  } else {    fprintf      (f,       "  Call-rate(length)     Port   Total-time  Total-calls  Remote-host"        SIPP_ENDL       "%19s   %-5d %6d.%02d s     %8d  %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, "%d new calls during %d.%03d s period ",            total_calls - last_report_calls,            (clock_tick-last_report_time) / 1000,             ((clock_tick-last_report_time) % 1000));  } else {    sprintf(temp_str, "Call limit reached (-m %d), %d.%03d 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 %d ms scheduler resolution"          SIPP_ENDL,         temp_str,         (clock_tick-last_report_time) / divisor);  /* 2nd line */  if( toolMode == MODE_SERVER) {     sprintf(temp_str, "%d calls", open_calls);  } else {    sprintf(temp_str, "%d calls (limit %d)", open_calls, open_calls_allowed);  }  fprintf(f,"  %-38s Peak was %d calls, after %d s" SIPP_ENDL,          temp_str,          open_calls_peak,          open_calls_peak_time);  fprintf(f,"  %d Running, %d Paused, %d Woken up" SIPP_ENDL,	 last_running_calls, last_paused_calls, last_woken_calls);  /* 3rd line (optional) */  if( toolMode != MODE_SERVER) {     sprintf(temp_str,"%d out-of-call msg (discarded)",             nb_out_of_the_blue);    fprintf(f,"  %-37s", temp_str);  }  if(compression) {    fprintf(f,"  Comp resync: %d sent, %d recv" ,            resynch_send, resynch_recv);  }  if(compression || (toolMode != MODE_SERVER)) {    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,"  %d/%d/%d %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, "%d Total RTP pckts sent ",            rtp_pckts_pcap);    if (clock_tick-last_report_time) {       fprintf(f,"  %-38s %d.%03d 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, "%d 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 %d.%03d 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, "%d 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 %d.%03d 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,"                                 "           "Messages  Retrans   Timeout   Unexp.    Lost"            SIPP_ENDL);  }  for(index = 0;      index < scenario_len;      index ++) {        if(scenario[index] -> send_scheme) {      char *dest, *src;      int len;      dest = temp_str;      src  = scenario[index] -> send_scheme;      if( strncmp(src, "SIP/2.0", 7) == 0) {        src += 8;      }      while((*src) && (*src != ' ') && (*src != '\t') && (*src != '\n')) {        *dest++ = *src ++;      }      *dest = 0;      if(toolMode == MODE_SERVER) {        fprintf(f,"  <---------- %-10s ", temp_str);      } else {        fprintf(f,"  %10s ----------> ", temp_str);      }      if (scenario[index] -> start_rtd) {	fprintf(f, " B-RTD%d ", scenario[index] -> start_rtd);      } else if (scenario[index] -> stop_rtd) {	fprintf(f, " E-RTD%d ", scenario[index] -> stop_rtd);      } else {	fprintf(f, "        ");      }      if(scenario[index] -> retrans_delay) {        fprintf(f,"%-9d %-9d %-9d" ,               scenario[index] -> nb_sent,               scenario[index] -> nb_sent_retrans,               scenario[index] -> nb_timeout);      } else {        fprintf(f,"%-9d %-9d                    " ,               scenario[index] -> nb_sent,               scenario[index] -> nb_sent_retrans);      }    } else if(scenario[index] -> recv_response) {      if(toolMode == MODE_SERVER) {	fprintf(f,"  ----------> %-10d ", scenario[index] -> recv_response);      } else { 	fprintf(f,"  %10d <---------- ", scenario[index] -> recv_response);      }      if (scenario[index] -> start_rtd) {	fprintf(f, " B-RTD%d ", scenario[index] -> start_rtd);      } else if (scenario[index] -> stop_rtd) {	fprintf(f, " E-RTD%d ", scenario[index] -> stop_rtd);      } else {	fprintf(f, "        ");      }      if(scenario[index]->retrans_delay) {        fprintf(f,"%-9ld %-9ld %-9ld %-9ld" ,               scenario[index]->nb_recv,               scenario[index]->nb_recv_retrans,               scenario[index]->nb_timeout,               scenario[index]->nb_unexp);      } else {        fprintf(f,"%-9ld %-9ld           %-9ld" ,               scenario[index] -> nb_recv,               scenario[index] -> nb_recv_retrans,               scenario[index] -> nb_unexp);      }    } else if (scenario[index] -> pause_function) {      char *desc = scenario[index]->pause_desc;      int len = strlen(desc) < 9 ? 9 : strlen(desc);      if(toolMode == MODE_SERVER) {	fprintf(f,"  [%9s] Pause%*s", desc, 23 - len > 0 ? 23 - len : 0, "");      } else {	fprintf(f,"       Pause [%9s]%*s", desc, 18 - len > 0 ? 18 - len : 0, "");      }      fprintf(f,"%-9d", scenario[index]->sessions);      fprintf(f,"                     %-9d" , scenario[index]->nb_unexp);    } else if(scenario[index] -> recv_request) {      if(toolMode == MODE_SERVER) {	fprintf(f,"  ----------> %-10s ", scenario[index] -> recv_request);      } else {	fprintf(f,"  %10s <---------- ", scenario[index] -> recv_request);      }      if (scenario[index] -> start_rtd) {	fprintf(f, " B-RTD%d ", scenario[index] -> start_rtd);      } else if (scenario[index] -> stop_rtd) {	fprintf(f, " E-RTD%d ", scenario[index] -> stop_rtd);      } else {	fprintf(f, "        ");      }      if(scenario[index]->retrans_delay) {        fprintf(f,"%-9ld %-9ld %-9ld %-9ld" ,               scenario[index]->nb_recv,               scenario[index]->nb_recv_retrans,               scenario[index]->nb_timeout,               scenario[index]->nb_unexp);      } else {        fprintf(f,"%-9ld %-9ld           %-9ld" ,               scenario[index] -> nb_recv,               scenario[index] -> nb_recv_retrans,               scenario[index] -> nb_unexp);      }    }    else if(scenario[index] -> M_type == MSG_TYPE_NOP) {      fprintf(f,"              [ NOP ]              ");    }#ifdef __3PCC__    else if(scenario[index] -> M_type == MSG_TYPE_RECVCMD) {      fprintf(f,"       [ Received Command ]        ");      if(scenario[index]->retrans_delay) {        fprintf(f,"%-9ld %-9s %-9ld %-9s" ,                scenario[index]->M_nbCmdRecv,                "",                scenario[index]->nb_timeout,                "");      } else {         fprintf(f,"%-9ld %-9s           %-9s" ,                scenario[index] -> M_nbCmdRecv,                "",                "");      }    } else if(scenario[index] -> M_type == MSG_TYPE_SENDCMD) {      fprintf(f,"         [ Sent Command ]          ");      fprintf(f,"%-9d %-9s           %-9s" ,             scenario[index] -> M_nbCmdSent,             "",             "");    }#endif    else {      ERROR("Scenario command not implemented in display\n");    }        if(lose_packets && (scenario[index] -> nb_lost)) {      fprintf(f," %-9d" SIPP_ENDL,             scenario[index] -> nb_lost);    } else {      fprintf(f,SIPP_ENDL);    }        if(scenario[index] -> crlf) {      fprintf(f,SIPP_ENDL);    }  }}void print_header_line(FILE *f, int last){    switch(currentScreenToDisplay)    {    case DISPLAY_STAT_SCREEN :      fprintf(f,"----------------------------- Statistics Screen ------- [1-9]: Change Screen --" SIPP_ENDL);      break;    case DISPLAY_REPARTITION_SCREEN :      fprintf(f,"---------------------------- Repartition Screen ------- [1-9]: Change Screen --" SIPP_ENDL);      break;    case DISPLAY_VARIABLE_SCREEN  :      fprintf(f,"----------------------------- Variables Screen -------- [1-9]: Change Screen --" SIPP_ENDL);      break;    case DISPLAY_TDM_MAP_SCREEN  :      fprintf(f,"------------------------------ TDM map Screen --------- [1-9]: Change Screen --" SIPP_ENDL);      break;    case DISPLAY_SECONDARY_REPARTITION_SCREEN :      fprintf(f,"--------------------------- Repartition %d Screen ------ [1-9]: Change Screen --" SIPP_ENDL, currentRepartitionToDisplay);      break;    case DISPLAY_SCENARIO_SCREEN :    default:      fprintf(f,"------------------------------ Scenario Screen -------- [1-9]: Change Screen --" SIPP_ENDL);      break;    }}void print_bottom_line(FILE *f, int last){  if(last) {    fprintf(f,"------------------------------ Test Terminated --------------------------------" SIPP_ENDL);  } else if(quitting) {    fprintf(f,"------- Waiting for active calls to end. Press [q] again to force exit. -------" SIPP_ENDL );  } else if(paused) {    fprintf(f,"----------------- Traffic Paused - Press [p] again to resume ------------------" SIPP_ENDL );  } else if(cpu_max) {    fprintf(f,"-------------------------------- CPU CONGESTED ---------------------------------" SIPP_ENDL);  } else if(outbound_congestion) {    fprintf(f,"------------------------------ OUTBOUND CONGESTION -----------------------------" SIPP_ENDL);  } else {    switch(toolMode)      {      case MODE_SERVER :        fprintf(f,"------------------------------ Sipp Server Mode -------------------------------" SIPP_ENDL);        break;#ifdef __3PCC__      case MODE_3PCC_CONTROLLER_B :        fprintf(f,"----------------------- 3PCC Mode - Controller B side -------------------------" SIPP_ENDL);        break;      case MODE_3PCC_A_PASSIVE :        fprintf(f,"------------------ 3PCC Mode - Controller A side (passive) --------------------" SIPP_ENDL);        break;      case MODE_3PCC_CONTROLLER_A :        fprintf(f,"----------------------- 3PCC Mode - Controller A side -------------------------" SIPP_ENDL);        break;#endif      case MODE_CLIENT :      default:        fprintf(f,"------ [+|-|*|/]: Adjust rate ---- [q]: Soft exit ---- [p]: Pause traffic -----" SIPP_ENDL);        break;      }  }  fprintf(f,SIPP_ENDL);  fflush(stdout);}void print_tdm_map(){  int interval = 0;  int i = 0;  int j = 0;  int in_use = 0;  interval = (tdm_map_a+1) * (tdm_map_b+1) * (tdm_map_c+1);  printf("TDM Circuits in use:"  SIPP_ENDL);  while (i<interval) {    if (tdm_map[i]) {      printf("*");      in_use++;    } else {      printf(".");    }    i++;    if (i%(tdm_map_c+1) == 0) printf(SIPP_ENDL);  }  printf(SIPP_ENDL);  printf("%d/%d circuits (%d%%) in use", in_use, interval, int(100*in_use/interval));  printf(SIPP_ENDL);  for(i=0; i<(scenario_len + 8 - int(interval/(tdm_map_c+1))); i++) {    printf(SIPP_ENDL);  }}void print_variable_list(){  CActions  * actions;  CAction   * action;  CVariable * variable;  int i,j;  bool found;  printf("Action defined Per Message :" SIPP_ENDL);  found = false;  for(i=0; i<scenario_len; i++)    {      actions = scenario[i]->M_actions;      if(actions != NULL)        {          switch(scenario[i]->M_type)            {            case MSG_TYPE_RECV:              printf("=> Message[%d] (Receive Message) - "                     "[%d] action(s) defined :" SIPP_ENDL,                     i,                                  actions->getUsedAction());              break;#ifdef __3PCC__            case MSG_TYPE_RECVCMD:              printf("=> Message[%d] (Receive Command Message) - "                     "[%d] action(s) defined :" SIPP_ENDL,                     i,                                  actions->getUsedAction());              break;#endif            default:              printf("=> Message[%d] - [%d] action(s) defined :" SIPP_ENDL,                     i,                                  actions->getUsedAction());              break;            }

⌨️ 快捷键说明

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