Data transmission method, apparatus, and system
A data transmission method, implemented by a network device, includes sending a probe packet to a log server, determining whether the log server can receive a packet responsive to whether the network device receives a probe response packet from the log server, and sending a log packet to the log server when the log server can receive a packet. The log packet includes a correspondence between a public Internet Protocol (IP) address and a private IP address.
1. A data transmission method implemented by a network device and comprising:
sending a probe packet to a log server, wherein the probe packet is a heartbeat probe packet and is based on Internet Control Message Protocol (ICMP) and User Datagram Protocol (UDP);
determining whether a probe response packet is received from the log server, wherein the probe response packet is a heartbeat probe response packet communicated in response to the probe packet, and wherein the probe response packet is based on the ICMP and the UDP;
determining, based on whether the probe response packet is received from the log server, whether the log server is capable of receiving a packet; and
sending a log packet to the log server when the log server is capable of receiving the packet,
wherein the log packet comprises a correspondence between a public Internet Protocol (IP) address and a private IP address.
2. The data transmission method of claim 1 , wherein the data transmission method further comprises:
detecting whether the heartbeat probe response packet is received within a first specified period;
determining that the log server is capable of receiving the packet when the heartbeat probe response packet is received within the first specified period; and
determining that the log server is not capable of receiving the packet when the heartbeat probe response packet is not received within the first specified period.
3. The data transmission method of claim 1 , wherein the probe packet comprises an ICMP probe packet and a UDP probe packet, wherein the probe response packet comprises an ICMP probe response packet and a UDP port unreachable packet, and wherein the data transmission method further comprises:
detecting whether the ICMP probe response packet is received within a second specified period;
sending the UDP probe packet to the log server when the ICMP probe response packet is received within the second specified period;
determining that the log server is not capable of receiving the packet when the UDP port unreachable packet is received within a third specified period; and
determining that the log server is capable of receiving the packet when the UDP port unreachable packet is not received within the third specified period.
4. The data transmission method of claim 3 , wherein after detecting whether the ICMP probe response packet is received within the second specified period, the data transmission method further comprises:
updating an accumulated quantity of times when the ICMP probe response packet is not received within the second specified period, wherein an updated accumulated quantity of times is a quantity of times for which the network device sends the ICMP probe packet to the log server from a moment after a latest ICMP probe response packet is received to a current moment; and
determining that the log server is not capable of receiving the packet when the updated accumulated quantity of times reaches a specified times threshold.
5. The data transmission method of claim 3 , wherein after determining that the log server is not capable of receiving the packet, the data transmission method further comprises:
periodically sending the UDP probe packet to the log server; and
determining that the log server is capable of receiving the packet when the UDP port unreachable packet is not received in a plurality of consecutive time periods.
6. The data transmission method of claim 1 , further comprising generating a quantity of log packets during a running process.
7. The data transmission method of claim 6 , further comprising deploying a plurality of log servers to receive the log packets in response to generating the quantity of log packets.
8. The data transmission method of claim 1 , wherein the probe packet and the probe response packet have a same data frame structure, but are of a different packet type.
9. A data transmission apparatus comprising:
a memory configured to store instructions; and
a processor coupled to the memory and configured to execute the instructions to cause the data transmission apparatus to:
send a probe packet to a log server, wherein the probe packet is a heartbeat probe packet and is based on Internet Control Message Protocol (ICMP) and User Datagram Protocol (UDP);
determine whether a probe response packet is received from the log server, wherein the probe response packet is a heartbeat probe response packet communicated non-regularly and in response to the probe packet, and wherein the probe response packet is based on the ICMP and the UDP;
determine, based on whether the probe response packet is received from the log server, whether the log server is capable of receiving a packet; and
send a log packet to the log server when the log server is capable of receiving the packet,
wherein the log packet comprises a correspondence between a public Internet Protocol (IP) address and a private IP address.
10. The data transmission apparatus of claim 9 , wherein the processor is further configured to execute the instructions to cause the data transmission apparatus to:
detect whether the heartbeat probe response packet is received within a first specified period;
determine that the log server is capable of receiving the packet when the heartbeat probe response packet is received within the first specified period; and
determine that the log server is not capable of receiving the packet when the heartbeat probe response packet is not received within the first specified period.
11. The data transmission apparatus of claim 9 , wherein the probe packet comprises an ICMP probe packet and a UDP probe packet, wherein the probe response packet comprises an ICMP probe response packet and a UDP port unreachable packet, and wherein the processor is further configured to execute the instructions to cause the data transmission apparatus to:
detect whether the ICMP probe response packet is received within a second specified period;
send the UDP probe packet to the log server when the ICMP probe response packet is received within the second specified period;
determine that the log server is not capable of receiving the packet when the UDP port unreachable packet is received within a third specified period; and
determine that the log server is capable of receiving the packet when the UDP port unreachable packet is not received within the third specified period.
12. The data transmission apparatus of claim 11 , wherein the processor is further configured to execute the instructions to cause the data transmission apparatus to:
update an accumulated quantity of times when the ICMP probe response packet is not received within the second specified period, wherein an updated accumulated quantity of times is a quantity of times for which the data transmission apparatus sends the ICMP probe packet to the log server from a moment after a latest ICMP probe response packet is received to a current moment; and
determine that the log server is not capable of receiving the packet when the updated accumulated quantity of times reaches a specified times threshold.
13. The data transmission apparatus of claim 11 , wherein the processor is further configured to execute the instructions to cause the data transmission apparatus to:
periodically send the UDP probe packet to the log server after the log server is not capable of receiving the packet; and
determine that the log server is capable of receiving the packet when the UDP port unreachable packet is not received in a plurality of consecutive time periods.
14. The data transmission apparatus of claim 9 , wherein the processor is further configured to execute the instructions to cause the data transmission apparatus to generate a quantity of log packets during a running process.
15. The data transmission apparatus of claim 14 , wherein the processor is further configured to execute the instructions to cause the data transmission apparatus to be configured to deploy a plurality of log servers to receive the log packets in response to generating the quantity of log packets.
16. The data transmission apparatus of claim 9 , wherein the probe packet and the probe response packet have a same data frame structure, but are of a different packet type.
17. A data transmission system comprising:
a log server; and
a network device comprising a data transmission apparatus configured to:
send a probe packet to the log server, wherein the probe packet is a heartbeat probe packet and is based on Internet Control Message Protocol (ICMP) and User Datagram Protocol (UDP);
determine whether a probe response packet is received from the log server, wherein the probe response packet is a heartbeat probe response packet communicated non-regularly and in response to the probe packet, and wherein the probe response packet is based on the ISMP and the UDP:
determine, based on whether the probe response packet is received from the log server, whether the log server is capable of receiving a packet; and
send a log packet to the log server when the log server is capable of receiving the packet,
wherein the log packet comprises a correspondence between a public Internet Protocol (IP) address and a private IP address.
18. The data transmission system of claim 17 , wherein the data transmission apparatus is further configured to:
detect whether the heartbeat probe response packet is received within a first specified period;
determine that the log server is capable of receiving the packet when the heartbeat probe response packet is received within the first specified period; and
determine that the log server is not capable of receiving the packet when the heartbeat probe response packet is not received within the first specified period.
19. The data transmission system of claim 17 , wherein the probe packet comprises an ICMP probe packet and a UDP probe packet, wherein the probe response packet comprises an ICMP probe response packet and a UDP port unreachable packet, and wherein the data transmission apparatus is further configured to:
detect whether the ICMP probe response packet is received within a second specified period;
send the UDP probe packet to the log server when the ICMP probe response packet is received within the second specified period;
determine that the log server is not capable of receiving the packet when the UDP port unreachable packet is received within a third specified period; and
determine that the log server is capable of receiving the packet when the UDP port unreachable packet is not received within the third specified period.
20. The data transmission system of claim 19 , wherein the data transmission apparatus is further configured to:
update an accumulated quantity of times when the ICMP probe response packet is not received within the second specified period, wherein an updated accumulated quantity of times is a quantity of times for which the network device sends the ICMP probe packet to the log server from a moment after a latest ICMP probe response packet is received to a current moment; and
determine that the log server is not capable of receiving the packet when the updated accumulated quantity of times reaches a specified times threshold.
21. The data transmission system of claim 19 , wherein the data transmission apparatus is further configured to:
periodically send the UDP probe packet to the log server after the log server is not capable of receiving the packet; and
determine that the log server is capable of receiving the packet when the UDP port unreachable packet is not received in a plurality of consecutive time periods.
22. The data transmission system of claim 17 , wherein the data transmission apparatus is further configured to:
generate a quantity of log packets during a running process; and
deploy a plurality of log servers to receive the log packets in response to the data transmission apparatus generating the quantity of log packets.
23. The data transmission system of claim 17 , wherein the probe packet and the probe response packet have a same data frame structure, but are of a different packet type.