关于sipp和jmeter的压测随记
关于jmeter的记录
#jdk和jmeter的环境变量
JAVA_HOME=/home/yc_sipp/jmeter/jdk1.8.0_351
export JAVA_HOME
PATH=$PATH:$HOME/bin:~/tomcat/bin:$JAVA_HOME/bin
export JMETER_HOME=/home/yc_sipp/jmeter/apache-jmeter-5.6.3
export PATH=$JMETER_HOME/bin:$PATH
#运行前需要确保report目录是空的,这个report会生成报告
jmeter -n -t out_call.jmx -l result.jtl -e -o ./report/
-n 以非GUI模式运行(命令行模式),避免GUI资源消耗,适用于负载测试 必选参数
-t 指定要执行的JMeter测试计划文件(.jmx格式) out_call.jmx
-l 指定测试结果输出文件(.jtl格式),记录所有采样数据 result.jtl
-e 测试完成后自动生成HTML格式的测试报告 需配合-o使用
-o 指定HTML报告的输出目录(必须为空或不存在,否则报错) ./report/
- jmeter运行并发说明
- 一共启600个线程50秒内完成,也就是1秒12线程同时执行,持续时间是1800秒,也就是半个小时解释,压测半小时。
- 具体循环里面逻辑就需要具体来看下。
关于sipp的记录
sipp应答侧(呼出客户测)
./sipp_phone -sn uas -sf custom_success.xml -p 7722 -i $ipaddr -mi $ipaddr -max_recv_loops 2000 -max_sched_loops 2000 -watchdog_interval 430 -watchdog_minor_threshold 1000 -watchdog_minor_maxtriggers 150 -watchdog_major_threshold 3500 -watchdog_major_maxtriggers 40 -r 4
0 -rp 1s -l 2000 -aa -trace_err -trace_stat -trace_msg -trace_screen -message_file ./log/msg_ivr-test.log -stf ./log/qingniu_ivr-test.csv -stat_delimiter ',' -fd 5 -error_file ./log/error_ivr-test.log -recv_timeout 900000
简单说明下: 接听的是77722端口,也就是呼叫送这个端口,根据 SIP 场景脚本进行放音等待或者挂机。
一、核心模式与场景配置
-sn uas 设置工作模式为 被叫(User Agent Server),模拟接收 SIP 请求 必选参数
-sf custom_success.xml 指定自定义 SIP 场景脚本,定义被叫行为(如响应逻辑、状态码处理) XML 文件路径
二、网络与端口配置
-p 7722 设置被叫监听的 SIP 信令端口 1-65535
-i $ipaddr 绑定本地 控制平面 IP 地址(用于接收 SIP 消息) 如 192.168.1.2
-mi $ipaddr 绑定本地 媒体流 IP 地址(用于 RTP 流传输) 需与媒体路径匹配
三、性能与负载控制
-max_recv_loops 2000 最大接收循环次数,防止无限等待 根据测试需求调整
-max_sched_loops 2000 最大调度循环次数,控制任务队列处理上限 建议 ≥ 并发量
-r 40 设置 呼叫速率(每秒发起 40 次 INVITE 请求) 单位:呼叫/秒
-rp 1s 呼叫速率的 时间粒度(每 1 秒调整一次速率) 如 500ms
-l 2000 最大 并发呼叫数(同时处理的 SIP 会话数量) 根据硬件资源调整
四、监控与稳定性保障
-watchdog_interval 430 监控检查周期(秒),超时触发异常处理 建议 ≤ 600
-watchdog_minor_threshold 1000 次要阈值(消息处理延迟超过 1000ms 触发警告) 单位:毫秒
-watchdog_major_threshold 3500 主要阈值(消息处理延迟超过 3500ms 触发严重告警) 单位:毫秒
五、日志与结果输出
-trace_err 启用 错误日志 记录(含协议错误、超时等) 开关参数
-trace_stat 输出 统计信息(如呼叫成功率、延迟分布) 开关参数
-trace_msg 记录 完整 SIP 消息(含头域和 SDP) 开关参数
-message_file 消息日志文件路径(记录原始 SIP 消息) 如 ./log/msg.log
-stf ./log/qingniu_ivr-test.csv 统计结果文件(以 CSV 格式输出指标,支持后续分析) 分隔符需指定
六、资源与超时控制
-fd 5 设置 最大文件描述符数(控制并发连接数) 根据系统限制调整
-recv_timeout 900000 设置 接收超时时间(900,000 毫秒 = 15 分钟,超时后终止会话) 单位:毫秒
-aa 启用 自动应答(被叫立即返回 200 OK,跳过正常流程) 开关参数
- 流程文件
- 接收INVITE消息后,发送ack 200消息,然后在发送一个按键音,等待100秒,好久发送bye消息
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="Basic UAS responder">
<recv request="INVITE" >
<action>
<ereg regexp="sip:(.*)@(.*)>;tag=(.*)"
search_in="hdr"
header="From:"
check_it="true"
assign_to="junk,caller_num,domain,caller_tag">
</ereg>
<ereg regexp="sip:(.*)@.*>"
search_in="hdr"
header="To:"
check_it="true"
assign_to="junk,callee_num">
</ereg>
</action>
</recv>
<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 8
a=rtpmap:0 PCMA/8000
]]>
</send>
<recv request="ACK" optional="false" rtd="true" crlf="true">
</recv>
<!--<pause milliseconds="50000"/>-->
<nop>
<action>
<!-- <exec play_pcap_audio="/home/sipp/yace/sipp-10007/pcap/pcma20s.pcap"/>-->
<exec play_pcap_audio="/home/yc_sipp/sipp-phone/pcap/dtmf_2833_2.pcap"/>
</action>
</nop>
<!-- <pause milliseconds="200000"/> -->
<pause milliseconds="100000"/>
<send start_rtd="bye">
<![CDATA[
BYE sip:[$caller_num]@[local_ip]:[local_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: "[$callee_num]" <sip:[$callee_num]@[local_ip]>;tag=[call_number]
To: "[$caller_num]" <sip:[$caller_num]@[local_ip]>;tag=[$caller_tag]
Call-ID: [call_id]
CSeq: 2 BYE
Max-Forwards: 70
Subject: normal call scenario
Content-Length: 0
]]>
</send>
<recv response="200" rtd="bye">
</recv>
<Reference variables="junk,domain">
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
</scenario>
sipp主动发起侧
- 呼入sbc后转接平台,本机监听192.168.127.22和773端口,把呼叫送给192.168.127.61:5070,接入号码是01011111113
./sipp 192.168.127.61:5070 -i 192.168.127.22 -p 7733 -r 2 -rp 1s -l 2000 -m 4080 -s 01011111113 -aa -max_recv_loops 2000 -max_sched_loops 2000 -watchdog_interval 430 -watchdog_minor_threshold
1000 -watchdog_minor_maxtriggers 150 -watchdog_major_threshold 3500 -watchdog_major_maxtriggers 40 -sf /home/sipp/sipp_call_in_slee/inbound_custom.xml -inf /home/sipp/sipp_call_in_slee/ca
ll_num.csv -trace_msg -trace_stat -trace_screen -trace_err -message_file /home/sipp/sipp_call_in_slee/log/msg_ivr-test.log -stf /home/sipp/sipp_call_in_slee/log/qingniu_ivr-test.csv -stat
_delimiter ',' -fd 5 -error_file /home/sipp/sipp_call_in_slee/log/error_ivr-test.log -recv_timeout 900000
- 流程文件
- 发送INVITE 消息,然后接收183,发送ack,然后在等待165秒,中没有放音操作。
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="UAC with media">
<!-- 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: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number]
To: sut <sip:[service]@[remote_ip]:[remote_port]>
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=[field0] 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 8 101
a=rtpmap:8 PCMA/8000
a=fmtp:101 0-16
a=rtpmap:101 telephone-event/8000
a=ptime:20
a=sendrecv
]]>
</send>
<recv response="100" optional="true">
</recv>
<!--<recv response="183" optional="true">-->
<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" crlf="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: [field0] <sip:[field0]@[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:[field0]@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Performance Test
Content-Length: 0
]]>
</send>
<!-- Play a pre-recorded PCAP file (RTP stream) -->
<!-- <lableid="2"/> -->
<!-- Pause 8 seconds, which is approximately the duration of the -->
<!-- PCAP file -->
<pause milliseconds="165000"/>
<!-- Play an out of band DTMF '1' -->
<!-- <nop>
<action>
<exec play_pcap_audio="zajtest/pcap/dtmf_2833_1.pcap"/>
</action>
</nop>
<pause milliseconds="1000"/>-->
<!-- 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: [field0] <sip:[field0]@[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:[field0]@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Performance Test
Content-Length: 0
]]>
</send>
<recv response="200" 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>
-->
<!-- 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>
评论区