WO2011157074A1 - Method, device and system for transferring and checking data files - Google Patents

Method, device and system for transferring and checking data files Download PDF

Info

Publication number
WO2011157074A1
WO2011157074A1 PCT/CN2011/072118 CN2011072118W WO2011157074A1 WO 2011157074 A1 WO2011157074 A1 WO 2011157074A1 CN 2011072118 W CN2011072118 W CN 2011072118W WO 2011157074 A1 WO2011157074 A1 WO 2011157074A1
Authority
WO
WIPO (PCT)
Prior art keywords
segment
crc value
data
data segment
parameter
Prior art date
Application number
PCT/CN2011/072118
Other languages
French (fr)
Chinese (zh)
Inventor
王光辉
贾晓强
谢大
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2011157074A1 publication Critical patent/WO2011157074A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/004Arrangements for detecting or preventing errors in the information received by using forward error control
    • H04L1/0056Systems characterized by the type of code used
    • H04L1/0061Error detection codes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/004Arrangements for detecting or preventing errors in the information received by using forward error control
    • H04L1/0041Arrangements at the transmitter end

Definitions

  • the present invention relates to information and communication technologies, and more particularly to a method, device and system for data file transmission and verification. Background technique
  • the data files are often involved in the transmission (including wireless transmission or wired transmission) between the devices in the communication system.
  • the data file is lost due to poor network status or unstable transmission channel during transmission. Problems such as codec errors in packets or data files may cause errors in the contents of data files transmitted to the target device.
  • the target device fails to use the incorrect data file to perform the business operation failure. After receiving the data file transmitted by the source device, the target device needs to verify the data file.
  • the method by which the target device verifies the received data file is for the check of the Cyclic Redundancy Check (CRC) field.
  • CRC Cyclic Redundancy Check
  • the source device generates a data file to be transmitted, calculates a CRC value for the entire data file, and writes the calculated CRC value to a fixed position of the data file, and then transmits the CRC value to the target device;
  • the target device recalculates the CRC value for the received entire data file, and compares the CRC value calculated by the target device with the CRC value written by the fixed position of the data file, thereby correcting the correctness of the received data file. Test. If the comparison result is that the CRC value calculated by the target device matches the CRC value written by the fixed position of the data file, it indicates that the data file has no error during transmission; otherwise, it indicates that the data file has an error during transmission.
  • both the source device and the target device calculate the CRC value for the entire data file, and therefore, only the target device completely receives the data file. After the device can verify the correctness of the data file transmission, even if some of the received data files have been wrong, they cannot be found in time.
  • the embodiment of the invention provides a method, a device and a system for data file transmission and verification, which are used to solve the problem that the error in the data file transmission process cannot be found in time in the prior art.
  • a method of data file transmission comprising:
  • the source device segments the data file to be transmitted to obtain a plurality of data segments
  • the source device calculates a cyclic redundancy check CRC value for each data segment
  • the source device transmits the data segment and the CRC value of the data segment to the target device.
  • the method further includes: after calculating a CRC value of each data segment, and transmitting the data segment and the CRC value of the data segment to the target device, the method further includes:
  • the source device places the CRC value of each data segment into the parameter segment, and calculates a CRC value of the parameter segment after the CRC value of the data segment is placed, and places the CRC value of the parameter segment into the parameter segment;
  • the source device transmits the data segment and the CRC value of the data segment to the target device as:
  • the source device transmits the parameter segment and each data segment to the target device; wherein the parameter segment is transmitted before the data segment.
  • a method for data file verification comprising:
  • the target device calculates a CRC value of the received data segment, and compares the calculated CRC value of the data segment with the CRC value of the received data segment;
  • the target device determines that the calculated CRC value of the data segment matches the received CRC value of the data segment, it determines that the data segment verification is successful; if not, determines that the data segment verification fails.
  • the method further includes Includes:
  • the target device calculates a CRC value of the received parameter segment, and determines that the parameter segment is successfully verified when it is determined that the calculated CRC value of the parameter segment matches the CRC value of the parameter segment carried in the parameter segment;
  • the target device determines a CRC value for each data segment carried in the parameter segment.
  • the method further includes: the target device requests the source device to retransmit the data segment that fails the verification.
  • a device for data file transmission comprising:
  • a segmentation module configured to segment the data file to obtain a plurality of data segments
  • a first CRC value calculation module configured to calculate a cyclic redundancy check CRC value of each data segment
  • a transmission module configured to transmit a data segment and a CRC value of the data segment.
  • the segmentation module is further configured to generate a parameter segment
  • the first CRC value calculation module is further configured to calculate a CRC value of a parameter segment after the CRC value of the data segment is placed;
  • the device further includes:
  • An information placing module configured to: put a CRC value of each data segment into the parameter segment, and place a CRC value of the parameter segment into the parameter segment;
  • the transmission module is further configured to transmit a parameter segment; wherein the parameter segment is transmitted before the data segment.
  • a device for verifying data files comprising:
  • a receiving module configured to receive a data segment and a CRC value of the data segment
  • a second CRC value calculation module configured to calculate a CRC value of the received data segment
  • a verification module configured to perform a CRC value of the data segment calculated by the second CRC value calculation module and a CRC value of the received data segment Compare, if calculated CRC of the data segment When the value matches the received CRC value of the data segment, it is determined that the data segment is successfully verified; when there is no match, it is determined that the data segment verification fails.
  • the receiving module is further configured to receive a parameter segment and a CRC value of the parameter segment;
  • the second CRC value calculation module is further configured to calculate a CRC value of the received parameter segment; the verification module is further configured to determine a CRC value of the calculated parameter segment and a parameter segment carried in the parameter segment When the CRC values match, it is determined that the parameter segment verification is successful.
  • the device further includes:
  • an information determining module configured to determine a CRC value of each data segment carried in the parameter segment. Further, the verification module is further configured to request, after determining that the data segment verification fails, to retransmit the data segment that fails the verification.
  • a data file verification system includes a source device and a target device; wherein, the source device is configured to segment the data file, obtain a plurality of data segments, and calculate a cyclic redundancy check CRC of each data segment. a value, and transmitting the data segment and the CRC value of the data segment to the target device;
  • a target device configured to calculate a CRC value of the received data segment, and compare the calculated CRC value of the data segment with a CRC value of the received data segment, if the CRC value of the calculated data segment is determined and received When the CRC value of the data segment matches, it is determined that the data segment is successfully verified; when there is no match, it is determined that the data segment verification fails.
  • the invention divides the data file into a plurality of data segments by the source device, and after calculating the CRC value of each data segment, respectively transmits the CRC values of each data segment and the data segment, so that the data segment and the data segment are received.
  • the target device of the CRC value can be verified for each data segment, so that the target device can timely discover errors occurring during the data file transmission when the data file has not been completely transmitted.
  • FIG. 1 is a schematic flowchart of an implementation of a method for data file transmission according to an embodiment of the present invention
  • FIG. 2(a) is a schematic diagram of a data file according to an embodiment of the present invention
  • 2(b) and 2(c) are schematic diagrams of segmented data segments based on different segmentation methods in the first embodiment of the present invention
  • FIG. 3 is a schematic flowchart of a method for verifying a data file according to Embodiment 2 of the present invention
  • FIG. 4 is a schematic structural diagram of a data file transmission device according to Embodiment 4 of the present invention.
  • FIG. 5 is a schematic structural diagram of a data file verification device according to Embodiment 5 of the present invention.
  • FIG. 6 is a schematic structural diagram of a data file verification system according to Embodiment 6 of the present invention. detailed description
  • an embodiment of the present invention proposes to segment a data file, calculate a CRC value for each data segment on the source device side, and send the data segment and the CRC value of the data segment to the target device.
  • the target device calculates the CRC value of the data segment again, and then matches the CRC value calculated by the target device for a certain data segment with the CRC value of the data segment sent by the source device, and further Determine if the verification of the data segment is successful.
  • the target device can verify the correctness of the received data file when receiving part of the data file, and can timely discover when the partial data file sends an error, thereby improving the correct rate of data file transmission.
  • Embodiment 1 is a diagrammatic representation of Embodiment 1:
  • Step 101 The source device segments the data file.
  • the source device may segment the data file according to the preset number of data segments and the length of each data segment. This includes but is not limited to the following two segmentation methods. method one:
  • a segment length to divide the data file into multiple data segments according to the set segment length. If the data file length cannot be completely evenly divided, the length of the last data segment can be smaller than the set segment length. For example, as shown in Figure 2 (a), for a data file of length 0x00012000, only the 32-byte content at the beginning of the data file and the 32-byte content at the end are shown in Figure 2 (a). Set the segment length to 0x4000, as shown in Figure 2 (b), the entire data file is divided into 5 data segments, the length of the first 4 data segments is 0x4000, the last data segment is not full, only the length is 0x2000 Partially written content.
  • the data file is still as shown in Figure 2 (a) before the division, and the length is 0x00012000.
  • the data file is divided into the data file as shown in Figure 2 (c). 4 data segments, each of which has a length of 0x2000, 0x6000, 0x7000, 0x3000, respectively.
  • the data segments are sequentially assigned identifiers 1 and 2 n.
  • Step 102 The source device calculates a cyclic redundancy check CRC value for each data segment.
  • the cyclic redundancy check method is used to calculate the CRC value of each data segment.
  • the first embodiment of the present invention provides, but is not limited to, the following three methods for storing the CRC value of each data segment:
  • Method 1 Save the CRC value at a fixed position in each data segment.
  • the source device saves the calculated CRC value of each data segment at a fixed position of the corresponding data segment. Further, a fragment terminator may be added at the end of the content of the non-last data segment, and a file terminator may be added at the end of the content of the last data segment, so that the target device can It is enough to correctly judge whether the transmission of data fragments and data files is completed.
  • Method 2 Save the CRC value in the parameter fragment.
  • the source device adds a parameter segment to the data header of the data file, and allocates a segment identifier for the segment.
  • the segment is assigned an identifier of 0, and the length of the segment 0 may be based on actual data transmission requirements. Set as long as the length of segment 0 is greater than or equal to the space required for the content to be carried.
  • the source device writes the calculated CRC value of each data segment into segment 0.
  • the CRC value is written in the segment 0, and the data segment corresponding to each CRC value is also recorded; or, in segment 0, dedicated to storage
  • the area of the CRC value of the data segment is sequentially written into the CRC value of the data segment according to the order of the identification of the data segment from small to large (or large to small), so that the target device reads and reads according to the order of the received data segment.
  • the order of the CRC values correctly identifies the relationship between the data segment and the CRC value.
  • the total length of the original file, the length of each data segment, and the length of the parameter fragment can also be written to the corresponding position of the segment 0.
  • the above three parameters can be used by the subsequent target device to determine whether the transmission of the data file, a certain data segment or the parameter segment is completed.
  • the source device calculates the CRC value of the segment 0, and writes the calculated CRC value of the parameter segment to the fixed position of the segment 0.
  • Method 3 Save the CRC value In the request message.
  • the source device generates a request message, and stores the calculated CRC value of each data segment in a fixed location of the request message.
  • Step 103 The source device transmits the data segment and the CRC value of the data segment to the target device.
  • the source device If the source device saves the CRC value at a fixed location of each data segment, in this step, the source device directly transmits each data segment to the target device.
  • the device transmits the parameter segment and each data segment to the target device according to the condition that the parameter segment is transmitted before the data segment.
  • the data segment may continue to be transmitted.
  • the source device If the source device saves the CRC value in the request message, since the content of the request message provides the basis for the subsequent operation of the data segment by the target device, the source device first transmits the request message to the target device, and after the request message is successfully transmitted, Continue to transfer the data fragments.
  • the source device sends the data segment and the CRC value of each data segment to the target device in multiple manners. Since the data file is fragmented, the target device can target the data segment with a shorter length. Receiving and verifying data improves the accuracy of data file transmission.
  • Embodiment 2 is a diagrammatic representation of Embodiment 1:
  • the second embodiment of the present invention provides a data file verification method based on the data file of the first embodiment. As shown in FIG. 3, the method includes the following steps:
  • Step 201 After receiving the data segment, the target device calculates a CRC value of the data segment. In this step, the target device and the source device calculate the CRC value of the data segment using the same algorithm.
  • Step 202 The target device compares the CRC value calculated by itself with the CRC value of the data segment sent by the source device. If the comparison result is that the CRC value matches, step 203 is performed; otherwise, step 204 is performed.
  • Step 203 The target device determines that the data segment is successfully verified.
  • Step 204 The target device determines that the data segment verification fails.
  • the manner in which the target device receives the data segment and the data segment is verified may also include the foregoing, in the solution of the second embodiment, the manner in which the source device receives the data segment. The following three:
  • the source device sends the CRC value of the data segment and the data segment to the target device according to the transmission mode in step 103, after the target device receives the data segment directly transmitted by the source device, first, the segment end character/file terminator of each data segment is determined. Whether the reception of the data segment/data file is completed, and the received data segment is verified.
  • the verification mode is: when the target device receives a data segment, the CRC value of the data segment is calculated, and compared with the CRC value stored in the fixed position in the segment, if the two CRC values do not match, the data segment The verification fails, and the target device requests the source device to retransmit the data segment that failed the verification; otherwise, the verification of the data segment is successful, and the target device continues to receive and verify other data segments. Until the transmission of the entire data file is completed according to the end of the file, and each segment is successfully verified, the target device integrates each data segment to obtain the data file transmitted by the source device.
  • the target device first receives the parameter segment, and determines whether the parameter segment is transmitted through the length of the parameter segment provided in the parameter segment. In the judgment of receiving the complete parameters After the segment, the CRC value of the received parameter segment is calculated and compared with the CRC value stored in the fixed position of the parameter segment. If the two CRC values do not match, the verification of the parameter segment fails, and the source device is requested to retransmit the parameter segment. Otherwise, the verification of the parameter segment is successful, the target device extracts the CRC value of each data segment carried from the parameter segment, and verifies the data segment by using the extracted CRC value.
  • the target device can verify the received data segments in a single-threaded or multi-threaded manner.
  • the target device receives the first data segment, and determines whether the transmission of the first data segment is completed according to the length of each data segment in the parameter segment. After the complete first data segment, the CRC value of the first data segment is calculated and compared with the CRC value of the first data segment stored in the parameter segment. If the two CRC values do not match, the data If the verification of the fragment fails, the target device requests the source device to retransmit the data fragment that failed the verification; otherwise, the verification of the data segment succeeds, the second data segment continues to be received, and the second data segment is verified as described above. After checking, according to the total length of the original file in the parameter segment, it is judged that the entire data file has been transmitted, and each data segment is verified successfully, and the verification of the entire data file by the target device is completed.
  • the target device can receive only one data segment at a time, and receive the next data segment when the data segment is successfully verified; the target device can also receive only N at a time ( N is a positive integer of more than 1 data segment, and then receives the following N data segments when all of the N data segments are successfully verified; if at least one of the N data segments is not verified successfully, Then, the target device will request the source device to retransmit the data segment whose verification fails, until all the N data segments are successfully verified.
  • the target device In the multi-thread verification mode, after the target device successfully verifies the parameter segment, the target device checks the received complete data segment, and if there is still not received the complete data segment, the target device will perform the same. The data segment is verified while receiving other pieces of data. In When at least one data segment currently being verified is verified to be successful, the data segment that has not been subjected to data verification is continuously determined from the received data segments, and the data segment that continues to be determined is calculated.
  • the target device first receives the request message, and extracts the CRC value of each data segment and the total length of the original file from the request message. Information such as the length of each data segment.
  • the target device After receiving the data segment, the target device determines whether the transmission of the data segment is completed according to the length of each data segment carried in the request message, and after determining that the complete data segment is received, calculates the CRC value of the received data segment, and requests The CRC value of the data segment carried in the message is compared. If the two CRC values do not match, the verification of the data segment fails, and the target device requests the source device to retransmit the data segment that failed the verification; otherwise, the data segment The verification succeeds, and the other data segments are continuously verified until the transmission of the entire data file is completed according to the total length of the data file in the request message, and each data segment is verified successfully, and the verification of the entire data file by the target device is completed.
  • Embodiment 3 is a diagrammatic representation of Embodiment 3
  • the third embodiment of the present invention describes the solutions of the first embodiment and the second embodiment by using specific examples.
  • the method in which the source device sends the data file to the target device and the target device checks the received data file includes:
  • the segment length is set to 0x4000, and the data file is segmented according to the length of the segment. Since the total length of the data file is 0x00012000, the data file can be divided into five data segments, and each data segment is sequentially numbered as 1. 2...5 , the last data fragment is less than 0x4000 The size and segmentation results are shown in Figure 2 (b).
  • a parameter fragment of size 0x4000 is added to the head of the data file, and the parameter fragment number is 0.
  • the data file after the parameter fragment is added may be referred to as a new file, and the data file when the parameter fragment is not added may be referred to as an original file. Since the total size of the data file is 0x00012000 before the parameter fragment is added, the offset of the original file content in the new file is 0x4000, and the size of each data segment is 0x4000 except for the last data segment.
  • the CRC values are respectively calculated for the first to fifth data segments of the file, and CRC1, CRC2, CRC3, CRC4, and CRC5 corresponding to the first to fifth data segments are obtained, and the obtained CRC values are respectively written.
  • the total length of the data file, the length of each data segment, and the length of the parameter segment are placed at corresponding positions within the parameter segment.
  • the CRC of the segment 0 after the information is added is calculated, and the fixed position of the segment 0 is written.
  • the fragment 0 of the new file is transmitted to the target device.
  • the target device completely receives the segment 0 according to the length of the parameter segment, the segment 0 is verified.
  • the target device calculates the CRC value of the segment 0 and compares it with the CRC value of the segment 0 stored in the fixed position in the segment 0. If the comparison result is inconsistent, the verification fails, and the target device requests to re-download the segment 0, returning to the first Six steps; If the comparison result is consistent, the verification passes, indicating that the transmission of segment 0 is successful, and the eighth step is performed.
  • the source device transmits a data segment to the target device.
  • the CRC value of the segment is calculated, and the calculation result is compared with the CRC value of the data segment written in the segment 0, if two The CRC value is consistent, indicating that the data segment is successfully transmitted, and jumps to the tenth step; if it is determined that the CRC value is inconsistent, the request to re-download the data segment is performed again.
  • the data segment verification is successful, jump to the tenth step.
  • Step 10 The target device determines whether the data file has been completely received according to the total length of the data file and the length of the data segment, and if so, integrates the data segment that has been received and verified successfully into a data file, and ends the data file transmission. And the operation of the check; otherwise, jump to the eighth step.
  • the data file is divided into a plurality of data segments for transmission, and the target setting can effectively improve the accuracy of the transmission; meanwhile, when the target device finds that one or more data segments are transmitted incorrectly, only the source device needs to be requested.
  • the data segment in which the transmission error occurs is retransmitted, which reduces the channel resources and transmission time required for retransmission, and improves the transmission efficiency of the data file.
  • Embodiment 4 is a diagrammatic representation of Embodiment 4:
  • a fourth embodiment of the present invention provides a data file transmission device. As shown in FIG. 4, the device includes a segmentation module 11, a first CRC value calculation module 12, and a transmission module 13, where:
  • the segmentation module 11 is configured to segment the data file to obtain a plurality of data segments; the first CRC value calculation module 12 is configured to calculate a cyclic redundancy check CRC value of each data segment; and the transmission module 13 is configured to transmit the data segment. And the CRC value of the data segment.
  • the segmentation module 11 is further configured to generate a parameter segment; the first CRC value calculation module 12 is further configured to calculate a CRC value of a parameter segment after the CRC value of the data segment is placed; the transmission module 13 is further configured to transmit A parameter fragment, where the parameter fragment is transmitted before the data fragment.
  • the device further includes: an information placing module 14 configured to: place a CRC value of each data segment into the parameter segment, and place the CRC of the parameter segment into the parameter segment; further, the information is placed into the module 14 is also used to set the total length of the data file and the length of each data segment. And the length of the parameter segment is placed in the parameter segment.
  • an information placing module 14 configured to: place a CRC value of each data segment into the parameter segment, and place the CRC of the parameter segment into the parameter segment; further, the information is placed into the module 14 is also used to set the total length of the data file and the length of each data segment. And the length of the parameter segment is placed in the parameter segment.
  • Embodiment 5 is a diagrammatic representation of Embodiment 5:
  • a fifth embodiment of the present invention provides a data file verification device. As shown in FIG. 5, the device includes a receiving module 21, a second CRC value calculation module 22, and a verification module 23, where:
  • the receiving module 21 is configured to receive the data segment and the CRC value of the data segment; the second CRC value calculating module 22 is configured to calculate the CRC value of the received data segment; the verifying module 23 is configured to calculate the second CRC value calculating module 22
  • the CRC value of the obtained data segment is compared with the CRC value of the received data segment. If the calculated CRC value of the data segment matches the received CRC value of the data segment, it is determined that the data segment is successfully verified; otherwise , to determine that the data fragment verification failed.
  • the receiving module 21 is further configured to receive a parameter segment and a CRC value of the parameter segment;
  • the second CRC value calculating module 22 is further configured to calculate a CRC value of the received parameter segment;
  • the verification module 23 is further configured to: When it is determined that the calculated CRC value of the parameter segment matches the CRC value of the received parameter segment, it is determined that the parameter segment verification is successful.
  • the device further includes: an information determining module 24, configured to determine a CRC value of each data segment carried in the parameter segment.
  • the verification module 23 is further configured to request to retransmit the data fragment that fails the verification after determining that the data segment verification fails.
  • the check module 23 is configured to calculate a CRC value of the at least one data segment after receiving at least one data segment, and calculate a CRC value of the at least one data segment and receive the at least one data Comparing the CRC values of the segments, when determining that the at least one data segment is successfully verified, continuing to receive the data segments, calculating a CRC value of the data segment that continues to be received, and verifying the data segments that continue to be received, Otherwise, the source device is requested to retransmit the data segment that failed the verification.
  • the verification module 23 is specifically configured to determine at least one number from the received data segments. After determining the CRC value of the determined at least one data segment, and calculating the calculated CRC value of the at least one data segment and comparing the CRC value of the at least one data segment, When at least one data segment is successfully verified, the data segment that has not been verified by the data segment is determined from the received data segment, and the CRC value of the data segment that continues to be determined is calculated, and the data segment that continues to be determined is verified. Otherwise, the source device is requested to retransmit the data fragment that failed the verification.
  • the functions of the data file transmission and the data file verification in the first embodiment to the second embodiment may be implemented in a physical device, and the physical devices integrated in the fourth embodiment and the fifth embodiment are used to transmit data files to other devices.
  • the data transmission operation may be implemented by using the function module involved in the fourth embodiment.
  • the physical device may perform the verification operation by using the function module involved in the fifth embodiment.
  • a sixth embodiment of the present invention provides a data file verification system. As shown in FIG. 6, the device includes a source device 31 and a target device 32, where:
  • the source device 31 is configured to segment the data file, obtain a plurality of data segments, calculate a CRC value of each data segment, and send the data segment and the CRC value of the data segment to the target device 32; the target device 32 is configured to target Receiving the data segment, calculating a CRC value of the data segment, and comparing the calculated CRC value of the data segment with the CRC value of the received data segment, if determining the CRC value of the calculated data segment and the received If the CRC value of the data segment matches, it is determined that the data segment is successfully verified; otherwise, it is determined that the data segment verification fails.
  • the source device 31 involved in the sixth embodiment of the present invention may be the source device involved in the implementation of the first embodiment to the third embodiment, and has various functional modules involved in the fourth embodiment.
  • the target device 32 is implemented in the first embodiment to the third embodiment.
  • the target device involved in the present invention has various functional modules involved in the fifth embodiment, and details are not described herein again.
  • the spirit and scope of the invention it is intended that the present invention cover the modifications and the modifications of the invention

Abstract

The present invention discloses a method, device and system for transferring and checking data files. The main content includes: with the present invention, after dividing a data file into multiple data segments and calculating the respective Cyclic Redundancy Check (CRC) value for each data segment, a source device performs transmission for each data segment and the CRC value of the data segment respectively, thus enabling a target device which receives the data segments and CRC values of the data segments to check each data segment, and to promptly discover, before the data file has been transferred completely, errors which occur in the course of the data file transfer.

Description

一种数据文件传输和校验的方法、 设备及系统 技术领域  Method, device and system for data file transmission and verification
本发明涉及信息与通信技术, 尤其涉及一种数据文件传输和校验的方 法、 设备及系统。 背景技术  The present invention relates to information and communication technologies, and more particularly to a method, device and system for data file transmission and verification. Background technique
为了确保通信系统的正常运行, 通信系统中的设备之间经常涉及数据 文件的传输 (包括无线传输或有线传输), 由于传输过程中网络的状态较差 或传输通道不稳定, 会造成数据文件丟包或数据文件的编解码错误等问题 , 进而可能导致传输到目标设备上的数据文件的内容出现差错。 为了避免由 于数据文件的内容出现差错, 导致目标设备利用有误的数据文件进行业务 操作失败的情况, 目标设备在接收到源设备传输的数据文件后, 需要对该 数据文件进行校验。  In order to ensure the normal operation of the communication system, the data files are often involved in the transmission (including wireless transmission or wired transmission) between the devices in the communication system. The data file is lost due to poor network status or unstable transmission channel during transmission. Problems such as codec errors in packets or data files may cause errors in the contents of data files transmitted to the target device. In order to avoid the error of the content of the data file, the target device fails to use the incorrect data file to perform the business operation failure. After receiving the data file transmitted by the source device, the target device needs to verify the data file.
目前, 目标设备对接收到的数据文件进行校验的方法是针对循环冗余 校验 ( CRC )字段的校验。 具体做法是:  Currently, the method by which the target device verifies the received data file is for the check of the Cyclic Redundancy Check (CRC) field. The specific approach is:
首先,源设备生成待传输的数据文件,针对整个数据文件计算 CRC值, 并将计算出的 CRC值写入数据文件的固定位置后传输给目标设备;  First, the source device generates a data file to be transmitted, calculates a CRC value for the entire data file, and writes the calculated CRC value to a fixed position of the data file, and then transmits the CRC value to the target device;
然后, 目标设备针对接收到的整个数据文件重新计算 CRC值, 并将目 标设备计算出的 CRC值与数据文件的固定位置写入的 CRC值比较, 从而 对接收到的数据文件的正确性进行校验。 如果比较结果为目标设备计算出 的 CRC值与数据文件的固定位置写入的 CRC值匹配, 则表示该数据文件 在传输过程中未出现差错; 否则, 表示该数据文件在传输过程中出现差错。  Then, the target device recalculates the CRC value for the received entire data file, and compares the CRC value calculated by the target device with the CRC value written by the fixed position of the data file, thereby correcting the correctness of the received data file. Test. If the comparison result is that the CRC value calculated by the target device matches the CRC value written by the fixed position of the data file, it indicates that the data file has no error during transmission; otherwise, it indicates that the data file has an error during transmission.
在上述目标设备对数据文件的校验过程中, 源设备和目标设备都是针 对整个数据文件来计算 CRC值的, 因此, 只有在目标设备完整接收数据文 件后才能校验数据文件传输的正确性, 即使在接收到的部分数据文件已出 现差错时也无法及时发现。 发明内容 In the verification process of the data file by the target device, both the source device and the target device calculate the CRC value for the entire data file, and therefore, only the target device completely receives the data file. After the device can verify the correctness of the data file transmission, even if some of the received data files have been wrong, they cannot be found in time. Summary of the invention
本发明实施例提供一种数据文件传输和校验的方法、 设备及系统, 用 以解决现有技术中不能及时发现数据文件传输过程中的错误的问题。  The embodiment of the invention provides a method, a device and a system for data file transmission and verification, which are used to solve the problem that the error in the data file transmission process cannot be found in time in the prior art.
一种数据文件传输的方法, 该方法包括:  A method of data file transmission, the method comprising:
源设备对待传输的数据文件进行分段, 得到多个数据片段;  The source device segments the data file to be transmitted to obtain a plurality of data segments;
源设备计算每个数据片段的循环冗余校验 CRC值;  The source device calculates a cyclic redundancy check CRC value for each data segment;
源设备将数据片段以及该数据片段的 CRC值传输给目标设备。  The source device transmits the data segment and the CRC value of the data segment to the target device.
其中, 在计算每个数据片段的 CRC值之后, 且将数据片段以及该数据 片段的 CRC值传输给目标设备之前, 所述方法还包括:  The method further includes: after calculating a CRC value of each data segment, and transmitting the data segment and the CRC value of the data segment to the target device, the method further includes:
源设备将每个数据片段的 CRC值置于参数片段内, 并计算置入数据片 段的 CRC值后的参数片段的 CRC值, 并将该参数片段的 CRC值置于参数 片段内;  The source device places the CRC value of each data segment into the parameter segment, and calculates a CRC value of the parameter segment after the CRC value of the data segment is placed, and places the CRC value of the parameter segment into the parameter segment;
相应地, 所述源设备将数据片段以及该数据片段的 CRC值传输给目标 设备为:  Correspondingly, the source device transmits the data segment and the CRC value of the data segment to the target device as:
源设备将所述参数片段和各数据片段传输给目标设备; 其中, 参数片 段先于数据片段传输。  The source device transmits the parameter segment and each data segment to the target device; wherein the parameter segment is transmitted before the data segment.
一种数据文件校验的方法, 所述方法包括:  A method for data file verification, the method comprising:
目标设备计算接收到的数据片段的 CRC值, 并将计算得到的数据片段 的 CRC值与接收到的数据片段的 CRC值进行比较;  The target device calculates a CRC value of the received data segment, and compares the calculated CRC value of the data segment with the CRC value of the received data segment;
若目标设备确定计算得到的数据片段的 CRC值与接收到的该数据片段 的 CRC值匹配, 则确定该数据片段校验成功; 若不匹配, 则确定该数据片 段校验失败。  If the target device determines that the calculated CRC value of the data segment matches the received CRC value of the data segment, it determines that the data segment verification is successful; if not, determines that the data segment verification fails.
其中, 目标设备计算接收到的数据片段的 CRC值之前, 所述方法还包 括: Wherein, before the target device calculates the CRC value of the received data segment, the method further includes Includes:
目标设备计算接收到的参数片段的 CRC值, 在确定计算得到的参数片 段的 CRC值与该参数片段中携带的参数片段的 CRC值匹配时, 确定所述 参数片段校验成功;  The target device calculates a CRC value of the received parameter segment, and determines that the parameter segment is successfully verified when it is determined that the calculated CRC value of the parameter segment matches the CRC value of the parameter segment carried in the parameter segment;
目标设备确定所述参数片段中携带的各数据片段的 CRC值。  The target device determines a CRC value for each data segment carried in the parameter segment.
进一步地, 在确定该数据片段校验失败后, 所述方法还包括: 目标设备请求源设备重新传输校验失败的数据片段。  Further, after determining that the data segment verification fails, the method further includes: the target device requests the source device to retransmit the data segment that fails the verification.
一种数据文件传输的设备, 该设备包括:  A device for data file transmission, the device comprising:
分段模块, 用于对数据文件进行分段, 得到多个数据片段;  a segmentation module, configured to segment the data file to obtain a plurality of data segments;
第一 CRC值计算模块, 用于计算每个数据片段的循环冗余校验 CRC 值;  a first CRC value calculation module, configured to calculate a cyclic redundancy check CRC value of each data segment;
传输模块, 用于传输数据片段以及该数据片段的 CRC值。  A transmission module, configured to transmit a data segment and a CRC value of the data segment.
其中, 所述分段模块, 还用于生成参数片段;  The segmentation module is further configured to generate a parameter segment;
所述第一 CRC值计算模块, 还用于计算置入数据片段的 CRC值后的 参数片段的 CRC值;  The first CRC value calculation module is further configured to calculate a CRC value of a parameter segment after the CRC value of the data segment is placed;
相应地, 所述设备还包括:  Correspondingly, the device further includes:
信息置入模块, 用于将每个数据片段的 CRC值置于参数片段内, 并将 该参数片段的 CRC值置于参数片段内;  An information placing module, configured to: put a CRC value of each data segment into the parameter segment, and place a CRC value of the parameter segment into the parameter segment;
所述传输模块, 还用于传输参数片段; 其中, 参数片段先于数据片段 传输。  The transmission module is further configured to transmit a parameter segment; wherein the parameter segment is transmitted before the data segment.
一种数据文件校验的设备, 该设备包括:  A device for verifying data files, the device comprising:
接收模块, 用于接收数据片段以及该数据片段的 CRC值;  a receiving module, configured to receive a data segment and a CRC value of the data segment;
第二 CRC值计算模块, 用于计算接收到的数据片段的 CRC值; 校验模块, 用于将第二 CRC值计算模块计算得到的数据片段的 CRC 值与接收到的数据片段的 CRC值进行比较,若计算得到的数据片段的 CRC 值与接收到的该数据片段的 CRC值匹配时, 则确定该数据片段校验成功; 不匹配时, 确定该数据片段校验失败。 a second CRC value calculation module, configured to calculate a CRC value of the received data segment; a verification module, configured to perform a CRC value of the data segment calculated by the second CRC value calculation module and a CRC value of the received data segment Compare, if calculated CRC of the data segment When the value matches the received CRC value of the data segment, it is determined that the data segment is successfully verified; when there is no match, it is determined that the data segment verification fails.
进一步地,所述接收模块,还用于接收参数片段以及该参数片段的 CRC 值;  Further, the receiving module is further configured to receive a parameter segment and a CRC value of the parameter segment;
所述第二 CRC值计算模块, 还用于计算接收到的参数片段的 CRC值; 所述校验模块, 还用于在确定计算得到的参数片段的 CRC值与该参数 片段中携带的参数片段的 CRC值匹配时, 确定所述参数片段校验成功。  The second CRC value calculation module is further configured to calculate a CRC value of the received parameter segment; the verification module is further configured to determine a CRC value of the calculated parameter segment and a parameter segment carried in the parameter segment When the CRC values match, it is determined that the parameter segment verification is successful.
所述设备还包括:  The device further includes:
信息确定模块,用于确定所述参数片段中携带的各数据片段的 CRC值。 进一步地, 所述校验模块, 还用于在确定该数据片段校验失败后, 请 求重新传输校验失败的数据片段。  And an information determining module, configured to determine a CRC value of each data segment carried in the parameter segment. Further, the verification module is further configured to request, after determining that the data segment verification fails, to retransmit the data segment that fails the verification.
一种数据文件校验系统, 所述系统包括源设备和目标设备; 其中, 源设备, 用于对数据文件进行分段, 得到多个数据片段, 计算每个数 据片段的循环冗余校验 CRC值, 并将数据片段以及该数据片段的 CRC值 传输给目标设备;  A data file verification system, the system includes a source device and a target device; wherein, the source device is configured to segment the data file, obtain a plurality of data segments, and calculate a cyclic redundancy check CRC of each data segment. a value, and transmitting the data segment and the CRC value of the data segment to the target device;
目标设备, 用于计算接收到的数据片段的 CRC值, 并将计算得到的数 据片段的 CRC值与接收到的数据片段的 CRC值进行比较, 若确定计算得 到的数据片段的 CRC值与接收到的该数据片段的 CRC值匹配时, 确定该 数据片段校验成功; 不匹配时, 确定该数据片段校验失败。  a target device, configured to calculate a CRC value of the received data segment, and compare the calculated CRC value of the data segment with a CRC value of the received data segment, if the CRC value of the calculated data segment is determined and received When the CRC value of the data segment matches, it is determined that the data segment is successfully verified; when there is no match, it is determined that the data segment verification fails.
本发明由源设备将数据文件分为多个数据片段, 并计算每个数据片段 的 CRC值后, 对每个数据片段和数据片段的 CRC值分别进行传输, 使得 接收到数据片段和数据片段的 CRC值的目标设备可以针对每个数据片段进 行校验, 使目标设备可以在数据文件还未完全传输时及时发现数据文件传 输过程中出现的错误。 附图说明 The invention divides the data file into a plurality of data segments by the source device, and after calculating the CRC value of each data segment, respectively transmits the CRC values of each data segment and the data segment, so that the data segment and the data segment are received. The target device of the CRC value can be verified for each data segment, so that the target device can timely discover errors occurring during the data file transmission when the data file has not been completely transmitted. DRAWINGS
图 1为本发明实施例一数据文件传输的方法的实现流程示意图; 图 2 ( a )为本发明实施例一数据文件示意图;  1 is a schematic flowchart of an implementation of a method for data file transmission according to an embodiment of the present invention; and FIG. 2(a) is a schematic diagram of a data file according to an embodiment of the present invention;
图 2 ( b )和图 2 ( c )为本发明实施例一中基于不同分段方法的分段后 的数据片段示意图;  2(b) and 2(c) are schematic diagrams of segmented data segments based on different segmentation methods in the first embodiment of the present invention;
图 3为本发明实施例二数据文件校验的方法的实现流程示意图; 图 4为本发明实施例四数据文件传输设备的结构示意图;  3 is a schematic flowchart of a method for verifying a data file according to Embodiment 2 of the present invention; FIG. 4 is a schematic structural diagram of a data file transmission device according to Embodiment 4 of the present invention;
图 5为本发明实施例五数据文件校验设备的结构示意图;  5 is a schematic structural diagram of a data file verification device according to Embodiment 5 of the present invention;
图 6为本发明实施例六数据文件校验系统的结构示意图。 具体实施方式  FIG. 6 is a schematic structural diagram of a data file verification system according to Embodiment 6 of the present invention. detailed description
为了实现本发明目的, 本发明实施例提出将数据文件进行分段, 在源 设备侧分别针对每个数据片段计算 CRC值, 并将数据片段以及该数据片段 的 CRC值都发送给目标设备, 而在目标设备侧, 目标设备在接收到数据片 段后, 再次计算数据片段的 CRC值, 然后将目标设备针对某一数据片段计 算的 CRC值和源设备发送的该数据片段的 CRC值进行匹配, 进而确定该 数据片段的校验是否成功。 在本发明方式下, 目标设备可以在接收到部分 数据文件时就对接收到的数据文件的正确性进行校验, 在部分数据文件发 送错误时能够及时发现, 提高了数据文件传输的正确率。  In order to achieve the object of the present invention, an embodiment of the present invention proposes to segment a data file, calculate a CRC value for each data segment on the source device side, and send the data segment and the CRC value of the data segment to the target device. On the target device side, after receiving the data segment, the target device calculates the CRC value of the data segment again, and then matches the CRC value calculated by the target device for a certain data segment with the CRC value of the data segment sent by the source device, and further Determine if the verification of the data segment is successful. In the mode of the present invention, the target device can verify the correctness of the received data file when receiving part of the data file, and can timely discover when the partial data file sends an error, thereby improving the correct rate of data file transmission.
下面结合说明书附图对本发明的实施例进行详细说明。  The embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
实施例一:  Embodiment 1:
如图 1 所示, 为本发明实施例一提供的一种数据文件传输的方法, 具 体步骤为:  As shown in FIG. 1, a method for data file transmission according to Embodiment 1 of the present invention, the specific steps are as follows:
步骤 101 : 源设备对数据文件进行分段。  Step 101: The source device segments the data file.
在本步骤中, 源设备可以按照预先设定的数据片段数量以及各数据片 段的长度对数据文件进行分段。 包括但不限于以下两种分段方法。 方法一: In this step, the source device may segment the data file according to the preset number of data segments and the length of each data segment. This includes but is not limited to the following two segmentation methods. method one:
设定一个片段长度, 根据设定的片段长度将数据文件平均划分为多个 数据片段, 如果数据文件长度无法完全平均划分, 则最后一个数据片段的 长度可以小于设定的片段长度。 例如, 如图 2 ( a ) 所示, 为一个长度为 0x00012000的数据文件, 图 2 ( a ) 中只显示了数据文件开始的 32个字节 内容和结尾的 32个字节内容。 设定片段长度为 0x4000, 则如图 2 ( b ) 所 示,整个数据文件划分为 5个数据片段,前面 4个数据片段的长度为 0x4000, 最后一个数据片段未写满, 只有长度为 0x2000的部分写入了内容。  Set a segment length to divide the data file into multiple data segments according to the set segment length. If the data file length cannot be completely evenly divided, the length of the last data segment can be smaller than the set segment length. For example, as shown in Figure 2 (a), for a data file of length 0x00012000, only the 32-byte content at the beginning of the data file and the 32-byte content at the end are shown in Figure 2 (a). Set the segment length to 0x4000, as shown in Figure 2 (b), the entire data file is divided into 5 data segments, the length of the first 4 data segments is 0x4000, the last data segment is not full, only the length is 0x2000 Partially written content.
方法二:  Method Two:
将数据文件划分为多个长度不完全相同的数据片段, 例如, 数据文件 在划分前仍如图 2 ( a )所示, 长度为 0x00012000, 将数据文件划分为如图 2 ( c )所示的 4个数据片段,每个数据片段长度依次分别为 0x2000, 0x6000, 0x7000, 0x3000。  Divide the data file into multiple pieces of data of different lengths. For example, the data file is still as shown in Figure 2 (a) before the division, and the length is 0x00012000. The data file is divided into the data file as shown in Figure 2 (c). 4 data segments, each of which has a length of 0x2000, 0x6000, 0x7000, 0x3000, respectively.
用上述任一方式对数据文件进行分段得到数据片段后, 需要对各数据 片段依次分配片段标识。 为叙述方便, 对各数据片段依次分配标识为 1 , 2 n。  After segmenting the data file in any of the above ways to obtain the data segment, it is necessary to sequentially assign the segment identifier to each data segment. For the convenience of description, the data segments are sequentially assigned identifiers 1 and 2 n.
步骤 102: 源设备计算每个数据片段的循环冗余校验 CRC值。  Step 102: The source device calculates a cyclic redundancy check CRC value for each data segment.
源设备将数据文件划分为多个数据片段后, 利用循环冗余校验方法, 计算各数据片段的 CRC值。  After the source device divides the data file into multiple data segments, the cyclic redundancy check method is used to calculate the CRC value of each data segment.
在源设备计算出每个数据片段的 CRC值后, 本发明实施例一提供但不 限于以下三种保存各数据片段的 CRC值的方法:  After the source device calculates the CRC value of each data segment, the first embodiment of the present invention provides, but is not limited to, the following three methods for storing the CRC value of each data segment:
方法一: 将 CRC值保存在各数据片段的固定位置。  Method 1: Save the CRC value at a fixed position in each data segment.
源设备将计算出的各数据片段的 CRC值保存在相应数据片段的固定位 置。 进一步的, 可以在非最后一个数据片段内容的结尾加上片段结束符, 在最后一个数据片段内容的结尾加上一个文件结束符, 以便于目标设备能 够正确判断数据片段及数据文件的传输是否完成。 The source device saves the calculated CRC value of each data segment at a fixed position of the corresponding data segment. Further, a fragment terminator may be added at the end of the content of the non-last data segment, and a file terminator may be added at the end of the content of the last data segment, so that the target device can It is enough to correctly judge whether the transmission of data fragments and data files is completed.
方法二: 将 CRC值保存在参数片段中。  Method 2: Save the CRC value in the parameter fragment.
在本方法中, 源设备在数据文件的数据头部增加一个参数片段, 为该 片段分配片段标识, 为叙述方便, 为该片段分配标识 0, 片段 0的长度可以 是根据实际的数据传输需求来设定的, 只要片段 0 的长度大于或等于需要 携带的内容所需的空间即可。  In the method, the source device adds a parameter segment to the data header of the data file, and allocates a segment identifier for the segment. For convenience of description, the segment is assigned an identifier of 0, and the length of the segment 0 may be based on actual data transmission requirements. Set as long as the length of segment 0 is greater than or equal to the space required for the content to be carried.
源设备将计算出的各数据片段的 CRC值写入片段 0。 为了使目标设备 能够从片段 0中正确识别各数据片段的 CRC值, 在片段 0中写入 CRC值 的同时, 还记录每个 CRC值对应的数据片段; 或者, 在片段 0中开辟专用 于存储数据片段的 CRC值的区域, 按照数据片段的标识由小到大(或由大 到小)的顺序, 依次写入数据片段的 CRC值, 使得目标设备根据接收到的 数据片段的顺序以及读取的 CRC值的顺序,能够正确识别数据片段和 CRC 值的关系。  The source device writes the calculated CRC value of each data segment into segment 0. In order to enable the target device to correctly identify the CRC value of each data segment from the segment 0, the CRC value is written in the segment 0, and the data segment corresponding to each CRC value is also recorded; or, in segment 0, dedicated to storage The area of the CRC value of the data segment is sequentially written into the CRC value of the data segment according to the order of the identification of the data segment from small to large (or large to small), so that the target device reads and reads according to the order of the received data segment. The order of the CRC values correctly identifies the relationship between the data segment and the CRC value.
进一步的, 还可以将原始文件总长度、 各数据片段的长度以及参数片 段的长度写入片段 0 的相应位置。 上述三个参数可用于后续目标设备判断 数据文件、 某个数据片段或参数片段的传输是否完成。  Further, the total length of the original file, the length of each data segment, and the length of the parameter fragment can also be written to the corresponding position of the segment 0. The above three parameters can be used by the subsequent target device to determine whether the transmission of the data file, a certain data segment or the parameter segment is completed.
在上述需要保存在片段 0 的各项内容写入完成后, 源设备计算片段 0 的 CRC值, 并将计算得到的参数片段的 CRC值写入片段 0的固定位置, 方法三: 将 CRC值保存在请求消息中。  After the above contents of the segment 0 need to be written, the source device calculates the CRC value of the segment 0, and writes the calculated CRC value of the parameter segment to the fixed position of the segment 0. Method 3: Save the CRC value In the request message.
源设备生成一条请求消息, 将计算出的各数据片段的 CRC值保存在请 求消息的固定位置中。  The source device generates a request message, and stores the calculated CRC value of each data segment in a fixed location of the request message.
进一步的, 可以将数据文件总长度以及各数据片段的长度写入请求消 息的相应位置。 上述两个参数可用于后续目标设备判断数据文件或某个数 据片段的传输是否完成, 以决定下一步的操作。 步骤 103: 源设备将数据片段以及该数据片段的 CRC值传输给目标设 备。 Further, the total length of the data file and the length of each data segment can be written to the corresponding location of the request message. The above two parameters can be used by the subsequent target device to determine whether the data file or the transmission of a certain data segment is completed, to determine the next operation. Step 103: The source device transmits the data segment and the CRC value of the data segment to the target device.
针对步骤 102中三种保存 CRC值的方法, 本步骤中也提供以下三种传 传输模式一:  For the three methods for saving the CRC value in step 102, the following three transmission modes are also provided in this step:
如果源设备将 CRC值保存在各数据片段的固定位置, 则本步骤中, 源 设备将各数据片段直接传输到目标设备。  If the source device saves the CRC value at a fixed location of each data segment, in this step, the source device directly transmits each data segment to the target device.
传输模式二:  Transmission mode two:
如果源设备将 CRC值保存在额外设置的参数片段中, 则本步骤中, 由 设备按照参数片段先于数据片段传输的条件, 将所述参数片段和各数据片 段传输给目标设备。 较优地, 可以在源设备接收到目标设备返回的参数片 段传输成功的响应消息后, 再继续传输数据片段。  If the source device saves the CRC value in the parameter segment of the additional setting, in this step, the device transmits the parameter segment and each data segment to the target device according to the condition that the parameter segment is transmitted before the data segment. Preferably, after the source device receives the response message that the parameter segment is successfully transmitted by the target device, the data segment may continue to be transmitted.
传输模式三:  Transmission mode three:
如果源设备将 CRC值保存在请求消息中, 由于请求消息的内容提供了 目标设备后续对数据片段的操作依据, 因此, 源设备首先向目标设备传输 请求消息, 并在请求消息传输成功后, 再继续传输数据片段。  If the source device saves the CRC value in the request message, since the content of the request message provides the basis for the subsequent operation of the data segment by the target device, the source device first transmits the request message to the target device, and after the request message is successfully transmitted, Continue to transfer the data fragments.
通过本发明实施例一的方案, 源设备通过多种方式将数据片段以及每 个数据片段的 CRC值发送给目标设备, 由于数据文件已分片, 因此, 目标 设备可以针对长度较短的数据片段进行数据的接收、 校验, 提高了数据文 件传输的正确率。  With the solution of the first embodiment of the present invention, the source device sends the data segment and the CRC value of each data segment to the target device in multiple manners. Since the data file is fragmented, the target device can target the data segment with a shorter length. Receiving and verifying data improves the accuracy of data file transmission.
实施例二:  Embodiment 2:
本发明实施例二在实施例一的传输数据文件的基础上, 提供一种数据 文件校验的方法, 如图 3所示, 包括以下步骤:  The second embodiment of the present invention provides a data file verification method based on the data file of the first embodiment. As shown in FIG. 3, the method includes the following steps:
步骤 201 : 目标设备在接收到数据片段后, 计算该数据片段的 CRC值。 在本步骤中, 目标设备和源设备釆用相同的算法计算数据片段的 CRC 值。 Step 201: After receiving the data segment, the target device calculates a CRC value of the data segment. In this step, the target device and the source device calculate the CRC value of the data segment using the same algorithm.
步骤 202: 目标设备将自身计算的 CRC值与源设备发送的该数据片段 的 CRC值进行比较; 若比较结果为 CRC值匹配, 则执行步骤 203; 否则, 执行步骤 204。  Step 202: The target device compares the CRC value calculated by itself with the CRC value of the data segment sent by the source device. If the comparison result is that the CRC value matches, step 203 is performed; otherwise, step 204 is performed.
步骤 203: 目标设备确定该数据片段校验成功。  Step 203: The target device determines that the data segment is successfully verified.
步骤 204: 目标设备确定该数据片段校验失败。  Step 204: The target device determines that the data segment verification fails.
考虑到实施例一中源设备向目标设备传输数据片段的传输模式至少有 三种, 因此, 在本实施例二的方案中, 目标设备接收数据片段, 并对数据 片段进行校验的方式也可以包括以下三种:  In the solution of the second embodiment, the manner in which the target device receives the data segment and the data segment is verified may also include the foregoing, in the solution of the second embodiment, the manner in which the source device receives the data segment. The following three:
校验模式一:  Calibration mode one:
如果源设备按照步骤 103 中的传输模式一向目标设备发送数据片段和 数据片段的 CRC值, 则目标设备接收源设备直接传输的数据片段后, 首先 通过各数据片段的片段结束符 /文件结束符判断对数据片段 /数据文件的接 收是否完成, 并对接收完成的数据片段进行校验。 其校验方式为: 目标设 备每接收完成一个数据片段时, 计算该数据片段的 CRC值, 并与保存在该 片段中固定位置的 CRC值进行比较, 如果两个 CRC值不匹配, 该数据片 段的校验失败, 目标设备请求源设备重传校验失败的数据片段; 否则, 该 数据片段的校验成功, 目标设备继续接收并校验其他数据片段。 直到根据 文件结束符判断出整个数据文件的传输完成, 且各片段均校验成功时, 目 标设备再对每个数据片段进行整合, 得到源设备传输的数据文件。  If the source device sends the CRC value of the data segment and the data segment to the target device according to the transmission mode in step 103, after the target device receives the data segment directly transmitted by the source device, first, the segment end character/file terminator of each data segment is determined. Whether the reception of the data segment/data file is completed, and the received data segment is verified. The verification mode is: when the target device receives a data segment, the CRC value of the data segment is calculated, and compared with the CRC value stored in the fixed position in the segment, if the two CRC values do not match, the data segment The verification fails, and the target device requests the source device to retransmit the data segment that failed the verification; otherwise, the verification of the data segment is successful, and the target device continues to receive and verify other data segments. Until the transmission of the entire data file is completed according to the end of the file, and each segment is successfully verified, the target device integrates each data segment to obtain the data file transmitted by the source device.
校验模式二:  Check mode 2:
如果源设备按照步骤 103 中的传输模式二向目标设备发送数据片段和 数据片段的 CRC值, 则目标设备首先接收参数片段, 并通过参数片段中提 供的参数片段的长度判断参数片段是否传输完成, 在判断接收完整个参数 片段后, 计算接收到的参数片段的 CRC值, 并与保存在参数片段中固定位 置的 CRC值进行比较, 如果两个 CRC值不匹配, 参数片段的校验失败, 请求源设备重传参数片段, 否则, 参数片段的校验成功, 目标设备从参数 片段中提取携带的各数据片段的 CRC值, 并利用提取的 CRC值校验数据 片段。 If the source device sends the CRC value of the data segment and the data segment to the target device according to the transmission mode in step 103, the target device first receives the parameter segment, and determines whether the parameter segment is transmitted through the length of the parameter segment provided in the parameter segment. In the judgment of receiving the complete parameters After the segment, the CRC value of the received parameter segment is calculated and compared with the CRC value stored in the fixed position of the parameter segment. If the two CRC values do not match, the verification of the parameter segment fails, and the source device is requested to retransmit the parameter segment. Otherwise, the verification of the parameter segment is successful, the target device extracts the CRC value of each data segment carried from the parameter segment, and verifies the data segment by using the extracted CRC value.
目标设备可以按照单线程或多线程的方式对接收到的数据片段进行校 验。  The target device can verify the received data segments in a single-threaded or multi-threaded manner.
在单线程校验方式下, 目标设备在参数片段校验成功后, 再接收第一 个数据片段, 并根据参数片段中各数据片段的长度判断第一个数据片段的 传输是否完成, 在判断接收到完整的第一个数据片段后, 计算该第一个数 据片段的 CRC值, 并与保存在参数片段中该第一个数据片段的 CRC值进 行比较, 如果两个 CRC值不匹配, 该数据片段的校验失败, 目标设备请求 源设备重传校验失败的数据片段; 否则, 该数据片段的校验成功, 继续接 收第二个数据片段, 并按照上述方式对第二个数据片段进行校验, 直到根 据参数片段中的原始文件总长度判断出整个数据文件已传输完成, 且各数 据片段均校验成功, 目标设备对整个数据文件的校验完成。  In the single-thread check mode, after the target segment is successfully verified, the target device receives the first data segment, and determines whether the transmission of the first data segment is completed according to the length of each data segment in the parameter segment. After the complete first data segment, the CRC value of the first data segment is calculated and compared with the CRC value of the first data segment stored in the parameter segment. If the two CRC values do not match, the data If the verification of the fragment fails, the target device requests the source device to retransmit the data fragment that failed the verification; otherwise, the verification of the data segment succeeds, the second data segment continues to be received, and the second data segment is verified as described above. After checking, according to the total length of the original file in the parameter segment, it is judged that the entire data file has been transmitted, and each data segment is verified successfully, and the verification of the entire data file by the target device is completed.
需要说明的是, 在单线程校验方式下, 目标设备可以每次只接收一个 数据片段, 并在该数据片段校验成功时再接收下一个数据片段; 目标设备 也可以每次只接收 N ( N为大于 1的正整数)个数据片段, 并在该 N个数 据片段全部都校验成功时再接收之后的 N个数据片段; 如果 N个数据片段 中有至少一个数据片段未校验成功, 则目标设备将请求源设备重传校验失 败的数据片段, 直至 N个数据片段全部校验成功。  It should be noted that, in the single-thread check mode, the target device can receive only one data segment at a time, and receive the next data segment when the data segment is successfully verified; the target device can also receive only N at a time ( N is a positive integer of more than 1 data segment, and then receives the following N data segments when all of the N data segments are successfully verified; if at least one of the N data segments is not verified successfully, Then, the target device will request the source device to retransmit the data segment whose verification fails, until all the N data segments are successfully verified.
在多线程校验方式下, 目标设备在参数片段校验成功后, 目标设备在 对接收完全的数据片段进行校验的同时, 如果当前还有未接收完全的数据 片段, 则目标设备将一边进行数据片段校验一边接收其他的数据片段。 在 当前进行校验的至少一个数据片段都校验成功时, 继续从已接收到的数据 片段中确定还未进行数据校验的数据片段, 并计算继续确定的数据片段的In the multi-thread verification mode, after the target device successfully verifies the parameter segment, the target device checks the received complete data segment, and if there is still not received the complete data segment, the target device will perform the same. The data segment is verified while receiving other pieces of data. In When at least one data segment currently being verified is verified to be successful, the data segment that has not been subjected to data verification is continuously determined from the received data segments, and the data segment that continues to be determined is calculated.
CRC值, 以及对继续确定的数据片段进行校验; 否则, 请求源设备重传校 验失败的数据片段。 The CRC value, and the data segment that continues to be determined; otherwise, the source device is requested to retransmit the data segment that failed the verification.
校验模式三:  Check mode three:
如果源设备按照步骤 103 中的传输模式三向目标设备发送数据片段和 数据片段的 CRC值, 则目标设备首先接收请求消息, 从请求消息中提取出 各数据片段的 CRC值以及原始文件总长度、 各数据片段的长度等信息。  If the source device sends the CRC value of the data segment and the data segment to the target device according to the transmission mode in step 103, the target device first receives the request message, and extracts the CRC value of each data segment and the total length of the original file from the request message. Information such as the length of each data segment.
目标设备接收数据片段后, 根据请求消息中携带的各数据片段的长度 判断该数据片段的传输是否完成, 在判断接收到完整的数据片段后, 计算 接收到的数据片段的 CRC值, 并与请求消息中携带的该数据片段的 CRC 值进行比较, 如果两个 CRC值不匹配, 该数据片段的校验失败, 目标设备 将请求源设备重传校验失败的数据片段; 否则, 该数据片段的校验成功, 继续校验其他数据片段, 直到根据请求消息中的数据文件总长度判断出整 个数据文件的传输完成, 且各数据片段均校验成功, 目标设备对整个数据 文件的校验完成。  After receiving the data segment, the target device determines whether the transmission of the data segment is completed according to the length of each data segment carried in the request message, and after determining that the complete data segment is received, calculates the CRC value of the received data segment, and requests The CRC value of the data segment carried in the message is compared. If the two CRC values do not match, the verification of the data segment fails, and the target device requests the source device to retransmit the data segment that failed the verification; otherwise, the data segment The verification succeeds, and the other data segments are continuously verified until the transmission of the entire data file is completed according to the total length of the data file in the request message, and each data segment is verified successfully, and the verification of the entire data file by the target device is completed.
实施例三:  Embodiment 3:
本发明实施例三通过具体的实例对实施例一和实施例二的方案进行说 明。  The third embodiment of the present invention describes the solutions of the first embodiment and the second embodiment by using specific examples.
仍以传输图 2 ( a )所示的数据文件为例, 本实施例三中源设备向目标 设备发送数据文件以及目标设备对接收到的数据文件进行校验的方法包 括:  For example, in the data file shown in FIG. 2 (a), the method in which the source device sends the data file to the target device and the target device checks the received data file includes:
第一步、 设定分段长度为 0x4000, 按照该片段长度对数据文件进行分 段,由于数据文件总长度是 0x00012000, 所以可以将数据文件分成 5个数据 片段, 各数据片段依次编号为 1 , 2......5 , 最后一个数据片段不足 0x4000 大小, 分段结果如图 2 ( b ) 所示。 In the first step, the segment length is set to 0x4000, and the data file is segmented according to the length of the segment. Since the total length of the data file is 0x00012000, the data file can be divided into five data segments, and each data segment is sequentially numbered as 1. 2...5 , the last data fragment is less than 0x4000 The size and segmentation results are shown in Figure 2 (b).
第二步、 在数据文件头部增加一个 0x4000大小的参数片段, 该参数片 段编号为 0。在本实施例中,可以将增加参数片段后的数据文件称为新文件, 未增加参数片段时的数据文件称为原始文件。 由于在增加参数片段之前, 数据文件的总大小 0x00012000, 因此, 原始文件内容在新文件内的偏移位 置是 0x4000, 除最后一个数据片段外, 每个数据片段的大小是 0x4000。  In the second step, a parameter fragment of size 0x4000 is added to the head of the data file, and the parameter fragment number is 0. In this embodiment, the data file after the parameter fragment is added may be referred to as a new file, and the data file when the parameter fragment is not added may be referred to as an original file. Since the total size of the data file is 0x00012000 before the parameter fragment is added, the offset of the original file content in the new file is 0x4000, and the size of each data segment is 0x4000 except for the last data segment.
第三步、 对文件的第 1至第 5个数据片段分别计算 CRC值, 得到第 1 至第 5个数据片段对应的 CRC1、 CRC2、 CRC3、 CRC4、 CRC5 , 并将得到 的 CRC值分别写入片段 0中相应的位置。  In the third step, the CRC values are respectively calculated for the first to fifth data segments of the file, and CRC1, CRC2, CRC3, CRC4, and CRC5 corresponding to the first to fifth data segments are obtained, and the obtained CRC values are respectively written. The corresponding position in fragment 0.
第四步、 将所述数据文件的总长度、 各数据片段的长度以及所述参数 片段的长度置于所述参数片段内的相应位置。  In a fourth step, the total length of the data file, the length of each data segment, and the length of the parameter segment are placed at corresponding positions within the parameter segment.
第五步、 计算增加了各项信息后的片段 0的 CRC, 并写入片段 0的固 定位置。  In the fifth step, the CRC of the segment 0 after the information is added is calculated, and the fixed position of the segment 0 is written.
第六步、 将新文件的片段 0传输到目标设备。  In the sixth step, the fragment 0 of the new file is transmitted to the target device.
第七步、 目标设备依据参数片段的长度完整接收片段 0后, 对片段 0 进行校验。  In the seventh step, after the target device completely receives the segment 0 according to the length of the parameter segment, the segment 0 is verified.
目标设备计算片段 0的 CRC值, 并与片段 0中固定位置保存的该片段 0的 CRC值进行比较, 如果比较结果不一致, 则校验不通过, 目标设备将 请求重新下载片段 0, 返回到第六步; 如果比较结果一致, 校验通过, 表示 片段 0的传输成功, 执行第八步。  The target device calculates the CRC value of the segment 0 and compares it with the CRC value of the segment 0 stored in the fixed position in the segment 0. If the comparison result is inconsistent, the verification fails, and the target device requests to re-download the segment 0, returning to the first Six steps; If the comparison result is consistent, the verification passes, indicating that the transmission of segment 0 is successful, and the eighth step is performed.
第八步、 源设备将一个数据片段传输到目标设备。  In the eighth step, the source device transmits a data segment to the target device.
第九步、 目标设备根据数据片段的长度完整接收到该数据片段后, 计 算出该片段的 CRC值,并把计算结果与片段 0内写入的该数据片段的 CRC 值作比较, 如果两个 CRC值一致, 表示该数据片段传输成功, 跳转至第十 步; 如果判断出 CRC值不一致, 则请求重新下载该数据片段, 并在重新下 载的数据片段校验成功时, 跳转至第十步。 In the ninth step, after the target device completely receives the data segment according to the length of the data segment, the CRC value of the segment is calculated, and the calculation result is compared with the CRC value of the data segment written in the segment 0, if two The CRC value is consistent, indicating that the data segment is successfully transmitted, and jumps to the tenth step; if it is determined that the CRC value is inconsistent, the request to re-download the data segment is performed again. When the data segment verification is successful, jump to the tenth step.
第十步、 目标设备根据数据文件的总长度和数据片段的长度判断当前 是否已完整接收数据文件, 若是, 则将已接收到且校验成功的数据片段整 合为数据文件, 并结束数据文件传输以及校验的操作; 否则, 跳转至第八 步。  Step 10: The target device determines whether the data file has been completely received according to the total length of the data file and the length of the data segment, and if so, integrates the data segment that has been received and verified successfully into a data file, and ends the data file transmission. And the operation of the check; otherwise, jump to the eighth step.
重复第八步至第十步, 在所有数据片段都传输和校验成功后, 表示整 个文件传输成功。  Repeat steps 8 through 10, after all data segments have been transmitted and verified successfully, indicating that the entire file was successfully transferred.
通过本发明方案, 将数据文件分为多个数据片段进行传输, 由目标设 能够有效提高传输的正确率; 同时, 目标设备在发现某一个或多个数据片 段传输错误时, 只需要请求源设备将发生传输错误的数据片段重新传输, 减少了重传时需要占用的通道资源以及传输时间, 提高了数据文件的传输 效率。  Through the solution of the invention, the data file is divided into a plurality of data segments for transmission, and the target setting can effectively improve the accuracy of the transmission; meanwhile, when the target device finds that one or more data segments are transmitted incorrectly, only the source device needs to be requested. The data segment in which the transmission error occurs is retransmitted, which reduces the channel resources and transmission time required for retransmission, and improves the transmission efficiency of the data file.
实施例四:  Embodiment 4:
本发明实施例四提供一种数据文件传输设备, 如图 4所示, 该设备包 括分段模块 11、 第一 CRC值计算模块 12和传输模块 13 , 其中:  A fourth embodiment of the present invention provides a data file transmission device. As shown in FIG. 4, the device includes a segmentation module 11, a first CRC value calculation module 12, and a transmission module 13, where:
分段模块 11用于对数据文件进行分段, 得到多个数据片段; 第一 CRC 值计算模块 12用于计算每个数据片段的循环冗余校验 CRC值; 传输模块 13用于传输数据片段以及该数据片段的 CRC值。  The segmentation module 11 is configured to segment the data file to obtain a plurality of data segments; the first CRC value calculation module 12 is configured to calculate a cyclic redundancy check CRC value of each data segment; and the transmission module 13 is configured to transmit the data segment. And the CRC value of the data segment.
所述分段模块 11还用于生成参数片段; 所述第一 CRC值计算模块 12 还用于计算置入数据片段的 CRC值后的参数片段的 CRC值; 所述传输模 块 13还用于传输参数片段, 其中, 参数片段先于数据片段传输。  The segmentation module 11 is further configured to generate a parameter segment; the first CRC value calculation module 12 is further configured to calculate a CRC value of a parameter segment after the CRC value of the data segment is placed; the transmission module 13 is further configured to transmit A parameter fragment, where the parameter fragment is transmitted before the data fragment.
所述设备还包括: 信息置入模块 14, 用于将每个数据片段的 CRC值置 于参数片段内, 以及将该参数片段的 CRC置于参数片段内; 进一步地, 所 述信息置入模块 14还用于将所述数据文件的总长度、 各数据片段的长度以 及所述参数片段的长度置于所述参数片段内。 The device further includes: an information placing module 14 configured to: place a CRC value of each data segment into the parameter segment, and place the CRC of the parameter segment into the parameter segment; further, the information is placed into the module 14 is also used to set the total length of the data file and the length of each data segment. And the length of the parameter segment is placed in the parameter segment.
实施例五:  Embodiment 5:
本发明实施例五提供一种数据文件校验设备, 如图 5 所示, 该设备包 括接收模块 21、 第二 CRC值计算模块 22和校验模块 23 , 其中:  A fifth embodiment of the present invention provides a data file verification device. As shown in FIG. 5, the device includes a receiving module 21, a second CRC value calculation module 22, and a verification module 23, where:
接收模块 21用于接收数据片段以及该数据片段的 CRC值; 第二 CRC 值计算模块 22用于计算接收到的数据片段的 CRC值; 校验模块 23用于将 第二 CRC值计算模块 22计算得到的数据片段的 CRC值与接收到的数据片 段的 CRC值进行比较, 若计算得到的数据片段的 CRC值与接收到的该数 据片段的 CRC值匹配, 则确定该数据片段校验成功; 否则, 确定该数据片 段校验失败。  The receiving module 21 is configured to receive the data segment and the CRC value of the data segment; the second CRC value calculating module 22 is configured to calculate the CRC value of the received data segment; the verifying module 23 is configured to calculate the second CRC value calculating module 22 The CRC value of the obtained data segment is compared with the CRC value of the received data segment. If the calculated CRC value of the data segment matches the received CRC value of the data segment, it is determined that the data segment is successfully verified; otherwise , to determine that the data fragment verification failed.
所述接收模块 21还用于接收参数片段以及该参数片段的 CRC值; 所 述第二 CRC值计算模块 22还用于计算接收到的参数片段的 CRC值; 所述 校验模块 23还用于在确定计算得到的参数片段的 CRC值与接收到的参数 片段的 CRC值匹配时, 确定所述参数片段校验成功。  The receiving module 21 is further configured to receive a parameter segment and a CRC value of the parameter segment; the second CRC value calculating module 22 is further configured to calculate a CRC value of the received parameter segment; the verification module 23 is further configured to: When it is determined that the calculated CRC value of the parameter segment matches the CRC value of the received parameter segment, it is determined that the parameter segment verification is successful.
所述设备还包括: 信息确定模块 24, 用于确定所述参数片段中携带的 各数据片段的 CRC值。  The device further includes: an information determining module 24, configured to determine a CRC value of each data segment carried in the parameter segment.
所述校验模块 23还用于在确定该数据片段校验失败后, 请求重传校验 失败的数据片段。  The verification module 23 is further configured to request to retransmit the data fragment that fails the verification after determining that the data segment verification fails.
所述校验模块 23 , 具体用于每接收到至少一个数据片段后, 计算所述 至少一个数据片段的 CRC值, 并将计算得到的至少一个数据片段的 CRC 值与接收到所述至少一个数据片段的 CRC值进行比较, 在确定所述至少一 个数据片段都校验成功时, 继续接收数据片段, 并计算继续接收到的数据 片段的 CRC值, 以及对继续接收到的数据片段进行校验, 否则, 请求源设 备重传校验失败的数据片段。  The check module 23 is configured to calculate a CRC value of the at least one data segment after receiving at least one data segment, and calculate a CRC value of the at least one data segment and receive the at least one data Comparing the CRC values of the segments, when determining that the at least one data segment is successfully verified, continuing to receive the data segments, calculating a CRC value of the data segment that continues to be received, and verifying the data segments that continue to be received, Otherwise, the source device is requested to retransmit the data segment that failed the verification.
所述校验模块 23 , 具体用于从已接收到的数据片段中确定至少一个数 据片段后, 计算确定的所述至少一个数据片段的 CRC值, 并将计算出的所 述至少一个数据片段的 CRC值与接收到所述至少一个数据片段的 CRC值 进行比较, 在确定所述至少一个数据片段都校验成功时, 继续从已接收到 的数据片段中确定还未进行数据校验的数据片段, 并计算继续确定的数据 片段的 CRC值, 以及对继续确定的数据片段进行校验, 否则, 请求源设备 重传校验失败的数据片段。 别实现实施例一至实施例二中数据文件传输、 数据文件校验的各种功能, 也可以集成在一个物理设备中, 集成了实施例四和实施例五的物理设备在 向其他设备传输数据文件时, 可以使用实施例四中涉及的功能模块实现数 据传输操作; 同时, 该物理设备在接收到其他设备传来的数据文件时, 可 以使用实施例五中涉及的功能模块实现校验的操作。 The verification module 23 is specifically configured to determine at least one number from the received data segments. After determining the CRC value of the determined at least one data segment, and calculating the calculated CRC value of the at least one data segment and comparing the CRC value of the at least one data segment, When at least one data segment is successfully verified, the data segment that has not been verified by the data segment is determined from the received data segment, and the CRC value of the data segment that continues to be determined is calculated, and the data segment that continues to be determined is verified. Otherwise, the source device is requested to retransmit the data fragment that failed the verification. The functions of the data file transmission and the data file verification in the first embodiment to the second embodiment may be implemented in a physical device, and the physical devices integrated in the fourth embodiment and the fifth embodiment are used to transmit data files to other devices. The data transmission operation may be implemented by using the function module involved in the fourth embodiment. At the same time, when receiving the data file transmitted by the other device, the physical device may perform the verification operation by using the function module involved in the fifth embodiment.
本发明实施例六提供一种数据文件校验系统, 如图 6所示, 该设备包 括源设备 31和目标设备 32, 其中:  A sixth embodiment of the present invention provides a data file verification system. As shown in FIG. 6, the device includes a source device 31 and a target device 32, where:
源设备 31用于对数据文件进行分段, 得到多个数据片段, 计算每个数 据片段的 CRC值, 并将数据片段以及该数据片段的 CRC值发送给目标设 备 32; 目标设备 32用于针对接收到的数据片段, 计算该数据片段的 CRC 值, 并将计算得到的数据片段的 CRC值与接收到的数据片段的 CRC值进 行比较, 若确定计算得到的数据片段的 CRC值与接收到的该数据片段的 CRC值匹配, 则确定该数据片段校验成功; 否则, 确定该数据片段校验失 败。  The source device 31 is configured to segment the data file, obtain a plurality of data segments, calculate a CRC value of each data segment, and send the data segment and the CRC value of the data segment to the target device 32; the target device 32 is configured to target Receiving the data segment, calculating a CRC value of the data segment, and comparing the calculated CRC value of the data segment with the CRC value of the received data segment, if determining the CRC value of the calculated data segment and the received If the CRC value of the data segment matches, it is determined that the data segment is successfully verified; otherwise, it is determined that the data segment verification fails.
本发明实施例六中涉及的源设备 31可以是实现实施例一至实施例三中 涉及的源设备, 且具有实施例四中涉及的各种功能模块; 目标设备 32是实 现实施例一至实施例三中涉及的目标设备, 且具有实施例五中涉及的各种 功能模块, 在此不再赘述。 本发明的精神和范围。 这样, 倘若本发明的这些修改和变型属于本发明权 利要求及其等同技术的范围之内, 则本发明也意图包含这些改动和变型在 内。 The source device 31 involved in the sixth embodiment of the present invention may be the source device involved in the implementation of the first embodiment to the third embodiment, and has various functional modules involved in the fourth embodiment. The target device 32 is implemented in the first embodiment to the third embodiment. The target device involved in the present invention has various functional modules involved in the fifth embodiment, and details are not described herein again. The spirit and scope of the invention. Thus, it is intended that the present invention cover the modifications and the modifications of the invention

Claims

权利要求书 Claim
1、 一种数据文件传输的方法, 其特征在于, 该方法包括:  A method for data file transmission, characterized in that the method comprises:
源设备对数据文件进行分段, 得到多个数据片段;  The source device segments the data file to obtain multiple pieces of data;
源设备计算每个数据片段的循环冗余校验 CRC值;  The source device calculates a cyclic redundancy check CRC value for each data segment;
源设备将数据片段以及该数据片段的 CRC值传输给目标设备。  The source device transmits the data segment and the CRC value of the data segment to the target device.
2、 如权利要求 1 所述的方法, 其特征在于, 在计算每个数据片段的 CRC值之后,且将数据片段以及该数据片段的 CRC值传输给目标设备之前, 所述方法还包括:  2. The method according to claim 1, wherein after calculating the CRC value of each data segment and transmitting the data segment and the CRC value of the data segment to the target device, the method further includes:
源设备将每个数据片段的 CRC值置于参数片段内, 并计算置入数据片 段的 CRC值后的参数片段的 CRC值, 并将该参数片段的 CRC值置于参数 片段内;  The source device places the CRC value of each data segment into the parameter segment, and calculates a CRC value of the parameter segment after the CRC value of the data segment is placed, and places the CRC value of the parameter segment into the parameter segment;
相应地, 所述源设备将数据片段以及该数据片段的 CRC值传输给目标 设备为:  Correspondingly, the source device transmits the data segment and the CRC value of the data segment to the target device as:
源设备将所述参数片段和各数据片段传输给目标设备; 其中, 参数片 段先于数据片段传输。  The source device transmits the parameter segment and each data segment to the target device; wherein the parameter segment is transmitted before the data segment.
3、 一种数据文件校验的方法, 其特征在于, 该方法包括:  3. A method for verifying data files, the method comprising:
目标设备计算接收到的数据片段的 CRC值, 并将计算得到的数据片段 的 CRC值与接收到的数据片段的 CRC值进行比较;  The target device calculates a CRC value of the received data segment, and compares the calculated CRC value of the data segment with the CRC value of the received data segment;
若目标设备确定计算得到的数据片段的 CRC值与接收到的该数据片段 的 CRC值匹配, 则确定该数据片段校验成功; 若不匹配, 则确定该数据片 段校验失败。  If the target device determines that the calculated CRC value of the data segment matches the received CRC value of the data segment, it determines that the data segment verification is successful; if not, determines that the data segment verification fails.
4、 如权利要求 3所述的方法, 其特征在于, 目标设备计算接收到的数 据片段的 CRC值之前, 所述方法还包括:  The method of claim 3, wherein before the target device calculates the CRC value of the received data segment, the method further includes:
目标设备计算接收到的参数片段的 CRC值, 在确定计算得到的参数片 段的 CRC值与该参数片段中携带的参数片段的 CRC值匹配时, 确定所述 参数片段校验成功; The target device calculates a CRC value of the received parameter segment, and determines that the CRC value of the calculated parameter segment matches the CRC value of the parameter segment carried in the parameter segment, The parameter segment verification is successful;
目标设备确定所述参数片段中携带的各数据片段的 CRC值。  The target device determines a CRC value for each data segment carried in the parameter segment.
5、 如权利要求 3所述的方法, 其特征在于, 在确定该数据片段校验失 败后, 所述方法还包括:  The method of claim 3, wherein after determining that the data segment verification fails, the method further includes:
目标设备请求源设备重新传输校验失败的数据片段。  The target device requests the source device to retransmit the data fragment that failed the verification.
6、 一种数据文件传输的设备, 其特征在于, 该设备包括:  6. A device for data file transmission, characterized in that the device comprises:
分段模块, 用于对数据文件进行分段, 得到多个数据片段;  a segmentation module, configured to segment the data file to obtain a plurality of data segments;
第一 CRC值计算模块, 用于计算每个数据片段的循环冗余校验 CRC 值;  a first CRC value calculation module, configured to calculate a cyclic redundancy check CRC value of each data segment;
传输模块, 用于传输数据片段以及该数据片段的 CRC值。  A transmission module, configured to transmit a data segment and a CRC value of the data segment.
7、 如权利要求 6所述的设备, 其特征在于,  7. Apparatus according to claim 6 wherein:
所述分段模块, 还用于生成参数片段;  The segmentation module is further configured to generate a parameter segment;
所述第一 CRC值计算模块, 还用于计算置入数据片段的 CRC值后的 参数片段的 CRC值;  The first CRC value calculation module is further configured to calculate a CRC value of a parameter segment after the CRC value of the data segment is placed;
相应地, 所述设备还包括:  Correspondingly, the device further includes:
信息置入模块, 用于将每个数据片段的 CRC值置于参数片段内, 并将 该参数片段的 CRC值置于参数片段内;  An information placing module, configured to: put a CRC value of each data segment into the parameter segment, and place a CRC value of the parameter segment into the parameter segment;
所述传输模块, 还用于传输参数片段; 其中, 参数片段先于数据片段 传输。  The transmission module is further configured to transmit a parameter segment; wherein the parameter segment is transmitted before the data segment.
8、 一种数据文件校验的设备, 其特征在于, 该设备包括:  8. A device for verifying data files, the device comprising:
接收模块, 用于接收数据片段以及该数据片段的 CRC值;  a receiving module, configured to receive a data segment and a CRC value of the data segment;
第二 CRC值计算模块, 用于计算接收到的数据片段的 CRC值; 校验模块, 用于将第二 CRC值计算模块计算得到的数据片段的 CRC 值与接收到的数据片段的 CRC值进行比较, 计算得到的数据片段的 CRC 值与接收到的该数据片段的 CRC值匹配时, 确定该数据片段校验成功; 不 匹配时, 确定该数据片段校验失败。 a second CRC value calculation module, configured to calculate a CRC value of the received data segment; a verification module, configured to perform a CRC value of the data segment calculated by the second CRC value calculation module and a CRC value of the received data segment Comparing, when the calculated CRC value of the data segment matches the received CRC value of the data segment, determining that the data segment is successfully verified; When matching, it is determined that the data segment verification failed.
9、 如权利要求 8所述的设备, 其特征在于,  9. Apparatus according to claim 8 wherein:
所述接收模块, 还用于接收参数片段以及该参数片段的 CRC值; 所述第二 CRC值计算模块, 还用于计算接收到的参数片段的 CRC值; 所述校验模块, 还用于在确定计算得到的参数片段的 CRC值与该参数 片段中携带的参数片段的 CRC值匹配时, 确定所述参数片段校验成功; 所述设备还包括:  The receiving module is further configured to receive a parameter segment and a CRC value of the parameter segment; the second CRC value calculating module is further configured to calculate a CRC value of the received parameter segment; the verification module is further used to When it is determined that the CRC value of the calculated parameter segment matches the CRC value of the parameter segment carried in the parameter segment, the parameter segment verification is determined to be successful; the device further includes:
信息确定模块,用于确定所述参数片段中携带的各数据片段的 CRC值。 And an information determining module, configured to determine a CRC value of each data segment carried in the parameter segment.
10、 如权利要求 8所述的设备, 其特征在于, 10. Apparatus according to claim 8 wherein:
所述校验模块, 还用于在确定该数据片段校验失败后, 请求重新传输 校验失败的数据片段。  The verification module is further configured to, after determining that the data segment fails to be verified, request to retransmit the data segment that fails the verification.
11、 一种数据文件校验系统, 其特征在于, 所述系统包括源设备和目 标设备; 其中,  A data file verification system, wherein the system includes a source device and a target device;
源设备, 用于对数据文件进行分段, 得到多个数据片段, 计算每个数 据片段的循环冗余校验 CRC值, 并将数据片段以及该数据片段的 CRC值 传输给目标设备;  a source device, configured to segment the data file, obtain a plurality of data segments, calculate a cyclic redundancy check CRC value of each data segment, and transmit the data segment and the CRC value of the data segment to the target device;
目标设备, 用于计算接收到的数据片段的 CRC值, 并将计算得到的数 据片段的 CRC值与接收到的数据片段的 CRC值进行比较, 确定计算得到 的数据片段的 CRC值与接收到的该数据片段的 CRC值匹配时, 确定该数 据片段校验成功; 不匹配时, 确定该数据片段校验失败。  a target device, configured to calculate a CRC value of the received data segment, and compare the calculated CRC value of the data segment with a CRC value of the received data segment, and determine a CRC value of the calculated data segment and the received When the CRC value of the data segment matches, it is determined that the data segment is successfully verified; when there is no match, it is determined that the data segment verification fails.
PCT/CN2011/072118 2010-06-13 2011-03-24 Method, device and system for transferring and checking data files WO2011157074A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201010207720.7A CN102281121B (en) 2010-06-13 2010-06-13 Method, equipment and system for transmitting and verifying data file
CN201010207720.7 2010-06-13

Publications (1)

Publication Number Publication Date
WO2011157074A1 true WO2011157074A1 (en) 2011-12-22

Family

ID=45106323

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/072118 WO2011157074A1 (en) 2010-06-13 2011-03-24 Method, device and system for transferring and checking data files

Country Status (2)

Country Link
CN (1) CN102281121B (en)
WO (1) WO2011157074A1 (en)

Families Citing this family (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102752283B (en) * 2012-05-30 2015-05-13 福建省三奥信息科技股份有限公司 Method and system for transmitting files with large data sizes
CN107622026B (en) * 2012-11-22 2021-12-03 华为终端有限公司 Data transmission method and equipment
CN103106068B (en) * 2013-02-28 2015-03-18 江苏中科物联网科技创业投资有限公司 Internet of things big data fast calibration method
GB2519140B (en) * 2013-10-11 2021-03-10 Advanced Risc Mach Ltd Cumulative error detection in data transmission
CN104579948A (en) * 2013-10-29 2015-04-29 国家计算机网络与信息安全管理中心 Method and device for fragmenting message
CN103957080B (en) * 2014-04-30 2017-05-31 浙江中控技术股份有限公司 A kind of data integrity verifying method and system
CN105491132A (en) * 2015-12-11 2016-04-13 北京元心科技有限公司 File server, terminal and file subpackage transmission method
CN106161473A (en) * 2016-09-06 2016-11-23 北京恒华伟业科技股份有限公司 The method for uploading of a kind of data and system
CN106843958A (en) * 2017-01-18 2017-06-13 成都黑盒子电子技术有限公司 A kind of embedded firmware upgrading method
CN108512809A (en) * 2017-02-24 2018-09-07 北京优朋普乐科技有限公司 A kind of transmission method and equipment of media file
CN107172174A (en) * 2017-06-01 2017-09-15 重庆高略启达智慧城市信息技术有限公司 The quick upload of file is realized between clients and servers
CN107509085B (en) * 2017-08-24 2019-12-24 山东浪潮商用系统有限公司 Storage method and device of streaming media file
CN109525542A (en) * 2017-09-20 2019-03-26 中兴通讯股份有限公司 Data reconstruction method, transmitting/receiving means and computer readable storage medium
CN108900282A (en) * 2018-06-29 2018-11-27 南昌华勤电子科技有限公司 The method of checking data integrity
CN109194593A (en) * 2018-08-29 2019-01-11 百度在线网络技术(北京)有限公司 Method for sending information, device, equipment and computer readable storage medium
CN111104248A (en) * 2018-10-26 2020-05-05 伊姆西Ip控股有限责任公司 Method, apparatus and computer program product for verifying cached files
CN111464258B (en) * 2019-01-18 2022-10-11 阿里巴巴集团控股有限公司 Data verification method, device, computing equipment and medium
CN110138867A (en) * 2019-05-17 2019-08-16 哈工大机器人(山东)智能装备研究院 File transmission and method of reseptance, computer equipment and storage medium
CN110363027B (en) * 2019-06-21 2021-04-09 捷德(中国)科技有限公司 Electronic contract generation and electronic signature method
WO2021077335A1 (en) * 2019-10-23 2021-04-29 深圳市欢太科技有限公司 Abnormality recovery method, abnormality recovery apparatus, and mobile terminal
WO2021134418A1 (en) * 2019-12-31 2021-07-08 华为技术有限公司 Data checking method and apparatus
CN111314021A (en) * 2020-02-07 2020-06-19 北京字节跳动网络技术有限公司 Data transmission method and device, electronic equipment and computer readable storage medium
CN113872735B (en) * 2020-06-30 2023-10-24 京东方科技集团股份有限公司 Data transmission method, device and equipment
CN112655243B (en) * 2020-12-14 2022-10-28 华为技术有限公司 Data transmission method and data transmission device
CN115314486A (en) * 2022-07-20 2022-11-08 交控科技股份有限公司 Software upgrading method and device for train control system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101159514A (en) * 2007-10-31 2008-04-09 中兴通讯股份有限公司 Method of adding cyclic redundancy code of transmission block
CN101272221A (en) * 2008-05-04 2008-09-24 中兴通讯股份有限公司 Transmission, receiving method and device of file data
EP2026470A1 (en) * 2007-08-17 2009-02-18 Panasonic Corporation Running cyclic redundancy check over coding segments
CN101673296A (en) * 2009-09-02 2010-03-17 太仓市同维电子有限公司 Method for checking file in the process of data communication

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2026470A1 (en) * 2007-08-17 2009-02-18 Panasonic Corporation Running cyclic redundancy check over coding segments
CN101159514A (en) * 2007-10-31 2008-04-09 中兴通讯股份有限公司 Method of adding cyclic redundancy code of transmission block
CN101272221A (en) * 2008-05-04 2008-09-24 中兴通讯股份有限公司 Transmission, receiving method and device of file data
CN101673296A (en) * 2009-09-02 2010-03-17 太仓市同维电子有限公司 Method for checking file in the process of data communication

Also Published As

Publication number Publication date
CN102281121A (en) 2011-12-14
CN102281121B (en) 2014-10-29

Similar Documents

Publication Publication Date Title
WO2011157074A1 (en) Method, device and system for transferring and checking data files
WO2021008248A1 (en) Data frame reception method and device and communication method and system
WO2009089716A1 (en) Data checking method and device
US10153887B2 (en) Patch download with improved acknowledge mechanism
CN106031072A (en) Harq frame data structure and method of transmitting and receiving with harq in systems using blind detection
JP5651191B2 (en) Method and apparatus for requesting retransmission of datagram in physical layer
CN106656424A (en) Verification method of data transmission
TWI650953B (en) Cumulative error detection in data transmission
KR20120112981A (en) Receiving node and method of reducing retransmission of data frame
TWI223520B (en) Wireless network receiver and method for performing message integrity check of service data unit thereof
EP2191602B1 (en) Improved data structure boundary synchronization between a transmitter and receiver
EP2784965A2 (en) Data communication method and apparatus using forward error correction
CN107852275A (en) Data transmission device and data transmission method, reception device and method of reseptance, program and data transmission system
WO2015139235A1 (en) Data transmission and feedback processing method and apparatus
CN104714761A (en) Wireless data printing system and method of equipment with Android system
US10101987B2 (en) Method and system of processing an image upgrade
US20170097867A1 (en) System and method for early packet header verification
JP2007049707A (en) Method, device and program for receiving data stream
CN109039536A (en) Transmission method, equipment and the readable medium of data
US9008077B2 (en) Method for quick map recovery in case of error in MoCA
WO2020238881A1 (en) Message generating and verifying method and apparatus
US20210014006A1 (en) System and method for implementing a hybrid automatic repeat request process
TWI381690B (en) Methods and apparatus for performing protocol data unit header re-synchronization in a communication system
CN109756468B (en) Data packet repairing method, base station and computer readable storage medium
CN112217600A (en) Data frame receiving method and device, and communication method and system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11795040

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11795040

Country of ref document: EP

Kind code of ref document: A1