# SDLC Frame Check Sequence details

In the Synchronous Data Link Control (SDLC) protocol, the frame contains a "frame-check-sequence" (a CRC). The protocol contains a number of other implementation details, such as NRZI encoding, and zero-bit insertion when the data contains too many contiguous 1's (so the data is not mistaken for the end-frame flag).

Three people seem to have three different interpretations on how to implement this FCS algorithm, based on the documentation not being explicit:

• One engineer says you must decode the NRZI encoding and discard the inserted-zero bits, and then the remaining bits will be pushed through a FCS algorithm.
• Another engineer says you must decode the NRZI encoding, but keep the zero-inserted bits when pumping data into the FCS algorithm.
• Another engineer says the FCS algorithm just inserts the raw data bits, not decoded and still containing inserted zero bits.

Could someone clarify which scenario is correct (or if none of them are, what is the correct sequence)? Or, if someone has an example waveform (raw logic levels as seen on the physical medium), that would help.

• SDLC is normally known for something else. Being that your protocol might be bespoke, you can decide on whatever method you want to implement. – Andy aka Nov 14 at 14:56
• I stated "Synchronous Data Link Control," an old IBM protocol. en.wikipedia.org/wiki/Synchronous_Data_Link_Control. I can't just "decide" to do anything, it has to be correct. – user2913869 Nov 14 at 15:01
• It has been quite a while since I did SDLC, but all the protocols with frame check sequences that I have used that have some form of non-deterministic link coding (of which zero bit insertions is an example) compute the FCS prior to link coding and therefore compute the received FCS after link decoding. – Peter Smith Nov 14 at 15:22
• IBM concepts manual including FCS: bitsavers.trailing-edge.com/pdf/ibm/datacomm/… – Peter Smith Nov 14 at 15:33

Could someone clarify which scenario is correct

It's the first one you listed:

One engineer says you must decode the NRZI encoding and discard the inserted-zero bits, and then the remaining bits will be pushed through a FCS algorithm.

Sequence of events

The SDLC FCS is calculated at the transmitter on the raw contents of the Address, Control & Information fields, before bit-stuffing and NRZI encoding (*) is done. The bit-stuffing and NRZI encoding is done "just before" transmission, after the FCS has been calculated.

At the receiver, the NRZI encoding and bit-stuffing are reversed first. Then the frames (consisting of the Address, Control and Information fields, and the transmitted FCS) are fed into the FCS checker. That means that the FCS checker (which is later in the processing pipeline) can't even get access to the datastream with the bit-stuffing still in it! That is why the other options you were given cannot be correct.

Confirmation

For confirmation, here is a block diagram of the receive path from the Zilog Z80C30/Z85C30 SCC (Serial Communications Controller) which implements SDLC:

Image source: Zilog Z80C30/Z85C30 SCC (Serial Communications Controller) datasheet

From the RXD input in the bottom-left, you can see that the sequence of processing is NRZI Decode, then Zero Delete (i.e. remove bit-stuffing), and only then, into CRC Checker (i.e. the FCS checker).

Summary

As I explained above, the receiver's FCS checker does not, and cannot, operate on the received bits which are still NRZI encoded or have bit-stuffing - those have already been reversed, before the frames go to the FCS checker. That is why only the one choice which I quoted above from your question, is correct.

(As kindly commented by Peter Smith, the old IBM manual "SDLC Concepts" is available online.)

(*) I have written the text above, assuming that NRZI encoding is being used. Although all the IBM SNA systems which I worked on used NRZI encoding (as far as I can remember - it was a long time ago!), I believe that there can be other encoding types, as long as both ends of a link use the same encoding, of course.