Data transmission method and device, electronic equipment and nonvolatile storage medium
By combining encoding compression and verification code generation methods in data transmission, the problem of inability to take into account both data transmission speed and accuracy in the prior art is solved, and efficient and reliable data transmission is achieved.
Patent Information
- Application Number
- CN202510219638.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-05-30
AI Technical Summary
The prior art cannot take into account the speed and accuracy of data transmission, especially after data encoding and compression, it cannot effectively detect data transmission errors.
By obtaining the target data, encoding and compression are performed and verification codes are generated, the data to be transmitted is generated, and transmission control data is generated based on the encoding strategy, which is sent to the receiving end respectively. After receiving the data, the receiving end verifies the data integrity through the verification code and decompresses the data based on the transmission control data.
It realizes the accuracy and reliability of data transmission while ensuring the speed of data transmission, solves the problem of data error detection during transmission, and improves the overall data transmission efficiency.
Smart Images

Figure CN120075319A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of fintech, and in particular, to a data transmission method, apparatus, electronic device, and non-volatile storage medium. It should be noted that the data transmission method, apparatus, electronic device, and non-volatile storage medium determined by the present invention can be used for data transmission in the field of fintech, and can also be used for data transmission in any field other than the field of fintech. The application field of the data transmission method, apparatus, electronic device, and non-volatile storage medium involved in the present invention is not limited. Background Art
[0002] With the development of information technologies such as big data, cloud computing, and the Internet of Things, data sharing has become more frequent, and the need for data transmission has become more urgent. Data transmission efficiency is an important indicator for measuring data transmission technology. The higher the data transmission efficiency, the lower the transmission cost; data transmission reliability refers to the accuracy of data during the data transmission process. The higher the data transmission reliability, the more reliable the data transmission. For example, the fewer the number of bytes lost during the data transmission process, the lower the processing cost of the lost data. However, during the data transmission process, related technologies cannot balance the speed and accuracy of data transmission. After encoding and compressing the data, it is impossible to detect whether the data is transmitted incorrectly.
[0003] Regarding the technical problem that the speed and accuracy of data transmission cannot be balanced in related technologies, no effective solution has been proposed yet. Summary of the Invention
[0004] Embodiments of the present invention provide a data transmission method, apparatus, electronic device, and non-volatile storage medium to at least solve the technical problem that the speed and accuracy of data transmission cannot be balanced.
[0005] To achieve the above object, according to one aspect of the present application, a data transmission method is provided. The method includes: obtaining target data; encoding and compressing the target data to obtain encoded data, and generating a check code based on the encoded data; generating data to be transmitted according to the check code and the encoded data; generating transmission control data based on the encoding strategy for encoding and compressing the target data; and respectively sending the data to be transmitted and the transmission control data to a receiving end.
[0006] Optionally, generating a check code based on the encoded data includes: obtaining the target data type of the target data; determining a target check rule in the pre-set correspondence between the data type and the check rule according to the target data type; and processing the encoded data according to the target check rule to generate a check code.
[0007] Optionally, transmission control data is generated based on an encoding strategy for encoding and compressing target data, including: generating a character correspondence relationship according to the encoding strategy for encoding and compressing the target data, where the character correspondence relationship is the correspondence relationship between multiple data characters included in the target data and multiple encoded characters included in the encoded data; determining the identification code of the target verification rule; and splicing the identification code of the target verification rule and the character correspondence relationship to generate the transmission control data, where the identification code of the target verification rule is located at a predetermined position in the transmission control data.
[0008] Optionally, the target data is encoded and compressed to obtain encoded data, including: determining the occurrence probability of each of the multiple data characters included in the target data; generating a character binary tree according to the occurrence probability of each of the multiple data characters; determining the encoded character corresponding to each of the multiple data characters based on the character binary tree to obtain multiple encoded characters; and generating the encoded data according to the target data and the multiple encoded characters.
[0009] To achieve the above object, according to another aspect of the present application, a data transmission method is further provided. The method includes: respectively receiving transmission data and transmission control data from a sending end; determining a verification code to be verified in the transmission data, and verifying the transmission data according to the verification code to be verified to obtain a verification result; and decompressing the transmission data according to the encoding strategy included in the transmission control data to obtain the target data when the verification result indicates that the data is received correctly.
[0010] Optionally, determining a verification code to be verified in the transmission data, and verifying the transmission data according to the verification code to be verified to obtain a verification result includes: determining the verification code to be verified in the transmission data; determining the target verification rule for verifying the transmission data according to the identification code of the target verification rule at a predetermined position in the transmission control data; processing the transmission data according to the target verification rule to generate a verification verification code; and obtaining a verification result indicating that the data is received correctly when the verification verification code matches the verification code to be verified.
[0011] To achieve the above object, according to another aspect of the present application, a data transmission device is provided. The device includes: an acquisition module for acquiring target data; a first generation module for encoding and compressing the target data to obtain encoded data, and generating a verification code based on the encoded data; a second generation module for generating data to be transmitted according to the verification code and the encoded data; a third generation module for generating transmission control data based on the encoding strategy for encoding and compressing the target data; and a sending module for respectively sending the data to be transmitted and the transmission control data to a receiving end.
[0012] Optionally, the first generation module further includes: a first acquisition unit configured to acquire the target data type of the target data; a first determination unit configured to determine a target verification rule from a pre-set correspondence between data types and verification rules according to the target data type; and a processing unit configured to process the encoded data according to the target verification rule to generate a verification code.
[0013] Optionally, the third generation module further includes: a first generation unit configured to generate a character correspondence according to an encoding strategy for encoding and compressing the target data, where the character correspondence is a correspondence between multiple data characters included in the target data and multiple encoded characters included in the encoded data; a second determination unit configured to determine an identification code of the target verification rule; and a second generation unit configured to splice the identification code of the target verification rule and the character correspondence to generate transmission control data, where the identification code of the target verification rule is located at a predetermined position in the transmission control data.
[0014] Optionally, the first generation module further includes: a third determination unit configured to determine the occurrence probability of each of the multiple data characters included in the target data; a third generation unit configured to generate a character binary tree according to the occurrence probability of each of the multiple data characters; a fourth determination unit configured to determine the encoded character corresponding to each of the multiple data characters based on the character binary tree to obtain multiple encoded characters; and a fourth generation unit configured to generate encoded data according to the target data and the multiple encoded characters.
[0015] To achieve the above object, according to another aspect of the present application, there is also provided a data transmission device. The device includes: a receiving module configured to respectively receive transmission data and transmission control data from a sending end; a verification module configured to determine a verification code to be verified in the transmission data and verify the transmission data according to the verification code to be verified to obtain a verification result; and a decompression module configured to decompress the transmission data according to the encoding strategy included in the transmission control data to obtain target data when the verification result indicates that the data is received correctly.
[0016] Optionally, the verification module further includes: a fifth determination unit configured to determine the verification code to be verified in the transmission data; a sixth determination unit configured to determine a target verification rule for verifying the transmission data according to the identification code of the target verification rule at a predetermined position in the transmission control data; a fifth generation unit configured to process the transmission data according to the target verification rule to generate a verification verification code; and a seventh determination unit configured to obtain a verification result indicating that the data is received correctly when the verification verification code matches the verification code to be verified.
[0017] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a non-volatile storage medium is provided, the non-volatile storage medium includes a stored program, wherein when the program is running, any one of the above-mentioned data transmission methods of the device where the non-volatile storage medium is located is controlled.
[0018] In order to achieve the above-mentioned purpose, according to another aspect of the present application, an electronic device is provided, comprising one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement any one of the above-mentioned data transmission methods.
[0019] In order to achieve the above object, according to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, any one of the above data transmission methods is implemented.
[0020] Through the present application, the following steps are adopted: obtaining target data; encoding and compressing the target data to obtain encoded data, and generating a check code based on the encoded data; generating data to be transmitted based on the check code and the encoded data; generating transmission control data based on a coding strategy for encoding and compressing the target data; and sending the data to be transmitted and the transmission control data to the receiving end respectively, thereby achieving the purpose of organically combining the compression process and the verification process, solving the technical problem in the related technology that the speed and accuracy of data transmission cannot be taken into account at the same time, and thus achieving the technical effect of improving the overall efficiency of data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0022] Figure 1 is a flow chart of a data transmission method provided according to an embodiment of the present application;
[0023] Figure 2 is a flowchart of another data transmission method provided according to an embodiment of the present application;
[0024] Figure 3 is a schematic diagram of a data transmission process provided according to an optional embodiment of the present application;
[0025] Figure 4 is a schematic diagram of a data transmission device provided according to an embodiment of the present application;
[0026] Figure 5 is a schematic diagram of another data transmission device provided according to an embodiment of the present application;
[0027] Figure 6 It is a schematic structural diagram of an electronic device for performing a data transmission method according to an embodiment of the present invention. Detailed implementation manners
[0028] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the drawings and in conjunction with the embodiments.
[0029] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0030] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so as to implement the embodiments of the present application described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0031] It should be noted that the relevant information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in the present disclosure are all information and data that have been authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data comply with the relevant laws, regulations and standards in the relevant regions. For example, an interface is set between the present system and the relevant users or institutions. Before obtaining the relevant information, a request for obtaining needs to be sent to the aforementioned users or institutions through the interface, and after receiving the consent information feedback from the aforementioned users or institutions, the relevant information is obtained.
[0032] The present invention will be described below in conjunction with the preferred implementation steps. Figure 1 It is a flowchart of a data transmission method according to an embodiment of the present application. As Figure 1 shown, the method includes the following steps:
[0033] Step S101, obtain target data.
[0034] The execution entity in this step is the sender in the data transmission process, and the target data is the data to be transmitted this time. The target data can be in any form, such as text, image, audio, or video, etc.
[0035] Step S102: Encode and compress the target data to obtain the encoded data, and generate a checksum based on the encoded data.
[0036] In this step, the sender can use a certain encoding and compression algorithm (such as Huffman coding) to reduce the size of the target data. The compressed data usually occupies less storage space or transmission bandwidth than the original data. After data compression, the sender can also calculate a checksum. This checksum is usually calculated by a certain algorithm on the encoded data and is appended to the end of the compressed data for the receiver to detect the integrity of the data during transmission. If an error occurs during data transmission, the checksum will not match the checksum recalculated by the receiver, thus enabling the error to be detected in a timely manner.
[0037] Step S103: Generate the data to be transmitted based on the checksum and the encoded data.
[0038] In this step, the encoded data and the checksum are combined to form the data packet to be transmitted. This data packet contains all the necessary information. The receiver can use the checksum to verify the integrity of the data and use the encoding strategy to decode the data and restore the original information. When generating the data packet to be transmitted, other processes can be performed, such as segmenting or formatting the data packet to adapt to a specific transmission protocol or network environment.
[0039] Step S104: Generate transmission control data based on the encoding strategy for encoding and compressing the target data.
[0040] In this step, the transmission control data contains the information required for the receiver to decode and verify the data, such as the encoding algorithm used, the encoding rule table, and the checksum algorithm, etc. In some cases, the transmission control data can also include the meta-information of the data, such as the size, type, or compression ratio of the data. These information are crucial for the receiver to correctly decode and process the data. The generation of the transmission control data ensures that the receiver can understand and correctly process the received data packet.
[0041] Step S105: Send the data to be transmitted and the transmission control data to the receiver respectively.
[0042] In this step, after generating the data packet to be transmitted and the transmission control data, the sender sends them to the receiver. The data packet and the transmission control data may be sent through the same channel or through different channels. In some applications, the transmission control data is sent first to ensure that the receiver is ready with the decoding and verification strategies before receiving the data packet. This step-by-step transmission mechanism ensures the efficiency and accuracy of data transmission.
[0043] Optionally, in the above data transmission method, generating a checksum based on the encoded data includes: obtaining the target data type of the target data; determining the target checksum rule according to the target data type in the pre-set correspondence between the data type and the checksum rule; and processing the encoded data according to the target checksum rule to generate a checksum.
[0044] Before generating the checksum, it is necessary to first determine the type of the data, that is, the "target data type". The data type can refer to the format of the data (such as text, image, audio, etc.) or the content characteristics of the data (such as whether it is structured data, whether it contains a large number of repeated elements, etc.). Understanding the data type helps to select the most suitable checksum rule because different types of data exhibit different error patterns, and different checksum rules have different error detection effects for different types of errors.
[0045] Once the target data type is obtained, the most suitable checksum rule can be found from the pre-defined "correspondence between the data type and the checksum rule". The above correspondence can be a lookup table or a database that stores various data types and recommended checksum rules. The checksum rule can include the Cyclic Redundancy Check (CRC), which calculates the checksum value through a polynomial division operation. The sender and the receiver must use the same generating polynomial for verification. Usually, the generating polynomial used is a binary number of a fixed length. For example, for text data, CRC-32 can be selected as the checksum rule, that is, the generated checksum is 32 bits, which can effectively detect burst errors; while for shorter data packets, CRC-16 can be selected, that is, the generated checksum is 16 bits, which has a lower calculation overhead and is more suitable for scenarios with high real-time requirements.
[0046] After determining the target checksum rule, use this rule to calculate the checksum of the encoded data. This process usually involves taking the encoded data as an input and calculating a checksum. The checksum is a data of a fixed length that reflects the characteristics of the encoded data and is usually appended to the end of the data for transmission. After receiving the data, the receiver can use the same checksum rule to recalculate the checksum of the data and then compare it with the received checksum to detect whether an error has occurred during the data transmission process.
[0047] Through the above steps, the most suitable verification rules can be selected for different types of data to generate verification codes, thereby improving the reliability and accuracy of data transmission while ensuring the efficiency of data transmission. It is also possible to dynamically adjust the verification strategy according to the characteristics of the data to achieve the best transmission effect.
[0048] Optionally, in the above data transmission method, based on the encoding strategy for encoding and compressing the target data, transmission control data is generated, including: generating a character correspondence relationship according to the encoding strategy for encoding and compressing the target data, where the character correspondence relationship is the correspondence relationship between multiple data characters included in the target data and multiple encoded characters included in the encoded data; determining the identification code of the target verification rule; and splicing the identification code of the target verification rule and the character correspondence relationship to generate transmission control data, where the identification code of the target verification rule is located at a predetermined position in the transmission control data.
[0049] The character correspondence relationship refers to the mapping relationship between the characters in the original data defined in the encoding strategy and the encoded characters in the encoded data. For example, when using Huffman coding for data compression, a Huffman tree is generated according to the frequency of the characters, and a binary code is assigned to each character. This coding rule is part of the character correspondence relationship and needs to be included in the transmission control data so that the receiving end can use the same rule to reconstruct the original data.
[0050] The identification code is a short code used to uniquely identify the verification rule used. In data transmission, different data types require different verification rules, and the identification code ensures that the receiving end can identify the specific verification rule used by the sending end, so as to execute the corresponding verification algorithm to verify the integrity of the data.
[0051] The transmission control data is the result of combining meta-information such as the identification code and the character correspondence relationship. These information will be spliced together in a certain order and format to form a data packet. The position of the identification code is specific, so that the receiving end can quickly locate the identification code and identify the verification rule used, which can ensure that the receiving end can immediately identify the verification rule after receiving the control data. The character correspondence relationship may exist in the form of a table or a mapping, which is used to guide the decoding process of the receiving end.
[0052] Through the above steps, the transmission control data contains the encoding strategy (such as the Huffman coding rule) and the verification rule (such as the CRC algorithm and its parameters), ensuring that the receiving end can correctly decode and verify the encoded data, thereby improving the reliability and efficiency of data transmission.
[0053] Optionally, in the above data transmission method, encoding and compressing the target data to obtain the encoded data includes: determining the occurrence probability of each of the multiple data characters included in the target data; generating a character binary tree according to the occurrence probability of each of the multiple data characters; determining the encoded characters corresponding to each of the multiple data characters based on the character binary tree to obtain multiple encoded characters; and generating the encoded data according to the target data and the multiple encoded characters.
[0054] Encoding compression is a means to improve efficiency and reduce the data volume in data transmission. Huffman coding is an effective encoding compression method, which realizes compression by assigning different encoding lengths to characters. In this process, characters with high occurrence frequencies will get shorter encodings, while characters with low occurrence frequencies will have longer encodings, thus reducing the encoding length of the entire data.
[0055] Among them, determining the occurrence probability of each of the multiple data characters included in the target data is the first step in generating Huffman coding. By scanning the target data, counting the number of occurrences of each character (data character), and then calculating the occurrence probability of each character. The allocation of the encoding length directly depends on the probability.
[0056] Secondly, a character binary tree is generated according to the occurrence probability of each of the multiple data characters. The character binary tree is generated through the following steps: First, put all characters and their occurrence probabilities as leaf nodes into a priority queue (usually a minimum heap), and the priority is determined by the occurrence probability. Secondly, take out two nodes with the minimum probability from the queue, create a new internal node, the probability of which is the sum of the probabilities of these two nodes, and put this new node back into the queue. Then, repeat the previous step until there is only one node left in the queue, and this node is the root node of the Huffman tree. Finally, according to the structure of the Huffman tree, assign an encoding to each leaf node. On the path from the root node to the leaf node, the left branch corresponds to 0 and the right branch corresponds to 1. In this way, each character corresponds to a binary encoding based on the Huffman tree structure, that is, the encoded character.
[0057] Once the Huffman tree is constructed, the encoding of each character can be read from the tree. The sequence of 0s and 1s on the path from the root node to the leaf node of a certain character is the encoded character of that character. The encoding length of a character is inversely proportional to the occurrence probability of the character, that is, a character with a high occurrence probability will have a shorter encoding.
[0058] Replace each original character in the target data with the corresponding encoded character to form the encoded data. Concatenate all the encoded characters in the order of the characters in the original data, and the final encoded data is obtained. Due to the adjustment of the encoding length, the encoded data usually occupies less storage space or transmission bandwidth than the original data.
[0059] Through the above steps, Huffman coding can effectively encode and compress the target data to generate the encoded data, and at the same time ensure the lossless compression of the data, that is, the receiving end can completely restore the original data using the same Huffman tree and coding rules.
[0060] The data transmission method provided by the embodiment of the present application includes: obtaining target data; encoding and compressing the target data to obtain encoded data, and generating a check code based on the encoded data; generating data to be transmitted according to the check code and the encoded data; generating transmission control data based on the encoding strategy for encoding and compressing the target data; and respectively sending the data to be transmitted and the transmission control data to the receiving end, achieving the purpose of organically combining the compression process and the verification process, solving the technical problem in the related art that the speed and accuracy of data transmission cannot be taken into account, and further achieving the technical effect of improving the overall efficiency of data transmission.
[0061] Figure 2 is a flowchart of another data transmission method provided by the embodiment of the present application, as Figure 2 shown, the method includes the following steps:
[0062] Step S201: Receive the transmission data and the transmission control data from the sending end respectively.
[0063] The execution subject of this step is the receiving end, and the receiving end needs to receive two parts of data respectively: the transmission data and the transmission control data. The transmission data is the actual data sent by the sending end after encoding and compression, including the encoded information and the additional check code. The transmission control data contains the information required for decompressing and verifying the transmission data, such as the encoding strategy (such as the Huffman coding rule), the identification code of the verification rule, etc. The receiving end first needs to distinguish these two parts of data. Usually, the transmission control data is sent before the transmission data, or there is a clear separation mark in the data packet.
[0064] Step S202: Determine the check code to be verified in the transmission data, and verify the transmission data according to the check code to be verified to obtain a verification result.
[0065] In this step, after the receiving end receives the transmission data, it needs to extract the check code to be verified from it. The check code is usually located at the end of the data packet. According to the information provided in the transmission control data, the receiving end can determine the position and length of the check code. Then, the receiving end will use the same check algorithm as the sending end (such as the CRC algorithm) to process the transmission data (excluding the check code) and calculate a new check code. Next, the receiving end will compare the calculated check code with the received check code to be verified. If the two are the same, it means that no error occurred during the data transmission process, that is, the data is received correctly. If they are not the same, it indicates that there may be data corruption or loss during the transmission process, and the received data is not trustworthy.
[0066] Step S203, when the verification result indicates that the data is received correctly, decompress the transmission data according to the encoding strategy included in the transmission control data to obtain the target data.
[0067] In this step, once the verification result indicates that the data is received correctly, the receiving end can decompress the transmission data using the encoding strategy provided in the transmission control data. For example, if the encoding strategy is Huffman coding, then the transmission control data will contain the Huffman coding rules, that is, the mapping table from characters to codes. The receiving end can use this mapping table to gradually restore the original character sequence from the encoded characters in the transmission data, thereby obtaining the decompressed target data. This process is the reverse of the encoding process, converting the received encoded characters into the original characters and finally restoring the original information.
[0068] Optionally, in the above data transmission method, determining the check code to be verified in the transmission data and verifying the transmission data according to the check code to be verified to obtain a verification result includes: determining the check code to be verified in the transmission data; determining the target check rule for verifying the transmission data according to the identification code of the target check rule at a predetermined position in the transmission control data; processing the transmission data according to the target check rule to generate a verification check code; and obtaining a verification result indicating that the data is received correctly when the verification check code matches the check code to be verified.
[0069] When the receiving end receives the transmission data, it first needs to identify the check code to be verified from the data packet. Usually, the check code is appended at the end of the transmission data as an independent paragraph. The receiving end needs to know the length and position of the check code to correctly extract it, and this information is usually clearly specified by the sending end in the transmission control data.
[0070] The transmission control data contains information about the encoding strategy and verification rules used by the sender. Among them, the identification code of the target verification rule is located at a predetermined position in the transmission control data. By parsing the transmission control data, the receiver can find this identification code and then determine the specific verification rule used by the sender. For example, the identification code may be the code or name of CRC verification algorithms such as CRC-16, CRC-32, or a custom verification rule number.
[0071] After determining the target verification rule, the receiver applies the same verification rule to the transmission data (excluding the verification code to be verified) to calculate a verification checksum. This process is to verify whether the transmission data has maintained integrity during transmission, that is, to verify whether the transmission data has not been changed or damaged. The generation process of the verification checksum depends on the specific verification algorithm, such as the CRC algorithm, which performs complex mathematical operations based on the binary representation of the data and finally obtains a fixed checksum value.
[0072] Once the verification checksum is generated, the receiver compares it with the received verification code to be verified. If these two checksums match exactly, it indicates that no errors have occurred during the transmission of the transmission data and the data reception is correct. If the checksums do not match, it means that errors may have occurred during the transmission of the transmission data and the data integrity has been damaged. At this time, the receiver needs to take corresponding measures, such as requesting the sender to retransmit the data.
[0073] Through the above steps, the receiver can effectively detect the integrity of the transmission data and ensure the correct reception of the data, effectively reducing the impact of data transmission errors and improving the reliability and efficiency of data transmission. If the verification fails, the receiver can detect it in time and request retransmission, avoiding the impact of data corruption or loss on the service.
[0074] The data transmission method provided by the embodiments of this application receives the transmission data and transmission control data from the sender respectively; determines the verification code to be verified in the transmission data, and verifies the transmission data according to the verification code to be verified to obtain a verification result; when the verification result indicates that the data reception is correct, decompresses the transmission data according to the encoding strategy included in the transmission control data to obtain the target data, achieving the purpose of organically combining the decompression process and the verification process, solving the technical problem in the related art that it is impossible to balance the speed and accuracy of data transmission, and thus achieving the technical effect of improving the overall efficiency of data transmission.
[0075] As a specific embodiment, Figure 3 is a schematic diagram of the data transmission process according to an optional embodiment of this application, as Figure 3As shown in the figure, the entire data transmission system may include a sending end, a receiving end, and a control module. It should be noted that the control module can be a device located outside the sending end and the receiving end. The sending end and the receiving end interact with the control module to obtain the CRC rules and numbers stored in the control module (i.e., the target verification rules and the identification codes of the target verification rules).
[0076] The sending end includes a compression module, which can use the Huffman coding principle to create a transcoding rule table and replace each original character in the file with a binary character segment according to the transcoding rule table to generate a data string.
[0077] Among them, the specific process of creating the transcoding rule table is as follows: Scan the entire text of the file to be sent, count that there are a total of n non-repeating characters (including: uppercase and lowercase letters, numbers, punctuation marks, special characters, etc.), and record the frequency F of each character i , calculate the probability P of each character appearing i , then there is:
[0078]
[0079] Sort the n characters in ascending order according to the probability P i to obtain the queue Q.
[0080] Then construct an encoding tree (binary tree): First, create an empty node Z 1 ; then select the character C at the front of the queue Q 1 (i.e., the character with the smallest appearance probability in the queue), and use it as the left child node of Z 1 , select the character C at the second position in the queue Q 2 (i.e., the character with the second smallest appearance probability in the queue), and use it as the right child node of Z 1 , then the probability P of node Z 1 = P z1 + P 1 . If P 2 = P 1 , then the placement positions of the two characters have no requirements. Delete C 2 and C 1 and C 2 from the queue Q, add Z 1 , re-sort all the existing characters in ascending order according to the appearance probability to obtain a new queue Q'; repeat the above operations until all n non-repeating characters appear on the nodes of the binary tree; then generate the encoding for each character, and the rule is: for each non-leaf node on the binary tree, assign 0 to the left side of the connection line and 1 to the right side of the connection line. Finally, the encoding of each character is the combination of the 0 and 1 sequences on the path from the root node of the binary tree to the character node.
[0081] Using the above encoding rules, each character of the original file is converted into binary code one by one, and the initial data string is obtained by splicing them in sequence.
[0082] Secondly, the sending end can obtain the CRC rule and number from the control module, calculate the check code of the initial data string using the CRC rule and assemble it at the end to generate a new data string.
[0083] Secondly, the CRC rule number used and the transcoding rule table are spliced into a control string.
[0084] Finally, the control string and the data string are sent to the receiving end in sequence.
[0085] The receiving end includes a decompression module, which receives the control string and splits it into the CRC rule number and the transcoding rule table; then, according to the CRC rule number, obtains the CRC rule from the control module; then receives the data string, strips the check code from it using the CRC rule, performs a CRC operation on the remaining string, and checks the obtained operation result with the stripped check code. If the two are consistent, it indicates that the data is received correctly, and then according to the transcoding rule table, the binary characters of the data string obtained by stripping are restored to the original file characters; if they are inconsistent, it indicates that the data is received incorrectly, and an instruction is sent to the sending end to request retransmission of the data string.
[0086] It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order from here.
[0087] The embodiment of the present application also provides a data transmission device. It should be noted that the data transmission device in the embodiment of the present application can be used to execute the data transmission method provided by the embodiment of the present application. The data transmission device provided by the embodiment of the present application is introduced below.
[0088] Figure 4 is a schematic diagram of a data transmission device according to an embodiment of the present application. As Figure 4 shown, the device includes: an acquisition module 41 for acquiring target data; a first generation module 42 connected to the acquisition module 41 for encoding and compressing the target data to obtain encoded data and generating a check code based on the encoded data; a second generation module 43 connected to the first generation module 42 for generating data to be transmitted according to the check code and the encoded data; a third generation module 44 connected to the second generation module 43 for generating transmission control data based on the encoding strategy for encoding and compressing the target data; a sending module 45 connected to the third generation module 44 for separately sending the data to be transmitted and the transmission control data to the receiving end.
[0089] Optionally, in the above data transmission device, the first generation module further includes: a first acquisition unit configured to acquire the target data type of the target data; a first determination unit configured to determine a target verification rule from a pre-set correspondence between data types and verification rules according to the target data type; and a processing unit configured to process the encoded data according to the target verification rule to generate a verification code.
[0090] Optionally, in the above data transmission device, the third generation module further includes: a first generation unit configured to generate a character correspondence according to an encoding strategy for encoding and compressing target data, where the character correspondence is a correspondence between multiple data characters included in the target data and multiple encoded characters included in the encoded data; a second determination unit configured to determine an identification code of the target verification rule; and a second generation unit configured to splice the identification code of the target verification rule and the character correspondence to generate transmission control data, where the identification code of the target verification rule is located at a predetermined position in the transmission control data.
[0091] Optionally, in the above data transmission device, the first generation module further includes: a third determination unit configured to determine the occurrence probability of each of the multiple data characters included in the target data; a third generation unit configured to generate a character binary tree according to the occurrence probability of each of the multiple data characters; a fourth determination unit configured to determine the encoded character corresponding to each of the multiple data characters based on the character binary tree to obtain multiple encoded characters; and a fourth generation unit configured to generate encoded data according to the target data and the multiple encoded characters.
[0092] The data transmission device provided in the embodiment of the present application adopts the following steps through the present application: acquiring target data; encoding and compressing the target data to obtain encoded data, and generating a verification code based on the encoded data; generating data to be transmitted according to the verification code and the encoded data; generating transmission control data based on an encoding strategy for encoding and compressing the target data; and respectively sending the data to be transmitted and the transmission control data to a receiving end, achieving the purpose of organically combining the compression process and the verification process, solving the technical problem in the related art that the speed and accuracy of data transmission cannot be taken into account, and further achieving the technical effect of improving the overall efficiency of data transmission.
[0093] Figure 5 is a schematic diagram of a data transmission device according to an embodiment of the present application. As Figure 5As shown in the figure, the device includes: a receiving module 51, configured to receive the transmission data and transmission control data from the sending end respectively; a verification module 52, connected to the receiving module 51, configured to determine the verification code to be verified in the transmission data, and verify the transmission data according to the verification code to be verified to obtain a verification result; a decompression module 53, connected to the verification module 52, configured to decompress the transmission data according to the encoding strategy included in the transmission control data to obtain the target data when the verification result indicates that the data is received correctly.
[0094] Optionally, in the above data transmission device, the verification module further includes: a fifth determination unit, configured to determine the verification code to be verified in the transmission data; a sixth determination unit, configured to determine the target verification rule for verifying the transmission data according to the identification code of the target verification rule at a predetermined position in the transmission control data; a fifth generation unit, configured to process the transmission data according to the target verification rule to generate a verification verification code; a seventh determination unit, configured to obtain a verification result indicating that the data is received correctly when the verification verification code matches the verification code to be verified.
[0095] The data transmission device provided by the embodiment of the present application adopts the following steps through the present application: respectively receive the transmission data and transmission control data from the sending end; determine the verification code to be verified in the transmission data, and verify the transmission data according to the verification code to be verified to obtain a verification result; when the verification result indicates that the data is received correctly, decompress the transmission data according to the encoding strategy included in the transmission control data to obtain the target data, achieving the purpose of organically combining the decompression process and the verification process, solving the technical problem in the related art that it is impossible to take into account both the speed and accuracy of data transmission, and further achieving the technical effect of improving the overall efficiency of data transmission.
[0096] The data transmission device includes a processor and a memory. The above modules are all stored in the memory as program units, and the corresponding functions are implemented by the processor executing the above program units stored in the memory.
[0097] The processor contains a kernel, and the kernel retrieves the corresponding program unit from the memory. One or more kernels can be set, and by adjusting the kernel parameters, the compression process and the verification process can be organically combined to improve the overall efficiency of data transmission.
[0098] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of, for example, read-only memory (ROM) or flash memory (flash RAM), and the memory includes at least one storage chip.
[0099] An embodiment of the present invention provides a computer-readable storage medium, on which a program is stored, and when the program is executed by a processor, the data transmission method is implemented.
[0100] An embodiment of the present invention provides a processor for running a program, wherein when the program runs, the data transmission method is executed.
[0101] Figure 6 is a schematic structural diagram of an electronic device for performing the data transmission method according to an embodiment of the present invention, as Figure 6 shown, an embodiment of the present invention provides an electronic device, the device includes a processor, a memory, and a program stored on the memory and executable on the processor, and when the processor executes the program, the following steps are implemented: obtaining target data; performing encoding and compression on the target data to obtain encoded data, and generating a check code based on the encoded data; generating data to be transmitted according to the check code and the encoded data; generating transmission control data based on the encoding strategy for encoding and compressing the target data; respectively sending the data to be transmitted and the transmission control data to the receiving end.
[0102] Optionally, when the processor executes the program, the following steps may also be implemented: generating a check code based on the encoded data, including: obtaining the target data type of the target data; determining the target check rule in the pre-set correspondence between data types and check rules according to the target data type; processing the encoded data according to the target check rule to generate a check code.
[0103] Optionally, when the processor executes the program, the following steps may also be implemented: generating transmission control data based on the encoding strategy for encoding and compressing the target data, including: generating a character correspondence according to the encoding strategy for encoding and compressing the target data, where the character correspondence is the correspondence between multiple data characters included in the target data and multiple encoded characters included in the encoded data; determining the identification code of the target check rule; splicing the identification code of the target check rule and the character correspondence to generate transmission control data, where the identification code of the target check rule is located at a predetermined position in the transmission control data.
[0104] Optionally, when the processor executes the program, the following steps may also be implemented: performing encoding and compression on the target data to obtain encoded data, including: determining the occurrence probability of each of the multiple data characters included in the target data; generating a character binary tree according to the occurrence probability of each of the multiple data characters; determining the encoded character corresponding to each of the multiple data characters based on the character binary tree to obtain multiple encoded characters; generating encoded data according to the target data and the multiple encoded characters.
[0105] When the processor executes the program, the following steps are implemented: receiving the transmission data and transmission control data from the sending end respectively; determining the check code to be verified in the transmission data, and verifying the transmission data according to the check code to be verified to obtain a verification result; when the verification result indicates that the data is received correctly, decompressing the transmission data according to the encoding strategy included in the transmission control data to obtain the target data.
[0106] Optionally, when the processor executes the program, the following steps can also be implemented: determining the check code to be verified in the transmission data, and verifying the transmission data according to the check code to be verified to obtain a verification result, including: determining the check code to be verified in the transmission data; determining the target verification rule for verifying the transmission data according to the identification code of the target verification rule at the predetermined position in the transmission control data; processing the transmission data according to the target verification rule to generate a verification check code; when the verification check code matches the check code to be verified, obtaining a verification result indicating that the data is received correctly.
[0107] The device in this article can be a server, a PC, a PAD, a mobile phone, etc.
[0108] This application also provides a computer program product, which, when executed on a data processing device, is adapted to execute a program initialized with the following method steps: obtaining the target data; encoding and compressing the target data to obtain the encoded data, and generating a check code based on the encoded data; generating the data to be transmitted according to the check code and the encoded data; generating transmission control data based on the encoding strategy for encoding and compressing the target data; respectively sending the data to be transmitted and the transmission control data to the receiving end.
[0109] Optionally, the computer program product can also be adapted to execute a program initialized with the following method steps: generating a check code based on the encoded data, including: obtaining the target data type of the target data; determining the target verification rule in the pre-set correspondence between the data type and the verification rule according to the target data type; processing the encoded data according to the target verification rule to generate a check code.
[0110] Optionally, the computer program product can also be adapted to execute a program initialized with the following method steps: generating transmission control data based on the encoding strategy for encoding and compressing the target data, including: generating a character correspondence according to the encoding strategy for encoding and compressing the target data, where the character correspondence is the correspondence between multiple data characters included in the target data and multiple encoded characters included in the encoded data; determining the identification code of the target verification rule; splicing the identification code of the target verification rule and the character correspondence to generate the transmission control data, where the identification code of the target verification rule is located at the predetermined position in the transmission control data.
[0111] Optionally, the computer program product may also be adapted to execute a program initialized with the following method steps: encoding and compressing target data to obtain encoded data, including: determining the occurrence probability of each of a plurality of data characters included in the target data; generating a character binary tree according to the occurrence probability of each of the plurality of data characters; determining, based on the character binary tree, the encoded characters corresponding to each of the plurality of data characters to obtain a plurality of encoded characters; and generating encoded data according to the target data and the plurality of encoded characters.
[0112] The computer program product is also adapted to execute a program initialized with the following method steps: respectively receiving transmission data and transmission control data from a sending end; determining a check code to be verified in the transmission data, and verifying the transmission data according to the check code to be verified to obtain a verification result; and decompressing the transmission data according to the encoding strategy included in the transmission control data to obtain target data when the verification result indicates that the data is received correctly.
[0113] Optionally, the computer program product may also be adapted to execute a program initialized with the following method steps: determining a check code to be verified in the transmission data, and verifying the transmission data according to the check code to be verified to obtain a verification result, including: determining the check code to be verified in the transmission data; determining a target verification rule for verifying the transmission data according to the identification code of the target verification rule at a predetermined position in the transmission control data; processing the transmission data according to the target verification rule to generate a verification check code; and obtaining a verification result indicating that the data is received correctly when the verification check code matches the check code to be verified.
[0114] Those skilled in the art should understand that the embodiments of the present application may be provided as a method, a system, or a computer program product. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0115] The present application is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate for implementing the process Figure 1one or more processes and / or blocks Figure 1 means for the functions specified in one or more blocks.
[0116] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce a manufacture including an instruction means that implements the functions in the process Figure 1 one or more processes and / or blocks Figure 1 specified in one or more blocks.
[0117] These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus, such that a series of operational steps are performed on the computer or other programmable apparatus to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable apparatus provide steps for implementing the functions in the process Figure 1 one or more processes and / or blocks Figure 1 specified in one or more blocks.
[0118] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0119] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
[0120] Computer-readable media includes both permanent and non-permanent, removable and non-removable media implemented by any method or technology for storing information. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media such as modulated data signals and carrier waves.
[0121] It should also be noted that the term "comprise", "include" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or apparatus that comprises a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or apparatus. Without further limitation, an element defined by the phrase "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or apparatus that comprises the element.
[0122] Those skilled in the art should understand that the embodiments of the present application may be provided as a method, a system or a computer program product. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0123] The above are only the embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. A data transmission method, characterized in that: include: Get target data; Encoding and compressing the target data to obtain encoded data, and generating a check code based on the encoded data; Generating data to be transmitted according to the check code and the encoded data; generating transmission control data based on a coding strategy for coding and compressing the target data; The data to be transmitted and the transmission control data are respectively sent to a receiving end.
2. The method according to claim 1, characterized in that The generating a check code based on the encoded data comprises: Acquire a target data type of the target data; According to the target data type, determining the target verification rule in the correspondence between the preset data types and the verification rules; The encoded data is processed according to the target verification rule to generate the verification code.
3. The method according to claim 2, characterized in that The step of generating transmission control data based on the encoding strategy for encoding and compressing the target data comprises: Generate a character correspondence relationship according to the encoding strategy for encoding and compressing the target data, wherein the character correspondence relationship is a correspondence relationship between a plurality of data characters included in the target data and a plurality of encoding characters included in the encoded data; Determining an identification code of the target verification rule; The identification code of the target verification rule and the character correspondence are concatenated to generate the transmission control data, wherein the identification code of the target verification rule is located at a predetermined position in the transmission control data.
4. The method according to any one of claims 1 to 3, characterized in that The step of encoding and compressing the target data to obtain encoded data includes: Determining the occurrence probability of each of a plurality of data characters included in the target data; Generate a character binary tree according to the occurrence probabilities of the plurality of data characters; Based on the character binary tree, determine the coded characters corresponding to the multiple data characters respectively to obtain multiple coded characters; The encoded data is generated according to the target data and the plurality of encoded characters.
5. A data transmission method, characterized in that: include: Receiving transmission data and transmission control data from a transmitting end respectively; Determining a check code to be checked in the transmission data, and checking the transmission data according to the check code to be checked to obtain a check result; When the verification result indicates that the data is received correctly, the transmission data is decompressed according to the encoding strategy included in the transmission control data to obtain the target data.
6. The method according to claim 5, characterized in that The step of determining a check code to be checked in the transmission data, and checking the transmission data according to the check code to be checked to obtain a check result includes: Determining a check code to be checked in the transmission data; Determining the target verification rule for verifying the transmission data according to the identification code of the target verification rule at a predetermined position in the transmission control data; Processing the transmission data according to the target verification rule to generate a verification code; In the case where the verification check code matches the check code to be verified, a verification result indicating that the data is received correctly is obtained.
7. A data transmission device, characterized in that: include: An acquisition module is used to acquire target data; A first generating module, used for encoding and compressing the target data to obtain encoded data, and generating a check code based on the encoded data; A second generating module, used to generate data to be transmitted according to the check code and the encoded data; A third generating module, configured to generate transmission control data based on a coding strategy for coding and compressing the target data; The sending module is used to send the data to be transmitted and the transmission control data to the receiving end respectively.
8. A data transmission device, characterized in that: include: A receiving module, used for receiving transmission data and transmission control data from a transmitting end respectively; A verification module, used to determine a verification code to be verified in the transmission data, and verify the transmission data according to the verification code to be verified to obtain a verification result; The decompression module is used to decompress the transmission data according to the encoding strategy included in the transmission control data to obtain the target data when the verification result shows that the data is received correctly.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored program, wherein when the program is executed, the device where the non-volatile storage medium is located is controlled to execute the data transmission method according to any one of claims 1 to 6.
10. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the data transmission method described in any one of claims 1 to 6.
11. A computer program product comprising computer instructions, characterized in that: The computer instructions are executed by the processor to execute the data transmission method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method for data error detection, device and communication system
CN102325003A
Data compression algorithm and system based on Internet of Things application identification
CN116527061A