A protocol frame header collision avoidance method, device, equipment and storage medium
By replacing conflicting data in data frames and dynamically selecting bitmap structures to generate bitmap annotations, the problems of frame header misjudgment and low transmission efficiency are solved, achieving efficient and reliable data transmission.
Patent Information
- Application Number
- CN202510615726.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2045-05-14
AI Technical Summary
Existing technologies suffer from problems such as frame header misjudgment, low data transmission efficiency, high processing complexity, long processing delay, insufficient robustness, and rigid bitmap design during data transmission.
By detecting conflicting data in the data frame and replacing the conflicting data with replacement data, the bitmap annotation is dynamically generated by selecting a single-layer or multi-layer bitmap structure, generating bitmap annotations according to the conflict rate, and adding a hierarchy identifier to the bitmap header and a check bit to the end to form a complete bitmap.
It improves data transmission rate, reduces data processing complexity and latency, and enhances the reliability and flexibility of data transmission.
Smart Images

Figure CN120263352B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data transmission technology, and in particular to a method, apparatus, device, and storage medium for avoiding protocol frame header conflicts. Background Technology
[0002] In communication protocols, a frame header is a predefined sequence of bytes used to identify the start of a data frame. However, when the data content contains a byte sequence identical to the frame header, the receiving end may mistakenly identify it as a new frame header, leading to data parsing errors—a case of frame header misinterpretation. To avoid frame header misinterpretation, bit stuffing or byte stuffing is commonly used. Bit stuffing involves inserting extra bits into the data stream to break the pattern similar to the frame header; byte stuffing involves inserting escape characters and modifying data identical to the frame header to avoid misinterpretation. These methods are widely used in serial communication protocols such as HDLC and PPP, ensuring the uniqueness of the frame header by changing the data content.
[0003] In the prior art, patent CN114337915A discloses a fault-tolerant processing method for a proprietary protocol based on serial communication. This method includes: the data sender adding frame header verification data to the end of the original data frame to obtain a first data frame, the first data frame including a frame header, a data area, a CRC checksum, and frame header verification data; replacing the pseudo-frame header in the data area and the CRC checksum with replacement data to obtain a second data frame, and sending the second data frame to the data receiver, the pseudo-frame header data being the same as the frame header data; the data receiver determining whether the frame header verification data of the received data frame meets preset conditions, and if so, restoring 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] While existing technologies can prevent frame header misjudgment in specific scenarios, they still suffer from problems such as low data transmission efficiency, high processing complexity, long processing latency, insufficient robustness, and rigid bitmap design. Summary of the Invention
[0005] This 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 in the prior art.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] In a first aspect, the present invention provides a method for avoiding protocol frame header collisions, applied to the sending end of data communication, the method comprising:
[0008] 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 identical to the frame header bytes except for the data block corresponding to the frame header.
[0009] The collision rate of the original data frame is determined based on the number of conflicting data and the total number of data blocks in the original data frame.
[0010] Based on the magnitude of the conflict rate, a single-layer bitmap structure or a multi-layer bitmap structure is dynamically selected to generate bitmap annotations representing the location of all conflicting data. The single-layer bitmap structure directly marks the position of conflicting data in the original data frame. In the multi-layer bitmap structure, the original data frame is divided layer by layer, and the position of conflicting data in each layer is marked sequentially using a hierarchical structure.
[0011] Add the corresponding hierarchy identifier to the header of the obtained bitmap annotation and add a check bit to the end to obtain the complete bitmap.
[0012] The complete bitmap is added to the end of the first data frame to obtain the second data frame.
[0013] In one possible implementation, the bitmap annotation includes single-layer bitmap annotations and multi-layer bitmap annotations; the single-layer bitmap structure or the multi-layer bitmap structure is dynamically selected according to the magnitude of the collision rate to generate bitmap annotations representing the locations of all conflicting data, specifically including:
[0014] When the conflict rate is less than a first threshold, a single-layer bitmap structure is selected. Each bit of the labeled data in the single-layer bitmap structure is used to mark whether each data block corresponding to the original data frame is conflicting data, thus obtaining a single-layer label.
[0015] When the conflict rate is greater than or equal to the first threshold, a multi-layer bitmap structure is selected. A hierarchical structure is used, and each bit of the labeled data in each layer is used to mark the position of the conflicting data in the current layer, thereby generating multi-layer annotations.
[0016] In one possible implementation, the multi-layer bitmap structure includes a two-layer bitmap structure and a three-layer bitmap structure; selecting the multi-layer bitmap structure when the conflict rate is greater than or equal to the first threshold specifically includes:
[0017] When the conflict rate is greater than or equal to the first threshold and less than the second threshold, the two-layer bitmap structure is selected.
[0018] When the conflict rate is greater than or equal to the second threshold, the three-layer bitmap structure is selected.
[0019] In one possible implementation, when the two-layer bitmap structure is selected, the marker data includes first-layer marker data and second-layer marker data, and the generated multi-layer annotation is a two-layer annotation; each bit of the marker data in each layer is used to mark the position of conflicting data within the same layer to generate multi-layer annotation, specifically including:
[0020] Each bit of the first layer of the two-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, and each data segment includes multiple data blocks.
[0021] Each bit of the second-level labeling data in the two-level bitmap structure is used to mark whether each data block in the data segment containing conflicting data is conflicting data, thus obtaining the two-level labeling.
[0022] In one possible implementation, when the three-layer bitmap structure is selected, the marker data includes first-layer marker data, second-layer marker data, and third-layer marker data, and the generated multi-layer annotation is a three-layer annotation; using each bit of the marker data in each layer to mark the position of conflicting data within the same layer, multi-layer annotation is generated, specifically including:
[0023] 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 data segment includes multiple data sub-segments, and each data sub-segment includes multiple data blocks;
[0024] Each bit of the second layer of the three-layer bitmap structure is used to mark whether each data segment in the data segment containing conflicting data contains conflicting data;
[0025] Each bit of the third layer of the three-layer bitmap structure is used to mark whether each data block in a data segment containing conflicting data is conflicting data, thus obtaining a three-layer label.
[0026] In one possible implementation, the collision rate of the original data frame is determined based on the number of conflicting data and the total number of data blocks in the original data frame, specifically as follows:
[0027] The collision rate of the original data frame is obtained by calculating the ratio of the number of conflicting data to the total number of data blocks in the original data frame.
[0028] Secondly, the present invention provides a method for avoiding protocol frame header collisions, applied at the receiving end of data communication, the method comprising:
[0029] Receive a second data frame containing a first data frame and a complete bitmap; the first data frame is a data frame after replacing conflicting data in the original data frame with replacement data; the conflicting data is a data block in the original data frame that is identical to the frame header bytes except for the data block corresponding to the frame header; the complete bitmap includes a hierarchy identifier, a bitmap annotation, and a check bit set sequentially.
[0030] The data parsing method is determined based on the hierarchical identifier as either 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; the single-layer bitmap structure directly marks the position of 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 position of conflicting data in each layer in turn;
[0031] Based on the determined data parsing method, the conflict position of the conflicting data in the original data frame is obtained by parsing the bitmap annotations; the bitmap annotations are 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 confirming that the check bit matches the preset check data, the restored original data frame is output.
[0034] Thirdly, the present invention provides a protocol frame header collision avoidance device, applied at the transmitting end of data communication, the device comprising:
[0035] The detection and processing module is used 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 a data block in the original data frame that is identical to the frame header bytes except for the data block corresponding to the frame header.
[0036] The collision frequency calculation module is used to determine the collision rate of the original data frame based on the number of conflicting data and the total number of data blocks in the original data frame;
[0037] The first bitmap generation module is used to dynamically select a single-layer bitmap structure or a multi-layer bitmap structure according to the magnitude of the conflict rate, and generate bitmap annotations to represent the location of all conflicting data; the single-layer bitmap structure directly marks the position of conflicting data in the original data frame; in the multi-layer bitmap structure, the original data frame is divided layer by layer, and the position of conflicting data in each layer is marked sequentially using a hierarchical structure.
[0038] The second bitmap generation module adds a corresponding level identifier to the header of the obtained bitmap annotation and a check bit to the end to obtain a complete bitmap.
[0039] A data bitmap composition module is used to add the complete bitmap to the end of the first data frame to obtain a second data frame.
[0040] In one possible implementation, the bitmap annotation includes single-layer bitmap annotations and multi-layer bitmap annotations; the first bitmap generation module is specifically configured to execute:
[0041] When the conflict rate is less than a first threshold, a single-layer bitmap structure is selected. Each bit of the labeled data in the single-layer bitmap structure is used to mark whether each data block corresponding to the original data frame is conflicting data, thus obtaining a single-layer label.
[0042] When the conflict rate is greater than or equal to the first threshold, a multi-layer bitmap structure is selected. A hierarchical structure is used, and each bit of the labeled data in each layer is used to mark the position of the conflicting data in the current layer, thereby generating multi-layer annotations.
[0043] In one possible implementation, the multi-layer bitmap structure includes a two-layer bitmap structure and a three-layer bitmap structure; when selecting the 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, the two-layer bitmap structure is selected.
[0045] When the conflict rate is greater than or equal to the second threshold, the three-layer bitmap structure is selected.
[0046] In one possible implementation, when the two-layer bitmap structure is selected, the marker data includes first-layer marker data and second-layer marker data, and the generated multi-layer annotation is a two-layer annotation; when using each bit of the marker data in each layer to mark the position of conflicting data within the same layer to generate multi-layer annotations, the first bitmap generation module is specifically configured to execute:
[0047] Each bit of the first layer of the two-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, and each data segment includes multiple data blocks.
[0048] Each bit of the second-level labeling data in the two-level bitmap structure is used to mark whether each data block in the data segment containing conflicting data is conflicting data, thus obtaining the two-level labeling.
[0049] In one possible implementation, when the three-layer bitmap structure is selected, the marker data includes first-layer marker data, second-layer marker data, and third-layer marker data, and the generated multi-layer annotation is a three-layer annotation; when using each bit of the marker data in each layer to mark the position of conflicting data within the same layer to generate multi-layer annotations, the first bitmap generation module is specifically configured to execute:
[0050] 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 data segment includes multiple data sub-segments, and each data sub-segment includes multiple data blocks;
[0051] Each bit of the second layer of the three-layer bitmap structure is used to mark whether each data segment in the data segment containing conflicting data contains conflicting data;
[0052] Each bit of the third layer of the three-layer bitmap structure is used to mark whether each data block in a data segment containing conflicting data is conflicting data, thus obtaining a three-layer label.
[0053] In one possible implementation, the collision frequency calculation module is specifically configured to perform:
[0054] The collision rate of the original data frame is obtained by calculating the ratio of the number of conflicting data to the total number of data blocks in the original data frame.
[0055] Fourthly, the present invention provides an electronic device comprising a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set, or an instruction set, wherein 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 protocol frame header conflict avoidance method as described in any of the preceding claims.
[0056] Fifthly, the present invention provides a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein 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 protocol frame header conflict avoidance method described in any of the preceding claims.
[0057] The protocol frame header conflict avoidance method provided in this invention, in practical applications, involves the following steps: First, at the sending end of data communication, conflicting data identical to the frame header bytes in the original data frame to be sent is detected, and the conflicting data is replaced with pre-designed replacement data to obtain a first data frame. Second, the conflict rate is determined based on the amount of conflicting data and the original data frame. Third, a single-layer bitmap structure or a multi-layer bitmap structure is dynamically selected based on the conflict rate to generate a bitmap annotation representing the position of the conflicting data in the original data frame. Then, a hierarchy identifier is added to the header of the bitmap annotation, and a checksum is added to the end to obtain a complete bitmap. Finally, the complete bitmap is appended to the end of the first data frame to obtain a second data frame. The receiving end efficiently reconstructs the original data frame based on the complete bitmap. This invention replaces conflicting data in the original data frame with replacement data and marks the replacement position of the conflicting data using a complete bitmap. The generation of the bitmap can dynamically select an appropriate bitmap structure based on the frequency of the conflicting data. In other words, this invention, through a smart multi-layer bitmap design scheme with dynamic division of labor, context awareness, and adaptive threshold adjustment, effectively improves the data transmission rate, reduces data processing complexity and latency, and enhances the reliability and flexibility of data transmission. Attached Figure Description
[0058] Figure 1 A method for avoiding protocol frame header conflicts provided in this embodiment of the invention, applied to a serial communication transmitting end, is illustrated in the following flowchart;
[0059] Figure 2 A method for avoiding protocol frame header conflicts provided in this embodiment of the invention, applied to a serial communication receiving end, is illustrated in the flowchart below;
[0060] Figure 3 This invention provides a protocol frame header conflict avoidance device, which is applied to a serial communication transmitting end. (Diagram of the device structure) Detailed Implementation
[0061] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0062] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of embodiments of this disclosure, unless otherwise stated, "a plurality of" means two or more. Furthermore, the use of "based on" or "according to" implies openness and inclusiveness, because processes, steps, calculations, or other actions "based on" or "according to" one or more of the stated conditions or values may in practice be based on additional conditions or beyond the stated values.
[0063] In the prior art, the core of a proprietary protocol fault-tolerant processing method based on serial communication disclosed in patent CN114337915A is as follows: the data sending end identifies the same byte sequence as the frame header in the data area or cyclic redundancy check code, and calls the identified byte sequence a pseudo frame header; the pseudo frame header is replaced with predefined replacement data to obtain the second data frame; the replacement position is marked with a single-layer bitmap in the frame header check data, for example: the position of the replacement data is represented by 1, and the position of the remaining data is represented by 0; the receiving end restores the pseudo frame header according to the frame header check data.
[0064] While the above processing methods can prevent frame header misjudgment in specific scenarios, they still have problems such as low transmission efficiency, high processing complexity, long processing latency, insufficient robustness, and rigid bitmap design.
[0065] Low transmission efficiency refers to the fact that using bit-stuffed or byte-stuffed frame header checksum data increases the amount of additional data, reducing bandwidth utilization. In other words, the addition of replacement data and a single-layer bitmap structure further increases the length of the data packet. Especially when frame header data collisions are frequent, the bit-by-bit marking method of the single-layer bitmap is inefficient in the transmission of long data packets, and the impact on transmission efficiency is more severe.
[0066] The high processing complexity refers to the fact that the sending end needs to monitor and replace data in real time, while the receiving end needs to decode and restore it, which increases the computational burden. In other words, the bit-by-bit marking method of a single-layer bitmap has a heavier computational burden for monitoring, replacing, and decoding during the transmission of long data packets.
[0067] Longer processing latency means that the filling, replacement and decoding processes introduce additional processing time, making them unsuitable for low-latency applications.
[0068] Insufficient robustness refers to the fact that information filling or verification data in noisy channels may be lost due to transmission errors, leading to failure in data packet reconstruction, and existing technologies cannot solve the problem of misjudgment or tampering of the bitmap itself.
[0069] Rigid bitmap design refers to the use of a fixed single-layer bitmap structure during data transmission, which cannot be adjusted according to data packet characteristics or channel conditions, resulting in poor signal transmission efficiency in high-collision or low-collision scenarios.
[0070] To address the problems of low data transmission efficiency, high processing complexity, long processing latency, insufficient robustness, and rigid bitmap design in existing technologies, embodiments of the present invention provide a method, apparatus, device, and storage medium for avoiding protocol frame header conflicts.
[0071] like Figure 1 As 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 communication, network communication, local area network communication, wireless communication and industrial communication, etc.
[0072] The method includes:
[0073] Step 101: Detect conflicting data in the original data frame and replace the conflicting data with replacement data to obtain the first data frame.
[0074] Among them, conflicting data refers to the data blocks in the original data frame that are identical to the frame header bytes, except for the data block corresponding to the frame header.
[0075] Specifically, the original data frame refers to the data packet to be sent, which contains a frame header byte. In step 101, the byte content of each data block in the original data frame is detected sequentially. After detecting conflicting data that is the same as the frame header byte, the conflicting data is replaced with predefined replacement data to obtain the first data frame. For example, if the frame header data is AA 55 and the predefined replacement data is AB 54, after detecting conflicting data, AB 54 is used to replace AA 55.
[0076] Step 102: Determine the collision rate of the original data frame based on the number of conflicting data and the total number of data blocks in the original data frame.
[0077] The collision rate refers to the percentage of conflicting data out of the total number of data blocks in the original data frame.
[0078] To address the issue of frame header misjudgment while enhancing the flexibility and adaptability of the communication protocol, data transmission scenarios can be divided based on the collision rate. For example, data transmission scenarios can be divided into high-collision and low-collision scenarios, or into high-collision, medium-collision, and low-collision scenarios. Different bitmap structures can then be designed for different collision scenarios.
[0079] Step 103: Dynamically select a single-layer bitmap structure or a multi-layer bitmap structure based on the collision rate, and generate bitmap annotations to represent the location of all conflicting data.
[0080] In this case, the single-layer bitmap structure directly marks the position of conflicting data in the original data frame.
[0081] In a multi-layer bitmap structure, the original data frames are divided layer by layer, and the position of conflicting data in each layer is marked sequentially using a hierarchical structure.
[0082] Specifically, the single-layer bitmap structure is suitable for scenarios with sparse collisions, directly marking whether each data block of the original data frame is collision data, which is simple and efficient.
[0083] The multi-layer bitmap structure divides the original data frame into multiple layers according to the user's actual needs. It uses a layered marking method to mark the position of conflicting data in each layer of the original data frame, thus optimizing the bitmap length. The number of layers in the multi-layer bitmap structure can be designed based on the conflict rate; when the conflict rate is high, the number of layers can be appropriately increased. In other words, the multi-layer bitmap structure is suitable for scenarios with concentrated conflicts. By first marking the data segments with concentrated conflicts through a layered structure, and then marking the specific location of conflicting data within the marked data segments, the total bitmap length is shortened.
[0084] Specifically, the collision rate reflects the frequency of conflicting data; a higher collision rate indicates more frequent conflicts. During actual data transmission, a single-layer or multi-layer bitmap structure is dynamically selected to generate bitmap annotations based on the collision rate, ensuring optimal transmission efficiency under different conflict scenarios.
[0085] Step 104: Add the corresponding hierarchy identifier to the header of the obtained bitmap annotation and add a check bit to the end to obtain the complete bitmap.
[0086] Specifically, the hierarchy identifier is used to distinguish the bitmap structure corresponding to the bitmap label, and different hierarchy identifiers correspond to different bitmap structures.
[0087] Specifically, a two-bit hierarchical identifier is used to distinguish the bitmap structure corresponding to the bitmap label. For example, 00, 01, and 10 represent a single-layer bitmap structure, a two-layer bitmap structure, and a three-layer bitmap structure, respectively.
[0088] The check bit is mainly used to verify data at the data receiving end, thereby improving 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 appended to the end of the first data frame, and the resulting second data is then transmitted.
[0091] In practical applications, the protocol frame header collision avoidance method provided in this invention involves the following steps: First, at the data communication sending end, conflicting data identical to the frame header bytes in the original data frame to be sent is detected, and the conflicting data is replaced with pre-designed replacement data to obtain a first data frame. Second, the collision rate is determined based on the amount of conflicting data and the original data frame. Third, a single-layer bitmap structure or a multi-layer bitmap structure is dynamically selected based on the collision rate to generate a bitmap annotation representing the position of the conflicting data in the original data frame. Then, a hierarchy identifier is added to the bitmap annotation header, and a checksum is added to the end to obtain a complete bitmap. Finally, the complete bitmap is appended to the end of the first data frame to obtain a second data frame. The receiving end efficiently reconstructs the original data frame based on the complete bitmap.
[0092] This invention replaces conflicting data in the original data frame with replacement data and marks the replacement position of the conflicting data with a complete bitmap. The generation of the bitmap can dynamically select an appropriate bitmap structure according to the frequency of the conflicting data.
[0093] In other words, this invention effectively improves data transmission rate, reduces data processing complexity and latency, and enhances the reliability and flexibility of data transmission through a smart multi-layer bitmap design scheme with dynamic division of labor, context awareness, and adaptive threshold adjustment.
[0094] Furthermore, bitmap annotations include single-layer bitmap annotations and multi-layer bitmap annotations. In step 103, a single-layer bitmap structure or a multi-layer bitmap structure is dynamically selected based on the collision rate to generate bitmap annotations representing the locations of all conflicting data, specifically including:
[0095] Step 1031: When the conflict rate is less than the first threshold, select a single-layer bitmap structure. Use each bit of the labeled data of the single-layer bitmap structure to mark whether each data block corresponding to the original data frame is conflicting data, and obtain single-layer annotation.
[0096] Specifically, a low-conflict scenario is defined as a conflict rate less than a first threshold. In a sparse conflict scenario, a single-layer bitmap structure is selected. The length of the marker data is equal to the total number of data blocks in the original data frame, and each bit of the marker data corresponds sequentially to a data block in the original data frame. The value of each bit of the marker data indicates whether the corresponding data block is conflicting data. For example, if a data block in the original data frame is conflicting data, the corresponding marker data bit 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 labeled data in each layer to mark the position of the conflicting data in this layer to generate multi-layer annotations.
[0098] Specifically, a conflict concentration scenario is defined as a conflict rate greater than or equal to a first threshold. In this scenario, a multi-layer bitmap structure is selected, and the bitmap length and parsing efficiency are optimized based on the conflict characteristics of the data. The number of layers for marking data is the same as the number of layers in the multi-layer bitmap structure, and the number of bits in each layer of marking data is the same as the number of segments the data is divided into in that layer. For each layer of marking data, the value of each bit in that layer's marking data indicates whether the corresponding data segment contains conflicting data. For example, for a certain layer of marking data, if a data segment within that layer contains conflicting data, the corresponding marking data bit is represented by 1; otherwise, it is represented by 0.
[0099] Furthermore, the multi-layer bitmap structure includes two-layer and three-layer bitmap structures. A multi-layer bitmap structure is selected when the collision rate is greater than or equal to a first threshold, specifically including:
[0100] When the conflict rate is greater than or equal to the first threshold and less than the second threshold, a two-layer bitmap structure is selected.
[0101] When the conflict rate is greater than or equal to the second threshold, a three-layer bitmap structure is selected.
[0102] Specifically, the values of the first and second thresholds can be adjusted according to user needs.
[0103] In this embodiment of the invention, the first threshold is 5% and the second threshold is 15%.
[0104] When the conflict rate is <5%, a single-layer bitmap structure is selected; when the conflict rate is 5% ≤ 15%, a two-layer bitmap structure is selected from the multi-layer bitmap structures; and when the conflict rate is ≥15%, a three-layer bitmap structure is selected from the multi-layer bitmap structures.
[0105] In this embodiment, each data block is taken as 1 byte. The bitmap design for different conflict scenarios is as follows:
[0106] As shown in Table 1:
[0107]
[0108] Table 1. Bitmap Design Tables for Low-Conflict, Medium-Conflict, and High-Conflict Scenarios
[0109] As shown in Table 1, in low-conflict scenarios with a conflict rate of <5%, the length of the data marked by a single-layer bitmap structure is equal to the number of data blocks, each bit of the marked data corresponds to one data block, and the total length of the generated bitmap annotation is fixed.
[0110] In medium-conflict scenarios with a conflict rate of 5% ≤ 15%, the first layer of the two-layer bitmap structure marks the data segments containing conflict data, and the second layer of the bitmap structure marks the specific location of the conflict data in the marked data segments, thus optimizing the bitmap length.
[0111] In high-conflict scenarios with a conflict rate of ≥15%, the first layer of a three-layer bitmap structure marks the data segments containing conflicting data, the second layer marks the position of the small data segments containing conflicting data within the marked data segments, and the third layer marks the position of the conflicting data within the marked data segments, thus balancing the bitmap length and parsing complexity.
[0112] Furthermore, when using a two-layer bitmap structure, the labeling data includes first-layer labeling data and second-layer labeling data, and the generated multi-layer annotation is a two-layer annotation.
[0113] Using each bit of the labeled data in each layer to mark the position of conflicting data within that layer, multi-layer annotations are generated, specifically including:
[0114] Each bit of the first layer of the two-layer bitmap structure is used to mark whether each data segment in the original data frame contains conflicting data.
[0115] Each raw data frame consists of multiple data segments, and each data segment consists of multiple data blocks.
[0116] Each bit of the second-level labeling data in the two-level bitmap structure is used to mark whether each data block in the data segment containing conflicting data is conflicting data, thus obtaining the two-level labeling.
[0117] Specifically, a medium-conflict scenario is defined as a conflict rate greater than or equal to the first threshold and less than the second threshold. In this conflict scenario, a two-layer bitmap structure is adopted.
[0118] The length of the first-level marker data is the same as the length of the data segment, and each bit of the first-level marker data corresponds to a data segment in turn. The value of each bit of the first-level marker data indicates whether the corresponding data segment contains conflicting data. If it contains conflicting data, it is represented by 1; otherwise, it is represented by 0.
[0119] The length of the second-level marker data is equal to the total number of data blocks in the data segment containing conflicting data. Each bit of the second-level marker data corresponds to a data block in the data segment containing conflicting data. The value of each bit of the second-level marker data indicates whether the corresponding data block is conflicting data. If it is conflicting data, it is represented by 1; otherwise, it is represented by 0.
[0120] Furthermore, when using a three-layer bitmap structure, the labeled data includes first-layer labeled data, second-layer labeled data, and third-layer labeled data, resulting in a three-layer label.
[0121] Using each bit of the labeled data in each layer to mark the position of conflicting data within that layer, multi-layer annotations are generated, specifically including:
[0122] 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.
[0123] Each raw data frame includes multiple data segments, each data segment includes multiple data sub-segments, and each data sub-segment includes multiple data blocks.
[0124] Each bit of the second layer of the three-layer bitmap structure is used to mark whether each data segment in the data segment containing conflicting data contains conflicting data.
[0125] Each bit of the third layer of the three-layer bitmap structure is used to mark whether each data block in a data segment containing conflicting data is conflicting data, thus obtaining a three-layer label.
[0126] Specifically, a high-conflict scenario is defined as one where the conflict rate exceeds the second threshold. In this scenario, a three-layer bitmap structure is adopted.
[0127] The length of the first-level marker data is the same as the length of the data segment, and each bit of the first-level marker data corresponds to a data segment in turn. The value of each bit of the first-level marker data indicates whether the corresponding data segment contains conflicting data. If it contains conflicting data, it is represented by 1; otherwise, it is represented by 0.
[0128] The length of the second-level marker data is equal to the total number of data segments in the data segment containing conflicting data. Each bit of the second-level marker data corresponds to a data segment in the data segment containing conflicting data. The value of each bit of the second-level marker data indicates whether the corresponding data segment contains conflicting data. If it does, it is represented by 1; otherwise, it is represented by 0.
[0129] The length of the third-level marker data is equal to the total number of data blocks in the data segment containing conflicting data. Each bit of the third-level marker data corresponds to a data block in the data segment containing conflicting data. The value of each bit of the third-level marker data indicates 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 this embodiment of the invention, it is assumed that the length of a data packet is 64 bytes, of which the frame header data is AA 55, occupying 2 bytes, and the remaining 62 bytes are the data portion. The size of each data block is defined as 2 bytes, therefore the data portion contains 31 data blocks.
[0131] The system detects the number of conflicting data in 31 data blocks and determines the conflict rate based on the number of conflicting data and the total number of data blocks. Based on the conflict rate, the data transmission scenario is divided into low-conflict scenario, medium-conflict scenario, and high-conflict scenario.
[0132] In the first scenario, assume there is one conflicting data point, located in the fifth data block.
[0133] Based on 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, with 31 bits representing 31 data blocks, occupying 4 bytes (insufficient bits are padded with 0). The bitmap annotation generated for the first scenario is: 00001000 00000000 00000000 00000000, indicating that the 5th data block is conflicting data.
[0134] Use 00 to represent a single-layer bitmap structure; the parity bit uses parity checking. When the number of 1s in the bitmap annotation is odd, the parity bit is 1, and when the number of 1s in the bitmap annotation is even, the parity bit is 0.
[0135] Therefore, the complete bitmap of the first scene is: 00 00001000 00000000 00000000 00000001.
[0136] In the second scenario, assume there are 3 conflicting data points, located in the 2nd, 5th, and 10th data blocks.
[0137] Based on the ratio of conflicting data to the total number of data blocks, the calculated conflict rate for the second scenario is 5% ≤ 15%. Therefore, the second scenario is a medium-conflict scenario, using a two-layer bitmap structure. The first layer divides the 31 data blocks into 4 data segments, each segment containing 8 data blocks (the last segment contains 7), and uses 4 bits to mark the data segments containing conflicting data. The second layer generates an 8-bit bitmap for each data segment containing conflicting data, marking the specific location of the conflicting data.
[0138] The first layer bitmap of the second scenario is 1100, indicating that the first and second data segments contain conflicting data. The first data segment (data blocks 1-8) of the second layer is labeled with 01001000, indicating that the second and fifth data blocks are conflicting data; the second data segment (data blocks 1-8) of the second layer is labeled with 01000000, indicating that the tenth data block is conflicting data.
[0139] The two-layer bitmap structure is represented by 0 and 1; the check 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 scene is: 01 1100 01001000 01000000 1.
[0141] In the third scenario, assume there are 10 conflicting data points, located in data blocks numbered 1, 3, 5, 7, 9, 11, 13, 15, 17, and 19.
[0142] Based on the ratio of conflicting data to the total number of data blocks, the calculated conflict rate for the third scenario is ≥15%. Therefore, the third scenario is a high-conflict scenario, using a three-layer bitmap structure. The first layer divides the 31 data blocks into two data segments, each with 16 data blocks (the last segment has 15), and uses 2 bits to mark the data segments containing conflicting data. The second layer divides the data segments containing conflicting data into four smaller data segments, each with four data blocks, and uses 4 bits to mark the smaller data segments containing conflicting data. The third layer generates a 4-bit bitmap for the smaller data segments containing conflicting data, marking the specific location of the conflicting data.
[0143] The first layer bitmap of the second scenario is 11, indicating that both data segments contain conflicting data. The first data segment of the second layer (data blocks 1-16) is labeled with 1111, indicating that all data sub-segments of the first data segment contain conflicting data; the second data segment of the second layer (data blocks 17-31) is labeled with 1000, indicating that only the first data sub-segment of the second data segment contains conflicting data. The bitmap for the first data segment (blocks 1-4) of the first data segment in the third layer is labeled 1010, indicating that the 1st and 3rd data blocks are conflicting data. The bitmap for the second data segment (blocks 5-8) of the first data segment in the third layer is labeled 1010, indicating that the 5th and 7th data blocks are conflicting data. The bitmap for the third data segment (blocks 9-12) of the first data segment in the third layer is labeled 1010, indicating that the 9th and 11th data blocks are conflicting data. The bitmap for the fourth data segment (blocks 13-16) of the first data segment in the third layer is labeled 1010, indicating that the 13th and 15th data blocks are conflicting data. The bitmap for the first data segment (blocks 17-20) of the second data segment in the third layer is labeled 1010, indicating that the 17th and 19th data blocks are conflicting data.
[0144] The number 10 represents a three-layer bitmap structure; the check bit is used to check the entire bitmap, and in this embodiment it is assumed to be 0.
[0145] Therefore, the complete bitmap for the third scene is: 10 11 1111 1000 1010 1010 1010 1010 10100.
[0146] The specific values and structures of the bitmaps in the three scenarios mentioned above are shown in Table 2:
[0147]
[0148] Table 2. Bitmap values and structures for low-conflict, medium-conflict, and high-conflict scenarios.
[0149] As shown in Table 2, this invention dynamically adjusts the bitmap level by utilizing the collision rate. In low-collision scenarios, a single-layer bitmap is used, which is simple and direct; in medium-collision scenarios, a two-layer bitmap is used to reduce the bitmap length; and in high-collision scenarios, a three-layer bitmap is used to further optimize the bitmap representation efficiency. This method balances the bitmap length and parsing complexity under different conditions, and improves the efficiency of data transmission and processing.
[0150] Furthermore, in step 102, the collision rate of the original data frame is determined based on the number of conflicting data and the total number of data blocks in the original data frame, specifically as follows:
[0151] The collision rate of the original data frame is obtained by calculating the ratio of the number of conflicting data to the total number of data blocks in the original data frame.
[0152] like Figure 2 As shown, in another embodiment of the present invention, a method for avoiding protocol frame header collisions is provided, applied to the receiving end of data communication. The method includes:
[0153] Step 201: Receive a second data frame containing a first data frame and a complete bitmap.
[0154] The first data frame is the data frame after replacing the conflicting data in the original data frame with replacement data.
[0155] Conflicting data refers to data blocks in the original data frame that are identical to the frame header bytes, except for the data block corresponding to the frame header.
[0156] A complete bitmap includes hierarchical identifiers, bitmap annotations, and check bits set sequentially.
[0157] Step 202: Determine the data parsing method based on the hierarchical identifier: either the single-layer parsing method corresponding to a single-layer bitmap structure or the multi-layer parsing method corresponding to a multi-layer bitmap structure.
[0158] In this case, the single-layer bitmap structure directly marks the position of conflicting data in the original data frame.
[0159] In a multi-layer bitmap structure, the original data frames are divided layer by layer, and the position of conflicting data in each layer is marked sequentially using a hierarchical structure.
[0160] Step 203: Based on the determined data parsing method, combine the bitmap annotation parsing to obtain the conflict position of the conflicting data in the original data frame.
[0161] Bitmap annotations are generated based on single-layer or multi-layer bitmap structures.
[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 confirming that the check bit matches the preset check data, output the restored original data frame.
[0164] In this embodiment of the invention, after receiving the second data frame, the receiving end first decomposes the second data frame into a first data frame and a complete bitmap.
[0165] Secondly, read the level identifiers from the complete bitmap header and determine the bitmap structure based on these identifiers. For example, reading the first two bits of the complete bitmap header to determine the bitmap structure: when the read level identifiers are 00, 01, and 10, the corresponding bitmap structures are a single-layer bitmap structure, a two-layer bitmap structure, and a three-layer bitmap structure, respectively.
[0166] Next, the bitmap annotations of the complete bitmap are parsed according to the data parsing method corresponding to the identified bitmap structure to determine the location of conflicting data.
[0167] For example, when the identified bitmap structure is a single-layer bitmap structure, the bitmap annotation is read directly, and the position of the conflicting data is determined according to the position of 1 in the bitmap annotation.
[0168] When the identified bitmap structure is a two-layer bitmap structure, first parse the first layer of data annotated with the bitmap to determine the data segment containing conflicting data; then parse the second layer of data annotated with the bitmap 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 of bitmap annotation data to determine the data segment containing conflicting data; then parse the second layer of bitmap annotation data to determine the data segment where the conflicting data is located; finally parse the third layer of bitmap annotation data to determine the position of the conflicting data in the corresponding data segment.
[0170] Then, based on the location of the conflicting data, i.e. the position marked as 1 in the bitmap annotation, the replacement byte is restored to the frame header byte, and the restored original data frame is obtained.
[0171] Finally, the restored original data frame is checked against the check bits of the complete bitmap. If the check bits match the preset check data, the restored original data frame is considered to be the same as the original data frame sent by the sender, and the restored original data frame is output. Otherwise, the restored original data frame is considered to be different from the original data frame sent by the sender, and the sender is requested to retransmit the data.
[0172] This invention provides an efficient, simple and reliable method for avoiding communication protocol frame header conflicts, with advantages such as high transmission efficiency, low latency, high reliability and flexible bitmap design.
[0173] The high transmission efficiency is specifically reflected in the fact that bitmaps occupy fewer bytes, significantly reducing data transmission overhead.
[0174] Low latency is specifically reflected in the fact that replacement and restoration operations are simple, processing time is short, and it is suitable for high-speed communication scenarios.
[0175] High reliability is specifically reflected in: avoiding the bitmap being the same as the frame header by constraining the bitmap value, further reducing the risk of misjudgment.
[0176] The flexibility of bitmap design is specifically reflected in the fact that each bit in the bitmap can correspond to a data block of different lengths (such as 2 bytes or 4 bytes), which can be flexibly adjusted according to the length of the frame header to compress the bitmap size.
[0177] like Figure 3 As shown, in another embodiment of the present invention, a protocol frame header collision avoidance device is provided, applied to the sending end of data communication. The device includes:
[0178] The detection and processing module 301 is used 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 a data block in the original data frame that is identical to the frame header bytes except for the data block corresponding to the frame header.
[0179] The collision frequency calculation module 302 is used to determine the collision rate of the original data frame based on the number of conflicting data and the total number of data blocks in the original data frame;
[0180] The first bitmap generation module 303 is used to dynamically select a single-layer bitmap structure or a multi-layer bitmap structure according to the magnitude of the conflict rate, and generate bitmap annotations to represent the location of all conflicting data; the single-layer bitmap structure directly marks the position of conflicting data in the original data frame; in the multi-layer bitmap structure, the original data frame is divided layer by layer, and the layered structure is used to mark the position of conflicting data in each layer in turn.
[0181] The second bitmap generation module 304 adds a corresponding level identifier to the header of the obtained bitmap annotation and adds a check bit to the end to obtain a complete bitmap.
[0182] The data bitmap synthesis module 305 is used to add the complete bitmap to the end of the first data frame to obtain the second data frame.
[0183] Furthermore, the bitmap annotation includes single-layer bitmap annotations and multi-layer bitmap annotations; the first bitmap generation module 303 is specifically configured to execute:
[0184] When the conflict rate is less than a first threshold, a single-layer bitmap structure is selected. Each bit of the labeled data in the single-layer bitmap structure is used to mark whether each data block corresponding to the original data frame is conflicting data, thus obtaining a single-layer label.
[0185] When the conflict rate is greater than or equal to the first threshold, a multi-layer bitmap structure is selected. A hierarchical structure is used, and each bit of the labeled data in each layer is used to mark the position of the conflicting data in the current layer, thereby generating multi-layer annotations.
[0186] Furthermore, 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 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, the two-layer bitmap structure is selected.
[0188] When the conflict rate is greater than or equal to the second threshold, the three-layer bitmap structure is selected.
[0189] Furthermore, when selecting the two-layer bitmap structure, the marker data includes first-layer marker data and second-layer marker data, and the generated multi-layer annotation is a two-layer annotation; when using each bit of the marker data in each layer to mark the position of conflicting data within the same layer to generate multi-layer annotations, the first bitmap generation module 303 is specifically configured to execute:
[0190] Each bit of the first layer of the two-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, and each data segment includes multiple data blocks.
[0191] Each bit of the second-level labeling data in the two-level bitmap structure is used to mark whether each data block in the data segment containing conflicting data is conflicting data, thus obtaining the two-level labeling.
[0192] Furthermore, when selecting the three-layer bitmap structure, the marker data includes first-layer marker data, second-layer marker data, and third-layer marker data, resulting in a three-layer annotation. When using each bit of the marker data in each layer to mark the position of conflicting data within the same layer to generate multi-layer annotations, the first bitmap generation module 303 is specifically configured to execute:
[0193] 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 data segment includes multiple data sub-segments, and each data sub-segment includes multiple data blocks;
[0194] Each bit of the second layer of the three-layer bitmap structure is used to mark whether each data segment in the data segment containing conflicting data contains conflicting data;
[0195] Each bit of the third layer of the three-layer bitmap structure is used to mark whether each data block in a data segment containing conflicting data is conflicting data, thus obtaining a three-layer label.
[0196] Furthermore, the conflict frequency calculation module 302 is specifically configured to perform:
[0197] The collision rate of the original data frame is obtained by calculating the ratio of the number of conflicting data to the total number of data blocks in the original data frame.
[0198] The protocol header conflict avoidance apparatus provided in this embodiment of the invention is used to execute the above-mentioned protocol header conflict avoidance method, and thus can achieve the same effect as the above-mentioned protocol header conflict avoidance method.
[0199] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0200] This invention also provides an electronic device, which includes a processor and a memory. The memory stores at least one instruction, at least one program, code set, or instruction set. The processor loads and executes the at least one instruction, at least one program, code set, or instruction set to implement the protocol frame header conflict avoidance method in this invention.
[0201] This invention also provides a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, at least one program, code set, or instruction set is loaded and executed by a processor to implement the protocol frame header conflict avoidance method in this invention.
[0202] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of the present invention is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state disk (SSD)).
[0203] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions within the technical scope disclosed in the present invention should be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for avoiding protocol frame header collisions, characterized in that, The method, applied to the sending end of data communication, includes: 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 identical to the frame header bytes except for the data block corresponding to the frame header. The collision rate of the original data frame is determined based on the number of conflicting data and the total number of data blocks in the original data frame. Based on the magnitude of the conflict rate, a single-layer bitmap structure or a multi-layer bitmap structure is dynamically selected to generate bitmap annotations representing the location of all conflicting data. The single-layer bitmap structure directly marks the position of conflicting data in the original data frame. In the multi-layer bitmap structure, the original data frame is divided layer by layer, and the position of conflicting data in each layer is marked sequentially using a hierarchical structure. Add the corresponding hierarchy identifier to the header of the obtained bitmap annotation and add a check bit to the end to obtain the complete bitmap. The complete bitmap is added to the end of the first data frame to obtain the second data frame; The collision rate of the original data frame is determined based on the number of conflicting data and the total number of data blocks in the original data frame, specifically as follows: The ratio of the number of conflicting data to the total number of data blocks in the original data frame is calculated to obtain the conflict rate of the original data frame; The bitmap annotations include single-layer bitmap annotations and multi-layer bitmap annotations; the single-layer bitmap structure or the multi-layer bitmap structure is dynamically selected according to the magnitude of the collision rate to generate bitmap annotations representing the locations of all conflicting data, specifically including: When the conflict rate is less than a first threshold, a single-layer bitmap structure is selected. Each bit of the labeled data in the single-layer bitmap structure is used to mark whether each data block corresponding to the original data frame is conflicting data, thus obtaining a single-layer label. When the conflict rate is greater than or equal to the first threshold, a multi-layer bitmap structure is selected. A hierarchical structure is used, and each bit of the labeled data in each layer is used to mark the position of the conflicting data in the current layer, thereby generating multi-layer annotations.
2. The method for avoiding protocol frame header collisions according to claim 1, characterized in that, 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, the multi-layer bitmap structure is selected, specifically including: When the conflict rate is greater than or equal to the first threshold and less than the second threshold, the two-layer bitmap structure is selected. When the conflict rate is greater than or equal to the second threshold, the three-layer bitmap structure is selected.
3. The method for avoiding protocol frame header collisions according to claim 2, characterized in that, When using the two-layer bitmap structure, the marker data includes first-layer marker data and second-layer marker data, and the generated multi-layer annotation is a two-layer annotation; each bit of the marker data in each layer is used to mark the position of conflicting data within the same layer to generate multi-layer annotation, specifically including: Each bit of the first layer of the two-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, and each data segment includes multiple data blocks. Each bit of the second-level labeling data in the two-level bitmap structure is used to mark whether each data block in the data segment containing conflicting data is conflicting data, thus obtaining the two-level labeling.
4. The method for avoiding protocol frame header collisions according to claim 2, characterized in that, When using the three-layer bitmap structure, the marker data includes first-layer marker data, second-layer marker data, and third-layer marker data, resulting in a three-layer multi-level annotation. Each bit of the marker data in each layer is used to mark the position of conflicting data within that layer, generating multi-layer annotations, specifically including: 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 data segment 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 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 a data segment containing conflicting data is conflicting data, thus obtaining a three-layer label.
5. A method for avoiding protocol frame header collisions, characterized in that, The method, applied to a receiving end in data communication, includes: Receive a second data frame containing a first data frame and a complete bitmap; the first data frame is a data frame after replacing conflicting data in the original data frame with replacement data; the conflicting data is a data block in the original data frame that is identical to the frame header bytes except for the data block corresponding to the frame header; the complete bitmap includes a hierarchy identifier, a bitmap annotation, and a check bit set sequentially. The data parsing method is determined based on the hierarchical identifier as either 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; the single-layer bitmap structure directly marks the position of 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 position of conflicting data in each layer in turn; Based on the determined data parsing method, the conflict position of the conflicting data in the original data frame is obtained by parsing the bitmap annotations; the bitmap annotations are generated based on the single-layer bitmap structure or the multi-layer bitmap structure. 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; After confirming that the check bit matches the preset check data, the restored original data frame is output.
6. A device for avoiding protocol frame header collisions, characterized in that, The device, used as a transmitter in data communication, includes: The detection and processing module is used 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 a data block in the original data frame that is identical to the frame header bytes except for the data block corresponding to the frame header. The collision frequency calculation module is used to determine the collision rate of the original data frame based on the number of conflicting data and the total number of data blocks in the original data frame; The first bitmap generation module is used to dynamically select a single-layer bitmap structure or a multi-layer bitmap structure according to the magnitude of the conflict rate, and generate bitmap annotations to represent the location of all conflicting data; the single-layer bitmap structure directly marks the position of conflicting data in the original data frame; in the multi-layer bitmap structure, the original data frame is divided layer by layer, and the position of conflicting data in each layer is marked sequentially using a hierarchical structure. The second bitmap generation module adds a corresponding level identifier to the header of the obtained bitmap annotation and a check bit to the end to obtain a complete bitmap. A data bitmap composition module is used to add the complete bitmap to the end of the first data frame to obtain a second data frame; The collision frequency calculation module is specifically configured to execute: The ratio of the number of conflicting data to the total number of data blocks in the original data frame is calculated to obtain the conflict rate of the original data frame; The bitmap annotations include single-layer bitmap annotations and multi-layer bitmap annotations; the first bitmap generation module is specifically configured to execute: When the conflict rate is less than a first threshold, a single-layer bitmap structure is selected. Each bit of the labeled data in the single-layer bitmap structure is used to mark whether each data block corresponding to the original data frame is conflicting data, thus obtaining a single-layer label. When the conflict rate is greater than or equal to the first threshold, a multi-layer bitmap structure is selected. A hierarchical structure is used, and each bit of the labeled data in each layer is used to mark the position of the conflicting data in the current layer, thereby generating multi-layer annotations.
7. An electronic device, characterized in that, The electronic device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set, or an instruction set, and 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 claim 1. The method for avoiding protocol frame header conflicts as described in any one of the above 4.
8. A computer-readable storage medium, characterized in that, The storage medium stores at least one instruction, at least one program, a code set, or an instruction set, wherein 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 claim 1. The method for avoiding protocol frame header conflicts as described in any one of the above 4.
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