From: <oja...@us...> - 2006-08-18 16:59:15
|
Revision: 24 Author: ojacques Date: 2006-08-18 09:58:55 -0700 (Fri, 18 Aug 2006) ViewCVS: http://svn.sourceforge.net/sipp/?rev=24&view=rev Log Message: ----------- New: new -tdmmap command line parameter that replaces [map...] keyword (syntax is the same) (ref: draft-taylor-mmusic-sdp-tdm-01.txt) - the keyword to use for TDM map is now [tdmmap]. New: notification of outbound congestion if TDM map entirely in use. New: new screen (5) to display TDM circuits in use if tdmmap is in use. Code indenting. Modified Paths: -------------- sipp/trunk/call.cpp sipp/trunk/call.hpp sipp/trunk/scenario.cpp sipp/trunk/sipp.cpp sipp/trunk/sipp.hpp sipp/trunk/stat.cpp sipp/trunk/stat.hpp Modified: sipp/trunk/call.cpp =================================================================== --- sipp/trunk/call.cpp 2006-08-16 08:10:26 UTC (rev 23) +++ sipp/trunk/call.cpp 2006-08-18 16:58:55 UTC (rev 24) @@ -63,21 +63,60 @@ static unsigned int next_number = 1; +unsigned int get_tdm_map_number(unsigned int number) { + unsigned int nb = 0; + unsigned int i=0; + unsigned int interval=0; + unsigned int random=0; + bool found = false; + + /* Find a number in the tdm_map which is not in use */ + interval = (tdm_map_a+1) * (tdm_map_b+1) * (tdm_map_c+1); + random = rand() % interval; + while ((i<interval) && (!found)) { + if (tdm_map[(random + i - 1) % interval] == false) { + nb = (random + i - 1) % interval; + found = true; + } + i++; + } + + if (!found) { + return 0; + } else { + return nb+1; + } +} + call * add_call(char * call_id, bool ipv6) { call * new_call; + unsigned int nb; + if(!next_number) { next_number ++; } + + if (use_tdmmap) { + nb = get_tdm_map_number(next_number); + if (nb != 0) { + /* Mark the entry in the list as busy */ + tdm_map[nb - 1] = true; + } else { + /* Can't create the new call */ + WARNING("Can't create new outgoing call: all tdm_map circuits busy"); + return NULL; + } + } + new_call = new call(call_id, ipv6); - if(!new_call) { ERROR("Memory Overflow"); } calls[std::string(call_id)] = new_call; - if(!next_number) { next_number ++; } new_call -> number = next_number; + new_call -> tdm_map_number = nb - 1; /* Vital counters update */ next_number++; @@ -98,18 +137,32 @@ call * add_call(char * call_id , int P_pollset_indx, bool ipv6) { call * new_call; + unsigned int nb; + if(!next_number) { next_number ++; } + + if (use_tdmmap) { + nb = get_tdm_map_number(next_number); + if (nb != 0) { + /* Mark the entry in the list as busy */ + tdm_map[nb - 1] = true; + } else { + /* Can't create the new call */ + WARNING("Can't create new outgoing call: all tdm_map circuits busy"); + return NULL; + } + } + new_call = new call(call_id, ipv6); - if(!new_call) { ERROR("Memory Overflow"); } calls[std::string(call_id)] = new_call; - if(!next_number) { next_number ++; } new_call -> number = next_number; + new_call -> tdm_map_number = nb - 1; new_call -> pollset_index = P_pollset_indx; /* Vital counters update */ @@ -186,14 +239,15 @@ call_ptr = (call_it != calls.end()) ? call_it->second : NULL ; if(call_ptr) { + tdm_map[call_ptr->tdm_map_number] = false; calls.erase(call_it); delete call_ptr; open_calls--; } else { if (start_calls == 0) { - ERROR("Call not found"); + ERROR("Call not found"); + } } - } } @@ -383,6 +437,7 @@ last_recv_msg = NULL; cseq = base_cseq; nb_last_delay = 0; + tdm_map_number = 0; #ifdef _USE_OPENSSL m_ctx_ssl = NULL ; @@ -1715,41 +1770,23 @@ if(peer_tag && strlen(peer_tag)) { dest += sprintf(dest, ";tag=%s", peer_tag); } - } else if(strstr(keyword, "map")) { + } else if(strstr(keyword, "tdmmap")) { /* keyword to generate c= line for TDM * format: g.h.i/j * g: varies in interval a, offset x * h: fix value * i: varies in interval b, offset y * j: varies in interval c, offset z - * Format: map{1-3}{0}{0-27}{1-24} + * Format: tdmmap{1-3}{0}{0-27}{1-24} */ - int h=99; - int a=0; /* or 2-0 */ - int b=27-0; - int c=24-1; - int x=0; - int y=0; - int z=1; - int i1, i2, i3, i4, i5, i6, i7; - - if (sscanf(keyword, "map{%d-%d}{%d}{%d-%d}{%d-%d}", &i1, &i2, &i3, &i4, &i5, &i6, &i7) == 7) { - a = i2 - i1; - x = i1; - h = i3; - b = i5 - i4; - y = i4; - c = i7 - i6; - z = i6; - dest += sprintf(dest, "%d.%d.%d/%d", - x+(int((number-1)/((b+1)*(c+1))))%(a+1), - h, - y+(int((number-1)/(c+1)))%(b+1), - z+(number-1)%(c+1) + if (!use_tdmmap) + ERROR("[tdmmap] keyword without -tdmmap parameter on command line"); + dest += sprintf(dest, "%d.%d.%d/%d", + tdm_map_x+(int((tdm_map_number-1)/((tdm_map_b+1)*(tdm_map_c+1))))%(tdm_map_a+1), + tdm_map_h, + tdm_map_y+(int((tdm_map_number-1)/(tdm_map_c+1)))%(tdm_map_b+1), + tdm_map_z+(tdm_map_number-1)%(tdm_map_c+1) ); - } else { - ERROR_P1("Keyword '%s' cannot be parsed - must be of the form 'map{%%d-%%d}{%%d}{%%d-%%d}{%%d-%%d}'", keyword); - } } else if(strstr(keyword, "$")) { int varId = atoi(keyword+1); if(varId < SCEN_VARIABLE_SIZE) { Modified: sipp/trunk/call.hpp =================================================================== --- sipp/trunk/call.hpp 2006-08-16 08:10:26 UTC (rev 23) +++ sipp/trunk/call.hpp 2006-08-18 16:58:55 UTC (rev 24) @@ -54,6 +54,7 @@ public: char * id; unsigned int number; + unsigned int tdm_map_number; unsigned int msg_index; Modified: sipp/trunk/scenario.cpp =================================================================== --- sipp/trunk/scenario.cpp 2006-08-16 08:10:26 UTC (rev 23) +++ sipp/trunk/scenario.cpp 2006-08-18 16:58:55 UTC (rev 24) @@ -365,30 +365,30 @@ if(ptr = xp_get_value((char *)"milliseconds")) { scenario[scenario_len] -> pause = atol(ptr); scenario_duration += scenario[scenario_len] -> pause; - } else if(ptr = xp_get_value((char *)"min")) { + } else if(ptr = xp_get_value((char *)"min")) { scenario[scenario_len] -> pause_min = atol(ptr); - if(ptr = xp_get_value((char *)"max")) { + if(ptr = xp_get_value((char *)"max")) { scenario[scenario_len] -> pause_max = atol(ptr); - if (scenario[scenario_len] -> pause_max < scenario[scenario_len] -> pause_min) { + if (scenario[scenario_len] -> pause_max < scenario[scenario_len] -> pause_min) { ERROR("Min is greater than max in variable pause!"); - } - /* Update scenario duration with max duration */ + } + /* Update scenario duration with max duration */ scenario_duration += scenario[scenario_len] -> pause_max; - } else { + } else { ERROR("Min without max for a variable pause"); - } - } else if(ptr = xp_get_value((char *)"max")) { + } + } else if(ptr = xp_get_value((char *)"max")) { scenario[scenario_len] -> pause_max = atol(ptr); - /* Update scenario duration with max duration */ + /* Update scenario duration with max duration */ scenario_duration += scenario[scenario_len] -> pause_max; - if(ptr = xp_get_value((char *)"min")) { + if(ptr = xp_get_value((char *)"min")) { scenario[scenario_len] -> pause_min = atol(ptr); - if (scenario[scenario_len] -> pause_max < scenario[scenario_len] -> pause_min) { + if (scenario[scenario_len] -> pause_max < scenario[scenario_len] -> pause_min) { ERROR("Min is greater than max in variable pause!"); } - } else { + } else { ERROR("Max without min for a variable pause"); - } + } } else { scenario[scenario_len] -> pause = -1; scenario_duration += duration; @@ -489,7 +489,7 @@ scenario[scenario_len] -> test = -1; } } else { - scenario[scenario_len] -> next = 0; + scenario[scenario_len] -> next = 0; } scenario_len++; @@ -662,14 +662,14 @@ ->isRegExpWellFormed())) ERROR_P1("Regexp '%s' is not valid in xml " "scenario file", currentRegExp); - } else { + } else { ERROR("Too many call variables in the scenario. Please change '#define SCEN_VARIABLE_SIZE' in scenario.hpp and recompile SIPp"); - } + } if (currentNbVarId > 1 ) { sub_currentNbVarId = currentNbVarId - 1 ; - tmpAction.setNbSubVarId(sub_currentNbVarId); - + tmpAction.setNbSubVarId(sub_currentNbVarId); + for(int i=1; i<= sub_currentNbVarId; i++) { if(currentTabVarId[i] < SCEN_VARIABLE_SIZE) { tmpAction.setSubVarId(currentTabVarId[i]); Modified: sipp/trunk/sipp.cpp =================================================================== --- sipp/trunk/sipp.cpp 2006-08-16 08:10:26 UTC (rev 23) +++ sipp/trunk/sipp.cpp 2006-08-18 16:58:55 UTC (rev 24) @@ -838,17 +838,20 @@ switch(currentScreenToDisplay) { case DISPLAY_STAT_SCREEN : - fprintf(f,"----------------------------- Statistics Screen ------- [1-4]: Change Screen --" SIPP_ENDL); + fprintf(f,"----------------------------- Statistics Screen ------- [1-5]: Change Screen --" SIPP_ENDL); break; case DISPLAY_REPARTITION_SCREEN : - fprintf(f,"---------------------------- Repartition Screen ------- [1-4]: Change Screen --" SIPP_ENDL); + fprintf(f,"---------------------------- Repartition Screen ------- [1-5]: Change Screen --" SIPP_ENDL); break; case DISPLAY_VARIABLE_SCREEN : - fprintf(f,"----------------------------- Variables Screen -------- [1-4]: Change Screen --" SIPP_ENDL); + fprintf(f,"----------------------------- Variables Screen -------- [1-5]: Change Screen --" SIPP_ENDL); break; + case DISPLAY_TDM_MAP_SCREEN : + fprintf(f,"------------------------------ TDM map Screen --------- [1-5]: Change Screen --" SIPP_ENDL); + break; case DISPLAY_SCENARIO_SCREEN : default: - fprintf(f,"------------------------------ Scenario Screen -------- [1-4]: Change Screen --" SIPP_ENDL); + fprintf(f,"------------------------------ Scenario Screen -------- [1-5]: Change Screen --" SIPP_ENDL); break; } } @@ -863,6 +866,8 @@ 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) { @@ -890,12 +895,38 @@ 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)); + 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; + int i,j; bool found; printf("Action defined Per Message :" SIPP_ENDL); @@ -946,6 +977,7 @@ printf(SIPP_ENDL); printf("Setted Variable List:" SIPP_ENDL); found = false; + j=0; for(i=0; i<SCEN_VARIABLE_SIZE; i++) { for (int j=0;j<SCEN_MAX_MESSAGES;j++) { @@ -956,10 +988,14 @@ i, variable->getRegularExpression()); found = true; + j++; } } } if(!found) printf("=> No variable found for this scenario"SIPP_ENDL); + for(i=0; i<(scenario_len + 5 - j); i++) { + printf(SIPP_ENDL); + } } @@ -1011,6 +1047,9 @@ case DISPLAY_VARIABLE_SCREEN : print_variable_list(); break; + case DISPLAY_TDM_MAP_SCREEN : + print_tdm_map(); + break; case DISPLAY_SCENARIO_SCREEN : default: print_stats_in_file(stdout, last); @@ -1130,6 +1169,13 @@ print_statistics(0); break; + case '5': + if (use_tdmmap) { + currentScreenToDisplay = DISPLAY_TDM_MAP_SCREEN; + print_statistics(0); + } + break; + case '+': set_rate(rate + 1); print_statistics(0); @@ -1198,6 +1244,13 @@ print_statistics(0); break; + case '5': + if (use_tdmmap) { + currentScreenToDisplay = DISPLAY_TDM_MAP_SCREEN; + print_statistics(0); + } + break; + case '+': set_rate(rate + 1); print_statistics(0); @@ -2212,11 +2265,17 @@ #else call_ptr = add_call(call_id , ipv6); #endif - if((pollset_index) && - (pollfiles[pollset_index].fd != main_socket) && - (pollfiles[pollset_index].fd != tcp_multiplex) ) { - - call_ptr -> call_socket = pollfiles[pollset_index].fd; + if(!call_ptr) { + outbound_congestion = true; + CStat::instance()->computeStat(CStat::E_CALL_FAILED); + CStat::instance()->computeStat(CStat::E_FAILED_OUTBOUND_CONGESTION); + } else { + outbound_congestion = false; + if((pollset_index) && + (pollfiles[pollset_index].fd != main_socket) && + (pollfiles[pollset_index].fd != tcp_multiplex) ) { + call_ptr -> call_socket = pollfiles[pollset_index].fd; + } } } #ifdef __3PCC__ @@ -2226,13 +2285,19 @@ CStat::instance()->computeStat (CStat::E_CREATE_OUTGOING_CALL); call_ptr = add_call(call_id ,ipv6); - - if((pollset_index) && - (pollfiles[pollset_index].fd != main_socket) && - (pollfiles[pollset_index].fd != tcp_multiplex) && - (pollfiles[pollset_index].fd != localTwinSippSocket) && - (pollfiles[pollset_index].fd != twinSippSocket)) { - call_ptr -> call_socket = pollfiles[pollset_index].fd; + if(!call_ptr) { + outbound_congestion = true; + CStat::instance()->computeStat(CStat::E_CALL_FAILED); + CStat::instance()->computeStat(CStat::E_FAILED_OUTBOUND_CONGESTION); + } else { + outbound_congestion = false; + if((pollset_index) && + (pollfiles[pollset_index].fd != main_socket) && + (pollfiles[pollset_index].fd != tcp_multiplex) && + (pollfiles[pollset_index].fd != localTwinSippSocket) && + (pollfiles[pollset_index].fd != twinSippSocket)) { + call_ptr -> call_socket = pollfiles[pollset_index].fd; + } } } #endif @@ -2241,7 +2306,8 @@ nb_out_of_the_blue++; CStat::instance()->computeStat (CStat::E_OUT_OF_CALL_MSGS); - // This is a message that is not relating to any call + WARNING_P1("Discarding message which can't be mapped to a known SIPp call:\n%s", msg); + // This is a message that is not relating to any known call } } @@ -2362,7 +2428,14 @@ // adding a new OUTGOING CALL CStat::instance()->computeStat(CStat::E_CREATE_OUTGOING_CALL); call * call_ptr = add_call(ipv6); - call_ptr -> run(); + if(!call_ptr) { + outbound_congestion = true; + CStat::instance()->computeStat(CStat::E_CALL_FAILED); + CStat::instance()->computeStat(CStat::E_FAILED_OUTBOUND_CONGESTION); + } else { + outbound_congestion = false; + call_ptr -> run(); + } } if(open_calls >= open_calls_allowed) { @@ -2838,6 +2911,10 @@ "\n" " -aa : Enable the automatic answer for the INFO message.\n" "\n" + " -tdmmap map : 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}\n" + "\n" " -xyz string : Any other parameter used in SIP messages as [xyz].\n" "\n" "Signal handling:\n" @@ -3801,6 +3878,29 @@ bind_local = 1; } + if(!strcmp(argv[argi], "-tdmmap")) { + if((++argi) < argc) { + processed = 1; + int i1, i2, i3, i4, i5, i6, i7; + + if (sscanf(argv[argi], "{%d-%d}{%d}{%d-%d}{%d-%d}", &i1, &i2, &i3, &i4, &i5, &i6, &i7) == 7) { + use_tdmmap = true; + tdm_map_a = i2 - i1; + tdm_map_x = i1; + tdm_map_h = i3; + tdm_map_b = i5 - i4; + tdm_map_y = i4; + tdm_map_c = i7 - i6; + tdm_map_z = i6; + } else { + ERROR("Parameter -tdmmap must be of form {%%d-%%d}{%%d}{%%d-%%d}{%%d-%%d}"); + } + } else { + ERROR_P1("Missing argument for param '%s'.\n" + "Use 'sipp -h' for details", argv[argi-1]); + } + } + /* --------------------------------------------- */ /* !!! This must be the last parameter processed */ if(processed == 0 && *argv[argi] == '-') { Modified: sipp/trunk/sipp.hpp =================================================================== --- sipp/trunk/sipp.hpp 2006-08-16 08:10:26 UTC (rev 23) +++ sipp/trunk/sipp.hpp 2006-08-18 16:58:55 UTC (rev 24) @@ -90,7 +90,7 @@ /************************** Constants **************************/ -#define SIPP_VERSION 20060605 +#define SIPP_VERSION 20060818 #define T_UDP 0 #define T_TCP 1 #ifdef _USE_OPENSSL @@ -113,6 +113,7 @@ #define DISPLAY_REPARTITION_SCREEN 2 #define DISPLAY_SCENARIO_SCREEN 3 #define DISPLAY_VARIABLE_SCREEN 4 +#define DISPLAY_TDM_MAP_SCREEN 5 #define MAX_RECV_LOOPS_PER_CYCLE 1000 #define NB_UPDATE_PER_CYCLE 1 @@ -212,6 +213,17 @@ extern char * call_id_string _DEFVAL("%u-%p@%s"); extern char **generic[100]; +/* TDM map */ +extern bool use_tdmmap _DEFVAL(false); +extern unsigned int tdm_map_a _DEFVAL(0); +extern unsigned int tdm_map_b _DEFVAL(0); +extern unsigned int tdm_map_c _DEFVAL(0); +extern unsigned int tdm_map_x _DEFVAL(0); +extern unsigned int tdm_map_y _DEFVAL(0); +extern unsigned int tdm_map_z _DEFVAL(0); +extern unsigned int tdm_map_h _DEFVAL(0); +extern bool tdm_map[1024]; + #ifdef _USE_OPENSSL extern BIO *bio ; extern SSL *ssl_tcp_multiplex ; @@ -252,6 +264,7 @@ extern unsigned long nb_net_cong _DEFVAL(0); extern unsigned long nb_net_recv_errors _DEFVAL(0); extern bool cpu_max _DEFVAL(false); +extern bool outbound_congestion _DEFVAL(false); extern int open_calls_peak _DEFVAL(0); extern unsigned long open_calls_peak_time _DEFVAL(0); extern int open_calls_user_setting _DEFVAL(0); Modified: sipp/trunk/stat.cpp =================================================================== --- sipp/trunk/stat.cpp 2006-08-16 08:10:26 UTC (rev 23) +++ sipp/trunk/stat.cpp 2006-08-18 16:58:55 UTC (rev 24) @@ -590,6 +590,12 @@ M_counters [CPT_PL_FailedCallRegexpHdrNotFound]++; break; + case E_FAILED_OUTBOUND_CONGESTION : + M_counters [CPT_C_FailedOutboundCongestion]++; + M_counters [CPT_PD_FailedOutboundCongestion]++; + M_counters [CPT_PL_FailedOutboundCongestion]++; + break; + case E_OUT_OF_CALL_MSGS : M_counters [CPT_C_OutOfCallMsgs]++; M_counters [CPT_PD_OutOfCallMsgs]++; @@ -1123,6 +1129,8 @@ << "FailedRegexpDoesntMatch(C);" << "FailedRegexpHdrNotFound(P);" << "FailedRegexpHdrNotFound(C);" + << "FailedOutboundCongestion(P);" + << "FailedOutboundCongestion(C);" << "OutOfCallMsgs(P);" << "OutOfCallMsgs(C);" << "AutoAnswered(P);" @@ -1174,6 +1182,8 @@ << M_counters[CPT_C_FailedCallRegexpDoesntMatch] << ";" << M_counters[CPT_PL_FailedCallRegexpHdrNotFound] << ";" << M_counters[CPT_C_FailedCallRegexpHdrNotFound] << ";" + << M_counters[CPT_PL_FailedOutboundCongestion] << ";" + << M_counters[CPT_C_FailedOutboundCongestion] << ";" << M_counters[CPT_PL_OutOfCallMsgs] << ";" << M_counters[CPT_C_OutOfCallMsgs] << ";" << M_counters[CPT_PL_AutoAnswered] << ";" Modified: sipp/trunk/stat.hpp =================================================================== --- sipp/trunk/stat.hpp 2006-08-16 08:10:26 UTC (rev 23) +++ sipp/trunk/stat.hpp 2006-08-18 16:58:55 UTC (rev 24) @@ -94,6 +94,7 @@ E_FAILED_CMD_NOT_SENT, E_FAILED_REGEXP_DOESNT_MATCH, E_FAILED_REGEXP_HDR_NOT_FOUND, + E_FAILED_OUTBOUND_CONGESTION, E_OUT_OF_CALL_MSGS, E_AUTO_ANSWERED }; @@ -119,6 +120,7 @@ CPT_C_FailedCallCmdNotSent, CPT_C_FailedCallRegexpDoesntMatch, CPT_C_FailedCallRegexpHdrNotFound, + CPT_C_FailedOutboundCongestion, CPT_C_OutOfCallMsgs, CPT_C_AutoAnswered, @@ -138,6 +140,7 @@ CPT_PD_FailedCallCmdNotSent, CPT_PD_FailedCallRegexpDoesntMatch, CPT_PD_FailedCallRegexpHdrNotFound, + CPT_PD_FailedOutboundCongestion, CPT_PD_OutOfCallMsgs, CPT_PD_AutoAnswered, // must be last (RESET_PD_COUNTER) @@ -157,6 +160,7 @@ CPT_PL_FailedCallCmdNotSent, CPT_PL_FailedCallRegexpDoesntMatch, CPT_PL_FailedCallRegexpHdrNotFound, + CPT_PL_FailedOutboundCongestion, CPT_PL_OutOfCallMsgs, CPT_PL_AutoAnswered, // must be last (RESET_PL_COUNTER) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |