? 博客主頁:小小馬車夫的主頁
? 所屬專欄:FreeSwitch開發(fā)實踐
? 專欄介紹:主要介紹博主在實際項目中使用FreeSwitch開發(fā)外呼類項目的一些經(jīng)驗心得,主要涉及FreeSwitch的基本安裝編譯、基本配置、ESL、WSS、錄音、自定義模塊、media bug、語音播放、MRCP及對接AI機器人等內(nèi)容。內(nèi)容在持續(xù)更新中,如果感興趣可以對專欄進行訂閱~
前言
FreeSwitch作用外呼系統(tǒng)的底層服務(wù)器,其穩(wěn)定性至關(guān)重要,因此有必要對FreeSwitch作一個壓力測試。而在FreeSwitch壓力測試方面,sipp是最好用的工具,也是FreeSwitch官方推薦的。本文對Sipp的編譯安裝、命令行參數(shù)及相關(guān)配置文件和對使用sipp對FreeSwitch壓力測試作簡要介紹,如想深入了解sipp工具可以參考:sipp官網(wǎng)。
1、sipp編譯安裝
運行環(huán)境
Ubuntu 18.04.7 LTS 64位
- 依賴安裝
apt-get?install?libncurses-dev
apt-get?install?libssl-dev
apt-get?install libpcap-dev
atp-get?install?openssl
apt-get?install?sip-tester
-
sipp編譯
源碼下載:https://sourceforge.net/projects/sipp/files/sipp/3.2/sipp.svn.tar.gz/download
博主用的是sipp3.2版本, 現(xiàn)在官網(wǎng)最新版本是3.7.0,有興趣的讀者可以自行下載嘗試。
下載完成之后,解壓后即可進行編譯了:
tar?-xvf?sipp.svn.tar.gz
cd sipp.svn
make?pcapplay_oss
編譯完成會生成sipp
可執(zhí)行文件,可運行一下,驗證是否編譯成功:
2、sipp命令參數(shù)
? -s:指定外呼號碼
? -sf:指定場景腳本文件,可分為注冊,UAC,UAS等
? -inf:指定注冊用戶信息,CSV配置文件,里面有用戶的帳號,密碼,端口等信息
? -i:Sipp所在主機地址
? -p:Sipp端口號
? -r:每秒發(fā)送多少Sip消息, 常與rp參數(shù)聯(lián)合使用, -r 1 -rp 3000 代碼每3秒發(fā)送1個外呼
? -trace_screen:當程序結(jié)束時候打印統(tǒng)計信息并彈出屏幕
? -m:共發(fā)送多少Sip消息
? -t:使用tcp的傳輸模式,公司內(nèi)網(wǎng)udp有限制,tn代表每個呼叫占用一個socket
- -rtp:啟用 rtp 回送功能
3、sipp注冊csv文件
user_data.csv
SEQUENTIAL
900000001;123;
900000002;123;
900000003;123;
說明:
900000001
為主叫用戶123
為被叫用戶,也可以是FreeSwitch中配置的撥號計劃
名稱, 這里使用的正是撥號計劃
4、sipp 壓力測試UAC腳本文件
uac_test.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="Basic Sipstone UAC">
<send retrans="500">
<![CDATA[
INVITE sip:[field1]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [field0] <sip:[field0]@[remote_ip]:[remote_port]>;tag=[call_number]
To: <sip:[field1]@[remote_ip]:5060>
Call-ID: [call_id]
CSeq: 1 INVITE
Contact: sip:[field0]@[local_ip]:[local_port]
Max-Forwards: 70
Subject: FreeSwitch Performance Test
Content-Type: application/sdp
Content-Length: [len]
v=0
o=HuaweiFlexit1.0 20004 20004 IN IP4 10.130.30.7
s=A call
c=IN IP4 10.130.30.7
t=1228447938 1228451538
m=audio 10500 RTP/AVP 18 4 8 0 97
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:4 G723/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:97 telephone-event/8000
a=fmtp:97 0-15
a=sendrecv
m=video 10510 RTP/AVP 34 98
b=AS:376
a=rtpmap:34 H263/90000
a=fmtp:34 QCIF=1 CIF=4 MaxBR=3760
a=rtpmap:98 MP4V-ES/90000
a=fmtp:98 profile-level-id=2
a=sendrecv
]]>
</send>
<recv response="100" >
</recv>
<recv response="180" optional="true">
</recv>
<recv response="183" optional="true">
</recv>
<recv response="200" >
</recv>
<send>
<![CDATA[
ACK sip:mod_sofia@[remote_ip]:[remote_port];transport=udp SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [field0] <sip:[field0]@[remote_ip]:[remote_port]>;tag=[call_number]
To: <sip:[field1]@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 1 ACK
Max-Forwards: 70
Subject: Performance Test
Content-Length: 0
]]>
</send>
<pause milliseconds="120000"/>
<send retrans="500">
<![CDATA[
BYE sip:[field0]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [field0] <sip:[field0]@[remote_ip]:[remote_port]>;tag=[call_number]
To: [field1] <sip:[field1]@[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>
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
</scenario>
5、FreeSwitch相關(guān)配置
撥號計劃
前面介紹用戶csv文件時提到被叫為123
, 這是FreeSwitch撥號計劃,配置如下:
<extension name="sipp_test">
<condition field="destination_number" expression="^123$">
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="playback" data="/data/1.wav"/>
<action application="sleep" data="1000"/>
<action application="hangup"/>
</condition>
</extension>
說明:
<action application="playback" data="/data/1.wav"/>
回放音頻文件 /data/1.wav
當進行sipp壓力測試,每一個呼叫通過上述撥號計劃打進來, FreeSwitch會播放音頻文件,持續(xù)時間為wav文件時長
FreeSwitch外呼數(shù)量限制修改autoload_configs/switch.conf.xml
<!--
Max number of sessions to allow at any given time.
NOTICE: If you're driving 28 T1's in a single box you should set this to 644*2 or 1288
this will ensure you're able to use the entire DS3 without a problem. Otherwise you'll
be 144 channels short of always filling that DS3 up which can translate into waste.
-->
<param name="max-sessions" value="5000"/>
<!--Most channels to create per second -->
<param name="sessions-per-second" value="60"/>
其中
max-sessions
為FreeSwitch配置的最大并發(fā)外呼數(shù)量,壓測時可根據(jù)實際情況修改
6、sipp對FreeSwitch壓力測試命令
./sipp 10.7.40.3:5060 -i 172.28.37.88 -p 2345 -m 1000 -r 20 -rp 1000 -l 1000 -t tn -max_socket 5000 -sf uac_test.xml -inf user_data.csv -rtp_echo -trace_screen -trace_err
說明:
10.7.40.3:5060
是FreeSwitch服務(wù)器的IP和端口-i 172.28.37.88 -p 2345
為sipp所在機器的IP和端口-m 1000
總共呼叫任務(wù)數(shù)量,到達指定數(shù)量后結(jié)果壓測任務(wù)-r 20 -rp 1000
每1000毫秒20個外呼-l 1000
最后維持1000個外呼并發(fā), 到達1000后,不再起新的任務(wù),當并發(fā)外呼數(shù)小于1000時,繼續(xù)增加外呼任務(wù)-t tn
每個外呼占用一個socket-max_socket 5000
最大支持5000個外呼-sf uac_test.xml
指定場景腳本,這里采用uac腳本, 參考:sipp uac腳本-inf user_data.csv
用戶csv文件, 這里測試1000個外呼,所以user_data.csv中可以構(gòu)造1000行, 其中主叫用戶號碼遞增即可
其他參數(shù)解釋參考:sipp參數(shù)介紹
壓測完成輸出:
其中 Successful call為1000, Failed call為0, 說明1000呼任務(wù)全部成功。
FreeSwitch呼叫并發(fā)數(shù)和CPU占用率查看:
在FreeSwitch命令行中輸出: show calls
, 在另一個bash命令行中輸入top
7、可能遇到的問題及解決辦法
-
received 'SIP/2.0 407 Proxy Authentication Required
此問題用戶驗證問題,由于use_data.csv中的主叫用戶都沒有注冊,因此會報此錯誤,可以在FreeSwitch中將用戶驗證暫時關(guān)閉,等壓測結(jié)束再開啟。
修改 vars.xml
<X-PRE-PROCESS cmd="set" data="internal_auth_calls=false"/>
最后
以上就是本次的內(nèi)容,來總結(jié)一下吧:文章來源:http://www.zghlxwxcb.cn/news/detail-777951.html
- sipp的安裝和編譯
- sipp參數(shù)介紹
- sipp 用戶腳本介紹
- sipp uac呼叫腳本介紹
- FreeSwitch相關(guān)配置
- sipp對FreeSwitch壓力測試
- 可能遇到的問題及解決辦法
如果覺得有些幫助或覺得文章還不錯,請關(guān)注一下博主,你的關(guān)注是我持續(xù)寫作的動力。另外,如果有什么問題,可以在評論區(qū)留言,或者私信博主,博主看到后會第一時間進行回復(fù)。
【間歇性的努力和蒙混過日子,都是對之前努力的清零】
歡迎轉(zhuǎn)載,轉(zhuǎn)載請注明出處:https://blog.csdn.net/xxm524/article/details/126680594文章來源地址http://www.zghlxwxcb.cn/news/detail-777951.html
到了這里,關(guān)于猿創(chuàng)征文|【FreeSwitch開發(fā)實踐】使用sipp對FreeSwitch進行壓力測試的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!