disclosure of Invention
In order to solve the technical problems, the invention provides a data sending and receiving method and device, a data transmission method and system, which can ensure the integrity in the data transmission process and realize the load balance of shunting equipment.
the technical scheme provided by the invention is as follows:
The invention discloses a data sending method, which is used for a shunting device to send data to an analysis device through a TCP channel and comprises the following steps: s11: sending the message with the sequence number to an analysis device; s12: monitoring whether a mark serial number fed back by the analysis equipment is received; s13: when the mark serial number fed back by the analysis equipment is received, recording the mark serial number; s14: judging whether the shunting equipment is connected to new analysis equipment again; if yes, executing the next step, otherwise, repeatedly executing the step S11; s15: determining the starting sequence number of the next message to be sent according to the mark sequence number recorded last time; s16: and sending the message to a new analysis device according to the starting sequence number.
Further preferably, the method further comprises the following steps: s10: and according to a preset rule, arranging continuous serial numbers of the messages in the message sequence.
Further preferably, the step S15 "determining the starting sequence number of the next message to be sent according to the tag sequence number recorded last time" specifically includes the steps of: s151: and taking the mark serial number recorded last time as the starting serial number of the next message to be sent according to a preset rule.
Further preferably, after the step S13 "the shunting device records the mark serial number", the method further includes the steps of: s131: and releasing the space corresponding to the message with the sequence number arranged in front of the marked sequence number.
The invention also discloses a data receiving method, which is used for the analysis equipment to receive the data sent by the shunting equipment through the TCP channel and comprises the following steps: s21: receiving a message with a sequence number sent by a shunting device; s22: judging whether the received message forms a complete message sequence or not; if so, executing the next step, otherwise, repeatedly executing the step S21; s23: and when the received message forms a complete message sequence, feeding back a mark serial number to the shunting equipment.
further preferably, the step S23 "feeding back a mark serial number to the shunting device" includes the steps of: s231: and feeding back the next sequence number of the last message in the currently formed complete message sequence to the shunting equipment as the marked sequence number.
the invention also discloses a data transmission method, which is used for transmitting data between the shunting device and the analysis device through the TCP channel and comprises the following steps: s11: the shunting equipment sends the message with the sequence number to the analysis equipment; s12: the shunting equipment monitors whether a mark serial number fed back by the analysis equipment is received; s21: the analysis equipment receives a message with a sequence number sent by the shunting equipment; s22: the analysis equipment judges whether the received message forms a complete message sequence or not; if so, executing the next step, otherwise, repeatedly executing the step S21; s23: when the received message forms a complete message sequence, the analysis equipment feeds back a mark serial number to the shunting equipment; s13: when the shunting equipment receives the marking serial number fed back by the analysis equipment, recording the marking serial number; s14: the shunting device judges whether to be connected to a new analysis device again; if yes, executing the next step, otherwise, repeatedly executing the step S11; s15: the shunting equipment determines the starting sequence number of the next message to be sent according to the mark sequence number recorded last time; s16: and the shunting equipment sends the message to new analysis equipment according to the starting sequence number.
further preferably, the method further comprises the following steps: s10: and according to a preset rule, arranging continuous serial numbers of the messages in the message sequence.
further preferably, the step S23 "feeding back a mark serial number to the shunting device" includes the steps of: s231: and feeding back the next sequence number of the last message in the currently formed complete message sequence to the shunting equipment as the marked sequence number.
Further preferably, the step S15 "determining the starting sequence number of the next message to be sent according to the tag sequence number recorded last time" specifically includes the steps of: s151: and taking the mark serial number recorded last time as the starting serial number of the next message to be sent according to a preset rule.
further preferably, after the step S13 "the shunting device records the mark serial number", the method further includes the steps of: s131: and releasing the space corresponding to the message with the sequence number arranged in front of the marked sequence number.
the invention discloses a data sending device, which is used for sending data to an analysis device through a TCP channel and comprises a shunting device, wherein the shunting device specifically comprises: the sending module is used for sending the message with the sequence number to the analysis equipment; the monitoring module is used for monitoring whether the mark serial number fed back by the analysis equipment is received; the recording module is used for recording the mark serial number fed back by the analysis equipment when receiving the mark serial number fed back by the analysis equipment; the connection judging module is used for judging whether the shunting equipment is connected to new analysis equipment again; the determining module is used for determining the starting sequence number of the next message to be sent according to the mark sequence number recorded last time when the shunting device is reconnected to the new analysis device; and the sending module is also used for sending the message to new analysis equipment according to the starting sequence number.
further preferably, the method further comprises the following steps: and the numbering module is used for numbering continuous serial numbers of the messages in the message sequence according to a preset rule.
Further preferably, the determining module is specifically configured to use the tag sequence number recorded last time as a starting sequence number of a next message to be sent according to a preset rule.
Further preferably, the method further comprises the following steps: and the releasing module is used for releasing the space corresponding to the message with the serial number arranged in front of the marked serial number.
The invention also discloses a data receiving device, which is used for receiving the data sent by the shunting equipment through the TCP channel and comprises analysis equipment, wherein the analysis equipment specifically comprises: the receiving module is used for receiving the message with the sequence number sent by the shunting equipment; the message sequence judging module is used for judging whether the received messages form a complete message sequence or not; and the feedback module is used for feeding back a marking serial number to the shunting equipment when the received message forms a complete message sequence.
preferably, the feedback module is specifically configured to feed back a next sequence number of a last packet in a currently formed complete packet sequence to the shunting device as the tag sequence number.
the invention also discloses a data transmission system, which is used for transmitting data through the TCP channel and comprises a data transmitting device and a data receiving device, wherein the data transmitting device comprises a shunting device; the shunting device specifically comprises: the sending module is used for sending the message with the sequence number to the analysis equipment; the monitoring module is used for monitoring whether the mark serial number fed back by the analysis equipment is received; the recording module is used for recording the mark serial number fed back by the analysis equipment when receiving the mark serial number fed back by the analysis equipment; the connection judging module is used for judging whether the shunting equipment is connected to new analysis equipment again; the determining module is used for determining the starting sequence number of the next message to be sent according to the mark sequence number recorded last time when the shunting device is reconnected to the new analysis device; the sending module is further configured to send the message to a new analysis device according to the start sequence number; the data receiving device comprises an analysis device, and the analysis device specifically comprises: the receiving module is used for receiving the message with the sequence number sent by the shunting equipment; the message sequence judging module is used for judging whether the received messages form a complete message sequence or not; and the feedback module is used for feeding back a marking serial number to the shunting equipment when the received message forms a complete message sequence.
Further preferably, the flow dividing apparatus further includes: and the numbering module is used for numbering continuous serial numbers of the messages in the message sequence according to a preset rule.
further preferably, the determining module is specifically configured to use the tag sequence number recorded last time as a starting sequence number of a next message to be sent according to a preset rule.
preferably, the feedback module is specifically configured to feed back a next sequence number of a last packet in a currently formed complete packet sequence to the shunting device as the tag sequence number.
further preferably, the flow dividing apparatus further includes: and the releasing module is used for releasing the space corresponding to the message sequence of the message with the sequence number arranged before the marked sequence number.
Compared with the prior art, the invention ensures the integrity of the message sending sequence between the shunting device and the analysis device by arranging the continuous serial numbers of the messages. If the device is disconnected or the software crashes, the shunt device is connected with new analysis equipment, or the analysis equipment is slow, so that more and more messages are accumulated by the shunt device, the shunt device is actively disconnected, the shunt device is connected with the new analysis equipment, and the messages can be retransmitted from the mark serial number fed back by the analysis equipment last time, so that the integrity of the message sequence for analysis is ensured.
Detailed Description
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following description will be made with reference to the accompanying drawings. It is obvious that the drawings in the following description are only some examples of the invention, and that for a person skilled in the art, other drawings and embodiments can be derived from them without inventive effort.
for the sake of simplicity, the drawings only schematically show the parts relevant to the present invention, and they do not represent the actual structure as a product. In addition, in order to make the drawings concise and understandable, components having the same structure or function in some of the drawings are only schematically illustrated or only labeled. In this document, "one" means not only "only one" but also a case of "more than one".
Fig. 1 is a schematic diagram of main steps of a data sending method according to the present invention, and as a specific embodiment of the present invention, as shown in fig. 1, a data sending method is used for a offloading device 110 to send data to an analysis device 220 through a TCP channel, and includes the steps of: s11: sending the message with the sequence number to the analysis device 220; s12: monitoring whether the mark serial number fed back by the analysis equipment 220 is received; s13: when the mark serial number fed back by the analysis equipment 220 is received, recording the mark serial number; s14: determining whether the shunting device 110 is reconnected to a new analysis device 220; if yes, executing the next step, otherwise, repeatedly executing the step S11; s15: determining the starting sequence number of the next message to be sent according to the mark sequence number recorded last time; s16: and sending the message to the new analysis device 220 according to the starting sequence number.
Specifically, the data transmission method of the present invention is established between the offloading device 110 and the analysis device 220, where the offloading device 110 and the analysis device 220 establish a TCP channel and transmit a TCP packet sequence. By sequencing a plurality of messages in a complete message sequence and then analyzing the tag sequence number fed back by the analyzing device 220, the TCP client of the offloading device 110 can determine the sequence number of the message in the message sequence that needs to be sent when reconnecting. The message is sent by the marked serial number, so that the integrity of message sequence sending is ensured, data loss is prevented, and the working efficiency of the analysis equipment 220 is improved.
preferably, the method further comprises the steps of: s10: and according to a preset rule, arranging continuous serial numbers of the messages in the message sequence. Specifically, fig. 2 is a schematic diagram of sequence number arrangement of messages in a data transmission method according to the present invention, as shown in fig. 2, the messages have different lengths, each message has a number, and the messages can be rolled back by arranging the sequence numbers of the messages from message 1. The message sequence numbers are consecutive, as shown, from sequence number 3 to sequence number 12. If the message is 16 bits, the next message sequence number is 0 after 0 xffff.
The above embodiments are modified to provide preferred embodiments. Fig. 3 is a diagram illustrating the steps of a data transmission method according to the present invention. As a specific embodiment of the present invention, as shown in fig. 3, a data transmission method includes the steps of: s10: according to a preset rule, serial numbers of messages in a message sequence are numbered continuously; s11: sending the message with the sequence number to the analysis device 220; s12: monitoring whether the mark serial number fed back by the analysis equipment 220 is received; s13: when the mark serial number fed back by the analysis equipment 220 is received, recording the mark serial number; s14: determining whether the shunting device 110 is reconnected to a new analysis device 220; if yes, executing the next step, otherwise, repeatedly executing the step S11; s151: taking the mark serial number recorded last time as the starting serial number of the next message to be sent according to a preset rule; s16: and sending the message to the new analysis device 220 according to the starting sequence number.
specifically, the present invention can determine whether a complete message sequence is completely sent or not by analyzing the tag sequence number fed back by the device 220, and can determine the message sequence number to be sent next when the distribution device 110 is reconnected to a new analyzing device 220, thereby avoiding that a message in a message sequence is sent to a different analyzing device 220, which causes incomplete message and fails to analyze the message sequence.
preferably, after the step S13 "the shunting device 110 records the mark serial number", the method further includes the steps of: s131: and releasing the space corresponding to the message with the sequence number arranged in front of the marked sequence number. Specifically, the present invention obtains the complete message sequence by marking the serial number, and timely clears the space corresponding to the complete message sequence that has been sent and received, so as to reduce the storage space occupied by the cached data and improve the processing speed of the shunting device 110.
Fig. 4 is a schematic step diagram of a data receiving method according to another embodiment of the present invention, and as shown in fig. 4, a data receiving method is used for an analysis device 220 to receive data sent by a offload device 110 through a TCP channel, and includes the steps of: s21: receiving a message with a sequence number sent by the shunting device 110; s22: judging whether the received message forms a complete message sequence or not; if so, executing the next step, otherwise, repeatedly executing the step S21; s23: when the received message forms a complete message sequence, a tag serial number is fed back to the shunting device 110.
Specifically, the data receiving method of the present invention is established between the distribution device 110 and the analysis device 220, where the distribution device 110 and the analysis device 220 establish a TCP channel to receive a TCP packet sequence. The analyzing device 220 of the present invention feeds back a tag serial number to the shunting device 110 when the received messages with sequence numbers form a complete message sequence. Because the TCP client of the shunting device 110 only has the capability of sending data, cannot process the response information of the complex analysis device 220, and cannot understand which messages can form a complete analysis sequence by itself, the data receiving method of the present invention can inform, by feeding back a tag sequence number, whether the message sequence sent by the shunting device 110 is complete and which message sequence is sent in detail.
Preferably, the step S23 "feeding back a mark serial number to the shunting device 110" specifically includes the step S231: the next sequence number of the last message in the currently formed complete message sequence is fed back to the shunting device 110 as the marked sequence number. Specifically, the marked sequence number in the present invention may represent a complete message sequence, and the sequence number of the last message in the received complete message sequence may be used as the marked sequence number, or the next sequence number of the last message in the complete message sequence may be used as the marked sequence number and fed back to the shunting device 110. The mark number is not particularly limited and may be set by itself.
Fig. 5 is a schematic diagram of main steps of a data transmission method of the present invention, and as a specific embodiment of the present invention, as shown in fig. 5, a data transmission method is used for transmitting data between a offloading device 110 and an analysis device 220 through a TCP channel, and includes the steps of: s11: the shunting device 110 sends a message with the sequence number to the analysis device 220; s12: the shunting device 110 monitors whether the mark serial number fed back by the analysis device 220 is received; s21: the analysis device 220 receives the message with the sequence number sent by the shunting device 110; s22: the analysis device 220 determines whether the received message forms a complete message sequence; if so, executing the next step, otherwise, repeatedly executing the step S21; s23: when the received message forms a complete message sequence, the analysis device 220 feeds back a tag serial number to the distribution device 110; s13: when the shunting device 110 receives the marking serial number fed back by the analysis device 220, recording the marking serial number; s14: the shunting device 110 determines whether to reconnect to a new analysis device 220; if yes, executing the next step, otherwise, repeatedly executing the step S11; s15: the shunting device 110 determines a starting sequence number of a next message to be sent according to the mark sequence number recorded last time; s16: the shunting device 110 sends the packet to the new analysis device 220 according to the start sequence number.
specifically, the data transmission method of the present invention is established between the shunting device 110 and the analysis device 220, and includes the data transmission method and the data reception method described above. The shunting device 110 and the analyzing device 220 establish a TCP channel to transmit a TCP packet sequence. The shunting device 110 performs the sequence numbering on a plurality of messages in a complete message sequence and sends the messages to the analysis device 220, and the analysis device 220 feeds back a tag sequence number to the shunting device 110 when the messages form a complete message sequence. When the distribution device 110 reconnects to the new analysis device 220, the sequence number of the message sequence that needs to be sent can be determined according to the marked sequence number. The sequence number of the mark ensures the integrity of message sequence transmission, prevents data loss, and improves the working efficiency of the analysis device 220.
Preferably, the method further comprises the following steps: s10: and according to a preset rule, arranging continuous serial numbers of the messages in the message sequence.
preferably, the step S23 "feeding back a mark serial number to the shunting device 110" specifically includes the steps of: s231: the next sequence number of the last message in the currently formed complete message sequence is fed back to the shunting device 110 as the marked sequence number.
Preferably, the step S15 "determining the starting sequence number of the next message to be sent according to the tag sequence number recorded last time" specifically includes the steps of: s151: and taking the mark serial number recorded last time as the starting serial number of the next message to be sent according to a preset rule.
preferably, after the step S13 "the shunting device 110 records the mark serial number", the method further includes the steps of: s131: and releasing the space corresponding to the message with the sequence number arranged in front of the marked sequence number.
The following describes in detail a transmission flow of a data transmission method according to the present invention with reference to fig. 2.
As shown in fig. 2, the distribution device 110 transmits the messages 3, 4, 5, 6, and 7 to the analysis device 220, and the analysis device 220 receives the messages successfully.
The analyzing device 220 feeds back the serial number of the tag to be 6 to the shunting device 110, which indicates that the message before the serial number 6 has become a complete sequence and the analysis is completed. The shunting device 110 may release the space corresponding to the message before the sequence number 6, and the next analyzed message sequence will start with the message with the sequence number 6.
the shunting device 110 continues to transmit the messages 8 and 9 to the analysis device 220, and the analysis device 220 receives the messages successfully.
the analyzing device 220 feeds back the marked serial number 10 to the shunting device 110, which indicates that the message before the serial number 10 has become a complete sequence, and after the analysis is completed, the shunting device 110 may release the space corresponding to the message before 10, and the next analyzed message sequence will start from 10.
The shunting device 110 continues to transmit the messages 10 and 11 to the analysis device 220, and the analysis device 220 receives the messages successfully.
The analysis device 220 has a problem (device dropped or software crashes).
The shunting device 110 reconnects to the new analyzing device 220, and starts to continue to transmit the messages 10, 11, and 12 from the last time the analyzing device 220 feedbacks the marked serial number, i.e. 10, and the analyzing device 220 succeeds in receiving.
The analysis device 220 feeds back the tag serial number 12 to the distribution device 110, which indicates that the message before the serial number 12 has become a complete sequence, and after the analysis is completed, the distribution device 110 may release the space corresponding to the message before the serial number 12, and the next analysis sequence will start from the serial number 12.
Fig. 6 is a schematic diagram of the main components of a data transmission apparatus according to the present invention. As a specific embodiment of the present invention, as shown in fig. 6, a data sending apparatus is used for sending data to an analysis device 220 through a TCP channel, and includes a offloading device 110, where the offloading device 110 specifically includes: the sending module 111 is configured to send a message with a sequence number to the analysis device 220; a monitoring module 112, configured to monitor whether the tag serial number fed back by the analysis device 220 is received; the recording module 113 is configured to record the tag serial number fed back by the analysis device 220 when receiving the tag serial number fed back by the analysis device 220; a connection judging module 114, configured to judge whether the shunting device 110 is reconnected to a new analysis device 220; a determining module 115, configured to determine a starting sequence number of a next message to be sent according to the tag sequence number recorded last time when the shunting device 110 is reconnected to a new analysis device 220; the sending module 111 is further configured to send the message to a new analysis device 220 according to the start sequence number.
Preferably, the device further includes a numbering module 116, configured to list consecutive sequence numbers for the messages in the message sequence according to a preset rule.
Preferably, the determining module 115 is specifically configured to use the mark sequence number recorded last time as a starting sequence number of a next message to be sent according to a preset rule.
preferably, the method further comprises the following steps: and the releasing module 117 is configured to release a space corresponding to the packet with the sequence number arranged before the marked sequence number.
it should be noted that the information interaction, execution process, and other contents between the modules in the apparatus are based on the same concept as the data transmission method embodiment, and specific contents may refer to the description in the data transmission method embodiment of the present invention, and are not described herein again.
Fig. 7 is a schematic diagram of the main components of a data receiving device according to the present invention. As a specific embodiment of the present invention, as shown in fig. 7, a data receiving apparatus is configured to receive data sent by a offloading device 110 through a TCP channel, and includes an analysis device 220, where the analysis device 220 specifically includes: a receiving module 221, configured to receive a message with a sequence number sent by the offloading device 110; a message sequence determining module 222, configured to determine whether the received message forms a complete message sequence; the feedback module 233 is configured to feed back a tag serial number to the offloading device 110 when the received message forms a complete message sequence.
Preferably, the feedback module 233 is specifically configured to feedback the next sequence number of the last message in the currently formed complete message sequence to the shunting device 110 as the marked sequence number.
It should be noted that the information interaction, execution process, and other contents between the modules in the apparatus are based on the same concept as the data receiving method embodiment, and specific contents may refer to the description in the data receiving method embodiment of the present invention, and are not described herein again.
Fig. 8 is a schematic diagram of the main components of a data transmission system according to the present invention, and as an embodiment of the present invention, as shown in fig. 8, the data transmission system is used for transmitting data through a TCP channel, and includes a data transmitting apparatus and a data receiving apparatus, where the data transmitting apparatus includes a shunting device 110; the shunting device 110 specifically includes: the sending module 111 is configured to send a message with a sequence number to the analysis device 220; a monitoring module 112, configured to monitor whether the tag serial number fed back by the analysis device 220 is received; the recording module 113 is configured to record the tag serial number fed back by the analysis device 220 when receiving the tag serial number fed back by the analysis device 220; a connection judging module 114, configured to judge whether the shunting device 110 is reconnected to a new analysis device 220; a determining module 115, configured to determine a starting sequence number of a next message to be sent according to the tag sequence number recorded last time when the shunting device 110 is reconnected to a new analysis device 220; the sending module 111 is further configured to send the message to a new analysis device 220 according to the start sequence number; the data receiving apparatus includes an analyzing device 220, and the analyzing device 220 specifically includes: a receiving module 221, configured to receive a message with a sequence number sent by the offloading device 110; a message sequence determining module 222, configured to determine whether the received message forms a complete message sequence; the feedback module 233 is configured to feed back a tag serial number to the offloading device 110 when the received message forms a complete message sequence.
Fig. 9 is a diagram illustrating the complete components of a data transmission system according to the present invention. As a specific embodiment of the present invention, as shown in fig. 9, the shunting device 110 further includes: and the numbering module 116 is configured to list consecutive sequence numbers of the messages in the message sequence according to a preset rule.
Preferably, the determining module 115 is specifically configured to use the mark sequence number recorded last time as a starting sequence number of a next message to be sent according to a preset rule.
preferably, the feedback module 233 is specifically configured to feedback the next sequence number of the last message in the currently formed complete message sequence to the shunting device 110 as the marked sequence number.
preferably, as shown in fig. 9, the shunt device 110 further includes: and the releasing module 117 is configured to release a space corresponding to a packet sequence in which the packet with the sequence number before the marked sequence number is located.
The data transmission system of the present invention is established between the shunting device 110 and the analyzing device 220, and includes the data transmitting apparatus and the data receiving apparatus described above. The shunting device 110 and the analyzing device 220 establish a TCP channel to transmit a TCP packet sequence. The shunting device 110 performs the sequence numbering on a plurality of messages in a complete message sequence and sends the messages to the analysis device 220, and the analysis device 220 feeds back a tag sequence number to the shunting device 110 when the messages form a complete message sequence. When the distribution device 110 reconnects to the new analysis device 220, the sequence number of the message sequence that needs to be sent can be determined according to the marked sequence number. The sequence number of the mark ensures the integrity of message sequence transmission, prevents data loss, and improves the working efficiency of the analysis device 220.
It should be noted that, the information interaction, execution process, and other contents between the modules in the system are based on the same concept as the method embodiment, and specific contents may refer to the description in the method embodiment of the present invention, and are not described herein again.
It should be noted that the above embodiments can be freely combined as necessary. The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.