使用SIPp进行压力测试
本文更新于2022-05-14,使用SIPp v3.5.3。
官网:http://sipp.sourceforge.net/。
中文文档:http://sipp.sourceforge.net/doc/cn-reference.pdf。
安装
其它版本请于官网下载。
wget https://github.com/SIPp/sipp/releases/download/v3.5.3/sipp-3.5.3.tar.gz tar -xzf sipp-3.5.3.tar.gz cd sipp-3.5.3/ ./build.sh sudo cp sipp /usr/local/bin/sipp
使用
sipp HOST[:PORT] [OPTIONS]
OPTIONS可为:
- -aa:对INFO、NOTIFY、OPTIONS、UPDATE自动回复200 OK。
- -d:每个呼叫的持续时间,单位为毫秒。
- -inf CSVFILENAME:CSV数据文件。
- -p PORT:sipp监听的端口。默认为5060(与freeswitch默认的internal Profile端口相同)。
- -r N:每秒发起的请求数。
- -rtp_echo:将收到的RTP流原样返回。
- -s USERNAME:被呼方用户名。默认为service。
- -sf XMLFILENAME:XML场景文件。
- -sn SCENARIO:使用默认的场景文件。uac作为UAC(即SIP客户端)。
运行时可使用1、2、3、4按键切换界面的显示信息。
示例
注册测试
sipp 192.168.1.1:5060 -aa -sf reg.xml -inf users.csv -r 10 -p 6060
reg.xml场景文件的内容如下(官网有示例文件http://sipp.sourceforge.net/doc/branchc.xml,不过需修改才能使用):
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE scenario SYSTEM "sipp.dtd"> <scenario name="register"> <send retrans="500"> <![CDATA[ REGISTER sip:[remote_ip] SIP/2.0 Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] Max-Forwards: 70 Contact: sip:[field0]@[local_ip]:[local_port] To: [field0] <sip:[field0]@[remote_ip]:[remote_port]> From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number] Call-ID: [call_id] CSeq: 1 REGISTER Expires: 3600 User-Agent: SIPp Content-Length: 0 ]]> </send> <recv response="401" auth="true"> </recv> <send retrans="500"> <![CDATA[ REGISTER sip:[field0]@[remote_ip]:[remote_port] SIP/2.0 Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] Max-Forwards: 70 Contact: sip:[field0]@[local_ip]:[local_port] [field1] To: [field0] <sip:[field0]@[remote_ip]:[remote_port]> From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number] Call-ID: [call_id] CSeq: 2 REGISTER Expires: 3600 User-Agent: SIPp Content-Length: [len] ]]> </send> <recv response="200"> </recv> <!-- Keep the call open for a while in case the 200 is lost to be --> <!-- able to retransmit it if we receive the 200 again. --> <timewait milliseconds="500"/> <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/> <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/> </scenario>
users.csv数据文件的内容如下(该文件提供注册用户的用户名和密码,SEQUENTIAL
表示顺序执行):
SEQUENTIAL 1001;[authentication username=1001 password=1234] 1002;[authentication username=1002 password=1234] 1003;[authentication username=1003 password=1234]
呼叫测试(使用默认场景)
sipp 192.168.1.1:5080 -sn uac -r 1 -d 10000 -rtp_echo -s 9664
需先在public Dialplan中为9664添加相应的路由。
呼叫测试(使用场景文件)
sipp 192.168.1.1:5080 -sf uac.xml -r 1 -d 10000 -rtp_echo -s 9664
需先在public Dialplan中为9664添加相应的路由。
uac.xml场景文件可以在官网查看:http://sipp.sourceforge.net/doc/uac.xml.html。文件内容如下:
<?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 'uac' scenario. --> <!-- --> <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=[call_number] To: sut <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> <!-- 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=[call_number] To: sut <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=[call_number] To: sut <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>
标签:
freeswitch
, sip
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 2025成都.NET开发者Connect圆满结束
· 后端思维之高并发处理方案
· 千万级大表的优化技巧
· 在 VS Code 中,一键安装 MCP Server!
· 10年+ .NET Coder 心语 ── 继承的思维:从思维模式到架构设计的深度解析
2019-01-03 生成并调用so动态库
2019-01-03 Go使用protobuf