天天看點

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的作用就是強制讓請求通過其包含的路由清單傳輸請求和應答)。