SIPp之播放rtp語音/視頻流

歡迎大家轉載,爲保留作者成果,轉載請註明出處,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
 print?
  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
 print?
  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
 print?
  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 ----------------  


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章