[Devel] rand function in config file
Daniel-Constantin Mierla
daniel at voice-system.ro
Fri Mar 30 17:22:42 CEST 2007
Hello Henning,
I would go for a generic named module (e.g., cfgutils or something else)
where to collect such small functions in the future. Considering that,
you can prepare such module with what you have implemented so far.
Because this 'random' is more like a value, I would say it is better to
have it as pseudo-variable instead of function (or both if considered
useful) -- it is easier to use it now with 1.2.0, and not complicated to
develop such functionality within a module (see tm/dlg for an example of
exporting pseudo-variables).
Cheers,
Daniel
On 03/30/07 18:08, Henning Westerholt wrote:
> On Thursday 22 March 2007 09:20, Henning Westerholt wrote:
>
>> On Wednesday 21 March 2007 17:26, you wrote:
>>
>>>> For the SER ratelimit module we have RED (random early detection).
>>>> In a nutshell it samples the number of messages and for the next
>>>> timeframe drops every n-th message in order to get the total number
>>>>
>>>>
>>>>> drop (causes retransmissions) or reject?
>>>>>
>>> It's up to the user to opt for drop or reject. Personally I had
>>> quite good results rejecting messages with a 500-class error
>>> including a Retry-After header.
>>> The Retry-After value should differ between replies though.
>>> That's where the randomize function comes into play.
>>>
>> Thanks all for your suggestions. I'll implement a simple module with some
>> randomize functions.
>>
>
> The module is finished now, and work rather good for the mentioned use case.
> This script snippet shows the usage:
>
> [...]
> if (get_random()) {
> get_random_val();
> $avp(i:10) = ($retcode / 16777216); # 2^24
> if ($avp(i:10) < 10) {
> $avp(i:10) = 10;
> }
> append_to_reply("Retry-After: $avp(i:10)\n");
> sl_send_reply("503", "Try later");
> };
> # normal message processing follows
> [...]
>
> Is there interest in such a module?
>
> Cheers,
>
> Henning
>
> _______________________________________________
> Devel mailing list
> Devel at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/devel
>
>
More information about the Devel
mailing list