[Home]

Summary:ASTERISK-30337: res_pjsip_sdp_rtp: RTP not read before negotiation completes
Reporter:Alex Hermann (gaaf)Labels:
Date Opened:2022-12-01 09:59:45.000-0600Date Closed:
Priority:MinorRegression?No
Status:Open/NewComponents:Channels/chan_pjsip Core/RTP Resources/res_pjsip_sdp_rtp Resources/res_rtp_asterisk
Versions:13.38.3 20.0.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Debian Sid with packaged Asterisk 1:20.0.0~dfsg+~cs6.12.40431414-2.Attachments:( 0) media-before-sdp-1.log
( 1) media-before-sdp-1.pcap
( 2) uas-media-without-sdp.xml
Description:When RTP is received from an UAS before the UAS has sent an SDP answer, that RTP is sent to the caller in a single burst after the SDP answer  is received.

Asterisk seems to open the port where RTP is to be received, but never actually reads from the socket until SDP is received. If the UAS sends RTP at this time, it gets queued by the OS. When SDP finally arrives, *all* RTP queued by the OS is read as fast as possible by Asterisk, resulting in a burst of forwarded RTP to the caller.

RFC 3264 says:
bq. Once the offerer has sent the offer, it MUST be prepared to receive media for any recvonly streams described by that offer. It MUST be prepared to send and receive media for any sendrecv streams in the offer,

So, I think this means that Asterisk should not only open the RTP port, but also read from it directly. I don't care much if the RTP that arrived before the SDP gets dropped or forwarded, although the latter seems the proper behavior.

The issue with forwarding in a burst, is that there are some devices in the wild that seem to have an unlimited (jitter)buffer and buffer _all_ received RTP and play/relay it according to the RTP timestamps. This means that, because of this bug, all audio gets delayed by the time between first RTP and reception of SDP, which often equals the ringtime, which may well be in the tens of seconds.

I'll attach Asterisk log and a pcap illustrating the issue and a sipp script to reproduce it.

I can reliably reproduce this on Asterisk 13.38+ and 20.0. I did not try intermediate versions.
Comments:By: Asterisk Team (asteriskteam) 2022-12-01 09:59:46.909-0600

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. Please note that log messages and other files should not be sent to the Sangoma Asterisk Team unless explicitly asked for. All files should be placed on this issue in a sanitized fashion as needed.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

Please note that by submitting data, code, or documentation to Sangoma through JIRA, you accept the Terms of Use present at [https://www.asterisk.org/terms-of-use/|https://www.asterisk.org/terms-of-use/].

By: Alex Hermann (gaaf) 2022-12-01 10:01:38.734-0600

RTP is sent directly after the 180 Ringing (16:23:27)
Asterisk starts forwarding RTP in a burst after receiving the 200 OK (16:30:30)

By: Alex Hermann (gaaf) 2022-12-01 10:07:06.941-0600

UAS starts sending RTP directly after sending a 180 Ringing (without SDP) from packet 8 onward.

Asterisk starts forwarding all buffered RTP after receiving a 200 OK (with SDP). RTP is sent in a burst from packet 158 onward.

By: Alex Hermann (gaaf) 2022-12-01 10:15:28.800-0600

To reproduce:

# Provide a _media.wav_ file with audio in G.711 codec.
# Start this SIPp script
# Bridge call from Asterisk to it