sipwise / rtpengine

The Sipwise media proxy for Kamailio
GNU General Public License v3.0
800 stars 375 forks source link

a=group is stripped, while a=mid is kept #1658

Closed dilyanpalauzov closed 1 year ago

dilyanpalauzov commented 1 year ago

Kamailio/rtpengine receive an offer:

INVITE sip:callee-addr@example.aa SIP/2.0
Via: SIP/2.0/WSS tjmis9tgapsl.invalid;branch=z9hG4bK4342301
Max-Forwards: 69
To: <sip:callee-addr@example.aa>
From: <sip:caller123@example.aa>;tag=33l6b5cs53
Call-ID: jaf10ohhdhfg361iddig
CSeq: 3695 INVITE
Proxy-Authorization: Digest algorithm=MD5, username="caller123", realm="example.aa", nonce="ab==", uri="sip:callee-addr@example.aa", response="64d"
Contact: <sip:caller123@example.aa;gr=urn:uuid:b724a2a6-96b9-425a-aa17-55888c1a15ff>
Content-Type: application/sdp
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Supported: gruu,ice,replaces,outbound
User-Agent: JsSIP 3.9.1
Content-Length: 2297

v=0
o=- 4996465725194122889 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=extmap-allow-mixed
a=msid-semantic: WMS 7b1ca936-965a-44b4-b21f-514f2f79322f
m=audio 50758 UDP/TLS/RTP/SAVPF 111 63 9 0 8 13 110 126
c=IN IP4 172.20.48.1
a=rtcp:9 IN IP4 0.0.0.0
a=candidate:2880783752 1 udp 2122260223 172.20.48.1 50758 typ host generation 0 network-id 4
a=candidate:4039014649 1 udp 2122063615 192.168.0.123 50759 typ host generation 0 network-id 1 network-cost 10
a=candidate:4000642609 1 udp 2122197247 2a02:8071:2289:d180:3a50:bbe1:c5c5:1163 50760 typ host generation 0 network-id 2 network-cost 10
a=candidate:1060091395 1 udp 2122131711 2a02:8071:2289:d180:e523:cd33:1cfc:21e9 50761 typ host generation 0 network-id 3 network-cost 10
a=candidate:3581585168 1 tcp 1518280447 172.20.48.1 9 typ host tcptype active generation 0 network-id 4
a=candidate:2389809761 1 tcp 1518083839 192.168.0.123 9 typ host tcptype active generation 0 network-id 1 network-cost 10
a=candidate:2428179625 1 tcp 1518217471 2a02:8071:2289:d180:3a50:bbe1:c5c5:1163 9 typ host tcptype active generation 0 network-id 2 network-cost 10
a=candidate:1105220763 1 tcp 1518151935 2a02:8071:2289:d180:e523:cd33:1cfc:21e9 9 typ host tcptype active generation 0 network-id 3 network-cost 10
a=ice-ufrag:YNi9
a=ice-pwd:Rg0WmotC+8wvvllJdSanLbNK
a=ice-options:trickle
a=fingerprint:sha-256 7E:C9:92:28:D7:81:02:02:E5:FE:F5:F8:CF:36:94:F9:92:E2:CC:36:C7:DF:34:37:35:C3:65:56:1D:3D:F5:9A
a=setup:actpass
a=mid:0
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=sendrecv
a=msid:7b1ca936-965a-44b4-b21f-514f2f79322f 8411375e-fe49-417b-8410-8376bd4ef5cc
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:63 red/48000/2
a=fmtp:63 111/111
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:126 telephone-event/8000
a=ssrc:1857807914 cname:jL6yWzxCyEEAkbFO
a=ssrc:1857807914 msid:7b1ca936-965a-44b4-b21f-514f2f79322f 8411375e-fe49-417b-8410-8376bd4ef5cc

then Kamailio calls

KSR.rtpengine.rtpengine_manage("replace-session-connection replace-origin SDES-pad SIP-source-address")

and this packet leaves the SIP proxy:

INVITE sip:callee-addr@192.168.0.171:3485;transport=tls;line=82vmy2o1 SIP/2.0
Record-Route: <sip:111.22.123.45:5061;transport=tls;r2=on;lr;ftag=33l6b5cs53;did=933.5bc;nat=yes>
Record-Route: <sip:111.22.123.45;transport=ws;r2=on;lr;ftag=33l6b5cs53;did=933.5bc;nat=yes>
Via: SIP/2.0/TLS 111.22.123.45:5061;branch=z9hG4bKf562.ee335ba3cfc6b4d50dcc6ecbec9c220b.0
Via: SIP/2.0/WSS tjmis9tgapsl.invalid;rport=36274;received=111.22.123.45;branch=z9hG4bK4342301
Max-Forwards: 68
To: <sip:callee-addr@example.aa>
From: <sip:caller123@example.aa>;tag=33l6b5cs53
Call-ID: jaf10ohhdhfg361iddig
CSeq: 3695 INVITE
Contact: <sip:caller123@example.aa;alias=111.22.123.45~36274~5;gr=urn:uuid:b724a2a6-96b9-425a-aa17-55888c1a15ff>
Content-Type: application/sdp
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Supported: gruu,ice,replaces,outbound
User-Agent: JsSIP 3.9.1
Content-Length: 2514
Session-Expires: 90

v=0
o=- 4996465725194122889 2 IN IP4 111.22.123.45
s=-
t=0 0
a=extmap-allow-mixed
a=msid-semantic: WMS 7b1ca936-965a-44b4-b21f-514f2f79322f
m=audio 38166 UDP/TLS/RTP/SAVPF 111 63 9 0 8 13 110 126
c=IN IP4 111.22.123.45
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=msid:7b1ca936-965a-44b4-b21f-514f2f79322f 8411375e-fe49-417b-8410-8376bd4ef5cc
a=ssrc:1857807914 cname:jL6yWzxCyEEAkbFO
a=ssrc:1857807914 msid:7b1ca936-965a-44b4-b21f-514f2f79322f 8411375e-fe49-417b-8410-8376bd4ef5cc
a=mid:0
a=rtpmap:111 opus/48000/2
a=fmtp:111 useinbandfec=1; minptime=10
a=rtcp-fb:111 transport-cc
a=rtpmap:63 red/48000/2
a=fmtp:63 111/111
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:126 telephone-event/8000
a=sendrecv
a=rtcp:38167
a=rtcp-mux
a=crypto:1 AEAD_AES_256_GCM inline:WwSXroKIPEa7sLvSp9OOIC56gtQ7iRjjQithsQoATndQmVF0MwEE1yW6MX0=
a=crypto:2 AEAD_AES_128_GCM inline:UwS0cq4F6VRSQRMciU0+7RUE0ysaA9wpXFdRJw==
a=crypto:3 AES_256_CM_HMAC_SHA1_80 inline:oj9FCz8z8QiW4o1H1NYwiFCihj7FNvIUh41syB9dTFLuKl3wjGJw9fwfopNOOw==
a=crypto:4 AES_256_CM_HMAC_SHA1_32 inline:uNzs6qx6NC3PEdzAKNPoOCPf0h1E8lISg7NWi8SgMVSKe4d7p+aanPTAIMy+UA==
a=crypto:5 AES_192_CM_HMAC_SHA1_80 inline:pZfs9Q+DHwFeLXvoY51f2Z+vEbnl9fqgjcujAoBtHH/HujKv/wI=
a=crypto:6 AES_192_CM_HMAC_SHA1_32 inline:8KhO55BXo/u3FzwnIBG47IOR/BV0hKl/4ZFYa3uqjw7caBgg9FI=
a=crypto:7 AES_CM_128_HMAC_SHA1_80 inline:CspOaJIztpYT7IY279Be2JYghbSTLeoEb3BGu4JH
a=crypto:8 AES_CM_128_HMAC_SHA1_32 inline:YvjKVNVDyYz35JGbFF++AYcT4y/qpPyXAy3rkIJc
a=crypto:9 F8_128_HMAC_SHA1_80 inline:E+mhk+FF+TNm0/8Wi5KWPfSwrN7GjyjzZ4KxM53G
a=crypto:10 F8_128_HMAC_SHA1_32 inline:LPX7Wlc2iFOH+zxYAlzs3usNPOCO+U8v/DQ/Yv2J
a=crypto:11 NULL_HMAC_SHA1_80 inline:gfwUegp7fW1HNDDmBfpFRjTZw/jbzURCCV8UHQmy
a=crypto:12 NULL_HMAC_SHA1_32 inline:QscU8eF0HIvK9Umqsouf46x53SzcfL/Zy3RpfEgd
a=setup:actpass
a=fingerprint:sha-256 C4:55:CA:34:36:B6:DE:1E:C7:6E:61:E7:7C:B1:7A:BF:8F:EA:62:E7:20:BF:ED:80:A6:98:77:41:EA:0B:E3:B9
a=tls-id:d05b56f756a2805f663702a2d404079a
a=ice-ufrag:T0PEy30a
a=ice-pwd:ukbETqDa8BNbPFNrg4XqwaohLK
a=candidate:KBA8UF5PyyDFFFiL 1 UDP 2130706431 111.22.123.45 38166 typ host
a=candidate:KBA8UF5PyyDFFFiL 2 UDP 2130706430 111.22.123.45 38167 typ host

As you can see the incoming message has

a=group:BUNDLE 0
m=audio 50758 UDP/TLS/RTP/SAVPF 111 63 9 0 8 13 110 126
a=mid:0

while the outgoing message lacks the "a=group:BUNDLE 0" line. When the answer goes over WebRTC back to Chrome, it logs:

SIP:WARN:RTCSession emit "peerconnection:setremotedescriptionfailed" [error:DOMException: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Failed to set remote answer sdp: The m= section with mid='0' is invalid. RTCP-MUX is not enabled when it is required.]

My understanding is that without a=group, the a=mid: line makes no sense. Rtpengine removes a=group, keeping a=mid , which causes the twist here.

This is the actual answer, which was declared invalid

SIP/2.0 200 Ok
Via: SIP/2.0/WSS ioergguli6d7.invalid;rport=37424;received=144.76.142.78;branch=z9hG4bK6765113
Record-Route: <sip:111.22.123.45:5061;transport=tls;r2=on;lr;ftag=h4a876lcc4;did=8fd.3562;nat=yes>
Record-Route: <sip:111.22.123.45;transport=ws;r2=on;lr;ftag=h4a876lcc4;did=8fd.3562;nat=yes>
From: <sip:caller123@example.aa>;tag=h4a876lcc4
To: <sip:callee-addr@example.aa>;tag=ls7j1a3ehu
Call-ID: m7mf7iq7srn06ug5pfck
CSeq: 2684 INVITE
User-Agent: snom870/8.7.5.35
Contact: <sip:callee-addr@192.168.0.171:4649;transport=tls;line=43f1ivdk;alias=99.44.33.22~44370~3>;reg-id=1
Session-Expires: 90;refresher=uas
Allow: INVITE, ACK, CANCEL, BYE, REFER, OPTIONS, NOTIFY, SUBSCRIBE, PRACK, MESSAGE, INFO, UPDATE
Allow-Events: talk, hold, refer, call-info
Supported: timer, 100rel, replaces, from-change
Content-Type: application/sdp
Content-Length: 706

v=0
o=root 795017189 795017190 IN IP4 111.22.123.45
s=call
c=IN IP4 111.22.123.45
t=0 0
m=audio 33568 UDP/TLS/RTP/SAVPF 9 0 8 126
a=mid:0
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:126 telephone-event/8000
a=sendrecv
a=rtcp:33569
a=setup:active
a=fingerprint:sha-256 F1:B4:8B:A6:87:0F:E8:2B:EE:25:C7:ED:8D:55:14:70:4C:41:B5:77:8F:B3:04:47:F6:73:E1:5E:9E:A2:13:E1
a=tls-id:44ad1f436737096e26666ca110169fcc
a=ice-ufrag:acZqcwhy
a=ice-pwd:qjBICL0q4JkxgRGqogeibBZALa
a=ice-options:trickle
a=candidate:8kdV5yMxMgJHnrz4 1 UDP 2130706431 144.76.142.78 33568 typ host
a=candidate:8kdV5yMxMgJHnrz4 2 UDP 2130706430 144.76.142.78 33569 typ host
a=end-of-candidates
dilyanpalauzov commented 1 year ago

The same client (JsSIP) does connect when run under Firefox, but not under Chrome.

rfuchs commented 1 year ago

Try with rtcp-mux-require as part of your offer flags.

dilyanpalauzov commented 1 year ago

Yes, rtcp-mux-require made it work, thanks!

Is the presence of a=mid , after a=group was removed, considered as bug?

rfuchs commented 1 year ago

Is the presence of a=mid , after a=group was removed, considered as bug?

No because a=mid doesn't depend on a=group. There's no problem having media ID labels without bundling active.