[Home]

Summary:ASTERISK-29096: chan_sip: Use of SIP_CODEC results in incorrect formats
Reporter:David Herselman (bbs2web)Labels:webrtc
Date Opened:2020-09-25 02:10:52Date Closed:2020-10-09 12:00:01
Priority:MajorRegression?
Status:Closed/CompleteComponents:Channels/chan_sip/CodecHandling
Versions:16.13.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:CentOS 7, Asterisk 16.13.0 with upstream (chan_sip) and downstream (chan_iax2)Attachments:( 0) chan_iax2_leg.png
( 1) chan_sip_leg.png
Description:In the below an incoming call from upstream provider uses chan_sip to receive a call from +27888888888 for 0100000000. Trunk for upstream allows several codecs but first dialplan action looks up destination and forces g729 before sending it on to a downstream chan_iax trunk.

Both legs of the call negotiate g729 in both of their directions (all 4 streams), exclusively receives g729 media from downstream destination but then unnecessarily transcodes and transmits g711a media to caller, although it wasn't negotiated.

PS: I was able to confirm with Unsniff that media received from the downstream IAX2 'B' party was encoded with G.729a. Wireshark shows a packet size of 74 bytes, which comprises of 20 bytes of encoded media.


Wireshark snippet of the SIP portion of the call (upstream -> Asterisk) showing outgoing G711a RTP stream:
   Available here: https://ibb.co/jRGvvVc
   Also uploaded as chan_sip_leg.png

Wireshark snippet of rhe IAX2 portion of the call (Asterisk -> downstream) showing incoming packets with a size of 74 bytes:
   Available here: https://ibb.co/jRGvvVc
   Also uploaded as chan_iax2_leg.png

PS: Nuance with this call is that we receive no incoming RTP stream from the caller as it originates from a WebRTC client which doesn’t transmit any audio, could this be influencing Asterisk's transcoding decision?  (ie they dial an IVR, listen to options and simply want to interact via DTMF, the call never gets routed to anything that expects audio from the caller).


Asterisk debug:
{code}
[2020-09-19 23:42:19] VERBOSE[2637] chan_sip.c:
<--- SIP read from UDP:41.11.11.12:5060 --->
INVITE sip:0100000000@52.22.22.22:5160 SIP/2.0
Record-Route: <sip:41.11.11.12;lr;ftag=as40fe2614>
Via: SIP/2.0/UDP 41.11.11.12:5060;branch=z9hG4bK4df7.5bc77035.0
Via: SIP/2.0/UDP 41.11.11.11:5070;received=41.11.11.11;branch=z9hG4bK0cb77ea3;rport=5070
From: "+27888888888" <sip:+27888888888@41.11.11.11:5070>;tag=as40fe2614
To: <sip:0100000000@52.22.22.22:5160>
Contact: <sip:+27888888888@41.11.11.11:5070>
Call-ID: 7030be5a09d89a9543234da051897a49@41.11.11.11
CSeq: 102 INVITE
User-Agent: PortaOne
Max-Forwards: 69
Date: Sat, 19 Sep 2020 21:42:19 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
X-LOCATION:
X-StartID: SDvb9r601-d482cc2b5e0b32417957ea02aaade464-a04aba0
Content-Type: application/sdp
Content-Length: 283

v=0
o=root 6009 6009 IN IP4 41.11.11.11
s=session
c=IN IP4 41.11.11.11
t=0 0
m=audio 13918 RTP/AVP 18 8 101
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv
<------------->
[2020-09-19 23:42:19] VERBOSE[2637] chan_sip.c: --- (18 headers 14 lines) ---
[2020-09-19 23:42:19] VERBOSE[2637] chan_sip.c: Sending to 41.11.11.12:5060 (NAT)
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Sending to 41.11.11.12:5060 (NAT)
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Using INVITE request as basis request - 7030be5a09d89a9543234da051897a49@41.11.11.11
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Found peer 'Upstream' for '+27888888888' from 41.11.11.12:5060
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] netsock2.c: Using SIP RTP TOS bits 184
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] netsock2.c: Using SIP RTP CoS mark 5
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Got SDP version 6009 and unique parts [root 6009 IN IP4 41.11.11.11]
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Found RTP audio format 18
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Found RTP audio format 8
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Found RTP audio format 101
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Found audio description format G729 for ID 18
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Found audio description format PCMA for ID 8
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Found audio description format telephone-event for ID 101
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Capabilities: us - (g722|alaw|g729), peer - audio=(alaw|g729)/video=(nothing)/text=(nothing), combined - (alaw|g729)
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] res_rtp_asterisk.c: 0x7f02241bdaf0 -- Strict RTP learning after remote address set to: 41.11.11.11:13918
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Peer audio RTP is at port 41.11.11.11:13918
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c: Looking for 0100000000 in from-pstn (domain 52.22.22.22)
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] sip/route.c: sip_route_dump: route/path hop: <sip:41.11.11.12;lr;ftag=as40fe2614>
[2020-09-19 23:42:19] VERBOSE[2637][C-00021a1f] chan_sip.c:
<--- Transmitting (NAT) to 41.11.11.12:5060 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 41.11.11.12:5060;branch=z9hG4bK4df7.5bc77035.0;received=41.11.11.12;rport=5060
Via: SIP/2.0/UDP 41.11.11.11:5070;received=41.11.11.11;branch=z9hG4bK0cb77ea3;rport=5070
Record-Route: <sip:41.11.11.12;lr;ftag=as40fe2614>
From: "+27888888888" <sip:+27888888888@41.11.11.11:5070>;tag=as40fe2614
To: <sip:0100000000@52.22.22.22:5160>
Call-ID: 7030be5a09d89a9543234da051897a49@41.11.11.11
CSeq: 102 INVITE
Server: Asterisk PBX 16.13.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: <sip:0100000000@52.22.22.22:5160>
Content-Length: 0


<------------>
[2020-09-19 23:42:19] VERBOSE[15153][C-00021a1f] pbx.c: Executing [0100000000@incoming:1] Set("SIP/Upstream-00021a0d", "1?SIP_CODEC=g729") in new stack
[2020-09-19 23:42:19] VERBOSE[15153][C-00021a1f] pbx.c: Executing [0100000000@incoming:2] NoOp("SIP/Upstream-00021a0d", "SIP Call ID: 7030be5a09d89a9543234da051897a49@41.11.11.11") in new stack
[2020-09-19 23:42:19] VERBOSE[15153][C-00021a1f] pbx.c: Executing [0100000000@incoming:3] Dial("SIP/Upstream-00021a0d", "iax2/Downstream/0100000000") in new stack
[2020-09-19 23:42:19] VERBOSE[15153][C-00021a1f] app_dial.c: Called iax2/Downstream/0100000000
[2020-09-19 23:42:20] VERBOSE[2602][C-00021a1f] chan_iax2.c: Call accepted by 196.43.209.105:4569 (format g729)
[2020-09-19 23:42:20] VERBOSE[2602][C-00021a1f] chan_iax2.c: Format for call is (g729)
[2020-09-19 23:42:20] VERBOSE[15153][C-00021a1f] app_dial.c: IAX2/Downstream-26055 is ringing
[2020-09-19 23:42:20] VERBOSE[15153][C-00021a1f] chan_sip.c:
<--- Transmitting (NAT) to 41.11.11.12:5060 --->
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 41.11.11.12:5060;branch=z9hG4bK4df7.5bc77035.0;received=41.11.11.12;rport=5060
Via: SIP/2.0/UDP 41.11.11.11:5070;received=41.11.11.11;branch=z9hG4bK0cb77ea3;rport=5070
Record-Route: <sip:41.11.11.12;lr;ftag=as40fe2614>
From: "+27888888888" <sip:+27888888888@41.11.11.11:5070>;tag=as40fe2614
To: <sip:0100000000@52.22.22.22:5160>;tag=as11a1cd82
Call-ID: 7030be5a09d89a9543234da051897a49@41.11.11.11
CSeq: 102 INVITE
Server: Asterisk PBX 16.13.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: <sip:0100000000@52.22.22.22:5160>
Content-Length: 0


<------------>
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] app_dial.c: IAX2/Downstream-26055 answered SIP/Upstream-00021a0d
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] chan_sip.c: Set codec to 'g729' for this call because of ${SIP_CODEC*} variable
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] chan_sip.c: Set codec to 'g729' for this call because of ${SIP_CODEC*} variable
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] chan_sip.c: Audio is at 17678
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] chan_sip.c: Adding codec g729 to SDP
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] chan_sip.c: Adding non-codec 0x1 (telephone-event) to SDP
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] chan_sip.c:
<--- Reliably Transmitting (NAT) to 41.11.11.12:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 41.11.11.12:5060;branch=z9hG4bK4df7.5bc77035.0;received=41.11.11.12;rport=5060
Via: SIP/2.0/UDP 41.11.11.11:5070;received=41.11.11.11;branch=z9hG4bK0cb77ea3;rport=5070
Record-Route: <sip:41.11.11.12;lr;ftag=as40fe2614>
From: "+27888888888" <sip:+27888888888@41.11.11.11:5070>;tag=as40fe2614
To: <sip:0100000000@52.22.22.22:5160>;tag=as11a1cd82
Call-ID: 7030be5a09d89a9543234da051897a49@41.11.11.11
CSeq: 102 INVITE
Server: Asterisk PBX 16.13.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: <sip:0100000000@52.22.22.22:5160>
Content-Type: application/sdp
Content-Length: 259

v=0
o=root 430525994 430525994 IN IP4 52.22.22.22
s=Asterisk PBX 16.13.0
c=IN IP4 52.22.22.22
t=0 0
m=audio 17678 RTP/AVP 18 101
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:230
a=sendrecv

<------------>
[2020-09-19 23:42:22] VERBOSE[15154][C-00021a1f] bridge_channel.c: Channel IAX2/Downstream-26055 joined 'simple_bridge' basic-bridge <0d377050-bca3-4db8-81e0-f677e37c24e9>
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] bridge_channel.c: Channel SIP/Upstream-00021a0d joined 'simple_bridge' basic-bridge <0d377050-bca3-4db8-81e0-f677e37c24e9>
[2020-09-19 23:42:22] VERBOSE[2637] chan_sip.c:
<--- SIP read from UDP:41.11.11.12:5060 --->
ACK sip:0100000000@52.22.22.22:5160 SIP/2.0
Record-Route: <sip:41.11.11.12;lr;ftag=as40fe2614>
Via: SIP/2.0/UDP 41.11.11.12:5060;branch=z9hG4bK4df7.5bc77035.2
Via: SIP/2.0/UDP 41.11.11.11:5070;received=41.11.11.11;branch=z9hG4bK7caba5c1;rport=5070
From: "+27888888888" <sip:+27888888888@41.11.11.11:5070>;tag=as40fe2614
To: <sip:0100000000@52.22.22.22:5160>;tag=as11a1cd82
Contact: <sip:+27888888888@41.11.11.11:5070>
Call-ID: 7030be5a09d89a9543234da051897a49@41.11.11.11
CSeq: 102 ACK
User-Agent: PortaOne
Max-Forwards: 69
Content-Length: 0

<------------->
[2020-09-19 23:42:22] VERBOSE[2637] chan_sip.c: --- (12 headers 0 lines) ---
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] res_rtp_asterisk.c: Sent RTP packet to      41.11.11.11:13918 (type 8, seq 020640, ts 000160, len 000160)
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] res_rtp_asterisk.c: Sent RTP packet to      41.11.11.11:13918 (type 8, seq 020641, ts 000320, len 000160)
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] res_rtp_asterisk.c: Sent RTP packet to      41.11.11.11:13918 (type 8, seq 020642, ts 000480, len 000160)
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] res_rtp_asterisk.c: Sent RTP packet to      41.11.11.11:13918 (type 8, seq 020643, ts 000640, len 000160)
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] res_rtp_asterisk.c: Sent RTP packet to      41.11.11.11:13918 (type 8, seq 020644, ts 000800, len 000160)
[2020-09-19 23:42:22] VERBOSE[15153][C-00021a1f] res_rtp_asterisk.c: Sent RTP packet to      41.11.11.11:13918 (type 8, seq 020645, ts 000960, len 000160)
<snip>
[2020-09-19 23:42:29] VERBOSE[15153][C-00021a1f] res_rtp_asterisk.c: Sent RTP packet to      41.11.11.11:13918 (type 8, seq 020999, ts 250248, len 000160)
[2020-09-19 23:42:29] VERBOSE[15153][C-00021a1f] res_rtp_asterisk.c: Sent RTP packet to      41.11.11.11:13918 (type 8, seq 021000, ts 250408, len 000160)
[2020-09-19 23:42:29] VERBOSE[15153][C-00021a1f] res_rtp_asterisk.c: Sent RTP packet to      41.11.11.11:13918 (type 8, seq 021001, ts 250568, len 000160)
[2020-09-19 23:42:29] VERBOSE[15153][C-00021a1f] res_rtp_asterisk.c: Sent RTP packet to      41.11.11.11:13918 (type 8, seq 021002, ts 250728, len 000160)
[2020-09-19 23:42:29] VERBOSE[15153][C-00021a1f] res_rtp_asterisk.c: Sent RTP packet to      41.11.11.11:13918 (type 8, seq 021003, ts 250888, len 000160)
[2020-09-19 23:42:29] VERBOSE[15153][C-00021a1f] res_rtp_asterisk.c: Sent RTP packet to      41.11.11.11:13918 (type 8, seq 021004, ts 251048, len 000160)
[2020-09-19 23:42:29] VERBOSE[2637] chan_sip.c:
<--- SIP read from UDP:41.11.11.12:5060 --->
BYE sip:0100000000@52.22.22.22:5160 SIP/2.0
Record-Route: <sip:41.11.11.12;lr;ftag=as40fe2614>
Via: SIP/2.0/UDP 41.11.11.12:5060;branch=z9hG4bK5df7.1435d67.0
Via: SIP/2.0/UDP 41.11.11.11:5070;received=41.11.11.11;branch=z9hG4bK577fb6bb;rport=5070
From: "+27888888888" <sip:+27888888888@41.11.11.11:5070>;tag=as40fe2614
To: <sip:0100000000@52.22.22.22:5160>;tag=as11a1cd82
Call-ID: 7030be5a09d89a9543234da051897a49@41.11.11.11
CSeq: 103 BYE
User-Agent: PortaOne
Max-Forwards: 69
Reason: Q.850 ;cause=16; text="Normal Clearing"
X-Asterisk-HangupCauseCode: 16
Content-Length: 0

<------------->
[2020-09-19 23:42:29] VERBOSE[2637] chan_sip.c: --- (13 headers 0 lines) ---
[2020-09-19 23:42:29] VERBOSE[2637][C-00021a1f] chan_sip.c: Sending to 41.11.11.12:5060 (NAT)
[2020-09-19 23:42:29] VERBOSE[2637][C-00021a1f] chan_sip.c: Scheduling destruction of SIP dialog '7030be5a09d89a9543234da051897a49@41.11.11.11' in 32000 ms (Method: BYE)
[2020-09-19 23:42:29] VERBOSE[2637][C-00021a1f] chan_sip.c:
<--- Transmitting (NAT) to 41.11.11.12:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 41.11.11.12:5060;branch=z9hG4bK5df7.1435d67.0;received=41.11.11.12;rport=5060
Via: SIP/2.0/UDP 41.11.11.11:5070;received=41.11.11.11;branch=z9hG4bK577fb6bb;rport=5070
Record-Route: <sip:41.11.11.12;lr;ftag=as40fe2614>
From: "+27888888888" <sip:+27888888888@41.11.11.11:5070>;tag=as40fe2614
To: <sip:0100000000@52.22.22.22:5160>;tag=as11a1cd82
Call-ID: 7030be5a09d89a9543234da051897a49@41.11.11.11
CSeq: 103 BYE
Server: Asterisk PBX 16.13.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0


<------------>
[2020-09-19 23:42:29] VERBOSE[15153][C-00021a1f] bridge_channel.c: Channel SIP/Upstream-00021a0d left 'simple_bridge' basic-bridge <0d377050-bca3-4db8-81e0-f677e37c24e9>
[2020-09-19 23:42:29] VERBOSE[15154][C-00021a1f] bridge_channel.c: Channel IAX2/Downstream-26055 left 'simple_bridge' basic-bridge <0d377050-bca3-4db8-81e0-f677e37c24e9>
[2020-09-19 23:42:29] VERBOSE[15153][C-00021a1f] pbx.c: Spawn extension (incoming, Downstream_0100000000, 1) exited non-zero on 'SIP/Upstream-00021a0d'
[2020-09-19 23:42:29] VERBOSE[15154][C-00021a1f] chan_iax2.c: Hungup 'IAX2/Downstream-26055'
{code}
Comments:By: Asterisk Team (asteriskteam) 2020-09-25 02:10:53.804-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: David Herselman (bbs2web) 2020-09-25 02:12:35.595-0500

Wireshark snippet of the 'A leg' portion of the call. Showing RTP towards calling party being G.711a

By: David Herselman (bbs2web) 2020-09-25 02:13:25.450-0500

Wireshark snippet showing a 'B leg' portion of the call. Here we are receiving g729 encoded media as expected.

By: Joshua C. Colp (jcolp) 2020-09-25 03:37:27.696-0500

What is the output of "core show channel" for the SIP channel?

As well the chan_sip module is community supported, meaning that it only receives fixes from community members and there is no guarantee on if or when such a thing would be looked into.

By: Asterisk Team (asteriskteam) 2020-10-09 12:00:00.896-0500

Suspended due to lack of activity. This issue will be automatically re-opened if the reporter posts a comment. If you are not the reporter and would like this re-opened please create a new issue instead. If the new issue is related to this one a link will be created during the triage process. Further information on issue tracker usage can be found in the Asterisk Issue Guidlines [1].

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines