赞
踩
SIPP是针对SIP协议的一个性能测试的命令行工具,可以动态显示测试的统计信息(如呼叫速率、延时、消息统计等)。用户可以通过XML场景配置文件,自定义模拟各种UAC/UAS测试场景的信令交互流程,可以被用来测试IP话机、SIP代理、SIP PBX等SIP设备。
官方网站:https://sipp.sourceforge.net/
参考文档:https://sipp.sourceforge.net/doc/reference.pdf
linux平台:
sudo apt install sip-tester
注:也可以下载源码编译安装
# sipp -h
Usage:
sipp remote_host[:remote_port] [options]
Example:
Run SIPp with embedded server (uas) scenario:
./sipp -sn uas
On the same host, run SIPp with embedded client (uac) scenario:
./sipp -sn uac 127.0.0.1
Available options:
*** Scenario file options:
-sd : Dumps a default scenario (embedded in the SIPp executable)
-sf : Loads an alternate XML scenario file. To learn more about XML scenario
syntax, use the -sd option to dump embedded scenarios.
They contain all the necessary help.
.................................
..................................
作用:显示版本信息
作用:后台模式运行
作用:输出SIPP内嵌的默认场景
sipp -sd <uac/uas/uac_pcap>
部分参数说明:
将场景内容重定向到文件
sipp -sd uas > uas.xml
作用:加载指定的场景文件
sipp -sf uas.xml
作用:使用默认的内置场景文件
# sipp -sn uas
# sipp -sn uac
作用:设置传输方式
部分参数说明:
u1: 使用一个UDP
un: 一个呼叫用一个UDP
t1: 使用一个TCP
tn: 一个呼叫使用一个TCP
作用:设置本地的IP地址,如contact,via,from
sip -i 192.168.1.100
作用:设置本地的端口
sip -p 5060
作用:绑定本地IP地址
作用:本地控制IP
作用:本地控制PORT
可以从在线参考文档(https://sipp.sourceforge.net/doc/reference.pdf) 中的链接获取一些内置的测试场景的xml模板,手动改变其中的一些参数或流程形成目标场景文件。
uac.xml:
<scenario name="Basic Sipstone UAC">
<!-- 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:[service]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
To: [service] <sip:[service]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 INVITE
Contact: sip:sipp@[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 [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv response="100"
optional="true">
</recv>
<recv response="180" optional="true">
</recv>
<recv response="183" optional="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. -->
<recv response="200" rtd="true">
</recv>
<!-- 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:[service]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
To: [service] <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 1 ACK
Contact: sip:sipp@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Performance Test
Content-Length: 0
]]>
</send>
<!-- This delay can be customized by the -d command-line option -->
<!-- or by adding a 'milliseconds = "value"' option here. -->
<pause/>
<!-- The 'crlf' option inserts a blank line in the statistics report. -->
<send retrans="500">
<![CDATA[
BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
To: [service] <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 2 BYE
Contact: sip:sipp@[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>
uas.xml:
<scenario name="Basic UAS responder">
<!-- 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. -->
<!-- Adding ignoresdp="true" here would ignore the SDP data: that -->
<!-- can be useful if you want to reject reINVITEs and keep the -->
<!-- media stream flowing. -->
<recv request="INVITE" crlf="true">
</recv>
<!-- The '[last_*]' keyword is replaced automatically by the -->
<!-- specified header if it was present in the last message received -->
<!-- (except if it was a retransmission). If the header was not -->
<!-- present or if no message has been received, the '[last_*]' -->
<!-- keyword is discarded, and all bytes until the end of the line -->
<!-- are also discarded. -->
<!-- -->
<!-- If the specified header was present several times in the -->
<!-- message, all occurrences are concatenated (CRLF separated) -->
<!-- to be used in place of the '[last_*]' keyword. -->
<send>
<![CDATA[
SIP/2.0 180 Ringing
[last_Via:]
[last_From:]
[last_To:];tag=[pid]SIPpTag01[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=[pid]SIPpTag01[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>
<!-- Keep the call open for a while in case the 200 is lost to be -->
<!-- able to retransmit it if we receive the BYE again. -->
<timewait milliseconds="4000"/>
<!-- 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>
# sipp -sn uas
# sipp -sn uac
sipp -sf my_uas.xml
sipp -sf uas.xml -i 192.168.1.200 5060
192.168.1.16终端呼叫192.168.1.200
测试结果:
# sipp -sn uas 192.168.1.200
Resolving remote host '192.168.1.200'... Done.
------------------------------ Scenario Screen -------- [1-9]: Change Screen --
Port Total-time Total-calls Transport
5060 30.29 s 1 UDP
0 new calls during 0.172 s period 1 ms scheduler resolution
0 calls Peak was 1 calls, after 10 s
0 Running, 3 Paused, 0 Woken up
0 dead call msg (discarded)
3 open sockets 0/0/0 UDP errors (send/recv/cong)
0 Total RTP pckts sent 0.000 last period RTP rate (kB/s)
Messages Retrans Timeout Unexpected-Msg
----------> INVITE 1 0 0 0
<---------- 180 1 0
<---------- 200 1 0 0
----------> ACK E-RTD1 1 0 0 0
----------> BYE 1 0 0 0
<---------- 200 1 0
[ 4000ms] Pause 1 0
点击ctrl+C结束sipp,打印结果:
------------------------------ Test Terminated --------------------------------
----------------------------- Statistics Screen ------- [1-9]: Change Screen --
Start Time | 2024-03-15 15:01:44.429203 1710486104.429203
Last Reset Time | 2024-03-15 15:02:14.553107 1710486134.553107
Current Time | 2024-03-15 15:02:14.731231 1710486134.731231
-------------------------+---------------------------+--------------------------
Counter Name | Periodic value | Cumulative value
-------------------------+---------------------------+--------------------------
Elapsed Time | 00:00:00:178000 | 00:00:00:178000
Call Rate | 0.000 cps | 0.033 cps
-------------------------+---------------------------+--------------------------
Incoming calls created | 0 | 1
Outgoing calls created | 0 | 0
Total Calls created | | 1
Current Calls | 0 |
-------------------------+---------------------------+--------------------------
Successful call | 0 | 1
Failed call | 0 | 0
-------------------------+---------------------------+--------------------------
Response Time 1 | 00:00:00:000000 | 00:00:00:000000
Call Length | 00:00:00:000000 | 00:00:00:000000
------------------------------ Test Terminated --------------------------------
网络抓包:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。