SIP协议.docx
《SIP协议.docx》由会员分享,可在线阅读,更多相关《SIP协议.docx(24页珍藏版)》请在冰点文库上搜索。
SIP协议
使用SIPp进行SIP压力测试
larkguo@
2008-03-26
目录
1简介2
2安装2
3使用方法3
4情景3
4.1注册3
4.1.1测试3
4.1.2reg.xml4
4.1.3test.csv6
4.2呼叫6
4.2.1测试6
4.2.2uac-media.xml7
4.2.3test.csv11
4.3会议11
4.3.1测试11
4.3.2meetme.xml12
4.3.3meetme.csv16
5XML与CSV关系17
1简介
SIPp是一个测试SIP协议性能的工具软件。
这是一个GPL的开放源码软件。
它包含了一些基本的用户代理工作流程(UAC和UAS),并可使用INVITE和BYE建立和释放多个呼叫。
它也可以读XML的场景文件,即描述任何性能测试的配置文件。
它能动态显示测试运行的统计数据(呼叫速率、信号来回的延迟,以及消息统计)。
周期性地把CSV统计数据转储,在多个套接字上的TCP和UDP,利用重新传输管理的多路复用。
在场景定义文件中可以使用正规表达式,动态调整呼叫速率。
SIPp可以用来测试许多真实的SIP设备,如SIP代理,B2BUAs,SIP媒体服务器,SIP/x网关,SIPPBX,等等,它也可以模仿上千个SIP代理呼叫你的SIP系统。
2安装
四种安装方法(本文使用第四种安装):
1.没有TLS支持与密码验证支持
#tar-xvfsipp-xxx.tar.gz
#cdsipp-xxx
#make
Make出来的sipp文件就是一个可执行的文件,只需要搭配场景xml文件与csv文件即可进行SIP测试
2.拥有TLS支持与密码验证支持,但是不支PCAP语音播放
#tar-xvfsipp-xxx.tar.gz
#cdsipp-xxx
#makeossl
这样编译出来的文件就加入了TLS至于与密码验证支持功能sipp软件了。
3.支持PCAPPlay,但是没有密码验证支持:
(PCAPPlay即为可以进行RTP语音,但是没有407AUTH验证)
#tar-xvfsipp-xxx.tar.gz
#cdsipp-xxx
#makepcapplay
4.支持PCAP声音文件播放,而且支持密码验证支持:
(支持407auth验证支持)
#tar-xvfsipp-xxx.tar
#cdsipp-xxx
#makepcapplay_ossl
3使用方法
./sipp-sfreg.xml-infreg.csv-p6077-i-m4:
5060
-sf读取场景文件
-inf读取csv文件
-p本机采用端口
-i本机IP
-m要进行压力测试的次数
Ipaddressofregistrar要进行压力测试的IP地址
4情景
Uac(192.216.2.224)Asterisk(192.216.224.183)Uas
4.1注册
模拟若干个注册包到asterisk,asterisk回100tring和401authentication,SIPp发送invite带auth验证消息到asterisk,asterisk回100tring和200ok。
4.1.1测试
./sipp-r1-l1-sfreg.xml-inftest.csv192.216.224.183
4.1.2reg.xml
xmlversion="1.0"encoding="ISO-8859-1"?
>
DOCTYPEscenarioSYSTEM"sipp.dtd">
--Thisprogramisfreesoftware;youcanredistributeitand/or-->
--modifyitunderthetermsoftheGNUGeneralPublicLicenseas-->
--publishedbytheFreeSoftwareFoundation;eitherversion2ofthe-->
--License,or(atyouroption)anylaterversion.-->
---->
--Thisprogramisdistributedinthehopethatitwillbeuseful,-->
--butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof-->
--MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe-->
--GNUGeneralPublicLicenseformoredetails.-->
---->
--YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense-->
--alongwiththisprogram;ifnot,writetothe-->
--FreeSoftwareFoundation,Inc.,-->
--59TemplePlace,Suite330,Boston,MA02111-1307USA-->
---->
--Sippdefault'branchc'scenario.-->
---->
--首先发送SIP注册消息,Register。
里面的From与To是注册的号码-->
[CDATA[
REGISTERsip:
[remote_ip]SIP/2.0
Via:
SIP/2.0/[transport][local_ip]:
[local_port];branch=[branch]
From:
[field0][field0]@[local_ip]:
[local_port]>;tag=[call_number]
To:
[field0][field0]@[remote_ip]:
[remote_port]>
Call-ID:
[call_id]
CSeq:
1REGISTER
Contact:
sip:
[field0]@[local_ip]:
[local_port]
Content-Length:
0
Expires:
300
]]>
--SIPp会收到来自AST要求验证的401消息体,Recv意思为Receive,接收到来自AST的401要求验证的消息,Next为如果收到401,那么转至Label为1的地方进行操作-->
--sendinvitewithauthenticationmessages-->
--开始发送Register消息,里面将把验证的密码消息发送给对方,在消息体里面是抓不到密码消息的,而且已经被md5方式加密过。
-->
[CDATA[
REGISTERsip:
[field0]@[remote_ip]:
[remote_port]SIP/2.0
Via:
SIP/2.0/[transport][local_ip]:
[local_port]
From:
[field0][field0]@[local_ip]:
[local_port]>;tag=[call_number]
To:
[field0][field0]@[remote_ip]:
[remote_port]>
Call-ID:
[call_id]
CSeq:
2REGISTER
Contact:
sip:
[field0]@[local_ip]:
[local_port]
[field1]
Content-Length:
[len]
Expires:
3600
]]>
--收到来自AST的200ACK消息后,系统转至等待1000ms,或者可以直接去掉该设置-->
--Keepthecallopenforawhileincasethe200islosttobe-->
--abletoretransmititifwereceivetheBYEagain.-->
--definitionoftheresponsetimerepartitiontable(unitisms)-->
--definitionofthecalllengthrepartitiontable(unitisms)-->
4.1.3test.csv
SEQUENTIAL
6666609;[authenticationusername=6666609password=6666609]
4.2呼叫
SIPp发送Invite消息到asterisk,AST回407要求密码验证,SIPp返回200ok,并发送invite带密码消息到asterisk,asterisk返回200OK,接着返回180,SIPp此时开始传输RTP到asterisk,延迟5000ms发送DTMF=1的号码,然后SIPp发送Bye消息到asterisk,asterisk返回200ok给SIPp。
4.2.1测试
./sipp-r1-i192.216.2.224-l1-sfuac-media.xml-inftest.csv192.216.224.183
4.2.2uac-media.xml
xmlversion="1.0"encoding="ISO-8859-1"?
>
DOCTYPEscenarioSYSTEM"sipp.dtd">
--Thisprogramisfreesoftware;youcanredistributeitand/or-->
--modifyitunderthetermsoftheGNUGeneralPublicLicenseas-->
--publishedbytheFreeSoftwareFoundation;eitherversion2ofthe-->
--License,or(atyouroption)anylaterversion.-->
---->
--Thisprogramisdistributedinthehopethatitwillbeuseful,-->
--butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof-->
--MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe-->
--GNUGeneralPublicLicenseformoredetails.-->
---->
--YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense-->
--alongwiththisprogram;ifnot,writetothe-->
--FreeSoftwareFoundation,Inc.,-->
--59TemplePlace,Suite330,Boston,MA02111-1307USA-->
---->
--Sipp'uac'scenariowithpcap(rtp)play-->
---->
--Inclientmode(sippplacingcalls),theCall-IDMUSTbe-->
--generatedbysipp.Todoso,use[call_id]keyword.-->
[CDATA[
INVITEsip:
[field1]@[remote_ip]:
[remote_port]SIP/2.0
Via:
SIP/2.0/[transport][local_ip]:
[local_port];branch=[branch]
From:
[field0][field0]@[local_ip]:
[local_port]>;tag=[call_number]
To:
[field1][field1]@[remote_ip]:
[remote_port]>
Call-ID:
[call_id]
CSeq:
1INVITE
Contact:
sip:
[field0]@[local_ip]:
[local_port]
Max-Forwards:
70
Subject:
PerformanceTest
Content-Type:
application/sdp
Content-Length:
[len]
v=0
o=user1536557652353687637INIP[local_ip_type][local_ip]
s=-
c=INIP[local_ip_type][local_ip]
t=00
m=audio[auto_media_port]RTP/AVP8
a=rtpmap:
8PCMA/8000
a=rtpmap:
101telephone-event/8000
a=fmtp:
1010-11,16
]]>
--Byaddingrrs="true"(RecordRouteSets),theroutesets-->
--aresavedandusedforfollowingmessagessent.Usefultotest-->
--againststatefulSIPproxies/B2BUAs.-->
--Packetlostcanbesimulatedinanysend/recvmessageby-->
--byaddingthe'lost="10"'.Valuecanbe[1-100]percent.-->
[CDATA[
ACKsip:
[field1]@[remote_ip]:
[remote_port]SIP/2.0
Via:
SIP/2.0/[transport][local_ip]:
[local_port];branch=[branch]
From:
[field0][field0]@[local_ip]:
[local_port]>;tag=[call_number]
To:
[field1][field1]@[remote_ip]:
[remote_port]>[peer_tag_param]
Call-ID:
[call_id]
CSeq:
1ACK
Contact:
sip:
[field0]@[local_ip]:
[local_port]
Max-Forwards:
70
Subject:
PerformanceTest
Content-Length:
0
]]>
[CDATA[
INVITEsip:
[field1]@[remote_ip]:
[remote_port]SIP/2.0
Via:
SIP/2.0/[transport][local_ip]:
[local_port]
From:
[field0][field0]@[local_ip]:
[local_port]>;tag=[call_number]
To:
[field1][field1]@[remote_ip]:
[remote_port]>
Call-ID:
[call_id]
CSeq:
2INVITE
Contact:
sip:
[field0]@[local_ip]:
[local_port]
[field2]
Max-Forwards:
70
Subject:
PerformanceTest
Content-Type:
application/sdp
Content-Length:
[len]
v=0
o=user1536557652353687637INIP[local_ip_type][local_ip]
s=-
t=00
c=INIP[media_ip_type][media_ip]
m=audio[auto_media_port]RTP/AVP0
a=rtpmap:
0PCMU/8000
]]>
--Packetlostcanbesimulatedinanysend/recvmessageby-->
--byaddingthe'lost="10"'.Valuecanbe[1-100]percent.-->
[CDATA[
ACKsip:
[field1]@[remote_ip]:
[remote_port]SIP/2.0
Via:
SIP/2.0/[transport][local_ip]:
[local_port];branch=[branch]
From:
[field0][field0]@[local_ip]:
[local_port]>;tag=[call_number]
To:
[field1][field1]@[remote_ip]:
[remote_port]>[peer_tag_param]
Call-ID:
[call_id]
CSeq:
2ACK
Contact:
sip:
[field0]@[local_ip]:
[local_port]
Max-Forwards:
70
Subject:
PerformanceTest
Content-Length:
0
]]>
--Playapre-recordedPCAPfile(RTPstream)-->
--Pause8seconds,whichisapproximatelythedurationofthe-->
--PCAPfile-->
--PlayanoutofbandDTMF'1'-->
--The'crlf'optioninsertsablanklineinthestatisticsreport.-->
[CDATA[
BYEsip:
[field1]@[remote_ip]:
[remote_port]SIP/2.0
Via:
SIP/2.0/[transport][local_ip]:
[local_port];branch=[branch]
From:
[field0][field0]@[local_ip]:
[local_port]>;tag=[call_number]
To:
[field1][field1]@[remote_ip]:
[remote_port]>[peer_tag_param]
Call-ID:
[call_id]
CSeq:
2BYE
Contact:
sip:
[field0]@[local_ip]:
[local_port]
Max-Forwards:
70
Subject:
PerformanceTest
Conten