[Asterisk-code-review] pjsip: Don't drop call when new SSRC and format are received. (testsuite[17])

Friendly Automation asteriskteam at digium.com
Tue Mar 10 13:44:26 CDT 2020


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/testsuite/+/13922 )

Change subject: pjsip: Don't drop call when new SSRC and format are received.
......................................................................

pjsip: Don't drop call when new SSRC and format are received.

If the SSRC of a received RTP packet differed from the previous SSRC
an SSRC change control frame would be queued ahead of the media
frame. In the case of audio this would result in the format of the
audio frame not being checked, and if it differed or was not allowed
then it could cause the call to drop due to failure to set up a
translation path. This test reproduces this scenario and ensures that
the call is not dropped but instead the media is ignored.

ASTERISK-28759

Change-Id: If3e760a7bb94c9bfc1ee24aff7f5fd7a3cbd33ed
---
A tests/channels/pjsip/non_negotiated_frame_SSRC_change/configs/ast1/extensions.conf
A tests/channels/pjsip/non_negotiated_frame_SSRC_change/configs/ast1/pjsip.conf
A tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/A_party_g711a.pcap
A tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/g711a.pcap
A tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/ssrc1.pcap
A tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/ssrc2.pcap
A tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/uac_g719_g711.xml
A tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/uas_asterisk.xml
A tests/channels/pjsip/non_negotiated_frame_SSRC_change/test-config.yaml
M tests/channels/pjsip/tests.yaml
10 files changed, 369 insertions(+), 0 deletions(-)

Approvals:
  Joshua 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/tests/channels/pjsip/non_negotiated_frame_SSRC_change/configs/ast1/extensions.conf b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/configs/ast1/extensions.conf
new file mode 100644
index 0000000..ad7b155
--- /dev/null
+++ b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/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/non_negotiated_frame_SSRC_change/configs/ast1/pjsip.conf b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..6ef2143
--- /dev/null
+++ b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/configs/ast1/pjsip.conf
@@ -0,0 +1,80 @@
+;--
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+Non mapped elements start
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+[general]
+sipdebug = yes
+
+[PEER_A]
+port = 5061
+
+[sbc]
+port = 5700
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+Non mapped elements end
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+--;
+
+
+[global]
+type = global
+user_agent = Callcontrol
+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
+direct_media = no
+send_rpid = yes
+sdp_session = session
+dtls_verify = no
+aors = PEER_A
+t38_udptl = yes
+t38_udptl_ec = redundancy
+asymmetric_rtp_codec = no
+
+[sbc]
+type = aor
+contact = sip:127.0.0.1:5700
+
+[sbc]
+type = endpoint
+context = callcontrol
+dtmf_mode = rfc4733
+disallow = all
+allow = alaw
+direct_media = no
+send_rpid = yes
+sdp_session = session
+dtls_verify = no
+dtls_rekey = 300
+dtls_cipher = ALL
+aors = sbc
+t38_udptl = yes
+t38_udptl_ec = redundancy
+asymmetric_rtp_codec = no
+
diff --git a/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/A_party_g711a.pcap b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/A_party_g711a.pcap
new file mode 100644
index 0000000..ba96dc6
--- /dev/null
+++ b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/A_party_g711a.pcap
Binary files differ
diff --git a/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/g711a.pcap b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/g711a.pcap
new file mode 100644
index 0000000..bafea38
--- /dev/null
+++ b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/g711a.pcap
Binary files differ
diff --git a/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/ssrc1.pcap b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/ssrc1.pcap
new file mode 100644
index 0000000..913dc79
--- /dev/null
+++ b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/ssrc1.pcap
Binary files differ
diff --git a/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/ssrc2.pcap b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/ssrc2.pcap
new file mode 100644
index 0000000..b248f20
--- /dev/null
+++ b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/ssrc2.pcap
Binary files differ
diff --git a/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/uac_g719_g711.xml b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/uac_g719_g711.xml
new file mode 100644
index 0000000..b819563
--- /dev/null
+++ b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/uac_g719_g711.xml
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE scenario SYSTEM "bansallaptop.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 (bansallaptop placing calls), the Call-ID MUST be         -->
+  <!-- generated by bansallaptop. 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:bansallaptop@[local_ip]:[local_port]>;tag=[call_number]
+      To: bansalphone <sip:[service]@[remote_ip]>
+      Call-ID: [call_id]
+      CSeq: 1 INVITE
+      Contact: sip:bansallaptop@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Type: application/sdp
+      Content-Length: [len]
+
+      v=0
+      o=bansallaptop 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+      s=-
+      c=IN IP4 127.0.0.1
+      t=0 0
+      m=audio [media_port] RTP/AVP 116 107 8 111 110 13
+      a=sendrecv
+      a=ptime:20
+      a=rtpmap:116 AMR-WB/16000/1
+      a=fmtp:116 mode-change-capability=2
+      a=rtpmap:107 AMR-WB/16000/1
+      a=fmtp:107 octet-align=1; mode-change-capability=2
+      a=rtpmap:8 PCMA/8000
+      a=rtpmap:111 telephone-event/16000
+      a=rtpmap:110 telephone-event/8000
+      a=rtpmap:13 CN/8000
+      a=fmtp:111 0-15
+      a=fmtp:111 0-15
+
+    ]]>
+  </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: bansallaptop <sip:bansallaptop@[local_ip]:[local_port]>;tag=[call_number]
+      To: bansalphone <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 1 ACK
+      Contact: sip:bansallaptop@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      [routes]
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <pause milliseconds="40"/>
+
+  <nop>
+    <action>
+	    <exec play_pcap_audio="tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/ssrc1.pcap"/>
+    </action>
+  </nop>
+  <pause milliseconds="40"/>
+  <nop>
+    <action>
+	    <exec play_pcap_audio="tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/ssrc2.pcap"/>
+    </action>
+  </nop>
+  <pause milliseconds="40"/>
+
+ <nop>
+    <action>
+	    <exec play_pcap_audio="tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/A_party_g711a.pcap"/>
+    </action>
+  </nop>
+
+  <pause milliseconds="3000"/>
+
+    <!-- This delay can be customized by the -d command-line option       -->
+  <!-- or by adding a 'milliseconds = "value"' option here.             -->
+  <pause/>
+
+  <!-- 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: bansallaptop <sip:bansallaptop@[local_ip]:[local_port]>;tag=[call_number]
+      To: bansalphone <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 2 BYE
+      Contact: sip:bansallaptop@[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/non_negotiated_frame_SSRC_change/sipp/uas_asterisk.xml b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/uas_asterisk.xml
new file mode 100644
index 0000000..657bcbb
--- /dev/null
+++ b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/uas_asterisk.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Re-Invite problem 1">
+
+<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 IP4 127.0.0.1
+t=0 0
+m=audio 9000 RTP/AVP 8 103
+a=rtpmap:8 PCMA/8000
+a=rtpmap:103 telephone-event/8000
+
+]]>
+</send>
+
+<recv request="ACK"
+      rtd="true"
+      crlf="true">
+</recv>
+
+<pause milliseconds="40"/>
+
+  <nop>
+    <action>
+	    <exec play_pcap_audio="tests/channels/pjsip/non_negotiated_frame_SSRC_change/sipp/g711a.pcap"/>
+    </action>
+  </nop>
+  <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/non_negotiated_frame_SSRC_change/test-config.yaml b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/test-config.yaml
new file mode 100644
index 0000000..2e4a598
--- /dev/null
+++ b/tests/channels/pjsip/non_negotiated_frame_SSRC_change/test-config.yaml
@@ -0,0 +1,32 @@
+testinfo:
+    summary: 'Ensure call is not terminated when frame with new SSRC and format is received'
+    description: |
+         'If the SSRC of a received RTP packet differed from the previous SSRC
+          an SSRC change control frame would be queued ahead of the media
+          frame. In the case of audio this would result in the format of the
+          audio frame not being checked, and if it differed or was not allowed
+          then it could cause the call to drop due to failure to set up a
+          translation path. This test reproduces this scenario and ensures that
+          the call is not dropped but instead the media is ignored.'
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    memcheck-delay-stop: 7
+    fail-on-any: True
+    test-iterations:
+        -
+            scenarios:
+                - { 'key-args': { 'scenario': 'uas_asterisk.xml', '-i': '127.0.0.1', '-p': '5700'} }
+                - { 'key-args': { 'scenario': 'uac_g719_g711.xml', '-i': '127.0.0.1', '-p': '5061', '-s': '3200000000', '-d': '20000', '-mp': '6000'} }
+
+properties:
+    dependencies:
+        - sipp :
+             version : 'v3.0'
+        - asterisk : 'res_pjsip'
+    tags:
+        - pjsip
diff --git a/tests/channels/pjsip/tests.yaml b/tests/channels/pjsip/tests.yaml
index 0635552..ebfb81c 100644
--- a/tests/channels/pjsip/tests.yaml
+++ b/tests/channels/pjsip/tests.yaml
@@ -59,3 +59,4 @@
     - test: 'dtmf_info_fallback'
     - test: 'invalid_uris'
     - test: 'moh_passthru_inactive'
+    - test: 'non_negotiated_frame_SSRC_change'

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

Gerrit-Project: testsuite
Gerrit-Branch: 17
Gerrit-Change-Id: If3e760a7bb94c9bfc1ee24aff7f5fd7a3cbd33ed
Gerrit-Change-Number: 13922
Gerrit-PatchSet: 1
Gerrit-Owner: Paulo Vicentini <paulo.vicentini at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200310/e58e0031/attachment-0001.html>


More information about the asterisk-code-review mailing list