Greetings, What is the recommended settings for using SPA-3000's FXO port for dialing out to PSTN in regard of the DTMF? The voip lan contains SPA-2100 and SPA-3000, with all fxs/fxo ports registered to the Asterisk box with unique username/passwords. The inbound PSTN DTMF works excellently, e.g. people calling from PSTN into the * box are able to pick IVR items with DTMF reliably. The problem manifests itself when you attempt to place a call via SPA-3000's FXO into PSTN to a different IVR system and try to navigate its menu. Audibly, the other end hears very short DTMF bursts with short silence afterwards, as like SPA-3000 detects a DTMF, mutes it and sends rfc2833 or whatever. Obviously, the burst is short enough to be ignored by the remote IVR system (similar Asterisk/SPA-3000 setup). The relevant settings in the SPA-3000/2100 config for DTMF are set to 'Auto' setting. The relevant lines in sip.conf: ;------- [general] ;irrelevant lines removed dtmfmode=rfc2833 disallow=all allow=alaw allow=ulaw allow=g729 [111] ;SPA-3000 FXO port type=friend username=111 secret=xxx host=dynamic [112] ;SPA-3000 FXS port type=friend username=112 secret=xxx host=dynamic [113] ;SPA-2100 FXS1 port type=friend username=115 secret=xxx host=dynamic [114] ;SPA-3000 FXS2 port type=friend username=114 secret=xxx host=dynamic ;------- Should I instead split the SPA-3000's FXO entry into a type=user and type=peer entries with the first having dtmfmode=rfc2833 and second dtmfmode=inband? Which is the proper way of sending inband dtmf over g711 into the PSTN? Awaiting assistance and thanks for your time, Vahan
Vahan, see my comments below.>Greetings, > >What is the recommended settings for using SPA-3000's >FXO port for >dialing out to PSTN in regard of the DTMF? > >The voip lan contains SPA-2100 and SPA-3000, with all >fxs/fxo ports >registered to the Asterisk box with unique >username/passwords.>The inbound PSTN DTMF works excellently, e.g. people >calling from PSTN >into the * box are able to pick IVR items with DTMF >reliably.exactly!> >The problem manifests itself when you attempt toplace >a call via>SPA-3000's FXO into PSTN to a different IVR systemand >try to navigate>its menu. Audibly, the other end hears very shortDTMF >bursts with short>silence afterwards, as like SPA-3000 detects a DTMF, >mutes it and sends >rfc2833 or whatever. Obviously, the burst is short >enough to be ignored >by the remote IVR system (similar Asterisk/SPA-3000 >setup).Actually SPA-3000 should receive rfc2833 DTMF events from IP side and put inband DTMFs instead to PSTN side. SPA-3000 fails to correctly detect rfc2833 events, which poorly constructed by asterisk. So asterisk isn't fully compliant to rfc2833, from the other hand other VoIP gateways (but not SPA-3000) manage to detect rfc2833 DTMFs from asterisk. SPA-3000 serves well in this scenario if source of RTP stream is another VoIP device or phone (cisco, snom, aastra...), not asterisk itself. Here come the solution: try to exclude asterisk from media path canreinvite=yes [111] ;SPA-3000 FXO port type=friend username=111 secret=xxx host=dynamic canreinvite=yes dtmfmode=rfc2833 This is the only way I manage to setup asterisk/SPA-3000 in described scenario. Hope this will help, Arsen.> >The relevant settings in the SPA-3000/2100 config for >DTMF are set to >'Auto' setting. > >The relevant lines in sip.conf: > >;------- >[general] >;irrelevant lines removed >dtmfmode=rfc2833 >disallow=all >allow=alaw >allow=ulaw >allow=g729 > >[111] >;SPA-3000 FXO port >type=friend >username=111 >secret=xxx >host=dynamic > >[112] >;SPA-3000 FXS port >type=friend >username=112 >secret=xxx >host=dynamic > >[113] >;SPA-2100 FXS1 port >type=friend >username=115 >secret=xxx >host=dynamic > >[114] >;SPA-3000 FXS2 port >type=friend >username=114 >secret=xxx >host=dynamic >;------- > > >Should I instead split the SPA-3000's FXO entry intoa >type=user and>type=peer entries with the first having >dtmfmode=rfc2833 and second >dtmfmode=inband? > >Which is the proper way of sending inband dtmf over >g711 into the PSTN? > > >Awaiting assistance and thanks for your time, >Vahan__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
>Actually, > >I believe that something is wrong with the wayasterisk >implements the>whole rfc2833 in rtp.c , moreover, the default valueof >100ms in>dtmf_tones[] in do_senddigit() inchannel.c is toshort >to be detected>for lots of commercially available fxo gateways.I can't agree on this. 100ms for inband DTMFs should be more than enough to detect, while for rfc2833 DTMFs even one packet can be enough, it depends on implementation. The main problem of asterisk isn't duration, but the way rtp stream is constructed.>This was reported several times but as of today the >issue is there.Seems there are a lot of other open issues concerning DTMFs in asterisk none trivial to fix.>I ended up with the following ugly hack for rtp.c & >channel.c:Increasing duration of dtmf events is not good idea. May be it force SPA-3000 to work, but this can be the source for another missfunctionalities. Please, find below my patch against 1.2.4, which makes asterisk more compliant to rfc2833 and reliable enough for SPA-3000. Index: rtp.c ==================================================================--- rtp.c (revision 10625) +++ rtp.c (working copy) @@ -1111,6 +1111,7 @@ int hdrlen = 12; int res; int x; + unsigned short duration = 0; int payload; char data[256]; char iabuf[INET_ADDRSTRLEN]; @@ -1143,7 +1144,9 @@ rtpheader[1] = htonl(rtp->lastdigitts); rtpheader[2] = htonl(rtp->ssrc); rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (0)); - for (x = 0; x < 6; x++) { + + + for (x = 0; x < 5; x++) { if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) { res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them)); if (res < 0) @@ -1155,35 +1158,46 @@ ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastdigitts, res - hdrlen); } - /* Sequence number of last two end packets does not get incremented */ - if (x < 3) - rtp->seqno++; + + /* Sequence number must be incremented for every packet*/ + rtp->seqno++; /* Clear marker bit and set seqno */ rtpheader[0] = htonl((2 << 30) | (payload << 16) | (rtp->seqno)); - /* For the last three packets, set the duration and the end bit */ - if (x == 2) { -#if 0 - /* No, this is wrong... Do not increment lastdigitts, that's not according - to the RFC, as best we can determine */ - rtp->lastdigitts++; /* or else the SPA3000 will click instead of beeping... */ - rtpheader[1] htonl(rtp->lastdigitts); -#endif - /* Make duration 800 (100ms) */ - rtpheader[3] |= htonl((800)); - /* Set the End bit */ - rtpheader[3] |= htonl((1 << 23)); + /* Increment duration for 160 (20ms) */ + duration += 160; + rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (duration)); + } + + /* Set the End bit */ + rtpheader[3] |= htonl((1 << 23)); + + /* Send last packet and repeat it 2 times */ + for (x = 0; x < 3; x++) { + if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) { + res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them)); + if (res < 0) + ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n", + ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), + ntohs(rtp->them.sin_port), strerror(errno)); + if (rtp_debug_test_addr(&rtp->them)) + ast_verbose("Sent RTP packet to %s:%d (type %d, seq %u, ts %u, len %u)\n", + ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), + ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastdigitts, res - hdrlen); } + + /* Sequence number must be incremented for every packet, even for retransmitted last two packets */ + rtp->seqno++; + /* Set seqno */ + rtpheader[0] = htonl((2 << 30) | (payload << 16) | (rtp->seqno)); } + /* Increment the digit timestamp by 120ms, to ensure that digits sent sequentially with no intervening non-digit packets do not get sent with the same timestamp, and that sequential digits have some 'dead air' in between them */ - rtp->lastdigitts += 960; - /* Increment the sequence number to reflect the last packet - that was sent - */ - rtp->seqno++; + duration += 160; + rtp->lastdigitts += duration; return 0; } __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com