【个人笔记】SIPp操作&学习--第二天

11 篇文章 3 订阅

uac

自己模仿范例写了一个

-sf uac -m 1 -i 192.168.自己的ip -d 5000 -p 7066 -s 1080 192.168.目标ip

没有传目标端口,自己电脑默认的是5060;[service][remote_ip] 由 -s 传入;[remote_port]5060
-i -p 【local_ip】【local_port】
[len] 长度 [branch] [call_number] [call_id] [local_ip_type] [media_ip_type] [media_port]都有系统确认或默认。
[transport] 比如说UDP
最重要是看这里 http://sipp.sourceforge.net/doc/reference.html

之前没有记的域 field
Version Number,协议版本 
Origin,所有者/创建者和会话标识符 
Subject,会话名称 
Connection Data,连接信息 
Time,会话活动时间 
Media(type, port, RTP/AVP Profile),媒体名称和传输地址

uac_pcap

在hp-sipp网站下的脚本使用sipp自带的pcap流媒体包。
转载别人博客里的写的:http://www.blogjava.net/amigoxie/archive/2010/07/21/326717.html

媒体包准备
          在测试过程中常常需要携带 RTP 流,此时需要有对应的 RTP 流文件, Sipp 安装目录 pcap 下有一些默认的 RTP 流文件,若不满足条件,也可以自行录制,录制好后,可在 wireshark 中过滤好需要的包后,点击“ Save As ”另存到 Sipp 安装目录 /pcap 目录。

RTP媒体分析  RTP媒体可分为两段,IAD>服务器;服务器>IAD  过滤RTP通过Invite或者200ok消息携带的rtp port字段  使用sip.Call-ID == "67410f21a1427a15" or udp.port == 8108过滤:

sipp官网refenence给的uac_pcap发送了一个g711a和DTMF的pcap_audio。
这个是自己模仿的:



SDP的属性(a)里的rtpmap要跟下面的PCAP PLAY对应上。
官方代码:
<?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">
  <!-- In client mode (sipp placing calls), the Call-ID MUST be         -->
  <!-- generated by sipp. To do so, use [call_id] keyword.                -->
  <!-- 没有加Allow    -->
  <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[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="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" 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: 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>

  <!-- Play a pre-recorded PCAP file (RTP stream)                       -->
  <nop>
    <action>
      <exec play_pcap_audio="pcap/g711a.pcap"/>
    </action>
  </nop>

  <!-- Pause 8 seconds, which is approximately the duration of the      -->
  <!-- PCAP file                                                        -->
  <pause milliseconds="8000"/>

  <!-- Play an out of band DTMF '1'                                     -->
  <nop>
    <action>
      <exec play_pcap_audio="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: 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>






invite tag

INVITE

tag=[call_number]这里的tag是自己随机生成的,而在To里面不带tag值


[peer_tag_param]

uac获取到uas的tag后使用[peer_tag_param]填入到To域中

注意:sipp使用时分号”;”不用写,[remote_port]>[peer_tag_param],虽然实际数据是需要分号的。


[Call-ID]从最初的INVITE到最后BYE结束通话,整个算同一个会话,所以这中间的其他请求(I帧请求和Session Timer更新也是包含在这个会话当中)和响应都是同一个Call-ID:

[Branch]初始INVITE、uas响应的100/422、uac的ACK确认是一个事务,Branch应该一样,这里ACK因为是对422(非2xx)响应的,所以Branch也一致


脚本部分

1. 响应消息间隔定义区,区分响应消息接受区间
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>

 定时器自定义区    该区域主要作用为:针对消息响应时长(ResponseTime)以及呼叫持续时长(CallLength)的Timer进行自定义间隔的配置,
以获取所需的显示范围。

标签

<send>消息发送
<recv>消息接收
<pause>暂停
<nop>媒体播放


 

通用属性: 

start_rtd 

启动响应定时器

 

<send start_rtd="invite

 > 

rtd 

停止响应定时器

 

<recv response=“200“ rtd=“invite“ /> 

repeat_rtd  

重复启用响应定时器

 

<recv response=“407”

rtd="invite" 

repeat_rtd="true“ /> 

crlf 

运行界面增加回车换行

 

<send crlf="true"> 

next 

跳转任意

label 

<recv response="403" optional="true" 

next=“reg_fail"> 

</recv> 

test 与 next一起使用,设置跳转条件

 

<send next="6" test=“flag1"> 

chance 与test、next一起使用,

当test结果有值时,则概率跳转

 

<recv response="403" optional="true" 

next=“reg_fail” test=“flag“

 chance="0.90"> 

 </recv> 

counter  

计数器累加

<recv response=“200”

counter=“SuccessCALL">

start_rtd 启动响应定时器
<send start_rtd="invite“ > rtd  停止响应定时器  
<recv response=“200”rtd=“invite“ />  

repeat_rtd  重复启用响应定时器
<recv response=“407”rtd="invite" repeat_rtd="true“ />

crlf 运行界面增加回车换行 <send crlf="true">  

next  跳转任意label  <recv response="403" optional="true" next=“reg_fail">
</recv>
test 与next一起使用,设置跳转条件  <send next="6" test=“flag1">

chance  与test、next一起使用,当test结果有值时,则概率跳转
<recv response="403" optional="true" next=“reg_fail” test=“flag“ chance="0.90">  
</recv>  

counter   计数器累加1  <recv response=“200”counter=“SuccessCALL">

犯的错误:
1:
[![CDATA[ 这中间不能夹注释,CDATA本来就表示 不应由 XML 解析器进行解析的文本数据。原封不动地传给加入后wireshark抓包显示sip提示。


2
大写小写,横杠划线下划线,空格都要注意。第一次写看的眼花。






REFERENCE:

1. http://blog.sina.com.cn/s/blog_4ceb322201000aig.html
2. https://www.cisco.com/c/zh_cn/support/docs/unified-communications/unified-border-element/200412-DTMF-Relay-and-Interworking-on-CUBE.html
3. http://www.cnblogs.com/lijingcheng/p/4454928.html
4. RFC1889 RTP: A Transport Protocol for Real-Time Applications
5. RFC2833 RTP Payload for DTMF Digits, Telephony Tones and Telephony Signals
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值