sipp进行压力测试的最佳工具,一般分三种。注册、模拟发起呼叫,接听。
脚本如下:
注册脚本:
<scenario name="Basic Sipstone UAC">
<send retrans="500">
<![CDATA[
REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch];rport
From: [service] <sip:[service]@[remote_ip]:[remote_port]>;tag=[call_number]
To: [service] <sip:[service]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 REGISTER
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=z9hG4bK-d87543-717507386-1--d87543-;rport
Contact: <sip:[service]@[local_ip]:[local_port]>
Expires: 360000000000
Content-Length: 0
]]>
</send>
<recv response="100" option="true" >
</recv>
<recv response="401" auth="true" >
</recv>
<send retrans="500">
<![CDATA[
REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch];rport
From: [service] <sip:[service]@[remote_ip]:[remote_port]>;tag=[call_number]
To: [service] <sip:[service]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 2 REGISTER
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=z9hG4bK-d87543-717507386-1--d87543-;rport
Contact: <sip:[service]@[local_ip]:[local_port]>
[authentication]
Expires: 360000000000
Max-Forwards: 70
Content-Length: [len]
]]>
</send>
<recv response="100" option="true">
</recv>
<recv response="200" next="2">
</recv>
<label id="2" />
<pause milliseconds="1000">
自动执行脚本:
#!/bin/sh
I=1
j=850
k=850
until [ "$I" = "49" ]
do
PORT=`expr $I + 5132`
I=`expr $I + 1`
NT=`expr $j + $I`
PD=`expr $k + $I`
./sipp -sf reg.xml -p $PORT -trace_err -m 1 -s $NT -ap $PD -i 192.168.18.39 192.168.1.103
done
发起呼叫:
<scenario name="/pcap play">
<send retrans="500">
<![CDATA[
INVITE sip:10000@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [service] <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
To: 10000 <sip:10000@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 INVITE
Contact: sip:[service]@[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 0 8 4 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11,16
a=ptime:20
]]>
</send>
<recv response="407" auth="true">
</recv>
<!-- By adding rrs="true" (Record Ro[field1]e Sets), the ro[field1]e 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[
ACK sip:10000@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [service] <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
To: 10000 <sip:10000@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 1 ACK
Contact: sip:[service]@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Performance Test
Content-Length: 0
]]>
</send>
<send retrans="500">
<![CDATA[
INVITE sip:10000@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [service] <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
To: 10000 <sip:10000@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 2 INVITE
[authentication]
Contact: sip:[service]@[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 [auto_media_port] RTP/AVP 0 8 4 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11,16
a=ptime:20
]]>
</send>
<recv response="100"
optional="true">
</recv>
<recv response="183"
optional="true">
</recv>
<recv response="180"
optional="true">
</recv>
<recv response="200" ctrf="true">
</recv>
<send>
<![CDATA[
ACK sip:10000@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [service] <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
To: 10000 <sip:10000@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 2 ACK
Contact: sip:[service]@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Performance Test
Content-Length: 0
]]>
</send>
<!-- Play a pre-recorded PCAP file (RTP stream) -->
<pause milliseconds="10000"/>
<nop>
<action>
<exec play_pcap_audio="pcap/g711.pcap"/>
</action>
</nop>
<pause milliseconds="90000"/>
<!-- This delay can be customized by the -d command-line option -->
<!-- or by adding a 'milliseconds = "value"' option here. -->
<!-- The 'crlf' option inserts a blank line in the statistics report. -->
<send retrans="500">
<![CDATA[
BYE sip:10000@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [service] <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
To: 10000 <sip:10000@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 1 BYE
Contact: sip:[service]@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Performance Test
Content-Length: 0
]]>
</send>
<recv response="503"
ctrf="true" >
</recv>
<send retrans="500">
<![CDATA[
BYE sip:10000@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [service] <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
To: 10000 <sip:10000@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 2 BYE
Contact: sip:[service]@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Performance Test
Content-Length: 0
]]>
</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>
接听:
<recv request="INVITE" crlf="true">
</recv>
<send>
<![CDATA[
SIP/2.0 100 Trying
[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>
<![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 [auto_media_port] RTP/AVP 8 0
a=rtpmap:4 g723/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
]]>
</send>
<recv request="ACK"
optional="true"
rtd="true"
crlf="true" >
</recv>
<nop>
<action>
<exec play_pcap_audio="pcap/g711.pcap"/>
</action>
</nop>
<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>