Content of the invention
When rebuilding tcp connection for solving application program in prior art, do not send successfully in original tcp Connection CacheData can be dropped, and lead to the part operation having executed and process the technological deficiency lost, and the present invention provides a kind of seamless heavyBuild the system and method for tcp connection.
One aspect of the present invention is:
There is provided a kind of method that seamless reconstruction tcp connects, including step: s1, tcp client determines what needs were rebuildOriginal tcp connects, and adds connection reconstruction option in tcp syn message, and described connection reconstruction option includes original tcp and connectsSource ip address and source port number and purpose ip address and destination slogan;S2, tcp service end finds according to the Reconstruction OptionOriginal tcp connects, and re-creates newly-built tcp connection according to the connection attribute that original tcp connects;S3, when newly-built tcp connect woundBuild when completing, tcp client each will be corresponding with the data in order caching for original tcp linkup transmit caching with tcp service endCopy in the transmission caching and order caching that newly-built tcp connects.
Another technical solution used in the present invention is:
There is provided the system that a kind of seamless reconstruction tcp connects, including tcp client and tcp service end, described tcp clientEnd includes the first connection reconstruction module, described tcp service end includes the second connection reconstruction module;Described first connection reconstruction moduleNeed the original tcp being rebuild to connect for determining, and add connection reconstruction option in tcp syn message, and be used forWhen newly-built tcp connection establishment completes, the data in original tcp linkup transmit caching and order caching is accordingly copied to newlyBuild in the transmission caching and order caching of tcp connection, wherein said connection reconstruction option includes the source ip address that original tcp connectsWith source port number and purpose ip address and destination slogan;Described second connection reconstruction module is used for being looked for according to the Reconstruction OptionConnect to original tcp, and newly-built tcp is re-created according to the connection attribute that original tcp connects and connect, and for when newly-builtWhen tcp connection establishment completes, the data in original tcp linkup transmit caching and order caching is accordingly copied to newly-built tcpIn the transmission caching and order caching that connect.
The invention has the beneficial effects as follows: when being different from the application program of prior art and rebuilding tcp and connect, original tcp connectsDo not send successful data in caching can be dropped, lead to the part operation having executed and process the technological deficiency lost,The present invention provides the system and method that a kind of seamless reconstruction tcp connects, when application program needs to rebuild tcp connection, by original tcpThere is no the data processing in linkup transmit and order caching, copy in newly-built tcp linkup transmit and order caching, tcp is evenAfter connecing reconstruction, application program can continue transceiving data in newly-built tcp connection, and original tcp does not have the number processing in connectingAccording to losing, make application program without the concern for and solve to rebuild the tcp data loss problem that leads to of connection.
Specific embodiment
By the technology contents of the detailed description present invention, structural feature, realized purpose and effect, below in conjunction with embodimentAnd coordinate accompanying drawing to be explained in detail.
Refer to Fig. 1, be the execution flow chart of a kind of method that seamless reconstruction tcp connects in an embodiment of the present invention.This is seamless to rebuild the method that tcp connects and includes step:
Step s1, tcp client determines needs the original tcp being rebuild to connect, and adds even in tcp syn messageConnect the Reconstruction Option, described connection reconstruction option includes source ip address and source port number and the purpose ip address that original tcp connectsAnd destination slogan.
Refer to Fig. 2, be the schematic diagram increasing the Reconstruction Option under tcp syn message options option list.tcpSyn message is first handshake packet of three-way handshake bag, and in tcp/ip agreement, tcp agreement provides reliable Connection Service, adoptsSet up a connection with three-way handshake:
Shake hands for the first time: when setting up connection, client sends syn bag (syn=j) and arrives server, and enters syn_sentState, waiting for server confirms, syn is synchronizing sequence numbering (synchronize sequence numbers).Hold for the second timeHand: server receives syn bag it is necessary to confirm the syn (ack=j+1) of client, oneself also sends a syn bag (syn=simultaneouslyK), i.e. syn+ack bag, now server enter syn_recv state.Third time is shaken hands: client receives the syn+ of serverAck bag, sends to server and confirms bag ack (ack=k+1), and this bag is sent, and client and server entersEstablished state.After completing above-mentioned three-way handshake, client and server start to transmit data.
Step s2, tcp service end finds original tcp according to the Reconstruction Option and connects, and the connection being connected according to original tcp belongs toProperty re-create newly-built tcp and connect.
Step s3, when newly-built tcp connects establishment and completes, original tcp is each connected by tcp client and tcp service endSend the data in caching and order caching accordingly to copy in the transmission caching and order caching that newly-built tcp connects.
In the present embodiment, described step s1 specifically includes:
Step s11, determination need the original tcp being rebuild to connect;
The connection attribute that step s12, the original tcp of reading connect, described connection attribute includes tcp source ip address, tcp purposeIp address, tcp source port number, tcp destination slogan, original sequence number and original confirmation number;
The sequence number that step s13, the newly-built tcp of initialization connect and confirmation number are respectively a First ray number and the first confirmationNumber, then initiate newly-built tcp connection request to tcp service end.
In the present embodiment, described step s2 specifically includes:
Step s21, when receiving newly-built tcp connection request, tcp service end judge tcp syn message whether there is weightBuild option;
Step s22, when judge tcp syn message there is the Reconstruction Option when, found former according to the field in the Reconstruction OptionThere is tcp to connect, obtain the connection attribute that this original tcp connects, connected according to the newly-built tcp of connection attribute setting that original tcp connectsConnect attribute, wherein, sequence number=original sequence number -1 that newly-built tcp connects, confirmation number=original confirmation that newly-built tcp connectsNumber -1.
It is described in detail with reference to the method that a specific implementation step connects to above-mentioned seamless reconstruction tcp.Please joinRead Fig. 3, be that tcp client is realized rebuilding the interaction diagrams that tcp is connected with tcp service end.Tcp client and tcp service endThe interaction realizing rebuilding tcp connection comprises the steps:
(1) tcp client determines needs the tcp rebuilding to connect;
(2) tcp client reads the connection attribute that original tcp connects;
(3) connection attribute of the newly-built connection of tcp client initialization;
(4) tcp client initiates the request of the tcp syn with the Reconstruction Option;
(5) tcp service end carries out port snoop;
(6) tcp service end receives the request of the tcp syn with the Reconstruction Option;
(7) find original tcp according to the Reconstruction Option to connect;
(8) tcp service end reads the connection attribute that original tcp connects;
(9) tcp service end initializes the connection attribute of newly-built connection;
(10) tcp service end sends tcp syn+ack response message;
(11) tcp client receives tcp syn+ack response message;
(12) tcp client sends tcp ack response message, then respectively enters step (13) and step (15);
(13) original tcp connection data duplication is connected by tcp client to newly-built tcp;
(14) the normal transceiving data of tcp client.
(15) tcp service end receives tcp ack response message;
(16) original tcp connection data duplication is connected by tcp service end to newly-built tcp;
(17) the normal transceiving data of tcp service end.
Another aspect of the present invention provides the system that a kind of seamless reconstruction tcp connects, the side that above-mentioned seamless reconstruction tcp connectsMethod is applied in this system.The system of reconstruction tcp connection that this is seamless includes tcp client and tcp service end.Described tcp visitorFamily end includes the first connection reconstruction module, described tcp service end includes the second connection reconstruction module.
Described first connection reconstruction module is used for determining needs the original tcp being rebuild to connect, and in tcp syn messageMiddle interpolation connection reconstruction option, when newly-built tcp connection establishment completes, by original tcp linkup transmit caching and order cachingData accordingly copy in the transmission caching and order caching that newly-built tcp connects, wherein, described connection reconstruction option includesSource ip address and source port number and purpose ip address and destination slogan that original tcp connects.
Described second connection reconstruction module is used for finding original tcp connection according to the Reconstruction Option, and is connected according to original tcpConnection attribute re-create newly-built tcp and connect, and for when newly-built tcp connects establishment and completes, original tcp being connected and sending outThe data in caching and order caching is sent accordingly to copy in the transmission caching and order caching that newly-built tcp connects.
In the present embodiment, described first connection reconstruction module specifically includes determining module, read module, asks modulusBlock, the first replication module.
Determining module is used for determining needs the original tcp being rebuild to connect.Read module is used for reading original tcp connectionConnection attribute, described connection attribute includes tcp source ip address, the ip address of tcp mesh, tcp source port number, tcp destination interfaceNumber, original sequence number and original confirmation number.Request module is used for initializing the sequence number of newly-built tcp connection and confirmation number is respectivelyFirst ray number and confirmation No. the first, then initiate newly-built tcp connection request to tcp service end.
In the present embodiment, described second connection reconstruction module specifically includes judge module, setup module, the second duplicationModule.Judge module is used for, when tcp service end receives newly-built tcp connection request, judging that tcp syn message whether there is weightBuild option.Setup module is used for when described judge module judges that tcp syn message has the Reconstruction Option, according in the Reconstruction OptionField find original tcp and connect, obtain the connection attribute that this original tcp connects, the connection attribute connecting according to original tcpNewly-built tcp connection attribute is set, wherein, sequence number=original sequence number -1 that newly-built tcp connects, the confirmation that newly-built tcp connectsNumber=original confirmation number -1.
Described first replication module and the second replication module are respectively used to when newly-built tcp connection establishment completes, by tcp visitorData in family end and tcp service end original tcp linkup transmit caching and order caching accordingly copies to what newly-built tcp connectedSend in caching and order caching.
The invention has the beneficial effects as follows: when being different from the application program of prior art and rebuilding tcp and connect, original tcp connectsDo not send successful data in caching can be dropped, lead to the part operation having executed and process the technological deficiency lost,The present invention provides the system and method that a kind of seamless reconstruction tcp connects, when application program needs to rebuild tcp connection, by original tcpThere is no the data processing in linkup transmit and order caching, copy in newly-built tcp linkup transmit and order caching, tcp is evenAfter connecing reconstruction, application program can continue transceiving data in newly-built tcp connection, and original tcp does not have the number processing in connectingAccording to losing, make application program without the concern for and solve to rebuild the tcp data loss problem that leads to of connection.
The foregoing is only embodiments of the invention, not thereby limit the present invention the scope of the claims, every using thisEquivalent structure or equivalent flow conversion that bright specification and accompanying drawing content are made, or directly or indirectly it is used in other related skillsArt field, is included within the scope of the present invention.