Sip架构理解

接触到GB28181或者是基于sip协议的视频直播、视频会议、VOIP的同志肯定都离不开sip协议的学习,今天我们就来一起聊聊sip协议的架构。

学习sip协议最重要的是要弄清楚sip协议的3个核心定义:dialog(对话)、session(会话)、transaction(事务)把这3部分梳理清楚就可以清楚的看到sip协议栈的基本架构了。见图1

图1

Dialog:

A key concept for a user agent is that of a dialog. A dialog represents a peer-to-peer SIP relationship between two user agents that persists for some time. The dialog facilitates sequencing of messages between the user agents and proper routing of requests between both of them. The dialog represents a context in which to interpret SIP messages. Section 8 discussed method independent UA processing for requests and responses outside of a dialog. This section discusses how those requests and responses are used to construct a dialog, and then how subsequent requests and responses are sent within a dialog.

A dialog is identified at each UA with a dialog ID, which consists of a Call-ID value, a local tag and a remote tag. The dialog ID at each UA involved in the dialog is not the same. Specifically, the local tag at one UA is identical to the remote tag at the peer UA. The tags are opaque tokens that facilitate the generation of unique dialog IDs.

对话:

对话对于用户代理(UA)来说是一个特别重要的概念。他代表着两个用户代理之间的端到端的SIP关系,这种关系会维持一段时间。对话可以确保两个用户代理之间的消息次序正常,同时为请求提供准确的路由信息(深入理解sip的同志应该知道,这是dialog中 route set 提供的路由信息)。对话代表一个上下文环境,依据此上下文环境可以理解SIP消息的内容。第8节讨论了请求和响应在一个对话以外的独立UA处理方法。本节讨论这些请求和应答是如何去创建一个对话,然后如何在对话内发送后续的请求和应答。

在UA中对话是通过 dialog ID 来标识的,dialog ID是由 Call-ID、local tag 和 remote tag 三部分组成。在一个对话中不同UA之间的 dialog ID 是不同的。需要特别说明的是,在一个UA中的 local tag 与其对方的 remote tag 是一样的。tag 是透明的标记,这有助于生成独一无二的 dialog ID。

transaction:

Transactions have a client side and a server side. The client side is known as a client transaction and the server side as a server transaction. The client transaction sends the request, and the server transaction sends the response. The client and server transactions are logical functions that are embedded in any number of elements. Specifically, they exist within user agents and stateful proxy servers. Consider the example in Section 4. In this example, the UAC executes the client transaction, and its outbound proxy executes the server transaction. The outbound proxy also executes a client transaction, which sends the request to a server transaction in the inbound proxy. That proxy also executes a client transaction, which in turn sends the request to a server transaction in the UAS. This is shown in Figure 4.

事务:

事务包含两个两种角色,分别是客户角色和服务角色。发挥客户角色的叫客户端事务,发挥服务角色的叫服务端事务。客户端事务发送请求,服务端事务发送响应。客户端事务和服务端事务都是包含在实体内的逻辑上的功能。需要特别强调的是他们存在于用户代理或者有状态的代理服务器中。回想一下第四节中的例子。在这个例子中 UAC 执行客户端事务,向外代理服务器执行服务端事务。向外代理服务器同时执行客户端事务,因为他要发送请求到向内代理服务器。向内代理服务器同时也执行客户端事务,因为他要把请求发送给UAS 中的服务端事务。图示见figure 4(即下图,源自rfc3261)

  • 3
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

heibao111728

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值