Network detection method and related device

文档序号:667159 发布日期:2021-04-30 浏览:22次 中文

阅读说明:本技术 网络检测方法及相关装置 (Network detection method and related device ) 是由 黄园 于 2019-03-19 设计创作,主要内容包括:本申请公开了一种网络检测方法及相关装置,应用于电子设备,所述方法包括:在检测到目标游戏应用向服务器发送第一游戏数据包时,确定所述第一游戏数据包是否为第一目标数据包;在确定所述第一游戏数据包为所述第一目标数据包时,记录发送所述第一游戏数据包的第一时间值;在检测到所述目标游戏应用接收来自所述服务器发送的第二游戏数据包时,确定所述第二游戏数据包是否为第二目标数据包;在确定所述第二游戏数据包为所述第二目标数据包时,记录接收到所述第二游戏数据包的第二时间值;根据所述第一时间值和所述第二时间值计算所述目标游戏应用的网络延迟。本申请有利于在目标游戏应用运行过程中准确计算出当前的网络延迟。(The application discloses a network detection method and a related device, which are applied to electronic equipment, wherein the method comprises the following steps: when detecting that a target game application sends a first game data packet to a server, determining whether the first game data packet is a first target data packet; when the first game data packet is determined to be the first target data packet, recording a first time value for sending the first game data packet; when the target game application is detected to receive a second game data packet sent by the server, determining whether the second game data packet is a second target data packet; when the second game data packet is determined to be the second target data packet, recording a second time value of receiving the second game data packet; calculating a network delay of the target game application according to the first time value and the second time value. The method and the device are beneficial to accurately calculating the current network delay in the running process of the target game application.)

1. A network detection method is applied to an electronic device, and the method comprises the following steps:

when detecting that a target game application sends a first game data packet to a server, determining whether the first game data packet is a first target data packet;

when the first game data packet is determined to be the first target data packet, recording a first time value for sending the first game data packet;

when the target game application is detected to receive a second game data packet sent by the server, determining whether the second game data packet is a second target data packet, wherein the second target data packet is a data packet sent to the target game application by the server after receiving the first target data packet;

when the second game data packet is determined to be the second target data packet, recording a second time value of receiving the second game data packet;

and calculating the network delay of the target game application according to the first time value and the second time value, and storing the calculation result of the network delay.

2. The method of claim 1, wherein the first target packet and the second target packet are User Datagram Protocol (UDP) packets for detecting the target game application network delay; the method further comprises the following steps:

capturing a plurality of UDP data packets for detecting the target game application network delay, wherein the UDP data packets comprise a first target data packet and a second target data packet;

obtaining effective data of the plurality of UDP data packets, wherein the effective data is data of the UDP data packets except the UDP message header;

determining first fixed data and second fixed data which have the same byte length and the same position and are contained in a plurality of effective data of the plurality of UDP data packets, wherein the first fixed data is associated with a first target data packet, and the second fixed data is associated with a second target data packet; the byte length of the first fixed data and the second fixed data is a specified byte length associated with the target game application, and the offset of the first byte data in the first fixed data and the second fixed data relative to the first byte data in the valid data is a specified offset.

3. The method of claim 1 or 2, wherein said determining whether the first game data packet is a first target data packet comprises:

acquiring first valid data in the first game data packet;

acquiring first data with the byte length being the specified byte length from the specified offset position in the first effective data; when the first data is detected to be matched with the first fixed data, the first game data packet is represented as the first target data packet.

4. The method of claim 1 or 2, wherein said determining whether the second game data packet is a second destination data packet comprises:

acquiring second effective data in the second game data packet;

acquiring second data with the byte length being the specified byte length from the specified offset position in the second effective data; when the second data is detected to be matched with the second fixed data, the second game data packet is represented as the second target data packet.

5. The method of any of claims 1-4, wherein after calculating the network delay of the target gaming application based on the first time value and the second time value, the method further comprises:

setting the first time value to zero.

6. The method of claim 5, wherein after zeroing the first time value, the method further comprises:

upon detecting that the target gaming application sends a third game data packet to the server, the third game data packet being a UDP data packet used to detect network latency of the target gaming application, determining whether the first time value is zero;

and when the first time value is not zero, determining that a data packet loss occurs, wherein the data packet loss is used for indicating that the target game application does not receive a second game data packet sent by the server.

7. The method of any of claims 1-6, wherein after calculating the network delay of the target gaming application based on the first time value and the second time value, the method further comprises:

calculating the network delay of the target game application for multiple times, and acquiring calculation results of the multiple network delays;

determining a network quality of the target game application according to the plurality of calculation results; and outputting a prompt message when the network quality of the target game application is detected not to meet the preset condition.

8. A network detection device, applied to an electronic device, comprises a processing unit and a communication unit, wherein,

the processing unit is used for determining whether a first game data packet is a first target data packet or not when detecting that a target game application sends the first game data packet to a server through the communication unit; and the first time value for sending the first game data packet is recorded when the first game data packet is determined to be the first target data packet; and the communication unit is used for determining whether a second game data packet sent by the server through the communication unit is a second target data packet when the target game application is detected to receive the second game data packet, wherein the second target data packet is a data packet sent by the server to the target game application after receiving the first target data packet; and recording a second time value of receiving the second game data packet when the second game data packet is determined to be the second target data packet; and the network delay is used for calculating the network delay of the target game application according to the first time value and the second time value, and the calculation result of the network delay is stored.

9. An electronic device comprising a processor, a memory, and a communication interface, one or more programs stored in the memory and configured to be executed by the processor, the programs comprising instructions for performing the steps in the method of any of claims 1-7.

10. A computer-readable storage medium, characterized in that a computer program for electronic data exchange is stored, wherein the computer program causes a computer to perform the method according to any one of claims 1-7.

Technical Field

The present application relates to the field of electronic technologies, and in particular, to a network detection method and a related device.

Background

When a user uses an electronic device to play a network game, if the network state is unstable, and data packet loss or delay fluctuation occurs, the game operation is jammed, and the game experience of the user is seriously affected. When a manufacturer performs network optimization on a game application, the manufacturer can take further network optimization measures only by identifying the current network state, so that the network delay of the game application is accurately detected and the current network state is identified, which is very important in the process of performing network optimization on the game.

Disclosure of Invention

The embodiment of the application provides a network detection method and a related device, so that the current network delay can be accurately calculated in the running process of a target game application.

In a first aspect, an embodiment of the present application provides a network detection method, which is applied to an electronic device, and the method includes:

when detecting that a target game application sends a first game data packet to a server, determining whether the first game data packet is a first target data packet;

when the first game data packet is determined to be the first target data packet, recording a first time value for sending the first game data packet;

when the target game application is detected to receive a second game data packet sent by the server, determining whether the second game data packet is a second target data packet, wherein the second target data packet is a data packet sent to the target game application by the server after receiving the first target data packet;

when the second game data packet is determined to be the second target data packet, recording a second time value of receiving the second game data packet;

and calculating the network delay of the target game application according to the first time value and the second time value, and storing the calculation result of the network delay.

In a second aspect, an embodiment of the present application provides a network detection apparatus applied to an electronic device, where the network detection apparatus includes a processing unit and a communication unit,

the processing unit is used for determining whether a first game data packet is a first target data packet or not when detecting that a target game application sends the first game data packet to a server through the communication unit; and the first time value for sending the first game data packet is recorded when the first game data packet is determined to be the first target data packet; and the communication unit is used for determining whether a second game data packet sent by the server through the communication unit is a second target data packet when the target game application is detected to receive the second game data packet, wherein the second target data packet is a data packet sent by the server to the target game application after receiving the first target data packet; and recording a second time value of receiving the second game data packet when the second game data packet is determined to be the second target data packet; and the network delay is used for calculating the network delay of the target game application according to the first time value and the second time value, and the calculation result of the network delay is stored.

In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a memory, a communication interface, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing steps in any method of the first aspect of the embodiment of the present application.

In a fourth aspect, the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program for electronic data exchange, where the computer program makes a computer perform part or all of the steps described in any one of the methods of the first aspect of the present application.

In a fifth aspect, the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to perform some or all of the steps as described in any one of the methods of the first aspect of the embodiments of the present application. The computer program product may be a software installation package.

It can be seen that, in the embodiment of the present application, an electronic device first determines whether a first game data packet is a first target data packet when it is detected that a target game application sends the first game data packet to a server, then records a first time value for sending the first game data packet when it is determined that the first game data packet is the first target data packet, then determines whether a second game data packet is a second target data packet when it is detected that the target game application receives a second game data packet sent from the server, where the second target data packet is a data packet sent by the server to the target game application after receiving the first target data packet, then records a second time value for receiving the second game data packet when it is determined that the second game data packet is the second target data packet, and finally, calculating the network delay of the target game application according to the first time value and the second time value, and storing the calculation result of the network delay. The electronic equipment can record a first time value when the target game application sends the first target data packet and a second time value when the target game application receives the second target data packet, and the first target data packet and the second target data packet are both used for detecting the network delay of the target game application, so that the network delay of the target game application can be calculated by calculating the first time value and the second time value, and the network optimization of the target game application is facilitated.

Drawings

In order to more clearly illustrate the technical solutions in the embodiments or the background art of the present application, the drawings required to be used in the embodiments or the background art of the present application will be described below.

Fig. 1A is a schematic flowchart of a network detection method according to an embodiment of the present application;

fig. 1B is a diagram illustrating an example analysis of a UDP packet according to an embodiment of the present application;

fig. 1C is a diagram illustrating another example of UDP packets provided in the embodiments of the present application;

fig. 2 is a schematic flowchart of another network detection method provided in an embodiment of the present application;

fig. 3 is a schematic flowchart of another network detection method provided in an embodiment of the present application;

fig. 4 is a schematic structural diagram of an electronic device provided in an embodiment of the present application;

fig. 5 is a block diagram illustrating functional units of a network detection apparatus according to an embodiment of the present disclosure.

Detailed description of the invention

In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.

The following are detailed below.

The terms "first," "second," "third," and "fourth," etc. in the description and claims of this application and in the accompanying drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.

Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.

The electronic device according to the embodiment of the present application may be an electronic device with network detection capability, and the electronic device may include various handheld devices with wireless communication functions, vehicle-mounted devices, wearable devices, computing devices or other processing devices connected to a wireless modem, and various forms of User Equipment (UE), Mobile Stations (MS), terminal devices (terminal device), and the like.

The following describes embodiments of the present application in detail.

Referring to fig. 1A, fig. 1A is a schematic flowchart of a network detection method applied to an electronic device according to an embodiment of the present disclosure. The network detection method comprises the following steps:

s101, when detecting that a target game application sends a first game data packet to a server, the electronic equipment determines whether the first game data packet is a first target data packet.

In the prior art, the network delay for acquiring the game application is usually the game network delay situation reported by the game manufacturer acquired by the game application through a specific interface, that is, the game application judges the network delay by judging the characteristics of the transmitted or received game data packet, such as the size of the data packet, the transmitting and receiving frequency, and the like.

In the embodiment of the application, a first target data packet and a second target data packet are UDP data packets used for detecting network delay of a target game application, and meanwhile, because the data packets sent to the server by the target game application not only include the UDP data packets used for detecting the network delay of the target game application, but also include data packets with other purposes and types, when the target game application is detected to send the first game data packet to the server, whether the first data packet is the UDP data packet used for detecting the network delay needs to be determined.

S102, when the electronic equipment determines that the first game data packet is the first target data packet, recording a first time value for sending the first game data packet.

S103, when detecting that the target game application receives a second game data packet sent by the server, the electronic device determines whether the second game data packet is a second target data packet, wherein the second target data packet is a data packet sent to the target game application by the server after receiving the first target data packet.

The server sends a second target data packet for detecting network delay to the target game application only when receiving a first target data packet sent by the target game application, so that when detecting that the target game application receives the second game data packet sent by the server, whether the second game data packet is the second target data packet for detecting network delay needs to be determined.

S104, when the electronic equipment determines that the second game data packet is the second target data packet, recording a second time value of receiving the second game data packet.

S105, the electronic device calculates the network delay of the target game application according to the first time value and the second time value, and stores the calculation result of the network delay.

The network delay of the target game application can be obtained by recording a first time value T1 when the target game application is detected to send the first target data packet, recording a second time value T2 when the target game application is detected to receive the second target data packet, and calculating an absolute value | T2-T1| of a difference between the first time value and the second time value, wherein the first time value can be a time when the target game application sends the first target data packet, and the second time value can be a time when the target game application receives the second target data packet.

It can be seen that, in the embodiment of the present application, an electronic device first determines whether a first game data packet is a first target data packet when it is detected that a target game application sends the first game data packet to a server, then records a first time value for sending the first game data packet when it is determined that the first game data packet is the first target data packet, then determines whether a second game data packet is a second target data packet when it is detected that the target game application receives a second game data packet sent from the server, where the second target data packet is a data packet sent by the server to the target game application after receiving the first target data packet, then records a second time value for receiving the second game data packet when it is determined that the second game data packet is the second target data packet, and finally, calculating the network delay of the target game application according to the first time value and the second time value, and storing the calculation result of the network delay. The electronic equipment can record a first time value when the target game application sends the first target data packet and a second time value when the target game application receives the second target data packet, and the first target data packet and the second target data packet are both used for detecting the network delay of the target game application, so that the network delay of the target game application can be calculated by calculating the first time value and the second time value, and the network optimization of the target game application is facilitated.

In one possible example, the first destination packet and the second destination packet are User Datagram Protocol (UDP) packets for detecting a network delay of the destination game application, and the method further comprises: capturing a plurality of UDP data packets for detecting the target game application network delay, wherein the UDP data packets comprise a first target data packet and a second target data packet; obtaining effective data of the plurality of UDP data packets, wherein the effective data is data of the UDP data packets except the UDP message header; comparing the effective data of the plurality of UDP data packets, and determining first fixed data and second fixed data which have the same byte length and the same position and are contained in the plurality of effective data, wherein the first fixed data is associated with a first target data packet, and the second fixed data is associated with a second target data packet; determining the byte length of the first fixed data and the second fixed data as the specified byte length associated with the target game application, and determining the offset of the first byte data in the first fixed data and the second fixed data relative to the first byte data in the valid data as the specified offset.

The UDP message has no reliability guarantee, sequence guarantee, flow control field and the like, and is poor in reliability, but the control options of the UDP protocol are few, so that the delay in the data transmission process is small, the data transmission efficiency is high, the UDP message is suitable for application programs which do not need the reliability requirement or application programs which can guarantee the reliability, and the game application can detect the network delay through the UDP data packet. Each UDP message is divided into two parts of a UDP header and a UDP data area, the message consists of four 8-byte fields which respectively indicate a source port, a destination port, a message length and a check value of the message, and the UDP data area stores effective data of a UDP data packet.

In which valid data of UDP packets for detecting a game application network delay have the same characteristics, for example, as shown in fig. 1B and 1C, analyzing the UDP data packet sent by the target game application, it is found that the UDP data packet starts from the position offset by 4 bytes from the start of the valid data of the UDP data packet, 8 fixed bytes are 0000000100010003, in the UDP packet returned by the server, the position offset from the valid data of the UDP packet is 4 bytes, 8 fixed bytes are 000003 e 900040003, since UDP packets for different game applications are fixed in different byte lengths at different offset positions in the payload data, the size of the payload data is not constant, before the network delay detection method provided by the application is implemented, a large number of UDP data packets for detecting the network delay of the target game application are required to be grabbed, and analyzed to obtain the specified offset and the specified byte length corresponding to the target game application.

After capturing a large number of UDP data packets for detecting network delay of a target game application, further obtaining effective data in the UDP data packets, and comparing the effective data of the UDP data packets, thereby determining that the effective data contains the same byte length and the data with the same position are fixed data, determining that the byte length of the fixed data is the specified byte length associated with the target game application, and determining that the offset of the first byte data in the fixed data relative to the first byte length data of the effective data is the specified offset.

In this example, it can be seen that, by analyzing a large number of UDP packets, first fixed data in first valid data of a first target packet and second fixed data in second valid data of a second target packet can be determined, so that a specified byte length and a specified offset associated with a target game application can be determined according to the first fixed data and the second fixed data, which is beneficial to determining the first target packet and the second target packet in a process of sending and receiving packets by a target game.

In one possible example, the determining whether the first game data packet is a first target data packet comprises: acquiring first valid data in the first game data packet; acquiring first data with the byte length being the specified byte length from the specified offset position in the first effective data; when the first data is detected to be matched with the first fixed data, determining the first game data packet as the first target data packet.

When the target game application sends the first game data packet, first effective data of the first game data packet is obtained, then first data with the byte length being the specified byte length from the specified offset position is obtained, whether the first data is matched with the first fixed data is further detected, and if the first data is matched with the first fixed data, the first game data packet can be determined to be the first target data packet.

As can be seen, in this example, based on the first valid data of the first game data packet, detecting whether the first data of the specified byte length at the specified offset position matches the first fixed data, it can be determined whether the first game data packet is the first target data packet, and thus the first time value at which the target game application sends the first target data packet can be determined.

In one possible example, the determining whether the second game data packet is a second destination data packet includes: acquiring second effective data in the second game data packet; acquiring second data with the byte length being the specified byte length from the specified offset position in the second effective data; when the second data is detected to be matched with the second fixed data, determining the second game data packet as the second target data packet.

When the target game application receives the second game data packet, the second effective data of the second game data packet is obtained first, then the second data with the byte length being the specified byte length from the specified offset position is obtained, whether the second data is matched with the second fixed data is further detected, and if the second data is matched with the second fixed data, the second game data packet can be determined to be the second target data packet.

As can be seen, in this example, based on the second valid data of the second game data packet, detecting whether the second data of the specified byte length at the specified offset position matches the second fixed data, it can be determined whether the second game data packet is a second target data packet, and thus a second time value for the target game application to send the second target data packet can be determined.

In one possible example, after calculating the network delay of the target gaming application based on the first time value and the second time value, the method further comprises: setting the first time value to zero.

It can be seen that in this example, the network delay of the current target gaming application can be determined based on the difference between the first time value and the second time value, and after the network delay of the target gaming application is calculated, the first time value can be set to zero for the next time the network delay is calculated.

In one possible example, after the setting the first time value, the method further comprises: upon detecting that the target gaming application sends a third game data packet to the server, the third game data packet being a UDP data packet used to detect network latency of the target gaming application, determining whether the first time value is zero; and when the first time value is not zero, determining that a data packet loss occurs, wherein the data packet loss is used for indicating that the target game application does not receive a second game data packet sent by the server.

If the third game data packet is detected to be sent to the server by the target game application and is a UDP (user Datagram protocol) data packet for detecting network delay of the target game application, determining whether the first time value is zero, and if the first time value is detected to be not zero, indicating that the second target data packet sent by the server is not received after the first target data packet is possibly sent by the target game application, namely data packet loss occurs. When packet loss occurs, the network delay may be determined according to a preset time, for example, if the packet loss occurs, the network delay is considered to be 500 milliseconds.

As can be seen, in this example, since the first time value is set to zero after the network delay of the target game application is calculated according to the first time value and the second time value, when it is detected that the target game application sends the UDP packet for detecting the network delay to the server again, it is possible to determine whether the data packet loss occurs by detecting whether the first time value is zero.

In one possible example, after calculating the network delay of the target gaming application based on the first time value and the second time value, the method further comprises: calculating the network delay of the target game application for multiple times, and acquiring calculation results of the multiple network delays; determining a network quality of the target game application according to the plurality of calculation results; and outputting a prompt message when the network quality of the target game application is detected not to meet the preset condition.

The target game application periodically sends the UDP data packets for detecting the network delay to the server, so that the network delay of the target game application can be continuously calculated for multiple times, the calculation results of the multiple calculations are obtained, the network quality of the target game application is determined according to the calculation results, and a prompt message is output to prompt a user when the current network quality does not meet the preset condition. For example, the target game application is glory by the royal, when the network delay is greater than 150 milliseconds, the network delay is considered to be large, and if the network delay is greater than 150 milliseconds in 80 calculation results in 100 consecutive network delay calculations, the current network state is judged not to be good, and a prompt message for prompting the user whether to continue the game is output.

As can be seen, in this example, the current network quality is determined by calculating the network delay of the target game application multiple times, so that a prompt message for prompting the user for the current network state can be output when the network quality is not good, and the user can select whether to continue the game.

Referring to fig. 2, fig. 2 is a schematic flowchart of a network detection method according to an embodiment of the present application, and the method is applied to an electronic device. As shown in the figure, the network detection method includes:

s201, when detecting that a target game application sends a first game data packet to a server, the electronic device determines whether the first game data packet is a first target data packet.

S202, when the electronic equipment determines that the first game data packet is the first target data packet, recording a first time value for sending the first game data packet.

S203, when detecting that the target game application receives a second game data packet sent from the server, the electronic device determines whether the second game data packet is a second target data packet, where the second target data packet is a data packet sent to the target game application by the server after receiving the first target data packet.

S204, when the electronic equipment determines that the second game data packet is the second target data packet, recording a second time value of receiving the second game data packet.

S205, the electronic device calculates the network delay of the target game application according to the first time value and the second time value, and stores the calculation result of the network delay.

S206, the electronic equipment sets the first time value to zero.

It can be seen that, in the embodiment of the present application, an electronic device first determines whether a first game data packet is a first target data packet when it is detected that a target game application sends the first game data packet to a server, then records a first time value for sending the first game data packet when it is determined that the first game data packet is the first target data packet, then determines whether a second game data packet is a second target data packet when it is detected that the target game application receives a second game data packet sent from the server, where the second target data packet is a data packet sent by the server to the target game application after receiving the first target data packet, then records a second time value for receiving the second game data packet when it is determined that the second game data packet is the second target data packet, and finally, calculating the network delay of the target game application according to the first time value and the second time value, and storing the calculation result of the network delay. The electronic equipment can record a first time value when the target game application sends the first target data packet and a second time value when the target game application receives the second target data packet, and the first target data packet and the second target data packet are both used for detecting the network delay of the target game application, so that the network delay of the target game application can be calculated by calculating the first time value and the second time value, and the network optimization of the target game application is facilitated.

In addition, a network delay of the current target gaming application may be determined based on a difference between the first time value and the second time value, and after the network delay of the target gaming application is calculated, the first time value may be zeroed for the next calculation of the network delay.

Referring to fig. 3, fig. 3 is a flowchart illustrating a network detection method according to an embodiment of the present application, applied to an electronic device, where the electronic device enables multiple wireless communication links, consistent with the embodiments shown in fig. 1A and fig. 2. As shown in the figure, the network detection method includes:

s301, when detecting that a target game application sends a first game data packet to a server, the electronic device determines whether the first game data packet is a first target data packet.

S302, when the electronic device determines that the first game data packet is the first target data packet, recording a first time value for sending the first game data packet.

S303, when detecting that the target game application receives a second game data packet sent from the server, the electronic device determines whether the second game data packet is a second target data packet, where the second target data packet is a data packet sent to the target game application by the server after receiving the first target data packet.

S304, when the electronic device determines that the second game data packet is the second target data packet, recording a second time value of receiving the second game data packet.

S305, the electronic device calculates the network delay of the target game application according to the first time value and the second time value, and stores the calculation result of the network delay.

S306, the electronic equipment sets the first time value to zero.

S307, when detecting that the target game application sends a third game data packet to the server, and the third game data packet is a UDP data packet for detecting network delay of the target game application, the electronic device determines whether the first time value is zero.

S308, when the electronic device detects that the first time value is not zero, determining that a data packet loss occurs, where the data packet loss is used to indicate that the target game application does not receive a second game data packet sent by the server.

It can be seen that, in the embodiment of the present application, an electronic device first determines whether a first game data packet is a first target data packet when it is detected that a target game application sends the first game data packet to a server, then records a first time value for sending the first game data packet when it is determined that the first game data packet is the first target data packet, then determines whether a second game data packet is a second target data packet when it is detected that the target game application receives a second game data packet sent from the server, where the second target data packet is a data packet sent by the server to the target game application after receiving the first target data packet, then records a second time value for receiving the second game data packet when it is determined that the second game data packet is the second target data packet, and finally, calculating the network delay of the target game application according to the first time value and the second time value, and storing the calculation result of the network delay. The electronic equipment can record a first time value when the target game application sends the first target data packet and a second time value when the target game application receives the second target data packet, and the first target data packet and the second target data packet are both used for detecting the network delay of the target game application, so that the network delay of the target game application can be calculated by calculating the first time value and the second time value, and the network optimization of the target game application is facilitated.

In addition, a network delay of the current target gaming application may be determined based on a difference between the first time value and the second time value, and after the network delay of the target gaming application is calculated, the first time value may be zeroed for the next calculation of the network delay.

In addition, since the first time value is set to zero after the network delay of the target game application is calculated according to the first time value and the second time value, when it is detected that the target game application sends the UDP packet for detecting the network delay to the server again, it is possible to determine whether the data packet loss occurs by detecting whether the first time value is zero.

Consistent with the embodiments shown in fig. 1A, fig. 2, and fig. 3, please refer to fig. 4, and fig. 4 is a schematic structural diagram of an electronic device 400 provided in the embodiments of the present application, where the electronic device 400 runs one or more application programs and an operating system, and as shown in the figure, the electronic device 400 includes a processor 410, a memory 420, a communication interface 430, and one or more programs 421, where the one or more programs 421 are stored in the memory 420 and configured to be executed by the processor 410, and the one or more programs 421 include instructions for performing the following steps;

when detecting that a target game application sends a first game data packet to a server, determining whether the first game data packet is a first target data packet;

when the first game data packet is determined to be the first target data packet, recording a first time value for sending the first game data packet;

when the target game application is detected to receive a second game data packet sent by the server, determining whether the second game data packet is a second target data packet, wherein the second target data packet is a data packet sent to the target game application by the server after receiving the first target data packet;

when the second game data packet is determined to be the second target data packet, recording a second time value of receiving the second game data packet;

and calculating the network delay of the target game application according to the first time value and the second time value, and storing the calculation result of the network delay.

It can be seen that, in the embodiment of the present application, an electronic device first determines whether a first game data packet is a first target data packet when it is detected that a target game application sends the first game data packet to a server, then records a first time value for sending the first game data packet when it is determined that the first game data packet is the first target data packet, then determines whether a second game data packet is a second target data packet when it is detected that the target game application receives a second game data packet sent from the server, where the second target data packet is a data packet sent by the server to the target game application after receiving the first target data packet, then records a second time value for receiving the second game data packet when it is determined that the second game data packet is the second target data packet, and finally, calculating the network delay of the target game application according to the first time value and the second time value, and storing the calculation result of the network delay. The electronic equipment can record a first time value when the target game application sends the first target data packet and a second time value when the target game application receives the second target data packet, and the first target data packet and the second target data packet are both used for detecting the network delay of the target game application, so that the network delay of the target game application can be calculated by calculating the first time value and the second time value, and the network optimization of the target game application is facilitated.

In one possible example, the first target data packet and the second target data packet are User Datagram Protocol (UDP) data packets for detecting the target game application network delay; the instructions in the program are specifically configured to perform the following operations: capturing a plurality of UDP data packets for detecting the target game application network delay, wherein the UDP data packets comprise a first target data packet and a second target data packet; obtaining effective data of the plurality of UDP data packets, wherein the effective data is data of the UDP data packets except the UDP message header; comparing the effective data of the plurality of UDP data packets, and determining first fixed data and second fixed data which have the same byte length and the same position and are contained in the plurality of effective data, wherein the first fixed data is associated with a first target data packet, and the second fixed data is associated with a second target data packet; determining the byte length of the first fixed data and the second fixed data as the specified byte length associated with the target game application, and determining the offset of the first byte data in the first fixed data and the second fixed data relative to the first byte data in the valid data as the specified offset.

In one possible example, in the determining whether the first game data packet is a first target data packet, the instructions in the program are specifically configured to: acquiring first valid data in the first game data packet; acquiring first data with the byte length being the specified byte length from the specified offset position in the first effective data; when the first data is detected to be matched with the first fixed data, determining the first game data packet as the first target data packet.

In one possible example, in the determining whether the second game data packet is a second target data packet, the instructions in the program are specifically configured to: acquiring second effective data in the second game data packet; acquiring second data with the byte length being the specified byte length from the specified offset position in the second effective data; when the second data is detected to be matched with the second fixed data, determining the second game data packet as the second target data packet.

In one possible example, after calculating the network latency of the target gaming application based on the first time value and the second time value, the instructions in the program are specifically configured to: setting the first time value to zero.

In one possible example, after the zeroing of the first time value, the instructions in the program are specifically configured to: upon detecting that the target gaming application sends a third game data packet to the server, the third game data packet being a UDP data packet used to detect network latency of the target gaming application, determining whether the first time value is zero; and when the first time value is not zero, determining that a data packet loss occurs, wherein the data packet loss is used for indicating that the target game application does not receive a second game data packet sent by the server.

In one possible example, after calculating the network latency of the target gaming application based on the first time value and the second time value, the instructions in the program are specifically configured to: calculating the network delay of the target game application for multiple times, and acquiring calculation results of the multiple network delays; determining a network quality of the target game application according to the plurality of calculation results; and outputting a prompt message when the network quality of the target game application is detected not to meet the preset condition.

The above embodiments mainly introduce the scheme of the embodiments of the present application from the perspective of the method-side implementation process. It is understood that the electronic device comprises corresponding hardware structures and/or software modules for performing the respective functions in order to realize the above-mentioned functions. Those of skill in the art would readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.

In the embodiment of the present application, the electronic device may be divided into the functional units according to the method example, for example, each functional unit may be divided corresponding to each function, or two or more functions may be integrated into one processing unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit. It should be noted that the division of the unit in the embodiment of the present application is schematic, and is only a logic function division, and there may be another division manner in actual implementation.

Fig. 5 is a block diagram of functional units of the network detection apparatus 500 according to the embodiment of the present application. The network detection apparatus 500 is applied to an electronic device, and includes a processing unit 501 and a communication unit 502, wherein,

the processing unit 501 is configured to, when it is detected that a target game application sends a first game data packet to a server through the communication unit 502, determine whether the first game data packet is a first target data packet; and the first time value for sending the first game data packet is recorded when the first game data packet is determined to be the first target data packet; and is configured to determine whether a second game data packet sent by the server from the server after receiving the first target data packet is a second target data packet when detecting that the target game application receives the second game data packet through the communication unit 502; and recording a second time value of receiving the second game data packet when the second game data packet is determined to be the second target data packet; and the network delay is used for calculating the network delay of the target game application according to the first time value and the second time value, and the calculation result of the network delay is stored.

The network detection apparatus 500 may further include a storage unit 503 for storing program codes and data of the electronic device. The processing unit 501 may be a processor, the communication unit 502 may be a touch display screen or a transceiver, and the storage unit 503 may be a memory.

It can be seen that, in the embodiment of the present application, an electronic device first determines whether a first game data packet is a first target data packet when it is detected that a target game application sends the first game data packet to a server, then records a first time value for sending the first game data packet when it is determined that the first game data packet is the first target data packet, then determines whether a second game data packet is a second target data packet when it is detected that the target game application receives a second game data packet sent from the server, where the second target data packet is a data packet sent by the server to the target game application after receiving the first target data packet, then records a second time value for receiving the second game data packet when it is determined that the second game data packet is the second target data packet, and finally, calculating the network delay of the target game application according to the first time value and the second time value, and storing the calculation result of the network delay. The electronic equipment can record a first time value when the target game application sends the first target data packet and a second time value when the target game application receives the second target data packet, and the first target data packet and the second target data packet are both used for detecting the network delay of the target game application, so that the network delay of the target game application can be calculated by calculating the first time value and the second time value, and the network optimization of the target game application is facilitated.

In one possible example, the first target data packet and the second target data packet are User Datagram Protocol (UDP) data packets for detecting the target game application network delay; the processing unit 501 is specifically configured to: capturing a plurality of UDP data packets for detecting the target game application network delay, wherein the UDP data packets comprise a first target data packet and a second target data packet; the effective data is used for acquiring effective data of the plurality of UDP packets, and the effective data is data of the UDP packets except the UDP message header; the UDP data packet processing device is used for comparing the effective data of the UDP data packets and determining first fixed data and second fixed data which have the same byte length and the same position and are contained in the effective data, wherein the first fixed data is associated with a first target data packet, and the second fixed data is associated with a second target data packet; and the offset of the first byte data in the first fixed data and the second fixed data relative to the first byte data in the effective data is a designated offset.

In one possible example, in the aspect of determining whether the first game data packet is the first target data packet, the processing unit 501 is specifically configured to: acquiring first valid data in the first game data packet; the first effective data is used for acquiring first data with the byte length being the specified byte length from the specified offset position; and the data processing device is used for determining the first game data packet as the first target data packet when the first data is detected to be matched with the first fixed data.

In one possible example, in the determining whether the second game data packet is a second target data packet plane, the processing unit 501 is specifically configured to: acquiring second effective data in the second game data packet; the second effective data is used for acquiring second data with the byte length being the specified byte length from the specified offset position; and the second data processing unit is used for determining the second game data packet as the second target data packet when the second data is detected to be matched with the second fixed data.

In a possible example, after calculating the network delay of the target game application according to the first time value and the second time value, the processing unit 501 is specifically configured to: setting the first time value to zero.

In a possible example, after setting the first time value to zero, the processing unit 501 is specifically configured to: upon detecting that the target gaming application sends a third game data packet to the server, the third game data packet being a UDP data packet used to detect network latency of the target gaming application, determining whether the first time value is zero; and the server is used for determining that a data packet loss occurs when the first time value is detected to be not zero, wherein the data packet loss is used for indicating that the target game application does not receive a second game data packet sent by the server.

In a possible example, after calculating the network delay of the target game application according to the first time value and the second time value, the processing unit 501 is specifically configured to: calculating the network delay of the target game application for multiple times, and acquiring calculation results of the multiple network delays; and means for determining a network quality of the target gaming application based on the plurality of computational results; and the prompt message is output when the network quality of the target game application is detected not to meet the preset condition.

Embodiments of the present application also provide a computer storage medium, where the computer storage medium stores a computer program for electronic data exchange, the computer program enabling a computer to execute part or all of the steps of any one of the methods described in the above method embodiments, and the computer includes an electronic device.

Embodiments of the present application also provide a computer program product comprising a non-transitory computer readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the methods as described in the above method embodiments. The computer program product may be a software installation package, the computer comprising an electronic device.

It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.

In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.

In the embodiments provided in the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, the above-described division of the units is only one type of division of logical functions, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of some interfaces, devices or units, and may be an electric or other form.

The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.

In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.

The integrated unit may be stored in a computer readable memory if it is implemented in the form of a software functional unit and sold or used as a stand-alone product. Based on such understanding, the technical solution of the present application may be substantially implemented or a part of or all or part of the technical solution contributing to the prior art may be embodied in the form of a software product stored in a memory, and including several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the above-mentioned method of the embodiments of the present application. And the aforementioned memory comprises: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.

Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable memory, which may include: flash Memory disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.

The foregoing detailed description of the embodiments of the present application has been presented to illustrate the principles and implementations of the present application, and the above description of the embodiments is only provided to help understand the method and the core concept of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

19页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:虚拟场景展示方法、装置、计算机设备及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类