17 Transactions 17 事务 SIP is a transactional protocol: interactions between components take place in a series of independent message exchanges. Specifically, a SIP transaction consists of a single request and any responses to that request, which include zero or more provisional responses and one or more final responses. In the case of a transaction where the request was an INVITE (known as an INVITE transaction), the transaction also includes the ACK only if the final response was not a 2xx response. If the response was a 2xx, the ACK is not considered part of the transaction. SIP是一种事务协议:组件之间的交互发生在一系列独立的消息交换中。具体而言,SIP事务由单个请求和对该请求的任何响应组成,这些响应包括零个或多个临时响应和一个或更多个最终响应。在请求是INVITE的事务(称为INVITE事务)的情况下,仅当最终响应不是2xx响应时,事务还包括ACK。如果响应是2xx,则ACK不被视为事务的一部分。 The reason for this separation is rooted in the importance of delivering all 200 (OK) responses to an INVITE to the UAC. To deliver them all to the UAC, the UAS alone takes responsibility for retransmitting them (see Section 13.3.1.4), and the UAC alone takes responsibility for acknowledging them with ACK (see Section 13.22.2.4). Since this ACK is retransmitted only by the UAC, it is effectively considered its own transaction. 这种分离的原因源于向UAC传递对INVITE的所有200(OK)响应的重要性。为了将它们全部发送给UAC,UAS单独负责重新发送(见第13.3.1.4节),UAC单独负责用ACK确认它们(见第13.22.2.4节)。由于该ACK仅由UAC重新发送,因此它实际上被视为自己的事务。 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. 事务有客户端和服务器端。客户端称为客户端事务,服务器端称为服务器事务。客户端事务发送请求,服务器事务发送响应。客户端和服务器事务是嵌入在任意数量的元素中的逻辑函数。具体来说,它们存在于用户代理和有状态代理服务器中。请考虑第4节中的示例。在本例中,UAC执行客户端事务,其出站代理执行服务器事务。出站代理还执行客户端事务,该事务将请求发送到入站代理中的服务器事务。该代理还执行客户端事务,客户端事务又将请求发送到UAS中的服务器事务。如图4所示。 +---------+ +---------+ +---------+ +---------+ | +-+|Request |+-+ +-+|Request |+-+ +-+|Request |+-+ | | |C||------->||S| |C||------->||S| |C||------->||S| | | |l|| ||e| |l|| ||e| |l|| ||e| | | |i|| ||r| |i|| ||r| |i|| ||r| | | |e|| ||v| |e|| ||v| |e|| ||v| | | |n|| ||e| |n|| ||e| |n|| ||e| | | |t|| ||r| |t|| ||r| |t|| ||r| | | | || || | | || || | | || || | | | |T|| ||T| |T|| ||T| |T|| ||T| | | |r|| ||r| |r|| ||r| |r|| ||r| | | |a|| ||a| |a|| ||a| |a|| ||a| | | |n|| ||n| |n|| ||n| |n|| ||n| | | |s||Response||s| |s||Response||s| |s||Response||s| | | +-+|<-------|+-+ +-+|<-------|+-+ +-+|<-------|+-+ | +---------+ +---------+ +---------+ +---------+ UAC Outbound Inbound UAS Proxy Proxy Figure 4: Transaction relationships 图4:事务关系 A stateless proxy does not contain a client or server transaction. The transaction exists between the UA or stateful proxy on one side, and the UA or stateful proxy on the other side. As far as SIP transactions are concerned, stateless proxies are effectively transparent. The purpose of the client transaction is to receive a request from the element in which the client is embedded (call this element the "Transaction User" or TU; it can be a UA or a stateful proxy), and reliably deliver the request to a server transaction.
无状态代理不包含客户端或服务器事务。事务存在于一方的UA或有状态代理与另一方的UA/有状态代理之间。就SIP事务而言,无状态代理实际上是透明的。客户端事务的目的是接收来自嵌入客户端的元素的请求(将此元素称为“事务用户”或TU;它可以是UA或有状态代理),并将请求可靠地传递到服务器事务。
The client transaction is also responsible for receiving responses and delivering them to the TU, filtering out any response retransmissions or disallowed responses (such as a response to ACK). Additionally, in the case of an INVITE request, the client transaction is responsible for generating the ACK request for any final response accepting a 2xx response. 客户端事务还负责接收响应并将其传递给TU,过滤掉任何响应重传或不允许的响应(例如对ACK的响应)。此外,在INVITE请求的情况下,客户端事务负责为接受2xx响应的任何最终响应生成ACK请求。 Similarly, the purpose of the server transaction is to receive requests from the transport layer and deliver them to the TU. The server transaction filters any request retransmissions from the network. The server transaction accepts responses from the TU and delivers them to the transport layer for transmission over the network. In the case of an INVITE transaction, it absorbs the ACK request for any final response excepting a 2xx response. 类似地,服务端事务的目的是接收来自传输层的请求并将其传递给TU。服务端事务过滤来自网络的任何请求重传。服务器事务接受来自TU的响应,并将它们传递到传输层以通过网络进行传输。在INVITE事务的情况下,它吸收除2xx响应之外的任何最终响应的ACK请求。 The 2xx response and its ACK receive special treatment. This response is retransmitted only by a UAS, and its ACK generated only by the UAC. This end-to-end treatment is needed so that a caller knows the entire set of users that have accepted the call. Because of this special handling, retransmissions of the 2xx response are handled by the UA core, not the transaction layer. Similarly, generation of the ACK for the 2xx is handled by the UA core. Each proxy along the path merely forwards each 2xx response to INVITE and its corresponding ACK.
2xx响应及其ACK接受特殊处理。此响应仅由UAS重新传输,其ACK仅由UAC生成。需要这种端到端的处理,以便呼叫者知道已经接受呼叫的整个用户集。由于这种特殊处理,2xx响应的重传由UA核心处理,而不是事务层。类似地,2xx的ACK的生成由UA核心处理。沿着该路径的每个代理仅将每个2xx响应转发到INVITE及其对应的ACK。