A data transmission optimization method and system
By using hash code checksum and repair code technology, the problem of bandwidth waste caused by errors in data transmission is solved. It enables the transmission of only the necessary repair code when an error occurs, thus saving bandwidth and improving transmission efficiency.
Patent Information
- Application Number
- CN202410294968.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-15
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-03-15
AI Technical Summary
During data transmission, errors may occur due to signal interference or other reasons. Existing technologies typically employ redundant transmission or retransmission of the entire data, wasting bandwidth.
Hash code verification and repair code technology is used to confirm the correctness of data transmission by comparing hash codes between devices. Repair codes are only generated and transmitted to repair data when an error occurs, avoiding redundant encoding and transmission for every error.
To save bandwidth and reduce redundant encoding transmission, repair codes are transmitted only when necessary, and the size of the repair codes is much smaller than the original data packets.
Smart Images

Figure CN118199800B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computer communication technology, in particular to a data transmission optimization method and system. BACKGROUND
[0002] At present, when data needs to be transmitted, the transmission process may be interfered by signals or other reasons, resulting in errors and being unable to use. Therefore, redundancy is generally performed on the data, or the entire data is retransmitted after failure, which actually wastes bandwidth. SUMMARY
[0003] In order to solve the above technical problems, the present application provides a data transmission optimization method and system, which can save bandwidth and avoid transmitting redundant codes every time an error occurs to occupy bandwidth.
[0004] The present application adopts the following technical solutions:
[0005] A data transmission optimization method, the method comprising the following steps:
[0006] Step S1, a device A generates a hash code A for data A, and saves the hash code A to a local disk as a key;
[0007] Step S2, the device A transmits the data A to a device B;
[0008] Step S3, after the device A completes the transmission of the data A, the device A sends the hash code A to the device B;
[0009] Step S4, after the device B receives the data A, the device B generates a hash code B for the data A;
[0010] Step S5, the device B compares the received hash code A with the hash code B, if they are the same, it indicates that the data transmission is correct; if they are different, it indicates that the data transmission is incorrect, the device B saves the data A as data B, and then executes step S6;
[0011] Step S6, the device A generates a repair code and sends it to the device B, and the device B receives the repair code and repairs the data B according to the repair code.
[0012] Preferably, the step S6 is further specifically: if they are different, it indicates that the data transmission is incorrect, the device B saves the data A as data B, and the device B sends a request repair code instruction and the hash code A to the device A.
[0013] Preferably, the step S6 is further specifically: the device A searches for the data A according to the hash code A, generates a repair code with a redundancy of 1% for the data A, and then sends the repair code to the device B.
[0014] Preferably, the repair code is generated in the following way:
[0015] The data A is divided into blocks in units of N bytes, and a repair code with a redundancy of 1% is generated for each block A; the N is greater than 200 bytes.
[0016] Preferably, in the step S1, the data A is greater than 2000 bytes.
[0017] Preferably, the data B is divided into blocks in units of N bytes, a corresponding repair code is applied to each block B to generate data C, then a hash code C is generated for the data C, and the hash code C is compared with the hash code A. If they are the same, the repair is successful; if they are different, it indicates that the repair fails, and the step S6 is continued to be executed, and the redundancy is doubled when generating the repair code.
[0018] A data transmission optimization system, the system comprising a generation module A, a transmission module, a sending module, a generation module B, a comparison module, a repair module;
[0019] The generation module A: the device A generates a hash code A for the data A, and saves the hash code A to the local disk as a key;
[0020] The transmission module: the device A transmits the data A to the device B;
[0021] The sending module: after the device A completes the transmission of the data A, the device A sends the hash code A to the device B;
[0022] The generation module B: after the device B receives the data A, the device B generates a hash code B for the data A;
[0023] The comparison module: the device B compares the received hash code A with the hash code B. If they are the same, it indicates that the data transmission is correct; if they are different, it indicates that the data transmission is incorrect, the data A is saved as the data B, and then the step S6 is executed;
[0024] The repair module: the device A generates a repair code and sends it to the device B, and the device B receives the repair code and repairs the data B according to the repair code.
[0025] Preferably, the repair module is further specific to: if they are different, it indicates that the data transmission is incorrect, the data A is saved as the data B, and the device B sends a request repair code instruction and the hash code A to the device A.
[0026] Preferably, the repair module is further specific to: the device A looks up the data A according to the hash code A, generates a repair code with a redundancy of 1% for the data A, and then sends the repair code to the device B.
[0027] Preferably, the repair code is generated in the following way:
[0028] The data A is divided into blocks in units of N bytes, and a repair code with a redundancy of 1% is generated for each block A; the N is greater than 200 bytes.
[0029] Preferably, in the generating module A, the data A is greater than 2000 bytes.
[0030] Preferably, the repairing module further comprises: dividing the data B into blocks in units of N bytes, applying the corresponding repair code to each block B to generate data C, generating a hash code C of the data C, comparing the hash code C with the hash code A, if the same, the repairing is successful; if different, it indicates that the repairing fails, and the step S6 is continuously executed, and the redundancy is doubled when the repair code is generated.
[0031] The present application has the following beneficial effects:
[0032] The present application provides a data transmission optimization method and system, which can save bandwidth, avoid transmission of redundant codes every time an error occurs to occupy bandwidth, and also incrementally transmit repair codes when an error occurs occasionally, which are much smaller than original data packets. BRIEF DESCRIPTION OF DRAWINGS
[0033] Figure 1 is a method flowchart of the present application.
[0034] Figure 2 is a system principle block diagram of the present application. DETAILED DESCRIPTION
[0035] The present application will be further described below with reference to the accompanying drawings.
[0036] Please refer to Figure 1 The present application provides a data transmission optimization method, which comprises the following steps:
[0037] Step S1, a device A generates a hash code A of data A, and saves the hash code A to a local disk as a key;
[0038] Step S2, the device A transmits the data A to a device B;
[0039] Step S3, after the device A completes the transmission of the data A, the device A sends the hash code A to the device B;
[0040] Step S4, after the device B receives the data A, the device B generates a hash code B of the data A;
[0041] Step S5, the device B compares the received hash code A with the hash code B, if the same, it indicates that the data transmission is correct; if different, it indicates that the data transmission is incorrect, the data A is saved as data B, and then the step S6 is executed;
[0042] Step S6, the device A generates the repair code and sends it to the device B, and the device B receives the repair code and repairs the data B according to the repair code.
[0043] The application will be further described in combination with a specific embodiment:
[0044] A data transmission optimization method,
[0045] Step 1, the device A generates the hash code A for the data A and saves it to the local disk as the key; the data A is greater than 2000 bytes;
[0046] 1. The device A generates the hash code A for the data A and saves it to the local disk as the key;
[0047] The device A generates the md5 value 97ba9c6563136b6116029d6b50f6ef63 for the data with the beginning abcdabcd and the rear all as \x00, and saves it to the local disk as the key.
[0048] Step 2, the device A transmits the data A to the device B;
[0049] 2. The device A transmits the data to the device B;
[0050] The device A transmits the data with the beginning abcdabcd to the device B;
[0051] Step 3, the device A transmits the data A and then sends the hash code A to the device B;
[0052] 3. The device A transmits the data and then sends the hash code A to the device B;
[0053] The device 1 transmits the data and then sends 97ba9c6563136b6116029d6b50f6ef63 to the device 2;
[0054] Step 4, the device B receives the data A and generates the hash code B for the data A;
[0055] 4. The device 2 receives the data and generates the hash code B by using the same algorithm;
[0056] The device 2 receives the data abcdabcd... and generates the md5 value 97ba9c6563136b6116029d6b50f6ef63 by using the same algorithm.
[0057] Step 5, the device B compares the received hash code A with the hash code B, if same, it means the data transmission is correct; if different, it means the data transmission is incorrect, the data A is saved as data B, then step S6 is executed;
[0058] 5. The device 2 compares the hash code A with the hash code B, if same, it means the data transmission is correct;
[0059] Both md5 are 97ba9c6563136b6116029d6b50f6ef63, which means the transmission is correct;
[0060] Otherwise, it means the data transmission is incorrect (here saved as incorrect data 1);
[0061] If the device B receives 1bcdabcd..., the same algorithm generates md5 value da5887aa5f0ea7fcbca33293c90f064a, which is not equal to 97ba9c6563136b6116029d6b50f6ef63 sent by the device 1.
[0062] Step 6, the device A generates the repair code and sends it to the device B, the device B receives the repair code and repairs the data B according to the repair code.
[0063] If different, it means the data transmission is incorrect, the data A is saved as data B, the device B sends the repair code request instruction and the hash code A to the device A.
[0064] The device A looks up the data A according to the hash code A, and generates the repair code with 1% redundancy for the data A, and then sends the repair code to the device B.
[0065] The data A is divided into blocks with N bytes as a unit, and a repair code with 1% redundancy is generated for each block A; the N is greater than 200 bytes.
[0066] The data B is divided into blocks with N bytes as a unit, and the corresponding repair code is applied to each block B to generate data C, then the hash code C is generated for the data C, and the hash code C is compared with the hash code A, if same, the repair is successful; if different, it means the repair fails, step S6 is continuously executed, and the redundancy is doubled when generating the repair code.
[0067] 6. The device 2 sends the repair code request instruction and the data hash code to the device 1;
[0068] The device 2 sends the repair code repair and 97ba9c6563136b6116029d6b50f6ef63 to the device 1;
[0069] Device 1 looks up the corresponding data based on the hash code, and generates a redundancy-1% repair code from the original data using Reed-Solomon coding, and sends the repair code to Device 2;
[0070] Device 1 finds the data abcdabcd... based on 97ba9c6563136b6116029d6b50f6ef63 and generates a repair with a redundancy of 1%.
[0071] The data is divided into blocks of N bytes, and one repair code is generated for each block;
[0072] Divide into blocks of 200 bytes each, the first block
[0073] abcdabcd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x 00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x 00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00;
[0074] Generate the first patch code
[0075] \x27\xa7\x0f\x8f;
[0076] Second block
[0077] \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00;
[0078] Repair code
[0079] \x00\x00\x00\x00;
[0080] Send the repair code to device 2;
[0081] Device 2 receives the repair code, applies it to the erroneous data 1 to generate the original data, generates a hash code C, and compares it with the original data. If they match, the repair is successful and the process ends. Otherwise, steps 7 to 9 are repeated, doubling the redundancy (2%, 4%, 8%... 256%).
[0082] Device 2 receives the data and repairs each line, appending a repair code to the first line.
[0083] 1bcdabcd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x27\xa7\x0f\x8f;
[0084] Repaired by Reed Solomon algorithm
[0085] abcdabcd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00;
[0086] The last several lines are not wrong, and they are also repaired, and the md5 of the whole data generated again is 97ba9c6563136b6116029d6b50f6ef63, which is correct, then the repair is completed, otherwise repeat step 6 to increase redundancy.
[0087] Please continue to refer to Figure 2The application also provides a data transmission optimization system, which comprises a generating module A, a transmission module, a sending module, a generating module B, a comparison module and a repairing module.
[0088] The generating module A: the device A generates a hash code A for the data A and saves the hash code A to the local disk as a key.
[0089] The transmission module: the device A transmits the data A to the device B.
[0090] The sending module: after the device A completes the transmission of the data A, the device A sends the hash code A to the device B.
[0091] The generating module B: after the device B receives the data A, the device B generates a hash code B for the data A.
[0092] The comparison module: the device B compares the received hash code A with the hash code B, if they are the same, it means that the data transmission is correct; if they are different, it means that the data transmission is incorrect, the data A is saved as data B, and then step S6 is executed.
[0093] The repairing module: the device A generates a repairing code and sends it to the device B, and the device B receives the repairing code and repairs the data B according to the repairing code.
[0094] Preferably, the repairing module is further specific to: if they are different, it means that the data transmission is incorrect, the data A is saved as data B, and the device B sends a request repairing code instruction and the hash code A to the device A.
[0095] Preferably, the repairing module is further specific to: the device A searches the data A according to the hash code A, generates a repairing code with a redundancy of 1% for the data A, and then sends the repairing code to the device B.
[0096] Preferably, the repairing code is generated in the following way:
[0097] The data A is divided into blocks in units of N bytes, and a repairing code with a redundancy of 1% is generated for each block A; the N is greater than 200 bytes.
[0098] Preferably, in the generating module A, the data A is greater than 2000 bytes.
[0099] Preferably, the repairing module is further specific to: the data B is divided into blocks in units of N bytes, a corresponding repairing code is applied to each block B to generate data C, a hash code C is generated for the data C, the hash code C is compared with the hash code A, if they are the same, the repairing is successful; if they are different, it means that the repairing fails, step S6 is continuously executed, and the redundancy is doubled when the repairing code is generated.
[0100] In summary, the present application can save bandwidth, avoid transmitting redundant codes every time an error occurs to occupy bandwidth, and also incrementally transmit repair codes when an error occurs, which are much smaller than original data packets.
[0101] The above description is merely preferred embodiments of the present application, and is not to be understood in its limiting sense, and it is to be understood that variations and modifications can be made by those skilled in the art without departing from the scope of the present application.
Claims
1. A data transmission optimization method, characterized in that: The method includes the following steps: Step S1: Device A generates a hash code A for data A and saves it to the local disk using hash code A as the key; Step S2: Device A transmits data A to device B; Step S3: After device A completes the transmission of data A, it sends hash code A to device B; Step S4: After receiving data A, device B generates hash code B for data A; Step S5: Device B compares the received hash code A with hash code B. If they are the same, the data transmission is correct; if they are different, the data transmission is incorrect. Data A is saved as data B, and then step S6 is executed. Step S6: Device A generates a repair code and sends it to Device B. After receiving the repair code, Device B repairs data B according to the repair code. Step S6 is further specified as follows: if they are different, it indicates that there is a data transmission error. Data A is saved as data B, and device B sends a request for repair code and hash code A to device A. Step S6 is further specified as follows: Device A searches for data A according to hash code A, generates a repair code with redundancy of 1% for data A, and then sends the repair code to device B; Generate the fix code using the following method: Data A is divided into blocks of N bytes, and a repair code with 1% redundancy is generated for each block A; where N is greater than 200 bytes. Step S6 is further specified as follows: Divide the data B into blocks of N bytes, apply the corresponding repair code to each block B to generate data C, generate hash code C for data C, compare hash code C with hash code A. If they are the same, the repair is successful; if they are different, the repair fails, and step S6 is continued, with the redundancy doubled when generating the repair code.
2. The data transmission optimization method according to claim 1, characterized in that: In step S1, the data A is greater than 2000 bytes.
3. A data transmission optimization system, characterized in that: The system includes a generation module A, a transmission module, a sending module, a generation module B, a comparison module, and a repair module; Generation module A: Device A generates hash code A for data A and saves it to the local disk using hash code A as the key; Transmission module: Device A transmits data A to device B; Sending module: After device A completes the transmission of data A, it sends hash code A to device B; Generation module B: After receiving data A, device B generates hash code B for data A; Comparison module: Device B compares the received hash code A with hash code B. If they are the same, it means that the data transmission is correct; if they are different, it means that the data transmission is incorrect. Data A is saved as data B, and then the repair module steps are executed. Repair module: Device A generates a repair code and sends it to Device B. After receiving the repair code, Device B repairs data B according to the repair code. The repair module is further specified as follows: if they are different, it indicates a data transmission error, data A is saved as data B, and device B sends a request repair code instruction and hash code A to device A; The repair module is further defined as follows: Device A searches for data A based on hash code A, generates a repair code with a redundancy of 1% for data A, and then sends the repair code to device B; Generate the fix code using the following method: Data A is divided into blocks of N bytes, and a repair code with 1% redundancy is generated for each block A; where N is greater than 200 bytes. The repair module is further specified as follows: the data B is divided into blocks of N bytes, the corresponding repair code is applied to each block B to generate data C, then a hash code C is generated for data C, and the hash code C is compared with the hash code A. If they are the same, the repair is successful; if they are different, the repair fails, and the steps of the repair module are continued, with the redundancy doubled when generating the repair code.
4. The data transmission optimization system according to claim 3, characterized in that: In the generation module A, the data A is greater than 2000 bytes.
Citation Information
Patent Citations
Information processing method and electronic equipment
CN104899107A
Intelligent power distribution network data secure transmission method and system and storage medium
CN113259345A