SIPp怎么压测集群,社区的文章相对较少,比较sip的知识细分相对比较垂直,最近刚好在做这个,其实难度不大,关键是要了解sip有个松散路由和绝对路由,是要根据实际sip交互来动态处理的

流程SIPp=呼叫=>代理服务器=>转发=>到具体服务器=>自动接通播放wav

clusterCall脚本xml

脚本大概意思是:发起成功后执行5分钟后自己挂断

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<!-- 集群音频单呼 -->
<scenario name="cluster_audio_call">
  <send retrans="500">
    <![CDATA[

      INVITE sip:00001234@[remote_ip]:[remote_port] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: <sip:[field0]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
      To:  <sip:00001234@[remote_ip]:[remote_port]>
      Call-ID: [call_id]
      CSeq: 1 INVITE
      Contact: sip:[field0]@[local_ip]:[local_port]
      Max-Forwards: 70
      Subject: Performance Test
      Content-Type: application/sdp
      Content-Length: [len]

      v=0
      o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
      s=-
      c=IN IP[media_ip_type] [media_ip]
      t=0 0
      m=audio [media_port] RTP/AVP 0
      a=rtpmap:0 PCMU/8000

    ]]>
  </send>

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

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

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

  
  <recv response="200" rtd="true">
      <!-- 核心代码  -->  
      <action>
        <!-- 从Contact中拿到单台服务的具体地址,变量为8, 使用[$8]  -->  
	<ereg regexp="([0-9]{1,3}\.){3}[0-9]{1,3}:[0-9]{1,5}" search_in="hdr" header="Contact:" check_it="true" assign_to="8" />  
       <!-- 从Record-Route中拿到路由,后续拼接到ACK和BYE消息上面,变量为9, 使用[$9]  -->     
	<ereg regexp="(.*)" search_in="hdr" header="Record-Route:" check_it="true" assign_to="9" />  
      </action>  
   </recv>

  
  <send>     
   <!--   ACK sip:00001234@[$8];transport=tcp SIP/2.0: 使用变量8  --> 
   <!--  Route: [$9]: 使用变量9 --> 
    <![CDATA[
      ACK sip:00001234@[$8];transport=tcp SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: <sip:[field0]@[remote_ip]:[remote_port]>;tag=[pid]SIPpTag00[call_number]
      To: <sip:00001234@[remote_ip]:[remote_port]>[peer_tag_param]
      Call-ID: [call_id]
      CSeq: 1 ACK
      Contact: sip:[field0]@[local_ip]:[local_port]
      Max-Forwards: 70
      Subject: Performance Test
      Content-Length: 0
      Route: [$9]	
    ]]>
  </send>
    <!--   最好Freeswitch设置播放视频,SIPp回显,注释掉这段代码  --> 
<!--
  <nop>
    <action>
      <exec play_pcap_audio="/root/sip_test/pcap/g711a.pcap"/>
    </action>
  </nop>
--> 
  <pause milliseconds="60000"/>

  <send retrans="500">
   <!--   ACK sip:00001234@[$8];transport=tcp SIP/2.0: 使用变量8  --> 
   <!--  Route: [$9]: 使用变量9 --> 
    <![CDATA[
      BYE sip:00001234@[$8] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: <sip:[field0]@[remote_ip]:[remote_port]>;tag=[pid]SIPpTag00[call_number]
      To:  <sip:00001234@[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
      Route: [$9]
    ]]>
  </send>

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

  <!-- definition of the response time repartition table (unit is ms)   -->
  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>

  <!-- definition of the call length repartition table (unit is ms)     -->
  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>

</scenario>
账号csv
SEQUENTIAL
yyh0001;[authentication username=yyh0001 password=123456]
yyh0002;[authentication username=yyh0002 password=123456]
压测指令解析
# -t tn:  每个呼叫是一个tcp(建议开启,这样模拟起来相对真实)
# -rtp_echo:  启用 RTP 回显
# -r 20 -rp 1000: 每秒注册20个账号
# -m 5000: 注册到达5000后停止脚本
# -trace_msg: 开启后打印所有过程中的消息(如果有错误建议开启,只能看到交互的消息,无法看到rtp传输)
# -trace_screen: 结束后吧结果打印到屏幕上
# -trace_err: 开启后打印错误消息
# remote_ip: 被压测Fs地址
# remote_port: 被压测Fs端口
sipp [remote_ip]:[remote_port] -inf [csv] -sf [xml]  -m [Number] -r [Number] -rp [Number] -t tn -rtp_echo -trace_screen -trace_err
使用
# 使用account.csv,按照每秒20个并发发起呼叫,呼叫执行40次
sipp 102.95.28:5060 -inf account.csv -sf clusterCall.xml -m 40 -r 20 -rp 1000 -t tn -rtp_echo -trace_screen -trace_err
Logo

欢迎加入 MCP 技术社区!与志同道合者携手前行,一同解锁 MCP 技术的无限可能!

更多推荐