Protocol frame header conflict avoidance method and device, equipment and storage medium
By detecting and replacing conflicting data in the data frame, and dynamically selecting the bitmap structure according to the conflict rate to generate bitmap annotations, the problems of low data transmission efficiency and insufficient robustness are solved, and efficient and reliable data transmission is achieved.
Patent Information
- Application Number
- CN202510615726.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2045-05-14
AI Technical Summary
The prior art has problems in data transmission with low data transmission efficiency, high processing complexity, long processing delay, insufficient robustness and rigid bitmap design.
By detecting conflicting data in the data frame and replacing conflicting data with replacement data, dynamically selecting a single-layer or multi-layer bitmap structure according to the conflict rate, generating bitmap annotations, and adding hierarchical identification and check bits at the end of the data frame to generate a complete bitmap.
It improves the data transmission rate, reduces the complexity and delay of data processing, and improves the reliability and flexibility of data transmission.
Smart Images

Figure CN120263352A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data transmission, and particularly to a method, apparatus, device, and storage medium for avoiding protocol frame header conflicts. Background Art
[0002] In communication protocols, a frame header is a predefined byte sequence used to identify the start of a data frame. However, when the same byte sequence as the frame header appears in the data content, the receiving end may misidentify it as a new frame header, resulting in data parsing errors, i.e., frame header misjudgment. To avoid frame header misjudgment, bit stuffing or byte stuffing methods are commonly used. Among them, bit stuffing breaks a pattern similar to the frame header by inserting extra bits into the data stream; byte stuffing inserts escape characters and modifies the data identical to the frame header to avoid misjudgment. The above methods have been widely applied in serial communication protocols such as HDLC and PPP to ensure the uniqueness of the frame header by changing the data content.
[0003] In the prior art, the patent with the publication number CN114337915A discloses a private protocol fault tolerance processing method based on serial communication. The method includes: the data sender adds frame header check data to the tail of the original data frame to obtain a first data frame, and the first data frame includes a frame header, a data area, a CRC check code, and frame header check data; replaces the pseudo-frame header in the data area and the CRC check code with replacement data to obtain a second data frame, and sends the second data frame to the data receiver, where the data of the pseudo-frame header is the same as the data of the frame header; the data receiver determines whether the frame header check data of the received data frame meets a preset condition. If so, restores the replacement data in the received data frame to the pseudo-frame header so that the data frame received by the data receiver is the same as the data frame sent by the data sender.
[0004] Although the prior art can prevent frame header misjudgment in specific scenarios, there are still problems such as low data transmission efficiency, high processing complexity, long processing delay, insufficient robustness, and rigid bitmap design. Summary of the Invention
[0005] The present invention provides a method, apparatus, device, and storage medium for avoiding protocol frame header conflicts, which solves the problems of low data transmission efficiency, high processing complexity, long processing delay, insufficient robustness, and rigid bitmap design existing in the prior art.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] In a first aspect, the present invention provides a method for avoiding protocol frame header conflicts, which is applied to the sending end of data communication. The method includes:
[0008] Detect the conflicting data in the original data frame, and replace the conflicting data with replacement data to obtain a first data frame; the conflicting data are the data blocks in the original data frame that are the same as the frame header bytes except for the data block corresponding to the frame header.
[0009] Determine the conflict rate of the original data frame according to the quantity of the conflicting data and the total quantity of data blocks in the original data frame.
[0010] Dynamically select a single-layer bitmap structure or a multi-layer bitmap structure according to the magnitude of the conflict rate, and generate a bitmap annotation for indicating the positions of all the conflicting data; the single-layer bitmap structure directly marks the positions of the conflicting data in the original data frame; in the multi-layer bitmap structure, the original data frame is divided layer by layer, and the hierarchical structure is used to mark the positions of the conflicting data within each layer in turn.
[0011] Add a corresponding hierarchical identifier to the head of the obtained bitmap annotation, and add a check bit to the end to obtain a complete bitmap.
[0012] Add the complete bitmap to the end of the first data frame to obtain a second data frame.
[0013] In a possible implementation manner, the bitmap annotation includes a single-layer bitmap annotation and a multi-layer bitmap annotation; dynamically selecting a single-layer bitmap structure or a multi-layer bitmap structure according to the magnitude of the conflict rate and generating a bitmap annotation for indicating the positions of all the conflicting data specifically includes:
[0014] When the conflict rate is less than a first threshold, select a single-layer bitmap structure, and use each bit of the marking data of the single-layer bitmap structure to mark whether each corresponding data block in the original data frame is conflicting data to obtain a single-layer annotation.
[0015] When the conflict rate is greater than or equal to the first threshold, select a multi-layer bitmap structure, use a hierarchical structure, and use each bit of the marking data of each layer to mark the positions of the conflicting data within this layer to generate a multi-layer annotation.
[0016] In a possible implementation manner, the multi-layer bitmap structure includes a two-layer bitmap structure and a three-layer bitmap structure; when the conflict rate is greater than or equal to the first threshold, selecting a multi-layer bitmap structure specifically includes:
[0017] When the conflict rate is greater than or equal to the first threshold and at the same time less than a second threshold, select the two-layer bitmap structure.
[0018] When the conflict rate is greater than or equal to the second threshold, select the three-layer bitmap structure.
[0019] In a possible implementation, when the two-layer bitmap structure is selected, the marking data includes first-layer marking data and second-layer marking data, and the generated multi-layer annotation is a two-layer annotation; using each bit of the marking data of each layer to mark the position of the conflict data within this layer to generate a multi-layer annotation, specifically including:
[0020] Using each bit of the first-layer marking data of the two-layer bitmap structure to mark whether each data segment in the original data frame contains conflict data; each original data frame includes multiple data segments, and each data segment includes multiple data blocks;
[0021] Using each bit of the second-layer marking data of the two-layer bitmap structure to mark whether each data block in the data segment containing conflict data is conflict data, obtaining a two-layer annotation.
[0022] In a possible implementation, when the three-layer bitmap structure is selected, the marking data includes first-layer marking data, second-layer marking data, and third-layer marking data, and the generated multi-layer annotation is a three-layer annotation; using each bit of the marking data of each layer to mark the position of the conflict data within this layer to generate a multi-layer annotation, specifically including:
[0023] Using each bit of the first-layer marking data of the three-layer bitmap structure to mark whether each data segment in the original data frame contains conflict data; each original data frame includes multiple data segments, each of the data segments includes multiple data sub-segments, and each data sub-segment includes multiple data blocks;
[0024] Using each bit of the second-layer marking data of the three-layer bitmap structure to mark whether each data sub-segment in the data segment containing conflict data contains conflict data;
[0025] Using each bit of the third-layer marking data of the three-layer bitmap structure to mark whether each data block in the data sub-segment containing conflict data is conflict data, obtaining a three-layer annotation.
[0026] In a possible implementation, according to the quantity of the conflict data and the total quantity of data blocks of the original data frame, determine the conflict rate of the original data frame, specifically:
[0027] Calculate the ratio of the quantity of the conflict data to the total quantity of data blocks of the original data frame to obtain the conflict rate of the original data frame.
[0028] In a second aspect, the present invention provides a method for avoiding protocol frame header conflicts, which is applied to the receiving end of data communication. The method includes:
[0029] Receive a second data frame including a first data frame and a complete bitmap; the first data frame is a data frame obtained by replacing the conflicting data in the original data frame with replacement data; the conflicting data is the data blocks in the original data frame that are the same as the frame header bytes except for the data block corresponding to the frame header; the complete bitmap includes a layer identifier, a bitmap annotation, and a check bit set in sequence;
[0030] Determine the data parsing method as a single-layer parsing method corresponding to a single-layer bitmap structure or a multi-layer parsing method corresponding to a multi-layer bitmap structure according to the layer identifier; the single-layer bitmap structure directly marks the positions of the conflicting data in the original data frame; in the multi-layer bitmap structure, the original data frame is divided layer by layer, and the hierarchical structure is used to mark the positions of the conflicting data in each layer in sequence;
[0031] According to the determined data parsing method, combine the bitmap annotation to parse and obtain the conflict positions of the conflicting data in the original data frame; the bitmap annotation is generated based on the single-layer bitmap structure or the multi-layer bitmap structure;
[0032] Replace the data block corresponding to the conflict position in the first data frame with the frame header byte to obtain the restored original data frame;
[0033] After determining that the check bit conforms to the preset check data, output the restored original data frame.
[0034] In a third aspect, the present invention provides a device for avoiding protocol frame header conflicts, which is applied to the sending end of data communication. The device includes:
[0035] A detection and processing module, configured to detect the conflicting data in the original data frame and replace the conflicting data with replacement data to obtain a first data frame; the conflicting data is the data blocks in the original data frame that are the same as the frame header bytes except for the data block corresponding to the frame header;
[0036] A conflict frequency calculation module, configured to determine the conflict rate of the original data frame according to the quantity of the conflicting data and the total quantity of data blocks in the original data frame;
[0037] A first bitmap generation module, configured to dynamically select a single-layer bitmap structure or a multi-layer bitmap structure according to the size of the conflict rate, and generate a bitmap annotation for indicating the positions of all conflicting data; the single-layer bitmap structure directly marks the positions of the conflicting data in the original data frame; in the multi-layer bitmap structure, the original data frame is divided layer by layer, and the hierarchical structure is used to mark the positions of the conflicting data in each layer in sequence;
[0038] A second bitmap generation module, configured to add a corresponding layer identifier to the head of the obtained bitmap annotation and add a check bit to the end to obtain a complete bitmap;
[0039] A data bitmap synthesis module, configured to add the complete bitmap to the end of the first data frame to obtain a second data frame.
[0040] In a possible implementation, the bitmap annotation includes single-layer bitmap annotation and multi-layer bitmap annotation; the first bitmap generation module is specifically configured to perform:
[0041] When the conflict rate is less than the first threshold, select a single-layer bitmap structure, and use each bit of the marked data of the single-layer bitmap structure to mark whether each data block corresponding to the original data frame is conflict data, to obtain a single-layer annotation;
[0042] When the conflict rate is greater than or equal to the first threshold, select a multi-layer bitmap structure, use a hierarchical structure, and use each bit of the marked data of each layer to mark the position of the conflict data within this layer, to generate a multi-layer annotation.
[0043] In a possible implementation, the multi-layer bitmap structure includes a two-layer bitmap structure and a three-layer bitmap structure; when selecting a multi-layer bitmap structure when the conflict rate is greater than or equal to the first threshold, the first bitmap generation module is specifically configured to perform:
[0044] When the conflict rate is greater than or equal to the first threshold and less than the second threshold, select the two-layer bitmap structure;
[0045] When the conflict rate is greater than or equal to the second threshold, select the three-layer bitmap structure.
[0046] In a possible implementation, when the two-layer bitmap structure is selected, the marked data includes first-layer marked data and second-layer marked data, and the generated multi-layer annotation is a two-layer annotation; when using each bit of the marked data of each layer to mark the position of the conflict data within this layer to generate a multi-layer annotation, the first bitmap generation module is specifically configured to perform:
[0047] Use each bit of the first-layer marked data of the two-layer bitmap structure to mark whether each data segment in the original data frame contains conflict data; each original data frame includes multiple data segments, and each data segment includes multiple data blocks;
[0048] Use each bit of the second-layer marked data of the two-layer bitmap structure to mark whether each data block in the data segment containing conflict data is conflict data, to obtain a two-layer annotation.
[0049] In a possible implementation, when the three-layer bitmap structure is selected, the marking data includes first-layer marking data, second-layer marking data, and third-layer marking data, and the generated multi-layer annotation is a three-layer annotation; when using each bit of the marking data of each layer to mark the position of the conflict data within this layer to generate the multi-layer annotation, the first bitmap generation module is specifically configured to execute:
[0050] Use each bit of the first-layer marking data of the three-layer bitmap structure to mark whether each data segment in the original data frame contains conflict data; each original data frame includes multiple data segments, each of the data segments includes multiple data sub-segments, and each data sub-segment includes multiple data blocks;
[0051] Use each bit of the second-layer marking data of the three-layer bitmap structure to mark whether each data sub-segment in the data segment containing conflict data contains conflict data;
[0052] Use each bit of the third-layer marking data of the three-layer bitmap structure to mark whether each data block in the data sub-segment containing conflict data is conflict data, so as to obtain a three-layer annotation.
[0053] In a possible implementation, the conflict frequency calculation module is specifically configured to execute:
[0054] Calculate the ratio of the number of the conflict data to the total number of data blocks of the original data frame to obtain the conflict rate of the original data frame.
[0055] Fourthly, the present invention provides an electronic device, which includes a processor and a memory. At least one instruction, at least one program, a code set or an instruction set is stored in the memory. The at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the method for avoiding protocol frame header conflicts as described in any one of the above.
[0056] Fifthly, the present invention provides a computer-readable storage medium, in which at least one instruction, at least one program, a code set or an instruction set is stored. The at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the method for avoiding protocol frame header conflicts as described in any one of the above.
[0057] In practical applications, the method for avoiding protocol frame header conflicts provided by the embodiments of the present invention detects conflict data in the original data frame to be sent that is the same as the frame header bytes at the sending end of data communication, and replaces the conflict data with pre-designed replacement data to obtain a first data frame; secondly, determines the conflict rate according to the data volume of the conflict data and the original data frame; thirdly, dynamically selects a single-layer bitmap structure or a multi-layer bitmap structure according to the size of the conflict rate to generate a bitmap annotation used to represent the position of the conflict data in the original data frame; then, adds a layer identifier to the head of the bitmap annotation and a check bit to the end to obtain a complete bitmap; finally, splices the complete bitmap to the end of the first data frame to obtain a second data frame; the receiving end restores the original data frame efficiently according to the complete bitmap. The present invention replaces the conflict data in the original data frame with replacement data, and uses the complete bitmap to mark the replacement position of the conflict data, where the generation of the bitmap can dynamically select an appropriate bitmap structure according to the frequency of the conflict data; that is to say, the present invention effectively improves the data transmission rate, reduces the data processing complexity and processing delay, and improves the reliability and flexibility of data transmission through an intelligent multi-layer bitmap design scheme of dynamic division of labor, context awareness, and adaptive threshold adjustment. Description of the Drawings
[0058] Figure 1 It is a flowchart of the method steps of a method for avoiding protocol frame header conflicts provided by the embodiments of the present invention and applied to the sending end of serial communication;
[0059] Figure 2 It is a flowchart of the method steps of a method for avoiding protocol frame header conflicts provided by the embodiments of the present invention and applied to the receiving end of serial communication;
[0060] Figure 3 It is a block diagram of the device structure of a device for avoiding protocol frame header conflicts provided by the embodiments of the present invention and applied to the sending end of serial communication. Detailed Embodiments
[0061] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0062] Hereinafter, the terms "first" and "second" are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the embodiments of the present disclosure, unless otherwise specified, the meaning of "a plurality" is two or more. Additionally, the use of "based on" or "in accordance with" implies openness and inclusivity, because a process, step, calculation, or other action based on or in accordance with one or more of the stated conditions or values may, in practice, be based on additional conditions or values beyond those stated.
[0063] In the prior art, the core of a private protocol fault tolerance processing method based on serial communication disclosed in the patent with the publication number CN114337915A lies in: the data sender identifies a byte sequence identical to the frame header in the data area or the cyclic redundancy check code, and the identified byte sequence is called a pseudo-frame header; the pseudo-frame header is replaced with predefined replacement data to obtain a second data frame; a single-layer bitmap is used to mark the replacement position in the frame header check data. For example, the position of the replacement data is represented by 1, and the positions of the remaining data are represented by 0; the receiving end restores the pseudo-frame header according to the frame header check data.
[0064] Although the above processing method can prevent misjudgment of the frame header in specific scenarios, there are still problems such as low transmission efficiency, high processing complexity, long processing delay, insufficient robustness, and rigid bitmap design.
[0065] Among them, low transmission efficiency means that the frame header check data using bit stuffing or byte stuffing will increase additional data volume and reduce bandwidth utilization. That is to say, the addition of replacement data and the single-layer bitmap structure will further increase the length of the data packet. Especially when frame header data conflicts are frequent, the bit-by-bit marking method of the single-layer bitmap has low transmission efficiency during the transmission of long data packets, and the impact on transmission efficiency is more serious.
[0066] High processing complexity means that the sender needs to monitor and replace data in real time, and the receiver needs to decode and restore it, increasing the computational burden. That is to say, the bit-by-bit marking method of the single-layer bitmap has a heavier computational burden for monitoring, replacing, and decoding during the transmission of long data packets.
[0067] Long processing delay means that the processes of filling, replacing, and decoding will introduce additional processing time and are not suitable for applications in low-latency scenarios.
[0068] Insufficient robustness means that the filling information or check data in a noisy channel may be lost due to transmission errors, resulting in failure to restore the data packet, and the prior art cannot solve the problems of misjudgment or tampering of the bitmap itself.
[0069] Bitmap design rigidity refers to the situation where only a fixed single - layer bitmap structure is used during data transmission, and it cannot be adjusted according to the characteristics of data packets or channel conditions, resulting in poor signal transmission efficiency in high - conflict or low - conflict scenarios.
[0070] To solve the problems of low data - transmission efficiency, high processing complexity, long processing delay, insufficient robustness, and bitmap design rigidity existing in the prior art, embodiments of the present invention provide a method, apparatus, device, and storage medium for avoiding protocol - frame - header conflicts.
[0071] As Figure 1 shown, in one embodiment of the present invention, a method for avoiding protocol - frame - header conflicts is provided, which is applied to the sending end of data communication. The data - communication methods include serial - port communication, network communication, local - area - network communication, wireless communication, and industrial communication, etc.
[0072] The method includes:
[0073] Step 101: Detect the conflicting data in the original data frame, and replace the conflicting data with replacement data to obtain a first data frame.
[0074] Among them, the conflicting data is the data block in the original data frame that is the same as the frame - header byte except for the data block corresponding to the frame header.
[0075] Specifically, the original data frame refers to the data packet to be sent, and this data packet contains frame - header bytes. In step 101, the byte content of each data block in the original data frame is detected in sequence. After detecting the conflicting data that is the same as the frame - header byte, the conflicting data is replaced with predefined replacement data to obtain a first data frame. For example: the frame - header data is AA 55, and the predefined replacement data is AB 54. After detecting the conflicting data, AA 55 is replaced with AB 54.
[0076] Step 102: Determine the conflict rate of the original data frame according to the number of conflicting data and the total number of data blocks in the original data frame.
[0077] Among them, the conflict rate refers to the percentage of the number of conflicting data in the total number of data blocks in the original data frame.
[0078] In order to solve the problem of frame - header misjudgment while improving the flexibility and self - adaptability of the communication protocol, the data - transmission scenarios can be divided according to the size of the conflict rate. For example, the data - transmission scenarios can be divided into two scenarios: high - conflict and low - conflict, or into three scenarios: high - conflict, medium - conflict, and low - conflict. Then, different bitmap structures are designed for different conflict scenarios.
[0079] Step 103: Dynamically select a single-layer bitmap structure or a multi-layer bitmap structure according to the conflict rate, and generate a bitmap annotation for representing the locations of all conflict data.
[0080] Among them, the single-layer bitmap structure directly marks the locations of conflict data in the original data frame.
[0081] In the multi-layer bitmap structure, the original data frame is divided layer by layer, and a hierarchical structure is used to mark the locations of conflict data within each layer in sequence.
[0082] Specifically, the single-layer bitmap structure is applicable to scenarios with sparse conflicts. It directly marks whether each data block in the original data frame is conflict data, which is simple and efficient.
[0083] The multi-layer bitmap structure divides the original data frame into multiple layers according to the actual needs of users, and uses a hierarchical marking method to mark the locations of conflict data in each layer of the original data frame, thereby optimizing the length of the bitmap. The number of layers divided by the multi-layer bitmap structure can be designed according to the conflict rate. When the conflict rate is relatively large, the number of layers divided by the multi-layer bitmap structure can be appropriately increased. That is to say, the multi-layer bitmap structure is applicable to scenarios with concentrated conflicts. By using the hierarchical structure to first mark the data segments with concentrated conflicts, and then mark the specific locations of conflict data within the marked data segments, the total length of the bitmap can be shortened.
[0084] Specifically, the frequency of occurrence of conflict data is reflected by the conflict rate. The larger the conflict rate, the more frequent the occurrence of conflict data. During the actual data transmission process, a single-layer bitmap structure or a multi-layer bitmap structure is dynamically selected according to the conflict rate to generate a bitmap annotation, so as to ensure the best transmission efficiency in different conflict scenarios.
[0085] Step 104: Add the corresponding hierarchical identifier to the head of the obtained bitmap annotation, and add a check bit at the end to obtain a complete bitmap.
[0086] Specifically, the hierarchical identifier is used to distinguish the bitmap structure corresponding to the bitmap annotation, and different hierarchical bitmap structures correspond to different hierarchical identifiers.
[0087] Specifically, 2-bit hierarchical identifiers are used to distinguish the bitmap structures corresponding to the bitmap annotations. For example, 00, 01, and 10 are used to represent the single-layer bitmap structure, the two-layer bitmap structure, and the three-layer bitmap structure respectively.
[0088] The check bit is mainly used for data verification at the data receiving end to improve the accuracy of data transmission.
[0089] Step 105: Add the complete bitmap to the end of the first data frame to obtain the second data frame.
[0090] Specifically, the complete bitmap is spliced at the end of the first data frame, and the obtained second data is transmitted.
[0091] In practical applications, the method for avoiding protocol frame header conflicts provided by the embodiments of the present invention detects the conflict data identical to the frame header byte in the original data frame to be sent at the sending end of data communication, and replaces the conflict data with pre-designed replacement data to obtain the first data frame; secondly, determines the conflict rate according to the data volume of the conflict data and the original data frame; thirdly, dynamically selects a single-layer bitmap structure or a multi-layer bitmap structure according to the size of the conflict rate to generate a bitmap annotation for indicating the positions of the conflict data in the original data frame; then, adds a layer identifier to the head of the bitmap annotation and a check bit to the end to obtain the complete bitmap; finally, splices the complete bitmap at the end of the first data frame to obtain the second data frame; the receiving end efficiently restores the original data frame according to the complete bitmap.
[0092] The present invention replaces the conflict data in the original data frame with replacement data, and uses the complete bitmap to mark the replacement positions of the conflict data, wherein the generation of the bitmap can dynamically select an appropriate bitmap structure according to the frequency of the conflict data.
[0093] That is to say, the present invention effectively improves the data transmission rate, reduces the data processing complexity and processing delay, and improves the reliability and flexibility of data transmission through an intelligent multi-layer bitmap design scheme of dynamic division of labor, context awareness and adaptive threshold adjustment.
[0094] Further, the bitmap annotation includes a single-layer bitmap annotation and a multi-layer bitmap annotation. In step 103, a single-layer bitmap structure or a multi-layer bitmap structure is dynamically selected according to the size of the conflict rate to generate a bitmap annotation for indicating the positions of all conflict data, specifically including:
[0095] Step 1031: Select a single-layer bitmap structure when the conflict rate is less than the first threshold, and use each bit of the marker data of the single-layer bitmap structure to mark whether each data block corresponding to the original data frame is conflict data, so as to obtain a single-layer annotation.
[0096] Specifically, when the conflict rate is less than the first threshold, it is a low-conflict scenario. In a scenario with sparse conflicts, a single-layer bitmap structure is selected. The length of the marker data is equal to the total number of data blocks of the original data frame, and each bit of the marker data corresponds to a data block of the original data frame in sequence. The value of each bit of the marker data is used to indicate whether the corresponding data block is conflict data. For example: when a data block in the original data frame is conflict data, the bit of the marker data corresponding to this data block is represented by 1, otherwise it is represented by 0.
[0097] Step 1032: When the conflict rate is greater than or equal to the first threshold, select a multi-layer bitmap structure. Use a hierarchical structure, and use each bit of the marking data in each layer to mark the position of the conflicting data within this layer, generating multi-layer annotations.
[0098] Specifically, when the conflict rate is greater than or equal to the first threshold, it is regarded as a conflict concentration scenario. In this scenario, select a multi-layer bitmap structure, and optimize the bitmap length and parsing efficiency according to the conflict characteristics of the data. The number of layers of the marking data is the same as the number of layers of the multi-layer bitmap structure, and the number of bits of the marking data in each layer is the same as the number of segments into which the data is divided in this layer; for the marking data in each layer, use the value of each bit of the marking data in this layer to represent whether the corresponding data segment includes conflicting data. For example: for the marking data in a certain layer, if a data segment within this layer contains conflicting data, the bit of the marking data corresponding to this data segment is represented by 1, otherwise it is represented by 0.
[0099] Furthermore, the multi-layer bitmap structure includes a two-layer bitmap structure and a three-layer bitmap structure. When the conflict rate is greater than or equal to the first threshold, selecting a multi-layer bitmap structure specifically includes:
[0100] When the conflict rate is greater than or equal to the first threshold and less than the second threshold, select a two-layer bitmap structure.
[0101] When the conflict rate is greater than or equal to the second threshold, select a three-layer bitmap structure.
[0102] Specifically, the magnitudes of the first threshold and the second threshold can be adjusted according to user requirements.
[0103] In the embodiments of the present invention, the first threshold is taken as 5%, and the second threshold is taken as 15%.
[0104] When the conflict rate < 5%, select a single-layer bitmap structure; when 5% ≤ conflict rate < 15%, select a two-layer bitmap structure in the multi-layer bitmap structure; when the conflict rate ≥ 15%, select a three-layer bitmap structure in the multi-layer bitmap structure.
[0105] In this embodiment, taking 1 byte for each data block as an example, the bitmap designs in different conflict scenarios are as
[0106] shown in Table 1:
[0107]
[0108] Table 1 Bitmap design table for low conflict, medium conflict, and high conflict scenarios
[0109] As can be seen from Table 1, in the low conflict scenario where the conflict rate < 5%, the length of the marking data by the single-layer bitmap structure is equal to the number of data blocks, each bit of the marking data corresponds to a data block, and the total length of the generated bitmap annotation is fixed.
[0110] In the medium conflict scenario where 5% ≤ conflict rate < 15%, the first layer of marker data in the two-layer bitmap structure is used to mark the data segment containing the conflict data, and the second layer of marker data is used to mark the specific position of the conflict data in the marked data segment, and the bitmap length is optimized.
[0111] In the high conflict scenario where the conflict rate ≥ 15%, the first layer of marker data in the three-layer bitmap structure is used to mark the data segment containing the conflict data, the second layer of marker data is used to mark the position of the small data segment containing the conflict data in the marked data segment, and the third layer of marker data is used to mark the position of the conflict data in the marked small data segment, balancing the bitmap length and the parsing complexity.
[0112] Furthermore, when selecting the two-layer bitmap structure, the marker data includes the first layer of marker data and the second layer of marker data, and the generated multi-layer annotation is a two-layer annotation.
[0113] Using each bit of the marker data in each layer to mark the position of the conflict data within this layer, a multi-layer annotation is generated, specifically including:
[0114] Using each bit of the first layer of marker data in the two-layer bitmap structure to mark whether each data segment in the original data frame contains conflict data.
[0115] Among them, each original data frame includes multiple data segments, and each data segment includes multiple data blocks.
[0116] Using each bit of the second layer of marker data in the two-layer bitmap structure to mark whether each data block in the data segment containing the conflict data is conflict data, obtaining a two-layer annotation.
[0117] Specifically, taking the conflict rate greater than or equal to the first threshold and less than the second threshold as the medium conflict scenario, in this conflict scenario, a two-layer bitmap structure is adopted.
[0118] The length of the first layer of marker data is the same as the length of the data segment, and each bit of the first layer of marker data corresponds to a data segment in sequence. The value of each bit of the first layer of marker data is used to indicate whether the corresponding data segment contains conflict data. If it contains, it is represented by 1, otherwise it is represented by 0.
[0119] The length of the second layer of marker data is equal to the total number of data blocks in the data segment containing the conflict data, and each bit of the second layer of marker data corresponds to a data block in the data segment containing the conflict data in sequence. The value of each bit of the second layer of marker data is used to indicate whether the corresponding data block is conflict data. If it is conflict data, it is represented by 1, otherwise it is represented by 0.
[0120] Furthermore, when selecting the three-layer bitmap structure, the marker data includes the first layer of marker data, the second layer of marker data and the third layer of marker data, and the generated multi-layer annotation is a three-layer annotation.
[0121] Use each bit of the marking data of each layer to mark the position of the conflicting data within this layer, generating multi-layer annotations, specifically including:
[0122] Use each bit of the marking data of the first layer of the three-layer bitmap structure to mark whether each data segment in the original data frame contains conflicting data.
[0123] Wherein, each original data frame includes multiple data segments, each data segment includes multiple data sub-segments, and each data sub-segment includes multiple data blocks.
[0124] Use each bit of the marking data of the second layer of the three-layer bitmap structure to mark whether each data sub-segment in the data segment containing conflicting data contains conflicting data.
[0125] Use each bit of the marking data of the third layer of the three-layer bitmap structure to mark whether each data block in the data sub-segment containing conflicting data is conflicting data, obtaining three-layer annotations.
[0126] Specifically, taking the conflict rate being greater than the second threshold as a high-conflict scenario, in this conflict scenario, a three-layer bitmap structure is adopted.
[0127] The length of the marking data of the first layer is the same as the length of the data segment, and each bit of the marking data of the first layer corresponds to a data segment in sequence. Use the value of each bit of the marking data of the first layer to represent whether the corresponding data segment contains conflicting data. If it contains, it is represented by 1, otherwise it is represented by 0.
[0128] The length of the marking data of the second layer is equal to the total amount of data sub-segments in the data segment containing conflicting data, and each bit of the marking data of the second layer corresponds to a data sub-segment in the data segment containing conflicting data in sequence. Use the value of each bit of the marking data of the second layer to represent whether the corresponding data sub-segment contains conflicting data. If it contains, it is represented by 1, otherwise it is represented by 0.
[0129] The length of the marking data of the third layer is equal to the total amount of data blocks in the data sub-segment containing conflicting data, and each bit of the marking data of the third layer corresponds to a data block in the data sub-segment containing conflicting data in sequence. Use the value of each bit of the marking data of the third layer to represent whether the corresponding data block is conflicting data. If it is conflicting data, it is represented by 1, otherwise it is represented by 0.
[0130] In the embodiment of the present invention, assume that the length of a data packet is 64 bytes, wherein the frame header data is AA 55, accounting for 2 bytes, and the remaining 62 bytes are the data part. Define the size of each data block as 2 bytes, so the data part contains 31 data blocks.
[0131] Detect the number of conflicting data in 31 data blocks of the detection data part, determine the conflict rate according to the number of conflicting data and the total number of data blocks, and divide the data transmission scenario into a low-conflict scenario, a medium-conflict scenario, and a high-conflict scenario according to the magnitude of the conflict rate.
[0132] In the first scenario, assume that the number of conflicting data is 1, and the position of the conflicting data is the 5th data block.
[0133] According to the ratio of the number of conflicting data to the total number of data blocks, the conflict rate of the first scenario is calculated to be <5%. Therefore, the first scenario is a low-conflict scenario. A single-layer bitmap structure is used, and 31 data blocks are represented by 31 bits, occupying 4 bytes (padding with 0 for insufficient bits); the bit map generated in the first scenario is labeled as: 00001000 00000000 00000000 00000000, indicating that the 5th data block is conflicting data.
[0134] Use 00 to represent the single-layer bitmap structure; the parity check is used for the parity bit. When the number of 1s in the bit map label is odd, the parity bit is 1, and when the number of 1s in the bit map label is even, the parity bit is 0.
[0135] Therefore, the complete bitmap of the first scenario is: 00 00001000 00000000 00000000 000000001.
[0136] In the second scenario, assume that the number of conflicting data is 3, and the positions of the conflicting data are the 2nd, 5th, and 10th data blocks.
[0137] According to the ratio of the number of conflicting data to the total number of data blocks, the conflict rate of the second scenario is calculated to be 5% ≤ conflict rate < 15%. Therefore, the second scenario is a medium-conflict scenario. A two-layer bitmap structure is used. The first layer divides 31 data blocks into 4 data segments, with 8 data blocks in each segment (7 in the last segment), and 4 bits are used to mark the data segments containing conflicting data; the second layer generates an 8-bit bitmap for each data segment containing conflicting data to mark the specific positions of the conflicting data.
[0138] The first-layer bitmap of the second scenario is: 1100, indicating that the first data segment and the second data segment contain conflicting data. The bitmap labeled for the first data segment (the 1st - 8th data blocks) in the second layer is: 01001000, indicating that the 2nd data block and the 5th data block are conflicting data; the bitmap labeled for the second data segment (the 1st - 8th data blocks) in the second layer is: 01000000, indicating that the 10th data block is conflicting data.
[0139] Use 01 to represent the two-layer bitmap structure; the parity bit is used to check the entire bitmap, and it is assumed to be 1 in this embodiment.
[0140] Therefore, the complete bitmap of the first scenario is: 01 1100 01001000 01000000 1.
[0141] In the third scenario, assume that the number of conflicting data is 10, and the positions of the conflicting data are the 1st, 3rd, 5th, 7th, 9th, 11th, 13th, 15th, 17th, and 19th data blocks.
[0142] According to the ratio of the number of conflicting data to the total number of data blocks, the conflict rate of the third scenario is calculated to be ≥15%. Therefore, the third scenario is a high-conflict scenario. A three-layer bitmap structure is used. The first layer divides 31 data blocks into 2 data segments, with 16 data blocks in each segment (15 in the last segment), and 2 bits are used to mark the data segments containing conflicting data; the second layer divides the data segments containing conflicting data into 4 data sub-segments, with 4 data blocks in each sub-segment, and 4 bits are used to mark the data sub-segments containing conflicting data; the third layer generates a 4-bit bitmap for the data sub-segments containing conflicting data to mark the specific positions of the conflicting data.
[0143] The first-layer bitmap of the second scenario is: 11, indicating that both data segments contain conflicting data. The bitmap marked for the first data segment (the 1st to 16th data blocks) in the second layer is: 1111, indicating that all data sub-segments in the first data segment contain conflicting data; the bitmap marked for the second data segment (the 17th to 31st data blocks) in the second layer is: 1000, indicating that only the first data sub-segment in the second data segment contains conflicting data. The bitmap marked for the first data sub-segment (the 1st to 4th data blocks) in the third layer of the first data segment is: 1010, indicating that the 1st and 3rd data blocks are conflicting data; the bitmap marked for the second data sub-segment (the 5th to 8th data blocks) in the third layer of the first data segment is: 1010, indicating that the 5th and 7th data blocks are conflicting data; the bitmap marked for the third data sub-segment (the 9th to 12th data blocks) in the third layer of the first data segment is: 1010, indicating that the 9th and 11th data blocks are conflicting data; the bitmap marked for the fourth data sub-segment (the 13th to 16th data blocks) in the third layer of the first data segment is: 1010, indicating that the 13th and 15th data blocks are conflicting data; the bitmap marked for the first data sub-segment (the 17th to 20th data blocks) in the third layer of the second data segment is: 1010, indicating that the 17th and 19th data blocks are conflicting data.
[0144] Use 10 to represent the three-layer bitmap structure; the check bit is used to check the entire bitmap, and it is assumed to be 0 in this embodiment.
[0145] Therefore, the complete bitmap of the third scenario is: 10 11 1111 1000 1010 1010 1010 1010 10100.
[0146] The specific values and structures of the bitmaps in the above three scenarios are shown in Table 2:
[0147]
[0148] Table 2 Specific values and structure table of bitmaps in low-conflict, medium-conflict, and high-conflict scenarios
[0149] As can be seen from Table 2, the present invention dynamically adjusts the bitmap level according to the conflict rate. A single-layer bitmap is used in the low-conflict scenario, which is simple and direct; a two-layer bitmap is adopted in the medium-conflict scenario to reduce the bitmap length; a three-layer bitmap is used in the high-conflict scenario to further optimize the representation efficiency of the bitmap. This method balances the bitmap length and parsing complexity in different situations and improves the efficiency of data transmission and processing.
[0150] Furthermore, in step 102, according to the number of conflict data and the total number of data blocks in the original data frame, the conflict rate of the original data frame is determined, specifically:
[0151] Calculate the ratio of the number of conflict data to the total number of data blocks in the original data frame to obtain the conflict rate of the original data frame.
[0152] As Figure 2 shown, in another embodiment of the present invention, a method for avoiding protocol frame header conflicts is provided, which is applied to the receiving end of data communication. The method includes:
[0153] Step 201: Receive a second data frame including a first data frame and a complete bitmap.
[0154] Wherein, the first data frame is a data frame obtained by replacing the conflict data in the original data frame with replacement data.
[0155] The conflict data are the data blocks in the original data frame that are the same as the frame header bytes except for the data blocks corresponding to the frame header.
[0156] The complete bitmap includes a level identifier, a bitmap annotation, and a check bit set in sequence.
[0157] Step 202: Determine the data parsing method as a single-layer parsing method corresponding to the single-layer bitmap structure or a multi-layer parsing method corresponding to the multi-layer bitmap structure according to the level identifier.
[0158] Wherein, the single-layer bitmap structure directly marks the positions of the conflict data in the original data frame.
[0159] In the multi-layer bitmap structure, the original data frame is divided layer by layer, and the hierarchical structure is used to mark the positions of the conflict data in each layer in sequence.
[0160] Step 203: According to the determined data parsing method, combine the bitmap annotation to parse and obtain the conflict positions of the conflict data in the original data frame.
[0161] Among them, the bit map annotation is generated based on a single-layer bitmap structure or a multi-layer bitmap structure.
[0162] Step 204: Replace the data block corresponding to the conflict position in the first data frame with the frame header byte to obtain the restored original data frame.
[0163] Step 205: After determining that the check bit conforms to the preset check data, output the restored original data frame.
[0164] In the embodiment of the present invention, after the receiving end receives the second data frame, it first disassembles the second data frame into a first data frame and a complete bitmap.
[0165] Secondly, read the layer identifier at the head of the complete bitmap, and determine the bitmap structure according to the layer identifier. For example: read 2 bits at the head of the complete bitmap to determine the bitmap structure. When the read layer identifiers are 00, 01, and 10 respectively, the corresponding bitmap structures are a single-layer bitmap structure, a two-layer bitmap structure, and a three-layer bitmap structure.
[0166] Thirdly, parse the bit map annotation of the complete bitmap according to the data parsing method corresponding to the identified bitmap structure to determine the position of the conflicting data.
[0167] For example: when the identified bitmap structure is a single-layer bitmap structure, directly read the bit map annotation, and determine the position of the conflicting data according to the position of 1 in the bit map annotation.
[0168] When the identified bitmap structure is a two-layer bitmap structure, first parse the first-layer data of the bit map annotation to determine the data segment containing the conflicting data; then parse the second-layer data of the bit map annotation to determine the position of the conflicting data in the corresponding data segment.
[0169] When the identified bitmap structure is a three-layer bitmap structure, first parse the first-layer data of the bit map annotation to determine the data segment containing the conflicting data; then parse the second-layer data of the bit map annotation to determine the data sub-segment where the conflicting data is located in the data segment; finally parse the third-layer data of the bit map annotation to determine the position of the conflicting data in the corresponding data sub-segment.
[0170] After that, according to the determined position of the conflicting data, that is, the position marked as 1 in the bit map annotation, restore the replacement byte to the frame header byte to obtain the restored original data frame.
[0171] Finally, perform data verification on the restored original data frame in combination with the check bit of the complete bitmap. When the check bit conforms to the preset check data, it is considered that the restored original data frame is the same as the original data frame sent by the sending end, and the restored original data frame is output; otherwise, it is considered that the restored original data frame is different from the original data frame sent by the sending end, and the sending end is requested to retransmit the data.
[0172] The present invention provides an efficient, simple and reliable method for avoiding communication protocol frame header conflicts, which has the advantages of high transmission efficiency, low latency, high reliability and flexible bitmap design.
[0173] Among them, the high transmission efficiency is specifically reflected in that the bitmap occupies few bytes, significantly reducing the data transmission overhead.
[0174] The low latency is specifically reflected in that the replacement and restoration operations are simple, the processing time is short, and it is suitable for high-speed communication scenarios.
[0175] The high reliability is specifically reflected in that by restricting the bitmap values, the risk of misjudgment is further reduced by avoiding the bitmap being the same as the frame header.
[0176] The flexible bitmap design is specifically reflected in that each bit of the bitmap can correspond to data blocks of different lengths (such as 2 bytes or 4 bytes), and the bitmap size can be flexibly adjusted according to the frame header length.
[0177] As Figure 3 shown, in another embodiment of the present invention, a device for avoiding protocol frame header conflicts is provided, which is applied to the sending end of data communication. The device includes:
[0178] A detection and processing module 301, configured to detect conflicting data in the original data frame and replace the conflicting data with replacement data to obtain a first data frame; the conflicting data is the data block in the original data frame that is the same as the frame header byte except for the data block corresponding to the frame header;
[0179] A conflict frequency calculation module 302, configured to determine the conflict rate of the original data frame according to the quantity of the conflicting data and the total quantity of data blocks in the original data frame;
[0180] A first bitmap generation module 303, configured to dynamically select a single-layer bitmap structure or a multi-layer bitmap structure according to the size of the conflict rate, and generate a bitmap annotation for indicating the positions of all conflicting data; the single-layer bitmap structure directly marks the positions of the conflicting data in the original data frame; in the multi-layer bitmap structure, the original data frame is divided layer by layer, and the hierarchical structure is used to mark the positions of the conflicting data in each layer in turn;
[0181] A second bitmap generation module 304, configured to add a corresponding hierarchical identifier to the head of the obtained bitmap annotation and add a check bit to the end to obtain a complete bitmap;
[0182] A data bitmap synthesis module 305, configured to add the complete bitmap to the end of the first data frame to obtain a second data frame.
[0183] Further, the bit map annotation includes single-layer bit map annotation and multi-layer bit map annotation; the first bit map generation module 303 is specifically configured to execute:
[0184] When the conflict rate is less than the first threshold, select a single-layer bit map structure, and use each bit of the marked data of the single-layer bit map structure to mark whether each data block corresponding to the original data frame is conflict data, so as to obtain a single-layer annotation;
[0185] When the conflict rate is greater than or equal to the first threshold, select a multi-layer bit map structure, use a hierarchical structure, and use each bit of the marked data of each layer to mark the position of the conflict data within this layer, so as to generate a multi-layer annotation.
[0186] Further, the multi-layer bit map structure includes a two-layer bit map structure and a three-layer bit map structure; when selecting a multi-layer bit map structure when the conflict rate is greater than or equal to the first threshold, the first bit map generation module 303 is specifically configured to execute:
[0187] When the conflict rate is greater than or equal to the first threshold and less than the second threshold, select the two-layer bit map structure;
[0188] When the conflict rate is greater than or equal to the second threshold, select the three-layer bit map structure.
[0189] Further, when the two-layer bit map structure is selected, the marked data includes first-layer marked data and second-layer marked data, and the generated multi-layer annotation is a two-layer annotation; when using each bit of the marked data of each layer to mark the position of the conflict data within this layer to generate a multi-layer annotation, the first bit map generation module 303 is specifically configured to execute:
[0190] Use each bit of the first-layer marked data of the two-layer bit map structure to mark whether each data segment in the original data frame contains conflict data; each original data frame includes multiple data segments, and each data segment includes multiple data blocks;
[0191] Use each bit of the second-layer marked data of the two-layer bit map structure to mark whether each data block in the data segment containing conflict data is conflict data, so as to obtain a two-layer annotation.
[0192] Further, when the three-layer bit map structure is selected, the marked data includes first-layer marked data, second-layer marked data and third-layer marked data, and the generated multi-layer annotation is a three-layer annotation; when using each bit of the marked data of each layer to mark the position of the conflict data within this layer to generate a multi-layer annotation, the first bit map generation module 303 is specifically configured to execute:
[0193] Each bit of the data in the first layer of the three - layer bitmap structure is used to mark whether each data segment in the original data frame contains conflicting data; each original data frame includes multiple data segments, each of the data segments includes multiple data sub - segments, and each data sub - segment includes multiple data blocks.
[0194] Each bit of the data in the second layer of the three - layer bitmap structure is used to mark whether each data sub - segment in the data segment containing conflicting data contains conflicting data.
[0195] Each bit of the data in the third layer of the three - layer bitmap structure is used to mark whether each data block in the data sub - segment containing conflicting data is conflicting data, obtaining a three - layer annotation.
[0196] Furthermore, the conflict frequency calculation module 302 is specifically configured to execute:
[0197] Calculate the ratio of the quantity of the conflicting data to the total quantity of the data blocks in the original data frame to obtain the conflict rate of the original data frame.
[0198] The device for avoiding protocol frame - header conflicts provided by the embodiments of the present invention is used to execute the method for avoiding protocol frame - header conflicts described above, and thus can achieve the same effect as the method for avoiding protocol frame - header conflicts described above.
[0199] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, and will not be elaborated herein.
[0200] The embodiments of the present invention also provide an electronic device. The electronic device includes a processor and a memory. At least one instruction, at least one program, a code set, or an instruction set is stored in the memory, and the at least one instruction, at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the method for avoiding protocol frame - header conflicts in the embodiments of the present invention.
[0201] The embodiments of the present invention also provide a computer - readable storage medium. At least one instruction, at least one program, a code set, or an instruction set is stored in the storage medium, and the at least one instruction, at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the method for avoiding protocol frame - header conflicts in the embodiments of the present invention.
[0202] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (such as coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that the computer can access or a data storage device such as a server, data center, etc. that contains one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
[0203] As described above, the above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed by the present invention should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims described above.
Claims
1. A method for avoiding protocol frame header conflicts, characterized in that Applied to the sending end of data communication, the method includes: Detecting the conflicting data in the original data frame and replacing the conflicting data with replacement data to obtain a first data frame; the conflicting data is the data block in the original data frame that is the same as the frame header byte except for the data block corresponding to the frame header; Determining the conflict rate of the original data frame according to the quantity of the conflicting data and the total quantity of data blocks in the original data frame; Dynamically selecting a single-layer bitmap structure or a multi-layer bitmap structure according to the magnitude of the conflict rate, and generating a bitmap annotation for indicating the positions where all the conflicting data are located; the single-layer bitmap structure directly marks the positions of the conflicting data in the original data frame; in the multi-layer bitmap structure, the original data frame is divided layer by layer, and the hierarchical structure is used to sequentially mark the positions of the conflicting data within each layer; Adding a corresponding hierarchical identifier to the head of the obtained bitmap annotation and adding a check bit at the end to obtain a complete bitmap; Adding the complete bitmap to the end of the first data frame to obtain a second data frame.
2. The method for avoiding protocol frame header conflicts according to claim 1, wherein, The bitmap annotation includes a single-layer bitmap annotation and a multi-layer bitmap annotation; dynamically selecting a single-layer bitmap structure or a multi-layer bitmap structure according to the magnitude of the conflict rate and generating a bitmap annotation for indicating the positions where all the conflicting data are located specifically includes: Selecting the single-layer bitmap structure when the conflict rate is less than a first threshold, and using each bit of the marking data of the single-layer bitmap structure to mark whether each data block corresponding to the original data frame is conflicting data to obtain a single-layer annotation; Selecting the multi-layer bitmap structure when the conflict rate is greater than or equal to the first threshold, and using the hierarchical structure and using each bit of the marking data of each layer to mark the positions of the conflicting data within this layer to generate a multi-layer annotation.
3. The method for avoiding protocol frame header conflicts according to claim 2, wherein The multi-layer bitmap structure includes a two-layer bitmap structure and a three-layer bitmap structure; dynamically selecting the multi-layer bitmap structure when the conflict rate is greater than or equal to the first threshold specifically includes: Selecting the two-layer bitmap structure when the conflict rate is greater than or equal to the first threshold and at the same time less than a second threshold; Selecting the three-layer bitmap structure when the conflict rate is greater than or equal to the second threshold.
4. The method for avoiding protocol frame header conflicts according to claim 3, wherein When the two-layer bitmap structure is selected, the marking data includes first-layer marking data and second-layer marking data, and the generated multi-layer annotation is a two-layer annotation; using each bit of the marking data of each layer to mark the positions of the conflicting data within this layer to generate a multi-layer annotation specifically includes: Using each bit of the first-layer marking data of the two-layer bitmap structure to mark whether each data segment in the original data frame contains conflicting data; each original data frame includes a plurality of data segments, and each data segment includes a plurality of data blocks; Using each bit of the second-layer marking data of the two-layer bitmap structure to mark whether each data block in the data segment containing conflicting data is conflicting data to obtain a two-layer annotation.
5. The method for avoiding protocol frame header conflicts according to claim 3, characterized in that, When the three-layer bitmap structure is selected, the marking data includes first-layer marking data, second-layer marking data and third-layer marking data, and the generated multi-layer annotation is a three-layer annotation; using each bit of the marking data of each layer to mark the positions of the conflicting data within this layer to generate a multi-layer annotation specifically includes: Each bit of the first layer of the three-layer bitmap structure is used to mark whether each data segment in the original data frame contains conflicting data; each original data frame includes multiple data segments, each of the data segments includes multiple data sub-segments, and each data sub-segment includes multiple data blocks; Each bit of the second layer of the three-layer bitmap structure is used to mark whether each data sub-segment in the data segment containing conflicting data contains conflicting data; Each bit of the third layer of the three-layer bitmap structure is used to mark whether each data block in the data sub-segment containing conflicting data is conflicting data, obtaining a three-layer annotation.
6. The method for avoiding protocol frame header conflicts according to claim 1, wherein According to the quantity of the conflicting data and the total quantity of data blocks of the original data frame, determine the conflict rate of the original data frame, specifically: Calculate the ratio of the quantity of the conflicting data to the total quantity of data blocks of the original data frame, obtaining the conflict rate of the original data frame.
7. A method for avoiding protocol frame header conflicts, characterized in that, Applied to the receiving end of data communication, the method includes: Receiving a second data frame including a first data frame and a complete bitmap; the first data frame is a data frame obtained by replacing the conflicting data in the original data frame with replacement data; the conflicting data are data blocks in the original data frame that are the same as the frame header byte except for the data blocks corresponding to the frame header; the complete bitmap includes a layer identifier, a bit annotation, and a check bit set in sequence; Determine the data parsing method as a single-layer parsing method corresponding to the single-layer bitmap structure or a multi-layer parsing method corresponding to the multi-layer bitmap structure according to the layer identifier; the single-layer bitmap structure directly marks the positions of the conflicting data in the original data frame; in the multi-layer bitmap structure, the original data frame is divided layer by layer, and a hierarchical structure is used to mark the positions of the conflicting data in each layer in sequence; According to the determined data parsing method, combine the bit annotation to parse and obtain the conflict positions of the conflicting data in the original data frame; the bit annotation is generated based on the single-layer bitmap structure or the multi-layer bitmap structure; Replace the data blocks corresponding to the conflict positions in the first data frame with the frame header byte, obtaining the restored original data frame; After determining that the check bit conforms to the preset check data, output the restored original data frame.
8. A device for avoiding protocol frame header conflicts, characterized in that, Applied to the sending end of data communication, the device includes: A detection and processing module, configured to detect the conflicting data in the original data frame, and replace the conflicting data with replacement data, obtaining a first data frame; the conflicting data are data blocks in the original data frame that are the same as the frame header byte except for the data blocks corresponding to the frame header; A conflict frequency calculation module, configured to determine the conflict rate of the original data frame according to the quantity of the conflicting data and the total quantity of data blocks of the original data frame; A first bitmap generation module, configured to dynamically select a single-layer bitmap structure or a multi-layer bitmap structure according to the size of the conflict rate, and generate a bit annotation for indicating the positions of all the conflicting data; the single-layer bitmap structure directly marks the positions of the conflicting data in the original data frame; in the multi-layer bitmap structure, the original data frame is divided layer by layer, and a hierarchical structure is used to mark the positions of the conflicting data in each layer in sequence; The second bitmap generation module adds a corresponding hierarchy identifier to the head of the obtained bitmap annotation and adds a check bit to the end to obtain a complete bitmap; The data bitmap synthesis module is used to add the complete bitmap to the end of the first data frame to obtain a second data frame.
9. An electronic device, characterized in that, The electronic device includes a processor and a memory. At least one instruction, at least one program, a code set or an instruction set is stored in the memory. The at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the method for avoiding protocol frame header conflicts as described in any one of claims 1-6.
10. A computer-readable storage medium, characterized in that, At least one instruction, at least one program, a code set or an instruction set is stored in the storage medium. The at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the method for avoiding protocol frame header conflicts as described in any one of claims 1-6.
Citation Information
Patent Citations
Private protocol fault-tolerant processing method and device based on serial communication and storage medium
CN114337915A
Data transmission method, power line communication device and system
CN116743306A
Communication method and communication device
CN119584318A
Block acknowledgment operation
US20190268099A1