3.3.1.1 Algorithm for Handling Available Message Sequence Numbers by the Server
The server MUST implement an algorithm to manage message sequence numbers. Sequence numbers are used to associate requests with responses, and to determine what requests are allowed for processing. The algorithm MUST meet the following conditions:
When an SMB2 transport connection is first established, the allowable sequence numbers that comprise the valid command window for received messages on that connection MUST be the set { 0 }.
After a sequence number is received, its value MUST never be allowed to be received again. (After the sequence number 0 is received, no other request that uses the sequence number 0 shall be processed.) If the 64-bit sequence wraps, the connection MUST be terminated.
As credits are granted as specified in section 3.3.1.2, the acceptable sequence numbers MUST progress in a monotonically increasing manner. For example, if the set consists of { 0 }, and 3 credits are granted, the valid command window set MUST grow to { 0, 1, 2, 3 }.
The server MUST allow requests to be received out of sequence. For example, if the valid command window set is { 0, 1, 2, 3 }, it is valid to receive a request with sequence number 2 before receiving a request with sequence number 0.
The server MAY limit the maximum range of the acceptable sequence numbers. For example, if the valid command window set is { 0, 1, 2, 3, 4, 5 }, and the server receives requests for 1, 2, 3, 4, and 5, it MAY<203> choose to not grant more credits and keep the valid command window set at { 0 } until the sequence number 0 is received.
The client's request consumes at least one sequence number for any request except the SMB2 CANCEL Request. If the negotiated dialect is SMB 2.1 or SMB 3.x and the request is a multi-credit request, it consumes sequence numbers based on the CreditCharge field in the SMB2 header, as specified in 3.3.5.2.3.
For the client side of this algorithm, see section 3.2.4.1.6.