Search code examples
algorithmchecksumerror-correctionerror-detection

Error correction code for lost bit


If we have to receive a data from sender as a chunk of bits (say 8 bits).

But, the transferring is unreliable which result in bit-lost. (Not bit-flip) That mean, any bit in the chunk can be absent and receiver would receive only 7 bits.

I studied some error-correction coding, such as 'Hamming code'. But, the code is designed to recover fliped-bit not lost-bit in this situation.


Solution

  • If you are happy with a low entropy code and you can detect an end-of-message, you can simply send each bit twice.

    This code can recover from any number of deletions that happen in different runs:

    On receiving, find all odd-sized runs and extend them by one bit. If you end up with less than the expected count of bits, you are unable to recover from multiple deletion.

    If you want to ensure a fixed error rate that can be recovered, use bit-stuffing.

    Example:

    0110
    
    encoded as:
    00 11 11 00
    
    a double error occurs:
    0x 11 x1 00
    
    received:
    011100
    
    '0' and '111' are odd-sized runs. Fix:
    00111100
    
    we have 8 bits, and have recovered from a double error.
    decode:
    0110
    

    Example 2:

    0101
    
    encoded as
    00110011
    
    transmitted as
    0xxx0011
    
    received as
    00011
    
    corrected as
    000011
    
    decoded as
    001
    
    which is shorter than expected. A transmission error has occured.
    

    Example 3 (bit stuffing after a run of 3 bits):

    0000 1111
    
    stuffed as
    00010 11101
    
    sent as
    0000001100 1111110011