[Computer Network Experiment 1] Haiming Code

xiaoxiao2021-03-05  55

1. The concept of Hay Ming Code is a code that can correct a wrong error. It uses the information bits to k bits, increasing the R bit, constitutes a n = k r bit codeword, and then uses the R correction factors generated by R-supervised relations to distinguish between unclear and codewords. One of the N different locations in the middle. It must meet the following relationship: 2R> = n 1 or 2R> = k r 1 sea maise code encoding efficiency is: r = k / (k r) in type k is the information bit bit number R to increase the redundancy The number of bits (these are copied from the Internet)

Example 3. Known: The information code is: "1 1 0 0 1 1 0 0" (k = 8) Seeking: Hymming Code. Solution: 1) Insert the redundant code A, B, C, ..., sequentially into the information code, to the Hai Ming Code word: "AB 1 C 1 0 0 D 1 1 0 0" code bits: 1 2 3 4 5 6 7 8 9 10 11 12 Where A, B, C, and D are plugged in 2k bits (k = 0, 1, 2, 3). The code bits are 1, 2, 4, 8, respectively. 2) The linear code bits of redundancys A, B, C, and D are: (equivalent to monitoring relationship) A-> 1, 3, 5, 7, 9, 11; b-> 2, 3, 6, 7 10, 11; C-> 4, 5, 6, 7, 12; (Note 5 = 4 1; 6 = 4 2; 7 = 4 2 1; 12 = 8 4) D-> 8 9, 10, 11, 12. 3) Volume of the value of the linear code bits as the value of redundant code (set by 0): a = σ (0, 1, 1, 0, 1, 0) = 1 b = σ (0, 1, 0, 0, 1, 0) = 0 c = σ (0, 1, 0, 0) = 1 D = σ (0, 1, 1, 0) = 0 4) Sea The yield is: "1 0 1 1 0 0 0 1 1 0 0" Hay Ming Code Reception. Example. Known: The received codeword is: "1 0 0 1 0 0 0 0 1 1 0 0" (k = 8) begins: the information code of the transmitting end. Solution: 1) Set the wrong accumulator (ERR) initial value = 0 2) Ask the redundant doll checks, and is accumulated in Err in the code bit: a = σ (1, 0, 1, 0, 1) , 0) = 1 Err = Err 20 = 1 b = σ (0, 0, 0, 0, 1, 0) = 1 Err = Err 21 = 3 c = σ (1, 1, 0, 0, 0 ) = 0 ERR = Err 0 = 3 d = σ (0, 1, 1, 0) = 0 Err = Err 0 = 3 by Err ≠ 0 to receive code word error, 3) Codeword errors The location is the value of the error accumulator (ERR). 4) Correction - The third bit of the code word is counter-correct code word: "1 0 1 1 0 0 0 1 1 0" 5) Delete the redundancy code at 2k bit: "1 1 0 0 1 1 0 0"

2. Programming to achieve Hayming Code (C )

The following this program is that the stuff in the example is a bit long, but after all, it is the first network experiment of the first network experiment.

# include # include void main () {int C [13]; int A, b, c, d; int err = 0; int K = 0; cout << "Input the Code ... "<< Endl; for (int i = 3; i <13; i ) {if (i == 4 || i == 8) i ; cout <<" << i << " Bit: "<< Endl; Cin >> C [I];} C [1] = ABS ((C [1] C [3] C [5] C [7] C [9] C [11])% 2); C [2] = ABS ((C [2] C [3] C [6] C [7] C [10] C [11])% 2); C [4] = ABS ((C [4] C [5] C [6] C [7] C [12])% 2); C [8] = ABS ((C [8] C [9] C [10] C [11] C [12])% 2); COUT << "The resulting sea code is:"; for (int J = 1; j <13; j ) cout << c [j]; cout << Endl; cout << "is now transporting time ... please decide to make this sea margin error" << Endl; cout << "error sequence?:" CIN >> K; C [0] = 1-c [k]; cout << "It turned out to" << c [k] << ", is now changed to" << C [0] << endl; C [K] = C [0]; C [1] = ABS ((C [1] C [3] C [5] C [7] C [9] C [11])% 2 ); C [2] = ABS ((C [2] C [3] C [6] C [7] C [10] C [11])% 2); C [4] = ABS ((C [4] C [5] C [6] C [7] C [12])% 2); C [8] = ABS ((C [8] C [9] C [10] C [11] C [12])% 2); COUT << "has arrived at the receiving end, the result of the inspection is:"; a = C [1]; b = C [2]; c = C [4]; D = C [8]; COUT << "ABCD: << a <<", "<< b <<", "<< c <<", "<< D << endl; IF (a == 1) Err = Err 1; if (b == 1) Err = Err 2; if (c == 1) Err = Err 4; if (D == 1) Err = Err 8; C [Err] = 1-C [Err]; COUT << "" "<< ERR <<" is wrong, the corrected result is: "; f OR (int M = 1; M <13; M ) cout << c [m]; cout << endl;

The result after COUT << "Remove the error code is:"; for (i = 3; i <13; i ) {if (i == 4 || i == 8) i ; cout << C [i] }}

Run results:

The problem is quite a lot, first, it is not simple enough, but that model 2 is really dizzy, I don't know if C has a simple implementation method.

I don't know which kind of people can help improve it.

转载请注明原文地址:https://www.9cbs.com/read-34652.html

New Post(0)