[Asterisk-code-review] testsuite: Added tests for correct packetization + review up... (testsuite[13])

Friendly Automation asteriskteam at digium.com
Tue Feb 5 08:17:28 CST 2019


Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/10557 )

Change subject: testsuite: Added tests for correct packetization + review update
......................................................................

testsuite: Added tests for correct packetization + review update

Added tests for transcode and a non transcode plus contrib/scripts
for verification
Also added the test directory to the pjsip tests.yaml

ASTERISK-28110 #close

Change-Id: I16cfb5805d2b96fdf5cdbc8f53a86522d1d251a7
---
A contrib/scripts/verify_codecs.pl
A contrib/scripts/verify_rtp_len.pl
A tests/channels/pjsip/rtp_ptime/non-transcode/configs/ast1/extensions.conf
A tests/channels/pjsip/rtp_ptime/non-transcode/configs/ast1/pjsip.conf
A tests/channels/pjsip/rtp_ptime/non-transcode/run-test
A tests/channels/pjsip/rtp_ptime/non-transcode/sipp/40msalaw.pcap
A tests/channels/pjsip/rtp_ptime/non-transcode/sipp/uac_asterisk.xml
A tests/channels/pjsip/rtp_ptime/non-transcode/sipp/uas_asterisk.xml
A tests/channels/pjsip/rtp_ptime/non-transcode/test-config.yaml
A tests/channels/pjsip/rtp_ptime/tests.yaml
A tests/channels/pjsip/rtp_ptime/transcode/configs/ast1/extensions.conf
A tests/channels/pjsip/rtp_ptime/transcode/configs/ast1/pjsip.conf
A tests/channels/pjsip/rtp_ptime/transcode/run-test
A tests/channels/pjsip/rtp_ptime/transcode/sipp/40msalaw.pcap
A tests/channels/pjsip/rtp_ptime/transcode/sipp/uac_asterisk.xml
A tests/channels/pjsip/rtp_ptime/transcode/sipp/uas_asterisk.xml
A tests/channels/pjsip/rtp_ptime/transcode/test-config.yaml
M tests/channels/pjsip/tests.yaml
18 files changed, 908 insertions(+), 0 deletions(-)

Approvals:
  Joshua C. Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/contrib/scripts/verify_codecs.pl b/contrib/scripts/verify_codecs.pl
new file mode 100644
index 0000000..5c00e60
--- /dev/null
+++ b/contrib/scripts/verify_codecs.pl
@@ -0,0 +1,109 @@
+#!/usr/bin/perl
+
+use strict;
+
+# This perl program parses an RTP dump file and looks for the codec
+# names provided on the command line in the RTM DUMP file, if none 
+# of the pref_codecs are found in RTP dump file, it exits with a status
+# code of 99 otherwise it will exit with a status code of 0
+
+# This perl program expects minium of two arguments on command line,
+# First argument is the name of RTP dump, second argument and so on
+# are the codec names to be searched in RTP dump file
+
+# Check the number of command lines arguments
+
+my $num_args = @ARGV;
+if ($num_args < 2)
+{
+	print "[VERIFY CODECS]Insufficient arguments\n";
+	exit(99);
+}
+else
+{
+	my $FILE_PTR;
+	my $bad_codec = 0;
+	my $lock_codec = 0;
+	my @pref_codecs = @ARGV[1..$num_args];
+	my $dump_file = $ARGV[0];
+        if (open(FILE_PTR,$dump_file))
+	{
+		my $count=0;
+		my $line;
+		my @lines;
+		my $dump_length=0;
+
+		# Read the dump file into arrat @lines 
+		@lines = <FILE_PTR>;
+		close FILE_PTR;
+		$dump_length = @lines;
+
+		# Process the dump file 
+		for ($count=0;$count<$dump_length;$count++)
+		{
+			$line = @lines[$count];
+			#Check for the payload type
+			if ($line =~ /.*pt=([0-9]+).*/)	
+			{
+				my $match=0;
+				#Check the payload type matched any of the expected
+				#payload types
+				if($lock_codec == 0)
+				{
+					#system settled down on desired codec
+					#make sure it keeps on that codec
+					if ($pref_codecs[0] eq $1)
+					{
+						$lock_codec=1;
+						$match=1;
+					}
+					else
+					{
+						foreach my $pref_codec (@pref_codecs)
+						{
+							if ($pref_codec eq $1)
+							{
+								$match=1;
+							}
+						}
+					}
+				}
+				elsif ($pref_codecs[0] eq $1)
+				{
+					$match=1;
+				}
+
+				if ($match == 0)
+				{
+					$bad_codec = 1;
+					last;
+				}
+
+					
+			}
+			
+		}
+
+
+		if ($bad_codec eq 1)
+		{
+			print "[VERIFY_CODECS] Unsupported codecs in dump file [$dump_file]\n";
+			exit(99);
+		}
+		elsif($lock_codec == 0)
+		{
+			print "[VERIFY_CODECS] Call never switched to preferred codec [$dump_file]\n";
+			exit(99);
+		}
+		else
+		{
+			exit(0);
+		}
+	}
+	else
+	{
+		print "[VERIFY_CODECS] Unable to open the dump file [$dump_file]\n";
+		exit(99);
+	}
+
+}
diff --git a/contrib/scripts/verify_rtp_len.pl b/contrib/scripts/verify_rtp_len.pl
new file mode 100755
index 0000000..50a45f3
--- /dev/null
+++ b/contrib/scripts/verify_rtp_len.pl
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+
+use strict;
+
+# This perl program parses an RTP dump file and looks for and verifies the RTP frame length len=xxx
+
+# Check the number of command lines arguments
+
+my $num_args = @ARGV;
+if ($num_args ne 2)
+{
+	print "[VERIFY RTP LEN] needs 2 arguments\n";
+	exit(99);
+}
+else
+{
+	my $ret=99;
+	my $dump_file = $ARGV[0];
+	my $len = $ARGV[1];
+    if (open(FILE_PTR,$dump_file)) {
+		my $count = 0;
+		my $line;
+		my @lines;
+		my $dump_length = 0;
+
+		# Read the dump file into array @lines
+		@lines = <FILE_PTR>;
+		close FILE_PTR;
+		$dump_length = @lines;
+
+		# Process the dump file
+		for ($count = 0; $count < $dump_length; $count++) {
+			$line = @lines[$count];
+			#Check for the payload type
+			if ($line =~ /.*len=([0-9]+).*/) {
+				if($1 ne $len) {
+					$ret = 99;
+					last;
+				} else {
+					$ret=0;
+				}
+			}
+		}
+	} else {
+		print("Failed to open dump file = $dump_file\n");
+		exit(99);
+	}
+	exit($ret);
+}
diff --git a/tests/channels/pjsip/rtp_ptime/non-transcode/configs/ast1/extensions.conf b/tests/channels/pjsip/rtp_ptime/non-transcode/configs/ast1/extensions.conf
new file mode 100644
index 0000000..ad7b155
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/non-transcode/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/channels/pjsip/rtp_ptime/non-transcode/configs/ast1/pjsip.conf b/tests/channels/pjsip/rtp_ptime/non-transcode/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..45d0b43
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/non-transcode/configs/ast1/pjsip.conf
@@ -0,0 +1,52 @@
+[global]
+type = global
+debug = yes
+
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[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
+disallow = all
+allow = alaw
+direct_media = no
+send_rpid = yes
+sdp_session = session
+aors = PEER_A
+use_ptime=yes
+
+[sbc]
+type = aor
+contact = sip:127.0.0.1:5700
+
+[sbc]
+type = endpoint
+disallow = all
+allow = alaw
+direct_media = no
+send_rpid = yes
+sdp_session = session
+aors = sbc
+use_ptime=yes
+
diff --git a/tests/channels/pjsip/rtp_ptime/non-transcode/run-test b/tests/channels/pjsip/rtp_ptime/non-transcode/run-test
new file mode 100755
index 0000000..9eb97d1
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/non-transcode/run-test
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+
+import sys
+import os
+import logging
+import signal
+import subprocess
+import time
+
+sys.path.append("lib/python")
+sys.path.append("utils")
+
+from twisted.internet import reactor
+from asterisk.sipp import SIPpTest
+
+WORKING_DIR = os.path.abspath(os.path.dirname(__file__))
+TEST_DIR = os.path.dirname(os.path.realpath(__file__))
+
+logger = logging.getLogger(__name__)
+e164 = "3200000000"
+sippA_logfile = WORKING_DIR + "/A_PARTY.log"
+sippA_errfile = WORKING_DIR + "/A_PARTY_ERR.log"
+sippB_logfile = WORKING_DIR + "/B_PARTY.log"
+sippB_errfile = WORKING_DIR + "/B_PARTY_ERR.log"
+dump_B = WORKING_DIR + "/codec_B.log"
+
+SIPP_SCENARIOS = [
+    {
+        'scenario' : 'uas_asterisk.xml',
+        '-i' : '127.0.0.1',
+        '-p' : '5700',
+        '-mp' : '6300',
+        '-message_file' : sippB_logfile,
+        '-error_file' : sippB_errfile,
+        '-trace_msg' : '-trace_err',
+    },
+    {
+        'scenario' : 'uac_asterisk.xml',
+        '-i' : '127.0.0.1',
+        '-p' : '5061',
+        '-s' : e164,
+        '-d' : '5000',
+        '-message_file' : sippA_logfile,
+        '-error_file' : sippA_errfile,
+        '-trace_msg' : '-trace_err',
+    }
+]
+
+def cleanup():
+    filelist = [ f for f in os.listdir(WORKING_DIR) if f.endswith(".log") ]
+    for f in filelist:
+        os.remove(os.path.join(WORKING_DIR, f))
+
+def main():
+
+    test = SIPpTest(WORKING_DIR, TEST_DIR, SIPP_SCENARIOS,test_config={'memcheck-delay-stop': 7})
+    test.reactor_timeout = 55;
+
+    # Run the RTPDUMP tool to capture the logs on B side
+    rtpdump = subprocess.Popen(["rtpdump", "-t","5", "-F","ascii","-o",dump_B, "127.0.0.1/8000"])
+
+    reactor.run()
+
+    # Kill the RTPDUMP, pass it the signal"
+    rtpdump.send_signal(signal.SIGINT)
+    rtpdump.wait()
+
+    ret_B = subprocess.call(["perl","contrib/scripts/verify_codecs.pl",dump_B ,"8"])
+    if (ret_B != 99):
+        ret_B = subprocess.call(["perl","contrib/scripts/verify_rtp_len.pl",dump_B ,"172"])
+    cleanup()
+    if(ret_B != 99):
+        return 0
+    else:
+        return 1
+
+if __name__ == "__main__":
+    sys.exit(main())
+
+
+# vim:sw=4:ts=4:expandtab:textwidth=79
diff --git a/tests/channels/pjsip/rtp_ptime/non-transcode/sipp/40msalaw.pcap b/tests/channels/pjsip/rtp_ptime/non-transcode/sipp/40msalaw.pcap
new file mode 100644
index 0000000..67356c5
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/non-transcode/sipp/40msalaw.pcap
Binary files differ
diff --git a/tests/channels/pjsip/rtp_ptime/non-transcode/sipp/uac_asterisk.xml b/tests/channels/pjsip/rtp_ptime/non-transcode/sipp/uac_asterisk.xml
new file mode 100644
index 0000000..f094815
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/non-transcode/sipp/uac_asterisk.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE scenario SYSTEM "testerlaptop.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 default 'uac' scenario.                       -->
+<!--                                                                    -->
+<scenario name="Basic Sipstone UAC">
+  <!-- In client mode (testerlaptop placing calls), the Call-ID MUST be         -->
+  <!-- generated by testerlaptop. To do so, use [call_id] keyword.                -->
+  <send retrans="500">
+    <![CDATA[
+
+      INVITE sip:[service]@[remote_ip] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From:  <sip:testerlaptop@[local_ip]:[local_port]>;tag=[call_number]
+      To: testerphone <sip:[service]@[remote_ip]>
+      Call-ID: [call_id]
+      CSeq: 1 INVITE
+      Contact: sip:testerlaptop@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Type: application/sdp
+      Content-Length: [len]
+
+      v=0
+      o=testerlaptop 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+      s=-
+      c=IN IP4 127.0.0.1
+      t=0 0
+      m=audio 9000 RTP/AVP 8
+      a=rtpmap:8 PCMA/8000 101
+      a=rtpmap:101 telephone-event/8000
+      a=ptime:40
+
+    ]]>
+  </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" rrs="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 [next_url] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: testerlaptop <sip:testerlaptop@[local_ip]:[local_port]>;tag=[call_number]
+      To: testerphone <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 1 ACK
+      Contact: sip:testerlaptop@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      [routes]
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <nop>
+    <action>
+	    <exec play_pcap_audio="./tests/channels/pjsip/rtp_ptime/non-transcode/sipp/40msalaw.pcap"/>
+    </action>
+  </nop>
+
+
+  <!-- This delay can be customized by the -d command-line option       -->
+  <!-- or by adding a 'milliseconds = "value"' option here.             -->
+  <pause milliseconds="5000" />
+
+
+  <!-- The 'crlf' option inserts a blank line in the statistics report. -->
+  <send retrans="500">
+    <![CDATA[
+
+      BYE [next_url] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: testerlaptop <sip:testerlaptop@[local_ip]:[local_port]>;tag=[call_number]
+      To: testerphone <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 2 BYE
+      Contact: sip:testerlaptop@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Length: 0
+      [routes]
+
+    ]]>
+  </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>
diff --git a/tests/channels/pjsip/rtp_ptime/non-transcode/sipp/uas_asterisk.xml b/tests/channels/pjsip/rtp_ptime/non-transcode/sipp/uas_asterisk.xml
new file mode 100644
index 0000000..8f6b0ae
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/non-transcode/sipp/uas_asterisk.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="rtp ptime problem">
+
+<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:testerlaptop@[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 IP4 127.0.0.1
+t=0 0
+m=audio 8000 RTP/AVP 8 103
+a=rtpmap:8 PCMA/8000
+a=rtpmap:103 telephone-event/8000
+a=ptime:20
+
+]]>
+</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/channels/pjsip/rtp_ptime/non-transcode/test-config.yaml b/tests/channels/pjsip/rtp_ptime/non-transcode/test-config.yaml
new file mode 100644
index 0000000..c515b53
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/non-transcode/test-config.yaml
@@ -0,0 +1,13 @@
+testinfo:
+    summary: 'Test that asterisk can convert 40ms audio in 20ms'
+    description: |
+        'When receiving 40ms audio verify that asterisk can convert it to 20m if customer requested'
+
+properties:
+    dependencies:
+        - app : 'sipp'
+        - app : 'rtpdump'
+        - app : 'perl'
+        - custom : 'rawsocket'
+    tags:
+        - PJSIP
diff --git a/tests/channels/pjsip/rtp_ptime/tests.yaml b/tests/channels/pjsip/rtp_ptime/tests.yaml
new file mode 100644
index 0000000..1186e84
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/tests.yaml
@@ -0,0 +1,4 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'transcode'
+    - test: 'non-transcode'
diff --git a/tests/channels/pjsip/rtp_ptime/transcode/configs/ast1/extensions.conf b/tests/channels/pjsip/rtp_ptime/transcode/configs/ast1/extensions.conf
new file mode 100644
index 0000000..ad7b155
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/transcode/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/channels/pjsip/rtp_ptime/transcode/configs/ast1/pjsip.conf b/tests/channels/pjsip/rtp_ptime/transcode/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..23d08bf
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/transcode/configs/ast1/pjsip.conf
@@ -0,0 +1,53 @@
+
+[global]
+type = global
+debug = yes
+
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[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
+disallow = all
+allow = alaw
+direct_media = no
+send_rpid = yes
+sdp_session = session
+aors = PEER_A
+use_ptime=yes
+
+[sbc]
+type = aor
+contact = sip:127.0.0.1:5700
+
+[sbc]
+type = endpoint
+disallow = all
+allow = ulaw
+direct_media = no
+send_rpid = yes
+sdp_session = session
+aors = sbc
+use_ptime=yes
+
diff --git a/tests/channels/pjsip/rtp_ptime/transcode/run-test b/tests/channels/pjsip/rtp_ptime/transcode/run-test
new file mode 100755
index 0000000..e17cb8d
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/transcode/run-test
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+
+import sys
+import os
+import logging
+import signal
+import subprocess
+import time
+
+sys.path.append("lib/python")
+sys.path.append("utils")
+
+from twisted.internet import reactor
+from asterisk.sipp import SIPpTest
+
+WORKING_DIR = os.path.abspath(os.path.dirname(__file__))
+TEST_DIR = os.path.dirname(os.path.realpath(__file__))
+
+logger = logging.getLogger(__name__)
+e164 = "3200000000"
+sippA_logfile = WORKING_DIR + "/A_PARTY.log"
+sippA_errfile = WORKING_DIR + "/A_PARTY_ERR.log"
+sippB_logfile = WORKING_DIR + "/B_PARTY.log"
+sippB_errfile = WORKING_DIR + "/B_PARTY_ERR.log"
+dump_B = WORKING_DIR + "/codec_B.log"
+
+SIPP_SCENARIOS = [
+    {
+        'scenario' : 'uas_asterisk.xml',
+        '-i' : '127.0.0.1',
+        '-p' : '5700',
+        '-mp' : '6300',
+        '-message_file' : sippB_logfile,
+        '-error_file' : sippB_errfile,
+        '-trace_msg' : '-trace_err',
+    },
+    {
+        'scenario' : 'uac_asterisk.xml',
+        '-i' : '127.0.0.1',
+        '-p' : '5061',
+        '-s' : e164,
+        '-d' : '5000',
+        '-message_file' : sippA_logfile,
+        '-error_file' : sippA_errfile,
+        '-trace_msg' : '-trace_err',
+    }
+]
+
+def cleanup():
+    filelist = [ f for f in os.listdir(WORKING_DIR) if f.endswith(".log") ]
+    for f in filelist:
+        os.remove(os.path.join(WORKING_DIR, f))
+
+def main():
+    test = SIPpTest(WORKING_DIR, TEST_DIR, SIPP_SCENARIOS,test_config={'memcheck-delay-stop':7})
+    test.reactor_timeout = 55;
+
+    # Run the RTPDUMP tool to capture the logs on B side
+    rtpdump = subprocess.Popen(["rtpdump", "-t","5", "-F","ascii","-o",dump_B, "127.0.0.1/8000"])
+
+    reactor.run()
+
+    # Kill the RTPDUMP, pass it the signal"
+    rtpdump.send_signal(signal.SIGINT)
+    rtpdump.wait()
+    
+    ret_B = subprocess.call(["perl","contrib/scripts/verify_codecs.pl",dump_B ,"0"])
+    if (ret_B != 99):
+        ret_B = subprocess.call(["perl","contrib/scripts/verify_rtp_len.pl",dump_B ,"172"])
+    cleanup()
+    if(ret_B != 99):
+        return 0
+    else:
+        return 1
+
+if __name__ == "__main__":
+    sys.exit(main())
+
+
+# vim:sw=4:ts=4:expandtab:textwidth=79
diff --git a/tests/channels/pjsip/rtp_ptime/transcode/sipp/40msalaw.pcap b/tests/channels/pjsip/rtp_ptime/transcode/sipp/40msalaw.pcap
new file mode 100644
index 0000000..67356c5
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/transcode/sipp/40msalaw.pcap
Binary files differ
diff --git a/tests/channels/pjsip/rtp_ptime/transcode/sipp/uac_asterisk.xml b/tests/channels/pjsip/rtp_ptime/transcode/sipp/uac_asterisk.xml
new file mode 100644
index 0000000..46aa8dc
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/transcode/sipp/uac_asterisk.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE scenario SYSTEM "testerlaptop.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 default 'uac' scenario.                       -->
+<!--                                                                    -->
+<scenario name="Basic Sipstone UAC">
+  <!-- In client mode (testerlaptop placing calls), the Call-ID MUST be         -->
+  <!-- generated by testerlaptop. To do so, use [call_id] keyword.                -->
+  <send retrans="500">
+    <![CDATA[
+
+      INVITE sip:[service]@[remote_ip] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From:  <sip:testerlaptop@[local_ip]:[local_port]>;tag=[call_number]
+      To: testerphone <sip:[service]@[remote_ip]>
+      Call-ID: [call_id]
+      CSeq: 1 INVITE
+      Contact: sip:testerlaptop@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Type: application/sdp
+      Content-Length: [len]
+
+      v=0
+      o=testerlaptop 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+      s=-
+      c=IN IP4 127.0.0.1
+      t=0 0
+      m=audio 9000 RTP/AVP 8
+      a=rtpmap:8 PCMA/8000 101
+      a=rtpmap:101 telephone-event/8000
+      a=ptime:40
+
+    ]]>
+  </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" rrs="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 [next_url] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: testerlaptop <sip:testerlaptop@[local_ip]:[local_port]>;tag=[call_number]
+      To: testerphone <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 1 ACK
+      Contact: sip:testerlaptop@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      [routes]
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <nop>
+    <action>
+	    <exec play_pcap_audio="./tests/channels/pjsip/rtp_ptime/transcode/sipp/40msalaw.pcap"/>
+    </action>
+  </nop>
+
+
+  <!-- This delay can be customized by the -d command-line option       -->
+  <!-- or by adding a 'milliseconds = "value"' option here.             -->
+  <pause milliseconds="5000" />
+
+
+  <!-- The 'crlf' option inserts a blank line in the statistics report. -->
+  <send retrans="500">
+    <![CDATA[
+
+      BYE [next_url] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: testerlaptop <sip:testerlaptop@[local_ip]:[local_port]>;tag=[call_number]
+      To: testerphone <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 2 BYE
+      Contact: sip:testerlaptop@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Length: 0
+      [routes]
+
+    ]]>
+  </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>
diff --git a/tests/channels/pjsip/rtp_ptime/transcode/sipp/uas_asterisk.xml b/tests/channels/pjsip/rtp_ptime/transcode/sipp/uas_asterisk.xml
new file mode 100644
index 0000000..283f398
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/transcode/sipp/uas_asterisk.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="rtp ptime problem">
+
+<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:testerlaptop@[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 IP4 127.0.0.1
+t=0 0
+m=audio 8000 RTP/AVP 0
+a=rtpmap:0 PCMU/8000
+a=rtpmap:103 telephone-event/8000
+a=ptime:20
+
+]]>
+</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/channels/pjsip/rtp_ptime/transcode/test-config.yaml b/tests/channels/pjsip/rtp_ptime/transcode/test-config.yaml
new file mode 100644
index 0000000..e53d3e4
--- /dev/null
+++ b/tests/channels/pjsip/rtp_ptime/transcode/test-config.yaml
@@ -0,0 +1,14 @@
+testinfo:
+    summary: 'Test that asterisk can convert 40ms audio in 20ms'
+    description: |
+        'When receiving 40ms audio verify that asterisk can convert it to 20m if customer requested'
+
+properties:
+    minversion: '1.4'
+    dependencies:
+        - app : 'sipp'
+        - app : 'rtpdump'
+        - app : 'perl'
+        - custom : 'rawsocket'
+    tags:
+        - SIP
diff --git a/tests/channels/pjsip/tests.yaml b/tests/channels/pjsip/tests.yaml
index 56d500f..4af6223 100644
--- a/tests/channels/pjsip/tests.yaml
+++ b/tests/channels/pjsip/tests.yaml
@@ -26,6 +26,7 @@
     - dir: 'ice'
     - dir: 'use_callerid_contact'
     - dir: 'connected_line'
+    - dir: 'rtp_ptime'
     - test: 'accountcode'
     - test: 'acl_call'
     - test: 'allow_overlap'

-- 
To view, visit https://gerrit.asterisk.org/10557
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I16cfb5805d2b96fdf5cdbc8f53a86522d1d251a7
Gerrit-Change-Number: 10557
Gerrit-PatchSet: 3
Gerrit-Owner: Robert Cripps <rcripps at voxbone.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Friendly Automation (1000185)
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua C. Colp <jcolp at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190205/3cad957d/attachment-0001.html>


More information about the asterisk-code-review mailing list