We are going to work on the billing side of the solution. The proxy is working fine, completing calls between users and gateways. However, we are not billing the calls. Billing is a two-step process. In the first place, you have to determine the duration of the call. This is done using RADIUS or MySQL. The next step is to determine the price of that single call. We will use CDRTool, an open-source tool to help us in this task.
The VoIP server uses the concept of AAA (Authentication, Authorization, and Accounting). Until now, we have used only MySQL to authenticate and to authorize users. We can use MySQL or RADIUs to store the accounting data. It is easier to work with a RADIUS server because it uses an account-start packet for each INVITE transaction and an account-stop packet for each BYE transaction, writing a single record with the duration of the call. When you use MySQL you have to manually correlate INVITE and BYE transactions.