SIP传输协议的选择

因为SIP提供了多种传输协议,所以必须有某种方法来选择要使用哪种传输协议。SIP中DNS的完整过程在RFC3263中定义,这儿只使用了基本的步骤。

选择传输协议有两种方法:

一 在SIP URI中显式定义,譬如在SIP URI中出现transport=tcp或者transport=sctp都说明了这个信令的传输协议。注意,如果要使用TLS进行传输,那么必须使用SIPS URI scheme。

二 如果在SIP URI中没有显式定义,那么必须按如下步骤进行选择: 
1. 如果URI中包含了“数点式”的IP地址,那么对于SIP URI使用UDP,对于SIPS URI使用TCP;
2. 如果URI中没有包含“数点式”的IP地址,只是包含数字形式的端口,那么同样对于SIP URI就是用UDP,对于SIPS URI使用TCP;
3. If the URI does not have a numeric IP address or port, and NAPTR
DNS queries are supported, then a DNS NAPTR query should be
performed on the host part of the URI. The NAPTR service fi elds are
“SIP+D2U” for UDP, “SIP+D2T” for TCP, and “SIP+D2S” for SCTP
transport. The result of the NAPTR regex replacement will be a URI,
which is used for an SRV lookup described in the next step. The preference
fi eld indicates the relative preference if multiple transports are
supported. If no NAPTR records are returned, an SRV query should
be performed.
4. The SIP usage of DNS SRV records uses “_sip” or “_sips” for the protocol
and “_udp”, “_tcp”, and “_sctp” for UDP, TCP, and SCTP transports.
The results of the SRV query will be a target hostname and port
number. The request should be sent to that address and port. Full details
on SRV record usage are in [11].
48 SIP: Understanding the Session Initiation Protocol
5. If no SRV records are found, then an address query for A or an AAAA
DNS query should be performed, and UDP should be used for a SIP
URI and TCP for a SIPS URI.
A slightly different set of rules are followed by proxy servers, as described
in [10].
For example, consider the DNS lookup performed by Schroedinger in Figure
2.2. The URI is sip:werner.heisenberg@munich.de, which does not contain
a numeric IP address or port, so steps 1 and 2 are not followed. Schroedinger
then follows step 3 and performs a NAPTR query on munich.de which returns
the following record:
munich.de. 360 IN NAPTR 100 50 “s” “SIPS+DTU” “” _sip._udp.munich.de
Since only UDP transport is supported, step 4 results in an SRV query on
_sip._udp.munich.de, which returns the following record:
_sip._udp.munich.de. 300 IN SRV 0 100 5060 proxy.munich.de
Finally, an A lookup is performed on proxy.munich.de which returns:
proxy.munich.de. 3600 IN A 100.101.102.105
As a result, Schroedinger sends the INVITE to 100.101.102.105:5060 as shown
in Figure 2.2.
2.7

posted @ 2010-12-08 22:46  茫茫深海一条鱼  阅读(754)  评论(0)    收藏  举报