Documentation

Documentation.Tutorials-ConcurrentCallsLimitation History

Hide minor edits - Show changes to markup

August 17, 2015, at 06:40 PM by 78.96.148.62 -
Added lines 4-5:

This scripting is valid for OpenSIPS versions 1.8 up to 2.1 .

August 17, 2015, at 06:39 PM by 78.96.148.62 -
Changed line 1 from:
Documentation -> Tutorials -> Concurrent calls limitation
to:
Documentation -> Tutorials -> Concurrent calls limitation 1.8
Changed lines 6-8 from:

Using the new 'dialog' module released with the upcoming 1.5x branch, it is now possible to easily impose channel limits within existing routing configurations. The example included below is a sample route block that integrates outbound channel limits with call control prepaid account support. Note that the example requires an AVP variable 'channels' to be set as user preference and can be adapted for both outbound and inbound channel limits using the existing profile architecture of the dialog module.

to:

OpenSIPS server can implement concurrent calls limitation by using the call profiles support provided by the dialog module. The call profiles are a simple mechanism that allows to group certain calls and to count them. The grouping can be extended by using labels (values inside a group). This allows a better granularity when comes to counting calls.

Different keys can be used to group calls (like the incoming IP address, the caller user, the outbound GW, etc). Once we create a profile for such a group of call, when handling the call in the OpenSIPS script, we add the call to such a group, eventually with an extra label (where the label is the actual value of the incoming IP or of the caller or of the GW).

In the below example we create a generic route to implement the limitation of concurrent calls from the same caller. The Route takes two parameters, the caller SIP username and the value of the limit. This Route is to be used when calls are created (when initial INVITEs are handled) after the dialog was created in script.

Deleted lines 18-20:
  1. Example route block:
  2. this example should be called before the t_relay() function of an outbound invite
Changed lines 20-24 from:
  1. Request route 'callcontrol' with channel limit
to:
  1. This route is to be called for initial INVITEs, after
  2. the dialog was created
  3. Parameters:
  4. * the caller URI (string)
  5. * the limit (integer)
Changed lines 26-27 from:

route[39]

to:

route[do_limit]

Changed lines 28-94 from:
	## have we done our checking on this call?
	if(!isflagset(31))
	{
		# user has max channel limit set as preference
		if(is_avp_set("$avp(s:channels)/n") && avp_check("$avp(s:channels)", "gt/i:0"))
		{
			# get current calls for uuid
			get_profile_size("caller","$avp(s:caller_uuid)","$var(calls)");	

			# check within limit
			if($avp(s:channels) > $var(calls))
			{
				xlog("L_INFO", "Call control: user '$avp(s:caller_uuid)' currently has 
				   '$var(calls)' of '$avp(s:channels)' active calls before this one\n");
				$var(setprofile) = 1;
			}
			else
			{
				xlog("L_INFO", "Call control: user channel limit exceeded [$var(calls)/$avp(s:channels)]\n");
				send_reply("487", "Request Terminated: Channel limit exceeded\n");
				exit;
			}
		}
		else
		{
			$var(setprofile) = 0;
		}

		call_control();

       	 	switch ($retcode) 
		{
        		case 2:
            			# Call with no limit
        		case 1:
            			# Call with a limit under callcontrol management (either prepaid or postpaid)
            			break;
        		case -1:
            			# Not enough credit (prepaid call)
            			xlog("L_INFO", "Call control: not enough credit for prepaid call\n");
            			acc_rad_request("402");
            			sl_send_reply("402", "Not enough credit");
            			exit;
            			break;
        		case -2:
           			# Locked by call in progress (prepaid call)
             			xlog("L_INFO", "Call control: prepaid call locked by another call in progress\n");
             			acc_rad_request("403");
             			sl_send_reply("403", "Call locked by another call in progress");
             			exit;
             			break;
        		default:
            			# Internal error (message parsing, communication, ...)
            			xlog("L_INFO", "Call control: internal server error\n");
            			acc_rad_request("500");
            			sl_send_reply("500", "Internal server error");
            			exit;
        	}

		if($var(setprofile) > 0)
		{
			create_dialog();
			set_dlg_profile("caller","$avp(s:caller_uuid)");
		}

		## mark checking done
		setflag(31);
to:
	# first add to the profile, just to avoid "test and set" false results
	set_dlg_profile("caller","$param(1)");


	# do the actual test - see how many calls the user has so far
	get_profile_size("caller","$param(1)","$var(calls)");
	xlog("User $param(1) has $var(calls) ongoing calls so far, limit is $param(2)\n");

	# check within limit
	if( $var(calls)>$param(2) )
	{	
		xlog("do_limit: user $param(1) exceeded number of calls [$var(calls)/$param(2)]\n");
		send_reply("487", "Request Terminated: Channel limit exceeded\n");
		exit;
		# terminating this call will automatically remove the call from the profile
Added lines 44-45:
	# call was added to the profile without exceeding the limit, simply continue
Added lines 47-54:

.... .... route {

	.....
	# initial INVITES
	route(do_limit,$fu, 10);
	.....

}

Deleted lines 58-63:

(:nl:)>>messagehead<<

Ramesh?22 October 2012, 20:35

Prepaid cards do not build your credit and don't corvnet to regular credit cards. Prepaid cards are more like gift cards. You put money on the card and when it's used up, you have to add more.What you need is a secured card you pay a deposit which is held as collateral against the line of credit. You use the card and get a monthly statement and are required to make payments just like a regular credit card. If you use the card and pay in full every month, you should be able to corvnet it to a regular account in about a year.,

May 16, 2013, at 06:09 PM by 109.99.235.212 -
Changed line 1 from:
to:
Documentation -> Tutorials -> Concurrent calls limitation
Changed line 6 from:
Using the new 'dialog' module released with the upcoming 1.5x branch, it is now possible to easily impose channel limits within existing routing configurations. The example included below is a sample route block that integrates outbound channel limits with call control prepaid account support. Note that the example requires an AVP variable 'channels' to be set as user preference and can be adapted for both outbound and inbound channel limits using the existing profile architecture of the dialog module.
to:

Using the new 'dialog' module released with the upcoming 1.5x branch, it is now possible to easily impose channel limits within existing routing configurations. The example included below is a sample route block that integrates outbound channel limits with call control prepaid account support. Note that the example requires an AVP variable 'channels' to be set as user preference and can be adapted for both outbound and inbound channel limits using the existing profile architecture of the dialog module.

May 09, 2013, at 02:03 PM by 79.118.227.150 -
Added line 2:

Changed line 4 from:

to:
May 09, 2013, at 02:02 PM by 79.118.227.150 -
Changed line 1 from:

Resources -> Documentation -> Tutorials -> Concurrent calls limitation

to:
Changed line 103 from:

(:commentboxchrono:)

to:

(:commentboxchrono:)

April 24, 2013, at 06:47 PM by 213.233.101.41 -
Added lines 1-103:

Resources -> Documentation -> Tutorials -> Concurrent calls limitation

This page has been visited 5994 times.


Using the new 'dialog' module released with the upcoming 1.5x branch, it is now possible to easily impose channel limits within existing routing configurations. The example included below is a sample route block that integrates outbound channel limits with call control prepaid account support. Note that the example requires an AVP variable 'channels' to be set as user preference and can be adapted for both outbound and inbound channel limits using the existing profile architecture of the dialog module.
....
# define the profile
modparam("dialog", "profiles_with_value", "caller")
....

# Example route block:
#   this example should be called before the t_relay() function of an outbound invite
#
########################################################################
# Request route 'callcontrol' with channel limit
########################################################################

route[39]
{
	## have we done our checking on this call?
	if(!isflagset(31))
	{
		# user has max channel limit set as preference
		if(is_avp_set("$avp(s:channels)/n") && avp_check("$avp(s:channels)", "gt/i:0"))
		{
			# get current calls for uuid
			get_profile_size("caller","$avp(s:caller_uuid)","$var(calls)");	

			# check within limit
			if($avp(s:channels) > $var(calls))
			{
				xlog("L_INFO", "Call control: user '$avp(s:caller_uuid)' currently has 
				   '$var(calls)' of '$avp(s:channels)' active calls before this one\n");
				$var(setprofile) = 1;
			}
			else
			{
				xlog("L_INFO", "Call control: user channel limit exceeded [$var(calls)/$avp(s:channels)]\n");
				send_reply("487", "Request Terminated: Channel limit exceeded\n");
				exit;
			}
		}
		else
		{
			$var(setprofile) = 0;
		}

		call_control();

       	 	switch ($retcode) 
		{
        		case 2:
            			# Call with no limit
        		case 1:
            			# Call with a limit under callcontrol management (either prepaid or postpaid)
            			break;
        		case -1:
            			# Not enough credit (prepaid call)
            			xlog("L_INFO", "Call control: not enough credit for prepaid call\n");
            			acc_rad_request("402");
            			sl_send_reply("402", "Not enough credit");
            			exit;
            			break;
        		case -2:
           			# Locked by call in progress (prepaid call)
             			xlog("L_INFO", "Call control: prepaid call locked by another call in progress\n");
             			acc_rad_request("403");
             			sl_send_reply("403", "Call locked by another call in progress");
             			exit;
             			break;
        		default:
            			# Internal error (message parsing, communication, ...)
            			xlog("L_INFO", "Call control: internal server error\n");
            			acc_rad_request("500");
            			sl_send_reply("500", "Internal server error");
            			exit;
        	}

		if($var(setprofile) > 0)
		{
			create_dialog();
			set_dlg_profile("caller","$avp(s:caller_uuid)");
		}

		## mark checking done
		setflag(31);
	}
}

(:nl:)>>messagehead<<

Ramesh?22 October 2012, 20:35

Prepaid cards do not build your credit and don't corvnet to regular credit cards. Prepaid cards are more like gift cards. You put money on the card and when it's used up, you have to add more.What you need is a secured card you pay a deposit which is held as collateral against the line of credit. You use the card and get a monthly statement and are required to make payments just like a regular credit card. If you use the card and pay in full every month, you should be able to corvnet it to a regular account in about a year.,

(:commentboxchrono:)


Page last modified on August 17, 2015, at 06:40 PM