[Home]

Summary:ASTERISK-29433: res_rtp_asterisk: Server reflexive candidates use incorrect raddr for RTCP
Reporter:Chris (ccasterisk)Labels:patch
Date Opened:2021-05-18 03:12:49Date Closed:2021-05-26 10:26:29
Priority:MajorRegression?
Status:Closed/CompleteComponents:Resources/res_rtp_asterisk
Versions:16.17.0 18.4.0 Frequency of
Occurrence
Frequent
Related
Issues:
Environment:Attachments:( 0) ASTERISK-29433.diff
( 1) no_audio_reproduction.zip
Description:Frequently our field-testers are complaining about missing audio and video.

After troubleshooting with the developer of our client SIP stack (AmSip/OSip2) we came to the conclusion that the root-cause is in Asterisk.

In the cases where no audio (or video) is received, it seems that Asterisk is sending the media packets to the wrong port.

See our engineer's detailed network analysis below.
_________________________________
FIRST OBSERVATION
_________________________________
From asterisk_tcpdump.cap
packet 1243: asterisk (192.168.1.2) makes a STUN BINDING REQUEST from port 14429
packet 1251: asterisk receive an answer MAPPED-ADDRESS: 78.22.132.194:14429

This means the packet was received by stun server from the NAT IP 78.22.132.194 AND NAT PORT 14429
This means the NAT has forwarded the packet **without** changing the PORT. (NAT are often changing port)

This means the candidate should be:
a=candidate:S4e1684c2 2 UDP 1694498814 78.22.132.194 14429 typ srflx raddr 192.168.1.2 rport 14429\r\n

But it appears in SDP as:
a=candidate:S4e1684c2 2 UDP 1694498814 78.22.132.194 14429 typ srflx raddr 192.168.1.2 rport 14428\r\n

CONCLUSION: THIS IS AN ERROR FROM ASTERISK

_________________________________
SECOND OBSERVATION
_________________________________
Let's look at iphone_tcpdump.pcap  "with filter (udp.port == 12600) && (ip.addr == 192.168.1.2)"

We can see many packets being sent to 192.168.1.2:14428, but nothing received. I guess
this is expected.


Let's look at asterisk_tcpdump.pcap  "with filter udp.port == 14428 && ip.addr == 192.168.0.201"

packet 1529: We can see a a bind request being sent  + a retransmission
The request is sent FROM 192.168.1.2 from port 14428 to 192.168.0.201on port 12601
The request TID is :Message Transaction ID: 0e5c00008d4ca0783b1a7b48

Then, asterisk receive a response:
packet 1538 is the symmetric response. It contains a XOR-MAPPED-ADDRESS: 192.168.0.145:14428
This response has been built from amsip.
This response is coming from 192.168.0.201from PORT 12601

Let's look  iphone_tcpdump.pcap if we can find this request + answer:
Let's use the filter "(udp.port == 12601) && (ip.addr == 192.168.0.145 && udp.port == 14428)"

The packet 721 is matching the request. It's coming on RTCP port (12601) but comes from the RTP port (14428)
The packet 723 is correct and match the response

amsip has correct processing: amsip understand this is coming to the RTCP port and establish the RTCP connection.

Unfortunately, asterisk has sent the packet from port 14428 instead and this is NOT CORRECT.


____________________
FINAL CONCLUSION
______________________
Asterisk has sent packet 1529 from the wrong port.

The fact that asterisk is using the wrong port (14428) in the RTCP candidate has no impact, but still it's WRONG.

There was no NAT issue.
Comments:By: Asterisk Team (asteriskteam) 2021-05-18 03:12:55.265-0500

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: Chris (ccasterisk) 2021-05-18 03:15:11.001-0500

This file contains:
- Pcap taken at Asterisk host
- Pcap taken at mobile-phone side
- phone/amsip logs
- asterisk logs

By: Joshua C. Colp (jcolp) 2021-05-18 04:07:28.044-0500

Severity is severity to the project and the user base as a whole, not to your specific deployment. In this case there are no other reported issues so far with this, if that changes then it can be increased. Additionally severity doesn't generally impact time to resolution except for certain situations so if you're expecting the fact it is Major to alter that, it is unlikely to.

By: Joshua C. Colp (jcolp) 2021-05-18 04:12:03.889-0500

Attached is a patch which fixes the port in the ICE candidate. I don't know what impact that would have had on the pjnath ICE implementation, but it may have caused it not to send the STUN packets.

By: Chris (ccasterisk) 2021-05-18 04:19:44.488-0500

Thanks Joshua.

We are currently testing with more debugging added .
I'll keep you posted.


By: Chris (ccasterisk) 2021-05-19 02:50:23.716-0500

Developer testing on 2 sites no longer shows the issue after applying the patch.

We've merged it in our weekly-build that will be handed over to the validation team for wider testing.
Once I have the results I will post the feedback here.


By: Chris (ccasterisk) 2021-05-20 07:45:07.656-0500

Issue seems resolved now. Thanks for the patch.
NOTE: While testing a new TURN issue was found. See new ticket ASTERISK-29438

By: Joshua C. Colp (jcolp) 2021-05-20 07:51:06.392-0500

I receive an email for every action that occurs on JIRA. That issue will be triaged, it is unlikely I will look at it personally.

By: Friendly Automation (friendly-automation) 2021-05-26 10:26:30.579-0500

Change 15913 merged by Friendly Automation:
res_rtp_asterisk: Set correct raddr port on RTCP srflx candidates.

[https://gerrit.asterisk.org/c/asterisk/+/15913|https://gerrit.asterisk.org/c/asterisk/+/15913]

By: Friendly Automation (friendly-automation) 2021-05-26 10:35:21.330-0500

Change 15897 merged by George Joseph:
res_rtp_asterisk: Set correct raddr port on RTCP srflx candidates.

[https://gerrit.asterisk.org/c/asterisk/+/15897|https://gerrit.asterisk.org/c/asterisk/+/15897]

By: Friendly Automation (friendly-automation) 2021-05-26 10:35:46.884-0500

Change 15914 merged by George Joseph:
res_rtp_asterisk: Set correct raddr port on RTCP srflx candidates.

[https://gerrit.asterisk.org/c/asterisk/+/15914|https://gerrit.asterisk.org/c/asterisk/+/15914]