sipp basic call 脚本

3 篇文章 0 订阅

  1 <?xml version="1.0" encoding="ISO-8859-1" ?>
  2 <!DOCTYPE scenario SYSTEM "sipp.dtd">
  3 
  4 <!-- This program is free software; you can redistribute it and/or  -->
  5 <!-- modify it under the terms of the GNU General Public License as -->
  6 <!-- published by the Free Software Foundation; either version 2 of the-->
  7 <!-- License, or (at your option) any later version.            -->
  8 <!--                                                            -->
  9 <!-- This program is distributed in the hope that it will be useful, -->
 10 <!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
 11 <!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -->
 12 <!-- GNU General Public License for more details.                -->
 13 <!--                                                            -->
 14 <!-- You should have received a copy of the GNU General Public License-->
 15 <!-- along with this program; if not, write to the              -->
 16 <!-- Free Software Foundation, Inc.,                            -->
 17 <!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA     -->
 18 <!--                                                           -->
 19 <!--                 Sipp default 'branchc' scenario.          -->
 20 <!--                                                           -->
 21 <scenario name="basiccall">
 22   <send retrans="500">
 23     <![CDATA[
 24 
 25       INVITE sip:[field3]@[field1] SIP/2.0
 26       Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
 27       From: <sip:[field0]@[field1]>;tag=[call_number]
 28       To: <sip:[field3]@[field1]>
 29       Call-ID: [call_id]
 30       CSeq: 1 INVITE
 31       Contact: sip:[field0]@[local_ip]:[local_port]
 32       Max-Forwards: 7
 33       Subject: Performance Test
 34       User-Agent: Sipp
 35       X-cid: [call_id]
 36       Content-Type: application/sdp
 37       Content-Length: [len]
 38 
 39       v=0
 40       o=[local_ip] 53655765 2353687637 IN IP[local_ip_type] [local_ip]
 41       s=-
 42       c=IN IP[local_ip_type] [local_ip]
 43       t=0 0
 44       m=audio [rtpstream_audio_port] RTP/AVP 8 0 101
 45       a=rtpmap:0 PCMU/8000
 46       a=rtpmap:101 telephone-event/8000
 47       a=fmtp:101 0-16
 48       a=sendrecv
 49     ]]>
 50   </send>
 51 
 52   <recv response="100" optional="true">
 53   </recv>
 54 
 55   <recv response="407" auth="true">
56       <action>
 57         <ereg regexp="branch=(.*)"
 58               search_in="hdr"
 59               header="Via: "
 60               assign_to="8"/>
 61     </action>
 62   </recv>
 63 
 64   <!-- By adding rrs="true" (Record Route Sets), the route sets    -->
 65   <!-- are saved and used for following messages sent. Useful to test-->
 66   <!-- against stateful SIP proxies/B2BUAs.                     -->
 67   <!-- Packet lost can be simulated in any send/recv message by  -->
 68   <!-- by adding the 'lost = "10"'. Value can be [1-100] percent.-->
 69   <send>
 70     <![CDATA[
 71 
 72       ACK sip:[field3]@[field1]:[remote_port] SIP/2.0
 73       Via: SIP/2.0/[transport] [local_ip]:[local_port];[$8]
 74       From: <sip:[field0]@[field1]>;tag=[call_number]
 75       To:  <sip:[field3]@[field1]>[peer_tag_param]
 76       Call-ID: [call_id]
 77       CSeq: 1 ACK
 78       Contact: sip:[field0]@[local_ip]:[local_port]
 79       Max-Forwards: 7
 80       User-Agent: Sipp
 81       X-cid: [call_id]
 82       Subject: Performance Test
 83       Content-Length: 0
 84     ]]>
 85   </send>
 86 
 87 
 88   <send retrans="500">
 89     <![CDATA[
 90 
 91       INVITE sip:[field3]@[field1]:[remote_port] SIP/2.0
 92       Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
 93       From: <sip:[field0]@[field1]>;tag=[call_number]
 94       To: <sip:[field3]@[field1]>
 95       Call-ID: [call_id]
 96       CSeq: 2 INVITE
 97       Contact: <sip:[field0]@[local_ip]:[local_port]>; expires=600
 98       [field2]
 99       Max-Forwards: 7
100       Subject: Performance Test
101       User-Agent: Sipp
102       X-cid: [call_id]
103       Content-Type: application/sdp
104       Content-Length: [len]
105       Expires: 600
106 
107       v=0
108       o=[local_ip] 53655765 2353687637 IN IP[local_ip_type] [local_ip]
109       s=-
110       c=IN IP[local_ip_type] [local_ip]
111       t=0 0
112       m=audio [rtpstream_audio_port] RTP/AVP 8 0 101
113       a=rtpmap:0 PCMU/8000
114       a=rtpmap:101 telephone-event/8000
115       a=fmtp:101 0-16
116       a=sendrecv
117     ]]>
118   </send>
119 
120 
121   <recv response="100" optional="true">
122   </recv>
123 
124   <recv response="183" optional="true">
125   </recv>
126 
127   <recv response="200">
128   </recv>
129 
130   <!-- Packet lost can be simulated in any send/recv message by -->
131   <!-- by adding the 'lost = "10"'. Value can be [1-100] percent. -->
132   <send>
133     <![CDATA[
134 
135       ACK sip:[field3]@[field1]:[remote_port] SIP/2.0
136       Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
137       From: <sip:[field0]@[field1]>;tag=[call_number]
138       To: <sip:[field3]@[field1]>[peer_tag_param]
139       Route: <sip:10.100.125.17:5060;lr>
140       Call-ID: [call_id]
141       CSeq: 2 ACK
142       Contact: sip:[field0]@[local_ip]:[local_port]
143       Max-Forwards: 7
144       Subject: Performance Test
145       User-Agent: Sipp
146       X-cid: [call_id]
147       Content-Length: 0
148     ]]>
149   </send>
150 
151 <!--
152   <nop>
153     <action>
154       <exec play_pcap_audio="g711u.pcap"/>
155     </action>
156   </nop>
157 -->
158 
159   <nop>
160     <action>
161         <exec rtp_stream="hahaha.wav,-1,0" />
162     </action>
163   </nop>
164 
165 
166 
167   <!-- <pause distribution="normal" mean="80000" stdev="1000"/> -->
168   <pause milliseconds="56000"/>
169 
170 
171   <!-- The 'crlf' option inserts a blank line in the statistics report.-->
172   <send retrans="2000">
173     <![CDATA[
174 
175       BYE sip:[field3]@[field1]:[remote_port]; SIP/2.0
176       Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
177       From: <sip:[field0]@[field1]>;tag=[call_number]
178       To:  <sip:[field3]@[field1]>[peer_tag_param]
179       Route: <sip:10.100.125.17:5060;lr>
180       Call-ID: [call_id]
181       CSeq: 2 BYE
182       Contact: sip:[field0]@[local_ip]:[local_port]
183       Max-Forwards: 7
184       Subject: Performance Test
185       User-Agent: Sipp
186       X-cid: [call_id]
187       Content-Length: 0
188     ]]>
189   </send>
190 
191   <recv response="200" crlf="true">
192   </recv>
193 
194   <ResponseTimeRepartition value="1000, 2000, 3000, 5000, 10000, 32000"/>
195   <CallLengthRepartition value="1000, 5000, 10000, 15000, 20000, 25000, 30000"/>
196 </scenario>
197 
 

使用pcap 模式发送RTP 包,效率并不高,会有大量的软中断,不能支持大并发测试,

因为使用pcap 发送RTP的模式中, SIPP client 协商出的RTP  端口号是一个(不管有多少路),也即auto_media_port

没有为每一路分配单独的RTP 端口。

而且为了操作方便,每一路通话,SIPP 都创建了一个RAW socket, 这些socket 都绑定在一个端口上,

在高并发中,例如2000路并发,就有2000个raw socket 绑定在一个端口收发,这个软中断非常高。

为什么软中断比较高,可以参考raw socket 接收数据流程理解。

 

所以使用rtp_stream 方式会好很多。使用这种方式, 每一路都有自己的单独的RTP 端口。还有一个好处是

如果使用pcap的话, 这个wireshark 包大小需要自己控制, sipp并不能循环播放这个pcap包,但是使用rtp_stream

的话,就可以测试长时间通话了。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SIPp可以使用XML脚本来描述SIP会话。盲转是一种SIP功能,允许用户在不知道目标URI的情况下将呼叫转移到其他URI。下面是一个基本的SIPp盲转脚本示例: ```xml <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE scenario SYSTEM "sipp.dtd"> <!-- 定义变量 --> <scenario name="Blind Transfer" description="Blind Transfer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <send retrans="500" trcount="1"> <![CDATA[ INVITE sip:user1@192.168.1.1 SIP/2.0 Via: SIP/2.0/UDP 192.168.1.2:5060;branch=z9hG4bK12345 From: sip:user2@192.168.1.2;tag=12345 To: sip:user1@192.168.1.1 Call-ID: 12345@192.168.1.2 CSeq: 1 INVITE Contact: sip:user2@192.168.1.2:5060 Content-Type: application/sdp Content-Length: 0 ]]> </send> <!-- 等待100 Trying响应 --> <recv response="100" optional="true"> </recv> <!-- 等待200 OK响应 --> <recv response="200"> <!-- 提取From标头 --> <check_from uri="sip:user2@192.168.1.2" /> <!-- 提取To标头 --> <check_to uri="sip:user1@192.168.1.1" /> <!-- 提取Contact标头 --> <check_contact /> <!-- 提取SDP信息 --> <check_body content="audio" /> </recv> <!-- 发送盲转请求 --> <send retrans="500" trcount="1"> <![CDATA[ REFER sip:user3@192.168.1.3 SIP/2.0 Via: SIP/2.0/UDP 192.168.1.2:5060;branch=z9hG4bK12346 From: sip:user2@192.168.1.2;tag=12345 To: sip:user1@192.168.1.1 Call-ID: 12345@192.168.1.2 CSeq: 2 REFER Contact: sip:user2@192.168.1.2:5060 Refer-To: <sip:user3@192.168.1.3> ]]> </send> <!-- 等待202 Accepted响应 --> <recv response="202"> </recv> <!-- 等待BYE请求 --> <recv request="BYE"> <!-- 提取From标头 --> <check_from uri="sip:user2@192.168.1.2" /> <!-- 提取To标头 --> <check_to uri="sip:user3@192.168.1.3" /> </recv> <!-- 发送200 OK响应 --> <send> <![CDATA[ SIP/2.0 200 OK Via: SIP/2.0/UDP 192.168.1.2:5060;branch=z9hG4bK12347 From: sip:user2@192.168.1.2;tag=12345 To: sip:user3@192.168.1.3 Call-ID: 12345@192.168.1.2 CSeq: 3 BYE Contact: sip:user2@192.168.1.2:5060 Content-Length: 0 ]]> </send> </scenario> ``` 如上所示,该脚本首先发送一个INVITE请求,等待100 Trying响应和200 OK响应。然后,发送一个REFER请求,将呼叫转移给URI为`<sip:user3@192.168.1.3>`的用户。最后,等待BYE请求和200 OK响应。在发送和接收消息时,可以使用`<check_*>`元素从SIP消息中提取信息,以便进行后续处理。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值