You are on page 1of 6

ANALYSIS OF CRC-POLYNOMIALS FOR SAFETY-CRITICAL

COMMUNICATION BY DETERMINISTIC AND STOCHASTIC AUTOMATA

Frank Schiller and Tina Mattes

Munich University of Technology


Institute of Information Technology in Mechanical Engineering
Automation Group
Boltzmannstr. 15, D-85748 Garching near Munich
{Schiller, Mattes}@itm.tum.de

Abstract: The Cyclic Redundancy Check (CRC) is an efficient method to ensure a low
probability of undetected errors in data transmission using a checksum as a result of poly-
nomial division. However, this probability depends extremely on the polynomial used.
Although CRC is well established in communication, it is still a challenge to identify
suitable polynomials. The determination of their characteristics becomes very complex in
safety-critical applications, where many data have to be exchanged with minimal residual
error probability. This complexity is handled by means of deterministic and stochastic
automata in the presented solution. Copyright 2006 IFAC

Keywords: data transmission, error-detecting codes, checksum, modeling errors,


deterministic automaton, stochastic automaton, safety analysis.

1. INTRODUCTION zero voltage). These kinds of states are usually faster


and easier to achieve than the state of normal opera-
Transmission of data is an essential functionality in tion.
automation systems. Sensors send data to processing
units like Programmable Logic Controllers (PLC) In the paper, the established and well known algo-
and these PLCs send data to actuators affecting the rithm for error detection CRC is modeled by specific
machine under control. In decentralized structures, deterministic and stochastic automata in order to
data are more and more processed by intelligent sen- enable the calculation of residual error probability
and additional characteristics for telegrams of length
sors and actuators. In all cases, the integrity of
up to kilobytes.
transmitted data is one of the most important features
of industrial communication and determines the The paper is structured as follows. After the presen-
quality of the overall automation system. tation of the principle of CRC with some remarks
about realization in Section 2 the problem of deter-
Several techniques have been developed in commu- mination of residual error probability is stated in
nication in order to detect and to correct errors, cf. Section 3 and some essential assumptions are for-
e.g. (Blahut, 2003; MacWilliams and Sloane, 1991; mulated. Current solutions to that problem are men-
Merchant, 2003; Sweeney, 1991). The goal of safety- tioned in Section 4. The new solution based on
critical communication is to detect errors and to initi- automata is explained in Section 5. Since there are
ate the transition of the overall process into a safe assumptions necessary to solve the problem in Sec-
state, see e.g. (IEC 61508, 2005). That state is not tions 4 and 5, additional characteristics are to be
necessarily the normal one but may also be a state of determined (Section 6). A few examples are given in
reduced functionality (like e.g. state of low speed or Section 7. Section 8 contains some conclusions.

944
2. PRINCIPLE OF CRC 3. PROBLEM DESCRIPTION

The CRC is an efficient method to create and evalu- The actual residual error probability depends on the
ate checksums for error detection. There the original length of the telegram n, the generator polynomial
message (called information bits or net data ND) g(x), and the bit error probability p.
consisting of m bits is handled as a binary polyno-
The bit error probability is the probability of corrup-
mial nd(x) of degree m-1 that is multiplied by xr and
tion of one bit. Usually a Binary Symmetric Channel
divided by the generator polynomial g(x) of degree r.
(BSC) is assumed, cf. (Peterson and Weldon, 1996):
The resulting remaining polynomial fcs(x) of degree
Each bit is corrupted independently of other bits, and
r-1 is called Frame Check Sequence (FCS) of length
a corruption from value 0 to value 1 occurs with
r, cf. (Castagnoli, 1989; Merchant, 2003; Wagner,
same probability like a corruption from value 1 to
1993; Wagner, 1986):
value 0. Additionally, values of p between 0 and 0.5
( nd ( x ) x r ) mod g ( x ) = fcs( x ) . (1) are considered only. Some additional characteristics
For instance, the bit pattern ND=[1010111] leads to without these assumptions are analyzed in Section 6.
nd ( x ) = 1 x 6 + 0 x 5 + 1 x 4 + 0 x 3 + 1 x 2 + 1 x1 + 1 x 0 The problem of determination of the residual error
= x 6 + x 4 + x 2 + x + 1. probability is stated as follows:
Assuming the generator polynomial g(x)=x3+1, the Given: length of telegram n,
FCS is obtained by applying equation (1): generator polynomial g(x) of degree r,
(( x 6 + x 4 + x 2 + x + 1) x 3 ) mod( x 3 + 1) = x 2 . bit error probability 0<p0.5,
Find: residual error probability Pre.
That means, the bit pattern FCS=[100] has to be
added to the original data ND. The resulting bit pat- The estimation (3) holds exactly for uniform distri-
tern of length n=m+r is called telegram TEL. In the bution at p=0.5 independently of the generator poly-
example, the telegram consists of ten bits, i.e. nomial. Therefore, the maximum value of Pre cannot
TEL=[1010111100]. It can be proved, see e.g. be less than 2-r.
(Wagner, 1993), that the following equation holds:
4. CURRENT SOLUTIONS
tel ( x ) mod g ( x ) (2)
= ( nd ( x ) x r + fcs( x )) mod g ( x ) = 0. Three main methods are distinguished in the litera-
The polynomial arithmetic is well described in e.g. ture, cf. Fig. 2.
Given: generator polynomial / telegram length
(Merchant, 2003) and (Wagner, 1993) and is not
needed in the following. Monte Carlo Direct code Transformed code
method analysis analysis

Realizations of CRC are developed for hardware and (weights) Ai


MacWilliams Identity
Bi (dual weights)
software, cf. e.g. (Castagnoli, 1989; Wagner, 1993). Pre Pre= f(Ai) Pre= f(Bi)
A standard way to implement the polynomial opera-
Fig. 2. Survey of current solutions (Mattes, 2004).
tion (1) is the application of a linear feedback shift
register (see Fig. 1). The number of bits of the regis- Direct code analysis. All 2m undetectable error pat-
ter is equal to the degree r of g(x). The gi denote the terns have to be generated explicitly because there
coefficients of g(x), and the bits of the register are exist 2m multiples of g(x) satisfying (2). The number
denoted by zi. The overall bit pattern of z=[zr-1 z0] of those of i erroneous bits (weights Ai) have to be
represents the state of the register. The input is sym- counted. Using these weights, Pre is calculated by
bolized by u. For u(x)=nd(x)xr, the final state corre- n
sponds to the solution of (1), for u(x)=tel(x) to the Pre = Ai p i (1 p ) n i .
solution of (2). i =1
Obviously, the generation of all these error patterns
zr-1 zr-2 zr-3 ... z1 z0 u
leads to a complexity of 2m and the computation be-
logical XOR
logical AND
comes feasible only for short telegrams.
gr=1 gr-1 gr-2 g1 g0 = 1
... Transformed code analysis. Instead of generating all
Fig. 1. Implementation of CRC by linear feedback undetectable error patterns of the original code, a
shift register. much smaller set of error patterns of the corre-
A rough estimation of the residual error probability sponding dual code is generated (with complexity of
Pre of CRC examines only the ratio of the number of 2r). The weights Bi of this code have to be deter-
non-detectable erroneous bit patterns of TEL to all mined. Based on these dual weights it is either possi-
possible erroneous bit patterns of TEL. The ratio can ble to calculate Pre directly or to calculate the weights
be calculated as follows, cf. e.g. (Merchant, 2003): Ai of the original code by means of the MacWilliams
Identity (MacWilliams and Sloane, 1991; Wolf, et
~ 2 1 2 1
m m
Pre = n = m+r < 2 r. (3) al., 1982). Both alternatives lead often to numerical
2 1 2 1 problems and inaccurate results (Mattes 2004).
The estimation (3) is sufficient for many applications
like transmission of voice, but not for safety-critical Monte-Carlo-Simulation. Random samples are used
communication where the residual error probability to estimate Pre by the ratio of the number of unde-
is closely related to hazards and accidents. tectable error patterns to the number of samples. This

945
method is an incomplete determination of estimation z(k) z(k+1)
(3) and therefore not reasonably applicable in safety- u(k)=0
0 0
critical applications. u(k)=1 u(k)=1

1 u(k)=0 1
5. SOLUTION BY MEANS OF AUTOMATA u(k)=0
u(k)=1
In the following, errors are modeled by superim- u(k)=1
2 u(k)=0 2
posed bit patterns (Section 5.1), and the correspond-
u(k)=1 u(k)=0
ing CRC process is modeled by a deterministic . .
automaton (Section 5.2). Its state relates to the state . .
. .
of the register in Fig. 1. The state transitions are ex-
tended by probabilities resulting from the bit error u(k)=1
2r-1 u(k)=0 2r-1
probability in the stochastic automaton (Section 5.3).
u(k)=1 u(k)=0
5.1 Modeling errors Fig. 3. Signal flow graph of the deterministic auto-
mata (5) of CRC.
Errors can be described by superimposed bit patterns
f(x). In this way, the CRC in the receiver checks the The state z(n)=(100)T in the receiver means that
following (cf. (2)): either an error-free or a non-detectable erroneous
transmission occurred, cf. (2).
(tel ( x ) + f ( x )) mod g ( x ) = 0 ?
Besides the application of the automaton (5) to the
That is (in the binary polynomial space) equivalent to calculation of fcs(x) in the sender (1) or to the check
tel ( x ) mod g ( x ) + f ( x ) mod g ( x ) = 0 ? of a telegram in the receiver (2), the automaton can
be applied to (4) as well. There each input bit at
Since equation (2) holds, the CRC in the receiver is
identical to the check value 1 means an erroneous bit (u(k)=f(k)). Since no
error could have occurred in the beginning, the
f ( x ) mod g ( x ) = 0 ? (4) process starts with state number 0.
Therefore, the analysis can be reduced to the specific z (k + 1)
case TEL=[00], where erroneous bits are modeled = M u =0 z ( k ) (1 f ( k )) + M u =1 z (k ) f ( k ), (6)
by bits at value 1 without any loss of validity, see z (0) = (1 0 K 0)T .
e.g. (Mattes, 2004; Wagner, 1993). In the next step, an extension of model (6) is made by
distinction of error-free state (0ok) and non detectable
5.2 Deterministic model of the CRC-process
erroneous state (0f). The modified signal flow graph
The implementation in Fig. 1 can be modeled by a is shown in Fig. 4.
deterministic automaton (Schiller and Mattes, 2005). z*(k) z*(k+1)
The input u is the telegram that is bitwise shifted into f(k)=0
0ok 0ok
the register. The present bit pattern z(k) in the regis- f(k)=1
ter and the present input bit u(k) determine the next
bit pattern z(k+1) in the register. The register content 0f f(k)=0 0f
f(k)=1
is therefore considered to be the state z of the f(k)=1
automaton in the following. The polynomial notation f(k)=0
1 f(k)=0 1
of the final state at k=n, z(n), is equivalent to the
f(k)=1
result of the CRC, see Section 2. Table 1 contains f(k)=1
f(k)=0
some examples of notations of the state. 2 2
f(k)=1 f(k)=0
Table 1. Notations of the state of the CRC .
.
.
.
. .
bit pattern state no. z(k)
[0 0 0 0] 0 (1 0 0 0 0 0 0)T f(k)=1
f(k)=0
[0 0 0 1] 1 (0 1 0 0 0 0 0)T 2r-1 2r-1
[0 0 1 0] 2 (0 0 1 0 0 0 0)T f(k)=1 f(k)=0
[0 0 1 1] 3 (0 0 0 1 0 0 0)T Fig. 4. Signal flow graph of the extended determinis-

tic automata (7) of CRC.
[1 1 1 1] 2r-1 (0 0 0 0 0 0 1)T
There the relation
The deterministic automaton can be formulated by z * ( k + 1)
z ( k + 1) = M *u =0 z * (k ) (1 f (k )) + M *u =1 z * ( k ) f (k ), (7)
= M u =0 z (k ) (1 u(k )) + M u =1 z (k ) u( k ), (5) z * (0) = (1 0 K 0)T
z (0) = (1 0 K 0) T . holds. The asterisk denotes the modified state space
Matrices M denote the transition matrices given u=0 compared to (6). The process starts here with the
or u=1, respectively. Each row and each column error-free state number 0ok.
contain exactly one 1 and remaining zeros. The In contrast to model (6), model (7) describes explic-
corresponding signal flow graph is depicted in Fig. 3. itly whether the register state at number 0 is a result
There the state values of z are symbolized by their of an error (state number 0f) or not (state number 0ok),
numbers according to Table 1. cf. Fig. 4.

946
5.3 Stochastic model of the CRC-process operation is applied to the number of erroneous bits
of both alternative paths, cf. Fig. 3.
Since error patterns occur with specific probabilities
according to the bit error probability p, i.e. the input The minimal telegram length is r+1 (ND of length
f(k) is at value 1 with probability p, the probability one, FCS of length r). Therefore, the initial state can
distribution P(z*) of the values of the state z* has to be given at k=r, since the values at r are easy to
be involved in the model: calculate:
P ( z * ( k + 1)) = M *u =0 P( z * ( k )) (1 p ) The values of all states different to state number 0 at
+ M *u =1 P ( z * ( k )) p, (8) k=r correspond to the number of ones in the bit pat-
P ( z (0)) = (1 0 0 ... 0)T .
*
tern (see Table 1), e.g. state number 1 at value 1,
Note, that the transition matrices M* are identical to state number 2 at value 1, state number 3 at value 2,
the matrices in model (7). state number 4 at value 1, and state number 2r-1 at
value r. Since the feedback of the register in Fig. 1
The final result of application of model (8) at k=n is has not been active yet for k=1 to k=r, these values
the probability distribution P(z*(n)), where its second are equal to the exact number of erroneous bits
element (probability of state number 0f) is equal to necessary to achieve these state numbers.
the probability the CRC in the receiver would not
detect the error since the register state z(n) is at state The value of state number 0 at k=r is set to any value
number 0. greater than r, e.g. r+1. This value will be overwrit-
ten in step k=r+1 because of application of the mini-
Fundamental principles of stochastic automata are mum operation described above. From k=r+1 on, the
described in e.g. (Lunze and Schrder, 2001). Their value of the first element of z (state number 0) repre-
application here enables an efficient analysis of sents the minimum number of erroneous bits neces-
polynomials for telegrams of length up to kilobytes. sary to reach state number 0, i.e. the state of a non-
That is impossible by application of other approaches detectable error.
because of complexity or accuracy reasons (cf. Sec-
tion 4). Additionally, the residual error probabilities Therefore, the determination of HD is formalized as
of all telegrams of length k smaller than n are calcu- follows:
lated as a side effect. z ( k + 1) = min( M u =0 z (k ), M u =1 z ( k ) + (1L1)T ),
z ( r ) = ( r + 1 1 1 2 1 K r 1 r )T
6. DETERMINATION OF OTHER PROPERTIES The value of the first element of z(n) stating mini-
mum number of erroneous bits necessary to achieve
In addition to the residual error probability, other so state number 0 (the non-detectable error) after in-
called deterministic properties are to be analyzed in volving n bits is equal to the HD of a telegram of n
order to decide about the use of a polynomial for bits using a CRC with the generator polynomial
CRC in safety-critical applications: applied for generation of matrices Mu=0 and Mu=1.
1. Hamming distance.
2. detection of bitwise inverted telegrams, Detection of bitwise inverted telegrams. A bitwise
3. detection of erroneous telegrams containing only inverted telegram will usually be detected by wrong
zeros or only ones, sequence numbers, addresses, etc. However, CRC
4. detection of all odd numbers of erroneous bits, may detect such errors, too. This property can be
5. detection of burst errors, easily proved by the application of automaton (6)
such that all bits are erroneous (f(k)=1). Only if the
Properties 1, 2, and 3 can be determined based on the final state z(n) is equal to state number 0 (all register
automata presented above. bits are at zero) then this error cannot be detected.
Determination of Hamming distance. The Hamming Detection of erroneous telegrams containing only
distance HD of a code is defined to be the minimal zeros or only ones. These errors are usually a result
number of positions two words of the code differ of stuck-at-errors in communication devices. By set-
(Hamming, 1950). ting the initial state of the register in Fig. 4 or model
For example, a HD of 6 means in communication (5), respectively, it can be guaranteed, that a
that at least 6 bits of a telegram have to be erroneous FCS=[00] will never fit to the information bits
before the error is not detectable, i.e. another valid ND=[00]. The same holds for FCS=[11] and
code word is received. All telegrams with less than 6 ND=[11]. The appropriate inversion of model (5)
erroneous bits will be detected. allows determining that initial state that has to be
This property is determined based on the determinis- excluded. Since another register circuit is often used
tic model (6). There the allocation of the state is where an explicit multiplication by xr proceeds in-
changed to the meaning minimal number of errone- stead of adding r zero-bits to the input, two forbidden
ous bits necessary to achieve that state number. In initial states are given for the examples in Section 7.
each step, this minimal number is transmitted to the Detection of all odd numbers of erroneous bits. It is
corresponding next state according to Mu=0 without a known that a CRC with a polynomial containing
change (present bit is correct) and increased by 1 and (x+1) as a factor will detect all odd numbers of erro-
transmitted to the corresponding next state according neous bits, e.g. (Tanenbaum, 1996; Koopman and
to Mu=1 (present bit is erroneous). The minimum Chakravarty, 2004). This can be shown by generali-

947
zation of a polynomial division by (x+1) (note: +
means exclusive or for binary polynomials):
(an x n + an 1 x n 1 + an 2 x n 2 + L) : ( x + 1) = an x n 1 +
an x n + an x n 1 ( an 1 + an ) x n 2
n 1 n 2
( an 1 + an ) x + an 2 x + L +L
( an 1 + an ) x n 1 + (an 1 + an ) x n 2
( an 2 + an 1 + an ) x n 2 + L
M
( a0 + L + an 1 + an )
The remainder (a0++an) is equal to the exclusive
or operation of all erroneous bits and therefore not
zero for an odd number of such bits.
Detection of burst errors. Adjacent erroneous bits are
called burst errors. Each polynomial of degree r al-
lows the detection of burst errors up to the length of
r-1, see e.g. (Wagner 1993). Consider a burst error
fburst at position q in a telegram: Fig. 6. Residual error probability of polynomial
( f burst ( x ) x q ) mod g ( x ) = 0 13613h for 160 information bits.
(( f burst ( x ) mod g ( x )) x q ) mod g ( x ) = 0
The lowest coefficient g0 of g(x) is always at 1, see
Fig. 1. Therefore, xq is not divisible by g(x). If the
length of a burst is smaller than r, than the result of
the modulo-operation cannot be 0. Therefore, any
single burst of length smaller than r at any position
will be detected.
7. EXAMPLES
In the following, some examples of polynomials are
analyzed by the methods described above. As usual,
they are denoted by their hexadecimal value.
Polynomial 13613h. The residual error probability of
a telegram of 128 bits, i.e. 112 information bits, is
depicted in Fig. 5, that one of 160 information bits in
Fig. 6. Since the residual error probability depends Fig. 7. Maximum residual error probability of poly-
on the length of the telegram, it is useful to identify nomial 13613h for 1 to 300 information bits.
the maximum residual error probability for 0<p0.5
of each considered telegram length. The result for the Polynomial 14EABh. That polynomial is used for
polynomial 13613h is given in Fig. 7. Note, the re- safety-critical communication by the PROFIsafe
sidual error probability increases by factor 100. The protocol. The residual error probability of a telegram
polynomial has a HD of 8 from 1 to 5 and of 6 from of 112 information bits is depicted in Fig. 8. The
6 to 135 information bits before it sinks to 2. A maximum residual error probability for 1 to 300 in-
bitwise inverted telegram is not detectable using that formation bits is shown in Fig. 9. The polynomial has
polynomial for 286 information bits. That is usually a HD of 10 from 1 to 2, of 8 from 3 to 9, and of 6
not a problem because the length of 286 information from 10 to 112 information bits before it sinks to 2.
bits does not fit into a byte structure. A bitwise inverted telegram is not detectable using
that polynomial for 492 information bits.

Fig. 5. Residual error probability of polynomial Fig. 8. Residual error probability of polynomial
13613h for 112 information bits. 14EABh for 112 information bits.

948
find the Hamming distance and other so called
deterministic criteria, cf. Sections 5.2 and 6. Further
research work will be done in order to make use of
these advantages and to extend the approach to a
constructive and efficient way to identify suitable
polynomials for CRC.

REFERENCES
Blahut, R. E. (2003). Algebraic codes for data
transmission, Cambridge University Press.
Fig. 9. Max. residual error probability of polynomial Castagnoli, G., (1989). On the Minimum Distance of
14EABh for 1 to 300 information bits. Long Cyclic Codes and Cyclic Redundancy-
Polynomial C599h. That polynomial is used by the Check Codes, ETH Zurich, Diss. No. 8979.
CAN protocol. It has a HD of 8 from 1 to 7 and a HD Hamming, R. W. (1950). Error Detecting and Error
of 6 from 8 to 112 information bits before it sinks to Correcting Codes. In: Bell System Tech. J., No.
2. A bitwise inverted telegram is not detectable using 29, pp. 147-160.
that polynomial for 239 information bits. The maxi- International Electrotechnical Commission (2005).
mum residual error probability for 1 to 300 informa- Functional safety of electrical/electronic/
tion bits is shown in Fig. 10. programmable electronic safety-related systems,
(IEC 61508).
Koopman, P. and T. Chakravarty (2004). Cyclic
Redundancy Code (CRC) Polynomial Selection
for Embedded Networks. In: International Con-
ference on Dependable Systems and Networks,
DSN 2004, pp. 145-154. Florence, Italy.
Lunze, J. and J. Schrder (2001). State observation
and diagnosis of discrete-event systems described
by stochastic automata. In: Discrete Event Dy-
namic Systems: Theory and Applications, No. 11,
pp. 319-369.
MacWilliams, F.J. and N.J.A. Sloane (1991). The
Fig. 10. Max. residual error probability of polyno- Theory of Error-Correcting Codes, North-
mial C599h from 1 to 300 information bits. Holland Mathematical Library.
Mattes, T. (2004). Untersuchungen zur effizienten
Polynomial 1FFEDh. Fig. 11 shows the maximum Bestimmung der Gte von Polynomen fr CRC-
residual error probability from 1 to 50 information Codes, Univ. of Trier, Siemens AG, Nuremberg.
bits. There the residual error probability increases up Merchant, K. (2003). CRC-Test einmal ganz anders
to 6 and decreases up to 16 information bits. betrachtet. In: Elektronik, 23/2003, pp. 86-92.
Peterson, W.W. and E.J. Weldon (1996). Error
Correcting Codes, MIT Press.
Schiller, F. and T. Mattes (2005). An efficient
method to evaluate CRC polynomials for safety-
critical industrial communication. In: 11th Int.
Symposium on System-Modelling-Control, SMC
2005, pp. 269-274. Zakopane, Poland.
Sweeney, P. (1991). Error Control Coding, Prentice
Hall, London.
Fig. 11. Max. residual error probability of polyno- Tanenbaum, A. (1996). Computer Networks, Prentice
mial 1FFEDh for 1 to 50 information bits. Hall, London.
Wagner, M. (1993). CRC-Verfahren in der Theorie
8. CONCLUSIONS und Praxis, Grundlagen der Implementierung
und Prfung von CRC-Tests, Siemens AG,
It has been shown that CRC-polynomials can be Nuremberg.
analyzed by means of deterministic and stochastic Wagner, M. (1986). On the Error Detecting
automata. These automaton-based approaches have Capability of CRC Polynomials. In:
some advantages compared to conventional analyz- Informationstechnik it, 28. Jahrgang, No. 4/1986,
ing techniques. For instance, they enable the appli- pp. 236-241.
cation of CRC to telegrams of lengths the quality Wolf, J. K., A. Michaelson and A. Levesque (1982).
could not be proved to before. A stochastic automa- On the probability of undetected errors for linear
ton has been used to determine the residual error block codes. In: IEEE Transactions on communi-
probability, cf. Section 5.3, a deterministic one to cations, Vol. 30, No. 2, pp. 317-324.

949

You might also like