天天看点

sip中Via、Record-Route和Route set的区别和联系

要彻底明白三者之间的区别,首先得弄清楚三者的定义是什么?(见rfc3261)

via:

The Via header field indicates the path taken by the request so far and indicates the path that should be followed in routing responses. The branch ID parameter in the Via header field values serves as a transaction identifier, and is used by proxies to detect loops.

Route:

The Route header field is used to force routing for a request through  the listed set of proxies. Examples of the use of the Route header  field are in Section 16.12.1.

Record-Route:

The Record-Route header field is inserted by proxies in a request to  force future requests in the dialog to be routed through the proxy.

简单来说,via的作用就是标记请求所经过的节点,好让其对应的响应能按照via标记好的路径返回回去;Route set(一个请求或应答中可以包含多个Route标记,这些Route标记称为Route Set)的作用是强制请求必须从Route set中设定的节点通过,Route set的生成可以是手动配置也可以是协议自己生成,需要手动配置的情况如,客户端向registar注册的时候,registar的路径就应该是通过手动配置,协议自己生成的情况如在对话生成前各个proxy往请求中添加Record-Route为了让后续的请求能继续通过该proxy发送,当对话建立好后就确定了后续的请求该走的路由,之后将Record-Route中的记录登记在Route set中来强制请求的路由。

Record-Route的是各个想在后续请求对话中还继续接收请求和应答的Proxy,将自己的地址信息添加在Record-Route中来帮助协议生成最终的Route set(也就是为什么说对话中的请求和应答包含的是Route-set,对话外的请求包含的Record-Route的原因,Route set用在对话外的情况就是在注册时客户端最初不清楚该往哪里去注册,需要手动配置,总之一句话,Route set的作用就是强制让请求通过其包含的路由列表传输请求和应答)。