SIP中的被叫

在SIP中被叫到底应该是哪个字段,其实之前一直没有使用到,但是偶尔有这方面的需求,需要查询记录下。

首先我们知道在SIP中的被叫其实有2个地方

  • 第一个就是请求行,类似 INVITE 1001@172.27.16.4 SIP/2.0 中的URL中的 username
  • 第二个是 To 行,类似 To: <sip:1001@172.27.16.4> 中的URL中的 username

那么到底哪个才是被叫呢,这个时候就需要查询标准的 RFC 2543 文档了。

摘抄如下:rfc2543 (ietf.org)

The Request-URI is a SIP URL as described in Section 2 or a general
URI. It indicates the user or service to which this request is being
addressed. Unlike the To field, the Request-URI MAY be re-written by
proxies.

When used as a Request-URI, a SIP-URL MUST NOT contain the
transport-param, maddr-param, ttl-param, or headers elements. A
server that receives a SIP-URL with these elements removes them
before further processing.

Typically, the UAC sets the Request-URI and To to the same
SIP URL, presumed to remain unchanged over long time
periods. However, if the UAC has cached a more direct path
to the callee, e.g., from the Contact header field of a
response to a previous request, the To would still contain
the long-term, "public" address, while the Request-URI
would be set to the cached address.

Proxy and redirect servers MAY use the information in the Request-URI
and request header fields to handle the request and possibly rewrite
the Request-URI. For example, a request addressed to the generic
address sip:sales@acme.com is proxied to the particular person, e.g.,
sip:bob@ny.acme.com , with the To field remaining as
sip:sales@acme.com. At ny.acme.com , Bob then designates Alice as
the temporary substitute.

什么意思呢

  1. 一般请求下请求URI和 To 中的URI是相同的,To 是不会被改的
  2. 当被中间设备路由时候,请求URI可能会被改为缓存的路由地址

这么说来,当我们收到呼叫的时候,请求行其实就是被叫(我们自己地址),To 字段才是原被叫。

最近的文章

FLV中AAC格式

简单的记录一下,在合成FLV文件时候,按照规范必须是特定采样率的AAC才行,但实际上并没有这个要求,只需要携带AAC的 Audio Specific Config 就可以了。 AAC音频格式按照FLV的规范要求,AAC可设置的采样率如下。 0 = 5.5-kHz1 = 11-kHz2 = 22-kH …

技术 继续阅读
更早的文章

开发从RTP抓包中抽取H264视频的工具

需求场景经常使用抓包工具分析RTP视频的人来讲,在抓包工具很容易分析包信息,但是并不能像PCMA音频一样可以直接预览,因此视频内容正确与否很难判断,因此需要开发工具来从抓包内提取视频出来。 总的来说,归纳下需要实现的关键点 为了简单期间,需要提前讲视频流单独导出一个单独的抓包文件(用端口等规则过滤 …

技术 继续阅读