Introduction

This manual is a step by step instruction on configuring one of the ways to integrate SKAT with billing in order to support an interaction with subscribers billing plans.
Note: the manual is suitable for version 2.1 "Polar Bear" and higher.

Subscriber's bandwidth control according to the billing plan

We use an option Channel sharing between subscribers to set the subscriber's bandwidth according to his billing plan.

1. We create the file with protocols' groups description that we intend to exclude from the common traffic and their assigned priorities /etc/dpi/protocols.dscp

First, we make a file protocols.txt

http cs0
https cs0
dns cs0
default cs1

Here cs0 - corresponds to priority 0 and class 0 respectively
cs1 - to priority 1, class1
The classes defined in this way can be used in billing plans descriptions. They allow to set up individual limitations for them. Additionally, the prioritization of protocols within a bandwidth will be arranged according to these classes.

Second, convert it to dscp format that DPI can read:

cat protocols.txt|lst2dscp /etc/dpi/protocols.dscp

2. We create a configuration file that describes subscriber's parameters for DPI for each of the billing plans. It is convenient to use the same name for the billing plan in billing and for DPI configuration file that defines settings for this plan.

For example: settings for billing plan 10 Mb. The billing name is "rate_10M".

First, we create a file rate_10M.cfg:

htb_inbound_root=rate 10mbit
htb_inbound_class0=rate 1mbit ceil 10mbit
htb_inbound_class1=rate 1mbit ceil 10mbit
htb_inbound_class2=rate 8bit ceil 10mbit
htb_inbound_class3=rate 8bit ceil 10mbit
htb_inbound_class4=rate 8bit ceil 10mbit
htb_inbound_class5=rate 8bit ceil 10mbit
htb_inbound_class6=rate 8bit ceil 10mbit
htb_inbound_class7=rate 8bit ceil 10mbit
htb_root=rate 10mbit
htb_class0=rate 1mbit ceil 10mbit
htb_class1=rate 1mbit ceil 10mbit
htb_class2=rate 8bit ceil 10mbit
htb_class3=rate 8bit ceil 10mbit
htb_class4=rate 8bit ceil 10mbit
htb_class5=rate 8bit ceil 10mbit
htb_class6=rate 8bit ceil 10mbit
htb_class7=rate 8bit ceil 10mbit

Notes:

htb_class2-7 - are not used as they are not defined. The upper limit is indicated for a future just in case they would be defined;

8 bit - is the minimal bandwidth. 0 is prohibited to use here, this value is reserved.

3. We connect subscribers' database UDR in order to preserve our settings (to be made later) on DPI reboot.

udr=1

and restart DPI.

4. Now we integrate DPI with billing:

The integration method depends on billing's ability to control equipment by events or not.

4а. Billing can control equipment by events: creation of a new subscriber, billing plan change, blocking.

In this case: we select the equipment controlled by SSH/RSH1) The additional SW compatible with OS Linux can be installed on DPI. It allows to expand remote control capabilities: for example telnet server. or by execution of local scripts. Then we add the commands to attach or change a billing plan into configurations of the respective commands or scripts:

fdpi_ctrl load --policing ${rateplan}.cfg --ip ${ip_address}
или
fdpi_ctrl load --policing ${rateplan}.cfg --login ${login}

Here ${rateplan} - is the variable: billing assigns it the subscriber's billing plan name: rate_10M
${ip_address} - billing assigns here IP address 192.168.0.1 of the subscriber (for subscribers with a fixed IP)
${login} - billing assigns here login name of the subscriber dom1kv2 (for subscribers with dynamic IP, multiple IPs or in case we control by login)

4б. Billing can not control equipment by events.

We configure a scheduled output of data from billing by crontab. The list of subscribers with respective billing plan is saved to files named as billing_plan_name.lst. This list may contain IP or login. Then we start loading of these data into DPI.

fdpi_ctrl load --policing rate_10M.cfg --file rate_10M.lst
fdpi_ctrl load --policing rate_20M.cfg --file rate_20M.lst
...
or (for all at once)
for rateplan in *.cfg; do fdpi_ctrl load --policing "$rateplan" --file "${rateplan%%.*}".lst; done

Subscriber's blocking by negative balance of his account and his placing into Captive Portal is arranged similarly. The Captive Portal allows to charge the subscriber's account.

5. We create a description of the billing plan blocked.cfg for restricted or blocked subscribers. Only cs0 traffic is allowed (check the list in paragraph 1):

htb_inbound_root=rate 10mbit
htb_inbound_class0=rate 10mbit ceil 10mbit
htb_inbound_class1=rate 8bit ceil 8bit
htb_inbound_class2=rate 8bit ceil 8bit
htb_inbound_class3=rate 8bit ceil 8bit
htb_inbound_class4=rate 8bit ceil 8bit
htb_inbound_class5=rate 8bit ceil 8bit
htb_inbound_class6=rate 8bit ceil 8bit
htb_inbound_class7=rate 8bit ceil 8bit
htb_root=rate 10mbit
htb_class0=rate 10mbit ceil 10mbit
htb_class1=rate 8bit ceil 8bit
htb_class2=rate 8bit ceil 8bit
htb_class3=rate 8bit ceil 8bit
htb_class4=rate 8bit ceil 8bit
htb_class5=rate 8bit ceil 8bit
htb_class6=rate 8bit ceil 8bit
htb_class7=rate 8bit ceil 8bit

6. Next, we create a list of sites that are available in Captive Portal mode. We can skip this step in case only the own portal pages are available. Please find more details in description of "White list" option.

7. We indicate the name or the address of the Captive Portal in configuration file /etc/dpi/fastdpi.cfg

cp_server=192.168.0.1

Next, we restart DPI: service fastdpi restart

8. To place a subscriber into Captive Portal2) In case the events based control is not supported: we save lists of blocked and unblocked subscribers into files blocked.lst and unblocked.lst

fdpi_ctrl load --policing blocked.cfg --ip ${ip_address}
fdpi_ctrl load --service 5 --ip ${ip_address}

9. Here we disactivate Captive Portal and restore his billing plan after receiving his payment:

fdpi_ctrl load --policing ${rateplan}.cfg --ip ${ip_address}
fdpi_ctrl del --service 5 --ip ${ip_address}