sipp是sip的压力测试工具,为了测试sip服务器的压力,在测试中使用sipp模拟了uac和uas。下面给出使用的脚本。
1,注册脚本
注册脚本分为两部分,一部分是主叫的注册,一部分是被叫的注册。这两个文件使用的csv文件不同,场景文件相同。
1.1 主叫的csv文件,reg1.csv
RANDOM
1000;1050;[authentication username=1000 password=1234]
1001;1051;[authentication username=1001 password=1234]
1002;1052;[authentication username=1002 password=1234]
1003;1053;[authentication username=1003 password=1234]
1004;1054;[authentication username=1004 password=1234]
1005;1055;[authentication username=1005 password=1234]
1006;1056;[authentication username=1006 password=1234]
1007;1057;[authentication username=1007 password=1234]
1008;1058;[authentication username=1008 password=1234]
1009;1059;[authentication username=1009 password=1234]
1010;1060;[authentication username=1010 password=1234]
1011;1061;[authentication username=1011 password=1234]
1012;1062;[authentication username=1012 password=1234]
1013;1063;[authentication username=1013 password=1234]
1014;1064;[authentication username=1014 password=1234]
1015;1065;[authentication username=1015 password=1234]
1016;1066;[authentication username=1016 password=1234]
1017;1067;[authentication username=1017 password=1234]
1018;1068;[authentication username=1018 password=1234]
1019;1069;[authentication username=1019 password=1234]
1020;1070;[authentication username=1020 password=1234]
1021;1071;[authentication username=1021 password=1234]
1022;1072;[authentication username=1022 password=1234]
1023;1073;[authentication username=1023 password=1234]
1024;1074;[authentication username=1024 password=1234]
1025;1075;[authentication username=1025 password=1234]
1026;1076;[authentication username=1026 password=1234]
1027;1077;[authentication username=1027 password=1234]
1028;1078;[authentication username=1028 password=1234]
1029;1079;[authentication username=1029 password=1234]
1030;1080;[authentication username=1030 password=1234]
1031;1081;[authentication username=1031 password=1234]
1032;1082;[authentication username=1032 password=1234]
1033;1083;[authentication username=1033 password=1234]
1034;1084;[authentication username=1034 password=1234]
1035;1085;[authentication username=1035 password=1234]
1036;1086;[authentication username=1036 password=1234]
1037;1087;[authentication username=1037 password=1234]
1038;1088;[authentication username=1038 password=1234]
1039;1089;[authentication username=1039 password=1234]
1040;1090;[authentication username=1040 password=1234]
1041;1091;[authentication username=1041 password=1234]
1042;1092;[authentication username=1042 password=1234]
1043;1093;[authentication username=1043 password=1234]
1044;1094;[authentication username=1044 password=1234]
1045;1095;[authentication username=1045 password=1234]
1046;1096;[authentication username=1046 password=1234]
1047;1097;[authentication username=1047 password=1234]
1048;1098;[authentication username=1048 password=1234]
1049;1099;[authentication username=1049 password=1234]
1.2 被叫的注册,reg2.csv
RANDOM
1050;1050;[authentication username=1050 password=1234]
1051;1051;[authentication username=1051 password=1234]
1052;1052;[authentication username=1052 password=1234]
1053;1053;[authentication username=1053 password=1234]
1054;1054;[authentication username=1054 password=1234]
1055;1055;[authentication username=1055 password=1234]
1056;1056;[authentication username=1056 password=1234]
1057;1057;[authentication username=1057 password=1234]
1058;1058;[authentication username=1058 password=1234]
1059;1059;[authentication username=1059 password=1234]
1060;1060;[authentication username=1060 password=1234]
1061;1061;[authentication username=1061 password=1234]
1062;1062;[authentication username=1062 password=1234]
1063;1063;[authentication username=1063 password=1234]
1064;1064;[authentication username=1064 password=1234]
1065;1065;[authentication username=1065 password=1234]
1066;1066;[authentication username=1066 password=1234]
1067;1067;[authentication username=1067 password=1234]
1068;1068;[authentication username=1068 password=1234]
1069;1069;[authentication username=1069 password=1234]
1070;1070;[authentication username=1070 password=1234]
1071;1071;[authentication username=1071 password=1234]
1072;1072;[authentication username=1072 password=1234]
1073;1073;[authentication username=1073 password=1234]
1074;1074;[authentication username=1074 password=1234]
1075;1075;[authentication username=1075 password=1234]
1076;1076;[authentication username=1076 password=1234]
1077;1077;[authentication username=1077 password=1234]
1078;1078;[authentication username=1078 password=1234]
1079;1079;[authentication username=1079 password=1234]
1080;1080;[authentication username=1080 password=1234]
1081;1081;[authentication username=1081 password=1234]
1082;1082;[authentication username=1082 password=1234]
1083;1083;[authentication username=1083 password=1234]
1084;1084;[authentication username=1084 password=1234]
1085;1085;[authentication username=1085 password=1234]
1086;1086;[authentication username=1086 password=1234]
1087;1087;[authentication username=1087 password=1234]
1088;1088;[authentication username=1088 password=1234]
1089;1089;[authentication username=1089 password=1234]
1090;1090;[authentication username=1090 password=1234]
1091;1091;[authentication username=1091 password=1234]
1092;1092;[authentication username=1092 password=1234]
1093;1093;[authentication username=1093 password=1234]
1094;1094;[authentication username=1094 password=1234]
1095;1095;[authentication username=1095 password=1234]
1096;1096;[authentication username=1096 password=1234]
1097;1097;[authentication username=1097 password=1234]
1098;1098;[authentication username=1098 password=1234]
1099;1099;[authentication username=1099 password=1234]
1.3 注册场景描述文件,reg.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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 default 'branchc' scenario. -->
<!-- -->
<scenario name="branch_client">
<send retrans="500">
<![CDATA[
REGISTER sip:[remote_ip] 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: [field0] <sip:[field0]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 REGISTER
Contact: sip:[field0]@[local_ip]:[local_port]
Content-Length: 0
Expires: 3600
]]>
</send>
<recv response="401" auth="true" next="1">
</recv>
<!-- send invite with authentication messages -->
<label id="1"/>
<send retrans="500">
<![CDATA[
REGISTER sip:[field0]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port]
From: [field0] <sip:[field0]@[remote_ip]:[remote_port]>;tag=[call_number]
To: [field0] <sip:[field0]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 2 REGISTER
Contact: sip:[field0]@[local_ip]:[local_port]
[field2]
Content-Length: [len]
Expires: 3600
]]>
</send>
<recv response="200" >
</recv>
<pause milliseconds="1000"/>
<!-- 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>
1.4 主叫注册命令
./sipp -sf reg.xml -inf reg1.csv -p 6067 -i 10.130.41.* -m 50 10.130.16.42:5060
其中10.130.41.*为sipp所在机器的IP地址。50 10.130.16.*为sip 服务器所在机器的IP地址。
1.5 被叫注册命令
./sipp -sf reg.xml -inf reg2.csv -p 6068 -i 10.130.41.* -m 50 10.130.16.42:5060
2,UAC脚本
2.1 场景描述脚本
<?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]@10.130.16.42:5060 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: 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" >
</recv>
<recv response="200" >
</recv>
<send>
<![CDATA[
ACK sip:
[email protected]:5060;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="5000"/>
<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>
2.2 UAC执行命令
./sipp -sf uac.xml -inf reg1.csv -p 6067 -i 10.130.41.* -m 50 10.130.16.42:5060
3 UAS脚本
3.1 场景描述脚本
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="Basic UAS responder">
<recv request="INVITE" crlf="true">
</recv>
<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">
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[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 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv request="ACK" optional="true" rtd="true" crlf="true">
</recv>
<recv request="BYE">
</recv>
<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>
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
</scenario>
3.2 UAS执行脚本
./sipp -sf uas.xml -inf reg2.csv -p 6068 -i 10.130.41.* -m 50 10.130.16.42:5060
4 自动生成csv文件的脚本
#!/bin/bash
dstfile="reg1.csv"
caller=1000
callee=1050
echo "RANDOM" > $dstfile
while [ $caller != 1050 ]
do
echo "$caller;$callee;[authentication username=$caller password=1234]" >> $dstfile
caller=$(($caller + 1))
callee=$(($callee + 1))
done;
5 对FS的测试结果
5.1 机器配置
FS所在机器
内存 1G
CPU AMD 2800+ 1.6G
5.2 测试结果
在测试中,共注册200个号码,其中100个作为uac,100个作为uas,共发生呼叫1000次。
UAC测试结果如下:
------------------------------ Scenario Screen -------- [1-9]: Change Screen --
Call-rate(length) Port Total-time Total-calls Remote-host
10.0(0 ms)/1.000s 6067 775.51 s 1000 10.130.16.42:5060(UDP)
Call limit reached (-m 1000), 0.000 s period 0 ms scheduler resolution
0 calls (limit 30) Peak was 30 calls, after 3 s
0 Running, 45 Paused, 0 Woken up
0 dead call msg (discarded) 0 out-of-call msg (discarded)
1 open sockets
Messages Retrans Timeout Unexpected-Msg
INVITE ----------> 1000 2 0
100 <---------- 1000 2 0 0
180 <---------- 580 0 0 420
200 <---------- 576 0 0 4
ACK ----------> 576 0
Pause [ 1000ms] 576 0
BYE ----------> 576 0 0
200 <---------- 576 0 0 0
------------------------------ Test Terminated --------------------------------
----------------------------- Statistics Screen ------- [1-9]: Change Screen --
Start Time | 2008-12-10 17:56:37:574 1228902997.574836
Last Reset Time | 2008-12-10 18:09:33:092 1228903773.092515
Current Time | 2008-12-10 18:09:33:092 1228903773.092666
-------------------------+---------------------------+--------------------------
Counter Name | Periodic value | Cumulative value
-------------------------+---------------------------+--------------------------
Elapsed Time | 00:00:00:000 | 00:12:55:517
Call Rate | 0.000 cps | 1.289 cps
-------------------------+---------------------------+--------------------------
Incoming call created | 0 | 0
OutGoing call created | 0 | 1000
Total Call created | | 1000
Current Call | 0 |
-------------------------+---------------------------+--------------------------
Successful call | 0 | 576
Failed call | 0 | 424
-------------------------+---------------------------+--------------------------
Call Length | 00:00:00:000 | 00:00:22:822
------------------------------ Test Terminated --------------------------------
2008-12-10 18:09:22:430 1228903762.430109: Aborting call on unexpected message for Call-Id '
[email protected]': while expecting '180' (index 2), received 'SIP/2.0 488 Not Acceptable Here
Via: SIP/2.0/UDP 10.130.41.253:6067;branch=z9hG4bK-3746-983-0
From: 1054 <sip:
[email protected]:5060>;tag=983
To: <sip:
[email protected]:5060>;tag=e571HjZtN3rUc
Call-ID:
[email protected]
CSeq: 1 INVITE
User-Agent: FreeSWITCH-mod_sofia/1.0.pre4-8795
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, PRACK, MESSAGE, SUBSCRIBE, NOTIFY, REFER, UPDATE, REGISTER, INFO, PUBLISH
Supported: 100rel, precondition, timer
Allow-Events: talk, presence, dialog, call-info, sla, include-session-description, presence.winfo, message-summary
Reason: Q.850;cause=88;text="INCOMPATIBLE_DESTINATION"
Content-Length: 0
UAS测试结果如下
Resolving remote host '10.130.16.42'... Done.
------------------------------ Scenario Screen -------- [1-9]: Change Screen --
Port Total-time Total-calls Transport
6068 1321.47 s 700 UDP
0 new calls during 0.530 s period 10 ms scheduler resolution
113 calls Peak was 137 calls, after 725 s
0 Running, 115 Paused, 1 Woken up
0 dead call msg (discarded)
3 open sockets
Messages Retrans Timeout Unexpected-Msg
----------> INVITE 700 0 0 0
<---------- 180 700 0
<---------- 200 700 0 0
----------> ACK E-RTD1 700 0 0 0
----------> BYE 587 0 0 0
<---------- 200 587 0
------------------------------ Test Terminated --------------------------------
----------------------------- Statistics Screen ------- [1-9]: Change Screen --
Start Time | 2008-12-10 17:56:32:845 1228902992.845066
Last Reset Time | 2008-12-10 18:18:33:790 1228904313.790969
Current Time | 2008-12-10 18:18:34:328 1228904314.328456
-------------------------+---------------------------+--------------------------
Counter Name | Periodic value | Cumulative value
-------------------------+---------------------------+--------------------------
Elapsed Time | 00:00:00:537 | 00:22:01:483
Call Rate | 0.000 cps | 0.530 cps
-------------------------+---------------------------+--------------------------
Incoming call created | 0 | 700
OutGoing call created | 0 | 0
Total Call created | | 700
Current Call | 113 |
-------------------------+---------------------------+--------------------------
Successful call | 0 | 587
Failed call | 0 | 0
-------------------------+---------------------------+--------------------------
Response Time 1 | 00:00:00:000 | 00:00:00:002
Call Length | 00:00:00:000 | 00:00:24:205
------------------------------ Test Terminated --------------------------------'.