当前位置: 代码网 > it编程>软件设计>软件测试 > 猿创征文|【FreeSwitch开发实践】使用sipp对FreeSwitch进行压力测试

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

2024年08月06日 软件测试 我要评论
FreeSwitch作用外呼系统的底层服务器,其稳定性至关重要,因此有必要对FreeSwitch作一个压力测试。而在FreeSwitch压力测试方面,sipp是最好用的工具,也是FreeSwitch官方推荐的。

请添加图片描述


前言

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


1、sipp编译安装

运行环境

  • 依赖安装
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;

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>

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"/>

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

压测完成输出:

在这里插入图片描述

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压力测试
  • 可能遇到的问题及解决办法
(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com