CN116032894A - TCP session reorganization method and device - Google Patents

TCP session reorganization method and device Download PDF

Info

Publication number
CN116032894A
CN116032894A CN202211721286.3A CN202211721286A CN116032894A CN 116032894 A CN116032894 A CN 116032894A CN 202211721286 A CN202211721286 A CN 202211721286A CN 116032894 A CN116032894 A CN 116032894A
Authority
CN
China
Prior art keywords
data
session
tcp
node
layer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211721286.3A
Other languages
Chinese (zh)
Inventor
梁圆
张磊
朱旭晖
陈承强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Westsoft Computer Engineering Co ltd
Original Assignee
Hangzhou Westsoft Computer Engineering Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Westsoft Computer Engineering Co ltd filed Critical Hangzhou Westsoft Computer Engineering Co ltd
Priority to CN202211721286.3A priority Critical patent/CN116032894A/en
Publication of CN116032894A publication Critical patent/CN116032894A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides a TCP session reorganization method and device. A TCP session reorganization method and device comprises a TCP transmission channel establishment module, a data packet acquisition module, a data processing module, a TCP session linked list management module, a TCP session assembly linked list management module, a positioning node management module and a session ID matching module. The invention is based on that in a large-flow network environment, a plurality of data packets split by a section of data are always transmitted in adjacent sequence, and according to the last positioned node, the data packets are matched nearby the node, so that the matching times are reduced, and the positioning and reorganizing efficiency of TCP session is improved.

Description

TCP session reorganization method and device
Technical Field
The invention relates to the technical field of information, in particular to a method and a device for TCP session reorganization.
Background
In the current internet data transmission process, a local host transmits data to a target host, and strict internet protocols are required to be followed, wherein the internet protocols comprise an ethernet protocol, an IP protocol, a TCP transmission control protocol and an application layer protocol, and because ethernet data packets defined in the ethernet protocol have a fixed size, a section of data is often required to be split into a plurality of sections of data packets when the data is transmitted; the multi-segment data packet is then restored to a segment of complete data that is passed into the application layer.
The TCP transmission control protocol is a connection-oriented, reliable and byte stream-based transmission layer communication protocol, and is widely applied to network data transmission. When the TCP protocol is adopted to transmit data, the data is required to be split into a plurality of data packets, and the corresponding data packets are subjected to positioning and recombination to restore a complete TCP session. In an actual network environment, particularly a high-flow network environment, N TCP sessions occur at the same time at the same network node; the efficiency of positioning and reorganizing the TCP session directly affects the data parsing of the application layer.
At present, the following modes are mostly adopted for TCP session positioning and reorganization: a data message arrives, five-tuple information in a TCP session chain table is positioned to a target TCP session through sequential comparison, and then the current session is recombined through information such as a serial number and the like in the data message. For networks with low traffic, such reorganization can be applied; however, when the network is in a large flow, the comparison of the five-tuple TCP session can occupy a large amount of computer performance and too much time, and the applicability is not strong. Thereby affecting the analysis application of the subsequent application layer to the data.
Disclosure of Invention
The invention is based on that in a large-flow network environment, a plurality of data packets split by a section of data are always transmitted in adjacent sequence, and according to the last positioned node, the data packets are matched nearby the node, so that the matching times are reduced, and the positioning and reorganizing efficiency of TCP session is improved.
A method of TCP session reassembly, comprising the steps of:
s1: establishing connection between a target host and a local host, and establishing an empty TCP session linked list TcpSessionList;
s2: acquiring a data packet, wherein the data packet comprises Ethernet header information, IP header information and TCP data, and the TCP data comprises a syn layer, a fin layer, a seq layer, a len layer, a prev layer, a next layer and a tcpdata layer;
s3: searching a value syn stored in a syn layer of the data packet according to the index, judging whether "syn= 1" is true, if so, proceeding to S4; if "syn= 1" is not true, the process proceeds to S7;
s4: judging whether the inside of the TCP session list TcpSessionList is empty or not, if so, entering S5; describing the existing content in the TCP session list TcpSess List, and entering S6;
s5: searching IP header information of the data packet according to the index, generating a unique session ID according to the IP header information, generating a node sequence number TSLindex and establishing a corresponding TCP session assembly linked list TcpList, and adding the node sequence number TSLindex, the session ID and the TCP session assembly linked list TcpList corresponding to the data packet into the TCP session linked list TcpSesseionList in a one-to-one mapping manner, wherein each node sequence number TSLindex corresponds to one node; meanwhile, adding TCP data corresponding to the data packet into a TCP session assembly linked list TcpList, storing the node sequence number TSLindex in a positioning node management module, marking the node sequence number TSLindex as a positioning node PostLindex, and returning to S2;
s6: releasing a node sequence number TSLindex stored in a positioning node management module, searching IP header information of the data packet according to an index, generating a unique session ID according to the IP header information, acquiring the largest TSLindex in a TCP session linked list TcpSessionList, assigning TSLindex+1 to the TSLindex, wherein the TSLindex is the node sequence number TSLindex corresponding to the data packet, establishing a corresponding TCP session assembly linked list TcpList, adding the node sequence number TSLindex, the session ID and the TCP session assembly linked list TcpList corresponding to the data packet to the tail of the TCP session linked list TcpSessionList in a one-to-one mapping manner, adding TCP data corresponding to the data packet to the TCP session assembly linked list TcpList, storing the node sequence number TSLindex in the positioning node management module as a positioning node PostLindex, and returning to S2;
s7: finding a corresponding node in a TCP session linked list TcpSessionList according to a node sequence number TSLindex stored in a positioning node management module, searching IP header information of the data packet according to an index, and generating a session ID according to the IP header information;
s8: the session ID is matched with the session ID corresponding to all the node serial numbers TSLindex which meet the condition that the PostLindex-r is less than or equal to TSLindex and less than or equal to PostLindex+r, wherein r is a preset node range, if the matching is successful, the S9 is entered; if the matching fails, entering S10;
s9: acquiring a node sequence number TSLindex corresponding to successful matching, adding TCP data corresponding to the data packet into a TCP session assembly linked list TcpList corresponding to the node sequence number TSLindex, storing the node sequence number TSLindex in a positioning node management module, marking the node sequence number TSLindex as a positioning node PostLindex, and returning to S2;
s10: judging whether all nodes are traversed in the matching process, if so, entering S11; if all the nodes are traversed, entering S12;
s11: assigning r+w to r, wherein w is a node range expansion coefficient, and the node range expansion coefficient can be adjusted through autonomous learning and returns to S8;
s12: acquiring the largest TSLindex in a TCP session list TcpSesseionList, assigning TSLindex+1 to TSLindex, wherein the TSLindex is the node sequence number TSLindex corresponding to the data packet, establishing a corresponding TCP session assembly list TcpList, adding the node sequence number TSLindex, a session ID and the TCP session assembly list TcpList corresponding to the data packet to the tail part of the TCP session list TcpSesseionList in a one-to-one mapping manner, adding TCP data corresponding to the data packet to the TCP session assembly list TcpList, storing the node sequence number TSLindex in a positioning node management module, and marking the node sequence number TSLindex as a positioning node PostLindex, and returning to S2;
and at the same time of the steps, the TCP session assembly linked list TcpList reorganizes the data packets according to the TCP data, and restores the original data.
In a preferred aspect, in the TCP data, the syn layer is used to record the beginning of a piece of data, denoted by 1; the fin layer is used for recording the end of a piece of data and is denoted by 0; the seq layer is used for recording the data sequence number of the data packet; the len layer is used for recording the length of data to be transmitted in the data packet; the prev layer is used for recording the data sequence number of the last data packet in sequence; the next layer is used for recording the data sequence number of the next data packet in sequence; the tcpdata layer is used to store the data to be transmitted in this packet.
In a preferred aspect, in the same TCP data, the data sequence number of the next layer is the data sequence number of the seq layer plus the length of the data to be transmitted in the packet.
As a preferred aspect, in the TCP session assembling linked list tcplaylist, selecting a data packet with a syn layer value of 1 as a starting node of the TCP session assembling linked list tcplaylist, acquiring a data sequence number of a next layer corresponding to the data packet, searching a data packet corresponding to a seq layer identical to the data sequence number, as a next data node of the TCP session assembling linked list tcplaylist, matching the data sequence number of a prev layer corresponding to the data node with the data sequence number corresponding to the seq layer of a previous data node, if the matching fails, disconnecting the link of the data packet, and continuing to search the data packet corresponding to the seq layer identical to the data sequence number of the next layer corresponding to the data packet; if the matching is successful, continuing the steps, and assembling the data nodes in the TCP session assembling linked list TcpList, and when the data sequence number of the data packet corresponding to the next layer is null and the value of the fin layer is 0, completing the assembly of the TCP session.
As a preferred aspect, the IP header information is stored in five-tuple form, including a source IP address, a destination IP address, a source port, a destination port, and a protocol number.
In a preferred aspect, in step S10, after determining that all nodes have been traversed, step S12 is not performed; storing the session ID corresponding to the data packet, and in steps S5 and S6, matching the session ID with the stored session ID each time a unique session ID is generated, if the matching fails, not performing an operation; if the matching is successful, according to the source IP address corresponding to the session ID which is successfully matched, a prompt message is sent to the local host corresponding to the source IP address to remind the local host to perform data transmission again, and the stored session ID is deleted.
An apparatus for TCP session reassembly, comprising:
the TCP transmission channel establishment module is used for establishing the connection between the target host and the local host;
the data packet acquisition module is used for acquiring a data packet, wherein the data packet comprises Ethernet header information, IP header information and TCP data, and the TCP data comprises a syn layer, a fin layer, a seq layer, a len layer, a prev layer, a next layer and a tcpdata layer;
the data processing module is used for judging the value stored in the syn layer of the data packet, judging whether the inside of the TCP session linked list is empty, generating a session ID and generating a node sequence number;
the TCP session linked list management module is used for establishing, storing and modifying a TCP session linked list;
the TCP session assembly linked list management module is used for establishing, storing and modifying a TCP session assembly linked list;
the positioning node management module is used for storing and releasing the corresponding node serial numbers after successful session ID matching each time;
and the session ID matching module is used for matching the session ID corresponding to the data packet with the session ID in the TCP session linked list.
As a preferred aspect, further comprising:
a session ID storage module, configured to store a session ID of a packet for which no beginning is found;
and the reminding module is used for reminding the local host to carry out data transmission again according to the session ID stored in the session ID storage module.
The invention has the following advantages:
1. the invention is based on that in a large-flow network environment, a plurality of data packets split by a section of data are always transmitted in adjacent sequence, and according to the last positioned node, the data packets are matched nearby the node, so that the matching times are reduced, and the positioning and reorganizing efficiency of TCP session is improved.
2. The invention ensures the integrity and accuracy of the data packet in the recombination process by matching the data sequence number of the prev layer corresponding to the data node with the data sequence number corresponding to the seq layer of the last data node.
3. According to the invention, the session ID of the data packet at the beginning can not be found out to be stored, the whole data packet is not stored any more, the storage space is reduced, the number of times of matching the data packet is reduced, and the recombination efficiency of the TCP session is further improved.
Drawings
Fig. 1 is a schematic structural diagram of an apparatus for TCP session reassembly according to an embodiment of the present invention.
Detailed Description
In order to make the technical solution of the present invention better understood by those skilled in the art, the technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
Example 1
In a specific embodiment, taking 10G bandwidth as an example for transmitting TCP data, the flow per second is about 1.25G, assuming that the average length of each data packet is 1000 bytes (in an actual network, the average length of one data packet is typically about 500 bytes to 700 bytes), the number of data packets transmitted per second is about 134 ten thousand, and in the about 134 ten thousand data packets, assuming that every 10 data packets are the same TCP session, the TCP reassembly linked list has about 13.4 ten thousand TCP sessions; assuming that each data message finds a corresponding TCP session only by comparing a linked list of 1/3, then about 598 ten thousand matches are required for 134 ten thousand data messages to find the corresponding TCP session; if the TCP five-tuple is not processed correspondingly in the matching process, the matching times are multiplied correspondingly. It can be seen that in the process of recombining the TCP session under the high-traffic network, finding a corresponding TCP session for each data packet consumes a great deal of performance of the computer, and for this case, a method for recombining the TCP session is specifically provided, which includes the following steps:
s1: establishing connection between a target host and a local host, and establishing an empty TCP session linked list TcpSessionList;
s2: acquiring a data packet, wherein the data packet comprises Ethernet header information, IP header information and TCP data, the IP header information is stored in a five-tuple form and comprises a source IP address, a destination IP address, a source port, a destination port and a protocol number, the TCP data comprises a syn layer, a fin layer, a seq layer, a len layer, a prev layer, a next layer and a tcpdata layer, and the syn layer is used for recording the beginning of a section of data and is denoted by 1; the fin layer is used for recording the end of a piece of data and is denoted by 0; of a plurality of data packets divided by one section of data, only the syn layer of one data packet is 1, the fin layer of one data packet is 0, and the syn layer and the fin layer of the other data packets are 2; the seq layer is used for recording the data sequence number of the data packet; the len layer is used for recording the length of data to be transmitted in the data packet; the prev layer is used for recording the data sequence number of the last data packet in sequence; the next layer is used for recording the data sequence number of the next data packet in sequence; the tcpdata layer is used for storing data to be transmitted in the data packet; in the same TCP data, the data sequence number of the next layer is the data sequence number of the seq layer plus the length of the data to be transmitted in the data packet;
s3: searching a value syn stored in a syn layer of the data packet according to the index, judging whether "syn= 1" is met, if so, indicating that the acquired data packet is the beginning of one piece of data, and entering S4; if "syn= 1" is not satisfied, it indicates that the packet is part of the ongoing TCP session reorganization, and S7 is entered;
s4: judging whether the inside of the TCP session list TcpSessionList is empty or not, if so, indicating that the inside of the TCP session list TcpSessionList is temporarily empty, and entering S5; if the inside of the TCP session list TcpSessionList is not empty, indicating that the inside of the TCP session list TcpSessionList has contents, and entering S6;
s5: searching IP header information of the data packet according to the index, calculating through a hash algorithm according to five-tuple information of the IP header information, generating a unique session ID, generating a node sequence number TSLindex and establishing a corresponding TCP session assembly linked list TcpList, and adding the node sequence number TSLindex, the session ID and the TCP session assembly linked list TcpList corresponding to the data packet into the TCP session linked list TcpSessionList in a one-to-one mapping manner, wherein each node sequence number TSLindex corresponds to one node; meanwhile, adding TCP data corresponding to the data packet into a TCP session assembly linked list TcpList, storing the node sequence number TSLindex in a positioning node management module, marking the node sequence number TSLindex as a positioning node PostLindex, and returning to S2;
s6: releasing a node sequence number TSLindex stored in a positioning node management module, searching IP header information of the data packet according to an index, calculating according to five-tuple information of the IP header information through a hash algorithm, generating a unique session ID, acquiring the largest TSLindex in a TCP session linked list TcpSessionList, assigning TSLindex+1 to the TSLindex, wherein the TSLindex is the node sequence number TSLindex corresponding to the data packet, establishing a corresponding TCP session assembly linked list TcpList, adding the node sequence number TSLindex, the session ID and the TCP session assembly linked list TcpList corresponding to the data packet to the tail of the TCP session linked list TcpSessionList in a one-to-one mapping manner, simultaneously adding TCP data corresponding to the data packet to the TCP session assembly linked list TcpList, storing the node sequence number TSLindex in the positioning node management module as a positioning node PostLindex, and returning to S2;
s7: finding out a corresponding node in a TCP session linked list TcpSesseionList according to a node sequence number TSLindex stored in a positioning node management module, searching IP header information of the data packet according to an index, and calculating according to five-tuple information of the IP header information by a hash algorithm to generate a session ID;
s8: the session ID is matched with the session ID corresponding to all the node serial numbers TSLindex which satisfy the conditions that the PostLindex-r is less than or equal to TSLindex and less than or equal to PostLindex+r one by one, wherein r is a preset node range and is determined by the actual network environment flow, if the matching is successful, the TCP session corresponding to the data packet is found, and S9 is entered; if the matching fails, the TCP session corresponding to the data packet is not found, and S10 is entered;
because a plurality of data packets split by a section of data are always transmitted in adjacent sequence in a large-flow network environment, according to the node positioned last time, the matching times are reduced by matching the data packets near the node, and the positioning and reorganizing efficiency of the TCP session is improved;
s9: acquiring a node sequence number TSLindex corresponding to successful matching, adding TCP data corresponding to the data packet into a TCP session assembly linked list TcpList corresponding to the node sequence number TSLindex, storing the node sequence number TSLindex in a positioning node management module, marking the node sequence number TSLindex as a positioning node PostLindex, and returning to S2;
s10: judging whether all nodes are traversed in the matching process, if so, entering S11; if all the nodes are traversed, entering S12;
s11: assigning r+w to r, wherein w is a node range expansion coefficient, and the node range expansion coefficient can be adjusted through autonomous learning and returns to S8;
s12: acquiring the largest TSLindex in a TCP session list TcpSesseionList, assigning TSLindex+1 to TSLindex, wherein the TSLindex is the node sequence number TSLindex corresponding to the data packet, establishing a corresponding TCP session assembly list TcpList, adding the node sequence number TSLindex, a session ID and the TCP session assembly list TcpList corresponding to the data packet to the tail part of the TCP session list TcpSesseionList in a one-to-one mapping manner, adding TCP data corresponding to the data packet to the TCP session assembly list TcpList, storing the node sequence number TSLindex in a positioning node management module, and marking the node sequence number TSLindex as a positioning node PostLindex, and returning to S2;
and at the same time of the steps, the TCP session assembly linked list TcpList reorganizes the data packets according to the TCP data, and restores the original data.
Selecting a data packet with the value of 1 of a syn layer from a TCP session assembly linked list TcpList as a starting node of the TCP session assembly linked list TcpList, acquiring a data sequence number of a next layer corresponding to the data packet, searching a data packet corresponding to a seq layer identical to the data sequence number as a next data node of the TCP session assembly linked list TcpList, matching the data sequence number of a prev layer corresponding to the data node with the data sequence number corresponding to the seq layer of a previous data node, if the matching fails, indicating that the data packet corresponding to the data node does not belong to the same kind of data, disconnecting the link of the data packet, and continuously searching the data packet corresponding to the seq layer identical to the data sequence number of the next layer corresponding to the data packet; if the matching is successful, continuing the steps, and assembling the data nodes in the TCP session assembling linked list TcpList, and when the data sequence number of the data packet corresponding to the next layer is null and the value of the fin layer is 0, completing the assembly of the TCP session.
The invention ensures the integrity and accuracy of the data packet in the recombination process by matching the data sequence number of the prev layer corresponding to the data node with the data sequence number corresponding to the seq layer of the last data node.
In the implementation, due to the problems of network fluctuation, data verification errors and the like, the problem of error transmission or retransmission occurs in the transmission process of the data packet, and for the error transmission, the data packet cannot find the beginning of the data packet, if the data packet is built to the node in the TCP session linked list TcpSess according to the step S12, the space is obviously wasted, the matching times of the session ID in the step S8 are increased, and the recombination efficiency of the TCP session is reduced, so that in the step S10, all the nodes are judged to be traversed, and the step S12 is not performed; and storing the session ID corresponding to the data packet, in steps S5 and S6, matching the unique session ID with the stored session ID every time, if the matching fails, not operating, if the matching is successful, sending prompt information to a local host corresponding to the source IP address according to the source IP address corresponding to the session ID which is successfully matched, reminding the local host to perform data transmission again, and deleting the stored session ID.
According to the invention, the session ID of the data packet at the beginning can not be found out to be stored, the whole data packet is not stored any more, the storage space is reduced, the number of times of matching the data packet is reduced, and the recombination efficiency of the TCP session is further improved.
Example 2
An apparatus for TCP session reassembly, as shown in fig. 1, includes:
the TCP transmission channel establishment module is used for establishing the connection between the target host and the local host, and realizing the connection in a three-message exchange mode;
the data packet acquisition module is used for acquiring a data packet in the TCP transmission process, wherein the data packet comprises Ethernet header information, IP header information and TCP data, and the TCP data comprises a syn layer, a fin layer, a seq layer, a len layer, a prev layer, a next layer and a tcpdata layer;
the data processing module is used for judging the value stored in the syn layer of the data packet, judging whether the inside of the TCP session linked list is empty, generating a session ID and generating a node sequence number;
the TCP session linked list management module is used for establishing, storing and modifying a TCP session linked list;
the TCP session assembly linked list management module is used for establishing, storing and modifying a TCP session assembly linked list;
the positioning node management module is used for storing and releasing the corresponding node serial numbers after successful session ID matching each time, so that the subsequent positioning of session ID matching is facilitated;
the session ID matching module is used for matching the session ID corresponding to the data packet with the session ID in the TCP session linked list according to the positioning node and the preset node range;
in order to store the session ID of the packet whose beginning cannot be found, as shown in fig. 1, the system further includes:
the session ID storage module is used for storing the session ID of the data packet with the beginning which cannot be found, so that the data packet with the beginning which can be found with the same session ID can be conveniently searched later;
and the reminding module is used for reminding the local host to carry out data transmission again according to the session ID stored in the session ID storage module, so as to avoid the loss of the data packet.
It will be understood that modifications and variations will be apparent to those skilled in the art from the foregoing description, and it is intended that all such modifications and variations be included within the scope of the following claims. Parts of the specification not described in detail belong to the prior art known to those skilled in the art.

Claims (8)

1. A method for reassembling a TCP session, comprising the steps of:
s1: establishing connection between a target host and a local host, and establishing an empty TCP session linked list TcpSessionList;
s2: acquiring a data packet, wherein the data packet comprises Ethernet header information, IP header information and TCP data, and the TCP data comprises a syn layer, a fin layer, a seq layer, a len layer, a prev layer and a next layer
A layer and a tcpdata layer;
s3: searching a value syn stored in a syn layer of the data packet according to the index, judging whether "syn= 1" is true, if so, proceeding to S4; if "syn= 1" is not true, the process proceeds to S7;
s4: judging whether the inside of the TCP session list TcpSessionList is empty or not, if so, entering S5; describing the existing content in the TCP session list TcpSess List, and entering S6;
s5: searching IP header information of the data packet according to the index, generating a unique session ID according to the IP header information, generating a node sequence number TSLindex and establishing a corresponding TCP session assembly linked list TcpList, and adding the node sequence number TSLindex, the session ID and the TCP session assembly linked list TcpList corresponding to the data packet to the TCP session linked list in a one-to-one mapping manner
In the TcpSessionList, each node sequence number TSLindex corresponds to one node; meanwhile, the TCP data corresponding to the data packet is added to a TCP session assembly linked list
In the TcpList, storing the node sequence number TSLindex in a positioning node management module, marking the node sequence number TSLindex as a positioning node PostLindex, and returning to S2;
s6: releasing a node sequence number TSLindex stored in a positioning node management module, searching IP header information of the data packet according to an index, generating a unique session ID according to the IP header information, acquiring the largest TSLindex in a TCP session linked list TcpSessionList, assigning TSLindex+1 to the TSLindex, wherein the TSLindex is the node sequence number TSLindex corresponding to the data packet, establishing a corresponding TCP session assembly linked list TcpList, adding the node sequence number TSLindex, the session ID and the TCP session assembly linked list TcpList corresponding to the data packet to the tail of the TCP session linked list TcpSessionList in a one-to-one mapping manner, adding TCP data corresponding to the data packet to the TCP session assembly linked list TcpList, storing the node sequence number TSLindex in the positioning node management module as a positioning node PostLindex, and returning to S2;
s7: finding a corresponding node in a TCP session linked list TcpSessionList according to a node sequence number TSLindex stored in a positioning node management module, searching IP header information of the data packet according to an index, and generating a session ID according to the IP header information;
s8: the session ID is matched with the session ID corresponding to all the node serial numbers TSLindex which meet the condition that the PostLindex-r is less than or equal to TSLindex and less than or equal to PostLindex+r, wherein r is a preset node range, if the matching is successful, the S9 is entered; if the matching fails, entering S10;
s9: acquiring a node sequence number TSLindex corresponding to successful matching, adding TCP data corresponding to the data packet into a TCP session assembly linked list TcpList corresponding to the node sequence number TSLindex, storing the node sequence number TSLindex in a positioning node management module, marking the node sequence number TSLindex as a positioning node PostLindex, and returning to S2;
s10: judging whether all nodes are traversed in the matching process, if so, entering S11; if all the nodes are traversed, entering S12;
s11: assigning r+w to r, wherein w is a node range expansion coefficient, and the node range expansion coefficient can be adjusted through autonomous learning and returns to S8;
s12: acquiring the largest TSLindex in a TCP session list TcpSesseionList, assigning TSLindex+1 to TSLindex, wherein the TSLindex is the node sequence number TSLindex corresponding to the data packet, establishing a corresponding TCP session assembly list TcpList, adding the node sequence number TSLindex, a session ID and the TCP session assembly list TcpList corresponding to the data packet to the tail part of the TCP session list TcpSesseionList in a one-to-one mapping manner, adding TCP data corresponding to the data packet to the TCP session assembly list TcpList, storing the node sequence number TSLindex in a positioning node management module, and marking the node sequence number TSLindex as a positioning node PostLindex, and returning to S2;
and at the same time of the steps, the TCP session assembly linked list TcpList reorganizes the data packets according to the TCP data, and restores the original data.
2. A method for reassembling a TCP session according to claim 1, wherein in the TCP data, the syn layer is used to record the beginning of a piece of data, denoted by 1; the fin layer is used for recording the end of a piece of data and is denoted by 0; the seq layer is used for recording the data sequence number of the data packet; the len layer is used for recording the length of data to be transmitted in the data packet; the prev layer is used for recording the data sequence number of the last data packet in sequence; the next layer is used for recording the data sequence number of the next data packet in sequence; the tcpdata layer is used to store the data to be transmitted in this packet.
3. A method according to claim 2, wherein the sequence number of the next layer is the sequence number of the seq layer plus the length of the data to be transmitted in the packet in the same TCP data.
4. A method for reorganizing a TCP session according to claim 3, wherein, in a TCP session assembly linked list tcplaylist, a data packet with a syn layer value of 1 is selected as a starting node of the TCP session assembly linked list tcplaylist, a data sequence number of a next layer corresponding to the data packet is obtained, a data packet corresponding to a seq layer with the same data sequence number is searched for as a next data node of the TCP session assembly linked list tcplaylist, the data sequence number of a prev layer corresponding to the data node is matched with the data sequence number corresponding to a seq layer of a previous data node, if the matching fails, the link of the data packet is disconnected, and the data packet corresponding to the seq layer with the same data sequence number of the next layer corresponding to the data packet is continuously searched; if the matching is successful, continuing the steps, and assembling the data nodes in the TCP session assembling linked list TcpList, and when the data sequence number of the data packet corresponding to the next layer is null and the value of the fin layer is 0, completing the assembly of the TCP session.
5. The method of claim 4, wherein the IP header information is stored in five-tuple form, including a source IP address, a destination IP address, a source port, a destination port, and a protocol number.
6. The method according to claim 5, wherein in step S10, after determining that all nodes have been traversed, step S12 is not performed; storing the session ID corresponding to the data packet, and in steps S5 and S6, matching the session ID with the stored session ID each time a unique session ID is generated, if the matching fails, not performing an operation; if the matching is successful, according to the source IP address corresponding to the session ID which is successfully matched, a prompt message is sent to the local host corresponding to the source IP address to remind the local host to perform data transmission again, and the stored session ID is deleted.
7. An apparatus for TCP session reassembly, comprising:
the TCP transmission channel establishment module is used for establishing the connection between the target host and the local host; the data packet acquisition module is used for acquiring a data packet, wherein the data packet comprises Ethernet header information, IP header information and TCP data, and the TCP data comprises a syn layer, a fin layer, a seq layer, a len layer, a prev layer, a next layer and a tcpdata layer;
a data processing module for judging the value stored in syn layer of the data packet, and for
Judging whether the inside of the TCP session linked list is empty, generating a session ID and generating a node sequence number;
the TCP session linked list management module is used for establishing, storing and modifying a TCP session linked list;
the TCP session assembly linked list management module is used for establishing, storing and modifying a TCP session assembly linked list;
the positioning node management module is used for storing and releasing the corresponding node serial numbers after successful session ID matching each time;
and the session ID matching module is used for matching the session ID corresponding to the data packet with the session ID in the TCP session linked list.
8. The apparatus for TCP session reassembly as defined in claim 7, further comprising:
a session ID storage module, configured to store a session ID of a packet for which no beginning is found;
and the reminding module is used for reminding the local host to carry out data transmission again according to the session ID stored in the session ID storage module.
CN202211721286.3A 2022-12-30 2022-12-30 TCP session reorganization method and device Pending CN116032894A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211721286.3A CN116032894A (en) 2022-12-30 2022-12-30 TCP session reorganization method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211721286.3A CN116032894A (en) 2022-12-30 2022-12-30 TCP session reorganization method and device

Publications (1)

Publication Number Publication Date
CN116032894A true CN116032894A (en) 2023-04-28

Family

ID=86070135

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211721286.3A Pending CN116032894A (en) 2022-12-30 2022-12-30 TCP session reorganization method and device

Country Status (1)

Country Link
CN (1) CN116032894A (en)

Similar Documents

Publication Publication Date Title
US6385199B2 (en) Method and apparatus for packet transmission with header compression
RU2208303C2 (en) Effective transport of internet protocol packets using asynchronous mode of adaptation level two transfer
US7355971B2 (en) Determining packet size in networking
US8009672B2 (en) Apparatus and method of splitting a data stream over multiple transport control protocol/internet protocol (TCP/IP) connections
US5931961A (en) Discovery of acceptable packet size using ICMP echo
US8255567B2 (en) Efficient IP datagram reassembly
US6333933B2 (en) Programmable network
US7212527B2 (en) Method and apparatus for communicating using labeled data packets in a network
US20050117577A1 (en) Method and system for assembling segmented frames of data transmitted over a backbone network
CN102325076B (en) Method for discovering PMTU (Path Maximum Transfer Unit) and node
EP0525174A1 (en) Tracking sequence numbers in packet data communication system.
US7302491B2 (en) System and method of reducing data corruption due to recycled IP identification numbers
US7346669B2 (en) Method, apparatus and system for processing message bundles on a network
WO2021088813A1 (en) Packet encapsulating method and apparatus, and packet decapsulating method and apparatus
US6871312B2 (en) Method and apparatus for time stamping data
EP3203699A1 (en) Method for man-in-the-middle processing for tcp without protocol stack
US9548921B2 (en) Compression of routing information exchanges
CN112436998B (en) Data transmission method and electronic equipment
KR20020087053A (en) Method for transmission of messages split over several packets
CN116032894A (en) TCP session reorganization method and device
CN109067503B (en) Data retransmission method and device
US11196792B2 (en) Method, device and system for transmitting data
CN116471283A (en) File transmission method
EP1355472B1 (en) Method and system to determine the most appropriate software layer after reception of a packet
CN113225376B (en) Ethernet frame and SDN data frame adapting method based on FPGA

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination