SequenceNumber fields are defined in different headers of the UADP or JSON Message Mapping.

A SequenceNumber is a monotonically increasing number assigned to messages headers represented by an unsigned integer of width N which is further specified in Table 135. The SequenceNumber starts at 0 and shall be incremented by exactly one for each message.

Receivers need to be aware of sequence numbers roll over (change from the largest possible value to 0).

To determine whether a received message is newer than the last processed message the following formula shall be used:

(received sequence number -1 – last processed sequence number) modulo 2^N

For the resulting value there is an upper bound and a lower bound depending on the bit width of the sequence number.

Results below the lower bound indicate that the received message is newer than the last processed message and it shall be processed.

Results above the upper bound indicate that the received message is older than (or same as) than the last processed message and it shall be ignored unless reordering of messages is required.

Other results are invalid and the message shall be ignored.

The lower bound is given as 2^(N-2).

The upper bound is given as 2^N – 2^(N-2).

Table 135 – Values for different sequence number sizes

DataType

Name

Value

Description

UInt16

Formula

(New-1-Last) modulo 65.536

Lower bound

16.384

2^14

Upper bound

49.152

2^16-2^14

UInt32

Formula

(New-1-Last) modulo 4.294.967.296

Lower bound

1.073.741.824

2^30

Upper bound

3.221.225.472

2^32-2^30

Subscribers shall discard the records they keep for sequence numbers if they do not receive messages for two times the keep alive time to deal with Publishers or brokers that are out of service and were not able to continue from the last used SequenceNumber.