[Home]

Summary:ASTERISK-17750: DTMF transmission does not meet the recommendations of the rfc2833(4733).
Reporter:Mike Danilenko (muhlik)Labels:
Date Opened:2011-04-25 08:51:17Date Closed:2012-09-27 12:00:11
Priority:MinorRegression?Yes
Status:Closed/CompleteComponents:Core/RTP
Versions:1.8.3 Frequency of
Occurrence
Constant
Related
Issues:
duplicatesASTERISK-20295 Asterisk is not incrementing the sequence numbers for the retransmission of the DTMF end packets(RTPEvent packet with end bit set to 1)
Environment:Attachments:( 0) issue17750-rtp-seqnum-trunk361279.diff
( 1) RTP_RCF2833_end_seqno.patch
Description:According to rfc4733:
{code}
Network Working Group                                     H. Schulzrinne
Request for Comments: 4733                                   Columbia U.
Obsoletes: 2833                                                T. Taylor
Category: Standards Track                                         Nortel
                                                          December 2006
2.5.1.6.  RTP Sequence Number

  The RTP sequence number MUST be incremented by one in each successive
  RTP packet sent.  Incrementing applies to retransmitted as well as
  initial instances of event reports, to permit the receiver to detect
  lost packets for RTP Control Protocol (RTCP) receiver reports.
{code}

We can see in res_rtp_asterisk.c
{code}
644: static int ast_rtp_dtmf_end_with_duration(struct ast_rtp_instance *instance, char digit, unsigned int duration)
...
692: for (i = 0; i < 3; i++) {
693: res = rtp_sendto(instance, (void *) rtpheader, hdrlen + 4, 0, &remote_address);
694: if (res < 0) {
695: ast_log(LOG_ERROR, "RTP Transmission error to %s: %s\n",
696: ast_sockaddr_stringify(&remote_address),
strerror(errno));
698: }
699: if (rtp_debug_test_addr(&remote_address)) {
700: ast_verbose("Sent RTP DTMF packet to %s (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
701:    ast_sockaddr_stringify(&remote_address),
702:    rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
703: }
704: }
{code}

in this function rtp->seqno++ is absent

In 1.6.2.17.3 version * in file rtp.c:
{code}
3295: int ast_rtp_senddigit_end_with_duration(struct ast_rtp *rtp, char digit, unsigned int duration)
...
3336: for (i = 0; i < 3; i++) {
3337: rtpheader[0] = htonl((2 << 30) | (rtp->send_payload << 16) | (rtp->seqno));
3338: res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them));
3339: rtp->seqno++;
3340: if (res < 0)
3341: ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n",
3342: ast_inet_ntoa(rtp->them.sin_addr),
3343: ntohs(rtp->them.sin_port), strerror(errno));
3344: if (rtp_debug_test_addr(&rtp->them))
3345: ast_verbose("Sent RTP DTMF packet to %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
3346:    ast_inet_ntoa(rtp->them.sin_addr),
3347:    ntohs(rtp->them.sin_port), rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
3348: }
{code}
Some SIP-gateway work incorrectly in this situation. If you are using Dial() with option D(some_number), SIP-gateway taking only the first tone.

****** ADDITIONAL INFORMATION ******

This problem is similar to:
ASTERISK-12308 (https://issues.asterisk.org/view.php?id=12983)
and apply to 1.8.3.2, 1.8.4 and may be to all 1.8.x versions
Comments:By: Mike Danilenko (muhlik) 2011-04-26 08:47:58

my patch:

--- res/res_rtp_asterisk.c 2010-10-06 08:35:51.000000000 +0400
+++ res/res_rtp_asterisk.c 2011-04-26 17:39:55.237263918 +0400
@@ -686,10 +686,10 @@
rtpheader[2] = htonl(rtp->ssrc);
rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (rtp->send_duration));
rtpheader[3] |= htonl((1 << 23));
- rtpheader[0] = htonl((2 << 30) | (rtp->send_payload << 16) | (rtp->seqno));

/* Send it 3 times, that's the magical number */
for (i = 0; i < 3; i++) {
+ rtpheader[0] = htonl((2 << 30) | (rtp->send_payload << 16) | (rtp->seqno));
res = rtp_sendto(instance, (void *) rtpheader, hdrlen + 4, 0, &remote_address);
if (res < 0) {
ast_log(LOG_ERROR, "RTP Transmission error to %s: %s\n",
@@ -701,6 +701,7 @@
   ast_sockaddr_stringify(&remote_address),
   rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
}
+ rtp->seqno++;
}

/* Oh and we can't forget to turn off the stuff that says we are sending DTMF */

By: Igor Goncharovsky (igorg) 2012-04-06 03:02:21.977-0500

Confirmed, this issue exists in 1.8, 10 and trunk. Patch for current trunk attached.

By: Filip Frank (frenk77) 2012-06-22 02:14:41.832-0500

I have a same problem, if i fix it DTMF works well now. I attached my patch, but is similar as patch from Mike. I must past it here because add attachment writes me some license problem.


--- res_rtp_asterisk.c  2012-06-21 13:41:34.780470962 +0200
+++ res_rtp_asterisk.c  2012-06-21 20:54:15.530623741 +0200
@@ -802,6 +802,8 @@
                                   ast_sockaddr_stringify(&remote_address),
                                   rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
               }
+               rtp->seqno++;
+               rtpheader[0] = htonl((2 << 30) | (rtp->send_payload << 16) | (rtp->seqno));
       }

       /* Oh and we can't forget to turn off the stuff that says we are sending DTMF */


By: Jan ńĆervenka (schod) 2012-06-22 03:38:12.980-0500

Hi,

I tested Filip's patch on Asterisk 1.8.13.0 and it solved my problem with DTMF.

Thx

By: David Woolley (davidw) 2012-06-22 04:29:07.572-0500

Patches must be attached and you must first have agreed to the licence terms.  You are granting Digium permission to use the patch in their commercial products, which you do by following the Sign a Licence Agreement link, at the top of the web page.  Unless you submit the patch as an attachment, with a valid licence grant, it will never be used in the official version.

By: Filip Frank (frenk77) 2012-06-25 13:36:38.030-0500

Ok I have a signed license now. :) Patch is now attached. Please merge it to official versions, it helps with many strange DTMF problems.

By: Filip Frank (frenk77) 2012-07-09 02:56:34.276-0500

It is two week after i send my patch and no response. What is a problem ?

By: Igor Goncharovsky (igorg) 2012-07-09 03:31:42.921-0500

The main reason for it that issue is not assigned to anybody. Try to ask on #asterisk-dev IRC channel for anyone to look ad this.

By: Matt Jordan (mjordan) 2012-09-27 12:00:01.085-0500

Fixed in r372199