猿创征文|【FreeSwitch开发实践】使用sipp对FreeSwitch进行压力测试

✨ 博客主页:小小马车夫的主页
✨ 所属专栏:FreeSwitch开发实践
✨ 专栏介绍:主要介绍博主在实际项目中使用FreeSwitch开发外呼类项目的一些经验心得,主要涉及FreeSwitch的基本安装编译、基本配置、ESL、WSS、录音、自定义模块、media bug、语音播放、MRCP及对接AI机器人等内容。内容在持续更新中,如果感兴趣可以对专栏进行订阅~

请添加图片描述


前言

FreeSwitch作用外呼系统的底层服务器,其稳定性至关重要,因此有必要对FreeSwitch作一个压力测试。而在FreeSwitch压力测试方面,sipp是最好用的工具,也是FreeSwitch官方推荐的。本文对Sipp的编译安装、命令行参数及相关配置文件和对使用sipp对FreeSwitch压力测试作简要介绍,如想深入了解sipp工具可以参考:sipp官网


1、sipp编译安装

运行环境

Ubuntu 18.04.7 LTS 64位

  • 依赖安装
apt-getinstall libncurses-dev
apt-getinstall libssl-dev
apt-getinstall libpcap-dev
atp-get install openssl
apt-getinstall sip-tester
tar -xvf sipp.svn.tar.gz
cd sipp.svn
make pcapplay_oss

编译完成会生成sipp可执行文件,可运行一下,验证是否编译成功:
sipp

2、sipp命令参数

• -s:指定外呼号码
• -sf:指定场景脚本文件,可分为注册,UAC,UAS等
• -inf:指定注册用户信息,CSV配置文件,里面有用户的帐号,密码,端口等信息
• -i:Sipp所在主机地址
• -p:Sipp端口号
• -r:每秒发送多少Sip消息, 常与rp参数联合使用, -r 1 -rp 3000 代码每3秒发送1个外呼
• -trace_screen:当程序结束时候打印统计信息并弹出屏幕
• -m:共发送多少Sip消息
• -t:使用tcp的传输模式,公司内网udp有限制,tn代表每个呼叫占用一个socket

  • -rtp:启用 rtp 回送功能

3、sipp注册csv文件

user_data.csv

SEQUENTIAL
900000001;123;
900000002;123;
900000003;123;

说明:
900000001 为主叫用户
123 为被叫用户,也可以是FreeSwitch中配置的拨号计划名称, 这里使用的正是拨号计划

4、sipp 压力测试UAC脚本文件

uac_test.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="Basic Sipstone UAC">
  <send retrans="500">
    <![CDATA[
      INVITE sip:[field1]@[remote_ip]:[remote_port] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: [field0] <sip:[field0]@[remote_ip]:[remote_port]>;tag=[call_number]
      To: <sip:[field1]@[remote_ip]:5060>
      Call-ID: [call_id]
      CSeq: 1 INVITE
      Contact: sip:[field0]@[local_ip]:[local_port]
      Max-Forwards: 70
      Subject: FreeSwitch Performance Test
      Content-Type: application/sdp
      Content-Length: [len]

      v=0
      o=HuaweiFlexit1.0 20004 20004 IN IP4 10.130.30.7
      s=A call
      c=IN IP4 10.130.30.7
      t=1228447938 1228451538
      m=audio 10500 RTP/AVP 18 4 8 0 97
      a=rtpmap:18 G729/8000
      a=fmtp:18 annexb=no
      a=rtpmap:4 G723/8000
      a=rtpmap:8 PCMA/8000
      a=rtpmap:0 PCMU/8000
      a=rtpmap:97 telephone-event/8000
      a=fmtp:97 0-15
      a=sendrecv
      m=video 10510 RTP/AVP 34 98
      b=AS:376
      a=rtpmap:34 H263/90000
      a=fmtp:34 QCIF=1 CIF=4 MaxBR=3760
      a=rtpmap:98 MP4V-ES/90000
      a=fmtp:98 profile-level-id=2
      a=sendrecv
    ]]>
  </send>

  <recv response="100" >
  </recv>
  
  <recv response="180" optional="true">
  </recv>
  
  <recv response="183" optional="true">
  </recv>

  <recv response="200" >
  </recv>

   <send>
    <![CDATA[
      ACK sip:mod_sofia@[remote_ip]:[remote_port];transport=udp SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: [field0] <sip:[field0]@[remote_ip]:[remote_port]>;tag=[call_number]
      To: <sip:[field1]@[remote_ip]:[remote_port]>[peer_tag_param]
      Call-ID: [call_id]
      CSeq: 1 ACK
      Max-Forwards: 70
      Subject: Performance Test
      Content-Length: 0
    ]]>
  </send>
 
  <pause milliseconds="120000"/>
  
  <send retrans="500">
    <![CDATA[
      BYE sip:[field0]@[remote_ip]:[remote_port] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: [field0] <sip:[field0]@[remote_ip]:[remote_port]>;tag=[call_number]
      To: [field1] <sip:[field1]@[remote_ip]:[remote_port]>[peer_tag_param]
      Call-ID: [call_id]
      CSeq: 2 BYE
      Contact: sip:[field0]@[local_ip]:[local_port]
      Max-Forwards: 70
      Subject: Performance Test
      Content-Length: 0
    ]]>
  </send>
  <recv response="200" crlf="true">
  </recv>
  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
</scenario>

5、FreeSwitch相关配置

拨号计划
前面介绍用户csv文件时提到被叫为123, 这是FreeSwitch拨号计划,配置如下:

<extension name="sipp_test">
  <condition field="destination_number" expression="^123$">
    <action application="answer"/>
    <action application="sleep" data="1000"/>
    <action application="playback" data="/data/1.wav"/>
    <action application="sleep" data="1000"/>
    <action application="hangup"/>
  </condition>
</extension>

说明:
<action application="playback" data="/data/1.wav"/> 回放音频文件 /data/1.wav
当进行sipp压力测试,每一个呼叫通过上述拨号计划打进来, FreeSwitch会播放音频文件,持续时间为wav文件时长

FreeSwitch外呼数量限制修改
autoload_configs/switch.conf.xml

    <!--
        Max number of sessions to allow at any given time.
        
        NOTICE: If you're driving 28 T1's in a single box you should set this to 644*2 or 1288
        this will ensure you're able to use the entire DS3 without a problem.  Otherwise you'll
        be 144 channels short of always filling that DS3 up which can translate into waste.
    -->
    <param name="max-sessions" value="5000"/>
    <!--Most channels to create per second -->
    <param name="sessions-per-second" value="60"/>

其中max-sessions 为FreeSwitch配置的最大并发外呼数量,压测时可根据实际情况修改

6、sipp对FreeSwitch压力测试命令

./sipp 10.7.40.3:5060 -i 172.28.37.88 -p 2345 -m 1000 -r 20 -rp 1000 -l 1000 -t tn  -max_socket 5000  -sf uac_test.xml -inf user_data.csv -rtp_echo -trace_screen -trace_err

说明:
10.7.40.3:5060 是FreeSwitch服务器的IP和端口
-i 172.28.37.88 -p 2345 为sipp所在机器的IP和端口
-m 1000 总共呼叫任务数量,到达指定数量后结果压测任务
-r 20 -rp 1000 每1000毫秒20个外呼
-l 1000 最后维持1000个外呼并发, 到达1000后,不再起新的任务,当并发外呼数小于1000时,继续增加外呼任务
-t tn 每个外呼占用一个socket
-max_socket 5000 最大支持5000个外呼
-sf uac_test.xml 指定场景脚本,这里采用uac脚本, 参考:sipp uac脚本
-inf user_data.csv 用户csv文件, 这里测试1000个外呼,所以user_data.csv中可以构造1000行, 其中主叫用户号码递增即可
其他参数解释参考:sipp参数介绍

压测完成输出:

在这里插入图片描述

其中 Successful call为1000, Failed call为0, 说明1000呼任务全部成功。

FreeSwitch呼叫并发数和CPU占用率查看:
在FreeSwitch命令行中输出: show calls, 在另一个bash命令行中输入top

freeswitch

7、可能遇到的问题及解决办法

  • received 'SIP/2.0 407 Proxy Authentication Required
    此问题用户验证问题,由于use_data.csv中的主叫用户都没有注册,因此会报此错误,可以在FreeSwitch中将用户验证暂时关闭,等压测结束再开启。

修改 vars.xml

 <X-PRE-PROCESS cmd="set" data="internal_auth_calls=false"/>

最后

以上就是本次的内容,来总结一下吧:

  • sipp的安装和编译
  • sipp参数介绍
  • sipp 用户脚本介绍
  • sipp uac呼叫脚本介绍
  • FreeSwitch相关配置
  • sipp对FreeSwitch压力测试
  • 可能遇到的问题及解决办法

如果觉得有些帮助或觉得文章还不错,请关注一下博主,你的关注是我持续写作的动力。另外,如果有什么问题,可以在评论区留言,或者私信博主,博主看到后会第一时间进行回复。
【间歇性的努力和蒙混过日子,都是对之前努力的清零】
欢迎转载,转载请注明出处:https://blog.csdn.net/xxm524/article/details/126680594

  • 34
    点赞
  • 42
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 60
    评论
评论 60
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一马途追

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值