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
注:也可以下载源码编译安装
三、使用
3.1 查看用法
# sipp -h
Usage:sipp remote_host[:remote_port] [options]Example:Run SIPp with embedded server (uas) scenario:./sipp -sn uasOn the same host, run SIPp with embedded client (uac) scenario:./sipp -sn uac 127.0.0.1Available 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 scenariosyntax, use the -sd option to dump embedded scenarios.They contain all the necessary help.
.................................
..................................
3.2 常用参数说明
-v
作用:显示版本信息
-bg
作用:后台模式运行
-sd
作用:输出SIPP内嵌的默认场景
sipp -sd <uac/uas/uac_pcap>
部分参数说明:
- uac: uac场景
- uas: uas场景
- uac_pcap: uac带媒体场景
将场景内容重定向到文件
sipp -sd uas > uas.xml
-sf
作用:加载指定的场景文件
sipp -sf uas.xml
-sn <uac/uas>
作用:使用默认的内置场景文件
# sipp -sn uas
# sipp -sn uac
-t <u1/un/t1/tn>
作用:设置传输方式
部分参数说明:
u1: 使用一个UDPun: 一个呼叫用一个UDPt1: 使用一个TCPtn: 一个呼叫使用一个TCP
-i
作用:设置本地的IP地址,如contact,via,from
sip -i 192.168.1.100
-p
作用:设置本地的端口
sip -p 5060
-bind_local
作用:绑定本地IP地址
-ci
作用:本地控制IP
-cp
作用:本地控制PORT
3.3 场景文件
可以从在线参考文档(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.0Via: 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 INVITEContact: sip:sipp@[local_ip]:[local_port]Max-Forwards: 70Subject: Performance TestContent-Type: application/sdpContent-Length: [len]v=0o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]s=-c=IN IP[media_ip_type] [media_ip]t=0 0m=audio [media_port] RTP/AVP 0a=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.0Via: 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 ACKContact: sip:sipp@[local_ip]:[local_port]Max-Forwards: 70Subject: Performance TestContent-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.0Via: 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 BYEContact: sip:sipp@[local_ip]:[local_port]Max-Forwards: 70Subject: Performance TestContent-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/sdpContent-Length: [len]v=0o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]s=-c=IN IP[media_ip_type] [media_ip]t=0 0m=audio [media_port] RTP/AVP 0a=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>
3.4 示例
3.4.1 运行内置UAS/UAC
# sipp -sn uas
# sipp -sn uac
3.4.2 指定自定义场景文件
sipp -sf my_uas.xml
3.4.3 指定本地IP/端口
sipp -sf uas.xml -i 192.168.1.200 5060
3.5 测试
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 Transport5060 30.29 s 1 UDP0 new calls during 0.172 s period 1 ms scheduler resolution 0 calls Peak was 1 calls, after 10 s0 Running, 3 Paused, 0 Woken up0 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 --------------------------------
网络抓包:
四、关键说明
- 一般用于性能、压力、稳定性测试
- 可以模拟一些异常或客户现场的信令交互流程,用于复现分析问题
- 场景文件编写人员既要熟悉SIP协议,又要熟悉SIPP的相关参数应用,因此实际上很少使用SIPP作为日常测试手段