Archives 2021

Load Balancing FusionPBX Outbound Gateways

In certain situations you want to load balance SIP traffic between multiple SIP endpoints. These SIP endpoints are typically a Session Border Controller (SBC) in your organization or an upstream SIP provider. In any case, you need some logic that will distribute the traffic between the SIP endpoints. In the FusionPBX world (which is based on FreeSWITCH) this module is called Distributor (mod_distributor). In this article we will explain how to configure it.

Assumptions

  • You have at least two gateways defined within FusionPBX, which represents the SIP endpoints that you want to distribute traffic between.

Configuration Steps

  1. Login to FusionPBX and make sure the mod_distributor module is enabled. You can do so by going under Advanced -> Modules. Distributor should be an option to choose from, but should be disabled.  It will need to be enabled. “Enabled” should read True on the distributor line once it’s enabled.
  2. Get Gateway ID’s – right click on the Gateway name and click “Copy Address”. Open up a text editor and paste the address. The Gateway ID is the string after “id=” in the URL. Do this for all of the gateways you want to distribute traffic too.
3. Changing the mod_distributor config xml:
  • SSH to your FusionPBX server, make your way into the /etc/freeswitch directory
  • Using your favorite editor, edit autoload_configs/distributor.conf.xml and add the following:
<list name="my_list_001" total-weight="2">
<node name="978fefdd-45cd-4457-8ecd-5d82eaea3b12" weight="1"/> <!-- my_gateway_001 - its just comment with actual GW name -->
<node name="1a8d448d-e06e-2dab-b6f9-4421a98e4d8e" weight="1"/> <!-- my_gateway_002 -->
</list>
4. Save and run the following commands from the FreeSWITCH cli
fs_cli > reloadxml
fs_cli > distributor_ctl reload
5. Updated your Outbound Routing setting. You have something like this now: But, you want to change the last line to something like this: The Distributor command above takes a string value that contains a list that was defined in distributor.conf.xml and returns a gateway based on the weight defined in the configuration. In this case, “my_list_001” is the list used. This module can be used for other use cases where you need to generate random/weighted values.

Using SIPp To Load Test With a Kamailio Proxy

SIPp is a free open source tool for generating SIP traffic usually for the purpose of load testing SIP components such as a PBX.  In this walkthrough we will detail two methods of running tests using built in settings, or alternatively a generated SIPp xml file. It includes basic user agent scenarios (UAC and UAS). Also, you can use these basic agent scenarios to build call flow scenarios that fit your use cases. The scenario files are basic files that allows you to subscribe simple to very complex call flows. We will touch on a couple scenarios with a focus on load testing a SIP element such as a PBX with a Kamailio Proxy in front of it. SIPp generates SIP traffic according to the scenario specified. You can control the number of calls that are started per second. We will focus on the use of the builtin UAC scenario. At starting time, you can control the rate by specifying parameters on the command line:
  • “-sn” to specify the built in call flow scenario
  • “-sf” to specify a custom scenario file
  • “-r” to specify the call rate in number of calls per seconds
  • “-rp” to specify the “rate period” in milliseconds for the call rate (default is 1000ms/1sec). This allows you to have n calls every m milliseconds (by using -r n -rp m).
In our example, we will run SIPp at 7 calls every 2 seconds (3.5 calls per second) to a SIP Server, without a proxy:
sipp -sn uac -r 7 -rp 2000 <ip of server>
In another example, we will run SIPp at 7 calls every 2 seconds using a SIP Proxy such as Kamailio and OpenSIPS friendly scenario file. If you need help building a scenario file please contact us and we can estimate the about of hours needs to build a scenario file to meet your requirements :
sipp -sf sipproxyfriendly.xml -r 7 -rp 2000 <ip of server>
You can pause the traffic by pressing the ‘p’ key. SIPp will stop placing new calls and wait until all current calls end. You can resume the traffic by pressing ‘p’. To quit SIPp, press the ‘q’ key. SIPp will stop placing new calls and wait until all current calls end. SIPp will then exit. You can also force SIPp to quit immediately by pressing the ‘Q’ key. Current calls will be terminated by sending a BYE or CANCEL message (depending if the calls have been established or not). The same behaviour is obtained by pressing ‘q’ twice.