在使用sipp脚本对sipserver和AS进行相关业务测试时,转接业务是较为复杂的业务流程类型,尤其是其中UE2涉及到两方呼叫流程的交互作用,对于构造sipp脚本而言更加繁琐。如下是我在日常工作中调试通过的sipp脚本内容,能够较好地模拟出盲转业务流程,可供大家参考。脚本未经过梳理,里面存在较多调试过程所涉及到的变量,请注意。
1.盲转业务流程图
图片描述

2.UE1的脚本内容:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<!--基本呼叫场景开始-ims作为主叫侧入局呼叫-->
<scenario name="caller_outside_tran_ue1">

<!--发送INVITE消息,设定重传定时器为500ms,同时启动定时器invite-->
    <send retrans="500" start_rtd="invite">
    <![CDATA[
      INVITE sip:[field3]@[remote_ip] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: "[field2]" <sip:[field2]@[local_ip]>;tag=[call_number]zhg8
      To: "[field3]"<sip:[field3]@[local_ip]>
      Call-ID: [call_id]
      CSeq: 1 INVITE
      Contact: <sip:[field2]@[local_ip]:[local_port]>
      User-Agent: SIPp client mode version [sipp_version]
      Allow: INVITE,PRACK,ACK,UPDATE,CANCEL,BYE,OPTIONS,INFO,SUBSCRIBE,REFER,NOTIFY
      Max-Forwards: 70
      Content-Type: application/sdp
      Content-Length: [len]

      v=0
      o=SIPp [pid][call_number] 8[pid][call_number]8 IN IP[local_ip_type] [local_ip]
      s=SIPp Normal Call Test
      t=0 0
      m=audio [media_port] RTP/AVP 0 101
      c=IN IP[media_ip_type] [media_ip]
      a=rtpmap:0 PCMU/8000
      a=rtpmap:101 telephone-event/8000
      a=sendrecv
    ]]>
     </send>

  <recv response="100" optional="true" rtd="invite">
  </recv>
    
  <recv response="183" optional="true" rtd="invite" next="normal">
  </recv>
  
  <recv hide="true" response="403" optional="true" rtd="invite" next="abortcall">
  </recv>  

  <recv hide="true" response="480" optional="true" rtd="invite" next="abortcall">
  </recv>

  <recv hide="true" response="486" optional="true" rtd="invite" next="abortcall">
  </recv>

  <recv hide="true" response="500" optional="true" rtd="invite" next="abortcall">
  </recv>

  <recv  hide="true" response="503" optional="true" rtd="invite" next="abortcall">
  </recv>

  <recv response="180"  optional="true" rtd="invite" next="normal">
  </recv>
   
  <label id="normal"/>
  <recv response="200" rtd="invite">
  </recv>
  
  <send>
    <![CDATA[
      ACK sip:[field3]@[remote_ip]:[remote_port] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: "[field2]" <sip:[field2]@[local_ip]>;tag=[call_number]zhg8
      To: "[field3]"<sip:[field3]@[local_ip]>[peer_tag_param]
      Call-ID: [call_id]
      CSeq: 1 ACK
      Contact: <sip:[field2]@[local_ip]:[local_port]>
      Max-Forwards: 70
      Subject: normal call scenario by wangwei
      user-agent: SIPp client mode version [sipp_version]
      Content-Length: 0

    ]]>
  </send>
  
    <recv request="INVITE"  >
  </recv>
  
    <send start_rtd="re-invite">
    <![CDATA[
            SIP/2.0 200 OK
            [last_From: ]
            [last_Via:]
            [last_From:]
            [last_To:]
            [last_Call-ID:]
            [last_CSeq:]
            Content-Length: 0
            Supported: 100rel,replaces,timer
            Contact: <sip:[field2]@[local_ip]:[local_port]>
            Allow:REGISTER,INVITE,ACK,PRACK,CANCEL,OPTIONS,BYE,INFO,UPDATE,REFER,NOTIFY,MESSAGE
            Content-Type: application/sdp
            Content-Length: [len]
            
            v=0
      o=SIPp [pid][call_number] 8[pid][call_number]8 IN IP[local_ip_type] [local_ip]
      s=SIPp Normal Call Test
      t=0 0
      m=audio [media_port] RTP/AVP 0
      c=IN IP[media_ip_type] [media_ip]
      a=rtpmap:0 PCMU/8000
      a=ptime:20

    ]]>
  </send>
  
     <recv request="ACK"  rtd="re-invite">
  </recv>
  
      <recv request="INVITE"  >
  </recv>
  
    <send start_rtd="re-invite">
    <![CDATA[
            SIP/2.0 200 OK
            [last_From: ]
            [last_Via:]
            [last_From:]
            [last_To:]
            [last_Call-ID:]
            [last_CSeq:]
            Content-Length: 0
            Supported: 100rel,replaces,timer
            Contact: <sip:[field2]@[local_ip]:[local_port]>
            Allow:REGISTER,INVITE,ACK,PRACK,CANCEL,OPTIONS,BYE,INFO,UPDATE,REFER,NOTIFY,MESSAGE
            Content-Type: application/sdp
            Content-Length: [len]
            
            v=0
o=SIPp [pid][call_number] 8[pid][call_number]8 IN IP[local_ip_type] [local_ip]
            s=SIPp Normal Call Test
            t=0 0
            m=audio [media_port] RTP/AVP 0
            c=IN IP[media_ip_type] [media_ip]
            a=rtpmap:0 PCMU/8000
            a=ptime:20

    ]]>
  </send>
  
     <recv request="ACK"  rtd="re-invite">
  </recv>
  
 <nop hide="true">
    <action>
     <exec rtp_stream="pcap/g711u.pcap,-1,0" />
    </action>
  </nop>
       <pause milliseconds="20000"/>
           
  <send start_rtd="bye">
    <![CDATA[
      BYE sip:[field3]@[remote_ip]:[remote_port] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: "[field2]" <sip:[field2]@[local_ip]>;tag=[call_number]zhg8
      To: "[field3]"<sip:[field3]@[remote_ip]>[peer_tag_param]
      Call-ID: [call_id]
      CSeq: 2 BYE
      Max-Forwards: 70
      Subject: normal call scenario by wangwei
      Content-Length: 0
    ]]>
  </send>

  <recv response="200" rtd="bye" next="END">
  </recv>

<!--异常结束-->
  <label id="abortcall"/>

  
<!--正常结束-->      
  <label id="END"/>

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

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

</scenario>

3.UE2的脚本内容:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<!--脚本编写时间:2015-11-11 17:15 作者:王伟-->
<!--编辑确认时间:2015-11-12 12:20 by:王伟-->
<scenario name="callee_inner_tran_ue2">
    
    <recv request="INVITE">
        <action>
            <ereg regexp="<sip:(.*)@(.*);.*>;(.*)"
              search_in="hdr"
              header="From: "
              check_it="true"
              assign_to="junk,ue1,ue1_ip,ue1_tag" />
            <ereg regexp="<sip:(.*)@.*"
              search_in="hdr"
              header="To: "
              check_it="true"
              assign_to="junk,callee" />
        </action>
        
    </recv>
    
         <pause hide="true" milliseconds="100"/>  
    
    <label id="100"/>
    <send>
        <![CDATA[
            SIP/2.0 100 Trying
            [last_Via:]
            [last_From:]
            [last_To:]
            [last_Call-ID:]
            [last_CSeq:]
            Contact: <sip:[local_ip]:[local_port];transport=[transport]>
            Content-Length: 0
            
        ]]>
    </send>

         <pause hide="true" milliseconds="100"/>  
    <send>
        <![CDATA[
            SIP/2.0 180 Ringing
            [last_Via:]
            [last_From:]
            [last_To:];tag=[call_number]
            [last_Call-ID:]
            [last_CSeq:]
            Contact: <sip:[local_ip]:[local_port];transport=[transport]>
            Content-Length: 0
            
        ]]>
    </send>

<send retrans="500" start_rtd="ack">
    <![CDATA[
            SIP/2.0 200 OK 
            [last_Via:]
            [last_From:]
            [last_To:];tag=[call_number]zhg8
            [last_Call-ID:]
            [last_CSeq:]
            Contact:<sip:[local_ip]:[local_port];transport=[transport]>
            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 8
            a=rtpmap:8 PCMA/8000
            a=ptime: 20
        ]]>
    </send>
    
    <recv request="ACK" rtd="ack" />

    <send retrans="500" start_rtd="invite">
    <![CDATA[

      INVITE sip:[$ue1]@[$ue1_ip] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: <sip:[$callee]@172.31.234.96:5060;user=phone>;tag=[call_number]zhg8
      To: <sip:[$ue1]@[$ue1_ip];user=phone>;[$ue1_tag]
      Call-ID: [call_id]
      CSeq: 1 INVITE
      Contact: <sip:[$callee]@[local_ip]:[local_port]>
      User-Agent: SIPp client mode version [sipp_version]
            Allow: INVITE,PRACK,ACK,UPDATE,CANCEL,BYE,OPTIONS,INFO,SUBSCRIBE,REFER,NOTIFY
      Max-Forwards: 70
      Content-Type: application/sdp
      Content-Length: [len]

      v=0
      o=SIPp [pid][call_number] 8[pid][call_number]8 IN IP[local_ip_type] [local_ip]
      s=SIPp Normal Call Test
      t=0 0
      m=audio [media_port] RTP/AVP 8
      c=IN IP[media_ip_type] [media_ip]
            a=rtpmap:8 PCMA/8000
            a=ptime:20
            a=sendonly
    ]]>
     </send>

  <recv response="200" rtd="invite">
  </recv>
  
    <send>
    <![CDATA[
      ACK sip:[$ue1]@[$ue1_ip] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      [last_From:]
      [last_To:]
            [last_Call-ID:]
      CSeq: 1 ACK
      Contact: <sip:[$ue1]@[local_ip]:[local_port]>
      Max-Forwards: 70
      Subject: normal call scenario by wangwei
      user-agent: SIPp client mode version [sipp_version]
      Content-Length: 0

    ]]>
  </send>

    <send start_rtd="refer">
    <![CDATA[
      REFER sip:[$ue1]@[$ue1_ip] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      [last_From:]
      [last_To:]
            [last_Call-ID:]
      CSeq: 2 REFER
      Contact: <sip:[$callee]@[local_ip]:[local_port]>
      Refer-To: <sip:[field1]@[$ue1_ip];user=phone;method=INVITE>
            Referred-By: <sip:[$callee]@172.31.232.220:5060>
      Max-Forwards: 70
      Subject: normal call scenario by wangwei
      Content-Length: 0

    ]]>
  </send>

  <recv response="202" rtd="refer">
  </recv>
  
    <recv request="NOTIFY">
        <action>
            <ereg regexp="(.*)"
              search_in="hdr"
              header="From: "
              check_it="true"
              assign_to="header_from" />
            <ereg regexp="(.*)"
              search_in="hdr"
              header="To: "
              check_it="true"
              assign_to="header_to" />
        </action>
        
    </recv>  
  
       <send>
        <![CDATA[
            SIP/2.0 200 OK
            [last_Via:]
            [last_From:]
            [last_To:]
            [last_Call-ID:]
            [last_CSeq:]
            Content-Length: 0
        ]]>
    </send>
  
<!--<send start_rtd="bye">
    <![CDATA[
      BYE sip:[$ue1]@[$ue1_ip] SIP/2.0
      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
      From: [$header_to]
      To: [$header_from]
            [last_Call-ID:]
      CSeq: 3 BYE
            Supported: 100rel,replaces,timer
      Max-Forwards: 70
      Content-Length: 0

    ]]>
  </send>-->
  
  
    <recv request="BYE">
    </recv>
    
           <send>
        <![CDATA[
            SIP/2.0 200 OK
            [last_Via:]
            [last_From:]
            [last_To:]
            [last_Call-ID:]
            [last_CSeq:]
            Content-Length: 0
        ]]>
    </send>
 
   <label id="END"/>
  <nop hide="true">
  </nop>
 
<!-- 防止对方未收到200 ok,继续重传BYE,因此等待3秒钟后结束-->
  <pause hide= "true" milliseconds="1000" />
  
 <Reference variables="header_from,header_to" />

  <!-- 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>

4.UE3的脚本内容:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<!--用于模拟局内被叫侧呼叫转接UE3用户的业务流程-->
<!--脚本编写时间:2015-12-1 17:15 作者:王伟-->
<scenario name="callee_inner_tran_ue3">
    
    <recv request="INVITE">
                <action>
            <ereg regexp="<sip:(.*)@.*>"
              search_in="hdr"
              header="To: "
              check_it="true"
              assign_to="junk,callee" />    
            <ereg regexp=".*"
              search_in="hdr"
              header="CSeq:"
              check_it="true"
              assign_to="invite_cseq" />  
              <lookup assign_to="line" file="trans_user.conf" key="[$callee]" />
              <assignstr assign_to="tmp" value="[field1 line=\"[$line]\" file=\"trans_user.conf\"]" />
              <strcmp assign_to="result1" variable="tmp" value="1" />
              <strcmp assign_to="result2" variable="tmp" value="2" />
              <test assign_to="result3" variable="result1" compare="equal" value="0" />    
          <test assign_to="result4" variable="result2" compare="equal" value="0" />              
    </action>    
    </recv>
        
         <pause hide="true" milliseconds="100"/>  
    
    <label id="100"/>
    <send>
        <![CDATA[
            SIP/2.0 100 Trying
            [last_Via:]
            [last_From:]
            [last_To:]
            [last_Call-ID:]
            [last_CSeq:]
            X-Test-Info: line="[$line]" var_tmp="[$tmp]" result1="[$result1]" result2="[$result2]" result3="[$result3]" result4="[$result4]"
            Content-Length: 0
            
        ]]>
    </send>
    
    <nop hide="true" test="result3" next="userbusy" />

 <pause hide="true" milliseconds="100"/>  
    <send>
        <![CDATA[
            SIP/2.0 180 Ringing
            [last_Via:]
            [last_From:]
            [last_To:];tag=zgh8.[call_number]
            [last_Call-ID:]
            [last_CSeq:]
            Contact:<sip:[field1]@[local_ip]:[local_port]>
            Content-Length: 0
            
        ]]>
    </send>

<nop hide="true" test="result4" next="norsp" />

<send retrans="500" start_rtd="ack">
    <![CDATA[
            SIP/2.0 200 OK 
            [last_Via:]
            [last_From:]
            [last_To:];tag=zgh8.[call_number]
            [last_Call-ID:]
            [last_CSeq:]
            Contact:<sip:[field1]@[local_ip]:[local_port]>
            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
            a=ptime: 20
        ]]>
    </send>
    
    <recv request="ACK" rtd="ack" />
 <nop hide="true">
    <action>
      <exec play_pcap_audio="pcap/g711u.pcap"/>
    </action>
  </nop>
  
    <recv request="BYE">
    </recv>
 
     <send next="END">
        <![CDATA[
            SIP/2.0 200 OK
            [last_Via:]
            [last_From:]
            [last_To:]
            [last_Call-ID:]
            [last_CSeq:]
            Contact:<sip:[field1]@[local_ip]:[local_port]>
            Content-Length: 0
        ]]>
    </send>
 
  <label id="userbusy"/> 
    <send next="err_ack">
        <![CDATA[
            SIP/2.0 486 Busy Here
            [last_Via:]
            [last_From:]
            [last_To];tag=ztesip20DWpDH4V9*1-1-20481*chci.1[call_number]
            [last_Call-ID:]
            [last_CSeq:]
            Contact: <sip:[local_ip]:[local_port];transport=[transport]>
            Content-Length: 0
            
        ]]>
    </send> 
 
 <label id="norsp"/> 
    <recv request="CANCEL" />
    
    <send>
        <![CDATA[
            SIP/2.0 200 OK
            [last_Via:]
            [last_From:]
            [last_To:]
            [last_Call-ID:]
            [last_CSeq:]
            Contact: <sip:[local_ip]:[local_port];transport=[transport]>
            Content-Length: 0
        ]]>
    </send>
    
        <send next="err_ack">
        <![CDATA[
            SIP/2.0 487 Request Terminated
            [last_Via:]
            [last_From:]
            [last_To];tag=ztesip20DWpDH4V9*1-1-20481*chci.1[call_number]
            [last_Call-ID:]
            CSeq: [$invite_cseq]
            Contact: <sip:[local_ip]:[local_port];transport=[transport]>
            Content-Length: 0
            
        ]]>
    </send>
    
    <label id="err_ack"/> 
    <recv request="ACK" /> 
  
   <label id="END"/>
  <nop hide="true">
  </nop>
 
<!-- 防止对方未收到200 ok,继续重传BYE,因此等待3秒钟后结束-->
  <pause hide= "true" milliseconds="1000" />

<Reference variables="junk" />

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

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

</scenario>

枫林晨曦
6 声望8 粉丝

工作十年,一直在做IMS相关的测试,想来也是一种缘分,愿意一直这么专注下去。只有坚持,才能成长。少一点浮躁,多一份执着。


引用和评论

0 条评论