概述

原本的计划是使用sipp完成带媒体压力测试,但是实际测试过程中发现sipp的媒体处理功能有问题(也有可能是我使用的姿势不对)。

sipp在带媒体的情况下(600路并发开始),出现大量的不响应和响应延迟,UAC和UAS都有该问题,猜测是sipp内部处理大量媒体的情况下,业务逻辑出现阻塞。

新的方案采用2台fs对接,增加的1台fs模拟UAC和UAS,使用python脚本发起呼叫并控制并发。

环境

centos7.9

freeswitch 1.10.7

python2.7.5

freeswitch压力测试服务器配置,cpu96线程核,内存32G。

freeswitch模拟服务器配置,cpu16线程核,内存32G。

对接方案

2台fs对接带媒体压测方案,见图。

 

 

 

fs配置

fs压力测试服务器,IP地址为192.168.1.2,开放3060和5066端口。

压测服务器的呼叫A路从3060端口进入,从5066端口呼出B路。拨号计划如下。

cat sbc-dp.xml

<include>

       <X-PRE-PROCESS cmd="set" data="callout_answer_timeout=60"/>

       <context name="out2in">

              <extension name="sbc-out2in" continue="true">

                     <condition field="${acl(${network_addr} 192.168.1.1/32)}" expression="true"/>

                     <condition field="destination_number" expression="^(\d+)$">

                            <action application="limit" data="hash cps all 500/1 !EXCHANGE_ROUTING_ERROR"/>

                            <action application="limit" data="hash capacity all 5000 !EXCHANGE_ROUTING_ERROR"/>

                            <action application="set" data="effective_caller_id_name=_undef_" />

                            <action application="set" data="effective_caller_id_number=${translate(${caller_id_number} GB-CALLER-IN)}" />

                            <action application="set" data="destination_number=${translate(${destination_number} GB-DEST-IN)}" />

                            <action application="set" data="inherit_codec=true"/>

                            <action application="export" data="absolute_codec_string=G729,PCMA" />

                            <action application="export" data="rtp_codec_negotiation=greedy" />

                            <action application="set" data="sip_copy_custom_headers=false"/>

                            <action application="export" data="passthrough180=true" />

                            <action application="export" data="ringback=${cn-ring}"/>

                            <action application="bridge" data="{sip_invite_call_id=${sip_call_id}

                                   }sofia/external5066/sip:${destination_number}@192.168.1.1:5080"/>

                     </condition>

              </extension>

       </context>

</include>

 

fs模拟服务器,IP地址为192.168.1.1,开放5080端口,呼入呼出都使用5080端口。

模拟UAS侧的呼叫处理,拨号计划如下。

cat test.xml

<include>

       <context name="public">

              <extension name="sbc-uas" continue="true">

                     <condition field="destination_number" expression="^(\d+)$">

                            <action application="set" data="inherit_codec=true"/>

                            <action application="export" data="absolute_codec_string=PCMA" />

                            <action application="export" data="rtp_codec_negotiation=greedy" />

                            <action application="pre_answer" />

                            <action application="sleep" data="500" />

                            <action application="answer" />

                            <action application="playback" data="/usr/local/freeswitch/sounds/ponce-preludio-in-e-major" />

                     </condition>

              </extension>

       </context>

</include>

其中的playback放音文件要准备多个格式的文件,防止UAS侧因为转码而消耗cpu。

ll /usr/local/freeswitch/sounds/

-rw-r--r--. 1 root root  140220 4月   6 11:20 ponce-preludio-in-e-major.G729

-rw-r--r--. 1 root root 1121760 4月   6 11:20 ponce-preludio-in-e-major.PCMA

-rw-r--r--. 1 root root 2243628 10月 12 14:09 ponce-preludio-in-e-major.wav

 

模拟UAC侧的呼叫发起由python脚本实现,见下一章。

python脚本

python脚本中使用fs的esl接口对接,通过循环调用fs的originate接口发起呼叫,通过参数方式设置cps、duration、capacity等信息,通过配置文件方式设置主被叫号码。

cat test-media.py

# coding=utf-8

#!/usr/bin/python2

 

#add by zr 20230404

#大并发场景下的语音媒体流压力测试

#根据配置的号码,批量并发拨测

 

import ESL

import time

import sys

 

#USAGE: python test-media.py cps duration calltotal

#PS: python test-media.py 10 30 100

 

cps = int(sys.argv[1])

duration = int(sys.argv[2])

calltotal = int(sys.argv[3])

callinterval = float(1)/cps

print('cps=%d, duration=%d, calltotal=%d, callinterval=%f' % (cps, duration, calltotal, callinterval))

 

con = ESL.ESLconnection('localhost', '8021', 'ClueCon')

 

if con.connected():

    pass

    # con.events('plain', 'CHANNEL_CREATE')

    #con.events('plain', 'CHANNEL_ANSWER')

    #con.events('plain', 'CHANNEL_HANGUP')

else:

    print("ESLconnection failed")

    exit()

 

fo = open('./test_multi.ini', 'r')

 

while calltotal > 0:

    line = fo.readline().strip()

 

    if not line:

        print('line is null')

        fo.seek(0)

        time.sleep(callinterval)

        continue

 

    if line.startswith('#'):

        print('line is ###')

        time.sleep(callinterval)

        continue

 

    calltotal = calltotal - 1

   

    caller, callee = line.split(' ')

    print('line=%s, %s' % (caller, callee))

 

    callstr =   ("originate {origination_caller_id_number=%s}"

                "[absolute_codec_string=^^:G729:PCMA]"

                "[execute_on_answer='sched_hangup +%d']sofia/external/%s@192.168.1.2:3060 "

                "&echo()"

                % (caller, duration, callee))

 

    print('callstr=%s' % (callstr))

    con.bgapi(callstr)

 

    time.sleep(callinterval)

 

fo.close()

 

con.disconnect()

 

配置文件如下。

cat test_multi.ini

#caller callee

10000 20000

10001 20001

10002 20002

测试

使用python脚本发起呼叫测试。

脚本参数含义为,每秒发起1通,接通后10秒挂断,总共发起2通呼叫。

python test-media.py 1 10 2

cps=1, duration=10, calltotal=2, callinterval=1.000000

line is ###

line=10000, 20000

callstr=originate {origination_caller_id_number=10000}[absolute_codec_string=^^:G729:PCMA][execute_on_answer='sched_hangup +10']sofia/external/20000@192.168.1.2:3060 &echo()

line=10001, 20001

callstr=originate {origination_caller_id_number=10001}[absolute_codec_string=^^:G729:PCMA][execute_on_answer='sched_hangup +10']sofia/external/20001@192.168.1.2:3060 &echo()

总结

通过修改UAC侧的python脚本中的“absolute_codec_string”变量,和UAS侧的dialplan中的“absolute_codec_string”变量,可以对不同的媒体流方式进行压力测试。

脚本命令使用“python test-media.py 44 50 44000”,即每秒发起44通呼叫,接通50秒后挂断,总共发起44000通呼叫。

SBC的AB路媒体为PCMA-PCMA,压测结果如下。

82sps,4100session,cpu4.5%,A路带宽占用162Mbps,B路带宽占用162Mbps。

SBC的AB路媒体为G729-G729,压测结果如下。

82sps,4100session,cpu5.5%,A路带宽占用59Mbps,B路带宽占用59Mbps。

SBC的AB路媒体为G729-PCMA,转码场景压测结果如下。

42sps,2096session,cpu37%,A路带宽占用31Mbps,B路带宽占用85Mbps。

62sps,3176session,cpu60%,A路带宽占用46Mbps,B路带宽占用129Mbps。

80sps,4000session,cpu86%,A路带宽占用58Mbps,B路带宽占用160Mbps。

 

空空如常

求真得真