Paragon-X: How is the CCSA ToD FCS Calculated?

My Paragon-X can generate China Mobile (CCSA) format time of day (ToD) messages. How does it calculate the Frame Check Sequence (FCS) for the generated messages?

CCSA ToD frame structure

The CCSA ToD frame structure is defined as:

The ToD frame is set as a multiple of 8 bits (octets) with FCS. The ToD can be identified by its message CLASS and message ID. The transmission of octets starts from bit 0 (LSB). The transmission of multi-octet fields of the frame (e.g. the length and payload fields) complies with the big-endian rules.  

The interpretation of ToD information is as follows:

  • Start of Frame (SoF)
    The start of the ToD frame has two octets: SYNC CHAR 1 and SYNC CHAR 2. These two octets are used for frame alignment without any specific means. A common value of 0x43 and 0x4D has been given to each octet, representing ASCII “C” and “M” respectively.
  • Header
    The ToD header includes the message CLASS and message ID. CLASS shows the basic type of ToD message; ID is encoded as the subtype of each class of message.
  • Length
    The Length field has two octets which indicates the length of the payload (excluding the length of SoF, Header, Length and FCS field).
  • Payload
    The Payload field contains the contents of the ToD message which may vary in length.
  • FCS
    The FCS is one octet. The checksum includes message Header, Length, and Payload fields. The polynomial for generating the FCS is G(x) = x8 + x5 + x4 + 1. The initial value of the field should be set to 0xFF. The right shift operation should be used, and there should be no bit inversion of the input and output values. The transmission of the octet should follow the same bit order as other data octets.

CCSA ToD frame examples

An example of a CCSA ToD frame is:

Start of Frame: 0x43, 0x4D

Header: 0x01, 0x20

Length: 0x00 0x10

Payload: 0x00, 0x02, 0xFF, 0x45, 0x00, 0x00, 0x00, 0x00, 0x06, 0x16, 0x0F, 0x00, 0xFF, 0x00, 0x00, 0x00.

FCS: 0x17

A second example of a CCSA ToD frame is:

Start of Frame: 0x43, 0x4D

Header: 0x01, 0x03

Length: 0x00, 0x10

Payload: 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

FCS: 0xF7

CRC Calculator website

The website http://www.zorc.breitbandkatze.de/crc.html provides a public CRC calculator to calculate FCS sequences. The screenshot below shows the website calculating the FCS value 0x17 from the first CCSA ToD packet example above.



To calculate an FCS using this website, use these settings:

CRC Order:          8

CRC polynom:      31

Initial Value:          ff

Select the direct radio button

Final XOR value:  00

Tick the reverse data bytes checkbox

Tick the reverse CRC result before Final XOR checkbox.

The CCSA ToD frame data may be typed into the Data Sequence box as shown. Some points to note:

The data sequence to enter is the ToD frame Header, Length and Payload only.

Don't enter the first two (sync) bytes of the message as they are not included in the FCS calculation.

Each hex byte is prefixed by a % rather than the 0x normally used to denote hex numbers.

The calculator appends an “Initial value” for the CRC of 0xff so don't include a byte for the FCS in the data sequence.

The website calculator assumes a leading 1 when you enter the CRC polynomial. Polynomial x8 + x5 + x4 + 1 converts to 0b_1_0011_0001, or hex 0x131. Thus, removing the leading 1 that represents the x8 term gives the value 0x31 to represent the polynomial.

Calnex has deployed Paragon-X instruments with network operators and equipment vendors in China who have verified the calculation method and provided the two example CCSA ToD frames used in this note.