3

我正在尝试为移动设备编写一个 SIP 客户端。我在 android 上使用 PJSIP,在 iOS 上使用 Linphone。有时客户端会响应 481 请求合法的 CANCEL。

我阅读了 RFC 3261 第 9.1 节并试图了解为什么客户端与对话框不匹配。但据我所知,请求 URI 匹配,Call-ID 标头、包含标签的 To 标头和 Cseq 的数字部分也匹配

INVITE sip:#######@127.0.0.0 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-197747523180-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>
Max-Forwards: 68
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204936 INVITE
Contact: <sip:##########@127.0.0.1>
User-Agent: Server UAS
Allow: ACK,BYE,CANCEL,INVITE,REGISTER,UPDATE,MESSAGE,INFO,OPTIONS,SUBSCRIBE,NOTIFY,REFER,COMET,PUBLISH,PING,DO
Allow-Events: presence,refer,telephone-event,keep-alive,dialog,message-summary
Supported: privacy,replaces
Accept: application/sdp,application/dtmf-relay,audio/telephone-event,message/sipfrag,text/plain,text/html
Content-Disposition: session;handling=required
Content-Type: application/sdp
Content-Length: 521

v=0
o=root 1954582096 1954582096 IN IP4 127.0.0.2
s=Sonus_UAC
c=IN IP4 127.0.0.1
t=0 0
m=audio 10852 RTP/AVP 0 9 8 18 10 3 111 5 7 110 97 101
a=rtpmap:0 PCMU/8000
a=rtpmap:9 G722/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:10 L16/8000
a=rtpmap:3 GSM/8000
a=rtpmap:111 G726-32/8000
a=rtpmap:5 DVI4/8000
a=rtpmap:7 LPC/8000
a=rtpmap:110 speex/8000
a=rtpmap:97 iLBC/8000
a=fmtp:97 mode=30
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv

SIP/2.0 100 Trying
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-197747523180-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: sip:#######@127.0.0.0
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204936 INVITE

SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-197747523180-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>;tag=43ye8Yn
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204936 INVITE
User-Agent: belle-sip/1.6.3
Supported: replaces, outbound

CANCEL sip:#######@127.0.0.0 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-171352412518-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>
Max-Forwards: 68
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204936 CANCEL
User-Agent: Server UAS
Warning: 399 127.0.0.0 "Cancel received (0x15) (4007)"
M-Stat: s:0 r:0 l:0 es:0 er:0 el:0
Content-Length: 0

BYE sip:#######@127.0.0.0 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-151544386511-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>;tag=43ye8Yn
Max-Forwards: 68
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204937 BYE
User-Agent: Server UAS
Warning: 399 127.0.0.0 "Cancel received (0x15) (4007)"
M-Stat: s:0 r:0 l:0 es:0 er:0 el:0
Content-Length: 0

SIP/2.0 481 Call/transaction does not exist
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-171352412518-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>;tag=K4PcWbb
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204936 CANCEL

SIP/2.0 501 Not implemented
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-151544386511-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>;tag=43ye8Yn
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204937 BYE

CANCEL sip:#######@127.0.0.0 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-171352412518-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>
Max-Forwards: 68
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204937 CANCEL
User-Agent: Server UAS
Warning: 399 127.0.0.0 "Cancel received (0x15) (4007)"
M-Stat: s:0 r:0 l:0 es:0 er:0 el:0
Content-Length: 0

SIP/2.0 481 Call/transaction does not exist
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-171352412518-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>;tag=azviy
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204937 CANCEL

出于隐私原因,我删除了识别详细信息。

4

1 回答 1

4

CANCEL 请求有一个额外的要求(RFC3261 第 9.1 章):

由客户端构造的 CANCEL 必须只有一个 Via 头字段值与被取消请求中的顶部 Via 值匹配。对这些标头字段使用相同的值允许 CANCEL 与它取消的请求相匹配

当 UAS 收到 CANCEL 请求时,它必须找到相应的 INVITE 服务器事务。RFC3261 第 9.2 章:

TU 通过接受 CANCEL 请求来确定要取消的事务,然后假设请求方法不是 CANCEL 或 ACK,并应用第 17.2.3 节的事务匹配过程。匹配交易是要取消的交易。

匹配条件之一是 CANCEL 请求的顶部 Via 标头中的分支参数:它必须与创建服务器事务的 INVITE 请求中的参数相同。由于您的 INVITE 和 CANCEL 请求中的分支参数不同,UAS 无法找到服务器事务并取消 INVITE。

于 2019-07-25T06:55:00.813 回答