[asterisk-commits] res/res pjsip t38 add test to verify T.38 gets quickly rejected (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 14 07:45:12 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5901 )

Change subject: res/res_pjsip_t38 add test to verify T.38 gets quickly rejected
......................................................................

res/res_pjsip_t38 add test to verify T.38 gets quickly rejected

this test makes sure asterisk rejects the call quickly when the
B leg has T.38 disabled

Change-Id: Ida087c3d410c95c87aeca506c81eabe8bde062ef
---
A tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.pl
A tests/fax/pjsip/t38_fast_reject/configs/ast1/extensions.conf
A tests/fax/pjsip/t38_fast_reject/configs/ast1/pjsip.conf
A tests/fax/pjsip/t38_fast_reject/run-test
A tests/fax/pjsip/t38_fast_reject/sipp/A_PARTY.xml
A tests/fax/pjsip/t38_fast_reject/sipp/B_PARTY.xml
A tests/fax/pjsip/t38_fast_reject/test-config.yaml
M tests/fax/pjsip/tests.yaml
8 files changed, 492 insertions(+), 0 deletions(-)

Approvals:
  Joshua Colp: Verified
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.pl b/tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.pl
new file mode 100644
index 0000000..1744aef
--- /dev/null
+++ b/tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.pl
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+use strict;
+use Text::CSV;
+use Data::Dumper;
+
+my $filename = $ARGV[0];
+open(my $fh, '<:utf8', $filename)
+    or die "Can't open $filename: $!";
+
+my $csv = Text::CSV->new({sep_char => ';'})
+    or die "Text::CSV error: " . Text::CSV->error_diag;
+
+my $header = <$fh>; 
+# define column names    
+$csv->parse($header);
+$csv->column_names([$csv->fields]);
+
+my $ret = 0;
+# parse the rest
+while (my $row = $csv->getline_hr($fh)) {
+    if (!defined  $row->{'ResponseTimereinvite(P)'} ) {
+	    print "column not found! make sure scenario is correct!\n";
+	    $ret = -1;
+	    last;
+    }
+ 
+    my $pkey = $row->{'ResponseTimereinvite(P)'};
+    my ($hour, $minute, $second, $msec) = split(/:/, $pkey);
+    $minute += $hour*60;
+    $second += $minute*60;
+    $msec += $second * 1000;
+    
+    if ($msec > 500) {
+	    print "Slow 488 Rejection detected ($msec)!\n";
+	    $ret = -2;
+	    last;
+    }
+}
+
+$csv->eof or $csv->error_diag;
+close $fh;
+
+exit $ret;
diff --git a/tests/fax/pjsip/t38_fast_reject/configs/ast1/extensions.conf b/tests/fax/pjsip/t38_fast_reject/configs/ast1/extensions.conf
new file mode 100644
index 0000000..ad7b155
--- /dev/null
+++ b/tests/fax/pjsip/t38_fast_reject/configs/ast1/extensions.conf
@@ -0,0 +1,11 @@
+[general]
+static=yes
+writeprotect=yes
+autofallthrough=yes
+clearglobalvars=no
+priorityjumping=yes
+
+[globals]
+
+[default]
+exten => _X.,1,Dial(pjsip/sbc,180)
diff --git a/tests/fax/pjsip/t38_fast_reject/configs/ast1/pjsip.conf b/tests/fax/pjsip/t38_fast_reject/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..280e204
--- /dev/null
+++ b/tests/fax/pjsip/t38_fast_reject/configs/ast1/pjsip.conf
@@ -0,0 +1,81 @@
+;--
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+Non mapped elements start
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+[general]
+sipdebug = yes
+
+[PEER_A]
+port = 5061
+
+[sbc]
+port = 5700
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+Non mapped elements end
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+--;
+
+
+[global]
+type = global
+debug = yes
+
+[transport-udp6]
+type = transport
+protocol = udp
+bind = [::]:5060
+
+[transport-udp]
+type = transport
+protocol = udp
+bind = 0.0.0.0:5060
+
+[PEER_A]
+type = aor
+contact = sip:127.0.0.1:5061
+
+[PEER_A]
+type = identify
+endpoint = PEER_A
+match = 127.0.0.1
+
+[PEER_A]
+type = endpoint
+context = default
+dtmf_mode = rfc4733
+disallow = all
+allow = alaw
+allow = ulaw
+allow = g729
+allow = h263p
+allow = h264
+direct_media = no
+send_rpid = yes
+sdp_session = session
+aors = PEER_A
+t38_udptl = yes
+t38_udptl_ec = none
+
+[sbc]
+type = aor
+contact = sip:127.0.0.1:5700
+
+[sbc]
+type = endpoint
+context = callcontrol
+dtmf_mode = rfc4733
+disallow = all
+allow = alaw
+allow = ulaw
+allow = g729
+allow = h263p
+allow = h264
+direct_media = no
+send_rpid = yes
+sdp_session = session
+aors = sbc
+t38_udptl = no
+t38_udptl_ec = none
+
diff --git a/tests/fax/pjsip/t38_fast_reject/run-test b/tests/fax/pjsip/t38_fast_reject/run-test
new file mode 100644
index 0000000..a93ef43
--- /dev/null
+++ b/tests/fax/pjsip/t38_fast_reject/run-test
@@ -0,0 +1,103 @@
+#!/usr/bin/env python
+# vim: sw=3 et:
+'''
+Copyright (C) 2017, Voxbone, SA
+Torrey Searle <torrey at voxbone.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import os
+import re
+import shutil
+import logging
+import signal
+import subprocess
+import time
+
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+sys.path.append("utils")
+from asterisk.asterisk import Asterisk
+from asterisk.sipp import SIPpTest
+
+logger = logging.getLogger(__name__)
+WORKING_DIR = os.path.abspath(os.path.dirname(__file__))
+TEST_DIR = os.path.dirname(os.path.realpath(__file__))
+
+e164 = "3200000000"
+sippA_logfile = WORKING_DIR + "/A_PARTY.log"
+sippA_errfile = WORKING_DIR + "/A_PARTY_ERR.log"
+sippA_statfile = WORKING_DIR + "/A_PARTY_STAT.log"
+
+sippB_logfile = WORKING_DIR + "/B_PARTY.log"
+sippB_errfile = WORKING_DIR + "/B_PARTY_ERR.log"
+
+SIPP_SCENARIOS = [
+    {
+        'scenario' : 'B_PARTY.xml',
+        '-i' : '127.0.0.1',
+        '-p' : '5700',
+        '-message_file' : sippB_logfile,
+        '-error_file' : sippB_errfile,
+        '-trace_msg' : '-trace_err',
+    },
+    {
+        'scenario' : 'A_PARTY.xml',
+        '-i' : '127.0.0.1',
+        '-p' : '5061',
+        '-s' : e164,
+        '-message_file' : sippA_logfile,
+        '-error_file' : sippA_errfile,
+        '-trace_msg' : '-trace_err',
+        '-trace_stat' : '-trace_stat',
+        '-stf' : sippA_statfile,
+    }
+]
+
+def main():
+    test = SIPpTest(WORKING_DIR, TEST_DIR, SIPP_SCENARIOS)
+    logger.info ("Running against asterisk version %s" %test.ast_version)
+		   
+    test.reactor_timeout = 100;
+
+    dump_A = WORKING_DIR + "/carrier_rtp.log"
+    dump_B = WORKING_DIR + "/customer_rtp.log"
+    rtpdump_A = subprocess.Popen(["rtpdump", "-t","5", "-F","ascii","-d","101","-o",dump_A, "127.0.0.1/9000"])
+    rtpdump_B = subprocess.Popen(["rtpdump", "-t","5", "-F","ascii","-d","101","-o",dump_B, "127.0.0.1/8000"])
+
+    time.sleep(10) #Wait 10 seconds to ensure that all the sockets are open before running the test	
+
+    reactor.run()
+
+    # Kill the RTPDUMP, pass it the signal"
+    rtpdump_A.send_signal(signal.SIGINT)	
+    rtpdump_A.wait()
+    rtpdump_B.send_signal(signal.SIGINT)	
+    rtpdump_B.wait()
+
+    #Verify that audio packets were routed in both directions after G711 fallback
+    if (os.path.getsize(dump_B) == 0):
+    	logger.error("No RTP routed towards customer ...failing the test")
+	return 1
+    if (os.path.getsize(dump_A) == 0):
+    	logger.error("No RTP routed towards carrier ...failing the test")
+	return 1
+
+    if not test.passed:
+        return 1
+
+    ret_A = subprocess.call([WORKING_DIR + "/check_reinvite_rtt.pl", WORKING_DIR+"/A_PARTY_STAT.log"])
+
+    if (ret_A != 0):
+	    logger.debug("Slow ReInvite Detected!")
+	    return 1
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)
+
diff --git a/tests/fax/pjsip/t38_fast_reject/sipp/A_PARTY.xml b/tests/fax/pjsip/t38_fast_reject/sipp/A_PARTY.xml
new file mode 100644
index 0000000..118d2f9
--- /dev/null
+++ b/tests/fax/pjsip/t38_fast_reject/sipp/A_PARTY.xml
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="T38 REINVTE">
+  <send retrans="500">
+    <![CDATA[
+
+      INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
+      From: <sip:390415094280@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+      To: <sip:[service]@[remote_ip]:[remote_port]>
+      Call-ID: [call_id]
+      Supported: rel1xx,timer,replaces
+      Min-SE:  181
+      User-Agent: Cisco-SIPGateway/IOS-12.x
+      Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, COMET, REFER, SUBSCRIBE, NOTIFY, INFO, UPDATE, REGISTER
+      CSeq: 101 INVITE
+      Max-Forwards: 69
+      Contact: <sip:390415094280@[local_ip]:[local_port]>
+      Expires: 180
+      Allow-Events: telephone-event
+      Content-Type: application/sdp
+      Content-Length: [len]
+      
+      v=0
+      o=CiscoSystemsSIP-GW-UserAgent 9624 5279 IN IP4 [local_ip]
+      s=SIP Call
+      c=IN IP4 [media_ip]
+      t=0 0
+      m=audio 9000 RTP/AVP 0 18 101
+      c=IN IP[local_ip_type] [local_ip]
+      a=rtpmap:101 telephone-event/101
+
+    ]]>
+  </send>
+
+  <recv response="100">
+  </recv>
+
+  <recv response="100" optional="true">
+  </recv>
+
+  <recv response="100" optional="true">
+  </recv>
+
+  <recv response="180" optional="true">
+  </recv>
+  <recv response="183" optional="true">
+  </recv>
+
+  <recv response="200" rrs="true">
+    <action>
+    	<ereg regexp="[[:punct:]](.*)[[:punct:]]" search_in="hdr" header="Contact:" check_it="true" assign_to="6,1" />
+    	<ereg regexp=".*" search_in="hdr" header="From:" check_it="true" assign_to="2" />
+    	<ereg regexp=".*" search_in="hdr" header="To:" check_it="true" assign_to="3" />
+    	<log message="Log to avoid the problem of not using $6 [$6]"/>
+    </action>
+  </recv>
+
+  <send>
+    <![CDATA[
+
+      ACK [next_url] SIP/2.0
+      [routes]
+      Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
+      From: [$2]
+      To: [$3]
+      Call-ID: [call_id]
+      Max-Forwards: 69
+      CSeq: 101 ACK
+      Content-Length: [len]
+
+    ]]>
+  </send>
+
+
+  <!--Send the T38 REINVITE -->
+  <send retrans="500" start_rtd="reinvite">
+    <![CDATA[
+
+      INVITE [$1] SIP/2.0
+      Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
+      From: [$2]
+      To: [$3]
+      Call-ID: [call_id]
+      User-Agent: Cisco-SIPGateway/IOS-12.x
+      CSeq: 102 INVITE
+      Max-Forwards: 69
+      Contact: <sip:390415094280@[local_ip]:[local_port]>
+      Allow-Events: telephone-event
+      Content-Type: application/sdp
+      Content-Length: [len]
+            
+      v=0
+      o=CiscoSystemsSIP-GW-UserAgent 9624 5280 IN IP4 [local_ip]
+      s=Asterisk PBX 1.6.2.0
+      c=IN IP[local_ip_type] [local_ip]
+      t=0 0
+      m=image 4389 udptl t38
+      a=T38FaxVersion:0
+      a=T38MaxBitRate:14400
+      a=T38FaxRateManagement:transferredTCF
+      a=T38FaxMaxDatagram:1400
+      a=T38FaxUdpEC:t38UDPRedundancy
+
+    ]]>
+  </send>
+
+  <recv response="100" optional="true">
+  </recv>
+
+  <recv response="488" rtd="reinvite" crlf="true">
+  </recv>
+
+  <send>
+  <![CDATA[
+
+  ACK [$1] SIP/2.0
+  Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+  [last_Call-ID:]
+  From: [$2]
+  To: [$3]
+  CSeq: 102 ACK
+  Max-Forwards: 69
+  Content-Length: 0
+
+  ]]>
+  </send>
+
+  <pause milliseconds="50000" />
+
+  <send retrans="500">
+    <![CDATA[
+
+      BYE [$1] SIP/2.0
+      Via: SIP/2.0/UDP [local_ip]:[local_port];branch=[branch]
+      From: [$2]
+      To: [$3]
+      Call-ID: [call_id]
+      User-Agent: Cisco-SIPGateway/IOS-12.x
+      Max-Forwards: 69
+      CSeq: 104 BYE
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <recv response="200">
+  </recv>
+
+
+</scenario>
+
diff --git a/tests/fax/pjsip/t38_fast_reject/sipp/B_PARTY.xml b/tests/fax/pjsip/t38_fast_reject/sipp/B_PARTY.xml
new file mode 100644
index 0000000..3262911
--- /dev/null
+++ b/tests/fax/pjsip/t38_fast_reject/sipp/B_PARTY.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="T38 REINVITE">
+
+<recv request="INVITE" crlf="true" rrs="true">
+</recv>
+
+
+
+<send>
+<![CDATA[
+
+SIP/2.0 100 Trying
+[last_Via:]
+[last_Call-ID:]
+[last_From:]
+[last_To:]
+[last_CSeq:]
+Content-Length: 0
+
+]]>
+</send>
+
+<send retrans="500">
+<![CDATA[
+
+SIP/2.0 200 OK
+[last_Via:]
+[last_Call-ID:]
+[last_From:]
+[last_To:];tag=[call_number]
+[last_CSeq:]
+[last_Record-Route]
+Contact: <sip:bansallaptop@[local_ip]:[local_port];user=phone>
+Content-Type: application/sdp
+Content-Length: [len]
+
+v=0
+o=HuaweiSoftX3000 6644052 6644052 IN IP[local_ip_type] [local_ip]
+s=Sip Call
+c=IN IP[media_ip_type] [media_ip]
+t=0 0
+m=audio 8000 RTP/AVP 0 100 101
+a=rtpmap:0 PCMU/8000
+a=rtpmap:100 NSE/8000
+a=rtpmap:101 telephone-event/101
+
+]]>
+</send>
+
+<recv request="ACK"
+      rtd="true"
+      crlf="true">
+</recv>
+
+<recv request="BYE">
+</recv>
+
+<send>
+    <![CDATA[
+
+      SIP/2.0 200 OK
+      [last_Via:]
+      [last_From:]
+      [last_To:]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+      Content-Length: 0
+
+    ]]>
+</send>
+
+<!-- Keep the call open for a while in case the 200 is lost to be     -->
+<!-- able to retransmit it if we receive the BYE again.               -->
+<pause milliseconds="4000"/>
+
+
+<!-- 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>
+
diff --git a/tests/fax/pjsip/t38_fast_reject/test-config.yaml b/tests/fax/pjsip/t38_fast_reject/test-config.yaml
new file mode 100644
index 0000000..64b4883
--- /dev/null
+++ b/tests/fax/pjsip/t38_fast_reject/test-config.yaml
@@ -0,0 +1,13 @@
+testinfo:
+    summary: 'Test that asterisk does not drop the call after it rejects the T38 reinvite from the carrier side because customer does not suport it.  It also makes sure that the rejection happends quickly'
+    description: |
+        'Test that asterisk does not drop the call after it rejects the T38 reinvite from the carrier side because customer does not suport it.  I also measures the 488 response time and make sure it happends quckly'
+
+properties:
+    minversion: '13.16.0'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+
+    tags:
+        - PJSIP
diff --git a/tests/fax/pjsip/tests.yaml b/tests/fax/pjsip/tests.yaml
index a7e8bda..3edf0c2 100644
--- a/tests/fax/pjsip/tests.yaml
+++ b/tests/fax/pjsip/tests.yaml
@@ -6,3 +6,4 @@
     - test: 'directmedia_reinvite_t38'
     - test: 'gateway_t38_g711'
     - test: 'gateway_native_t38'
+    - test: 't38_fast_reject'

-- 
To view, visit https://gerrit.asterisk.org/5901
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ida087c3d410c95c87aeca506c81eabe8bde062ef
Gerrit-Change-Number: 5901
Gerrit-PatchSet: 4
Gerrit-Owner: Torrey Searle <tsearle at gmail.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20170714/c7684a3e/attachment-0001.html>


More information about the asterisk-commits mailing list