maksimio / simple-anti-noize-coding

Simple algorithms for error-correcting coding and decoding of a message

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Noiseless coding📺

This repository contains a set of encoder and decoder that redundantly encode and decode a message. The encoded message is obtained resistant to two types of distortion:

  1. Uniform bit noise up to 1%
  2. Loss of significant message blocks

Project structure📃

The two files encoder.py and decoder.py contain, respectively, only the encoder and decoder code. They are controlled, that is, the cycle of encoding-decoding, is carried out by the controller.py. This controller also simulates the distortion of the encoded transfer file.

Encoding way📥

Algoritm of encoding:

  1. Compress input file (with zlib)
  2. Split compressed file into chunks and add checksum and sequence number to each chunk
  3. Duplicate this binary string multiple times
  4. Apply three bit encoding

Decoding way📤

The decoding algorithm is the opposite of the encoding algorithm. However, we wrote a special function read_corrupted_file that allows you to unpack even a damaged archive at least partially.

Here we are trying to find one intact chunk with CRC32 and place them in order to unzip the message.

Three bit coding💬

Сoding each bit with three allows at the decoding stage to correct single bit errors in each bit-triple. Its implementation slows down the program hundreds of times.

Why is compression using❔

The use of such an algorithm was an attempt (unsuccessful) to earn points in the distance NTI Olympiad (Russia).

Something went wrong, the message was not transmitted. Our team still doesn't understand why it didn't work. But I find this code worthy of being here.

In NTI Olympiad, the source file had the content as file 1_input.dat. Therefore, the compression in our case was effective.

About

Simple algorithms for error-correcting coding and decoding of a message


Languages

Language:Python 100.0%