Cyclic redundancy check code generation method, device, equipment, medium and program product
By customizing the length and form of the bit sequence and the generator polynomial in the cyclic redundancy check, the cyclic redundancy check code is generated, which solves the problem of insufficient applicability and reliability of CRC code generation in the existing technology, and realizes various Efficient data transmission in chemical verification scenarios.
Patent Information
- Application Number
- CN202111533950.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-15
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-12-15
AI Technical Summary
In the existing technology, the cyclic redundancy check (CRC) code generation method has insufficient applicability and reliability when faced with diverse verification scenarios, and is difficult to meet the needs of complex data transmission.
By obtaining the network data to be verified and the preset generator polynomial, the corresponding coefficient matrix is calculated, and matrix multiplied with the input matrix to generate a cyclic redundancy check code, allowing the length and power of the bit sequence and generator polynomial Set by yourself to adapt to different verification scenarios.
It improves the applicability and reliability of cyclic redundancy check, can work effectively in various verification scenarios, adapts to different bit widths and polynomial forms, and improves the accuracy and reliability of data transmission.
Smart Images

Figure CN114389752B
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a cyclic redundancy check code generation method, device, equipment, medium and program product. Background Art
[0002] Cyclic Redundancy Check (CRC) is a method used to verify the accuracy of digital transmission on a data transmission link. Due to its strong error detection capability and low detection cost, CRC has been widely used in the transmission of network data.
[0003] The specific process of cyclic redundancy check is: the sender calculates the CRC code of the information contained in the transmitted data, and attaches this CRC code to the transmitted data to form a frame of data. The receiver performs the same calculation on the frame of data as the sender. If the CRC code obtained by the receiver is inconsistent with the CRC code obtained by the sender, it means that an error occurred in the transmission, and the receiver can ask the sender to resend the data.
[0004] The generation of CRC code is a key step in cyclic redundancy check. As the verification scenarios become more and more diverse, how to provide a universal CRC code generation method to improve the applicability and reliability of cyclic redundancy check has become a problem that needs to be solved urgently. Summary of the invention
[0005] Based on this, it is necessary to provide a cyclic redundancy check code generation method, device, equipment, medium and program product that can improve the applicability and reliability of cyclic redundancy check in order to solve the above technical problems.
[0006] In a first aspect, the present application provides a method for generating a cyclic redundancy check code, the method comprising:
[0007] Acquire first network data to be subjected to cyclic redundancy check, and acquire an input matrix according to the first network data, wherein the first network data is a first bit sequence having a preset length;
[0008] Obtain a preset first generating polynomial, and determine a coefficient matrix corresponding to the first bit sequence according to the first generating polynomial, wherein the number of rows of the coefficient matrix is related to the highest power of the first generating polynomial, and the number of columns of the coefficient matrix is related to the length of the first bit sequence;
[0009] The coefficient matrix is multiplied with the input matrix to obtain a cyclic redundancy check code, and the cyclic redundancy check code is used to perform a cyclic redundancy check on the first network data.
[0010] In one embodiment, determining a coefficient matrix corresponding to the first bit sequence according to the first generator polynomial includes:
[0011] For each target bit in the first bit sequence, calculating a coefficient factor corresponding to the target bit according to the first generating polynomial;
[0012] The coefficient matrix is generated according to the coefficient factors corresponding to each of the target bits.
[0013] In a second aspect, the present application provides a method for generating a cyclic redundancy check code, the method comprising:
[0014] Acquire second network data to be cyclically redundancy checked and a preset second generating polynomial, wherein the second network data includes n second bit sequences of m bits, where n and m are both positive integers greater than 1;
[0015] Using the method described in the first aspect, obtaining an initial cyclic redundancy check code of an nth second bit sequence among the n m-bit second bit sequences;
[0016] Determine the size relationship between the highest power of the second generating polynomial and m, and based on the cyclic redundancy check code generation strategy corresponding to the size relationship, use the initial cyclic redundancy check code to iteratively process the remaining n-1 second bit sequences in the n m-bit second bit sequences to obtain a target cyclic redundancy check code, wherein the target cyclic redundancy check code is used to perform a cyclic redundancy check on the second network data, and different cyclic redundancy check code generation strategies correspond to different size relationships.
[0017] In one embodiment, when the magnitude relationship is that the highest power of the second generator polynomial is equal to m, the Kth processing of the iterative processing includes:
[0018] Performing an XOR process on the intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process using the method described in the first aspect;
[0019] Wherein, k is a positive integer greater than or equal to 1 and less than or equal to n-1. When k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code. When k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing.
[0020] In one embodiment, when the magnitude relationship is that the highest power of the second generator polynomial is less than m, the Kth processing of the iterative processing includes:
[0021] The intermediate cyclic redundancy check code is shifted left to obtain a target intermediate cyclic redundancy check code;
[0022] Performing an XOR process on the target intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process using the method described in the first aspect;
[0023] Among them, k is a positive integer greater than or equal to 1 and less than or equal to n-1; when k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing; the shift bit width corresponding to the left shift processing is equal to the difference between m and the highest power of the second generating polynomial.
[0024] In one embodiment, when the magnitude relationship is that the highest power of the second generator polynomial is greater than m, the Kth processing of the iterative processing includes:
[0025] Splitting the intermediate cyclic redundancy check code to obtain a first intermediate cyclic redundancy check code corresponding to the upper m bits of the intermediate cyclic redundancy check code and a second intermediate cyclic redundancy check code corresponding to the remaining bits except the upper m bits;
[0026] Performing an XOR process on the first intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process using the method described in the first aspect to obtain a first cyclic redundancy check code;
[0027] The second intermediate cyclic redundancy check code is subjected to left shift processing, and the second intermediate cyclic redundancy check code subjected to left shift processing and the first cyclic redundancy check code are subjected to XOR processing;
[0028] Among them, k is a positive integer greater than or equal to 1 and less than or equal to n-1; when k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing; the shift bit width corresponding to the left shift processing is equal to m.
[0029] In a third aspect, the present application provides a cyclic redundancy check code generation device, the device comprising:
[0030] A first acquisition module, used to acquire first network data to be subjected to cyclic redundancy check, and acquire an input matrix according to the first network data, wherein the first network data is a first bit sequence with a preset length;
[0031] a second acquisition module, configured to acquire a preset first generating polynomial, and determine a coefficient matrix corresponding to the first bit sequence according to the first generating polynomial, wherein the number of rows of the coefficient matrix is related to the highest power of the first generating polynomial, and the number of columns of the coefficient matrix is related to the length of the first bit sequence;
[0032] A processing module is used to perform matrix multiplication processing on the coefficient matrix and the input matrix to obtain a cyclic redundancy check code, and the cyclic redundancy check code is used to perform a cyclic redundancy check on the first network data.
[0033] In a fourth aspect, the present application provides a cyclic redundancy check code generation device, the device comprising:
[0034] A first acquisition module, used to acquire second network data to be cyclically redundancy checked and a preset second generating polynomial, wherein the second network data includes n second bit sequences of m bits, where n and m are both positive integers greater than 1;
[0035] A second acquisition module, used in the method described in the first aspect, to acquire an initial cyclic redundancy check code of an nth second bit sequence among the n m-bit second bit sequences;
[0036] A generating module is used to determine the size relationship between the highest power of the second generating polynomial and m, and based on the cyclic redundancy check code generation strategy corresponding to the size relationship, use the initial cyclic redundancy check code to iteratively process the remaining n-1 second bit sequences in the n m-bit second bit sequences to obtain a target cyclic redundancy check code, wherein the target cyclic redundancy check code is used to perform a cyclic redundancy check on the second network data, and different cyclic redundancy check code generation strategies corresponding to different size relationships are different.
[0037] In a fifth aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method of the first aspect or the second aspect are implemented.
[0038] In a sixth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method in the first aspect or the second aspect are implemented.
[0039] In a seventh aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the method in the first aspect or the second aspect are implemented.
[0040] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:
[0041] The above-mentioned cyclic redundancy check code generation method, device, equipment, medium and program product obtain the first network data to be cyclically redundancy checked, and obtain an input matrix according to the first network data, the first network data is a first bit sequence with a preset length, and then obtain a preset first generating polynomial, and determine the coefficient matrix corresponding to the first bit sequence according to the first generating polynomial, the number of rows of the coefficient matrix is related to the highest power of the first generating polynomial, and the number of columns of the coefficient matrix is related to the length of the first bit sequence, and then, the coefficient matrix is matrix-multiplied with the input matrix to obtain a cyclic redundancy check code, which is used to perform a cyclic redundancy check on the first network data. In the embodiment of the present application, the first network data (i.e., the first bit sequence) and the first generating polynomial can be set as needed. For example, the first bit sequence can be set to any length, such as any bit width of 3, 4, 5, 7, 8, 11, 13, 16, etc., and the first generating polynomial can also be set to any form, rather than a fixed form, so that the embodiment of the present application can meet the needs of various verification scenarios and improve the applicability and reliability of the cyclic redundancy check. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 A schematic diagram of a flow chart of a method for generating a cyclic redundancy check code in one embodiment;
[0043] Figure 2 A schematic diagram of a flow chart of determining a coefficient matrix corresponding to a first bit sequence in another embodiment;
[0044] Figure 3 is a flow chart of a method for generating a cyclic redundancy check code in another embodiment;
[0045] Figure 4 is a flowchart of the Kth processing process of the iterative processing in step 303 in another embodiment;
[0046] Figure 5 is a flowchart of the Kth processing process of the iterative processing in step 303 in another embodiment;
[0047] Figure 6 is a structural block diagram of a cyclic redundancy check code generating device in one embodiment;
[0048] Figure 7 It is a structural block diagram of a cyclic redundancy check code generating device in another embodiment;
[0049] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0051] Cyclic Redundancy Check (CRC) is a method used to verify the accuracy of digital transmission on a data transmission link. Due to its strong error detection capability and low detection cost, cyclic redundancy check has been widely used in the transmission of network data. The specific process of cyclic redundancy check is: the sender calculates the CRC code of the information contained in the transmitted data, and attaches this CRC code to the transmitted data to form a frame of data. The receiver performs the same calculation on the frame of data as the sender. If the CRC code obtained by the receiver is inconsistent with the CRC code obtained by the sender, it means that an error occurred in the transmission, and the receiver can ask the sender to resend the data.
[0052] The generation of CRC code is a key step in cyclic redundancy check. As the verification scenarios become more and more diverse, how to provide a universal CRC code generation method to improve the applicability and reliability of cyclic redundancy check has become a problem that needs to be solved urgently.
[0053] In view of this, an embodiment of the present application proposes a cyclic redundancy check code generation method. In the method, by obtaining first network data to be cyclically redundancy checked, and obtaining an input matrix according to the first network data, the first network data is a first bit sequence with a preset length, and then, a preset first generating polynomial is obtained, and a coefficient matrix corresponding to the first bit sequence is determined according to the first generating polynomial, the number of rows of the coefficient matrix is related to the highest power of the first generating polynomial, and the number of columns of the coefficient matrix is related to the length of the first bit sequence. Then, the coefficient matrix and the input matrix are subjected to matrix multiplication processing to obtain a cyclic redundancy check code, and the cyclic redundancy check code is used to perform a cyclic redundancy check on the first network data. In the embodiment of the present application, the first network data (i.e., the first bit sequence) and the first generating polynomial can be set as needed. For example, the first bit sequence can be set to any length, such as any bit width of 3, 4, 5, 7, 8, 11, 13, 16, etc., and the first generating polynomial can also be set to any form, rather than a fixed form, so that the embodiment of the present application can meet the needs of various verification scenarios and improve the applicability and reliability of the cyclic redundancy check.
[0054] It should be noted that the cyclic redundancy check code generation method provided in the embodiment of the present application can be executed by a cyclic redundancy check code generation device, and the cyclic redundancy check code generation device can be implemented as part or all of a computer device through software, hardware, or a combination of software and hardware.
[0055] In the following method embodiments, the execution subject is a computer device as an example for explanation, wherein the computer device can be a server, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices, etc. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. The portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. There is no specific restriction on the type of computer devices here.
[0056] Please refer to Figure 1 , which shows a flow chart of a method for generating a cyclic redundancy check code provided in an embodiment of the present application. Figure 1 As shown, the cyclic redundancy check code generation method may include the following steps:
[0057] Step 101: A computer device obtains first network data to be subjected to cyclic redundancy check, and obtains an input matrix according to the first network data.
[0058] In the embodiment of the present application, the computer device can be the data sender in the network transmission process, and of course, it can also be the data receiver. In the case where the computer device is the data sender, the first network data can be the transmitted data as described above acquired by the computer device during the network transmission process; in the case where the computer device is the data receiver, the first network data can be the data frame with the CRC code added to it sent by other computer devices during the network transmission process. The specific application scenario of the embodiment of the present application is not limited here.
[0059] In the embodiment of the present application, the first network data is a first bit sequence with a preset length. For example, the first bit sequence is a first bit sequence B of m bits={D m-1 , D m-2 ,......,D1,D0}, where m is a positive integer greater than 1.
[0060] The preset length may be any length (i.e., any bit width). For example, the bit width of the first bit sequence may be not only conventional bit widths such as 4, 8, 16, 32, 64, but also prime bit widths such as 3, 5, 7, 11, 13, etc. In actual implementation, the preset length may be set as required.
[0061] In the embodiment of the present application, the computer device obtains the input matrix according to the first network data, which may be a form of converting the first bit sequence into a column matrix. For example, the first bit sequence is B={D m-1 , D m-2 ,......,D1,D0} as an example, the input matrix is:
[0062] Input Matrix =
[0063] Step 102: The computer device obtains a preset first generating polynomial, and determines a coefficient matrix corresponding to the first bit sequence according to the first generating polynomial.
[0064] The computer device can operate on the first generating polynomial to obtain a coefficient matrix corresponding to the first bit sequence, wherein the number of rows of the coefficient matrix is related to the highest power of the first generating polynomial, and the number of columns of the coefficient matrix is related to the length of the first bit sequence.
[0065] In the embodiment of the present application, the number of rows of the coefficient matrix may be equal to the highest power of the first generating polynomial + 1, and the number of columns of the coefficient matrix may be equal to the length (i.e., the bit width) of the first bit sequence. Below, a possible implementation process of a computer device determining a coefficient matrix corresponding to a first bit sequence according to a first generating polynomial is introduced.
[0066] See also Figure 2 , the computer device can execute Figure 2 Steps 201 and 202 shown implement the process of determining the coefficient matrix corresponding to the first bit sequence according to the first generating polynomial:
[0067] Step 201: The computer device calculates a coefficient factor corresponding to each target bit in a first bit sequence according to a first generating polynomial.
[0068] According to the principle of cyclic redundancy check, assuming that the information polynomial is M(x)=x 7 +x 6 +x 5 +x 2 +x 1 , then the bit sequence obtained by the information polynomial is 11100110. If the generating polynomial G(x)=x 3 +x+1, then the remainder term R(x)={M(x)×x 3}modG(x)=x 2 , that is, the CRC code is "100".
[0069] Thus, in the embodiment of the present application, it is assumed that the first generating polynomial is represented by G:
[0070] G={Gr , G r-1 , G r-2 , ..., G1, G0}
[0071] Then the remainder (i.e. cyclic redundancy check code) R=(B×x r )mod(G)={(D m-1 × m-1 +D m-2 × m-2 ......D1×x 1 +D0)×x r}mod(G)
[0072] Let R i =(D i × i × r )mod(G), 0≤i≤m-1, that is, R i Equal to the bit string {D i , } Shift left by r bits and divide by the remainder of G, then R=R m-1 +R m-2 +......+R1+R0. For the circuit description of polynomial division, the linear feedback shift register LFSRII is the best model. From LFSRII, we can know that R i i+1 shift operations are required. Let j be the order of the shift operations and 1≤j≤i+1, then R i,j,r is a bit string {D i , }The result of the rth bit after j shifts:
[0073] R i,1 ={G r ×D i ,G r-1 ×D i ,G r-2 ×D i ......G1×D i ,G0×D i}; (1)
[0074] R i,j ={(R i,j-1,r-1 +R i,j-1,r-1 ×G r ),(R i,j-1,r-2 +R i,j-1,r-1 ×G r-1 ),(R i,j-1,r-3 +R i,j-1,r-1 ×G r-2 )......
[0075] (Ri,j-1,0 +R i,j-1,r-1 ×G1),R i,j-1,r-1 ×G0};(2)
[0076] From formula (1), we can see that D i =1, R i,1 ={G r ,G r-1 ,G r-2i ......G1,G0}. The first generating polynomial is a preset known quantity, that is, the coefficient Gi is a constant, and R i,1 Substitute into formula (2), and finally get R through loop iteration. i , that is, the bit string {D i , }The result obtained after r+1 shift operations.
[0077] And by R i,1 and R i,j It can be seen that in R i During the shift operation, D i First enter LFSRII, then compare the bit string {D i , }, the operation of entering the "0" of LFSRII is to convert D i The operation result of the LFSRII circuit is continuously subjected to linear feedback XOR operation, that is, based on R i,1 Continue iterating.
[0078] Due to R i,1 Each bit in D i The multiplication factor, so R i Finally, R is obtained by shifting i+1 times i,i+1 Each bit in must have D i Factor and a coefficient factor Hi,r obtained by operation of the first generating polynomial, then:
[0079] R i ={H i,r ×D i ,H i,r-1 ×D i ,H i,r-2 ×D i ,......,H i,1 ×D i ,H i,0 ×D i}; (3)
[0080] It can be seen from formula (3) that if D i =0, then R i =0, if D i =1, then
[0081] R i ={H i,r ,H i,r-1 ,H i,r-2 ,......,H i,1 ,H i,0};(4)
[0082] From formula (4), we can see that Hi,r is a known quantity that can be obtained by the first generating polynomial, then R i By D i Sure.
[0083] In this way, by the same method as above, we can get m H i ={H i,r ,H i,r-1 ,H i,r-2 ,......,H i,1 ,
[0084] H i,0}. m H i That is, the first bit sequence B={D m-1 , D m-2 ,......,D1,D0} respectively correspond to the coefficient factors of the m target bits.
[0085] Step 202: The computer device generates a coefficient matrix according to the coefficient factors corresponding to each target bit.
[0086] The computer device converts the coefficient factors corresponding to each target bit into a matrix form, and obtains the coefficient matrix H:
[0087] H=
[0088] Step 103: The computer device performs matrix multiplication processing on the coefficient matrix and the input matrix to obtain a cyclic redundancy check code.
[0089] From the above analysis, we can see that the cyclic redundancy check code = R m-1 +R m-2 +......+R1+R0, in this way, after the computer device obtains the coefficient matrix and the input matrix, it directly performs matrix multiplication on the coefficient matrix and the input matrix, which is equivalent to converting the first bit sequence B={D m-1 , D m-2 , ..., D1, D0} are multiplied by each target bit and its corresponding coefficient factor, and then the multiplication results are added to obtain a cyclic redundancy check code corresponding to the first bit sequence, and the cyclic redundancy check code is used to perform a cyclic redundancy check on the first network data.
[0090] Taking the computer device as the data sender as an example, after the computer device obtains the cyclic redundancy check code, it adds the cyclic redundancy check code after the first bit sequence to obtain a data frame, and then sends the data frame to the data receiver, so that the data receiver can perform the same operation on the data frame to obtain the cyclic redundancy check code. If the cyclic redundancy check codes obtained at both ends are consistent, it indicates that there is no error in the data transmission. If the cyclic redundancy check codes obtained at both ends are inconsistent, it means that an error has occurred in the data transmission, and the data receiver can ask the data sender to resend the data.
[0091] By obtaining first network data to be cyclically redundancy checked, and obtaining an input matrix according to the first network data, the first network data is a first bit sequence with a preset length, and then, obtaining a preset first generating polynomial, and determining a coefficient matrix corresponding to the first bit sequence according to the first generating polynomial, the number of rows of the coefficient matrix is related to the highest power of the first generating polynomial, and the number of columns of the coefficient matrix is related to the length of the first bit sequence, and then, the coefficient matrix and the input matrix are subjected to matrix multiplication processing to obtain a cyclic redundancy check code, and the cyclic redundancy check code is used to perform a cyclic redundancy check on the first network data. In the embodiment of the present application, the first network data (i.e., the first bit sequence) and the first generating polynomial can be set as needed. For example, the first bit sequence can be set to any length, such as any bit width of 3, 4, 5, 7, 8, 11, 13, 16, etc., and the first generating polynomial can also be set to any form, rather than a fixed form. Therefore, the embodiment of the present application has no fixed restriction on the input bit width, and has no fixed restriction on the power of the generating polynomial and the specific form of the polynomial, can adapt to the needs of various verification scenarios, and improves the applicability and reliability of the cyclic redundancy check.
[0092] Please refer to Figure 3 , which shows a flow chart of a method for generating a cyclic redundancy check code provided in an embodiment of the present application. Figure 3 As shown, the cyclic redundancy check code generation method may include the following steps:
[0093] Step 301: The computer device obtains second network data to be subjected to cyclic redundancy check and a preset second generating polynomial.
[0094] The second network data includes n m-bit second bit sequences, where n and m are both positive integers greater than 1, and the n m-bit second bit sequences may be n consecutive parallel inputs obtained by the computer device, each input being an m-bit second bit sequence.
[0095] Similar to the above embodiment, n and m can be set as needed during implementation. For example, m can be not only a conventional bit width of 4, 8, 16, 32, 64, but also a prime bit width of 3, 5, 7, 11, 13, etc. The power of the second generating polynomial and the specific form of the polynomial can also be set as needed. The embodiment of the present application has no fixed restrictions on the power of the second generating polynomial and the specific form of the polynomial.
[0096] Step 302: Obtain an initial cyclic redundancy check code of an nth second bit sequence among n m-bit second bit sequences.
[0097] Assume that B[n-1] is the nth second bit sequence in the second network data (i.e., n second bit sequences of m bits), the highest power of the second generating polynomial G is r, and assume that B r [n-1] is the remainder of B[n-1] divided by G, that is, B r [n-1]=(B[n-1]×x r )mod(G). Then the remainder R (i.e., the target cyclic redundancy check code) of the n second bit sequences of m bits divided by G is:
[0098] R={(B[n-1]×x (n-1)m +B[n-2]×x (n-2)m +,......,B[1]×x m +B[0])×x r}mod(G)
[0099] ={(B[n-1]×x r )×x (n-1)m}mod(G)+{(B[n-2]×x (n-2)m +,......,B[1]×x m +B[0])×x r}mod(G)
[0100] ={B r [n-1]×x m × (n-2)m}mod(G)+{(B[n-2]×x (n-2)m +,......,B[1]×x m +B[0])×x r}mod(G)
[0101] ={B r [n-1]×x r × m-r × (n-2)m}mod(G)+{(B[n-2]×x (n-2)m +,......,B[1]×x m+B[0])×x r}mod(G)
[0102] ={((B r [n-1]×x m-r +B[n-2])×x (n-2)m +,......,B[1]×x m +B[0])×x r}mod(G); (5)
[0103] That is, formula (5) is the calculation formula of the target cyclic redundancy check code. Computer equipment uses Figure 1 or Figure 2 The cyclic redundancy check code generation method shown in the figure calculates the initial cyclic redundancy check code B of the nth second bit sequence B[n-1] among the n second bit sequences of m bits. r [n-1].
[0104] Step 303: The computer device determines the size relationship between the highest power of the second generating polynomial and m, and based on the cyclic redundancy check code generation strategy corresponding to the size relationship, uses the initial cyclic redundancy check code to iteratively process the remaining n-1 second bit sequences in the n m-bit second bit sequences to obtain a target cyclic redundancy check code.
[0105] It can be seen from formula (5) that the magnitude relationship between the highest power r and m of the second generator polynomial G affects the result of the target cyclic redundancy check code. In the embodiment of the present application, different magnitude relationships correspond to different cyclic redundancy check code generation strategies.
[0106] The relationship between the highest power r and m of the second generating polynomial includes: r=m, r<m、r> m; under different size relationships, the computer device uses the corresponding cyclic redundancy check code generation strategy, and based on the calculated initial cyclic redundancy check code, iteratively processes the remaining n-1 second bit sequences in the n m-bit second bit sequences except the above-mentioned nth second bit sequence to obtain a target cyclic redundancy check code.
[0107] The following introduces the iterative processing of computer equipment under three different size relationships.
[0108] First, when the magnitude relationship between the highest power r and m of the second generating polynomial is that the highest power r of the second generating polynomial is equal to m, the K-th processing process of the iterative processing in step 303 includes: the computer device performs XOR processing on the intermediate cyclic redundancy check code and the nk-th second bit sequence, and uses Figure 1 or Figure 2The cyclic redundancy check code generation method shown performs cyclic redundancy check code generation processing on the result of XOR processing.
[0109] Wherein, k is a positive integer greater than or equal to 1 and less than or equal to n-1. When k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code. When k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing.
[0110] Continuing with the above example, assume that B[n-1] is the nth second bit sequence among the n m-bit second bit sequences, B[n-2] is the n-1th second bit sequence among the n m-bit second bit sequences, ..., B[1] is the 2nd second bit sequence among the n m-bit second bit sequences, and B[0] is the 1st second bit sequence among the n m-bit second bit sequences.
[0111] According to formula (5), when r=m, the calculation formula of the target cyclic redundancy check code is transformed from formula (5) to:
[0112] R={((B r [n-1]+B[n-2])×x (n-2)m +,......,B[1]×x m +B[0])×x r}mod(G)
[0113] Thus, during the first processing of the iterative process, the computer device converts the initial cyclic redundancy check code B r [n-1] and the nkth second bit sequence (i.e., the n-1th second bit sequence B[n-2]) are subjected to XOR processing to obtain the result of the XOR processing. Then, the computer device uses Figure 1 or Figure 2 The cyclic redundancy check code generation method shown in the figure calculates the cyclic redundancy check code B corresponding to the result of the XOR processing r [n-2], complete the first processing process.
[0114] Then, in the second processing of the iterative processing, the computer device converts the cyclic redundancy check code B obtained in the first processing into r [n-2] and the nkth second bit sequence (i.e., the n-2th second bit sequence B[n-3]) are subjected to XOR processing to obtain the result of the XOR processing. Then, the computer device uses Figure 1 or Figure 2 The cyclic redundancy check code generation method shown in the figure calculates the cyclic redundancy check code B corresponding to the result of the XOR processing r [n-3], complete the second processing process.
[0115] By analogy, in the last (i.e., the (n - 1)-th) processing of the iterative processing, the computer device will use the cyclic redundancy check code B obtained in the (n - 2)-th processing r [1] and the (n - k)-th second bit sequence (i.e., the first second bit sequence B[0]) to perform an exclusive OR operation to obtain the result of the exclusive OR operation. Then, the computer device uses Figure 1 or Figure 2 The cyclic redundancy check code generation method shown to calculate the cyclic redundancy check code B corresponding to the result of the exclusive OR operation r [0], completing the last processing process, and the obtained B r [0] is the target cyclic redundancy check code.
[0116] Secondly, in the case where the relationship between the highest power r of the second generating polynomial and m is that the highest power of the second generating polynomial is less than m, refer to Figure 4 , the K-th processing process of the iterative processing in step 303 includes step 401 and step 402:
[0117] Step 401, the computer device performs a left shift operation on the intermediate cyclic redundancy check code to obtain the target intermediate cyclic redundancy check code.
[0118] Step 402, the computer device performs an exclusive OR operation on the target intermediate cyclic redundancy check code and the (n - k)-th second bit sequence, and performs cyclic redundancy check code generation processing on the result of the exclusive OR operation.
[0119] Where k is a positive integer greater than or equal to 1 and less than or equal to n - 1; when k = 1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k > 1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained in the (k - 1)-th iterative processing; the shift width corresponding to the left shift operation is equal to the difference between m and the highest power of the second generating polynomial.
[0120] According to formula (5), in the case of r < m, m - r is greater than 0, and B r [n - 1] × x m-r is equivalent to shifting B r [n - 1] to the left by m - r bits and padding "0" on the right.
[0121] In this way, in the first processing process of the iterative processing, the computer device performs a left shift operation on the initial cyclic redundancy check code B r [n - 1] to obtain the target intermediate cyclic redundancy check code, that is, shifting B r[n-1] is shifted left by mr bits and padded with "0" on the right to obtain the target intermediate cyclic redundancy check code. Then, the computer device performs XOR processing on the target intermediate cyclic redundancy check code and the nkth second bit sequence (i.e., the n-1th second bit sequence B[n-2]) to obtain the result of the XOR processing. Then, the computer device uses Figure 1 or Figure 2 The cyclic redundancy check code generation method shown in the figure calculates the cyclic redundancy check code B corresponding to the result of the XOR processing r [n-2], complete the first processing process.
[0122] Then, in the second processing of the iterative processing, the computer device converts the cyclic redundancy check code B obtained in the first processing into r [n-2] is shifted left by mr bits and padded with "0" on the right to obtain the target intermediate cyclic redundancy check code. Then, the computer device performs XOR processing on the target intermediate cyclic redundancy check code and the nkth second bit sequence (i.e., the n-2th second bit sequence B[n-3]) to obtain the result of the XOR processing. Then, the computer device uses Figure 1 or Figure 2 The cyclic redundancy check code generation method shown in the figure calculates the cyclic redundancy check code B corresponding to the result of the XOR processing r [n-3], complete the second processing process.
[0123] Similarly, in the last (n-1th) iterative process, the computer device will process the cyclic redundancy check code B obtained in the n-2th process. r [1] Shift left by mr bits and add “0” to the right to obtain the target intermediate cyclic redundancy check code. Then, the computer device performs XOR processing on the target intermediate cyclic redundancy check code and the nkth second bit sequence (i.e., the first second bit sequence B[0]) to obtain the XOR processing result. Then, the computer device uses Figure 1 or Figure 2 The cyclic redundancy check code generation method shown in the figure calculates the cyclic redundancy check code B corresponding to the result of the XOR processing r [0], after completing the last processing, the obtained B r [0] is the target cyclic redundancy check code.
[0124] Finally, in the case where the highest power r of the second generating polynomial is greater than m, see Figure 5 The Kth iterative processing in step 303 includes steps 501, 502 and 503:
[0125] Step 501, the computer device splits the intermediate cyclic redundancy check code to obtain a first intermediate cyclic redundancy check code corresponding to the high m bits in the intermediate cyclic redundancy check code and a second intermediate cyclic redundancy check code corresponding to the remaining bits except the high m bits.
[0126] Step 502, the computer device performs an exclusive OR operation on the first intermediate cyclic redundancy check code and the (n - k)-th second bit sequence, and performs a cyclic redundancy check code generation process on the result of the exclusive OR operation to obtain a first cyclic redundancy check code.
[0127] Step 503, the computer device performs a left shift operation on the second intermediate cyclic redundancy check code, and performs an exclusive OR operation on the left-shifted second intermediate cyclic redundancy check code and the first cyclic redundancy check code.
[0128] Where k is a positive integer greater than or equal to 1 and less than or equal to n - 1; when k = 1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k > 1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained from the (k - 1)-th iteration process; the shift width corresponding to the left shift operation is equal to m.
[0129] According to formula (5), it can be seen that when r > m, m - r is less than 0, so the intermediate cyclic redundancy check code cannot be left-shifted as in the case of r < m. In the embodiments of the present application, the computer device splits the intermediate cyclic redundancy check code into high m bits and low r - m bits, and then calculates the target cyclic redundancy check code.
[0130] Assume B r [n] is any intermediate cyclic redundancy check code, let B rm [n] be the high m bits of B r [n], and B r-m [n] be the low r - m bits of B r [n], that is:
[0131] B r [n] = {B rm [n], } + B r-m [n] = B rm [n] × x r-m + B r-m [n];
[0132] Then B r [n] × x m-r = B rm [n] + B r-m [n] × x m-r ; (6)
[0133] Substituting formula (6) into formula (5) and transforming formula (5) using formula (6), we can obtain:
[0134] R={((B rm [n-1]+B[n-2])×x (n-2)m +B r-m [n-1]×x m-r × (n-2)m ,......,B[1]×x m +B[0])×x r}mod(G);
[0135] Let B' r [n-2] is B rm The remainder of [n-1]+B[n-2] divided by G is similar to the calculation of B[n-1], and we get:
[0136] R={(B' r [n-2]×x m-r × (n-3)m +B r-m [n-1]×x m × m-r × (n-3)m ,......,B[1]×x m +B[0])×x r}mod(G);
[0137] Let B'' r [n-2]=B' r [n-2]+B r-m [n-1]×x m ,but:
[0138] R={((B'' r [n-2]×x m-r +B[n-3])×x (n-3)m +B[n-4]×x (n-4)m ,......,B[1]×x m +B[0])×x r}mod(G).
[0139] Thus, based on the conclusion of the derivation process, in the first processing of the iterative processing, the computer device converts the initial cyclic redundancy check code B r [n-1] is split and B is obtained r The first intermediate cyclic redundancy check code B corresponding to the high m bits in [n-1] rm [n-1] and the second intermediate cyclic redundancy check code B corresponding to the remaining bits (rm bits) except the high m bits r-m [n-1]. Then, the computer device willrm [n-1] and the nkth second bit sequence (i.e. the n-1th second bit sequence B[n-2]) are subjected to XOR processing to obtain the result of the XOR processing, and then used Figure 1 or Figure 2 The cyclic redundancy check code generation method shown in the figure calculates the first cyclic redundancy check code B' corresponding to the result of the XOR process r [n-2]. Then, the computer device will r-m [n-1] is shifted left by m bits and the right side is filled with "0" to obtain the second intermediate cyclic redundancy check code {B r-m [n-1], }, and for {B r-m [n-1], } and B' r [n-2] is XORed to get B'' r [n-2],B'' r [n-2] is the cyclic redundancy check code B corresponding to the first processing process r [n-2], complete the first processing process.
[0140] Then, in the second processing of the iterative processing, the computer device converts the cyclic redundancy check code B obtained in the first processing into r [n-2] is split and B is obtained r The first intermediate cyclic redundancy check code B corresponding to the high m bits in [n-2] rm [n-2] and the second intermediate cyclic redundancy check code B corresponding to the remaining bits (rm bits) except the high m bits r-m [n-2]. Then, the computer device will rm [n-2] and the nk-th second bit sequence (i.e., the n-2-th second bit sequence B[n-3]) are subjected to XOR processing to obtain the result of the XOR processing, and then used Figure 1 or Figure 2 The cyclic redundancy check code generation method shown in the figure calculates the first cyclic redundancy check code B' corresponding to the result of the XOR process r [n-3]. Then, the computer device will r-m [n-2] is shifted left by m bits and the right side is filled with "0" to obtain the second intermediate cyclic redundancy check code after left shift processing
[0141] {B r-m [n-2], }, and for {B r-m [n-2], } and B' r [n-2] is XORed to get B'' r [n-3],B''r [n-3] is the cyclic redundancy check code B corresponding to the second processing process r [n-3], complete the second processing process.
[0142] Similarly, in the last (n-1th) iterative process, the computer device will process the cyclic redundancy check code B obtained in the n-2th process. r [1] split and get B r The first intermediate cyclic redundancy check code B corresponding to the high m bits in [1] rm [1] and the second intermediate cyclic redundancy check code B corresponding to the remaining bits (rm bits) except the upper m bits r-m [1]. Then, the computer device will rm [1] and the nkth second bit sequence (i.e., the first second bit sequence B[0]) are XORed to obtain the result of the XOR processing, and then used Figure 1 or Figure 2 The cyclic redundancy check code generation method shown in the figure calculates the first cyclic redundancy check code B' corresponding to the result of the XOR process r [0]. Then, the computer device will r-m [1] Perform a left shift, shift left by m bits and add “0” on the right to obtain the second intermediate cyclic redundancy check code after the left shift.
[0143] {B r-m [1], }, and {B r-m [1], } and B' r [0] XOR processing is performed to obtain B'' r [0],B'' r [0] is the cyclic redundancy check code B corresponding to the last processing process r [0], complete the last processing process.
[0144] In this way, by adopting the above different cyclic redundancy check code generation strategies for different size relationships, the computer device obtains the final target cyclic redundancy check code, and the target cyclic redundancy check code is used to perform a cyclic redundancy check on the second network data.
[0145] The process of the computer device performing a cyclic redundancy check on the second network data using the target cyclic redundancy check code is similar to the process of performing a cyclic redundancy check on the first network data using the cyclic redundancy check code obtained in the above embodiment, and will not be repeated here.
[0146] In the embodiment of the present application, n, m, and the second generating polynomial can be set as needed. For example, m can be not only a conventional bit width of 4, 8, 16, 32, 64, but also a prime bit width of 3, 5, 7, 11, 13, etc. The second generating polynomial can also be set to any form instead of a fixed form. Therefore, in the embodiment of the present application, there is no fixed restriction on the input bit width in the parallel CRC calculation, and there is no fixed restriction on the power of the generating polynomial and the specific form of the polynomial. It can adapt to the needs of various verification scenarios, improve the applicability and reliability of the cyclic redundancy check, and parallel computing also improves the calculation speed.
[0147] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0148] Based on the same inventive concept, the embodiment of the present application also provides a cyclic redundancy check code generation device for implementing the cyclic redundancy check code generation method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more cyclic redundancy check code generation device embodiments provided below can refer to the limitations of the cyclic redundancy check code generation method above, and will not be repeated here.
[0149] In one embodiment, Figure 6 As shown, a cyclic redundancy check code generation device is provided, comprising:
[0150] A first acquisition module 601 is used to acquire first network data to be subjected to cyclic redundancy check, and acquire an input matrix according to the first network data, wherein the first network data is a first bit sequence with a preset length;
[0151] A second acquisition module 602 is used to acquire a preset first generating polynomial, and determine a coefficient matrix corresponding to the first bit sequence according to the first generating polynomial, where the number of rows of the coefficient matrix is related to the highest power of the first generating polynomial, and the number of columns of the coefficient matrix is related to the length of the first bit sequence;
[0152] The processing module 603 is used to perform matrix multiplication processing on the coefficient matrix and the input matrix to obtain a cyclic redundancy check code, and the cyclic redundancy check code is used to perform a cyclic redundancy check on the first network data.
[0153] Optionally, the second acquisition module 602 is specifically used to calculate, for each target bit in the first bit sequence, a coefficient factor corresponding to the target bit according to the first generating polynomial; and generate the coefficient matrix according to the coefficient factors corresponding to each target bit.
[0154] In one embodiment, Figure 7 As shown, a cyclic redundancy check code generation device is provided, comprising:
[0155] A first acquisition module 701 is used to acquire second network data to be cyclically redundancy checked and a preset second generating polynomial, wherein the second network data includes n second bit sequences of m bits, where n and m are both positive integers greater than 1;
[0156] The second acquisition module 702 is used to acquire an initial cyclic redundancy check code of an nth second bit sequence among the n m-bit second bit sequences by using the first acquisition module 601, the second acquisition module 602 and the processing module 603;
[0157] A generating module 703 is used to determine the size relationship between the highest power of the second generating polynomial and m, and based on the cyclic redundancy check code generation strategy corresponding to the size relationship, use the initial cyclic redundancy check code to iteratively process the remaining n-1 second bit sequences in the n m-bit second bit sequences to obtain a target cyclic redundancy check code, wherein the target cyclic redundancy check code is used to perform a cyclic redundancy check on the second network data, and different cyclic redundancy check code generation strategies corresponding to different size relationships are different.
[0158] Optionally, when the size relationship is that the highest power of the second generating polynomial is equal to m, the Kth processing process of the iterative processing includes: performing XOR processing on the intermediate cyclic redundancy check code and the nkth second bit sequence, and using the first acquisition module 601, the second acquisition module 602 and the processing module 603 to generate a cyclic redundancy check code for the result of the XOR processing; wherein k is a positive integer greater than or equal to 1 and less than or equal to n-1, when k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing.
[0159] Optionally, when the size relationship is that the highest power of the second generating polynomial is less than m, the Kth processing process of the iterative processing includes: left-shifting the intermediate cyclic redundancy check code to obtain a target intermediate cyclic redundancy check code; performing XOR processing on the target intermediate cyclic redundancy check code and the nk-th second bit sequence, and using the first acquisition module 601, the second acquisition module 602 and the processing module 603 to generate a cyclic redundancy check code for the result of the XOR processing; wherein k is a positive integer greater than or equal to 1 and less than or equal to n-1; when k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing; the shift bit width corresponding to the left shift processing is equal to the difference between m and the highest power of the second generating polynomial.
[0160] Optionally, when the size relationship is that the highest power of the second generating polynomial is greater than m, the Kth processing process of the iterative processing includes: splitting the intermediate cyclic redundancy check code to obtain a first intermediate cyclic redundancy check code corresponding to the upper m bits of the intermediate cyclic redundancy check code and a second intermediate cyclic redundancy check code corresponding to the remaining bits except the upper m bits; performing XOR processing on the first intermediate cyclic redundancy check code and the nkth second bit sequence, and using the first acquisition module 601, the second acquisition module 602 and the processing module 603, performing cyclic redundancy check code generation processing on the result of the XOR processing to obtain a first cyclic redundancy check code; performing left shift processing on the second intermediate cyclic redundancy check code after the left shift processing and performing XOR processing on the first cyclic redundancy check code; wherein k is a positive integer greater than or equal to 1 and less than or equal to n-1; when k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing; the shift bit width corresponding to the left shift processing is equal to m.
[0161] Each module in the above-mentioned cyclic redundancy check code generation device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0162] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store cyclic redundancy check code generation method data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a cyclic redundancy check code generation method is implemented.
[0163] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0164] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0165] Acquire first network data to be subjected to cyclic redundancy check, and acquire an input matrix according to the first network data, wherein the first network data is a first bit sequence having a preset length;
[0166] Obtain a preset first generating polynomial, and determine a coefficient matrix corresponding to the first bit sequence according to the first generating polynomial, wherein the number of rows of the coefficient matrix is related to the highest power of the first generating polynomial, and the number of columns of the coefficient matrix is related to the length of the first bit sequence;
[0167] The coefficient matrix is multiplied with the input matrix to obtain a cyclic redundancy check code, and the cyclic redundancy check code is used to perform a cyclic redundancy check on the first network data.
[0168] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0169] For each target bit in the first bit sequence, calculating a coefficient factor corresponding to the target bit according to the first generating polynomial;
[0170] The coefficient matrix is generated according to the coefficient factors corresponding to each of the target bits.
[0171] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0172] Acquire second network data to be cyclically redundancy checked and a preset second generating polynomial, wherein the second network data includes n second bit sequences of m bits, where n and m are both positive integers greater than 1;
[0173] Obtaining an initial cyclic redundancy check code of an nth second bit sequence among the n m-bit second bit sequences;
[0174] Determine the size relationship between the highest power of the second generating polynomial and m, and based on the cyclic redundancy check code generation strategy corresponding to the size relationship, use the initial cyclic redundancy check code to iteratively process the remaining n-1 second bit sequences in the n m-bit second bit sequences to obtain a target cyclic redundancy check code, wherein the target cyclic redundancy check code is used to perform a cyclic redundancy check on the second network data, and different cyclic redundancy check code generation strategies correspond to different size relationships.
[0175] In one embodiment, when the size relationship is that the highest power of the second generator polynomial is equal to m, the processor further implements the following steps when executing the computer program:
[0176] Performing an XOR process on the intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process;
[0177] Wherein, k is a positive integer greater than or equal to 1 and less than or equal to n-1. When k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code. When k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing.
[0178] In one embodiment, when the size relationship is that the highest power of the second generator polynomial is less than m, the processor further implements the following steps when executing the computer program:
[0179] The intermediate cyclic redundancy check code is shifted left to obtain a target intermediate cyclic redundancy check code;
[0180] Performing an XOR process on the target intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process;
[0181] Among them, k is a positive integer greater than or equal to 1 and less than or equal to n-1; when k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing; the shift bit width corresponding to the left shift processing is equal to the difference between m and the highest power of the second generating polynomial.
[0182] In one embodiment, when the size relationship is that the highest power of the second generator polynomial is greater than m, the processor further implements the following steps when executing the computer program:
[0183] Splitting the intermediate cyclic redundancy check code to obtain a first intermediate cyclic redundancy check code corresponding to the upper m bits of the intermediate cyclic redundancy check code and a second intermediate cyclic redundancy check code corresponding to the remaining bits except the upper m bits;
[0184] Performing an XOR process on the first intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process to obtain a first cyclic redundancy check code;
[0185] The second intermediate cyclic redundancy check code is subjected to left shift processing, and the second intermediate cyclic redundancy check code subjected to left shift processing and the first cyclic redundancy check code are subjected to XOR processing;
[0186] Among them, k is a positive integer greater than or equal to 1 and less than or equal to n-1; when k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing; the shift bit width corresponding to the left shift processing is equal to m.
[0187] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0188] Acquire first network data to be subjected to cyclic redundancy check, and acquire an input matrix according to the first network data, wherein the first network data is a first bit sequence having a preset length;
[0189] Obtain a preset first generating polynomial, and determine a coefficient matrix corresponding to the first bit sequence according to the first generating polynomial, wherein the number of rows of the coefficient matrix is related to the highest power of the first generating polynomial, and the number of columns of the coefficient matrix is related to the length of the first bit sequence;
[0190] The coefficient matrix is multiplied with the input matrix to obtain a cyclic redundancy check code, and the cyclic redundancy check code is used to perform a cyclic redundancy check on the first network data.
[0191] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0192] For each target bit in the first bit sequence, calculating a coefficient factor corresponding to the target bit according to the first generating polynomial;
[0193] The coefficient matrix is generated according to the coefficient factors corresponding to each of the target bits.
[0194] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0195] Acquire second network data to be cyclically redundancy checked and a preset second generating polynomial, wherein the second network data includes n second bit sequences of m bits, where n and m are both positive integers greater than 1;
[0196] Obtaining an initial cyclic redundancy check code of an nth second bit sequence among the n m-bit second bit sequences;
[0197] Determine the size relationship between the highest power of the second generating polynomial and m, and based on the cyclic redundancy check code generation strategy corresponding to the size relationship, use the initial cyclic redundancy check code to iteratively process the remaining n-1 second bit sequences in the n m-bit second bit sequences to obtain a target cyclic redundancy check code, wherein the target cyclic redundancy check code is used to perform a cyclic redundancy check on the second network data, and different cyclic redundancy check code generation strategies correspond to different size relationships.
[0198] In one embodiment, when the size relationship is that the highest power of the second generator polynomial is equal to m, the computer program further implements the following steps when executed by the processor:
[0199] Performing an XOR process on the intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process;
[0200] Wherein, k is a positive integer greater than or equal to 1 and less than or equal to n-1. When k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code. When k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing.
[0201] In one embodiment, when the size relationship is that the highest power of the second generator polynomial is less than m, the computer program further implements the following steps when executed by the processor:
[0202] The intermediate cyclic redundancy check code is shifted left to obtain a target intermediate cyclic redundancy check code;
[0203] Performing an XOR process on the target intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process;
[0204] Among them, k is a positive integer greater than or equal to 1 and less than or equal to n-1; when k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing; the shift bit width corresponding to the left shift processing is equal to the difference between m and the highest power of the second generating polynomial.
[0205] In one embodiment, when the size relationship is that the highest power of the second generator polynomial is greater than m, the computer program further implements the following steps when executed by the processor:
[0206] Splitting the intermediate cyclic redundancy check code to obtain a first intermediate cyclic redundancy check code corresponding to the upper m bits of the intermediate cyclic redundancy check code and a second intermediate cyclic redundancy check code corresponding to the remaining bits except the upper m bits;
[0207] Performing an XOR process on the first intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process to obtain a first cyclic redundancy check code;
[0208] The second intermediate cyclic redundancy check code is subjected to left shift processing, and the second intermediate cyclic redundancy check code subjected to left shift processing and the first cyclic redundancy check code are subjected to XOR processing;
[0209] Among them, k is a positive integer greater than or equal to 1 and less than or equal to n-1; when k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing; the shift bit width corresponding to the left shift processing is equal to m.
[0210] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0211] Acquire first network data to be subjected to cyclic redundancy check, and acquire an input matrix according to the first network data, wherein the first network data is a first bit sequence having a preset length;
[0212] Obtain a preset first generating polynomial, and determine a coefficient matrix corresponding to the first bit sequence according to the first generating polynomial, wherein the number of rows of the coefficient matrix is related to the highest power of the first generating polynomial, and the number of columns of the coefficient matrix is related to the length of the first bit sequence;
[0213] The coefficient matrix is multiplied with the input matrix to obtain a cyclic redundancy check code, and the cyclic redundancy check code is used to perform a cyclic redundancy check on the first network data.
[0214] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0215] For each target bit in the first bit sequence, calculating a coefficient factor corresponding to the target bit according to the first generating polynomial;
[0216] The coefficient matrix is generated according to the coefficient factors corresponding to each of the target bits.
[0217] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0218] Acquire second network data to be cyclically redundancy checked and a preset second generating polynomial, wherein the second network data includes n second bit sequences of m bits, where n and m are both positive integers greater than 1;
[0219] Obtaining an initial cyclic redundancy check code of an nth second bit sequence among the n m-bit second bit sequences;
[0220] Determine the size relationship between the highest power of the second generating polynomial and m, and based on the cyclic redundancy check code generation strategy corresponding to the size relationship, use the initial cyclic redundancy check code to iteratively process the remaining n-1 second bit sequences in the n m-bit second bit sequences to obtain a target cyclic redundancy check code, wherein the target cyclic redundancy check code is used to perform a cyclic redundancy check on the second network data, and different cyclic redundancy check code generation strategies correspond to different size relationships.
[0221] In one embodiment, when the size relationship is that the highest power of the second generator polynomial is equal to m, the computer program further implements the following steps when executed by the processor:
[0222] Performing an XOR process on the intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process;
[0223] Wherein, k is a positive integer greater than or equal to 1 and less than or equal to n-1. When k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code. When k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing.
[0224] In one embodiment, when the size relationship is that the highest power of the second generator polynomial is less than m, the computer program further implements the following steps when executed by the processor:
[0225] The intermediate cyclic redundancy check code is shifted left to obtain a target intermediate cyclic redundancy check code;
[0226] Performing an XOR process on the target intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process;
[0227] Among them, k is a positive integer greater than or equal to 1 and less than or equal to n-1; when k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing; the shift bit width corresponding to the left shift processing is equal to the difference between m and the highest power of the second generating polynomial.
[0228] In one embodiment, when the size relationship is that the highest power of the second generator polynomial is greater than m, the computer program further implements the following steps when executed by the processor:
[0229] Splitting the intermediate cyclic redundancy check code to obtain a first intermediate cyclic redundancy check code corresponding to the upper m bits of the intermediate cyclic redundancy check code and a second intermediate cyclic redundancy check code corresponding to the remaining bits except the upper m bits;
[0230] Performing an XOR process on the first intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process to obtain a first cyclic redundancy check code;
[0231] The second intermediate cyclic redundancy check code is subjected to left shift processing, and the second intermediate cyclic redundancy check code subjected to left shift processing and the first cyclic redundancy check code are subjected to XOR processing;
[0232] Among them, k is a positive integer greater than or equal to 1 and less than or equal to n-1; when k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing; the shift bit width corresponding to the left shift processing is equal to m.
[0233] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0234] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification. The above-mentioned embodiments only express several implementation methods of the present application, and their descriptions are relatively specific and detailed, but they cannot be understood as limiting the scope of the patent of this application. It should be pointed out that for ordinary technicians in this field, without departing from the concept of the present application, several deformations and improvements can be made, which all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be based on the attached claims.
Claims
1. A method for generating a cyclic redundancy check code, characterized in that: The method comprises: Acquire first network data to be cyclically redundancy checked, and acquire an input matrix according to the first network data, wherein the first network data is a first bit sequence B with a preset length={D m-1 , D m-2 , ..., D1, D0}; Get the preset first generating polynomial G={G r , G r-1 , G r-2 , ..., G1, G0}, and determine a coefficient matrix corresponding to the first bit sequence according to the first generating polynomial, the number of rows of the coefficient matrix is equal to the highest power r of the first generating polynomial G plus one, and the number of columns of the coefficient matrix is equal to the length m of the first bit sequence B; Performing matrix multiplication processing on the coefficient matrix and the input matrix to obtain a cyclic redundancy check code, wherein the cyclic redundancy check code is used to perform a cyclic redundancy check on the first network data; The determining, according to the first generating polynomial, a coefficient matrix corresponding to the first bit sequence comprises: For the first bit sequence B={D m-1 , D m-2 , ..., D1, D0} i , calculate the target bit D according to the first generator polynomial G i The corresponding remainder term R i , the remainder term R i To convert the bit string The remainder term R is obtained by dividing by the first generating polynomial G after being shifted left by r bits; i ={H i,r ×D i , H i,r-1 ×D i , H i,r-2 ×D i ,......,H i,1 ×D i , H i,0 ×D i }, where {H i,r , H i,r-1 , H i,r-2 ,......,H i,1 , H i,0 } is the target bit D i The corresponding coefficient factor; The coefficient matrix H is generated according to the coefficient factors corresponding to each target bit, wherein the coefficient matrix 2. A method for generating a cyclic redundancy check code, characterized in that: The method comprises: Acquire second network data to be cyclically redundancy checked and a preset second generating polynomial, wherein the second network data includes n second bit sequences of m bits, where n and m are both positive integers greater than 1; Using the method of claim 1, obtaining an initial cyclic redundancy check code of the nth second bit sequence among the n m-bit second bit sequences; Determine the size relationship between the highest power of the second generating polynomial and m, and based on the cyclic redundancy check code generation strategy corresponding to the size relationship, use the initial cyclic redundancy check code to iteratively process the remaining n-1 second bit sequences in the n m-bit second bit sequences to obtain a target cyclic redundancy check code, wherein the target cyclic redundancy check code is used to perform a cyclic redundancy check on the second network data, and different cyclic redundancy check code generation strategies correspond to different size relationships.
3. The method according to claim 2, characterized in that When the magnitude relationship is that the highest power of the second generator polynomial is equal to m, the Kth processing process of the iterative processing includes: Performing an XOR process on the intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process using the method of claim 1; Wherein, k is a positive integer greater than or equal to 1 and less than or equal to n-1. When k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code. When k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing.
4. The method according to claim 2, characterized in that: When the magnitude relationship is that the highest power of the second generator polynomial is less than m, the Kth processing process of the iterative processing includes: The intermediate cyclic redundancy check code is shifted left to obtain a target intermediate cyclic redundancy check code; Performing an XOR process on the target intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process using the method of claim 1; Among them, k is a positive integer greater than or equal to 1 and less than or equal to n-1; when k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing; the shift bit width corresponding to the left shift processing is equal to the difference between m and the highest power of the second generating polynomial.
5. The method according to claim 2, characterized in that: When the magnitude relationship is that the highest power of the second generator polynomial is greater than m, the Kth processing process of the iterative processing includes: Splitting the intermediate cyclic redundancy check code to obtain a first intermediate cyclic redundancy check code corresponding to the upper m bits of the intermediate cyclic redundancy check code and a second intermediate cyclic redundancy check code corresponding to the remaining bits except the upper m bits; Performing an XOR process on the first intermediate cyclic redundancy check code and the nk-th second bit sequence, and performing a cyclic redundancy check code generation process on the result of the XOR process using the method of claim 1 to obtain a first cyclic redundancy check code; The second intermediate cyclic redundancy check code is left-shifted, and the second intermediate cyclic redundancy check code after the left-shifting is XORed with the first cyclic redundancy check code; Among them, k is a positive integer greater than or equal to 1 and less than or equal to n-1; when k=1, the intermediate cyclic redundancy check code is the initial cyclic redundancy check code, and when k>1, the intermediate cyclic redundancy check code is the cyclic redundancy check code obtained by the k-1th iterative processing; the shift bit width corresponding to the left shift processing is equal to m.
6. A cyclic redundancy check code generation device, characterized in that: The device comprises: The first acquisition module is used to acquire first network data to be cyclic redundancy checked and acquire an input matrix according to the first network data, wherein the first network data is a first bit sequence B with a preset length={D m-1 , D m-2 , ..., D1, D0}; The second acquisition module is used to acquire a preset first generating polynomial G={G r , G r-1 , G r-2 , ..., G1, G0}, and determine a coefficient matrix corresponding to the first bit sequence according to the first generating polynomial, the number of rows of the coefficient matrix is equal to the highest power r of the first generating polynomial G plus one, and the number of columns of the coefficient matrix is equal to the length m of the first bit sequence B; A processing module, used for performing matrix multiplication processing on the coefficient matrix and the input matrix to obtain a cyclic redundancy check code, wherein the cyclic redundancy check code is used to perform a cyclic redundancy check on the first network data; The second acquisition module is specifically used to: for the first bit sequence B={D m-1 , D m-2 , ..., D1, D0} i , calculate the target bit D according to the first generator polynomial G i The corresponding remainder term R i , the remainder term R i To convert the bit string The remainder term R is obtained by dividing by the first generating polynomial G after being shifted left by r bits; i ={H i,r ×D i , H i,r-1 ×D i , H i,r-2 ×D i ,......,H i,1 ×D i , H i,0 ×D i }, where {H i,r , H i,r-1 , H i,r-2 ,......,H i,1 , H i,0 } is the target bit D i The corresponding coefficient factor; The coefficient matrix H is generated according to the coefficient factors corresponding to each target bit, wherein the coefficient matrix 7. A cyclic redundancy check code generating device, characterized in that: The device comprises: A first acquisition module, used to acquire second network data to be cyclically redundancy checked and a preset second generating polynomial, wherein the second network data includes n second bit sequences of m bits, where n and m are both positive integers greater than 1; A second acquisition module, configured to acquire an initial cyclic redundancy check code of an nth second bit sequence among the n m-bit second bit sequences by using the method according to claim 1; A generating module is used to determine the size relationship between the highest power of the second generating polynomial and m, and based on the cyclic redundancy check code generation strategy corresponding to the size relationship, use the initial cyclic redundancy check code to iteratively process the remaining n-1 second bit sequences in the n m-bit second bit sequences to obtain a target cyclic redundancy check code, wherein the target cyclic redundancy check code is used to perform a cyclic redundancy check on the second network data, and different cyclic redundancy check code generation strategies corresponding to different size relationships are different.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to claim 1 are implemented; or, when the processor executes the computer program, the steps of the method according to any one of claims 2 to 5 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to claim 1 are implemented; or, when the computer program is executed by a processor, the steps of the method according to any one of claims 2 to 5 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to claim 1 are implemented; or, when the computer program is executed by a processor, the steps of the method according to any one of claims 2 to 5 are implemented.
