[go: up one dir, main page]

CN103036957A - Method and device of data communication - Google Patents

Method and device of data communication Download PDF

Info

Publication number
CN103036957A
CN103036957A CN2012105166150A CN201210516615A CN103036957A CN 103036957 A CN103036957 A CN 103036957A CN 2012105166150 A CN2012105166150 A CN 2012105166150A CN 201210516615 A CN201210516615 A CN 201210516615A CN 103036957 A CN103036957 A CN 103036957A
Authority
CN
China
Prior art keywords
data packet
socket
checkpoint
receiving queue
queue
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.)
Granted
Application number
CN2012105166150A
Other languages
Chinese (zh)
Other versions
CN103036957B (en
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.)
XFusion Digital Technologies Co Ltd
Original Assignee
Huawei Technologies 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201210516615.0A priority Critical patent/CN103036957B/en
Publication of CN103036957A publication Critical patent/CN103036957A/en
Application granted granted Critical
Publication of CN103036957B publication Critical patent/CN103036957B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明实施例提供一种基于套接字的数据通信方法和数据通信装置,该方法包括:在接收到客户端发送的数据包后,寻找该数据包的宿主套接字;寻找所述宿主套接字的接收队列的尾端的数据包,判断所述尾端的数据包的检查点标志位是否被置为表示该接收队列内容已经被检查点进程保存到检查点文件中的值;如果所述尾端数据包的检查点标志位被置为表示该接收队列内容已经被检查点进程保存到检查点文件中的值,则直接丢弃接收到的数据包。

Embodiments of the present invention provide a socket-based data communication method and data communication device. The method includes: after receiving a data packet sent by a client, searching for the host socket of the data packet; The data packet at the tail end of the receiving queue of the socket, and judge whether the checkpoint flag bit of the data packet at the tail end is set as a value indicating that the content of the receiving queue has been saved in the checkpoint file by the checkpoint process; if the tail If the checkpoint flag bit of the terminal data packet is set to a value indicating that the content of the receiving queue has been saved in the checkpoint file by the checkpoint process, the received data packet is directly discarded.

Description

A kind of data communications method and device
Technical field
The invention belongs to networking technology area, relate in particular to a kind of data communications method and device.
Background technology
Along with the fast development of current network technology, a lot of traditional services have been transferred in the network environment and have been implemented such as financial transaction, business administration etc.Because the fragility of network environment often causes server to need to safeguard, in case server is in maintenance state, does not take necessary measure if having, the service that provides so will be interrupted the long time.And for the application of enterprise-level, the interruption of so long service is unacceptable.
In order to overcome the problems referred to above, high availability cluster now can move server system incessantly, and this server system generally is comprised of two or more nodes.If certain node needs to safeguard that the service processes on this node can be continued service by real-time migration to secondary node.
Service processes is carried out real-time migration, need to suspend this process to be migrated at server, and with this process execution state information be saved in the file of checkpoint (checkpoint), then stop this process.A newly-built process and from inspection file obtained above, read in the execution state information of original process on secondary node afterwards, thus continue to provide service.
Service processes often comprises one and monitors socket and receive the connection of client in running, and have some sockets of opening just with the client transmissions data that connected.Therefore in the process that service processes is moved, also need the socket of opening of this service processes is moved, therefore need the socket state information of opening of this service processes is saved in the check point file.
In the process that socket is moved, network protocol stack still works.Migration since a service processes, to the migration of this service processes finish (namely this service processes is rebulid on secondary node) during in, packet can't normally receive, but client not can be appreciated that again the packet that it sends is not normally received, so the packet that client sends during the period will be lost.
In addition, in transition process, will stop former service processes, client will be received the FIN packet that server sends, and close simultaneously the socket of the service processes that stops, client is owing to perceive connection that the migration of process causes and disconnect therefore and need to reconnect server.
Summary of the invention
In view of this, the object of the present invention is to provide a kind of data communications method based on socket and device, can avoid because the phenomenon of the data-bag lost that process migration causes.
For achieving the above object, one embodiment of the present of invention provide a kind of data communications method based on socket, comprising:
Behind the packet that receives the client transmission, seek host's socket of this packet;
Seek the packet of tail end of the receiving queue of described host's socket, the checkpoint flag bit of judging the packet of described tail end whether be set to this receiving queue content of expression the tested process of making an inventory of be saved in value in the check point file;
If the checkpoint flag bit of described endian data bag be set to this receiving queue content of expression the tested process of making an inventory of be saved in value in the check point file, then directly abandon the packet that receives.
On the other hand, the embodiment of the invention also provides a kind of data communication equipment, comprising:
The packet receiving element is used for receiving the packet that client sends;
Socket is searched the unit, is used for seeking host's socket of the described packet that receives;
Packet is searched the unit, is used for seeking the packet of tail end of the receiving queue of described host's socket;
Whether judging unit, the checkpoint flag bit that is used for judging the packet of described tail end are set to that this receiving queue content of expression is tested makes an inventory of the value that process is saved in check point file;
Discarding unit, the judged result that is used for when described judging unit is yes, then abandons the packet that receives.
According to the embodiment of the invention, after receiving packet, at first check the checkpoint flag bit in the packet of receiving queue tail end of host's socket of this packet, the receiving queue content that whether is set to this host's socket of the expression tested process of making an inventory of is saved in value in the check point file, if, then can be with the data packet discarding that receives, and then can be so that client recognizes that the data that this client sends are not normally received, carry out follow-up retransmission steps, can not produce the problem of packet loss.
Description of drawings
In order to be illustrated more clearly in the embodiment of the invention or technical scheme of the prior art, the below will do to introduce simply to the accompanying drawing of required use in embodiment or the description of the Prior Art, apparently, accompanying drawing in the following describes is some embodiments of the present invention, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain according to these accompanying drawings other accompanying drawing.
Fig. 1 is the schematic diagram that the embodiment of the invention provides a kind of data communications method based on socket;
Fig. 2 is the schematic diagram of a specific embodiment of the data communications method based on socket provided by the invention;
Fig. 3 and Fig. 4 are respectively before revising and the form schematic diagram of amended tcp data bag;
Fig. 5 is a kind of flow chart of closing socket that provides in the embodiment of the invention;
Fig. 6 is the schematic diagram of a kind of data communication equipment of providing of the embodiment of the invention.
Embodiment
For the purpose, technical scheme and the advantage that make the embodiment of the invention clearer, below in conjunction with the accompanying drawing in the embodiment of the invention, technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that obtains under the creative work prerequisite.
The embodiment of the invention provides a kind of data communications method based on socket, and as shown in Figure 1, the method comprises the steps:
Step S101: behind the packet that receives the client transmission, seek host's socket of this packet;
Step S102: the packet of seeking the receiving queue tail end of host's socket;
Step S103: the checkpoint flag bit of the packet of the tail end that searches out among the determining step S102 whether be set to this receiving queue content of expression the tested process of making an inventory of be saved in value in the check point file;
Step S104: when the judged result of step S103 when being, directly abandon the packet that receives.
In the data communications method that the embodiment of the invention provides, the receiving queue content that has increased the host's socket that is used for representing this packet in the packet that client sends the tested process of making an inventory of is saved in flag bit (can be abbreviated as CKPT) in the check point file.When the value of CKPT flag bit tested when making an inventory of process and being saved in value in the check point file for the receiving queue content of host's socket of this packet of expression, represent current reception packet host's socket the receiving queue content the tested process of making an inventory of be saved in the check point file, that is to say that this host's socket is moved, this moment can be with the data packet discarding that receives, and then can be so that client recognizes that the data that this client sends are not normally received, carry out follow-up retransmission steps, can not produce the problem of packet loss.
Below describe specific implementation of the present invention in detail with a concrete example.
As shown in Figure 2, this scheme comprises the steps:
Step S201: the socket to process moves;
Step S202: if the receiving queue of the socket that should move is not empty, then checkpointing is saved in the receiving queue content of this socket in the check point file, and with the value of the CKPT flag bit in the packet of this receiving queue tail end be set to this receiving queue content of expression the tested process of making an inventory of be saved in value in the check point file.
In addition, the receiving queue that it is also conceivable that the socket that is moved in the present embodiment is empty situation, at this moment, just construct the packet of a sky, here so-called empty packet refers to not comprise the packet of real data, and the value of the CKPT flag bit in should the packet of sky be set to expression the tested process of making an inventory of be saved in value in the check point file.
In embodiments of the present invention, can revise the form of tcp data bag, use a reservation bit position of original tcp data bag as the CKPT flag bit.A kind of concrete scheme can be referring to Fig. 3 and Fig. 4.The form of the tcp data bag before revising has been shown among Fig. 3, and Fig. 4 shows the form of amended tcp data bag, and comparison diagram 4 and Fig. 3 have utilized in some reservation bits position of original tcp data bag one as the CKPT flag bit as can be known in this scheme.
When the reservation bit position of adopting original tcp data bag during as the CKPT flag bit, can not exert an influence to the performance of network protocol stack and other links in the network service process.
Step S203: when receiving the packet of client transmission, the packet that receives is carried out the correctness verification.
The correctness verification can comprise whether correct etc. whether packet belong to local, stem verification and.
Step S204: whether the correctness verification among the determining step S203 is passed through, and if so, then continues execution in step S205, if not, and direct execution in step S210 then: packet discard.
Step S205: host's socket of seeking this packet that receives.
Can from deposit the Hash table of opening socket, seek in practice the transmit control block under this packet, and find host's socket by this transmit control block.In fact, each opens socket and receiving queue is safeguarded in a Hash (hash) table, and the key assignments of four-tuple (source IP, purpose IP, source port, destination interface) in Hash table that belongs to the packet of same socket is identical, therefore can determine the socket that it is affiliated, i.e. host's socket according to the four-tuple of the packet that receives.
Step S206: after finding host's socket, seek the packet of the receiving queue tail end of this host's socket.
Step S207: the value of CKPT flag bit of judging the packet of this tail end whether be set to this receiving queue content of expression the tested process of making an inventory of be saved in value in the check point file, if judged result is yes, direct execution in step S210 then: packet discard; If the determination result is NO, then continue execution in step S208.
Step S208: the tail end that the packet that receives is suspended to the receiving queue of its host's socket.
Step S209: to client feedback ACK acknowledge message, this packet that the expression client sends serviced often rectifying receives.
In the process that process is moved, can finish former process, all of closing simultaneously former process are opened socket, another embodiment of the present invention also is optimized the flow process of closing socket, as shown in Figure 5, also comprise the following step of closing socket that illustrates in the data communications method that the embodiment of the invention provides:
Step S501: the value of the CKPT flag bit of the packet of the receiving queue tail end of the socket that inspection will be closed whether be set to this receiving queue content of expression the tested process of making an inventory of be saved in value in the check point file.
If the judged result among the step S501 is yes, then execution in step S502: the buffering area and the structure of cancelling this socket of closing that directly discharge this socket of closing.Thereby skip the step that sends FIN message and directly close this socket.In this case, client does not receive FIN message, also just can not perceive ServerSocket is closed, if be successfully completed the migration of process at the tcp connect timeout in setting time, then can recover to open the state of socket, except time-delay was to a certain degree arranged, client can not perceive network connection and once be interrupted.
If the determination result is NO among the step S501, then according to traditional socket closing flow path socket is closed, be execution in step S503: send FIN message to client, after waiting for the affirmation of client, discharge the buffering area of this socket of closing, and cancel the structure of this socket of closing.Client also will be closed the related port of this socket simultaneously.
The embodiment of the invention is also corresponding to provide a kind of data communication equipment, and as shown in Figure 6, this device comprises:
Packet receiving element 601 is used for receiving the packet that client sends;
Socket is searched unit 602, is used for searching host's socket of the packet that receives;
Packet is searched unit 603, be used for to seek the packet of tail end of the receiving queue of host's socket;
Whether judging unit 604, the checkpoint flag bit that is used for judging the packet of tail end are set to and represent that this receiving queue content is tested and make an inventory of the value that process is saved in check point file;
Discarding unit 605, the judged result that is used for when judging unit 604 is yes, then abandons the packet that receives.
In addition, data communication equipment in the present embodiment can also comprise that packet hangs into unit 606, when the determination result is NO for judging unit 604, the packet that receives is suspended to the tail end of the receiving queue of host's socket, and returns the affirmation information that the expression packet has normally been received to client.
The above only is preferred implementation of the present invention; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.

Claims (7)

1.一种基于套接字的数据通信方法,其特征在于,包括:1. A socket-based data communication method, characterized in that, comprising: 在接收到客户端发送的数据包后,寻找该数据包的宿主套接字;After receiving the data packet sent by the client, look for the host socket of the data packet; 寻找所述宿主套接字的接收队列的尾端的数据包,判断所述尾端的数据包的检查点标志位是否被置为表示该接收队列内容已经被检查点进程保存到检查点文件中的值;Find the data packet at the tail end of the receive queue of the host socket, and determine whether the checkpoint flag bit of the data packet at the tail end is set to a value indicating that the content of the receive queue has been saved in the checkpoint file by the checkpoint process ; 如果所述尾端数据包的检查点标志位被置为表示该接收队列内容已经被检查点进程保存到检查点文件中的值,则直接丢弃接收到的数据包。If the checkpoint flag of the tail data packet is set to a value indicating that the content of the receiving queue has been saved in the checkpoint file by the checkpoint process, the received data packet is directly discarded. 2.根据权利要求1所述的方法,其特征在于,该方法还包括:2. The method according to claim 1, characterized in that the method further comprises: 如果所述最后一个数据包的检查点标志位未被置为表示该接收队列内容已经被检查点进程保存到检查点文件中的值时,则将所述接收到的数据包挂到所述宿主套接字的接收队列的尾端,并向所述客户端反馈表示数据包已经被正常接收的确认信息。If the checkpoint flag bit of the last data packet is not set to a value indicating that the receive queue content has been saved to the checkpoint file by the checkpoint process, then the received data packet is hung to the host The tail end of the receiving queue of the socket, and feeds back the confirmation information indicating that the data packet has been received normally to the client. 3.根据权利要求1或2所述的方法,其特征在于,该方法还包括:3. The method according to claim 1 or 2, characterized in that the method further comprises: 在对套接字进行迁移的过程中,如果所述套接字的接收队列不为空,则检查点进程将所述套接字的接收队列内容保存到检查点文件中,并将所述接收队列尾端的数据包中的检查点标志位置为表示该接收队列内容已经被检查点进程保存到检查点文件中的值。During the process of migrating the socket, if the receiving queue of the socket is not empty, the checkpoint process will save the content of the receiving queue of the socket into the checkpoint file, and save the received The checkpoint mark position in the data packet at the end of the queue is a value indicating that the content of the receiving queue has been saved into the checkpoint file by the checkpoint process. 4.根据权利要求3所述的方法,其特征在于,该方法还包括:4. The method according to claim 3, characterized in that the method further comprises: 在对套接字进行迁移的过程中,如果所述套接字的接收队列为空,则创建一个空数据包,将所述创建的空数据包中的检查点标志位置为表示该接收队列内容已经被检查点进程保存到检查点文件中的值,将置位后的空数据包挂到接收队列中,然后检查点进程将所述套接字的接收队列内容保存到检查点文件中。In the process of migrating the socket, if the receiving queue of the socket is empty, create an empty data packet, and set the checkpoint flag in the created empty data packet to represent the content of the receiving queue The value that has been saved in the checkpoint file by the checkpoint process hangs the empty data packet after setting in the receive queue, and then the checkpoint process saves the content of the receive queue of the socket into the checkpoint file. 5.根据权利要求1或2所述的方法,其特征在于,该方法还包括:5. The method according to claim 1 or 2, characterized in that the method further comprises: 在对套接字进行关闭的过程中,判断所述套接字的接收队列尾端的数据包的检查点标志位是否被置为表示该接收队列内容已经被检查点进程保存到检查点文件中的值;In the process of closing the socket, judge whether the checkpoint flag bit of the data packet at the end of the receiving queue of the socket is set to indicate that the content of the receiving queue has been saved in the checkpoint file by the checkpoint process value; 如果是,则直接释放缓冲区和撤销所述套接字的结构体;If yes, directly release the buffer and revoke the structure of the socket; 如果否,则向客户端发送FIN数据包,待客户端确认后释放缓冲区和撤销所述套接字的结构体。If not, then send a FIN data packet to the client, release the buffer and revoke the structure of the socket after the client confirms. 6.一种数据通信装置,其特征在于,包括:6. A data communication device, characterized in that, comprising: 数据包接收单元,用于接收客户端发送的数据包;A data packet receiving unit, configured to receive a data packet sent by the client; 套接字查找单元,用于寻找所述接收到的数据包的宿主套接字;A socket search unit, configured to find the host socket of the received data packet; 数据包查找单元,用于寻找所述宿主套接字的接收队列的尾端的数据包;A data packet search unit, configured to search for a data packet at the end of the receiving queue of the host socket; 判断单元,用于判断所述尾端的数据包的检查点标志位是否被置为表示该接收队列内容已经被检查点进程保存到检查点文件中的值;A judging unit, configured to judge whether the checkpoint flag bit of the data packet at the tail end is set to a value indicating that the content of the receiving queue has been saved into the checkpoint file by the checkpoint process; 丢弃单元,用于当所述判断单元的判断结果为是,则丢弃接收到的数据包。The discarding unit is configured to discard the received data packet when the judgment result of the judging unit is yes. 7.根据权利要求6所述的装置,其特征在于,该装置还包括:7. The device according to claim 6, further comprising: 数据包挂入单元,用于在所述判断单元的判断结果为否时,将所述接收到的数据包挂到宿主套接字的接收队列的尾端,并向客户端返回表示数据包已经被正常接收的确认信息。The data packet hanging unit is used to hang the received data packet to the end of the receiving queue of the host socket when the judgment result of the judging unit is no, and return to the client to indicate that the data packet has been received. Acknowledgments received normally.
CN201210516615.0A 2012-12-05 2012-12-05 Method and device of data communication Active CN103036957B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210516615.0A CN103036957B (en) 2012-12-05 2012-12-05 Method and device of data communication

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210516615.0A CN103036957B (en) 2012-12-05 2012-12-05 Method and device of data communication

Publications (2)

Publication Number Publication Date
CN103036957A true CN103036957A (en) 2013-04-10
CN103036957B CN103036957B (en) 2015-04-29

Family

ID=48023429

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210516615.0A Active CN103036957B (en) 2012-12-05 2012-12-05 Method and device of data communication

Country Status (1)

Country Link
CN (1) CN103036957B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016106780A1 (en) * 2015-01-04 2016-07-07 华为技术有限公司 User data transmission method and apparatus and terminal
CN113132065A (en) * 2019-12-30 2021-07-16 西安诺瓦星云科技股份有限公司 Data communication method, device and system, storage medium and video processing equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030115357A1 (en) * 2001-12-17 2003-06-19 Chu Hao-Hua Communication socket migration among different devices
CN101369241A (en) * 2007-09-21 2009-02-18 中国科学院计算技术研究所 A cluster fault-tolerant system, device and method
CN101969442A (en) * 2010-10-28 2011-02-09 南京博智软件科技有限公司 Process running environment perception and migration based network analog framework implementation method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030115357A1 (en) * 2001-12-17 2003-06-19 Chu Hao-Hua Communication socket migration among different devices
CN101369241A (en) * 2007-09-21 2009-02-18 中国科学院计算技术研究所 A cluster fault-tolerant system, device and method
CN101969442A (en) * 2010-10-28 2011-02-09 南京博智软件科技有限公司 Process running environment perception and migration based network analog framework implementation method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
CSDN: "TCP状态迁移图浅析", 《HTTP://BLOG.CSDN.NET/WEIWANGCHAO_/ARTICLE/DETAILS/7225652》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016106780A1 (en) * 2015-01-04 2016-07-07 华为技术有限公司 User data transmission method and apparatus and terminal
CN105940658A (en) * 2015-01-04 2016-09-14 华为技术有限公司 A user data transmission method, apparatus and terminal
CN105940658B (en) * 2015-01-04 2019-04-26 华为技术有限公司 A user data transmission method, device and terminal
CN113132065A (en) * 2019-12-30 2021-07-16 西安诺瓦星云科技股份有限公司 Data communication method, device and system, storage medium and video processing equipment

Also Published As

Publication number Publication date
CN103036957B (en) 2015-04-29

Similar Documents

Publication Publication Date Title
US10749993B2 (en) Path selection using TCP handshake in a multipath environment
US8311059B2 (en) Receive coalescing and automatic acknowledge in network interface controller
US8904224B2 (en) Providing replication and fail-over as a network service in data centers
US9813526B2 (en) Reducing transmission pathway lengths within a distributed network
US8107360B2 (en) Dynamic addition of redundant network in distributed system communications
EP3707882A1 (en) Multi-path rdma transmission
CN103795632B (en) Data message transmission method, related equipment and system
CN105376173B (en) A kind of sending window flow control method and terminal
WO2015114473A1 (en) Method and apparatus for locality sensitive hash-based load balancing
CN103918307A (en) Packet sorting based on delivery route changes
CN106576108B (en) Communication method, equipment and system in communication system
US11848989B2 (en) Separate routing of NVMe-over-fabric packets and non-NVMe packets
CN105763440A (en) Message forwarding method and device
EP3585025B1 (en) Data migration method and apparatus
WO2017028399A1 (en) Communication data transmission method and system
TW202512710A (en) Fairness and congestion control convergence
CN103036957A (en) Method and device of data communication
JP4348227B2 (en) Hierarchical packet processing system, relay device, server, method thereof, and program thereof
US7535916B2 (en) Method for sharing a transport connection across a multi-processor platform with limited inter-processor communications
CN110192378A (en) Control the device and method of non-optimal path used
RU2715016C1 (en) Transmitting device, method, program and recording medium
EP3382984A1 (en) Techniques for network multicasting with buffering
CN111200505B (en) Message processing method and device
WO2018133784A1 (en) Packet processing method, device and system
JP4228850B2 (en) Packet relay device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20211224

Address after: 450046 Floor 9, building 1, Zhengshang Boya Plaza, Longzihu wisdom Island, Zhengdong New Area, Zhengzhou City, Henan Province

Patentee after: xFusion Digital Technologies Co., Ltd.

Address before: 518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen

Patentee before: HUAWEI TECHNOLOGIES Co.,Ltd.