Electronic – Question about sentence in application note: “incremented modulo-256”. Request explanation and clarification

802.15.4wireless

Context: I am reading an application note for a UWB transceiver. In it they are describing the typical message frame format, in accordance with IEEE rules. There is some wording that is confusing me and I am unsure whether I need to implement anything on the host controller, in accordance with this information.

In this application note (pg. 6 of 15)

It says

The sequence number octet is incremented modulo-256 for every frame sent, as per IEEE rules. The
source and destination addresses are either 64-bit numbers programmed uniquely into each unit
(during manufacture) or 16-bit addresses temporarily assigned. The 2-octet FCS is a CRC frame
check sequence following the IEEE standard, (this can be generated automatically by the DW1000 IC
and appended to the transmitted message)

In the IEEE standard (802.15.4-2011) (pg. 59)

It states:

5.2.1.2 Sequence Number field

The Sequence Number field specifies the sequence identifier for the frame.
For a beacon frame, the Sequence Number field shall specify a BSN. For a
data, acknowledgment, or MAC
command frame, the Sequence Number field shall specify a DSN that is used to
match an acknowledgment
frame to the data or MAC command frame.

I understand the principles of modulo arithmetic and I understand (and please correct me if this is wrong) that the sequence number refers to a frame and its order within a greater sequence of frames. However, the wording "increments by modulo-256" has thrown me a little.

Does it mean that it will bit shift a single bit, within an octet, once every time a frame is sent until a pre-defined number of frames have been sent? Do I need to process this to piece the greater sequence together?

Any help is appreciated.

Best Answer

It just means that the number is incremented. But when it reaches the value 255 the next value will be 0.

Thus the sequence will be:
0, 1, 2, 3, .... 250, 251, 252, 253, 254, 255, 0, 1, 2, ...

You will get this behavior if you use an uint8_t ( #include <stdint.h>) and increment it:

#include <stdint.h>

uint8_t sequence_number=0;
...
   sequence_number++;