撰写了基于SIP的meeting压力测试脚本。可以实现同时50个人同时进入meeting,然后说话,12秒后同时退出聊天室,系统等待8秒,再次重复50个人进入会议室,可以实现对meeting的压力测试。
压力测试流程图如下:
invite--------------->meeting
407<------------------meeting
invite with auth----->meeting
100<------------------meeting
user PIN<-------------meeting RTP
DTMF 1 and #---------->meeting RTP
RTP------------------->meeting
pause 18 sec
Bye------------------->meeting
200 ok<----------------meeting
xml文档如下:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<!-- This program is free software; you can redistribute it and/or -->
<!-- modify it under the terms of the GNU General Public License as -->
<!-- published by the Free Software Foundation; either version 2 of the -->
<!-- License, or (at your option) any later version. -->
<!-- -->
<!-- This program is distributed in the hope that it will be useful, -->
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
<!-- GNU General Public License for more details. -->
<!-- -->
<!-- You should have received a copy of the GNU General Public License -->
<!-- along with this program; if not, write to the -->
<!-- Free Software Foundation, Inc., -->
<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -->
<!-- -->
<!-- Sipp 'uac' scenario with pcap (rtp) play -->
<!-- -->
<!-- modify it under the terms of the GNU General Public License as -->
<!-- published by the Free Software Foundation; either version 2 of the -->
<!-- License, or (at your option) any later version. -->
<!-- -->
<!-- This program is distributed in the hope that it will be useful, -->
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
<!-- GNU General Public License for more details. -->
<!-- -->
<!-- You should have received a copy of the GNU General Public License -->
<!-- along with this program; if not, write to the -->
<!-- Free Software Foundation, Inc., -->
<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -->
<!-- -->
<!-- Sipp 'uac' scenario with pcap (rtp) play -->
<!-- -->
<scenario name="UAC with media">
<!-- In client mode (sipp placing calls), the Call-ID MUST be -->
<!-- generated by sipp. To do so, use [call_id] keyword. -->
<send retrans="500">
<![CDATA[
<!-- In client mode (sipp placing calls), the Call-ID MUST be -->
<!-- generated by sipp. To do so, use [call_id] keyword. -->
<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]@[local_ip]:[local_port]>;tag=[call_number]
To: [field1] <sip:[field1]@[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]
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number]
To: [field1] <sip:[field1]@[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[local_ip_type] [local_ip]
t=0 0
m=audio [auto_media_port] RTP/AVP 8
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11,16
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[local_ip_type] [local_ip]
t=0 0
m=audio [auto_media_port] RTP/AVP 8
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11,16
]]>
</send>
<recv response="407" auth="true">
</recv>
</send>
<recv response="407" auth="true">
</recv>
<!-- By adding rrs="true" (Record Route Sets), the route sets -->
<!-- are saved and used for following messages sent. Useful to test -->
<!-- against stateful SIP proxies/B2BUAs. -->
<!-- Packet lost can be simulated in any send/recv message by -->
<!-- by adding the 'lost = "10"'. Value can be [1-100] percent. -->
<send>
<![CDATA[
<!-- are saved and used for following messages sent. Useful to test -->
<!-- against stateful SIP proxies/B2BUAs. -->
<!-- Packet lost can be simulated in any send/recv message by -->
<!-- by adding the 'lost = "10"'. Value can be [1-100] percent. -->
<send>
<![CDATA[
ACK sip:[field1]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number]
To: [field1] <sip:[field1]@[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
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number]
To: [field1] <sip:[field1]@[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
]]>
</send>
<send retrans="500">
<![CDATA[
</send>
<send retrans="500">
<![CDATA[
INVITE sip:[field1]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port]
From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number]
To: [field1] <sip:[field1]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 2 INVITE
Contact: sip:[field0]@[local_ip]:[local_port]
[field2]
Max-Forwards: 70
Subject: Performance Test
Content-Type: application/sdp
Content-Length: [len]
Via: SIP/2.0/[transport] [local_ip]:[local_port]
From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number]
To: [field1] <sip:[field1]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 2 INVITE
Contact: sip:[field0]@[local_ip]:[local_port]
[field2]
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=-
t=0 0
c=IN IP[media_ip_type] [media_ip]
m=audio [auto_media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
t=0 0
c=IN IP[media_ip_type] [media_ip]
m=audio [auto_media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv response="100" optional="true">
</recv>
</recv>
<recv response="180" optional="true">
</recv>
<recv response="200" rtd="true" crlf="true">
</recv>
<!-- Play a pre-recorded PCAP file (RTP stream) -->
<!-- Pause 8 seconds, which is approximately the duration of the -->
<!-- PCAP file -->
<pause milliseconds="2000"/>
</recv>
<recv response="200" rtd="true" crlf="true">
</recv>
<!-- Play a pre-recorded PCAP file (RTP stream) -->
<!-- Pause 8 seconds, which is approximately the duration of the -->
<!-- PCAP file -->
<pause milliseconds="2000"/>
<!-- Play an out of band DTMF '1' '#' -->
<nop>
<action>
<exec play_pcap_audio="pcap/dtmf_2833_1.pcap"/>
</action>
</nop>
<pause milliseconds="950"/>
<nop>
<action>
<exec play_pcap_audio="pcap/dtmf_2833_pound.pcap"/>
</action>
</nop>
<pause milliseconds="1500"/>
<nop>
<action>
<exec play_pcap_audio="pcap/g711a.pcap"/>
</action>
</nop>
<pause milliseconds="12000"/>
<!-- The 'crlf' option inserts a blank line in the statistics report. -->
<send retrans="500">
<![CDATA[
<nop>
<action>
<exec play_pcap_audio="pcap/dtmf_2833_1.pcap"/>
</action>
</nop>
<pause milliseconds="950"/>
<nop>
<action>
<exec play_pcap_audio="pcap/dtmf_2833_pound.pcap"/>
</action>
</nop>
<pause milliseconds="1500"/>
<nop>
<action>
<exec play_pcap_audio="pcap/g711a.pcap"/>
</action>
</nop>
<pause milliseconds="12000"/>
<!-- The 'crlf' option inserts a blank line in the statistics report. -->
<send retrans="500">
<![CDATA[
BYE sip:[field1]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [field0] <sip:[field0]@[local_ip]:[local_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
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [field0] <sip:[field0]@[local_ip]:[local_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>
</send>
<recv response="200" crlf="true">
</recv>
<pause milliseconds="8000"/>
<!-- definition of the response time repartition table (unit is ms) -->
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
</recv>
<pause milliseconds="8000"/>
<!-- 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"/>
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
</scenario>
测试csv批量文件如下:
3001;904;[authentication username=3001 password=3001]
3002;904;[authentication username=3002 password=3002]
3003;904;[authentication username=3003 password=3003]
3004;904;[authentication username=3004 password=3004]
3005;904;[authentication username=3005 password=3005]
3006;904;[authentication username=3006 password=3006]
3007;904;[authentication username=3007 password=3007]
3008;904;[authentication username=3008 password=3008]
3009;904;[authentication username=3009 password=3009]
3010;904;[authentication username=3010 password=3010]
3011;904;[authentication username=3011 password=3011]
3012;904;[authentication username=3012 password=3012]
3013;904;[authentication username=3013 password=3013]
3014;904;[authentication username=3014 password=3014]
3015;904;[authentication username=3015 password=3015]
3016;904;[authentication username=3016 password=3016]
3017;904;[authentication username=3017 password=3017]
3018;904;[authentication username=3018 password=3018]
3019;904;[authentication username=3019 password=3019]
3020;904;[authentication username=3020 password=3020]
3002;904;[authentication username=3002 password=3002]
3003;904;[authentication username=3003 password=3003]
3004;904;[authentication username=3004 password=3004]
3005;904;[authentication username=3005 password=3005]
3006;904;[authentication username=3006 password=3006]
3007;904;[authentication username=3007 password=3007]
3008;904;[authentication username=3008 password=3008]
3009;904;[authentication username=3009 password=3009]
3010;904;[authentication username=3010 password=3010]
3011;904;[authentication username=3011 password=3011]
3012;904;[authentication username=3012 password=3012]
3013;904;[authentication username=3013 password=3013]
3014;904;[authentication username=3014 password=3014]
3015;904;[authentication username=3015 password=3015]
3016;904;[authentication username=3016 password=3016]
3017;904;[authentication username=3017 password=3017]
3018;904;[authentication username=3018 password=3018]
3019;904;[authentication username=3019 password=3019]
3020;904;[authentication username=3020 password=3020]
注意:这里的904号码为meeting接入号。这里我只写了20个,当然您可以写50,100都没关系。
测试方法与步骤:
(1):首先采用eyebeam呼入904号码,进入后根据密码PIN输入1#,进入会议室,然后听背景音乐
(2):采用sipp压力呼入904号码
./sipp -sf meeting.cml -sf meeting.csv -p 6718 -i 192.168.0.254 -m 100000 192.168.0.254 -l 50
(3):此时会听到一批号码登入会议室,然后可以听到一人说话,因为meeting的会议声音是采用叠加技术的,所以会出现很大的回声,之后陆续用户exit,完全退出后会继续听到音乐,因为只有你一个人在会议室了,这说明人已经全部走光了。然后会重复之前的动作
(4):注意 192.168.0.254是发起者呼叫机;192.168.0.194是被测试机。SIpp必须安装在254服务器上才能发起呼叫,另外我这里所指的meeting是指asterisk的conference功能,所以如果有其他软交换要测试会议的话,只需要稍微修改xml文件即可。