[Home]

Summary:ASTERISK-29276: stun: Implementation causes delay and does not work in all network topologies.
Reporter:Chris (ccasterisk)Labels:
Date Opened:2021-02-03 02:25:09.000-0600Date Closed:
Priority:MajorRegression?No
Status:Open/NewComponents:Resources/res_rtp_asterisk
Versions:16.16.0 Frequency of
Occurrence
Related
Issues:
is related toASTERISK-29507 STUN timeout is silently delaying calls
Environment:Attachments:
Description:Despite of the documentation here https://wiki.asterisk.org/wiki/display/~jcolp/ICE,+STUN,+and+TURN+Support Asterisk does *not* implement this RFC rfc5389. Id rather implements RFC https://tools.ietf.org/html/rfc3489 which is known for it's design flaws.

{quote}
However, experience since the publication
  of RFC 3489 has found that classic STUN simply does not work
  sufficiently well to be a deployable solution.  The address and port
  learned through classic STUN are sometimes usable for communications
  with a peer, and sometimes not.  Classic STUN provided no way to
  discover whether it would, in fact, work or not, and it provided no
  remedy in cases where it did not.  Furthermore, classic STUN's
  algorithm for classification of NAT types was found to be faulty, as
  many NATs did not fit cleanly into the types defined there.

{quote}

The current rfc3489 implementation in stun.c also has serious flaws. E.g. it always waits for 3 seconds before doing a retry.
This means, if the UDP packet is dropped, you immediately have a delay of 3 seconds before the call starts.
{quote}
/* Wait for response. */
{
struct pollfd pfds = { .fd = s, .events = POLLIN };
int ms;

//** Reduce to < 200MS
ms = ast_remaining_ms(start, 3000);
if (ms <= 0) {
/* No response, timeout */
res = 1;
continue;
}
res = ast_poll(&pfds, 1, ms);
if (res < 0) {
/* Error */
continue;
}
if (!res) {
/* No response, timeout */
res = 1;
continue;
}
}
{quote}

What should be improved :

- Implement RFC rfc5389 or use 3rd party STUN library (pjsip ?)
- Improve wait-loop in stun.c
- Update the docs reflecting correct RFC
Comments:By: Asterisk Team (asteriskteam) 2021-02-03 02:25:15.745-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: Joshua C. Colp (jcolp) 2021-02-03 03:26:20.457-0600

The documentation you actually reference isn't documentation. It's in my personal space, which is a dumping ground of stuff. I think I was just randomly writing that doc at one point in time, but never really finished/moved it around and such. I've restricted my personal space to remove confusion.

By: Chris (ccasterisk) 2021-02-03 08:37:32.860-0600

Okay thanks for the update.

I also would like to mention that, if 'icesupport' is enabled in rtp.conf the delay above *blocks* the processing of the dialplan in extensions.conf until the STUN server is resolved or it times out.
So it's not specifically the SIP channel that is delayed, it's the complete dialplan that blocks.

By: Chris (ccasterisk) 2021-02-10 04:16:03.745-0600

Update about field-usage:  If the installation is without Internet connection all *local LAN calls* are also delayed with 3 seconds.


By: Joshua C. Colp (jcolp) 2021-07-05 14:44:21.681-0500

There is also no warning or error message when this occurs currently.