SIP CSeq for INFO and INVITE methods
Asked Answered
B

1

9

Consider this sample SIP dialog

    A-->--INVITE-->--B CSeq 101
    A--<--TRYING--<--B CSeq 101
    A--<--200 OK--<--B CSeq 101
    A-->-- ACK  -->--B CSeq 101
    A-->-- INFO -->--B CSeq 2
    A--<-- 500  --<--B CSeq 2
    ...

While working on a SIP handling code, we put a validation for CSeq of a SIP INFO message for a dialog to be greater than the one sent for the INVITE. However, as shown in the above SIP flow, one of the remote SIP gateways is sending it to be lower, ie 2 instead of the expected 102 or higher.

The RFC https://www.ietf.org/rfc/rfc3261.txt states that

Requests within a dialog MUST contain strictly monotonically increasing and contiguous CSeq sequence numbers (increasing-by-one) in each direction

So, is the observed behavior a violation of the RFC?

Borreri answered 5/2, 2018 at 16:17 Comment(0)
F
5

Yes, it is. You paraphrased the correct text.

The RFC on SIP INFO messages states CSeq header values follow the mechanism in RFC3261:

The Info Package mechanism does not define a delivery order mechanism. Info Packages can rely on the CSeq header field [RFC3261] to detect if an INFO request is received out of order.

However, keep in mind you can't rely on the received CSeq number being only one higher than the previously received one (https://www.rfc-editor.org/rfc/rfc3261#section-12.2.2):

It is possible for the CSeq sequence number to be higher than the remote sequence number by more than one. This is not an error condition, and a UAS SHOULD be prepared to receive and process requests with CSeq values more than one higher than the previous received request. The UAS MUST then set the remote sequence number to the value of the sequence number in the CSeq header field value in the request.

If a proxy challenges a request generated by the UAC, the UAC has to resubmit the request with credentials. The resubmitted request will have a new CSeq number. The UAS will never see the first request, and thus, it will notice a gap in the CSeq number space. Such a gap does not represent any error condition.

Forgotten answered 6/2, 2018 at 7:28 Comment(2)
So you want to say something like below : A--->--Cseq101--->-----B--->---Cseq2----->------C Here sequence number changed , from B to C new Cseq number generated . But in reverse path , i think it should be like below: A---<--Cseq102(or any other greater than 101)---<-----B---<---Cseq3(or any other greater than 2)-----<------C So , between A to B it will always greater than 101 . Is my understanding correct ?Reluctance
No, within a dialog CSeq numbers for both directions are not linked. If UA A sends more SIP requests than UA B the used CSeq number for UA A will increase faster, namely by 1 for each message sent. In your example, the next request sent by UA A will have CSeq 102; the request after that will have CSeq 103. The first request sent by UA B to UA A can have any value as long as it is less than 2**31 (rfc3261 8.1.1.5), say 12345. The second request sent by UA B will then have value 12346.Forgotten

© 2022 - 2024 — McMap. All rights reserved.