SIP和SDP协议中的SESSION ID
众所周知,SDP协议中Origin ("o=")字段名提供会话发起者的信息,其中有会话ID (session id)的属性。在VOLTE呼叫场景中,稍加留意,会发现SIP Invite消息的Header中也出现了一个类似的SESSION-ID的属性。
下面简单介绍一下这两个会话ID的区别。
SDP协议中的会话ID:
详细内容参见RFC 4566: SDP: Session Description Protocol。
这是用于media媒体层的会话,英文是session identifier,简写sess-id。
o字段名提供会话发起者的信息(比如用户名和域名地址),以及会话ID和版本:
o=<username> <sess-id> <sess-version> <nettype> <addrtype> <unicast-address>
其中<sess-id>是一个数字字符串,<username>,<sess-id>, <nettype>, <addrtype>, <unicast-address>的元组为会话形成一个全局唯一的标识符。
生成<sess-id>的方式是由SDP创建工具决定的,规范建议使用NTP (Network Time Protocol)格式的时间戳以确保唯一性。
SIP协议中的会话ID:
详细内容参见RFC 7989: End-to-End Session Identification in IP-Based Multimedia Communication Networks,有多种应用场景。
这是从中摘录的:
IP-based multimedia communication systems, such as Session Initiation Protocol (SIP) [RFC3261] and [H.323], have the concept of a "call identifier" that is globally unique. The identifier is intended to represent an end-to-end communication session from the originating device to the terminating device.
This document defines a new identifier, referred to as the "session identifier", that is intended to overcome the issues that exist with the currently defined call identifiers used in SIP and other IP-based communication systems.
The term "session identifier" refers to the value of the identifier, whereas "Session-ID" refers to the header field used to convey the identifier. The session identifier is a set of two Universally Unique Identifiers (UUIDs) and each element of that set is simply referred to herein as a "UUID".
简单来说,引入Session Identification(简写SESSION-ID)的一个场景是用于signaling信令层中Call-ID无法关联标识一个end-to-end的会话的情况,比如Back-to-Back User Agents (B2BUAs)会改变Call-ID。
常见的是VOLTE网络的IMS呼叫,如3GPP TS 24.229所述:
The Call-ID header field in combination with the tags in the From header field and in the To header field is the standard mechanism to identify SIP messages which belong to the same dialog. However the Call-ID header field is often changed by B2BUAs and other SIP intermediaries in the end-to-end message path.
To solve this problem, a Session-ID header field containing a globally unique session identifier, as defined in RFC 7989 [162], can be used to correlate SIP messages belonging to the same session. In the case of a concatenation of dialogs, the dialog correlation mechanism indicates that these dialogs belong to the same session.
就是说依靠这个end-to-end的SESSION-ID,关联起属于同一个会话(Session)的多个对话(Dialog)。如下图所示(源自RFC7329):
(注:上述B2BUA场景下,SDP中的session id通常会随着call-id的改变而变化。)