Method for detecting network state of mobile terminal and related product thereof
By calculating the number of unanswered SYN packets on the mobile terminal and using a packet mapping table for initial and subsequent judgments, the cumbersome and time-consuming problems of existing TCP network detection methods are solved, achieving fast and accurate network status detection and improving the stability and reliability of network communication.
Patent Information
- Application Number
- CN202411225129.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-11-12
AI Technical Summary
Existing TCP network detection methods, such as the ping command, are cumbersome and time-consuming, affecting detection efficiency and failing to quickly identify abnormal network conditions.
By calculating the number of SYN packets that have not been replied to within a preset time period on the mobile terminal, and using the packet mapping table for initial and re-judgment, the detection parameters are dynamically adjusted to reduce false detections and improve detection accuracy and efficiency.
It enables fast and accurate network status detection, reduces false alarms, improves the stability and reliability of network communication, and simplifies user operations.
Smart Images

Figure CN118945082A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure generally relates to the field of network communication technology. More specifically, the present disclosure relates to a method for detecting a network status of a mobile terminal, a mobile terminal and a computer-readable storage medium. Background Art
[0002] The Transmission Control Protocol (TCP) is a connection-oriented protocol commonly used in network communications. It provides reliable data transmission services. During TCP communication, the network may encounter various abnormal conditions, which usually lead to connection interruption or data transmission failure. Detecting abnormal conditions of TCP networks is crucial to quickly locate and solve network problems and ensure the stability and reliability of network communications.
[0003] Currently, the ping command or the network detection tool CoNetServ integrated in the browser is usually used to detect abnormal status of the TCP network. However, the ping command is cumbersome to use, and some users cannot understand DOS commands, which affects the efficiency of network status detection. In addition, the detection time of the network detection tool CoNetServ is relatively long, so it is impossible to quickly detect whether the network is in an abnormal state.
[0004] In view of this, there is an urgent need to provide a solution for detecting the network status of a mobile terminal, so as to quickly detect abnormal network status, improve the efficiency of locating and solving network problems, and ensure the stability and reliability of network communications. Summary of the invention
[0005] In order to at least solve one or more of the technical problems mentioned above, the present disclosure proposes a solution for detecting the network status of a mobile terminal in the following aspects.
[0006] In a first aspect, the present disclosure provides a method for detecting a network status of a mobile terminal, comprising: at an end time of a first preset time length, calculating a first number of unreplied SYN messages of the mobile terminal within the first preset time length, and determining whether the first number is greater than a preset threshold; if the first number is greater than the preset threshold, delaying a second preset time length from the end time of the first preset time length to a second moment, determining whether the unreplied SYN messages within the first preset time length are replied within the second preset time length, so as to obtain the number of reply messages; based on the number of reply messages, recalculating the number of unreplied SYN messages within the first preset time length as a second number; determining whether the second number is greater than the preset threshold; if the second number is greater than the preset threshold, determining that the network connection of the mobile terminal is abnormal.
[0007] In some embodiments, at the end time of a first preset time length, a first number of unanswered SYN messages of the mobile terminal within the first preset time length is calculated, including: saving the message information within the first preset time length to a message mapping table, wherein the message mapping table includes a mapping key and a key value; and at the end time of the first preset time length, adding each key value in the message mapping table to obtain the first number of the unanswered SYN messages.
[0008] In some embodiments, saving the message information within the first predetermined time length to the message mapping table includes: when a SYN message is received, saving the combination of the source address, the destination address and the source port in the SYN message as a mapping key to the message mapping table, and adding 1 to the key value of the mapping key; when a SYN ACK message is received, using the combination of the destination address, the source address and the destination port in the SYN ACK message as a query key, and querying whether there is a mapping key in the message mapping table that is the same as the query key; and when there is a mapping key in the message mapping table that is the same as the query key, subtracting 1 from the key value of the mapping key that is the same as the query key.
[0009] In some embodiments, determining whether an unanswered SYN message within a first preset time length has a reply within a second preset time length includes: using a combination of a target address, a source address, and a target port in a SYN ACK message within the second preset time length as a query key, and querying whether there is a mapping key in the message mapping table that is the same as the query key; when there is a mapping key in the message mapping table that is the same as the query key, determining whether a SYN message corresponding to the mapping key that is the same as the query key has a reply within the second preset time length.
[0010] In some embodiments, recalculating the number of SYN messages not replied within the first preset time period as a second number based on the number of reply messages includes: calculating the difference between the first number and the number of reply messages, and determining the difference as the second number.
[0011] In some embodiments, the aforementioned method further includes: clearing the message mapping table; and entering a new detection cycle, and continuing to execute the end time of the first preset time length, calculating the first number of unanswered SYN messages of the mobile terminal within the first preset time length.
[0012] In some embodiments, the aforementioned method further includes: if the second number is less than or equal to the preset threshold, determining that the network connection of the mobile terminal is normal.
[0013] In some embodiments, the aforementioned method further includes: determining the number of network connection anomalies of the mobile terminal within a third preset time period; and adjusting the value of the second preset time period according to the number of network connection anomalies.
[0014] In a second aspect, the present disclosure provides a mobile terminal for detecting a network status, comprising: a processor; and a memory on which program instructions for detecting a network status are stored, and when the program instructions are executed by the processor, the method described in the first aspect and its multiple embodiments are implemented.
[0015] In a third aspect, the present disclosure provides a computer-readable storage medium storing program instructions for detecting a network status. When the program instructions are executed by a processor, the method described in the first aspect and its multiple embodiments are implemented.
[0016] By using the solution provided above for detecting the network status of the mobile terminal, the network status of the mobile terminal can be determined according to the number of SYN messages that the mobile terminal has not responded to within a preset time. Compared with the existing method for detecting abnormal network status, when the solution disclosed herein is used to detect the network status of the mobile terminal, there is no need for the user to manually input DOS commands or operate the network detection tool integrated in the browser. The detection process is convenient and fast, and the abnormal network status can be quickly detected, which helps to improve the efficiency of locating and solving network problems and enhance the stability and reliability of network communications.
[0017] Further, when determining the network status of the mobile terminal according to the number of SYN messages that the mobile terminal has not responded to within a preset time, a preset threshold can be pre-set according to actual needs, and the network status can be initially judged according to whether the first number of SYN messages that the mobile terminal has not responded to within the first preset time is greater than the preset threshold. When the first number is greater than the preset threshold, it can be preliminarily determined that the mobile terminal may have an abnormal network connection. In order to determine whether the abnormal network connection of the mobile terminal is a false detection, the second preset time can be delayed from the end time of the first preset time to the second moment, and it can be determined whether the unreplied SYN message within the first preset time is replied within the second preset time to obtain the number of reply messages. Then, according to the number of reply messages, the second number of SYN messages that have not responded within the first preset time can be recalculated, and the network status can be re-judged according to whether the second number is greater than the preset threshold. Finally, when the second number is greater than the preset threshold, it can be determined that the network connection is abnormal during movement. The present disclosure provides a detection method for initial judgment and re-judgment of the network status of a mobile terminal. By adopting the detection method of initial judgment and re-judgment of the network status of the mobile terminal, the occurrence of false detection can be reduced, which helps to improve the accuracy of detection.
[0018] Furthermore, in some embodiments, the second preset duration can be dynamically lengthened or shortened. Specifically, the value of the second preset duration can be adjusted according to the number of network connection anomalies of the mobile terminal within the third preset duration. When the number of network connection anomalies is always large, it indicates that the second preset duration may be set too short, resulting in the reply SYN ACK message not being received. At this time, the second preset duration can be appropriately lengthened. Conversely, when the number of network connection anomalies is always small, it indicates that the second preset duration may be set too long. At this time, the second preset duration can be shortened. Therefore, the scheme disclosed in the present invention realizes that the detection parameters can be adjusted according to the detection results of the network status, has good flexibility, and can improve the accuracy of the detection results, thereby ensuring the reliability and effectiveness of the detection results. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] By reading the detailed description below with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0020] Figure 1 is an exemplary flow chart showing a method for detecting a network status of a mobile terminal according to an embodiment of the present disclosure;
[0021] Figure 2 is an exemplary process diagram illustrating determining mapping keys and key values of a message mapping table according to an embodiment of the present disclosure;
[0022] Figure 3 is an exemplary process diagram showing whether an unanswered SYN message within a first preset time period is answered within a second preset time period according to an embodiment of the present disclosure;
[0023] Figure 4 is a schematic diagram showing an exemplary structure of a mobile terminal for detecting a network status according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0025] In order to facilitate understanding of the solution of the present disclosure, the SYN message, SYNACK message and Map data structure involved in the present disclosure are first introduced as an example.
[0026] Before the mobile terminal communicates with the server over the TCP network, it needs to use a three-way handshake to establish a TCP connection with the server. Specifically, the mobile terminal first sends a SYN (Synchronize Sequence Numbers) message to the server. Then the server sends a SYN ACK (Acknowledgement Number) message in response to the mobile terminal. Then, the mobile terminal returns an ACK packet to the server to complete a complete TCP connection. After that, the mobile terminal and the server can exchange data with each other.
[0027] As those skilled in the art know, the SYN message contains source IP (also known as source IP or source address), destination IP (also known as target IP or target address) and source port. The SYN ACK message is exactly the opposite of the SYN message, and contains destination IP (also known as target IP or target address), source IP (also known as source IP or source address) and destination port. Since the SYN message is sent from the mobile terminal to the server, the source IP is the mobile terminal IP, the destination IP is the server IP, and the source port is the port of the mobile terminal. The SYN ACK message is returned by the server to the mobile terminal, so the destination IP is the mobile terminal IP, the source IP is the server IP, and the destination port is the port of the mobile terminal. By comparison, it is found that the combination of source IP, destination IP and source port in the SYN message (i.e. sourceIP+destination IP+source port) and the combination of destination IP, source IP and destination port in the SYN ACK message (i.e. destination IP+source IP+destination port) are the same.
[0028] Map<String,Object> It is a very flexible data structure that allows strings to be used as keys to store any type of object as a value. This data structure is particularly useful when dealing with heterogeneous data because it can accommodate different types of values, such as primitive data types, objects, and arrays.
[0029] Based on this, the applicant has found through research that a Map data structure can be used to store message information. Specifically, the source IP+destination IP+source port in the SYN message can be saved as a mapping key KEY in the MAP object, and the key value of the mapping key KEY can be increased by 1 to obtain a message mapping table. Thereafter, the destination IP+source IP+destination port in the SYN ACK message can be used as a query key KEY to query the message mapping table to find out which SYN message this SYN ACK message is replying to. Furthermore, the key value of the mapping key KEY in the queried message mapping table can be reduced by 1. Thus, when determining the number of SYN messages that have not replied to the SYN ACK message, it can be obtained by adding the key value of each mapping key KEY in the message mapping table.
[0030] Figure 1 1 is an exemplary flow chart showing a method 100 for detecting the network status of a mobile terminal according to an embodiment of the present disclosure. It is understood that in order to achieve the purpose of real-time detection of the network status of the mobile terminal, the method 100 can be executed periodically and can be executed by any appropriate mobile terminal with data processing capabilities, such as but not limited to smart phones, personal computers, laptops, tablet computers, and portable wearable devices. Therefore, the embodiments of the present disclosure do not limit the specific type of mobile terminals.
[0031] like Figure 1 As shown in, at step S101, method 100 can calculate the first number of unanswered SYN messages of the mobile terminal within the first preset time period at the end time of the first preset time period, and determine whether the first number is greater than a preset threshold. In the scheme disclosed herein, unanswered is used to indicate the situation where no SYN ACK message in reply to the SYN message is received. Here, the first preset time period, the first number and the preset threshold are all non-negative integers. The first preset time period can take the start time of the current detection cycle as its start time, or the time when the first message is received in the current detection cycle as its start time.
[0032] It is understandable that those skilled in the art can select a specific value or value range of the preset threshold value based on the first preset duration. In other words, when those skilled in the art adjust the preset duration, the value of the preset threshold value should also be adaptively adjusted to ensure accurate detection of the network status of the mobile terminal. It is also understandable that those skilled in the art can also select specific values or value ranges of the first preset duration and the preset threshold value based on actual needs. For example, the first preset duration can be any value within [15s, 25s], and the preset threshold value can be any value within [5, 8]. The present disclosure does not make specific limitations in this regard.
[0033] In the scheme disclosed in the present invention, method 100 can adopt a receiving and saving method to save the message information of the SYN message and SYN ACK message received within the first preset time length to a message mapping table, and the message mapping table includes a mapping key and a key value. Thereafter, at the end time of the first preset time length, the key values in the message mapping table can be added to obtain the first number of unanswered SYN messages of the mobile terminal within the first preset time length. Based on the foregoing description, it can be known that the mapping keys and key values of the message mapping table here can be determined using the message information of the SYN message and SYN ACK message within the first preset time length of the mobile terminal. For ease of understanding, this will be described later in conjunction with Figure 2 Describe in detail how to determine the mapping key and key value of the message mapping table.
[0034] In the scheme disclosed herein, when the first number is less than or equal to the preset threshold, it indicates that the number of SYN messages that have not been responded to within the first preset time length is not large, and it can be determined that the network connection of the mobile terminal is normal. In this case, method 100 can enter the next detection cycle and re-execute step S101. When the first number is greater than the preset threshold, it indicates that the number of SYN messages that have not been responded to within the first preset time length is large, and the mobile terminal may have a network connection abnormality. In this case, method 100 can go to step S102 to continue execution, so as to re-judge the network status of the mobile terminal.
[0035] At step S102, when the first number is greater than the preset threshold, the method 100 can delay the second preset time from the end time of the first preset time to the second moment, and determine whether the unanswered SYN message within the first preset time has a reply within the second preset time, so as to obtain the number of reply messages. Here, the number of reply messages is the number of SYN messages that have not been replied within the first preset time and have a reply within the second preset time.
[0036] In actual applications, considering that at the end time of the first preset time, there may be a situation where a SYN message has just been received and the SYN ACK message in response to the SYN message has not yet been received. If the network status of the mobile terminal is directly determined as an abnormal network connection at this time, the accuracy of network status detection will be affected. Based on this, method 100 can delay the second preset time from the end time of the first preset time to the second moment, and determine whether the unanswered SYN message within the first preset time has been answered within the second preset time, so as to obtain the number of reply messages.
[0037] In the scheme of the present disclosure, the second preset duration and the second quantity are both non-negative integers. In actual operation, a SYN message can receive a SYN ACK message in response to it within approximately 300ms. Taking into account the situation of short-term signal difference, the second preset duration can be set to any value within [300ms, 2s]. It should be understood that the 300ms and 2s here are merely exemplary and illustrative, and those skilled in the art can select a specific value or range of values for the second preset duration according to actual needs, and the present disclosure does not specifically limit it.
[0038] In the scheme disclosed herein, method 100 can use a receiving and querying method to determine whether an unanswered SYN message within a first preset time period has a reply within a second preset time period. Specifically, the SYN ACK message received within the second preset time period can be compared with the SYN message that has not been replied within the first preset time period to determine whether an unanswered SYN message within the first preset time period has a reply within the second preset time period. Figure 3 A detailed description is given of how to determine whether an unanswered SYN message within a first preset time period has a reply within a second preset time period.
[0039] Next, at step S103, method 100 can recalculate the number of SYN messages that have not been replied within the first preset time period according to the number of reply messages as the second number. In one embodiment, the difference between the first number and the number of reply messages can be calculated and determined as the second number.
[0040] Next, method 100 may determine the network status of the mobile terminal according to the second number. In the solution disclosed herein, the network status of the mobile terminal includes normal network connection and abnormal network connection. When method 100 determines the network status of the mobile terminal according to the second number, step S104 may be performed first, and then step S105 or step S106 may be selected based on the processing result of step S104.
[0041] Specifically, at step S104, method 100 may determine whether the second number is greater than a preset threshold. When the second number is greater than the preset threshold, method 100 may proceed to step S105 for further execution; when the second number is less than or equal to the preset threshold, method 100 may proceed to step S106 for further execution. Specifically, at step S105, method 100 may determine that the network connection of the mobile terminal is abnormal. Conversely, at step S106, method 100 may determine that the network connection of the mobile terminal is normal.
[0042] Further, after determining that the network connection is abnormal during movement, method 100 may also generate network connection abnormality prompt information, and may output the network connection abnormality prompt information in a visual or audible manner. In one embodiment, the network connection abnormality prompt information may include source IP, destination IP and source port, and may also include an abnormality identifier. The abnormality identifier here may be an identifier in any form such as letters, numbers or symbols, and the present disclosure does not make specific limitations in this regard.
[0043] Combination of the above Figure 1 A method 100 for detecting the network status of a mobile terminal is described. Through the method 100, a detection method for initial judgment and re-judgment of the network status of the mobile terminal is provided, which can reduce the occurrence of false detections and help improve the accuracy of detection. On the other hand, there is no need for the user to manually input DOS commands or operate the network detection tool integrated in the browser. The detection process is convenient and fast, and the abnormal status of the network can be quickly detected, which helps to improve the efficiency of locating and solving network problems and enhance the stability and reliability of network communications.
[0044] In the scheme disclosed herein, after completing the current network status detection and before entering the next network status detection, method 100 can first clear the message mapping table so as to save the message information of the new detection cycle to the message mapping table, thereby reducing the impact of historical message information on the detection accuracy of the current network status of the mobile terminal and improving the timeliness of the network status detection.
[0045] In order to improve the flexibility of method 100, in the solution disclosed herein, method 100 can also lengthen or shorten the second preset duration according to the number of abnormal states of the mobile terminal. Specifically, when the number of abnormal states is always large, it indicates that the first preset duration may be set too short, resulting in the reply SYN ACK message not being received. In this case, the first preset duration can be appropriately lengthened. On the contrary, when the number of abnormal states is always small, it indicates that the first preset duration may be set too long. In this case, the first preset duration can be shortened.
[0046] In actual operation, method 100 may first determine the number of times the network state of the mobile terminal is in an abnormal state within the third preset time period. Thereafter, the value of the second preset time period may be adjusted according to the number of times the abnormal state occurs. It should be understood that those skilled in the art may select a specific value or value range of the third preset time period according to actual needs, and the present disclosure does not specifically limit this. Thus, the scheme disclosed herein realizes that the detection parameters can be adjusted according to the detection results of the network state, has good flexibility, and can improve the accuracy of the detection results, thereby ensuring the reliability and effectiveness of the detection results.
[0047] Next, combine Figure 2 The process 200 of determining the mapping key and key value of the message mapping table according to the embodiment of the present disclosure is exemplarily introduced. Figure 2 The description is a specific implementation of the aforementioned method of storing the message information of the SYN message and the SYN ACK message received within the first preset time length into the message mapping table. Figure 1 The features described in can be applied analogously here.
[0048] like Figure 2 As shown, at step S201, process 200 can monitor whether a message is received. When a message is received, process 200 can flow to step S202 to determine whether the message is a SYN message. On the one hand, when it is determined that the message is a SYN message, process 200 can transfer to step S203 to continue execution. On the other hand, when it is determined that the message is not a SYN message, process 200 can transfer to step S204 to continue execution.
[0049] At step S203, the process 200 can save the combination of source IP, destination IP and sourceport in the SYN message as a mapping key to the message mapping table, and increase the key value of the mapping key by 1. Here, the initial value of the key value is 0.
[0050] At step S204, process 200 may determine whether the message is a SYN ACK message. Further, when it is determined that the message is a SYN ACK message, process 200 may proceed to step S205 for continued execution. At step S205, process 200 may use the combination of destination IP, source IP, and destination port in the SYNACK message as a query key (for distinction, it may be referred to as a first query key), and query whether there is a mapping key in the message mapping table that is the same as the query key. When there is a mapping key in the message mapping table that is the same as the query key, process 200 may proceed to step S206 for continued execution, so as to reduce the key value of the mapping key that is the same as the query key by 1.
[0051] Next, combine Figure 3 The process 300 of judging whether a SYN message that has not been replied to within a first preset time period has been replied to within a second preset time period according to the embodiment of the present disclosure is exemplarily introduced. Figure 3 The description is a specific implementation of the aforementioned determination of whether a SYN message that has not been replied within the first preset time length has been replied within the second preset time length. Figure 1 The features described in can be applied analogously here.
[0052] like Figure 3 As shown, at step S301, process 300 may determine whether the message received within the second preset time period is a SYN ACK message. When the received message is a SYN ACK message, process 300 may continue to execute step S302.
[0053] At step S302, process 300 may use the combination of the destination address, source address and destination port in the SYN ACK message as a query key (for distinction, may be referred to as a second query key), and query whether there is a mapping key in the message mapping table that is the same as the query key.
[0054] When there is a mapping key in the message mapping table that is the same as the query key, process 300 may execute step S303. At step S303, process 300 may reduce the key value of the mapping key that is the same as the query key by 1, and determine whether the SYN message corresponding to the mapping key that is the same as the query key has a reply within the second preset time length.
[0055] In the scheme disclosed herein, by repeatedly executing step S301, step S302 and step S303, the number of SYN messages that have not been replied within the first preset time and have been replied within the second preset time can be determined, and the number of SYN messages that have not been replied within the first preset time and have not been replied within the second preset time can also be determined. Further, for SYN messages that have not been replied within both the first preset time and the second preset time, the target address of the network connection anomaly can be determined according to the source IP+destination IP+source port in the mapping key, thereby locating the network connection anomaly and improving the efficiency of solving network connection problems.
[0056] Next, combine Figure 4 The mobile terminal 400 for detecting the network status provided by the embodiment of the present disclosure is introduced as an example. Figure 4 As described above, the mobile terminal 400 of the embodiment of the present disclosure includes a processor 401 , a memory 402 , and a communication bus 403 .
[0057] In the process of a specific embodiment, the processor 401 may be at least one of an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing image processing device (DSPD), a programmable logic image processing device (PLD), a field programmable gate array (FPGA), a CPU, a controller, a microcontroller, and a microprocessor. It can be understood that for different devices, the electronic device used to implement the above-mentioned processor function can also be other, which is not specifically limited in this embodiment.
[0058] In the embodiment of the present disclosure, the communication bus 403 is used to realize the connection and communication between the processor 401 and the memory 402; the memory 402 stores program instructions for displaying desktop icons; when the processor 401 executes the program instructions stored in the memory 402, the present disclosure is realized in combination with the attached Figures 1 to 3 The described method for detecting network status and multiple embodiments thereof.
[0059] Combination of the above Figure 4 A mobile terminal for detecting network status that can be used to perform the present disclosure is described. It should be understood that the terminal structure or architecture here is only exemplary, and the implementation method and implementation entity of the present application are not limited thereto, but can be changed without departing from the spirit of the present application.
[0060] It is understandable that the description of each embodiment in this disclosure emphasizes the differences between the embodiments, and the same or corresponding parts can be referenced to each other. For the purpose of brevity, this disclosure will not repeat them one by one.
[0061] It should be understood that when the terms "first", "second", "third" and "fourth" are used in the claims, the specification and the drawings of the present application, they are only used to distinguish different objects, rather than to describe a specific order. The terms "include" and "comprise" used in the specification and claims of the present application indicate the presence of the described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or their collections.
[0062] It should also be understood that the terms used in this disclosure are only for the purpose of describing specific embodiments and are not intended to limit the disclosure. As used in this disclosure and claims, the singular forms of "a", "an", and "the" are intended to include the plural forms unless the context clearly indicates otherwise. It should also be further understood that the term "and / or" used in this disclosure and claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations.
[0063] As used in this specification and claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0064] According to the above description in combination with the accompanying drawings, those skilled in the art can also understand that the embodiments of the present application can also be implemented by a software program. Therefore, the present application also provides a computer-readable storage medium. The computer-readable storage medium can be used to implement the present application in combination with the accompanying drawings. Figure 1-Figure 3 The described method is used to detect the network status.
[0065] It should be noted that although the operations of the method of the present application are described in a specific order in the accompanying drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. On the contrary, the steps depicted in the flow chart can be performed in a different order. Additionally or alternatively, some steps can be omitted, multiple steps can be combined into one step, and / or one step can be decomposed into multiple steps.
[0066] The embodiments of the present disclosure are described in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present disclosure. The description of the above embodiments is only used to help understand the method and its core idea of the present disclosure. At the same time, changes or deformations made by those skilled in the art based on the ideas of the present disclosure, the specific implementation methods and the scope of application of the present disclosure, all belong to the scope of protection of the present disclosure. In summary, the content of this specification should not be understood as a limitation on the present disclosure.
Claims
1. A method for detecting a network status of a mobile terminal, comprising: At the end time of the first preset time length, calculating a first number of unanswered SYN messages of the mobile terminal within the first preset time length, and determining whether the first number is greater than a preset threshold; If the first number is greater than a preset threshold, delaying a second preset time period from the end time of the first preset time period to a second moment, determining whether the unanswered SYN message within the first preset time period has a reply within the second preset time period, so as to obtain the number of reply messages; Recalculate the number of SYN messages that have not been replied within the first preset time period according to the number of reply messages as a second number; determining whether the second number is greater than the preset threshold; If the second number is greater than the preset threshold, it is determined that the network connection of the mobile terminal is abnormal.
2. The method according to claim 1, wherein: At the end time of the first preset time, calculating a first number of unanswered SYN messages of the mobile terminal within the first preset time, including: Saving the message information within the first preset time length to a message mapping table, wherein the message mapping table includes a mapping key and a key value; and At the end time of the first preset duration, each key value in the message mapping table is added to obtain a first number of the unreplied SYN messages.
3. The method according to claim 2, wherein: Saving the message information within the first predetermined time period to the message mapping table includes: When a SYN message is received, the combination of the source address, the destination address and the source port in the SYN message is saved as a mapping key in the message mapping table, and the key value of the mapping key is increased by 1; When a SYN ACK message is received, a combination of a target address, a source address and a target port in the SYN ACK message is used as a query key, and a query is made as to whether there is a mapping key in the message mapping table that is the same as the query key; and When there is a mapping key in the message mapping table that is the same as the query key, the key value of the mapping key that is the same as the query key is reduced by 1.
4. The method according to claim 2, wherein: Determining whether the unanswered SYN message within the first preset time period is answered within the second preset time period includes: Using the combination of the destination address, source address and destination port in the SYN ACK message within the second preset time as a query key, and querying whether there is a mapping key in the message mapping table that is the same as the query key; When a mapping key in the message mapping table is the same as the query key, it is determined that a SYN message corresponding to the mapping key that is the same as the query key has a reply within the second preset time length.
5. The method according to claim 4, wherein: Recalculating the number of SYN messages that have not been replied to within the first preset time period according to the number of reply messages, as a second number, includes: Calculate the difference between the first number and the number of reply messages, and determine the difference as the second number.
6. The method according to claim 4, further comprising: Clearing the message mapping table; as well as Entering a new detection cycle, and continuing to execute the end time of the first preset time length, calculating the first number of unanswered SYN messages of the mobile terminal within the first preset time length.
7. The method according to claim 1, further comprising: If the second number is less than or equal to the preset threshold, it is determined that the network connection of the mobile terminal is normal.
8. The method according to claim 7, further comprising: Determining the number of network connection anomalies of the mobile terminal within a third preset time period; as well as The value of the second preset duration is adjusted according to the number of network connection anomalies.
9. A mobile terminal for detecting a network status, comprising: Processor; and A memory having program instructions for detecting a network status stored thereon, wherein when the program instructions are executed by a processor, the method according to any one of claims 1-8 is implemented.
10. A computer-readable storage medium storing program instructions for detecting a network status, wherein when the program instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.
