From b1a3a7f79fa666009905adf87be78ff331fe637d Mon Sep 17 00:00:00 2001 From: Fred Allen Date: Wed, 23 Feb 2022 11:25:21 -0600 Subject: [PATCH] 9 - Added information to Learn page - fa --- web/src/components/Learn/Learn.jsx | 151 ++++++++++++++++++++++++++--- 1 file changed, 136 insertions(+), 15 deletions(-) diff --git a/web/src/components/Learn/Learn.jsx b/web/src/components/Learn/Learn.jsx index d72d435..ef97521 100644 --- a/web/src/components/Learn/Learn.jsx +++ b/web/src/components/Learn/Learn.jsx @@ -1,12 +1,49 @@ import React from 'react'; import './Learn.css'; +import { Link } from 'react-router-dom'; import HomeLink from '../sharedComponents/HomeLink'; import DisplayHammingGrid from './DisplayHammingGrid'; function Learn() { + const indexBits = { + parity: [1, 2, 4, 8], + counted: [], + bits: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + }; const dataBits = { parity: [1, 2, 4, 8], - counted: [0, 1, 2, 4, 8], + counted: [], + bits: [null, null, null, 0, null, 1, 1, 0, null, 1, 0, 0, 1, 0, 0, 1], + }; + + const setBit1 = { + parity: [1, 2, 4, 8], + counted: [1, 5, 9, 15], + bits: [null, 1, null, 0, null, 1, 1, 0, null, 1, 0, 0, 1, 0, 0, 1], + }; + + const setBit2 = { + parity: [1, 2, 4, 8], + counted: [2, 6, 15], + bits: [null, 1, 0, 0, null, 1, 1, 0, null, 1, 0, 0, 1, 0, 0, 1], + }; + + const setBit4 = { + parity: [1, 2, 4, 8], + counted: [4, 5, 6, 12, 15], + bits: [null, 1, 0, 0, 0, 1, 1, 0, null, 1, 0, 0, 1, 0, 0, 1], + }; + + const setBit8 = { + parity: [1, 2, 4, 8], + counted: [8, 9, 12, 15], + bits: [null, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1], + }; + + const setBit0 = { + parity: [1, 2, 4, 8], + counted: [0, 1, 5, 6, 8, 9, 12, 15], + bits: [1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1], }; return ( @@ -15,28 +52,112 @@ function Learn() {

Learn about Hamming codes

- Hamming codes were invented a long time ago by a guy whose name I will allow you to - guess. They were useful for detecting and correcting errors in transmitted data, until the - technology was usurped due to the efforts of two other guys named Reed and Solomon - (again, no hints about the name of the code they invented) + Let's say we attend school from September to April and we want to report the number + of hours we spent studying each month. There are eight months from September to April, + so we can represent the month in question with three bits of data since there are eight + possible combinations of three bits: +

+
000 = September,
+
001 = October,
+
010 = November,
+
011 = December,
+
100 = January,
+
101 = February,
+
110 = March, and 
+
111 = April
+

+ For the part of the message that represents hours spent studying, since we + can not send decimal numbers with bits directly, we first need to convert + them from decimal to binary: +

+
0 in decimal = 0 in binary
+
1 in decimal = 1 in binary
+
2 in decimal = 10 in binary
+
3 in decimal = 11 in binary
+
4 in decimal = 100 in binary
+
5 in decimal = 101 in binary
+
and so on...
+

+ So we inform the recipient that the first three bits of data we send will represent the + month, and the last 8 bits will represent the hours spent studying (we don't + plan to spend more than 255 hours studying in a month). +

+

+ But there's a problem: bits are transmitted through physical media and can + inadvertently be altered due to random phenomena. Therefore a 101 that was sent + may arrive as 001.

- Let's say we wanted to send a block of 11 bits of data. We can add just 5 bits of - data, for a total of 16 bits, to be able to - correct - one bit that was flipped during transmission or - detect - two bits that were flipped during transmission. + In 1950 Richard Hamming published a paper called + {' '} + Error detecting and error correcting codes + {' '} + that outlined a way for the computer to + {' '} + correct + {' '} + one bit that was flipped during transmission or to + {' '} + detect + {' '} + two bits that were flipped during transmission. Following is an example of how this works.

The grid below represents the bits we are sending in an arrangement that makes it easier - to visualize how the error correction works. Bits 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, - and 15 are the 11 bits that we want to send. Bits 1, 2, 4 and 8 - are the error-correcting bits and bit 0 is a parity bit. + to visualize how the error correction works. The numbers here do not represent the value + or data being sent (must be 0 or 1) but indicate the order that they will be + sent. Bits 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, and 15 are the 11 bits that we want to + send. Bits 1, 2, 4 and 8 are the error-correcting bits and bit 0 is a parity bit. +

+ +

+ Each error-correcting bit "counts" a group of data bits and becomes a 1 if there + are an odd number of 1 bits and a 0 if there are an even number of 1 bits. Let's + replace the index values of the bits with the data we want to send. If we spent 73 hours + studying in the month of December, we will need to send the code 01101001001, where 011 + represents the month of December and 01001001 is binary for 73. So + bit 3 will be set to 0, bit 5 will be set to 1, bit 6 will be set to 1, and so on.

+

+ Now we need to set the error correcting bits. Bit 1 will be a 0 if the bits directly + underneath it and the bits in the last column have zero or an even number of 1s. But there + are three ones, so we will set bit 1 to 1. +

+ +
+

+ Bit 2 will be set by the bits directly underneath it and the bits in the last column. + There are two 1s, bit 2 is set to 0. +

+ +

+ Bit 4 will be set by the bits directly to the right of it and the bits on the bottom + row. There are four 1s, so bit 4 is set to 0. +

+ +

+ Bit 8 will be set by the bits directly to the right of it and the bits on the botton + row. There are three 1s, so bit 8 is set to 1. +

+ +

+ Finally, bit 0 is set based on the number of 1s in the rest of the block. There are + seven 1s, so bit 0 is set to 1. +

+ +

+ Now there is enough information in the block to correct a single bit error and to + detect a two bit error. + {' '} + Give it a try! +

+
+

+ For further information, please see: +

+ Google
-
Links go here
); }