# Longitudinal redundancy check

In telecommunication, a longitudinal redundancy check (LRC), or horizontal redundancy check, is a form of that is applied independently to each of a parallel group of bit streams. The data must be divided into , to which the additional check data is added.

The term usually applies to a single parity bit per bit stream, calculated independently of all the other bit streams (), although it could also be used to refer to a larger Hamming code.

This “extra” LRC word at the end of a block of data is very similar to checksum and CRC.

## Optimal rectangular code

While simple longitudinal parity can only errors, it can be combined with additional error-control coding, such as a transverse redundancy check, to errors. The transverse redundancy check is stored on a dedicated “parity track”.

Whenever any single-bit error occurs in a transmission block of data, such two-dimensional parity checking, or “two-coordinate parity checking”, enables the receiver to use the TRC to detect which byte the error occurred in, and the LRC to detect exactly which track the error occurred in, to discover exactly which bit is in error, and then correct that bit by flipping it.

## Pseudocode

International standard ISO 1155 states that a longitudinal redundancy check for a sequence of bytes may be computed in software by the following algorithm:

>source lang=”text”> Set LRC = 0 For each byte b in the buffer do

`Set LRC = (LRC + b) AND 0xFF `

end do Set LRC = (((LRC XOR 0xFF) + 1) AND 0xFF) >/source>

which can be expressed as “the 8-bit two’s-complement value of the sum of all bytes modulo 2>sup>8>/sup>” (>code>x AND 0xFF>/code> is equivalent to >code>x MOD 2>sup>8>/sup>>/code>).

Many protocols use an XOR-based longitudinal redundancy check byte (often called or BCC), including the (SLIP), the -21 standard for electrical-meter reading, smart cards as defined in , and the protocol.

An 8-bit LRC such as this is equivalent to a cyclic redundancy check using the polynomial x>sup>8>/sup> + 1, but the independence of the bit streams is less clear when looked at in that way.

## Source

http://wikipedia.org/