Data packet processing method and system, communication terminal and storage medium
Through the mechanism of combining hash table and sliding window, the problem of low efficiency of vector recovery algorithm under large data traffic is solved, fast and efficient sequence recovery is achieved, and the efficiency and real-time performance of data packet processing are improved.
Patent Information
- Application Number
- CN202411037380.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-10-11
AI Technical Summary
The vector recovery algorithm in the existing IEEE 802.1CB standard consumes a lot of resources and is inefficient when processing large data traffic, and the length setting of the sequence history table is complicated, which affects real-time performance.
Using a mechanism that combines a hash table with a sliding window, it determines whether the data packet sequence number is within the reception range through hash value calculation and sliding window management, and determines whether the data packet is received or discarded based on the sequence difference and entry value to control the hash rate. Hash table size to avoid conflicts.
It improves the execution efficiency of the vector recovery algorithm, achieves fast and efficient sequence recovery, reduces time and space complexity, and is suitable for efficient data processing.
Smart Images

Figure CN118764443A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network communication technology, and in particular to a data packet processing method, system, communication terminal and storage medium. Background Art
[0002] The Vector Recovery Algorithm (VRA) in the IEEE 802.1CB (IEEE 802.1 is a collection of protocols, such as the spanning tree protocol, VLAN protocol, etc.) standard is a sequence number tracking mechanism used in the frame duplication and elimination process. It provides effective packet duplication detection and elimination functions, but the shortcomings in actual operation limit its efficiency.
[0003] First, in terms of algorithm complexity, the vector recovery algorithm needs to maintain a sequence history table to track the most recently received sequence number. Each time a data packet is received, this vector needs to be shifted, which causes the algorithm to consume a lot of memory and computing resources. The algorithm time complexity is O(n), where n is the length of the sequence history table, and the space complexity is O(n). When processing large amounts of data traffic, high resource overhead will occur because it directly affects the speed and efficiency of data processing and cannot guarantee strict real-time performance.
[0004] Secondly, the execution efficiency of the vector recovery algorithm is related to the length of the sequence history table (frerSeqRcvyHistoryLength). The longer the length of the sequence history table is set, the more bits need to be operated each time, the greater the time and space complexity of the algorithm, and the lower the processing efficiency. However, if the set length is too short, it cannot effectively handle situations with large sequence number differences, because the difference in the received sequence numbers may have exceeded the length of the sequence history table, resulting in data loss. Under different network and traffic conditions, the optimal history length is unknown, and the setting of the history length will directly affect the efficiency, which makes the optimization of the algorithm complex and unpredictable.
[0005] Therefore the prior art still needs to be improved and enhanced. Summary of the invention
[0006] The main purpose of the present invention is to provide a data packet processing method, system, communication terminal and storage medium, aiming to solve the problem of poor execution efficiency of vector recovery algorithms in the prior art.
[0007] In order to achieve the above object, the present invention adopts the following technical solutions:
[0008] In a first aspect, an embodiment of the present application provides a method for processing a data packet, including:
[0009] After obtaining the first sequence number of the current data packet received, judging whether the first sequence number is within the receiving range of a plurality of sliding windows in the sequence history record table according to the first sequence number and the second sequence number in the current sliding window of the sequence history record table;
[0010] If it is determined that the third sequence number is within the receiving range, a hash value is calculated for the third sequence number in the target sliding window to obtain a corresponding current hash table index, and a first entry value corresponding to the third sequence number is found according to the current hash table index;
[0011] The current data packet is discarded or received according to the sequence difference between the first sequence number and the second sequence number, and the first entry value.
[0012] In some embodiments, discarding or receiving the current data packet according to the sequence difference between the first sequence number and the second sequence number and the first entry value includes:
[0013] Subtracting the second sequence number from the first sequence number to obtain the sequence difference;
[0014] After determining that the sequence difference is less than or equal to 0, determining whether the third sequence number exists in the target sliding window and whether the first entry value is 0, discarding or writing the first sequence number into the target sliding window according to the determination result, and marking the current data packet accordingly;
[0015] When it is determined that the sequence difference is greater than 0, it is determined whether the second entry value corresponding to the fourth sequence number in the next sliding window adjacent to the current sliding window is 0, and the target data packet corresponding to the fourth sequence number is marked accordingly according to the judgment result until the first sequence number is written into the target sliding window.
[0016] In some embodiments, after determining that the sequence difference is less than or equal to 0, determining whether the third sequence number exists in the target sliding window and whether the first entry value is 0, discarding or writing the first sequence number into the target sliding window according to the determination result, and marking the current data packet accordingly, includes:
[0017] When it is determined that the sequence difference is less than or equal to 0, determining whether the third sequence number exists in the target sliding window;
[0018] If the third serial number exists, determining whether the first entry value corresponding to the third serial number in the hash table is 0;
[0019] If it is determined that the first entry value is 0, the current data packet is marked as a third mark, the first sequence number is written into the target sliding window and the first entry value is increased by one;
[0020] If it is determined that the first entry value is not 0, the current data packet is discarded and marked as a second mark, and the first entry value is increased by one;
[0021] The target sliding window is the index position in the sequence history record table of the sum of the current index value of the current sliding window and the sequence difference value.
[0022] In some embodiments, the fourth sequence number in the next sliding window is obtained by incrementing the second sequence number in the current sliding window by 1;
[0023] When it is determined that the sequence difference is greater than 0, determining whether a second entry value corresponding to a fourth sequence number in a next sliding window adjacent to the current sliding window is 0, and marking a target data packet corresponding to the fourth sequence number according to the determination result, until the first sequence number is written into the target sliding window, including:
[0024] When it is determined that the sequence difference is greater than 0, the index value of the next sliding window is calculated, and the second entry value corresponding to the index value of the next sliding window in the hash table is searched;
[0025] Determine whether the second entry value is 0, and if it is 0, mark the target data packet as the first mark; and if it is not 0, clear the second entry value and mark the target data packet as the second mark;
[0026] When the fourth sequence number is equal to the third sequence number, the first sequence number is written into the target sliding window, the current data packet is marked as a third mark, and the third entry value corresponding to the first sequence number in the hash table is increased by one.
[0027] In some embodiments, when it is determined that the sequence difference is greater than 0, the method further includes:
[0028] Determine in real time whether all sliding windows in the sequence history record table have written sequence numbers;
[0029] If so, the sequence number in the first sliding window in the sequence history record table is deleted, and the first sliding window is used as the current sliding window.
[0030] In some embodiments, after acquiring the first sequence number of the current received data packet, judging whether the first sequence number is within a receiving range of a plurality of sliding windows in the sequence history record table according to the first sequence number and a second sequence number in a current sliding window of the sequence history record table includes:
[0031] After receiving the current data packet, analyzing the current data packet to obtain a first sequence number of the current data packet;
[0032] calculating a difference between the first sequence number and the second sequence number, performing an absolute value operation, and comparing the obtained absolute value with the number of windows of the plurality of sliding windows;
[0033] If the absolute value is not greater than the number of windows, it is determined that the first sequence number is within the receiving range; otherwise, it is determined that the first sequence number is not within the receiving range.
[0034] In some embodiments, if it is determined that the receiving range is within the receiving range, a hash value calculation is performed on the third sequence number in the target sliding window to obtain a corresponding current hash table index, and a first entry value corresponding to the third sequence number is found according to the current hash table index, including:
[0035] If it is determined that the first sequence number is within the receiving range of the plurality of sliding windows, a hash value calculation is performed on the third sequence number using a preset hash function to obtain a current hash table index corresponding to the third sequence number, and the first entry value is searched in the hash table according to the current hash table index;
[0036] The calculation formula of the preset hash function is:
[0037] Hash(SequenceNum)=SequenceNum%n+A;
[0038] Wherein, SequenceNum is the target sequence number, A is a preset constant, and n is the number of sliding windows of the sequence history record table.
[0039] In a second aspect, an embodiment of the present application provides a data packet processing system, including:
[0040] a judgment module, configured to, after obtaining a first sequence number of a current data packet received, judge whether the first sequence number is within a receiving range of a plurality of sliding windows in the sequence history record table according to the first sequence number and a second sequence number in a current sliding window of the sequence history record table;
[0041] A hash calculation module is used to calculate a hash value for the third sequence number in the target sliding window if it is determined that the third sequence number is within the receiving range, obtain a corresponding current hash table index, and find a first entry value corresponding to the third sequence number according to the current hash table index;
[0042] A processing module is used to discard or receive the current data packet according to the sequence difference between the first sequence number and the second sequence number, and the first entry value.
[0043] In a third aspect, an embodiment of the present application provides a communication terminal, comprising: a memory, a processor, a display, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the method for processing data packets as described above when executed by the processor.
[0044] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the method for processing a data packet as described above.
[0045] Compared with the prior art, the present invention provides a data packet processing method, system, communication terminal and storage medium. The method eliminates duplicate data by adopting a combination mechanism of a hash table and a sliding window, and adopts a sliding window mechanism to track and manage the sequence number of the data packet, and control the size of the hash table, thereby avoiding hash conflicts, realizing fast and efficient sequence recovery in FRER (frame replication and elimination for rel iabi lity, Chinese for frame replication and frame elimination mechanism), and effectively improving the execution efficiency of the vector recovery algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0047] Figure 1 The negotiation processing flow of the FRER vector recovery algorithm for data frames in the prior art provided by the present invention;
[0048] Figure 2 A flowchart of a preferred embodiment of the method for processing a data packet provided by the present invention;
[0049] Figure 3A schematic diagram of an algorithm flow chart of a preferred embodiment of a method for processing a data packet provided by the present invention;
[0050] Figure 4 A flowchart of step S100 in a preferred embodiment of the method for processing a data packet provided by the present invention;
[0051] Figure 5 A flowchart of step S300 in a preferred embodiment of the method for processing a data packet provided by the present invention;
[0052] Figure 6 A flowchart of step S320 in a preferred embodiment of the method for processing a data packet provided by the present invention;
[0053] Figure 7 A flowchart of step S330 in a preferred embodiment of the method for processing a data packet provided by the present invention;
[0054] Figure 8 A schematic diagram of FRER deduplication based on a hash table data structure in a preferred embodiment of the method for processing a data packet provided by the present invention;
[0055] Fig. 9 A flowchart of steps S10 and S20 in a preferred embodiment of the method for processing a data packet provided by the present invention;
[0056] Fig.10 A diagram showing an architecture of a preferred embodiment of a data packet processing system provided by the present invention;
[0057] Fig.11 A schematic diagram of an operating environment of a preferred embodiment of a communication terminal provided by the present invention. DETAILED DESCRIPTION
[0058] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0059] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0060] Hereinafter, the terms "including", "having" and their cognates that can be used in various embodiments of the present application are intended only to indicate specific features, numbers, steps, operations, elements, components or a combination of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or a combination of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or a combination of the foregoing items. In addition, the terms "first", "second", "third" and the like are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance.
[0061] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present application belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.
[0062] In order to facilitate understanding of the embodiments of the present application, the relevant technologies involved in the embodiments of the present invention are first introduced here.
[0063] The development of Industry 4.0, smart manufacturing and the Industrial Internet of Things (IIoT) is catalyzing a new industrial revolution, which has brought fundamental changes in many fields such as control systems, robotics, automation technology, production processes and logistics management. The core purpose of these cutting-edge technologies is to optimize production efficiency, improve product quality and reduce operating costs. With the deep integration of OT (OT is operational technology, mainly referring to the equipment and control systems of the factory) and IT (IT is information technology, mainly referring to the network architecture and application systems of the enterprise), in addition to the need for high scalability, flexibility and reliability, for time-sensitive applications, real-time and deterministic communication behavior must also be guaranteed. In this demand context, key technologies such as Time Sensitive Network (TSN, a standard Ethernet-based industrial communication technology that can transmit periodic and non-periodic data in the same network and support real-time and deterministic) have emerged.
[0064] TSN is a series of standards developed by the IEEE 802.1 working group. It aims to meet the high requirements for data transmission quality in the fields of industrial automation, vehicle networks, and self-driving cars by extending the functions of traditional Ethernet, and to achieve high reliability and low latency data transmission services. In TSN, the IEEE 802.1CB frame replication and elimination mechanism provides an effective solution to ensure reliable communication of data frames. This mechanism adopts a static redundancy method. Key data is encoded with a unique serial number on the source node or forwarding device so that it can be copied to two or more non-overlapping paths. In the process of data flow through the network, each intermediate node or terminal identifies and processes these serial numbers, decodes the serial number information and deletes any duplicate data packets to ensure that the upper-layer application does not process the same data. In this network, the system is allowed to fail in the link or node, thereby achieving zero packet loss transmission.
[0065] Among them, the TSN frame replication and elimination mechanism does not copy all the data to the network, but judges the key data based on the flow identification module in the frame replication and elimination mechanism. It will identify the field information in the module such as VLANID (virtual local area network identifier) and source and destination MAC information to judge the key data of the flow data and copy it. In the frame replication and elimination mechanism, each key data packet that passes the flow identification is encoded with a 16-bit sequence number (SequenceNum), whose value range is 0 to SeqNumSpace-1, where SeqNumSpace represents the size of the sequence number space.
[0066] Furthermore, if the device supports the IEEE802.1Qca explicit routing control protocol, the frame replication and elimination mechanism combined with the Qca protocol will copy the key data to the path planned by the Qca protocol. If there is no explicit routing control protocol support, the data will be copied to the egress port configured in advance by the device through configuration commands.
[0067] Figure 1The negotiation process of the FRER (Frame Replication and Elimination for Reliability) vector recovery algorithm for data frames is demonstrated. When the sequence number (SequenceNum) of the data frame is received, the difference delta between the data frame sequence number and the first sequence number in the sequence history table is calculated = (SequenceNum-RecvSequenceNum). If the value of delta is within the range of the history record length (frerSeqRcvyHistoryLength) and is the previous sequence number (delta>0, that is, there is a difference in the time when the data frames on different paths (fast path and slow path) are transmitted to the destination node, and the data arriving at the destination node on the fast path generally has a previous sequence number), then it is necessary to shift the delta bit sequence history table bit by bit to check whether the Boolean value (Boolean value is a built-in data type of Python, a subclass of integer (int), indicating the validity of a state, that is, whether the state is true or false: True and False, True=1, False=0) at the current position is 1. If it is 1, it means that the data frame has been received before and the frame is discarded, otherwise the position is set to 1. If delta<0 indicates an old sequence number, the Boolean value of the corresponding bit in the sequence history table is directly determined.
[0068] The present invention provides a data packet processing method, system, communication terminal and storage medium. In the present invention, a combination mechanism of a hash table and a sliding window is adopted to eliminate duplicate data, and a sliding window mechanism is adopted to track and manage the sequence number of the data packet, and the size of the hash table is controlled, thereby avoiding the generation of hash conflicts, realizing fast and efficient sequence recovery in FRER, and effectively improving the execution efficiency of the vector recovery algorithm.
[0069] The following describes the design of the method for processing a data packet through specific exemplary embodiments. It should be noted that the following embodiments are only used to explain the technical solution of the invention and are not specifically limited:
[0070] For further information, see Figure 2 , the embodiment of the present application provides a method for processing a data packet, including:
[0071] S100, after obtaining the first sequence number of the current received data packet, determine whether the first sequence number is within the receiving range of several sliding windows in the sequence history record table according to the first sequence number and the second sequence number in the current sliding window of the sequence history record table.
[0072] In this embodiment, the data packet is composed of several TSN (Time Sensitive Network, which is an industrial communication technology based on standard Ethernet) data frames. The data packet processing method belongs to a method for improving the efficiency of deduplication in TSN frame replication and elimination. The method implements deduplication and filtering of duplicate data in FRER (FRER: Frame Replication and Elimination for Rel iabi lity, a feature of IEEE802.1CB protocol, used to enhance the reliability of Ethernet network) based on a hash table data structure.
[0073] The data packet processing method in this embodiment combines a hash table and a sliding window mechanism, and uses a hash table data structure to implement a duplicate data packet detection and elimination mechanism in frame replication redundancy elimination (FRER). Among them, as an efficient data structure, the hash table has the greatest advantage of providing search, insertion and deletion operations with a time complexity close to constant (i.e., the time complexity is O(1) in the average case). This feature enables the algorithm to complete the identification and processing of duplicate data packets in a constant time, thereby greatly improving the efficiency of data processing. In addition, a sliding window mechanism is also used to manage and track the sequence numbers of data packets. The update of the sliding window only involves the modification of a new index variable, and the time complexity of this operation is also O(1). Therefore, the time complexity of the entire algorithm is maintained at O(1), that is, the processing time of the data packet is not affected by the amount of data.
[0074] In this embodiment, a fixed-size array (i.e., a sequence history table) is used to simulate a hash table; the sequence history table contains n sliding windows, and the size of n is dynamically adjusted according to the actual application scenario and data stream characteristics. In each sliding window, an index value is set corresponding to a sequence number, that is, the sequence number is saved in the sliding window according to the calculated index value, and each record in the sliding window contains the sequence number value of the most recently processed data, which is used to control the size of the hash table and avoid hash conflicts.
[0075] Optionally, see also Figure 3 , the specific implementation process of the data packet processing method is as follows:
[0076] It mainly includes three steps: search, write and delete process.
[0077] The first step is the search process, which is the hashing process of the serial number (any input is processed in a specific way (hash function) to generate a value, which is equivalent to the address where the data is stored).
[0078] After receiving the current data packet, extract the first sequence number of the current data packet to obtain the sequence number SequenceNum. Then, based on the first sequence number and the second sequence number in the current sliding window pointed to by the pointer of the sequence history record table (expressed by window[index]), determine whether the first sequence number is within the receiving range of several sliding windows in the sequence history record table, that is, determine whether the data frame corresponding to the first sequence number is not within the receiving range of the sliding window.
[0079] In the present application, by judging whether the first sequence number is within the receiving range of several sliding windows in the sequence history record table based on the second sequence number in the current sliding window of the sequence history record table, the current data packet is screened, and repeated processing of old data and processing of large-format data are avoided, which affects processing efficiency.
[0080] For further information, see Figure 4 Step S100, after obtaining the first sequence number of the current data packet received, judging whether the first sequence number is within the receiving range of a plurality of sliding windows in the sequence history record table according to the first sequence number and the second sequence number in the current sliding window of the sequence history record table, includes:
[0081] S110, after receiving the current data packet, analyzing the current data packet to obtain a first sequence number of the current data packet;
[0082] S120, calculating the difference between the first sequence number and the second sequence number, performing an absolute value operation, and comparing the obtained absolute value with the number of windows of the plurality of sliding windows;
[0083] S130: If the absolute value is not greater than the number of windows, it is determined that the first sequence number is within the receiving range; otherwise, it is determined that the first sequence number is not within the receiving range.
[0084] Optionally, during the search process, if the current data packet is received, it is analyzed and extracted to obtain a 16-bit first sequence number. Then, the difference between the first sequence number and the second sequence number (the sequence number in the current sliding window of the sequence history record table) is calculated, that is, the difference between the first sequence number and the sequence number stored at the current index position of the sliding window, which is expressed by the formula: delta = SequenceNum-window[index](1); wherein SequenceNum is the target sequence number, which is the first sequence number at this time; index is the index value of the current sliding window; window[index] is the sequence number stored at the current index position of the sliding window, that is, the second sequence number in this application.
[0085] Secondly, after taking the absolute value of the above difference, compare the absolute value with the number of windows of several sliding windows to determine whether the absolute value is greater than the number of windows (corresponding to Figure 3 |delta|>n? ):
[0086] If the absolute value is not greater than the number of windows n, that is, when |delta|≤n, it means that the data frame of the sequence number is within the range of the sliding window, then the data packet is received. If the absolute value is greater than the number of windows, that is, when |delta|>n, it means that the data frame of the sequence number is not within the range of the sliding window, then the data frame is discarded and the current data packet is marked as the first mark (corresponding to Figure 3 lost_packages++ in .
[0087] For further information, please refer to Figure 2 , S200, if it is determined that it is within the receiving range, a hash value calculation is performed on the third sequence number in the target sliding window to obtain the corresponding current hash table index, and the first entry value corresponding to the third sequence number is found according to the current hash table index.
[0088] The target sliding window is the index position of the sum of the current index value of the current sliding window and the sequence difference in the sequence history table, expressed as window[index+delta].
[0089] Optionally, when determining whether the first sequence number is within the receiving range of a plurality of sliding windows in the sequence history record table: if it is determined to be within the receiving range, a hash value calculation is performed on the third sequence number on the target sliding window (window[index+delta]) to obtain a corresponding hash value as the current hash table index in the hash table. Then, the first entry value corresponding to the third sequence number is searched in the hash table according to the current hash table index (expressed as hash[window[index+delta]%n).
[0090] Because in this embodiment the entry value is used to count the number of times the same sequence number appears, and each sequence number has an entry value corresponding to it, that is, the current entry value corresponding to the current sequence number in the hash table is stored at the position of the current hash table index corresponding to the current sequence number, so the current hash table index can be used to find the first entry value (that is, the current entry value at this time) corresponding to the third sequence number (that is, the current sequence number at this time), thereby helping to quickly realize the search of data frames and effectively save retrieval time.
[0091] Furthermore, in step S200, if it is determined that the third sequence number in the target sliding window is within the receiving range, a hash value is calculated to obtain a corresponding current hash table index, and a first entry value corresponding to the third sequence number is found according to the current hash table index, including:
[0092] S210: If it is determined that the first sequence number is within the receiving range of the plurality of sliding windows, a hash value is calculated for the third sequence number using a preset mapping function to obtain a current hash table index corresponding to the third sequence number, and the first entry value is searched in the hash table according to the current hash table index;
[0093] Among them, the calculation formula of the preset mapping function is:
[0094] Hash(SequenceNum)=SequenceNum%n+A (2);
[0095] In formula (2), SequenceNum is the target sequence number, A is a preset constant, and n is the number of sliding windows of the sequence history table.
[0096] Optionally, after determining that the first sequence number is within the receiving range of several sliding windows, a preset mapping function (also referred to as a preset hash function, and in this embodiment, the expression of the preset hash function is obtained through corresponding design) is used to calculate the hash value of the third sequence number, that is, the third sequence number will be used as a key value of the preset mapping function for calculation, and the sequence number is processed by the preset mapping function to obtain the current hash table index corresponding to the third sequence number, and then the first entry value corresponding to the current hash table index is found in the hash table.
[0097] For further information, please refer to Figure 2 S300: discard or receive the current data packet according to the sequence difference between the first sequence number and the second sequence number, and the first entry value.
[0098] Optionally, after finding the first entry value corresponding to the third sequence number according to the current hash table index, a decision is made to discard or receive the current data packet based on the sequence difference between the first sequence number of the current data packet and the second sequence number in the current sliding window of the sequence history table, as well as the first entry value.
[0099] In the present application, after determining that the first sequence number is within the acceptance range, a decision is made as to whether to receive the current data packet based on the sequence difference between the first sequence number and the second sequence number, and the first entry value in the target sliding window, thereby achieving corresponding processing of the current data packet according to different sequence differences and first entry values, which helps to improve the efficiency of processing data packets.
[0100] For further information, see Figure 5 Step S300, according to the sequence difference between the first sequence number and the second sequence number, and the first entry value, discarding or receiving the current data packet, including:
[0101] S310, subtracting the second sequence number from the first sequence number to obtain a sequence difference;
[0102] S320, after determining that the sequence difference is less than or equal to 0, determine whether there is a third sequence number in the target sliding window and whether the first entry value is 0, discard or write the first sequence number into the target sliding window according to the determination result, and mark the current data packet accordingly;
[0103] S330. When it is determined that the sequence difference is greater than 0, determine whether the second entry value corresponding to the fourth sequence number in the next sliding window adjacent to the current sliding window is 0, and mark the target data packet corresponding to the fourth sequence number accordingly according to the judgment result until the first sequence number is written into the target sliding window.
[0104] Among them, in this application, the fourth sequence number in the next sliding window is obtained by increasing the second sequence number in the current sliding window by 1.
[0105] Optionally, after finding the first entry value, the second sequence number is subtracted from the first sequence number to obtain a sequence difference delta.
[0106] Then, determine the relationship between the sequence difference delta and 0:
[0107] In the first case, if the sequence difference is less than 0, that is, delta<0, it means that the data packet at this time is the previous data packet, but it does not mean that the data packet has been received in the hash table, because in this embodiment, for a new data packet, under normal circumstances, the record of the hash table and the writing of the sliding window are synchronized, that is, delta should be equal to 0; and if the sequence difference is less than 0, it means that the pointer index of the sliding window is faster than the pointer index of the hash table.
[0108] Then, the first sequence number of the current data packet needs to be written into the position of the sliding window window[index+delta] (target sliding window) so that the current sequence number can be saved at the difference position (delta position) with the previous sequence number, and finally the sequence numbers saved in the sliding window can be guaranteed to be sorted continuously.
[0109] However, before writing, it is first determined whether the third sequence number already exists in the target sliding window, and when it is determined that the third sequence number exists, it is further determined whether the first entry value is 0 (corresponding to Figure 3hash[window[index+delta]%n==0? ) in the target sliding window, that is, when it is determined that the sequence number exists in the target sliding window, it is determined whether the data packet corresponding to the sequence number has been received, and then the sequence number is discarded according to the determination result, and the current data packet is marked, or the sequence number is discarded and written into the target sliding window, and the current data packet is also marked.
[0110] In the second case, if the sequence difference is equal to 0, that is, delta = 0, it means that the first sequence number has been written into the sliding window in the target sliding window, that is, the first sequence number is the third sequence number. Further determine whether the first entry value corresponding to the third sequence number in the target sliding window is 0, that is, determine whether the data packet corresponding to the third sequence number appears for the first time: when it appears for the first time, that is, when the first entry value is 0, write the first sequence number and add 1 to the first entry value; and when it does not appear for the first time, that is, when the first entry value is not 0, discard the first sequence number and mark the current data packet accordingly.
[0111] In the third case, if the sequence difference is greater than 0, that is, delta>0, first search for the next sliding window (next_index) adjacent to the current sliding window, and determine whether the second entry value corresponding to the fourth sequence number in the next sliding window in the hash table is 0, and then mark the target data packet corresponding to the fourth sequence number according to the determination result. Then, continue to search and determine whether the second entry value corresponding to the fourth sequence number in the next sliding window in the hash table is 0, and mark the target data packet corresponding to the fourth sequence number according to the determination result. After that, the judgment, search and marking process is circulated until the current sliding window moves to the target sliding window, and the first sequence number is written into the target sliding window.
[0112] For further information, see Figure 6 Step S320: after determining that the sequence difference is less than or equal to 0, determine whether there is a third sequence number in the target sliding window and whether the first entry value is 0, discard or write the first sequence number into the target sliding window according to the determination result, and mark the current data packet accordingly, including:
[0113] S321, when it is determined that the sequence difference is less than or equal to 0, determining whether there is a third sequence number in the target sliding window;
[0114] S322: If the third serial number exists, determine whether the first entry value corresponding to the third serial number in the hash table is 0;
[0115] S323, if it is determined that the first entry value is 0, mark the current data packet as the third mark, write the first sequence number into the target sliding window and increase the first entry value by one;
[0116] S324: If it is determined that the value of the first entry is not 0, the current data packet is discarded and marked as a second mark, and the value of the first entry is increased by one.
[0117] Optionally, when determining the relationship between the sequence difference and 0, if it is determined that the sequence difference is less than or equal to 0, further determining whether there is a third sequence number in the target sliding window:
[0118] (1) If the third sequence number exists, it is represented as window[index+delta]!=0, and then determine whether the first entry value corresponding to the third sequence number in the hash table is 0 (hash[window[index+delta]%n==0?):
[0119] If the first entry value is 0, indicating that the current data packet has not been received, the current data packet is received, written into the target sliding window, and the current data packet is marked as the third mark (corresponding to Figure 3 receive_package++), then write the first sequence number into the target sliding window and add one to the first entry value; if it is determined that the first entry value is not 0, it means that the current data packet has been received, then the current data packet is discarded and marked as the second mark (corresponding to Figure 3 discard_packages++) in the same way, the value of the first entry is increased by one.
[0120] (2) However, if there is no third sequence number, it is represented as window[index+delta]==0
[0121] (3) indicates that the current sliding window within the target sliding window does not have a sequence number and can be written directly.
[0122] For further information, see Figure 7 Step S330: when it is determined that the sequence difference is greater than 0, determine whether the second entry value corresponding to the fourth sequence number in the next sliding window adjacent to the current sliding window is 0, and mark the target data packet corresponding to the fourth sequence number according to the determination result, until the first sequence number is written into the target sliding window, including:
[0123] S331, when it is determined that the sequence difference is greater than 0, the index value of the next sliding window is calculated, and the second entry value corresponding to the index value of the next sliding window in the hash table is searched;
[0124] S332, determining whether the second entry value is 0, and if it is 0, receiving the target data packet and marking it as the first mark, and if it is not 0, clearing the second entry value and marking the target data packet as the second mark;
[0125] S333. When the fourth sequence number is equal to the third sequence number, write the first sequence number into the target sliding window, mark the current data packet as the third mark, and increase the third entry value corresponding to the first sequence number in the hash table by one.
[0126] In this embodiment, the sequence numbers in the next sliding window are all referred to as fourth sequence numbers, the entry values corresponding to the fourth sequence numbers are all referred to as second entry values, and the data packets corresponding to the fourth sequence numbers are all referred to as target data packets.
[0127] Optionally, when determining the relationship between the sequence difference and 0, if it is determined that the sequence difference is greater than 0, the index value of the next sliding window is calculated, expressed as next_index = (index++)% n(4), and the operation modulo n can ensure that the sliding window can be cyclically indexed when the sliding window reaches its capacity limit, that is, it returns to the initial moving sliding window and rewrites it.
[0128] Then, the fourth sequence number to be stored in the next sliding window is the second sequence number in the current sliding window incremented by 1 to obtain: window[next_index]=window[next_index-1]+1(5), where next_index-1=index, which is the current sliding window position. That is, the sequence number to be stored in the next sliding window each time is the sequence number in the current sliding window plus 1, and the sequence numbers are saved one by one in the continuous sliding windows window[next_index].
[0129] Secondly, according to the fourth sequence number that should be saved in the next sliding window, the second entry value corresponding to the fourth sequence number is found in the hash table, and it is determined whether the second entry value is 0:
[0130] When the second entry value is 0, it means that the target data packet corresponding to the fourth sequence number in the current sliding window has not been actually received, that is, the second entry value in the hash table is not effectively counted, and the target data packet is received and marked as the first mark (lost_package++).
[0131] When the second entry value is not 0, it means that the data packet corresponding to the second entry value is actually received. At this time, all sliding windows have been written with sequence numbers, and the fourth entry value of the first sequence number in the hash table needs to be cleared to start counting new data packets, and then the target data packet is marked with the second mark (discard_packages++).
[0132] Finally, the pointer of the sliding window keeps moving right in a circular motion, and at the same time, the entry values corresponding to the sequence numbers in these windows (all referred to as the fourth sequence numbers) are determined to perform corresponding markings, until the fourth sequence number is equal to the third sequence number, that is, until the pointer of the sliding window indexes the target sliding window, that is, next_index==index+delta(6); at this time, the first sequence number of the current data packet is written into the target sliding window, and the current data packet is marked as the third mark (receive_package++), and then the third entry value corresponding to the first sequence number in the hash table is increased by one, so that the sequence numbers in all sliding windows are increased by 1 in sequence.
[0133] Afterwards, the hash table is updated, the value of the corresponding hash table hash(window[next_index]) entry is incremented by 1, and the current data packet is marked as the third mark (receive_package++), thereby completing the entire writing process.
[0134] See also Figure 8 The schematic diagram of FRER deduplication based on the hash table data structure shown in FIG. 1 is illustrated below by taking an example, from the sequence history record table ( Figure 8 It can be seen from the long horizontal table in the middle that the pointer index of the current sliding window is 3, that is, the pointer indexes to the fourth window (the index value of the corresponding sequence history table is 3), and the sequence number (the second sequence number) in the current sliding window is 13.
[0135] Case 1: Assume that the sequence number SequenceNum of the current data packet received is 12 (i.e., the first sequence number at this time). Since the current sliding window stores the sequence number 13, i.e., window[index%n] is 13. Then, delta = SequenceNum-window[index%n] = 12-13 = -1. At this time, delta < 0, window[(index+delta)%n] = window[3-1] = 12. The first sequence number 12 of the current data packet is written to the target sliding window, i.e. Figure 8 In the third window of the sequence history table, at this time, the hash table ( Figure 8The index value of the vertical table in the middle is Hash[SequenceNum]%n=2; at the same time, the entry value corresponding to the index value corresponding to the first sequence number in the hash table (2 in this case) is increased by 1.
[0136] Case 2: Assume that the sequence number SequenceNum of the current data packet received is 17 (i.e., the first sequence number at this time). Since the sequence number in the current sliding window is 13, delta = SequenceNum-window[index%n] = 17-13 = 4. At this time, delta>0, so the sequence number in the next sliding window of the current sliding window should be: window[4] = window[3]+1 = 14, i.e. Figure 8 The sequence number 14 should be written in the 5th window.
[0137] Then, the corresponding sequence numbers written in the subsequent sliding windows continue to increase by 1 until the index value reaches 7 (the target sliding window, that is, the 8th window of the sequence history table), at which time the sequence number should be 17. Then 17 is written into the 8th window, and the current data packet is marked as receive_package++ (the third mark), and then the entry value corresponding to 17 in the hash table is increased by 1.
[0138] At the same time, in the process of cyclically adding 1 to the sequence number in the next sliding window, it is necessary to determine each time whether the entry value corresponding to the sequence number in the next sliding window is 0, and mark the target data packet accordingly according to the determination result.
[0139] For further information, see Fig. 9 When it is determined that the sequence difference is greater than 0, the method further includes:
[0140] S10, determining in real time whether all sliding windows in the sequence history record table have been written with sequence numbers;
[0141] S20: If yes, then delete the sequence number in the first sliding window in the sequence history record table, and use the first sliding window as the current sliding window.
[0142] Optionally, the third step of processing the data packet in this embodiment, i.e., the deletion process, is implemented as follows:
[0143] When judging whether the sequence difference is greater than 0, if the sequence difference is greater than 0, it is judged in real time whether all sliding windows in the sequence history record table have written the sequence number. If all have been written, it means that all sliding windows are fully stored. At this time, the pointer points to the last sliding window, that is, the current sliding window is the last sliding window.
[0144] Then, it is necessary to find the next sliding window adjacent to the current sliding window, that is, find the first sliding window, delete the sequence number in the first sliding window, and then restart the indexing of the current sliding window with the first sliding window, thereby realizing circular indexing.
[0145] For further information, see Fig.10 , an embodiment of the present application provides a data packet processing system, comprising:
[0146] The judgment module 1 is used to obtain the first sequence number of the current data packet received, and then judge whether the first sequence number is within the receiving range of several sliding windows in the sequence history record table based on the first sequence number and the second sequence number in the current sliding window of the sequence history record table.
[0147] The hash calculation module 2 is used to calculate the hash value of the third serial number in the target sliding window if it is determined to be within the receiving range, obtain the corresponding current hash table index, and find the first entry value corresponding to the third serial number according to the current hash table index.
[0148] The processing module 3 is used to discard or receive the current data packet according to the sequence difference between the first sequence number and the second sequence number and the first entry value.
[0149] Optionally, the data packet processing system is applicable to the data packet processing method. Then, similarly, the implementation process of the data packet processing system is as follows:
[0150] First, after receiving the current data packet, extract the first sequence number of the current data packet to obtain the sequence number SequenceNum. Then, based on the second sequence number in the current sliding window pointed to by the pointer of the sequence history record table (expressed by window[index]) and the first sequence number corresponding to the current data packet, determine whether the first sequence number is within the receiving range of several sliding windows in the sequence history record table.
[0151] Then, when judging whether the first sequence number is within the receiving range of a plurality of sliding windows:
[0152] If it is determined to be within the receiving range, the third sequence number on the target sliding window (the index position of the sum of the current index value of the current sliding window and the sequence difference in the sequence history record table, represented by window[index+delta]) is hashed to obtain the corresponding hash value as the current hash table index in the hash table. Then, the first entry value corresponding to the third sequence number is searched in the hash table according to the current hash table index (represented as hash[window[index+delta]%n).
[0153] Finally, it is further decided to discard or receive the current data packet based on the sequence difference between the first sequence number and the second sequence number and the first entry value corresponding to the third sequence number in the target sliding window.
[0154] In this embodiment, by writing, searching and deleting the sequence number of the data packet, the sequence number stored in the sliding window in the sequence history record table can be guaranteed to be continuous. The sequence number in the current sliding window on the sequence history record table is extracted to search the corresponding entry value in the hash table to determine whether the data packet has been processed. In addition, the function of the sequence history record table maintained by the sequence recovery function in the FRER mechanism is simulated by the sliding window index self-increment operation, and whether the data frame is a duplicate frame or a lost data frame is correctly determined within the receiving range.
[0155] By combining hash tables and sliding window mechanisms, an efficient and stable FRER sequence recovery table algorithm is implemented. The time complexity of this algorithm is O(1), which makes the data packet processing speed unaffected by the amount of data. It is suitable for application scenarios with large data flow and high requirements for data processing speed, such as real-time video transmission, high-frequency trading systems, etc., providing a reliable and efficient data processing solution for these applications.
[0156] Furthermore, if Fig.11 As shown, based on the above data packet processing method, the present invention also provides a communication terminal accordingly. The communication terminal includes a processor 10, a memory 20 and a display 30. Fig.11 Only some components of the communication terminal are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0157] The memory 20 may be an internal storage unit of the communication terminal in some embodiments, such as a hard disk or memory of the communication terminal. The memory 20 may also be an external storage device of the communication terminal in other embodiments, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the communication terminal. Further, the memory 20 may also include both an internal storage unit of the communication terminal and an external storage device. The memory 20 is used to store application software and various types of data installed in the communication terminal, such as program codes for installing the communication terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a computer program 40 is stored on the memory 20, and the computer program 40 can be executed by the processor 10, thereby realizing the method for processing data packets in the present application.
[0158] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, and is used to run program codes stored in the memory 20 or process data, such as executing a method for processing data packets.
[0159] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the communication terminal and to display a visual user interface. The components 10-30 of the communication terminal communicate with each other via a system bus.
[0160] In one embodiment, the steps implemented when the processor 10 executes the computer program 40 in the memory 20 can refer to the corresponding description in the above-mentioned data packet processing method, and will not be repeated here.
[0161] Optionally, in this embodiment, the specific functions of each module of the above-mentioned data packet processing system can refer to the corresponding description in the above-mentioned data packet processing method, and will not be repeated here.
[0162] Furthermore, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program 40, and when the computer program 40 is executed by a processor, the steps of the method for processing the data packet as described above are implemented; since the steps of the method for processing the data packet are described in detail above, they will not be repeated here.
[0163] In summary, the present invention provides a method, system, communication terminal and storage medium for processing a data packet, the method comprising: after obtaining the first sequence number of the current data packet received, judging whether the first sequence number is within the receiving range of several sliding windows in the sequence history record table according to the first sequence number and the second sequence number in the current sliding window of the sequence history record table; if it is judged to be within the receiving range, performing a hash value calculation on the third sequence number in the target sliding window to obtain the corresponding current hash table index, and finding the first entry value corresponding to the third sequence number according to the current hash table index; discarding or receiving the current data packet according to the sequence difference between the first sequence number and the second sequence number, and the first entry value. By searching, writing and deleting data packets, the efficiency of processing data packets is improved.
[0164] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. A method for processing a data packet, It is characterized in that include: After obtaining the first sequence number of the current data packet received, judging whether the first sequence number is within the receiving range of a plurality of sliding windows in the sequence history record table according to the first sequence number and the second sequence number in the current sliding window of the sequence history record table; If it is determined that the third sequence number is within the receiving range, a hash value is calculated for the third sequence number in the target sliding window to obtain a corresponding current hash table index, and a first entry value corresponding to the third sequence number is found according to the current hash table index; The current data packet is discarded or received according to the sequence difference between the first sequence number and the second sequence number, and the first entry value.
2. The method for processing a data packet according to claim 1, It is characterized in that The discarding or receiving the current data packet according to the sequence difference between the first sequence number and the second sequence number, and the first entry value, includes: Subtracting the second sequence number from the first sequence number to obtain the sequence difference; After determining that the sequence difference is less than or equal to 0, determining whether the third sequence number exists in the target sliding window and whether the first entry value is 0, discarding or writing the first sequence number into the target sliding window according to the determination result, and marking the current data packet accordingly; When it is determined that the sequence difference is greater than 0, it is determined whether the second entry value corresponding to the fourth sequence number in the next sliding window adjacent to the current sliding window is 0, and the target data packet corresponding to the fourth sequence number is marked accordingly according to the judgment result until the first sequence number is written into the target sliding window.
3. The method for processing a data packet according to claim 2, It is characterized in that After determining that the sequence difference is less than or equal to 0, determining whether the third sequence number exists in the target sliding window and whether the first entry value is 0, discarding or writing the first sequence number into the target sliding window according to the determination result, and marking the current data packet accordingly, including: When it is determined that the sequence difference is less than or equal to 0, determining whether the third sequence number exists in the target sliding window; If the third serial number exists, determining whether the first entry value corresponding to the third serial number in the hash table is 0; If it is determined that the first entry value is 0, the current data packet is marked as a third mark, the first sequence number is written into the target sliding window and the first entry value is increased by one; If it is determined that the first entry value is not 0, the current data packet is discarded and marked as a second mark, and the first entry value is increased by one; The target sliding window is the index position in the sequence history record table of the sum of the current index value of the current sliding window and the sequence difference value.
4. The method for processing a data packet according to claim 3, It is characterized in that The fourth sequence number in the next sliding window is obtained by incrementing the second sequence number in the current sliding window by 1; When it is determined that the sequence difference is greater than 0, determining whether a second entry value corresponding to a fourth sequence number in a next sliding window adjacent to the current sliding window is 0, and marking a target data packet corresponding to the fourth sequence number according to the determination result, until the first sequence number is written into the target sliding window, including: When it is determined that the sequence difference is greater than 0, the index value of the next sliding window is calculated, and the second entry value corresponding to the index value of the next sliding window in the hash table is searched; Determine whether the second entry value is 0, and if it is 0, mark the target data packet as the first mark; and if it is not 0, clear the second entry value and mark the target data packet as the second mark; When the fourth sequence number is equal to the third sequence number, the first sequence number is written into the target sliding window, the current data packet is marked as a third mark, and the third entry value corresponding to the first sequence number in the hash table is increased by one.
5. The method for processing a data packet according to claim 1, It is characterized in that When it is determined that the sequence difference is greater than 0, the method further includes: Determine in real time whether all sliding windows in the sequence history record table have written sequence numbers; If so, the sequence number in the first sliding window in the sequence history record table is deleted, and the first sliding window is used as the current sliding window.
6. The method for processing a data packet according to claim 1, It is characterized in that After obtaining the first sequence number of the current data packet received, judging whether the first sequence number is within a receiving range of a plurality of sliding windows in the sequence history record table according to the first sequence number and a second sequence number in the current sliding window of the sequence history record table includes: After receiving the current data packet, analyzing the current data packet to obtain a first sequence number of the current data packet; calculating a difference between the first sequence number and the second sequence number, performing an absolute value operation, and comparing the obtained absolute value with the number of windows of the plurality of sliding windows; If the absolute value is not greater than the number of windows, it is determined that the first sequence number is within the receiving range; otherwise, it is determined that the first sequence number is not within the receiving range.
7. The method for processing a data packet according to claim 1, It is characterized in that If it is determined that the receiving range is within the receiving range, a hash value calculation is performed on the third sequence number in the target sliding window to obtain a corresponding current hash table index, and a first entry value corresponding to the third sequence number is found according to the current hash table index, including: If it is determined that the first serial number is within the receiving range of the plurality of sliding windows, a hash value calculation is performed on the third serial number using a preset hash function to obtain a current hash table index corresponding to the third serial number, and the first entry value is searched in the hash table according to the current hash table index; The calculation formula of the preset hash function is: Hash(SequenceNum)=SequenceNum%n+A; Wherein, SequenceNum is the target sequence number, A is a preset constant, and n is the number of sliding windows of the sequence history record table.
8. A data packet processing system, It is characterized in that include: a judgment module, configured to, after obtaining a first sequence number of a current data packet received, judge whether the first sequence number is within a receiving range of a plurality of sliding windows in the sequence history record table according to the first sequence number and a second sequence number in a current sliding window of the sequence history record table; A hash calculation module is used to calculate a hash value for the third sequence number in the target sliding window if it is determined that the third sequence number is within the receiving range, obtain a corresponding current hash table index, and find a first entry value corresponding to the third sequence number according to the current hash table index; A processing module is used to discard or receive the current data packet according to the sequence difference between the first sequence number and the second sequence number, and the first entry value.
9. A communication terminal, It is characterized in that include: A memory, a processor, a display, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the method for processing a data packet as described in any one of claims 1 to 7.
10. A computer-readable storage medium, It is characterized in that A computer program is stored, and when the computer program is executed by a processor, the steps of the method for processing a data packet as described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Abnormal data packet processing method, electronic equipment and robot
CN122621548A
