rence between a hop-by-hop request and an end-to- end request is shown in Figure 4.3. The CSeq is not incremented for this method SO that proxies and user agents can match the CSeq of the CANCEL with the CSeq of the pending INVITE to which it corresponds. Stateful proxy Request (end to end) Request (end to end) Response (end to end) Response (end to end) Request (hop by hop) Request (hop by hop) Response (hop by hop) Response (hop by hop) Figure 4.3 End-to-end versus hop-by-hop requests. SIP: Understanding the Session Initiation Protocol The branch ID for a CANCEL matches the INVITE that it is cancel- ing. A CANCEL only has meaning for an INVITE since only an INVITE may take several seconds (or minutes) to complete. All other SIP requests complete immediately (that is, a UAS must immediately generate a final response). Consequently, the final result will always be generated before the CANCEL is received. A proxy receiving a CANCEL forwards the CANCEL to the same set of locations with pending requests that the initial INVITE was sent to. A proxy does not wait for responses to the forwarded CANCEL requests, but responds immediately. A user agent confirms the cancellation with a 200 OK response to the CANCEL and replies to the INVITE with a 487 Request Termi- nated response. If a final response has already been received, a user agent will need to send a BYE to terminate the session. This is also the case in the race condition where a CANCEL and a final response cross in the network, as shown in Figure 4.4. In this example, the CANCEL and 200 OK response messages cross between the proxy and the UAS. The proxy still replies to the CANCEL with a 200 OK, but then also forwards the 200 OK response to the INVITE. The 200 OK response to the CANCEL sent by the proxy only means that the CANCEL request was received and has been forwarded-the UAC must still be prepared Stateful proxy INVITE INVITE CSeq: 1 INVITE CSeq: 1 INVITE 100 Trying 100 Trying CSeq: 1 INVITE CSeq: 1 INVITE CANCEL 200 OK CSeq: 1 CANCEL CSeq: 1 INVITE 200 O