From 184764ba242114d5b8b7f2a64f7d3bb11f7ce755 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Mon, 6 Oct 2014 00:44:57 -0400 Subject: [PATCH 1/2] Separate call rate increase to a dedicated task --- .gitignore | 1 + Makefile.am | 2 ++ include/ratetask.hpp | 50 ++++++++++++++++++++++++++++ include/sipp.hpp | 4 +++ src/ratetask.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++++ src/reporttask.cpp | 13 ++------ src/sipp.cpp | 7 ++-- 7 files changed, 142 insertions(+), 13 deletions(-) create mode 100644 include/ratetask.hpp create mode 100644 src/ratetask.cpp diff --git a/.gitignore b/.gitignore index 77ac289cc..c08be9f8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.o *~ +.*.sw* .deps/ Makefile Makefile.in diff --git a/Makefile.am b/Makefile.am index 999c837bc..63e3511ff 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,6 +52,7 @@ common_incl = include/comp.h \ include/message.hpp \ include/milenage.h \ include/call_generation_task.hpp \ + include/ratetask.hpp \ include/reporttask.hpp \ include/rijndael.h \ include/scenario.hpp \ @@ -83,6 +84,7 @@ common_SOURCES = src/actions.cpp \ src/message.cpp \ src/milenage.c \ src/call_generation_task.cpp \ + src/ratetask.cpp \ src/reporttask.cpp \ src/rijndael.c \ src/scenario.cpp \ diff --git a/include/ratetask.hpp b/include/ratetask.hpp new file mode 100644 index 000000000..5173d102b --- /dev/null +++ b/include/ratetask.hpp @@ -0,0 +1,50 @@ +/* + * 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 + * 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 + */ + +#ifndef RATETASK_HPP +#define RATETASK_HPP + +#include "task.hpp" + +class ratetask : public task +{ +public: + unsigned int wake(); + static void initialize(); + bool run(); + void dump(); +private: + static class ratetask *instance; +}; + +#endif diff --git a/include/sipp.hpp b/include/sipp.hpp index 03729c30c..0ec8a310c 100644 --- a/include/sipp.hpp +++ b/include/sipp.hpp @@ -82,6 +82,7 @@ #include "infile.hpp" #include "call_generation_task.hpp" #include "reporttask.hpp" +#include "ratetask.hpp" #include "watchdog.hpp" /* Open SSL stuff */ #ifdef _USE_OPENSSL @@ -162,6 +163,7 @@ cmd messages are received */ #define DEFAULT_SERVICE ((char *)"service") #define DEFAULT_AUTH_PASSWORD ((char *)"password") #define DEFAULT_REPORT_FREQ 1000 +#define DEFAULT_RATE_INCR_FREQ 60000 #define DEFAULT_REPORT_FREQ_DUMP_LOG 60000 #define DEFAULT_TIMER_RESOLUTION 1 #define DEFAULT_FREQ_DUMP_RTT 200 @@ -190,6 +192,7 @@ extern double rate _DEFVAL(DEFAULT_RATE); extern double rate_scale _DEFVAL(DEFAULT_RATE_SCALE); extern int rate_increase _DEFVAL(0); extern int rate_max _DEFVAL(0); +extern unsigned long rate_increase_freq _DEFVAL(DEFAULT_RATE_INCR_FREQ); extern bool rate_quit _DEFVAL(true); extern int users _DEFVAL(-1); extern int rate_period_ms _DEFVAL(DEFAULT_RATE_PERIOD_MS); @@ -391,6 +394,7 @@ extern int last_paused_calls _DEFVAL(0); extern unsigned int open_calls_allowed _DEFVAL(0); extern unsigned long last_report_time _DEFVAL(0); extern unsigned long last_dump_time _DEFVAL(0); +extern unsigned long last_rate_increase_time _DEFVAL(0); /********************** Clock variables ***********************/ diff --git a/src/ratetask.cpp b/src/ratetask.cpp new file mode 100644 index 000000000..f03de92c2 --- /dev/null +++ b/src/ratetask.cpp @@ -0,0 +1,78 @@ +/* + * 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 + * 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 + */ +#include "sipp.hpp" + +class ratetask *ratetask::instance = NULL; + +void ratetask::initialize() +{ + assert(instance == NULL); + if (rate_increase) { + instance = new ratetask(); + } +} + +void ratetask::dump() +{ + WARNING("Increasing call rate task."); +} + +bool ratetask::run() +{ + if (quitting >= 10) { + delete this; + return false; + } + + /* Statistics Logs. */ + if ((getmilliseconds() - last_rate_increase_time) >= rate_increase_freq) { + if (rate_increase) { + rate += rate_increase; + if (rate_max && (rate > rate_max)) { + rate = rate_max; + if (rate_quit) { + quitting += 10; + } + } + CallGenerationTask::set_rate(rate); + last_rate_increase_time = clock_tick; + } + } + setPaused(); + return true; +} + +unsigned int ratetask::wake() +{ + return last_rate_increase_time + rate_increase_freq; +} diff --git a/src/reporttask.cpp b/src/reporttask.cpp index 0bf8d9bfd..e23ccd67b 100644 --- a/src/reporttask.cpp +++ b/src/reporttask.cpp @@ -38,7 +38,7 @@ class screentask *screentask::instance = NULL; void stattask::initialize() { assert(instance == NULL); - if (dumpInFile || useCountf || useErrorCodesf || rate_increase) { + if (dumpInFile || useCountf || useErrorCodesf) { instance = new stattask(); } } @@ -109,16 +109,6 @@ bool stattask::run() { /* Statistics Logs. */ if((getmilliseconds() - last_dump_time) >= report_freq_dumpLog) { - if (rate_increase) { - rate += rate_increase; - if (rate_max && (rate > rate_max)) { - rate = rate_max; - if (rate_quit) { - quitting += 10; - } - } - CallGenerationTask::set_rate(rate); - } report(); } setPaused(); @@ -129,3 +119,4 @@ unsigned int stattask::wake() { return last_dump_time + report_freq_dumpLog; } + diff --git a/src/sipp.cpp b/src/sipp.cpp index e4787628f..0ea394faa 100644 --- a/src/sipp.cpp +++ b/src/sipp.cpp @@ -273,12 +273,13 @@ struct sipp_option options_table[] = { "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" + {"rate_increase", "Specify the rate increase every -rate_interval units (default is seconds). This allows you to increase the load for each independent logging period.\n" + "Example: -rate_increase 10 -rate_interval 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}, + {"rate_interval", "Set the interval by which the call rate is increased. Default is 60 and default unit is seconds.", SIPP_OPTION_TIME_SEC, &rate_increase_freq, 1}, {"no_rate_quit", "If -rate_increase is set, do not quit after the rate reaches -rate_max.", SIPP_OPTION_UNSETFLAG, &rate_quit, 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" @@ -1936,6 +1937,8 @@ int main(int argc, char *argv[]) stattask::initialize(); /* Create the screen update task. */ screentask::initialize(); + /* Create the rate increase task. */ + ratetask::initialize(); /* Create a watchdog task. */ if (watchdog_interval) { new watchdog(watchdog_interval, watchdog_reset, watchdog_major_threshold, watchdog_major_maxtriggers, watchdog_minor_threshold, watchdog_minor_maxtriggers); From 7badf8babcdf4caca51145d753d7870f20132854 Mon Sep 17 00:00:00 2001 From: Ben Langfeld Date: Mon, 16 Mar 2015 15:42:42 -0300 Subject: [PATCH 2/2] Default rate increase to -fd --- include/sipp.hpp | 2 +- src/sipp.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/sipp.hpp b/include/sipp.hpp index 0ec8a310c..52fd588bb 100644 --- a/include/sipp.hpp +++ b/include/sipp.hpp @@ -163,7 +163,7 @@ cmd messages are received */ #define DEFAULT_SERVICE ((char *)"service") #define DEFAULT_AUTH_PASSWORD ((char *)"password") #define DEFAULT_REPORT_FREQ 1000 -#define DEFAULT_RATE_INCR_FREQ 60000 +#define DEFAULT_RATE_INCR_FREQ 0 #define DEFAULT_REPORT_FREQ_DUMP_LOG 60000 #define DEFAULT_TIMER_RESOLUTION 1 #define DEFAULT_FREQ_DUMP_RTT 200 diff --git a/src/sipp.cpp b/src/sipp.cpp index 0ea394faa..132422709 100644 --- a/src/sipp.cpp +++ b/src/sipp.cpp @@ -279,7 +279,7 @@ struct sipp_option options_table[] = { {"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}, - {"rate_interval", "Set the interval by which the call rate is increased. Default is 60 and default unit is seconds.", SIPP_OPTION_TIME_SEC, &rate_increase_freq, 1}, + {"rate_interval", "Set the interval by which the call rate is increased. Defaults to the value of -fd.", SIPP_OPTION_TIME_SEC, &rate_increase_freq, 1}, {"no_rate_quit", "If -rate_increase is set, do not quit after the rate reaches -rate_max.", SIPP_OPTION_UNSETFLAG, &rate_quit, 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" @@ -1835,6 +1835,10 @@ int main(int argc, char *argv[]) report_freq_dumpRtt); } + if (rate_increase_freq == 0) { + rate_increase_freq = report_freq_dumpLog; + } + // Check the soft limit on the number of open files, // error out if this does not allow us to open the // required number of signalling channels, and warn