您的位置:首页 > 运维架构 > Linux

使用sipp对FreeSwitch进行测试(Linux环境,会议模式)

2013-04-18 17:10 411 查看
一、下载与安装

到http://sourceforge.net/projects/sipp/files/sipp/下载sipp的源码。我下载的是sipp3.2版本。SIPp是用C++写的,因此系统必须支持G++才可成功编译。

SIPp支持四种不同的安装模式:

1) 没有TLS支持与密码验证支持:

a) # tar -xvf sipp-1.1rc6.tar.gzb)

# cd sipp-1.1.rc6c)

# makeMake

出来的sipp文件就是一个可执行的文件,只需要搭配场景xml文件与csv文件即可进行SIP测试,这是最常用的安装。

2) 拥有TLS支持与密码验证支持,但是不支PCAP语音播放:

a) # tar -xvf sipp-1.1rc6.tar.gzb)

# cd sipp-1.1.rc6c)

# make ossl

这样编译出来的文件就加入了TLS至于与密码验证支持功能sipp软件了。

3) 支持PCAP Play,但是没有密码验证支持:(PCAP Play即为可以进行RTP语音,但是没有407 AUTH验证)

a) # tar -xvf sipp-1.1rc6.tar.gzb)

# cd sipp-1.1.rc6c)

# make pcapplay

4) 支持PCAP 声音文件播放,而且支持密码验证支持:(支持407 auth验证支持)

a) # tar -xvf sipp-1.1rc6.tar

b) # cd sipp-1.1.rc6

c) # make pcapplay_ossl

我是使用的是第四种安装,即支持PCAP 声音文件播放,而且支持密码验证支持( make pcapplay_ossl命令)

最后将给sipp建立快捷方式

ln -sf /usr/local/sipp/sipp3.2/sipp /usr/local/bin/ (这个是根据我的sipp安装位置写的)

二、测试用的文件

用SIPp做测试的时候需要准备三个文件:meet.csv, meet.sh, meetme.xml,。

meet.csv 需要引入的数据

meet.sh 调用sipp命令,并传入相应参数,模拟呼叫

meetme.xml 根据需要编写的信号流程。(场景文件)

创建一个文件夹(如 meeting-test),新建上述三个文件,并将sipp安装目录下的pcap文件夹复制进来。(模拟音频输入用的)。

三、例子和说明

meet.sh说明

sipp -i 192.168.76.128 -sf meetme.xml -inf meet.csv 192.168.76.128:5060 -l 50 -trace_msg -trace_screen -trace_err -p 12345 -m 1 -rtp_echo 192.168.76.128

各个参数说明:

-i 192.168.76.128: 本地地址(在脚本中用[local_ip]引入)

-sf meetme.xml: 引入脚本文件,根据需要模拟的呼叫流程编写

-inf meet.csv: 引入数据配置文件

192.168.76.128:5060: FS远端地址和端口(在脚本中用[remote_ip],[remote_port]引入)

-l 50 :最大同时保持呼叫量,默认值为3*caps值*呼叫时长,当因种种原因导致现存呼叫总数达到此值时,SIPp将停止产生新的呼叫,等待现存呼叫总数低于此值时才继续产生呼叫。

-trace_msg : 将发送和接收的数据打印到日志中

-trace_screen:将屏幕上显示的信息打印到日志中

-trace_err :将错误信息打印到日志中

-p 12345 : 发送端的端口号

-m 1:发送一次后停止并退出

-rtp_echo 192.168.76.128 :产生往返rtp流用的

meet.csv说明

SEQUENTIAL

1000;78900;[authentication username=1000 password=1234]

SEQUENTIAL :数据读取的顺序,有SEQUENTIAL和RANDOM两个值

1000;78900;[authentication username=1000 password=1234]:第一个数字1000表示本机号码;第二个数字78900表示要呼叫的会议的号码。[]里面是用户名和密码

meetme.xml 说明

<?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 'uac' scenario with pcap (rtp) play -->

<!-- -->

<scenario name="UAC with media">

<send retrans="500">

<![CDATA[

REGISTER sip:[remote_ip] 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: [field0] <sip:[field0]@[remote_ip]:[remote_port]>

Call-ID: [call_id]

CSeq: 1 REGISTER

Contact: sip:[field0]@[local_ip]:[local_port]

Content-Length: 0

Expires: 3600

]]>

</send>

<recv response="401" auth="true" next="1">

</recv>

<!-- send invite with authentication messages -->

<label id="1"/>

<send retrans="500">

<![CDATA[

REGISTER sip:[field0]@[remote_ip]:[remote_port] SIP/2.0

Via: SIP/2.0/[transport] [local_ip]:[local_port]

From: [field0] <sip:[field0]@[remote_ip]:[remote_port]>;tag=[call_number]

To: [field0] <sip:[field0]@[remote_ip]:[remote_port]>

Call-ID: [call_id]

CSeq: 2 REGISTER

Contact: sip:[field0]@[local_ip]:[local_port]

[field2]

Content-Length: [len]

Expires: 3600

]]>

</send>

<recv response="200" >

</recv>

<!-- 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:[field1]@[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: [field1] <sip:[field1]@[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=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]

s=-

c=IN IP[local_ip_type] [local_ip]

t=0 0

m=audio [auto_media_port] RTP/AVP 8

a=rtpmap:8 PCMA/8000

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-11,16

]]>

</send>

<recv response="100" optional="true"></recv>

<recv response="200" rtd="true" crlf="true">

</recv>

<pause milliseconds="10000"/>

<send>

<![CDATA[

ACK sip:[field1]@[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: [field1] <sip:[field1]@[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>

<pause milliseconds="3000"/>

<pause milliseconds="10000"/>

<nop>

<action>

<exec play_pcap_audio="pcap/g711a.pcap"/>

</action>

</nop>

<pause milliseconds="10000"/>

<nop>

<action>

<exec play_pcap_audio="pcap/g711a.pcap"/>

</action>

</nop>

<pause milliseconds="10000"/>

<nop>

<action>

<exec play_pcap_audio="pcap/g711a.pcap"/>

</action>

</nop>

<pause milliseconds="10000"/>

<nop>

<action>

<exec play_pcap_audio="pcap/g711a.pcap"/>

</action>

</nop>

<pause milliseconds="1500"/>

<send retrans="500">

<![CDATA[

BYE sip:[field1]@[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: [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>

<!-- 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>

说明:

1.需要sipp命令赋值的参数,请参考关于meet.bat的说明

[local_ip]、[local_port]、[remote_ip]、[remote_port]、[service]

2.sipp自动检测生成的参数:

[call_number]、[call_id]、[cseq]、[len]、[branch]

3.从数据配置文件引入的参数,请参考meet.csv,第一个值为field0,第二个值为field1(不同的值会以分号;分开)

<scenario>...</scenario>说明这是一个场景文件

<send>...</send>发送的内容

<recv>...</recv>接收的内容,FS返回的一般是HTTP状态码

<pause>...</pause>暂停

<nop>...</nop>动作

4.场景文件示意图:

REGISTER ---------->

401 <----------

REGISTER ---------->

200 <----------

INVITE ---------->

100 <----------

200 <----------

Pause [10.0s]

ACK ---------->

Pause [3000ms]

Pause [10.0s]

[ NOP ]

Pause [10.0s]

[ NOP ]

Pause [10.0s]

[ NOP ]

Pause [10.0s]

[ NOP ]

Pause [1500ms]

BYE ---------->

200 <----------

说明:

向右的箭头表示sipp发消息给FS,向左的箭头表示sipp接收的FS的返回值。REGISTER 表示注册(登录)用的请求,INVITE表示邀请会话请求,Pause表示暂停,BYE表示结束会话请求。FS的返回值一般为http状态码。根据这个场景文件,首先sipp会发送一个不带验证的REGISTER请求给FS,这时FS应该给SIPP返回401(401表示需要验证)。收到401后,SIPP发送带验证信息的REGISTER请求给FS,FS返回先返回100(表示接收到请求),再返回200(表示验证通过)。接着SIPP发送INVITE请求,发起会话,FS返回100表示收到请求,返回200表示验证通过。Sipp收到200后,暂停10秒钟,发送ACK请求表示收到了FS的回应。此时,通话开始。暂停13秒钟后,sipp发送第一段声音给FS;10秒钟后,发送第二段声音;又10秒钟后,发送第三段声音;又10秒钟后,发送第四段声音。最后1.5秒之后,发送BYE请求,表示会话结束。FS接到请求之后,发200表示收到,并关闭会话。

5. 场景文件的解释

比如下面这块代码里:

<send retrans="500">

<![CDATA[

REGISTER sip:[remote_ip] 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: [field0] <sip:[field0]@[remote_ip]:[remote_port]>

Call-ID: [call_id]

CSeq: 1 REGISTER

Contact: sip:[field0]@[local_ip]:[local_port]

Content-Length: 0

Expires: 3600

]]>

</send>

<recv response="401" auth="true" next="1">

</recv>

<send></send>部分其实是按照sip协议生成一段请求。REGISTER 表示这是一个注册(登录)的请求。[remote_ip]表示FS所在服务器的ip,这个ip在meet.sh文件里指定了,sipp在发送sip请求的时候,会自动将这个字段对应成实际的ip,即192.168.76.128。[remote_port],是FS服务器的端口号,FS默认的是5060,所以我们在meet.sh文件里写的就是5060 。[local_ip]:[local_port]是meet.sh中指定的sipp所在的ip和端口号。[field0]是csv文件中的第一个字段,本例子中的csv文件中只有一条数据,[field0]对应的就是1000这个字段了。

From……to……表示从哪个号码打到哪个号码。[call_id]是sipp内部生成的id。[transport]是值要走哪个协议(tcp/udp,默认的是udp)。[branch]分支,自动生成的。CSeq是说明性的部分,表示这是第几个什么请求。Content-Length正文内容,我们没有。Expires缓存时间。

<recv></recv>部分是接受FS的返回值,<recv response="401" auth="true" next="1"></recv>表示接收到401返回值后,将auth字段设为true,然后执行label=1的下面的代码块的代码。

这里的属性值和字段是都是sipp协议规定的。具体的sip协议个字段的内容,可以参考百度文库中的这篇文档(http://wenku.baidu.com/view/aa45b24f767f5acfa1c7cd50.html )

具体SIPP发送的sip请求和FS的响应,可以从执行meet.sh之后生成的meetme_XXXX_messages.log看到。

又如下面一块代码

<nop>

<action>

<exec play_pcap_audio="pcap/g711a.pcap"/>

</action>

</nop>

表示使用pcap文件夹下的g711a.pcap音频文件模拟音频输入。所以上面要把sipp安装目录下的pcap文件夹复制到meetme.xml的统计目录下,否则会提示找不到文件。

四、测试结果

测试结果可以在屏幕上直接观察到,也可以从生成的meetme_XXXX_screen.log文件中看到。

五、其他说明

sipp命令的参数-m表示的是一共要发起的呼叫数量。Csv文件中一行记录对应的这一个账户,一个账户对应着一个呼叫。所以如果指定 -m 1 的话,只能对csv文件中的第一个记录对应的账户进行呼叫。-l 表示同时最大允许多少个呼叫存在。如果指定-m 1 -l 1,并且csv的指定的读取顺序是SEQUENTIAL的话,sipp会按照csv文件中从上到下的顺序读取账户信息进行呼叫。因为通知只能有一个呼叫,所以上一个呼叫完全结束之后,才会进行下一个呼叫。

另外FS中的账户文件是在FS安装目录下的conf/directory/default/文件夹里,每一个账户对应一个xml文件。默认的有20个账户,分别是1000到1019。

如果sipp连不上FS,请检查sh文件中ip是否写错了,并检查【FS安装目录】/conf/vars.xml 中指定sip的监听ip和端口是否正确。

如果sipp和FS在同一台机器上,那么sipp脚本中不要用127.0.0.1,而要用实际的ip地址。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐