Brekeke SIP Server Wiki

Limit Concurrent Sessions through a specific route

From Brekeke SIP Server v3.1.x , with methods listed below used in a dial plan rule, the number of concurrent sessions under the same route name can be counted and limited.

The function counts the number of concurrent calls with Route Name which is defined with variable “$routename” in Deploy Patterns. The number of concurrent calls can be referred from Matching Patterns with “$route.concurrent” and “$route.underlimit”.

Methods in Matching Patterns

$route.concurrent – It returns the number of concurrent sessions associated with the route name.

Syntax:      $route.concurrent( <route_name> )
Returns:      The number of concurrent sessions associated with the routename.

$route.underlimit – It returns “true” if the number of concurrent sessions doesn’t reach the limit yet.

Syntax:      $route.underlimit( <route_name>, <max> )
Returns:      true | false

 

Methods in Deploy Patterns

$routename – define a route name to count concurrent session under this route name

Syntax:     $routename = <route_name>

 

Examples:

Ex1: Limit maximum 5 calls based on caller’s remote IP address.

--------------------------------------------
[Matching Patterns]
$request = ^INVITE
$addr = (.+)
$route.underlimit( "%1", "5" ) = true

[Deploy Patterns]
$routename = %1
$continue = true
--------------------------------------------

Ex2: Limit maximum 5 calls based on destination.

--------------------------------------------
[Matching Patterns]
$request = ^INVITE
To = sip:(.+)@
$route.underlimit( "gateway1", "5" ) = true

[Deploy Patterns]
To = sip:%1@172.16.1.101
$routename = gateway1
$continue = true
--------------------------------------------

Ex3: Limit maximum 10 concurrent calls based on registered calee’s IP address.

--------------------------------------------
[Matching Patterns]
$request = ^INVITE
$regaddr = (.+)
$route.underlimit( "%1", "10" ) = true

[Deploy Patterns]
$routename = %1
$continue = true
--------------------------------------------

Ex4: Limit maximum 5 calls based on caller’s username 

--------------------------------------------
[Matching Patterns]
$request = ^INVITE
From = sip:(.+)@
$route.underlimit( "%1", "5" ) = true

[Deploy Patterns]
$routename = %1
$continue = true
--------------------------------------------

Ex5: Limit maximum 5 calls based on callee’s username 

--------------------------------------------
[Matching Patterns]
$request = ^INVITE
To = sip:(.+)@
$route.underlimit( "%1", "5" ) = true

[Deploy Patterns]
$routename = %1
$continue = true
--------------------------------------------

Ex6: Limit maximum 5 calls based on username.

--------------------------------------------
[Matching Patterns]
$request = ^INVITE
From = sip:(.+)@
To = sip:(.+)@
$route.underlimit( "%1", "5" ) = true
$route.underlimit( "%2", "5" ) = true

[Deploy Patterns]
$routename = %1
$routename = %2
$continue = true
--------------------------------------------

Ex7: Limit maximum 5 calls with ITSP (in this case, Vonage.)

--------------------------------------------
[Matching Patterns]
$request = ^INVITE
From = vonage.net
$route.underlimit( "Vonage", "5" ) = true

[Deploy Patterns]
$routename = Vonage
$continue = true
--------------------------------------------
--------------------------------------------
[Matching Patterns]
$request = ^INVITE
To = vonage.net
$route.underlimit( "Vonage", "5" ) = true

[Deploy Patterns]
$routename = Vonage
$continue = true
--------------------------------------------


Ex8: Limit maximum 5 concurrent video calls

--------------------------------------------
[Matching Patterns]
$request = ^INVITE
$body( "(m=video)" ) = .+
$route.underlimit( "video", "5" ) = true

[Deploy Patterns]
$routename = video
$continue = true
--------------------------------------------
Yes No
Suggest Edit