[Kamailio-Users] CDRTool and Prepaid

Raúl Alexis Betancor Santana rabs at dimension-virtual.com
Fri Sep 5 11:48:42 CEST 2008


El Friday 05 September 2008 10:00:04 Adrian Georgescu escribió:
> The problem with concurrent prepaid calls and single balance is that
> you have to correlate between the call control and rating angine
> somehow so that all calls terminate when balnce becomes zero. The
> problem is a bit complex:
>
> Example:
>
> Balance = 10.
> A call starts to destination XXX, for the sake of example max session
> time = 2 minutes
> After one minute, you start second call to destination YYY which has a
> different price and your balance is not anymore 10 but depends on the
> duration of the first call which is in progress.
>
> What is the maximum session time for it given that the first call is
> already in progress?
> What should happen with the first call?
>
> I am looking for suggestions on implementing a proper algorithm to
> deal with this situation in the rating engine. If you have any I would
> be glad to hear it.
>
> Adrian

Hi Adrian, A simple approach could be:

- New Call1 to Dest XXX
	- Get cost per sec to dest XXX
	- Get connection cost to dest XXX (if any)
	- Set customer.balance =- thisCallConnectionCost
	- Set global var customer.costPerSec to customercostPerSec =+ 
thisCallCostPerSec
	- Notify externalWatcher new customer.costPerSec

- BYE Call1 to Dest XXX
	- Get disconnection cost to dest XXX (if any)
	- Set customer.balance =- thisCallDisconnectionCost
	- Set global var customer.costPerSec to customercostPerSec =- 
thisCallCostPerSec
	- Notify externalWatchr new customer.costPerSec

Then on a separate  thread or proc or "something" ...
- Every timeslice
	- while activeCustomers.next()
		- activeCustomer.balance =- activeCustomer.costPerSec
		- If (activeCustomer.balance <= activeCustomer.lowBalanceAlarm) and 
!activeCustomer.allreadyNotified
			- Send lowBalance Notify to customer
		- If (activeCustomer.balance <= activeCustomer.minAllowedBalance)
			- while activeCustomer.activeCall.next()
				- activeCustomer.activeCall.finish()
			- activeCustomer.lockNewCalls()

I think it's a good approach

-- 
Raúl Alexis Betancor Santana
Dimensión Virtual S.L.




More information about the Users mailing list