%docentities; ]> &adminguide;
Overview This module implements traffic limiting for SIP requests. The module defines in an abstract mode the notion of 'pipe', which can be a link to an IP address, to a network or a trunk. The associtiation of traffic to a pipe is done in the config file, therefore, a pipe could represent SIP traffic coming from a user or the flow of specific SIP requests such as INVITE or REGISTER. Pipelimit started from ratelimit module, adding support for definition of pipes limits in database and dynamic names. Complexity of keeping everything in a module and make it dual mode functional resulted in a new module which is focused on just traffic shaping policies. For description of the algorithms see the README of ratelimit.
Dependencies
&kamailio; Modules The following modules must be loaded before this module: database connection module.
External Libraries or Applications The following libraries or applications must be installed before running &kamailio; with this module loaded: None.
Parameters
<varname>db_url</varname> (string) URL of the database server to be used. Default value is &defaultdb;. Set <varname>db_url</varname> parameter ... modparam("pipelimit", "db_url", "&exampledb;") ...
<varname>plp_table_name</varname> (string) Name of DB table where data definition for pipes is stores. Default value is pl_pipes. Set <varname>plp_table_name</varname> parameter ... modparam("pipelimit", "plp_table_name", "mypipes") ...
<varname>plp_pipeid_column</varname> (string) Name of 'pipeid' column. Default value is pipeid. Set <varname>plp_pipeid_column</varname> parameter ... modparam("pipelimit", "plp_pipeid_column", "name") ...
<varname>plp_limit_column</varname> (string) Name of 'limit' column. Default value is limit. Set <varname>plp_limit_column</varname> parameter ... modparam("pipelimit", "plp_limit_column", "name") ...
<varname>plp_algorithm_column</varname> (string) Name of 'algorithm' column. Default value is algorithm. Set <varname>plp_algorithm_column</varname> parameter ... modparam("pipelimit", "plp_algorithm_column", "name") ...
<varname>timer_interval</varname> (integer) The initial length of a timer interval in seconds. All amounts of messages have to be divided by this timer to get a messages per second value. IMPORTANT: A too small value may lead to performance penalties due to timer process overloading. Default value is 10. Set <varname>timer_interval</varname> parameter ... modparam("ratelimit", "timer_interval", 5) ...
<varname>reply_code</varname> (integer) The code of the reply sent by &kamailio; while limiting. Default value is 503. Set <varname>reply_code</varname> parameter ... modparam("ratelimit", "reply_code", 505) ... This value can be modified at runtime using sercmd Set <varname>reply_code</varname> parameter at runtime sercmd cfg.set_now_int ratelimit reply_code 505
<varname>reply_reason</varname> (string) The reason of the reply sent by &kamailio; while limiting. Default value is "Server Unavailable". Set <varname>reply_reason</varname> parameter ... modparam("ratelimit", "reply_reason", "Limiting") ... This value can be modified at runtime using sercmd Set <varname>reply_reason</varname> parameter at runtime sercmd cfg.set_now_string ratelimit reply_reason "Limiting"
Functions
<function moreinfo="none">pl_check(name)</function> Check the current request against the 'name' pipe. The pipe name can be provided via a pseudo variabile. The method will return an error code if the limit for the matched algorithm is reached. Meaning of the parameters is as follows: name - the pseudovariable holding the pipe name. This function can be used from REQUEST_ROUTE. <function>rl_check</function> usage ... # perform pipe match for current method if (!pl_check("one")) { pl_drop(); exit; } ... # use pipe 'one' for the current method via PV $var(p) = "one"; if (!pl_check("$var(p)")) { pl_drop(); exit; } ...
<function moreinfo="none">pl_drop([ [min ], max ])</function> For the current request, a "503 - Server Unavailable" reply is sent back. The reply may or may not have a "Retry-After" header. If no parameter is given, there will be no "Retry-After" header. If only the max parameter is given, the reply will contain a "Retry-After: max" header. If both min and max params are given, the reply will contain a "Retry-After: random" header with random being a random value between the given min and max. Meaning of the parameters is as follows: min - the minimum value of "Retry-After" header. max - the maximum value of "Retry-After" header. This function can be used from REQUEST_ROUTE. <function>pl_drop</function> usage ... if (!pl_check("one")) { # send back a "503 - Server Unavailable" # with a "Retry-After: 5" pl_drop("5"); exit; } ...
MI Commands
<function moreinfo="none">pl_stats</function> Lists the parameters and variabiles in the pipelimit module. Name: pl_stats Parameters: none MI FIFO Command Format: :pl_stats:_reply_fifo_file_ _empty_line_
<function moreinfo="none">pl_set_pipe</function> Sets the pipe parameters for the given pipe id. Name: pl_set_pipe Parameters: pipe_id - pipe id. pipe_algorithm - the algorithm assigned to the given pipe id. pipe_limit - the limit assigned to the given pipe id. MI FIFO Command Format: :pl_set_pipe:_reply_fifo_file_ 2 RED 10 _empty_line_
<function moreinfo="none">pl_get_pipes</function> Gets the list of in use pipes. Name: pl_get_pipes Parameters: none MI FIFO Command Format: :pl_get_pipes:_reply_fifo_file_ _empty_line_
<function moreinfo="none">pl_set_pid</function> Sets the PID Controller parameters for the Feedback Algorithm. Name: pl_set_pid Parameters: ki - the integral parameter. kp - the proportional parameter. kd - the derivative parameter. MI FIFO Command Format: :pl_set_pid:_reply_fifo_file_ 0.5 0.5 0.5 _empty_line_
<function moreinfo="none">pl_get_pid</function> Gets the list of in use PID Controller parameters. Name: pl_get_pid Parameters: none MI FIFO Command Format: :pl_get_pid:_reply_fifo_file_ _empty_line_
<function moreinfo="none">pl_push_load</function> Force the value of the load parameter. This command is useful for testing the Feedback algorithm. Name: pl_push_load Parameters: load - the forced value of load (it must be greater then 0.0 and smaller then 1.0). MI FIFO Command Format: :pl_push_load:_reply_fifo_file_ 0.85 _empty_line_