【转载】SIPp之播放rtp语音/视频流

来源:互联网 发布:apache tomcat怎么用 编辑:程序博客网 时间:2024/06/05 09:13

欢迎大家转载,为保留作者成果,转载请注明出处,http://blog.csdn.net/netluoriver,有些文件在资源中也可以下载!如果你没有积分,可以联系我!


经过多天的努力,用脚本呼叫eyebeem电话,在电话端终于听到录制的语音包了,费话不多说,描述环境:

192.168.0.20是一个有注册认证的SIP服务器,服务器端口为5060;
192.168.0.101是我在windows安装的cygwin软件后测试机器;
branchc1.xml 中的50000 呼叫 eyebeem号码50010
sipp版本: SIPp v3.2-TLS-PCAP, version unknown, built Jul 17 2013, 21:50:11

user.csv脚本:
[html] view plain copy
 
 
  1. SEQUENTIAL  
  2. 50000;50010;[authentication username=50000 password=50000]  



流程如下:
                              
    REGISTER ----------> SIP_server     
         401 <---------- SIP_server       
    REGISTER ----------> SIP_server        
         200 <---------- SIP_server        
      INVITE ----------> SIP_server       
         407 <---------- SIP_server       
         ACK ----------> SIP_server       
      INVITE ----------> SIP_server -- INVITE--------->50010(eyebeem)     
         100 <---------- SIP_server---100 <---------- 50010(eyebeem)  
         180 <---------- SIP_server---180 <---------- 50010(eyebeem)    
         200 <---------- SIP_server---200 <---------- 50010(eyebeem)
         ACK ----------> SIP_server---ACK ---------->50010(eyebeem) 
       -----------RTP语音流(wireshark抓的语音包G711u.pcap)-----------
       Pause [    50.0s]      
         BYE ---------->       
         200 <----------       

脚本如下:
[html] view plain copy
 
 
  1. <?xml version="1.0" encoding="ISO-8859-1" ?>  
  2. <!DOCTYPE scenario SYSTEM "sipp.dtd">  
  3.   
  4. <!-- This program is free software; you can redistribute it and/or  -->  
  5. <!-- modify it under the terms of the GNU General Public License as -->  
  6. <!-- published by the Free Software Foundation; either version 2 of the-->  
  7. <!-- License, or (at your option) any later version.            -->  
  8. <!--                                                            -->  
  9. <!-- This program is distributed in the hope that it will be useful, -->  
  10. <!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->  
  11. <!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -->  
  12. <!-- GNU General Public License for more details.                -->  
  13. <!--                                                            -->  
  14. <!-- You should have received a copy of the GNU General Public License-->  
  15. <!-- along with this program; if not, write to the              -->  
  16. <!-- Free Software Foundation, Inc.,                            -->  
  17. <!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA     -->  
  18. <!--                                                           -->  
  19. <!--                 Sipp default 'branchc' scenario.          -->  
  20. <!--                                                           -->  
  21. <!-- 首先发送SIP注册消息,Register。里面的From与To是注册的号码  -->  
  22. <scenario name="branch_client">  
  23.   <send retrans="500">  
  24.     <![CDATA[ 
  25.   
  26.       REGISTER sip:[remote_ip] SIP/2.0 
  27.       Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] 
  28.       From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number];rport 
  29.       To: [field0] <sip:[field0]@[remote_ip]:[remote_port]> 
  30.       Call-ID: [call_id] 
  31.       CSeq: 1 REGISTER 
  32.       Contact: sip:[field0]@[local_ip]:[local_port] 
  33.       Content-Length: 0 
  34.       Expires: 300 
  35.     ]]>  
  36.   </send>  
  37.   
  38.   <recv response="100" ptional="true">  
  39.   </recv>  
  40.   
  41.   <!--  SIPp会收到来自AST要求验证的401 消息体,Recv意思为Receive,接收到来自AST的401要求验证的消息,Next为如果收到401,那么转至Label为1的地方进行操作 -->  
  42.   <recv response="401" auth="true" next="1">  
  43.   </recv>  
  44.   
  45.   <!--  send invite with authentication messages -->  
  46.   <!--  开始发送Register消息,里面将把验证的密码消息发送给对方,在消息体里面是抓不到密码消息的,而且已经被md5方式加密过。-->  
  47.   
  48.   <label id="1"/>  
  49.   <send retrans="500">  
  50.     <![CDATA[ 
  51.   
  52.       REGISTER sip:[field0]@[remote_ip]:[remote_port] SIP/2.0 
  53.       Via: SIP/2.0/[transport] [local_ip]:[local_port] 
  54.       From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number];rport 
  55.       To: [field0] <sip:[field0]@[remote_ip]:[remote_port]> 
  56.       Call-ID: [call_id] 
  57.       CSeq: 2 REGISTER 
  58.       Contact: sip:[field0]@[local_ip]:[local_port] 
  59.       [field2] 
  60.       Content-Length: [len] 
  61.       Expires: 3600 
  62.     ]]>  
  63.   </send>  
  64.   
  65.   <recv response="100" ptional="true">  
  66.   </recv>  
  67.   
  68.   <!--   收到来自AST的200 ACK消息后,系统转至等待1000ms,或者可以直接去掉该设置 -->  
  69.   
  70.   <recv response="200"  next="2">  
  71.   </recv>  
  72.   
  73.   <label id="2"/>  
  74.   <pause milliseconds="1000"/>  
  75.    
  76.    
  77.   <send retrans="500">  
  78.     <![CDATA[ 
  79.  
  80.       INVITE sip:[field1]@[remote_ip]:[remote_port] SIP/2.0 
  81.       Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] 
  82.       From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number] 
  83.       To: [field1] <sip:[field1]@[remote_ip]:[remote_port]> 
  84.       Call-ID: [call_id] 
  85.       CSeq: 1 INVITE 
  86.       Contact: sip:[field0]@[local_ip]:[local_port] 
  87.       Max-Forwards: 70 
  88.       Subject: Performance Test 
  89.       Content-Type: application/sdp 
  90.       Content-Length: [len] 
  91.  
  92.        v=0 
  93.       o=[local_ip] 53655765 2353687637 IN IP[local_ip_type] [local_ip] 
  94.       s=- 
  95.       c=IN IP[local_ip_type] [local_ip] 
  96.       t=0 0 
  97.       m=audio [auto_media_port] RTP/AVP 8 0 101 
  98.       a=rtpmap:8 PCMA/8000 
  99.       a=rtpmap:0 PCMU/8000 
  100.       a=rtpmap:101 telephone-event/8000 
  101.       a=fmtp:101 0-16 
  102.       a=recvonly 
  103.     ]]>  
  104.   </send>  
  105.   
  106.   <recv response="407" auth="true">  
  107.   </recv>  
  108.   
  109.   <!-- By adding rrs="true" (Record Route Sets), the route sets    -->  
  110.   <!-- are saved and used for following messages sent. Useful to test-->  
  111.   <!-- against stateful SIP proxies/B2BUAs.                     -->  
  112.   <!-- Packet lost can be simulated in any send/recv message by  -->  
  113.   <!-- by adding the 'lost = "10"'. Value can be [1-100] percent.-->  
  114.   <send>  
  115.     <![CDATA[ 
  116.  
  117.       ACK sip:[field1]@[remote_ip]:[remote_port] SIP/2.0 
  118.       Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] 
  119.       From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number] 
  120.       To: [field1] <sip:[field1]@[remote_ip]:[remote_port]>[peer_tag_param] 
  121.       Call-ID: [call_id] 
  122.       CSeq: 1 ACK 
  123.       Contact: sip:[field0]@[local_ip]:[local_port] 
  124.       Max-Forwards: 70 
  125.       Subject: Performance Test 
  126.       Content-Length: 0 
  127.     ]]>  
  128.   </send>  
  129.   
  130.   <send retrans="500">  
  131.     <![CDATA[ 
  132.  
  133.       INVITE sip:[field1]@[remote_ip]:[remote_port] SIP/2.0 
  134.       Via: SIP/2.0/[transport] [local_ip]:[local_port] 
  135.       From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number] 
  136.       To: [field1] <sip:[field1]@[remote_ip]:[remote_port]> 
  137.       Call-ID: [call_id] 
  138.       CSeq: 2 INVITE 
  139.       Contact: sip:[field0]@[local_ip]:[local_port] 
  140.       [field2] 
  141.       Max-Forwards: 70 
  142.       Subject: Performance Test 
  143.       Content-Type: application/sdp 
  144.       Content-Length: [len] 
  145.  
  146.        v=0 
  147.       o=[local_ip] 53655765 2353687637 IN IP[local_ip_type] [local_ip] 
  148.       s=- 
  149.       c=IN IP[local_ip_type] [local_ip] 
  150.       t=0 0 
  151.       m=audio [auto_media_port] RTP/AVP 8 0 101 
  152.       a=rtpmap:8 PCMA/8000 
  153.       a=rtpmap:0 PCMU/8000 
  154.       a=rtpmap:101 telephone-event/8000 
  155.       a=fmtp:101 0-16 
  156.       a=recvonly 
  157.     ]]>  
  158.   </send>  
  159.   
  160.   <recv response="100" ptional="true">  
  161.   </recv>  
  162.   
  163.   <recv response="183" ptional="true">  
  164.   </recv>  
  165.   
  166.   <recv response="180" ptional="true">  
  167.   </recv>  
  168.   
  169.   <recv response="200" rtd="true">  
  170.   </recv>  
  171.   
  172.   <!-- Packet lost can be simulated in any send/recv message by -->  
  173.   <!-- by adding the 'lost = "10"'. Value can be [1-100] percent. -->  
  174.   <send>  
  175.     <![CDATA[ 
  176.  
  177.       ACK sip:[field1]@[remote_ip]:[remote_port] SIP/2.0 
  178.       Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] 
  179.       From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number] 
  180.       To: [field1] <sip:[field1]@[remote_ip]:[remote_port]>[peer_tag_param] 
  181.       Call-ID: [call_id] 
  182.       CSeq: 2 ACK 
  183.       Contact: sip:[field0]@[local_ip]:[local_port] 
  184.       Max-Forwards: 70 
  185.       Subject: Performance Test 
  186.       Content-Length: 0 
  187.     ]]>  
  188.   </send>  
  189.   
  190.   <!-- Play a pre-recorded PCAP file (RTP stream)           -->  
  191.   <nop>  
  192.     <action>  
  193.       <exec play_pcap_audio="pcap/G711u.pcap"/>  
  194.     </action>  
  195.   </nop>  
  196.   
  197.   
  198.   <!-- Pause 8 seconds, which is approximately the duration of the-->  
  199.   <!-- PCAP file                                            -->  
  200.   <pause milliseconds="50000"/>  
  201.   
  202.    
  203.   <!-- The 'crlf' option inserts a blank line in the statistics report.-->  
  204.   <send retrans="500">  
  205.     <![CDATA[ 
  206.  
  207.       BYE sip:[field1]@[remote_ip]:[remote_port] SIP/2.0 
  208.       Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] 
  209.       From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number] 
  210.       To: [field1] <sip:[field1]@[remote_ip]:[remote_port]>[peer_tag_param] 
  211.       Call-ID: [call_id] 
  212.       CSeq: 2 BYE 
  213.       Contact: sip:[field0]@[local_ip]:[local_port] 
  214.       Max-Forwards: 70 
  215.       Subject: Performance Test 
  216.       Content-Length: 0 
  217.     ]]>  
  218.   </send>  
  219.   
  220.   <recv response="200" crlf="true">  
  221.   </recv>  
  222.   
  223.  <pause milliseconds="5000"/>  
  224.   
  225.   
  226.   <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>  
  227.   
  228.   <!-- definition of the call length repartition table (unit is ms)     -->  
  229.   
  230.   <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>  
  231. </scenario>  



     
执行结果如下:

[html] view plain copy
 
 
  1. $ sipp -r 1 -i 192.168.0.102 -l 1 -sf branchc1.xml -inf user.csv 192.168.0.20  
  2. prepare_pcap.c: Ignoring non UDP packet!  
  3. In pcap pcap/G711u.pcap, npkts 3789  
  4. max pkt length 180  
  5. base port 10546  
  6. Warning: open file limit > FD_SETSIZE; limiting max.  
  7. # of open files to FD_SETSIZE = 64  
  8.        Resolving remote host '192.168.0.20'... Done.  
  9. ----------------------- Scenario Screen -------- [1-9]: Change Screen --  
  10.   Call-rate(length)   Port   Total-time  Total-calls  Remote-host  
  11.    1.0(0 ms)/1.000s   5060     144.66 s            3  192.168.0.20:5060(UDP)  
  12.   
  13.   0 new calls during 21.408 s period     1 ms scheduler resolution  
  14.   1 calls (limit 1)                      Peak was 1 calls, after 1 s  
  15.   0 Running, 0 Paused, 0 Woken up  
  16.   0 dead call msg (discarded)            1 out-of-call msg (discarded)  
  17.   3 open sockets  
  18.   7809 Total RTP pckts sent              0.000 last period RTP rate (kB/s)  
  19.   
  20.                                  Messages  Retrans   Timeout   Unexpected-Msg  
  21.     REGISTER ---------->         3         0         0  
  22.          100 <----------         0         0         0         0  
  23.          401 <----------         3         0         0         0  
  24.     REGISTER ---------->         3         0         0  
  25.          100 <----------         0         0         0         0  
  26.          200 <----------         3         0         0         0  
  27.        Pause [   1000ms]         3                             0  
  28.       INVITE ---------->         3         0         0  
  29.          407 <----------         3         0         0         0  
  30.          ACK ---------->         3         0  
  31.       INVITE ---------->         3         0         0  
  32.          100 <----------         3         0         0         0  
  33.          183 <----------         0         0         0         0  
  34.          180 <----------         3         0         0         0  
  35.          200 <----------  E-RTD1 3         0         0         0  
  36.          ACK ---------->         3         0  
  37.               [ NOP ]  
  38.        Pause [    50.0s]         3                             0  
  39.          BYE ---------->         2         0         0  
  40.          200 <----------         2         0         0         0  
  41.   
  42.        Pause [   5000ms]         2                             0  
  43. --------------------------- Test Terminated -----------------  
  44.   
  45.   
  46. ------------- Statistics Screen ------- [1-9]: Change Screen--  
  47.        Start Time             | 2013-07-25   20:20:35:856    1374754835.856243  
  48.   Last Reset Time        | 2013-07-25   20:22:39:148    1374754959.148399  
  49.       Current Time           | 2013-07-25   20:23:00:557    1374754980.557117  
  50. -------------------------+---------------------------+--------  
  51.           Counter Name           | Periodic value            |     Cumulative value  
  52. -------------------------+---------------------------+---------  
  53.           Elapsed Time           | 00:00:21:408              | 00:02:24:700  
  54.              Call Rate              |    0.000 cps              |    0.021 cps  
  55. -------------------------+---------------------------+-------  
  56.   Incoming call created  |        0                  |        0  
  57.   OutGoing call created  |        0                  |        3  
  58.      Total Call created     |                           |        3  
  59.             Current Call           |        1                  |  
  60. -------------------------+---------------------------+----------  
  61.          Successful call        |        0                  |        2  
  62.              Failed call            |        0                  |        0  
  63. -------------------------+---------------------------+---------  
  64.         Response Time 1        | 00:00:00:000              | 00:00:03:336  
  65.             Call Length            | 00:00:05:113              | 00:00:40:770  
  66. ------------------------------ Test Terminated ----------------  
阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 伞兵 第一伞兵队 地狱伞兵 星船伞兵 伞兵魂 伞兵队 supreme伞兵 512伞兵真实死亡 伞兵打一成语 odst地狱伞兵拉克丝为什么非卖 地狱伞兵拉克丝 小伞兵和小刺猬 法国外籍军团第2伞兵团 军运会跳伞 军运会跳伞比赛时间 雨夜带刀不带伞作品集 夜雨带刀不带伞作品集 雨夜带刀不带伞作品 雨夜带刀不带伞第一版 雨夜带刀不带伞全部作品 雨天带刀不带伞全部作品 雨夜带刀不带伞警母 雨夜带刀不带伞经典作品 雨夜带刀不带伞所有作品 雨夜带刀不带伞作品目录 雨夜带刀不带伞作品txt 雨夜带伞不带刀 雨夜带刀不带伞林婉儿 夜雨带刀不带伞 伞刀 第二精品版主雨夜带刀不带伞 李彤彤雨夜不带伞带刀 圣女母亲雨夜带刀不带伞 摩托车伞 室外遮阳伞厂家 输卵管伞端上举图片 幼儿伞车 我在古代当县令 伞杉 撑伞女子背影古风图 千机伞十三形态图 蘑菇伞小兔天晴4幅图看图说话