Skip to content

Instantly share code, notes, and snippets.

@OkiStuff
Last active April 29, 2022 01:18
Show Gist options
  • Save OkiStuff/a4bc74c43af96bce3744604243f365ae to your computer and use it in GitHub Desktop.
Save OkiStuff/a4bc74c43af96bce3744604243f365ae to your computer and use it in GitHub Desktop.

Error Correction

Parity is a bit that says if a string of binary should have an even or odd amount of ones

  • 0 is even
  • 1 is odd

Hamming Distance

Hamming Distance is (in this context) basically the amount of bits need to be flipped until error detection fails

Example

[0/1] is the parity bit

0101[0] has a hamming distance of 2 because only 2 bits need to be flipped until parity is even again

Example implemention

  • 03 is opcode for starting the metadata section
  • A0 is opcode for starting the row of parity bit section
  • A1 is opcode for starting the coloum of parity bit section
  • A3 is opcode for starting the final parity bit section (parity of all parity bits)
  • 04 is opcode for ending the metadata section
  • 05 is opcode for starting the frame section
  • 06 is opcode for ending the frame section

03 A0 [..row of parity bits..] A1 [..coloum of parity bits..] A3 [..final parity..] 04 05 [..data..] 06 [..rest of data..] 06

In the frame we have 06, which is also the opcode to end the frame. To prevent corrupted frames we can compare the frame to the paritys, because it was cut off, it will not match and we can ignore this 06

Hamming Distance of 4 bits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment