Connectivity detection method and device
Through the bidirectional asymmetric connectivity detection method, the problem of port mismatch caused by timing issues in ICE connectivity detection is solved, and efficient port-to-port connectivity detection is achieved to ensure normal communication of terminals.
Patent Information
- Application Number
- CN202310401237.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-13
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2043-04-13
AI Technical Summary
The existing ICE connectivity detection method has a timing problem, resulting in a one-to-one correspondence between the ports finally obtained, causing the terminal to be unable to connect.
A bidirectional asymmetric connectivity detection method is adopted. Regardless of whether the first terminal or the second terminal initiates the connectivity detection request first, the connectivity detection of the first terminal succeeds first. The connectivity of the port pair is confirmed through two handshakes, and the order of connectivity detection is clarified.
It effectively shortens the connectivity detection time, improves the connectivity detection efficiency, ensures the one-to-one correspondence of terminal port pairs, and avoids connectivity anomalies caused by timing problems.
Smart Images

Figure CN116566858B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a connectivity detection method and device. Background Art
[0002] Due to the scarcity of IPv4 ports and the need to reduce costs, Network Address Translation (NAT) traversal technology has emerged. Specifically, two subnet terminals located behind NAT, with the assistance of an intermediate server, conduct mutual network communication detection, thereby achieving direct subnet-to-subnet (P2P) network communication. During NAT traversal, ICE connectivity testing is performed, generally using the standard ICE_RFC protocol. However, current ICE connectivity testing methods may result in mismatched ports due to timing issues, which may lead to the two terminals undergoing connectivity testing being unable to connect. Summary of the Invention
[0003] The present application provides a connectivity detection method and device, which can solve the problem that the ports finally obtained do not correspond one to one due to timing problems.
[0004] To achieve the above objectives, the present application provides a connectivity detection method, which includes:
[0005] Regardless of whether the first terminal initiates the connectivity detection request first or the second terminal initiates the connectivity detection request first, the first terminal confirms that the connectivity detection is successful through interaction with the second terminal;
[0006] In response to the first terminal's connectivity detection being successful, the first terminal replies with a response message to the second terminal, so that the second terminal confirms the second terminal's connectivity detection being successful in response to the response message replied by the first terminal.
[0007] The step of replying a message from the first terminal to the second terminal in response to the first terminal successfully detecting connectivity, so that the second terminal confirms the success of the second terminal connectivity detection in response to the message replied by the first terminal, includes:
[0008] The first terminal replies a response message to the second terminal based on the port pair whose connectivity test succeeds first, so that the second terminal responds to the response message and confirms that the connectivity test of the port pair that succeeds first is successfully completed;
[0009] The method further includes: the first terminal communicating and interacting with the second terminal based on the first successful port pair.
[0010] Wherein, whether the first terminal initiates the connectivity detection request first or the second terminal initiates the connectivity detection request first, the first terminal confirms that the connectivity detection is successful through interaction with the second terminal, including:
[0011] In the case that the second terminal initiates the connectivity detection request first, in response to the connectivity detection request of the second terminal, the first terminal confirms that the connectivity detection is successful.
[0012] Wherein, whether the first terminal initiates the connectivity detection request first or the second terminal initiates the connectivity detection request first, the first terminal confirms that the connectivity detection is successful through interaction with the second terminal, which includes:
[0013] The first terminal and the second terminal exchange their respective ports to confirm a port pair of the first terminal and the second terminal.
[0014] Wherein, the port pair includes at least a first port pair and a second port pair;
[0015] The first terminal confirming that the connectivity test is successful in response to the connectivity test request of the second terminal when the second terminal first initiates the connectivity test request includes: confirming that the connectivity test of the first terminal is successful in response to the connectivity test request of the first port pair initiated by the second terminal;
[0016] Regardless of whether the first terminal initiates the connectivity detection request first or the second terminal initiates the connectivity detection request first, the first terminal confirms that the connectivity detection is successful through interaction with the second terminal, further comprising:
[0017] The first terminal sends a first connectivity detection request for a second port pair to the second terminal, so that the second terminal responds to the first connectivity detection request and sends a response message and a second connectivity detection request to the first terminal; the first terminal confirms that the connectivity detection of the first terminal is successful under the second port pair based on the first connectivity detection request and the response message.
[0018] Wherein, whether the first terminal initiates the connectivity detection request first or the second terminal initiates the connectivity detection request first, the first terminal confirms that the connectivity detection is successful through interaction with the second terminal, which includes:
[0019] The first terminal and the second terminal negotiate a port pair connectivity detection method to be adopted by each terminal; or,
[0020] The first terminal and the second terminal negotiate to confirm which terminal will be the terminal that completes the connectivity test first and which terminal will be the terminal that completes the connectivity test later; wherein, regardless of whether the first terminal initiates the connectivity test request first or the second terminal initiates the connectivity test request first, the terminal that completes the connectivity test first confirms that the connectivity test is successful before the terminal that completes the connectivity test later.
[0021] The first terminal and / or the second terminal is a symmetric network.
[0022] To achieve the above objectives, the present application also provides a connectivity detection method, which includes:
[0023] Regardless of whether the first terminal initiates the connectivity check request first or the second terminal initiates the connectivity check request first, the second terminal confirms that the connectivity check is successful in response to a response message sent by the first terminal, wherein the response message is sent when the first terminal confirms that the connectivity check is successful based on interaction with the second terminal. To achieve the above-mentioned purpose, the present application also provides a terminal comprising a processor; the processor is configured to execute instructions to implement the steps of the above-mentioned method.
[0024] To achieve the above objectives, the present application also provides a computer-readable storage medium for storing instructions / program data, which can be executed to implement the above method.
[0025] In the connectivity detection method of the present application, no matter whether the first terminal initiates a connectivity detection request or the second terminal initiates a connectivity detection request, the connectivity detection of the first terminal succeeds first. In this way, connectivity detection can be performed on at least two port pairs of the first terminal and the second terminal through a bidirectional asymmetric connectivity detection method, so that the order in which the connectivity detection of the first terminal and the second terminal is successful can be clearly determined, solving the problem of no one-to-one correspondence between the ports finally obtained due to timing issues. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0027] Figure 1 This is an interactive diagram of an implementation method of a port pair connectivity detection method of the present application;
[0028] Figure 2 This is an interactive diagram of another embodiment of the port pair connectivity detection method of the present application;
[0029] Figure 3This is an interactive diagram of another embodiment of the port pair connectivity detection method of the present application;
[0030] Figure 4 This is a flow diagram of another embodiment of the port pair connectivity detection method of the present application;
[0031] Figure 5 It is an interactive diagram of a bidirectional connectivity detection method;
[0032] Figure 6 It is an interactive diagram of a bidirectional connectivity detection method;
[0033] Figure 7 This is an interactive diagram of yet another embodiment of the port pair connectivity detection method of the present application;
[0034] Figure 8 This is an interactive diagram of another embodiment of the port pair connectivity detection method of the present application;
[0035] Figure 9 This is an interactive diagram of yet another implementation of the port pair connectivity detection method of the present application;
[0036] Figure 10 It is an interactive diagram of the connectivity detection method of the present application;
[0037] Figure 11 It is a schematic diagram of the interactive information in the connectivity detection method of the present application;
[0038] Figure 12 It is a flowchart of the connectivity detection method of this application;
[0039] Figure 13 This is a schematic diagram of the structure of an embodiment of the terminal of the present application;
[0040] Figure 14 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION
[0041] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative work are within the scope of protection of this application. In addition, unless otherwise specified (for example, "or in addition" or "or in an alternative"), the term "or" as used herein refers to a non-exclusive "or" (that is, "and / or"). Furthermore, the various embodiments described herein are not necessarily mutually exclusive, because some embodiments can be combined with one or more other embodiments to form new embodiments.
[0042] In related technologies, the Interactive Connectivity Establishment (ICE) method is as follows:
[0043] Step 1: Sort the port pairs in order of priority.
[0044] Step 2: Detect connectivity of at least some of the port pairs in order of priority.
[0045] Wherein, both terminals that need to establish a communication connection can perform connectivity detection on the port pair.
[0046] Taking the establishment of a communication connection between the first terminal and the second terminal as an example, the process of performing connectivity detection on the port pair can be as follows: Figure 1 As shown, the following steps are included:
[0047] ① The first terminal sends a connectivity check request (i.e., a STUN request) to the second terminal;
[0048] ② The second terminal replies with a response message (i.e., STUN response) to the first terminal;
[0049] ③ The second terminal sends a connectivity check request (i.e., STUN request) to the first terminal;
[0050] ④ The first terminal replies with a response message (ie, STUN response) to the second terminal.
[0051] After the 4-way handshake is completed, the first terminal and the second terminal both know that they can send (and receive) end-to-end messages in both directions, that is, the connectivity test of the port pair is successful.
[0052] Among them, STUN request can be abbreviated as SYN, and STUN response can be abbreviated as ACK.
[0053] As an optimization, Figure 2 As shown, once the second terminal receives the check message from the first terminal, it sends the connectivity check message and the response message to the first terminal of the same port pair. This speeds up the process of finding a valid port pair, which is called "TRIGGERED CHECK".
[0054] However, in the above-mentioned related technologies, each connectivity detection of a port pair requires at least three handshakes, and the connectivity detection time is relatively long.
[0055] Based on this, the present application proposes a port pair connectivity detection method, which can complete the connectivity detection of a port pair through two handshakes. Compared with the above-mentioned related technologies, it effectively shortens the connectivity detection time and improves the connectivity detection efficiency.
[0056] Specifically, if Figure 3 and Figure 4 As shown, the port pair connectivity detection method proposed in this application specifically includes the following steps. It should be noted that the following step numbers are only used to simplify the description and are not intended to limit the execution order of the steps. The steps of this embodiment can be changed in any order without violating the technical concept of this application.
[0057] S101: A second terminal sends a first connectivity detection request to a first terminal.
[0058] In this embodiment, the second terminal sends a first connectivity detection request to the first terminal, so that the first terminal can subsequently confirm that the connectivity detection of the first terminal is successful based on the first connectivity detection request, and reply to the second terminal with a first response message. In this way, the second terminal can subsequently confirm that the connectivity detection of the second terminal is successful in response to obtaining the first response message. Therefore, the connectivity detection method of this embodiment can complete the connectivity detection of a port pair through two handshakes, thereby effectively shortening the connectivity detection time and improving the connectivity detection efficiency.
[0059] Optionally, the second terminal sending the first connectivity detection request to the first terminal means that the second terminal sends a STUN request to the first terminal.
[0060] In the case where there are multiple pairs of connectable port pairs between the second terminal and the first terminal, that is, in the case where the second terminal and / or the first terminal have multiple communication ports, the second terminal sending a first connectivity detection request to the first terminal may mean: the second terminal sends the first connectivity detection request to a communication port of the first terminal through a communication port of the second terminal, so as to subsequently determine the connectivity detection results of a communication port of the second terminal and a communication port of the first terminal, thereby facilitating the subsequent determination of the final connection port pair of the second terminal and the first terminal based on the connectivity detection results of at least one port pair (i.e., the communication port pair) of the second terminal and the first terminal.
[0061] S102: The first terminal confirms that the connectivity check is successful based on the obtained first connectivity check request, and replies with a first response message to the second terminal.
[0062] After the second terminal sends the first connectivity detection request to the first terminal, the first terminal can confirm that the connectivity detection of the first terminal is successful based on the obtained first connectivity detection request, and reply a first response message to the second terminal, so that the second terminal can subsequently confirm that the connectivity detection of the second terminal is successful in response to the obtained first response message.
[0063] Optionally, the first terminal sending the first response message to the second terminal means that the second terminal sends a STUN response to the first terminal.
[0064] In the case where there are multiple port pairs (i.e., communication port pairs) between the second terminal and the first terminal, when the second terminal sends a first connectivity detection request to a communication port of the first terminal through a communication port of the second terminal, it can be determined that the connectivity detection of the first terminal under the port pair consisting of the communication port of the first terminal that receives the first connectivity detection request and the communication port of the second terminal that sends the first connectivity detection request is successful, and the first terminal can reply a first response message to the communication port of the second terminal that sends the first connectivity detection request through the communication port that receives the first connectivity detection request, so as to subsequently determine the connectivity detection result of the second terminal under the port pair, thereby facilitating the subsequent determination of the final connection communication port pair of the second terminal and the first terminal based on the connectivity detection result of at least one port pair of the second terminal and the first terminal.
[0065] S103: In response to receiving the first response message, the second terminal confirms that the connectivity check of the second terminal is successful.
[0066] After the first terminal replies with the first response message to the second terminal, the second terminal may confirm that the connectivity detection of the second terminal is successful in response to obtaining the first response message.
[0067] In the case where there are multiple port pairs between the second terminal and the first terminal, after the first terminal replies with a first response message to the communication port of the second terminal that sent the first connectivity check request through the communication port that received the first connectivity check request, the second terminal can confirm that the connectivity check is successful under the port pair formed by the communication port of the first terminal that received the first connectivity check request and the communication port of the second terminal that sent the first connectivity check request. In this way, the connectivity check result of one port pair of the second terminal can be determined, which facilitates the subsequent determination of the final connection port pair of the second terminal and the first terminal based on the connectivity check result of at least one port pair of the second terminal and the first terminal.
[0068] In this embodiment, the connectivity detection of a port pair can be completed through two handshakes. Compared with the above-mentioned related technologies, the connectivity detection time is effectively shortened and the connectivity detection efficiency is improved.
[0069] In addition, if Figure 5 As shown, Figure 5 This is a flowchart of bidirectional connectivity detection between two terminals in the related art.
[0070] During the two-way connectivity test between the two terminals,
[0071] 1) When the first terminal sends a connectivity check request first:
[0072] a) The first terminal sends a connectivity check request to the second terminal, and the first terminal starts the connectivity check;
[0073] b) The second terminal replies with a response message to the first terminal and simultaneously sends a connectivity detection request to the first terminal, and the second terminal starts the connectivity detection;
[0074] c) The first terminal receives a response message from the second terminal, and the connectivity detection of the first terminal is successful, and the first terminal replies with a response message to the second terminal;
[0075] d) The second terminal receives the response message from the first terminal, and the connectivity detection of the second terminal is successful.
[0076] 2) When the second terminal sends a connectivity check request first:
[0077] a) The second terminal sends a connectivity detection request to the first terminal, and the second terminal starts the connectivity detection;
[0078] b) The first terminal replies with a response message to the first terminal and simultaneously sends a connectivity detection request to the second terminal, and the first terminal starts the connectivity detection;
[0079] c) The second terminal receives the response message from the first terminal, the connectivity detection of the second terminal is successful, and the second terminal replies with a response message to the first terminal;
[0080] d) The first terminal receives a response message from the second terminal, and the connectivity detection of the first terminal is successful.
[0081] However, when multiple pairs of ports are performing ICE connectivity detection simultaneously, due to the inevitable network timing problem, in this process, no matter whether the first terminal detects first or the second terminal detects first, the two sides are symmetrical three-way handshakes, and the order of the first terminal and the second terminal's successful detection time is uncertain. Figure 6 In this case, the connection port pair finally selected by the first terminal and the second terminal may have the four situations shown in Table 1. Figure 6 As can be seen from Table 1, there are two types of connection port pairs that may cause communication abnormalities.
[0082] Table 1 Schematic diagram of the distribution of bidirectional ICE connectivity results of related technologies
[0083]
[0084] For example, using Scenario 2 in Table 1 as an example, since only one port after a successful connectivity test is used, for the first terminal, only the first port after the successful test is used, not the second port. For the second terminal, only the fourth port after the successful test is used, not the third port. In this case, the first port on the first terminal and the fourth port on the second terminal do not have a one-to-one correspondence, and connectivity is impossible. For the same reason, the second and third ports in Scenario 3 in Table 1 do not have a one-to-one correspondence, and connectivity is impossible.
[0085] In this related technology, the first terminal side (whose ports include the first port L1 and the second port L2) and the second terminal side (whose ports include the third port R1 and the fourth port R2) will respectively generate a set of candidate port pairs that require ICE connectivity detection (i.e., candidate information, which can be included in the attributes of the SDP Offer) according to a certain algorithm, such as Figure 6 The first port L1-third port R1 and the second port L2-fourth port R2 are shown as one-to-one port pairs. However, due to timing issues, the port pairs ultimately used by the first terminal and the second terminal may not correspond one-to-one, which may result in the final NAT port being unable to connect. This is shown in Table 1.
[0086] Based on this, the present application further proposes a connectivity detection method, in which the number of handshakes during the process of one of the first terminal and the second terminal initiating and successfully completing the connectivity detection is different from the number of handshakes during the process of the other of the first terminal and the second terminal initiating and successfully completing the connectivity detection. Moreover, regardless of whether the first terminal initiates the connectivity detection request or the second terminal initiates the connectivity detection request, the connectivity detection of one of the first terminal and the second terminal succeeds first. In this way, connectivity detection can be performed on at least two port pairs of the first terminal and the second terminal through a bidirectional asymmetric connectivity detection method, thereby clarifying the order in which the connectivity detection of the first terminal and the second terminal succeeds, solving the problem of the ports ultimately obtained not corresponding to each other due to timing issues.
[0087] In a first possible implementation, if the first terminal first initiates a connectivity detection request, such as Figure 2 In the three-way handshake interaction, the first terminal succeeds first; if the second terminal initiates a connectivity detection request first, such as Figure 3In the two-way handshake interaction, the first terminal succeeds first. Therefore, regardless of whether the first terminal initiates a connectivity check request or the second terminal initiates a connectivity check request, the first terminal's connectivity check succeeds first. When only one port is used after a successful connectivity check, the first and second terminals both use the port with the first successful connectivity check as the communication port. Since the first terminal's connectivity check succeeds first regardless of whether the first terminal initiates a connectivity check request or the second terminal initiates a connectivity check request, the communication ports selected by the first and second terminals are in a one-to-one correspondence, ensuring normal connectivity between the first and second terminals.
[0088] In a second possible implementation, if the first terminal first initiates a connectivity detection request, such as Figure 1 In the 4-way handshake interaction, the first terminal succeeds first; if the second terminal initiates a connectivity detection request first, such as Figure 3 In the two-way handshake interaction, the first terminal succeeds first. Therefore, regardless of whether the first terminal initiates a connectivity check request or the second terminal initiates a connectivity check request, the first terminal's connectivity check succeeds first. When only one port is used after a successful connectivity check, the first and second terminals both use the port with the first successful connectivity check as the communication port. Since the first terminal's connectivity check succeeds first regardless of whether the first terminal initiates a connectivity check request or the second terminal initiates a connectivity check request, the communication ports selected by the first and second terminals are in a one-to-one correspondence, ensuring normal connectivity between the first and second terminals.
[0089] In a third possible implementation, if the first terminal first initiates a connectivity detection request, such as Figure 7 In the two-way handshake interaction, the second terminal succeeds first; if the second terminal initiates a connectivity detection request first, such as Figure 8 In the three-way handshake interaction, the second terminal succeeds first. Therefore, regardless of whether the first terminal initiates a connectivity check request or the second terminal initiates a connectivity check request, the second terminal's connectivity check succeeds first. When only one port is used after a successful connectivity check, the first and second terminals both use the port with the first successful connectivity check as the communication port. Since the second terminal's connectivity check succeeds first regardless of whether the first terminal initiates a connectivity check request or the second terminal initiates a connectivity check request, the communication ports selected by the first and second terminals are in a one-to-one correspondence, ensuring normal connectivity between the first and second terminals.
[0090] In a fourth possible implementation, if the first terminal first initiates a connectivity detection request, such as Figure 7 In the two-way handshake interaction, the second terminal succeeds first; if the second terminal initiates a connectivity detection request first, such as Figure 9In the four-way handshake interaction, the second terminal succeeds first; thus, regardless of whether the first terminal initiates a connectivity check request or the second terminal initiates a connectivity check request, the second terminal's connectivity check succeeds first. When only one port is used after a successful connectivity check, the first and second terminals both use the port with the first successful connectivity check as the communication port. Furthermore, regardless of whether the first terminal initiates a connectivity check request or the second terminal initiates a connectivity check request, the second terminal's connectivity check succeeds first. Therefore, the communication ports selected by the first and second terminals are in a one-to-one correspondence, ensuring normal connectivity between the first and second terminals.
[0091] Taking the first implementation method mentioned above as an example, Figure 10 As shown, one embodiment of the connectivity detection method proposed in this application specifically includes the following steps. The first terminal includes at least a first port and a second port, and the second terminal includes at least a third port and a fourth port. It should be noted that the following step numbers are only used to simplify the description and are not intended to limit the order in which the steps are executed. The steps in this embodiment can be executed in any order without violating the technical principles of this application.
[0092] 201. A first terminal sends a first connectivity check request to a third port of a second terminal through a first port.
[0093] 202. In response to the first connectivity detection request, the second terminal sends a first response message and a second connectivity detection request to the first port of the first terminal through the third port.
[0094] 203. In response to the first response message and the second connectivity detection request, it is determined that the connectivity detection of the first port is successful, and the first terminal replies a second response message to the third port of the second terminal through the first port.
[0095] 204. In response to the second response message, determine that the third port connectivity detection is successful.
[0096] 205. The second terminal sends a third connectivity detection request to the second port of the first terminal through the fourth port.
[0097] 206. In response to the third connectivity detection request, the first terminal determines that the connectivity detection of the second port is successful, and the first terminal replies a third response message to the fourth port of the second terminal through the second port.
[0098] 207 . In response to the third response message, determine that the fourth port connectivity detection is successful.
[0099] The order of steps 201 and 205 is not restricted. As can be seen from steps 201-204 and 205-207, regardless of whether the first terminal initiates a connectivity check request first or the second terminal initiates a connectivity check request first, the first terminal's connectivity check succeeds first. Furthermore, regardless of whether the first terminal initiates a connectivity check request first or the second terminal initiates a connectivity check request first, after the first terminal's connectivity check succeeds, the first terminal will send a response message to the second terminal. The second terminal then determines whether the second terminal's connectivity check succeeded based on this handshake of the response message. Furthermore, if the connectivity check on the first port of the first terminal succeeds first, the first terminal will first send a response message to the third port of the second terminal via the first port, and then send a response message to the fourth port of the second terminal via the second port. In this way, the third port of the second terminal will receive the response message before the fourth port. Alternatively, if the connectivity check on the second port of the first terminal succeeds first, the first terminal will first send a response message to the fourth port of the second terminal via the second port, and then send a response message to the third port of the second terminal via the first port. In this way, the fourth port of the second terminal will receive the response message before the third port. It seems that in this embodiment, the port on which the connectivity test of the second terminal succeeds first must correspond one-to-one with the port on which the connectivity test of the first terminal succeeds first, thereby solving the problem that "due to timing problems, the port pairs finally adopted by the first terminal and the second terminal do not have a one-to-one correspondence, resulting in the inability of the NAT port finally obtained to be connected."
[0100] Since the first terminal and the second terminal will only use one port after the connectivity test is successful, in order to ensure the efficiency of the connectivity test, the first terminal and the second terminal will only complete the connectivity test once. In this embodiment, after the first terminal confirms that the connectivity test of a port is successful, it ends the connectivity test on the first terminal side. In this way, the first terminal can only send a response message to the port corresponding to the second terminal through this port. In this way, the second terminal will only receive the response message once, further ensuring that the port determined by the second terminal to have successfully connected to the communication port selected by the first terminal must correspond to the communication port selected by the first terminal, thereby avoiding the problem of the ultimately obtained NAT port being unable to connect due to timing issues.
[0101] In addition, before the first terminal and the second terminal initiate connectivity detection, the first terminal and the second terminal can first agree on the use of Figure 1 、 Figure 2 and Figure 3 Which method initiates connectivity detection?
[0102] In a feasible implementation, the first terminal may broadcast to inform the second terminal of the connectivity detection method it adopts, and the second terminal selects a connectivity detection method based on the content broadcast by the first terminal. Figure 1 The method shown initiates connectivity detection, and based on this broadcast content, the second terminal adopts Figure 3 For example, the first terminal broadcasts to inform the second terminal that it uses Figure 2 The method shown initiates connectivity detection, and based on this broadcast content, the second terminal adopts Figure 3 For example, the first terminal broadcasts to inform the second terminal that it uses Figure 7 The method shown initiates connectivity detection, and based on this broadcast content, the second terminal adopts Figure 8 The method shown initiates a connectivity check.
[0103] In another feasible implementation, the second terminal may broadcast to inform the first terminal of the connectivity detection method it adopts, and the first terminal selects a connectivity detection method based on the content broadcast by the second terminal. Figure 1 The method shown initiates connectivity detection, based on the broadcast content, the first terminal adopts Figure 3 For example, the first terminal broadcasts to inform the second terminal that it uses Figure 2 The method shown initiates connectivity detection, and based on this broadcast content, the second terminal adopts Figure 3 For example, the first terminal broadcasts to inform the second terminal that it uses Figure 7 The method shown initiates connectivity detection, and based on this broadcast content, the second terminal adopts Figure 8 The method shown initiates a connectivity check.
[0104] In another feasible implementation, the first terminal can broadcast to inform the first terminal of the connectivity detection method it can adopt, and the second terminal selects a method based on the content broadcast by the first terminal, that is, the connectivity detection method it can adopt. The second terminal broadcasts to inform the first terminal of the connectivity detection method it adopts, and the first terminal selects a connectivity detection method based on the content broadcast by the second terminal.
[0105] In another possible implementation, Figure 11 As shown, the first terminal and the second terminal can communicate via the auxiliary server to agree on the method to be adopted.
[0106] In one specific example, a first terminal sends information about its connectivity detection method to an auxiliary server; the auxiliary server forwards the first terminal's information to a second terminal; and the second terminal confirms its own connectivity detection method based on the connectivity detection method used by the first terminal. Of course, in other examples, the second terminal may initiate the process, where the second terminal first forwards the information about its connectivity detection method to the first terminal via the auxiliary server, allowing the first terminal to confirm its own connectivity detection method based on the connectivity detection method used by the second terminal.
[0107] In another specific example, a first terminal sends information about its available connectivity detection methods to a second terminal via an auxiliary server; the second terminal confirms its own connectivity detection method based on the first terminal's available connectivity detection methods and its own available connectivity detection methods; the second terminal forwards the information about its own connectivity detection method to the first terminal via the auxiliary server; the first terminal confirms its own connectivity detection method based on the connectivity detection method used by the second terminal. Of course, in other examples, the second terminal may initiate the process, i.e., the second terminal first forwards the information about its available connectivity detection methods to the first terminal via the auxiliary server, and then, based on the steps of the above method, agrees on the connectivity detection methods to be used by the first and second terminals.
[0108] In other possible implementations, before the first terminal and the second terminal initiate a connectivity test, the first and second terminals may agree on which terminal will complete the connectivity test first and which terminal will complete the connectivity test later. Regardless of whether the first terminal initiates the connectivity test request first or the second terminal initiates the connectivity test request first, the terminal that completes the connectivity test first confirms the success of the connectivity test before the terminal that completes the connectivity test later. For example, the first and second terminals may agree that the first terminal will complete the connectivity test first and the second terminal will complete the connectivity test later. Regardless of whether the first terminal initiates the connectivity test request first or the second terminal initiates the connectivity test request first, the first terminal confirms the success of the connectivity test through interaction with the second terminal. Then, in response to the first terminal's successful connectivity test, the first terminal sends a response message to the second terminal, so that the second terminal confirms the success of the second terminal's connectivity test in response to the response message sent by the first terminal.
[0109] In addition, if Figure 12As shown, before the first terminal and the second terminal initiate a connectivity test, the first terminal and the second terminal can first interact to confirm each other's ports. Specifically, the first terminal and the second terminal can exchange the IP and port after NAT, so that the first terminal and the second terminal can use the above-mentioned connectivity test method to perform connectivity test based on the obtained IP and port.
[0110] In one embodiment, if Figure 11 As shown, the first terminal and the second terminal can interact via the auxiliary server to confirm each other's ports. For example, the first terminal can send its own NATed IP and port to the auxiliary server; the auxiliary server sends the first terminal's NATed IP and port to the second terminal; and the second terminal will also forward its NATed IP and port to the first terminal via the auxiliary server.
[0111] In addition, before the first terminal and the second terminal initiate a connectivity test, the first terminal and the second terminal can each create at least one network socket. Each port of the first terminal corresponds to a network socket, and each port of the second terminal also corresponds to a network socket. In this way, when the first terminal and the second terminal perform a connectivity test, the port of the first terminal will send information to a port of the second terminal through the network socket corresponding to the port for connectivity testing, and the port of the second terminal will also send information to a port of the first terminal through the network socket corresponding to the port for connectivity testing.
[0112] The first terminal and / or the second terminal may be a symmetric network, i.e., each port of the first terminal and / or the second terminal corresponds to the network socket created thereby. Alternatively, the first terminal and / or the second terminal may be a conical network, i.e., multiple ports of the first terminal correspond to the same network socket, and / or multiple ports of the second terminal correspond to the same network socket.
[0113] When at least one of the first terminal and the second terminal is a symmetric network, if the relevant technology is used to perform connectivity detection, there may be a problem that the port pair ultimately used by the first terminal and the second terminal does not correspond one-to-one. Since each port of the symmetric network corresponds to a different network socket, if the ports ultimately used by the first terminal and the second terminal do not correspond one-to-one, the NAT ports ultimately obtained by the first terminal and the second terminal cannot be connected. Based on the connectivity detection method of the present application, the ports ultimately used by the first terminal and the second terminal can be made to correspond one-to-one, thereby solving the problem that the NAT ports ultimately obtained by the first terminal and the second terminal after the connectivity detection cannot be connected when at least one of the first terminal and the second terminal is a symmetric network.
[0114] To better illustrate the connectivity detection method of the present application, the following specific embodiment of connectivity detection is provided for illustrative purposes:
[0115] Assume that the network type of the L side is symmetric, create M network sockets on the L side, and generate a set of detection ports L1, L2...Lm. Each detection port in the set corresponds to a different network socket LF1, LF2...LFm.
[0116] The network type on the R side is not limited (both symmetric and conical types are acceptable). N network sockets are created on the R side, generating a set of detection ports R1, R2...Rn. The network socket corresponding to each detection port in the set can be the same or different RF1, RF2...RFn.
[0117] L1 sends a SYN probe message to R1 via LF1, L2 sends a SYN probe message to R2 via LF2... Lm sends a SYN probe message to Rm via LFm (the sending order can be simultaneous or sequential, or other rules can be used as needed).
[0118] R1 sends a SYN probe message to L1 via RF1, R2 sends a SYN probe message to L2 via RF2... Rn sends a SYN probe message to Ln via RFn (the sending order can be based on needs, sent simultaneously or sequentially, or according to other rules).
[0119] One example, such as Figure 10 As shown in the figure, if L2 receives the SYN message sent by R2, it determines that the connectivity test on the L side is successful, responds to the ACK message on the R2 side, and ends the ICE on the L side.
[0120] The R side receives the ACK message of the L2 response, determines that the R side connectivity test is successful, and ends the R side ICE.
[0121] Since only one address after a successful connectivity test is used, for the L side, only L2, which is detected first and succeeded, will be used, and L1 will not be used.
[0122] For the R side, only R2, which succeeds first, is used, and R1 is not used. At this time, L2 on the L side and R2 on the R side have a one-to-one correspondence, and connectivity is normal.
[0123] When both M and N are 2, that is, the L side has ports L1 and L2, and the R side has ports R1 and R2, the connectivity results of the connectivity detection method of the present application may be distributed as shown in Table 2:
[0124] Table 2 Schematic diagram of the distribution of bidirectional ICE connectivity results in one embodiment of the present application
[0125] Scene Number L Final selected address The address finally selected by R Is it possible to connect Optimized results one L1 R1 yes \ two L1 R2 no This scene no longer exists three L2 R1 no This scene no longer exists Four L2 R2 yes \
[0126] And combined Figure 10 It can be seen that:
[0127] 1) When the R side completes the connectivity test through R1, the L side must complete the connectivity test through L1.
[0128] 2) When the R side completes the connectivity test through R2, the L side must complete the connectivity test through L2.
[0129] 3) When the R side completes the connectivity test through R1 first, the L side must complete the connectivity test through L1 first.
[0130] 4) When the R side completes the connectivity test through R2 first, the L side must complete the connectivity test through L2 first.
[0131] In this way, the communication ports finally selected on the L side and the R side must correspond one to one.
[0132] See also Figure 13 , Figure 13 2 is a schematic diagram of the structure of an embodiment of a decoder of the present application. The decoder 20 includes a processor 22, which is configured to execute instructions to implement the above-mentioned prediction method and image decoding method. The specific implementation process is described in the above-mentioned embodiment and will not be repeated here.
[0133] The processor 22 may also be referred to as a CPU (Central Processing Unit). The processor 22 may be an integrated circuit chip having signal processing capabilities. The processor 22 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. A general-purpose processor may be a microprocessor, or the processor 22 may be any conventional processor.
[0134] The decoder 20 may further include a memory 21 for storing instructions and data required for the processor 22 to execute.
[0135] The processor 22 is configured to execute instructions to implement the method provided by any embodiment of the prediction method and image decoding method of the present application and any non-conflicting combination thereof.
[0136] See also Figure 14 , Figure 14Schematic diagram of the structure of the computer-readable storage medium in the embodiment of the present application. The computer-readable storage medium 30 of the embodiment of the present application stores instruction / program data 31, which, when executed, implements the method provided by any embodiment of the prediction method, image decoding method and image encoding method of the present application and any non-conflicting combination. Among them, the instruction / program data 31 can form a program file and be stored in the above-mentioned storage medium 30 in the form of a software product, so that a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) executes all or part of the steps of the various embodiments of the present application. The aforementioned storage medium 30 includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or terminal devices such as a computer, a server, a mobile phone, and a tablet.
[0137] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0138] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0139] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0140] The above is only an implementation method of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the description and drawings of this application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A connectivity detection method, characterized in that: The method comprises: The first terminal and the second terminal exchange their respective ports to confirm at least one port pair of the first terminal and the second terminal, where the at least one port pair includes at least a first port pair and a second port pair; Regardless of whether the first terminal initiates the connectivity detection request first or the second terminal initiates the connectivity detection request first, the first terminal confirms that the connectivity detection is successful through interaction with the second terminal; In response to a success of the connectivity detection of the first terminal, the first terminal replies with a response message to the second terminal, so that the second terminal confirms the success of the connectivity detection of the second terminal in response to the response message replied by the first terminal; Wherein, whether the first terminal initiates the connectivity detection request first or the second terminal initiates the connectivity detection request first, the first terminal confirming that the connectivity detection is successful through interaction with the second terminal includes: In a case where the second terminal initiates a connectivity detection request first, in response to the connectivity detection request for the first port pair initiated first by the second terminal, the first terminal confirms that the connectivity detection of the first terminal on the first port pair is successful; The first terminal sends a first connectivity detection request for the second port pair to the second terminal, so that the second terminal responds to the first connectivity detection request and sends a response message and a second connectivity detection request to the first terminal; The first terminal confirms, based on the second connectivity detection request and response message, that connectivity detection of the first terminal on the second port pair is successful.
2. The connectivity detection method according to claim 1, wherein: In response to the connectivity detection of the first terminal being successful, the first terminal replies with a response message to the second terminal, so that the second terminal confirms that the connectivity detection of the second terminal is successful in response to the response message replied by the first terminal, including: The first terminal replies to the second terminal with the response message based on the port pair whose connectivity test succeeds first, so that the second terminal responds to the response message and confirms that the connectivity test of the port pair that succeeds first is successfully completed; The method further comprises: The first terminal communicates and interacts with the second terminal based on the first successful port pair.
3. The connectivity detection method according to claim 1, wherein: Regardless of whether the first terminal initiates the connectivity detection request first or the second terminal initiates the connectivity detection request first, the first terminal confirms that the connectivity detection is successful through interaction with the second terminal, which includes: The first terminal and the second terminal negotiate a port pair connectivity detection method respectively adopted; Alternatively, the first terminal and the second terminal negotiate to determine which terminal serves as the terminal that completes the connectivity detection first and which terminal serves as the terminal that completes the connectivity detection later; Wherein, no matter whether the first terminal initiates the connectivity detection request first or the second terminal initiates the connectivity detection request first, the terminal that completes the connectivity detection first confirms that the connectivity detection is successful before the terminal that completes the connectivity detection later.
4. The connectivity detection method according to claim 1, wherein: The first terminal and / or the second terminal are / is a symmetric network.
5. A connectivity detection method, characterized in that: The method comprises: The second terminal and the first terminal exchange their respective ports to confirm at least one port pair of the second terminal and the first terminal, where the at least one port pair includes at least a first port pair and a second port pair; Regardless of whether the first terminal initiates the connectivity check request first or the second terminal initiates the connectivity check request first, the second terminal confirms, in response to a response message sent by the first terminal, that the connectivity check of the second terminal is successful, where the response message is sent when the first terminal confirms, based on interaction with the second terminal, that the connectivity check of the first terminal is successful; If the second terminal first initiates a connectivity detection request for the first port pair: after the second terminal sends the connectivity detection request for the first port pair to the first terminal, the second terminal receives a first response message from the first terminal in response to the connectivity detection request for the first port pair, and the second terminal confirms, in response to the first response message, that the connectivity detection for itself is successful under the first port pair, wherein the first response message is sent by the first terminal after confirming that the connectivity detection for itself is successful under the first port pair; If the first terminal first initiates a connectivity detection request for the second port pair, after the second terminal receives the first connectivity detection request for the second port pair sent by the first terminal, it sends a second response message and a second connectivity detection request to the first terminal, and then receives a third response message from the first terminal in reply based on the second response message and the second connectivity detection request. The second terminal confirms, in response to the third response message, that its connectivity detection on the second port pair is successful, wherein the third response message is sent by the first terminal after confirming that its connectivity detection on the second port pair is successful.
6. A terminal, characterized in that: The terminal includes a processor; the processor is configured to execute instructions to implement the steps of the method according to any one of claims 1 to 5.
7. A computer-readable storage medium having instructions / program data stored thereon, characterized in that: When the instructions / program data are executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Method for traversing Symmetric NAT (Network Address Translator) device by SIP (Session Initiation Protocol) based on ICE (Interactive Connectivity Establishment)
CN105827748A